Changeset 6963

Show
Ignore:
Timestamp:
06/13/07 20:22:19
Author:
robert
Message:

Improved overlay shaders

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • OpenSceneGraph-Data/trunk/shaders/overlay_perspective_main.frag

    r6959 r6963  
    22uniform sampler2D texture_1; 
    33 
    4 uniform float y0; 
    5 uniform float inverse_one_minus_y0; 
     4uniform float exponent_scale; 
     5uniform float exponent_offset; 
     6 
     7#if 1 
     8vec4 warp(in vec4 source) 
     9
     10    float divisor = exp2(source.y); 
     11    return vec4(source.x/divisor, source.y, source.z, source.w); 
     12
     13#else 
     14vec4 warp(in vec4 source) 
     15
     16    return source; 
     17
     18#endif 
    619 
    720void main() 
    821{ 
     22    vec4 coord = gl_TexCoord[1]; 
     23    coord.x = coord.x*2.0 - 1.0; 
     24    coord.y = coord.y*2.0 - 1.0; 
     25     
     26    vec4 warped = warp(coord); 
     27    warped.x = (warped.x + 1.0)*0.5; 
     28    warped.y = (warped.y + 1.0)*0.5; 
     29     
    930    vec4 base_color = texture2D(texture_0, gl_TexCoord[0].xy); 
    10     vec4 overlay_color = texture2D(texture_1, gl_TexCoord[1].xy); 
     31    vec4 overlay_color = texture2D(texture_1, warped ); 
    1132    vec3 mixed_color = mix(base_color.rgb, overlay_color.rgb, overlay_color.a); 
    1233    gl_FragColor = vec4(mixed_color, base_color.a); 
  • OpenSceneGraph-Data/trunk/shaders/overlay_perspective_rtt.vert

    r6959 r6963  
    1 uniform float y0
    2 uniform float inverse_one_minus_y0
     1uniform float exponent_offset
     2uniform float exponent_scale
    33 
    44vec3 fnormal(void) 
     
    3737} 
    3838 
     39#if 1 
     40vec4 warp(in vec4 source) 
     41{ 
     42    float divisor = exp2(source.y/source.w); 
     43    return vec4(source.x/divisor, source.y, source.z, source.w); 
     44} 
     45#else 
     46vec4 warp(in vec4 source) 
     47{ 
     48    return source; 
     49} 
     50#endif 
     51 
    3952void main() 
    4053{ 
    41     gl_Position = ftransform(); 
     54    gl_Position = warp(ftransform()); 
    4255     
    4356    vec4 ambient = vec4(0.0); 
     
    5568         
    5669    gl_FrontColor = color; 
     70    gl_FrontColor.x = 0.0; 
    5771}