Changeset 6976

Show
Ignore:
Timestamp:
06/14/07 19:07:23
Author:
robert
Message:

Improved shaders

Files:

Legend:

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

    r6963 r6976  
    22uniform sampler2D texture_1; 
    33 
    4 uniform float exponent_scale; 
    5 uniform float exponent_offset; 
     4uniform float y0; 
    65 
    76#if 1 
    87vec4 warp(in vec4 source) 
    98{ 
    10     float divisor = exp2(source.y); 
    11     return vec4(source.x/divisor, source.y, source.z, source.w); 
     9    float inv_divisor = 1.0 / (source.y + y0); 
     10    return vec4(source.x * (1.0 + y0 ) * inv_divisor , (source.y * y0 + 1.0 ) * inv_divisor, source.z, source.w); 
    1211} 
    1312#else 
     
    2928     
    3029    vec4 base_color = texture2D(texture_0, gl_TexCoord[0].xy); 
    31     vec4 overlay_color = texture2D(texture_1, warped ); 
     30    vec4 overlay_color = texture2D(texture_1, warped.xy ); 
    3231    vec3 mixed_color = mix(base_color.rgb, overlay_color.rgb, overlay_color.a); 
    3332    gl_FragColor = vec4(mixed_color, base_color.a); 
  • OpenSceneGraph-Data/trunk/shaders/overlay_perspective_rtt.vert

    r6963 r6976  
    1 uniform float exponent_offset; 
    2 uniform float exponent_scale; 
     1uniform float y0; 
     2 
     3 
     4#if 1 
     5vec4 warp(in vec4 source) 
     6
     7    float divisor = source.y + y0; 
     8    return vec4(source.x * (1.0 + y0 ), source.y * y0 + 1.0, (source.z * y0 + 1.0)*0.05, source.w * divisor); 
     9
     10#else 
     11vec4 warp(in vec4 source) 
     12
     13    return source; 
     14
     15#endif 
     16 
    317 
    418vec3 fnormal(void) 
     
    3650   specular += gl_LightSource[i].specular * pf; 
    3751} 
    38  
    39 #if 1 
    40 vec4 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 
    46 vec4 warp(in vec4 source) 
    47 { 
    48     return source; 
    49 } 
    50 #endif 
    51  
    5252void main() 
    5353{ 
     
    6666                 diffuse  * gl_FrontMaterial.diffuse + 
    6767                 specular * gl_FrontMaterial.specular; 
    68          
     68 
     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 
    6973    gl_FrontColor = color; 
    70     gl_FrontColor.x = 0.0; 
     74     
     75     
    7176}