Changeset 6982
- Timestamp:
- 06/14/07 22:58:59
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
OpenSceneGraph-Data/trunk/shaders/overlay_perspective_main.frag
r6976 r6982 4 4 uniform float y0; 5 5 6 #if 1 7 vec4 warp(in vec4 source) 6 vec2 warp(in vec2 source) 8 7 { 9 8 float inv_divisor = 1.0 / (source.y + y0); 10 return vec 4(source.x * (1.0 + y0 ) * inv_divisor , (source.y * y0 + 1.0 ) * inv_divisor, source.z, source.w);9 return vec2(source.x * (1.0 + y0 ) * inv_divisor , (source.y * y0 + 1.0 ) * inv_divisor); 11 10 } 12 #else13 vec4 warp(in vec4 source)14 {15 return source;16 }17 #endif18 11 19 12 void main() 20 13 { 21 vec 4 coord = gl_TexCoord[1];14 vec2 coord = gl_TexCoord[1].xy; 22 15 coord.x = coord.x*2.0 - 1.0; 23 16 coord.y = coord.y*2.0 - 1.0; 24 17 25 vec 4warped = warp(coord);18 vec2 warped = warp(coord); 26 19 warped.x = (warped.x + 1.0)*0.5; 27 20 warped.y = (warped.y + 1.0)*0.5; 28 21 29 22 vec4 base_color = texture2D(texture_0, gl_TexCoord[0].xy); 30 vec4 overlay_color = texture2D(texture_1, warped .xy);23 vec4 overlay_color = texture2D(texture_1, warped ); 31 24 vec3 mixed_color = mix(base_color.rgb, overlay_color.rgb, overlay_color.a); 32 25 gl_FragColor = vec4(mixed_color, base_color.a); OpenSceneGraph-Data/trunk/shaders/overlay_perspective_rtt.vert
r6976 r6982 1 1 uniform float y0; 2 uniform bool lightingEnabled; 2 3 3 4 #if 15 4 vec4 warp(in vec4 source) 6 5 { 7 6 float divisor = source.y + y0; 8 return vec4(source.x * (1.0 + y0 ), source.y * y0 + 1.0, (source.z * y0 + 1.0)*0.0 5, source.w * divisor);7 return vec4(source.x * (1.0 + y0 ), source.y * y0 + 1.0, (source.z * y0 + 1.0)*0.01, source.w * divisor); 9 8 } 10 #else11 vec4 warp(in vec4 source)12 {13 return source;14 }15 #endif16 9 17 10 … … 54 47 gl_Position = warp(ftransform()); 55 48 56 vec4 ambient = vec4(0.0); 57 vec4 diffuse = vec4(0.0); 58 vec4 specular = vec4(0.0); 59 60 vec3 normal = fnormal(); 61 62 directionalLight(0, normal, ambient, diffuse, specular); 49 if (lightingEnabled) 50 { 51 vec4 ambient = vec4(0.0); 52 vec4 diffuse = vec4(0.0); 53 vec4 specular = vec4(0.0); 63 54 64 vec4 color = gl_FrontLightModelProduct.sceneColor +65 ambient * gl_FrontMaterial.ambient +66 diffuse * gl_FrontMaterial.diffuse +67 specular * gl_FrontMaterial.specular;68 55 69 #if 0 70 if (gl_Position.y < 0.0) color.r = 0.0; 71 if (gl_Position.x < 0.0) color.g = 0.0; 72 #endif 73 gl_FrontColor = color; 74 56 vec3 normal = fnormal(); 57 58 directionalLight(0, normal, ambient, diffuse, specular); 59 60 vec4 color = gl_FrontLightModelProduct.sceneColor + 61 ambient * gl_FrontMaterial.ambient + 62 diffuse * gl_FrontMaterial.diffuse + 63 specular * gl_FrontMaterial.specular; 64 65 gl_FrontColor = color; 66 67 } 68 else 69 { 70 gl_FrontColor = gl_Color; 71 } 75 72 76 73 }
