Changes between Version 1 and Version 2 of Support/Tutorials/ShadersSampleGrayingOut

Show
Ignore:
Timestamp:
07/02/08 07:35:40 (6 years ago)
Author:
osg (IP: 203.100.229.194)
Comment:

added uniforms for screen center and in/out range

Legend:

Unmodified
Added
Removed
Modified
  • Support/Tutorials/ShadersSampleGrayingOut

    v1 v2  
    66 
    77{{{ 
    8     uniform vec4 grayScaleWeights; 
     8    uniform sampler2D testTexture; 
     9    uniform vec4 grayScaleWeights; // [0.3, 0.59, 0.11, 1.0] 
     10    uniform vec4 screenCenterAndInOut; // [screenCenterX, screenCenterY, inRange, outRange] 
    911 
    1012    void main( void ) 
    1113    { 
    12  
    1314        // Fetch the regular RGB texel color from the texture 
    1415        vec4 texelColor = texture2D( testTexture, gl_TexCoord[0].xy ); 
     
    2930        // 
    3031 
    31         //  grayScaleWeights = vec4(1,1,1,1); 
    32  
    3332        vec4 scaledColor = texelColor * grayScaleWeights; 
    3433        float luminance = scaledColor.r + scaledColor.g + scaledColor.b; 
    3534 
    36         // 
    37         float screenCenterX = 640; 
    38         float screenCenterY = 512; 
    39  
    40         float deltaX = screenCenterX - gl_FragCoord.x; 
    41         float deltaY = screenCenterY - gl_FragCoord.y; 
     35        float deltaX = screenCenterAndInOut.x - gl_FragCoord.x; 
     36        float deltaY = screenCenterAndInOut.y - gl_FragCoord.y; 
    4237 
    4338        float dist = sqrt(deltaX * deltaX + deltaY * deltaY);  
    44         float inRange = 50.; 
    45         float outRange = 600.; 
     39        float inRange = screenCenterAndInOut.z; 
     40        float outRange = screenCenterAndInOut.w; 
    4641 
    4742        if (dist < inRange) 
    4843        { 
    49  
    5044           gl_FragColor = texelColor; 
    5145        } 
     
    7064    } 
    7165}}} 
    72  
    73 Todo: 
    74  * Need to pass uniforms to vary the cone of visibility. 
    75  * Need to pass parameters in for center of screen.