[osg-users] Setting alpha channel in Frag Shader does not work.

Steven Powers StevenAPowers at gmail.com
Thu Mar 19 09:33:16 PDT 2009


Here is my shader code in its entirety.

Code:

    //Shaders
    const char VertexShaderSrc[]  = 
    varying vec4 vVertPos;
    attribute vec4 gl_MultiTexCoord0;
    uniform mat4 osg_ViewMatrixInverse;
    uniform vec3 worldOffset;         //offset from world origin
    void main(void)
    {
       gl_Position = ftransform();
       vec4 eyeVector = gl_ModelViewMatrix * gl_Vertex;
       vVertPos = osg_ViewMatrixInverse * eyeVector;
       vVertPos.xyz = vVertPos.xyz - worldOffset;      //apply offset so it is in ansRel coordinates
       gl_TexCoord[0] = gl_MultiTexCoord0;
    };

    const char  FragShaderSrc[] = 
    varying vec4 vVertPos;
    uniform float minimumDistance;
    uniform float maximumDistance;
    uniform bool sendDepth;
    void main(void)"
    {
       float depth = gl_FragCoord.z / gl_FragCoord.w;
       gl_FragDepth  = depth / maximumDistance;
       if(abs(depth) < minimumDistance || abs(depth) > maximumDistance)
       {
           gl_FragColor = vec4(0,0,0, 1);
       }
       else
       {
           if(sendDepth)
           {
               gl_FragColor = vec4(depth, depth, depth, depth);
           }
           else
           {
               gl_FragColor = vec4(vVertPos.xyz , 1);
           }
       }
    } ;




------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=8780#8780








More information about the osg-users mailing list