Show
Ignore:
Timestamp:
06/09/05 10:29:22 (9 years ago)
Author:
robert
Message:

Added texture2D shader source

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osgmovie/osgmovie.cpp

    r4321 r4322  
    260260        //useTextureRectangle = false; 
    261261         
    262         static const char *shaderSource = { 
     262        static const char *shaderSourceTextureRec = { 
    263263            "uniform vec4 cutoff_color;\n" 
    264264            "uniform samplerRect movie_texture;" 
     
    270270            "}\n" 
    271271        }; 
     272 
     273        static const char *shaderSourceTexture2D = { 
     274            "uniform vec4 cutoff_color;\n" 
     275            "uniform sampler2D movie_texture;" 
     276            "void main(void)\n" 
     277            "{\n" 
     278            "    vec4 texture_color = texture2D(movie_texture, gl_TexCoord[0]); \n" 
     279            "    if (all(lessThanEqual(texture_color,cutoff_color))) discard; \n" 
     280            "    gl_FragColor = texture_color;\n" 
     281            "}\n" 
     282        }; 
     283 
    272284        osg::Program* program = new osg::Program; 
    273         program->addShader(new osg::Shader(osg::Shader::FRAGMENT,shaderSource)); 
     285         
     286        program->addShader(new osg::Shader(osg::Shader::FRAGMENT, 
     287                                           useTextureRectangle ? shaderSourceTextureRec : shaderSourceTexture2D)); 
    274288 
    275289        stateset->addUniform(new osg::Uniform("cutoff_color",osg::Vec4(0.1f,0.1f,0.1f,1.0f)));