Hi, I guess I'm missing something really obvious here.
I'm trying to render a simple scene (just a cube), keep the result in a texture and use this texture as a state texture attribute. Only the backfaces of the scene need to be rendered. My approach so far is as follows: 1. Create the scene which is simply a Geode with a osg::Box attached. 2. Create the osgPPU::Processor attach it to the root node and set the main camera. 3. Create new osgPPU:UnitInOut and add it to the processor. Also create new osg:Texture2D to render into and pass it to the unit as output texture. 4. Setup a simple shader which will output the vertex positions as color values. Setup a CullFace::FRONT and pass both as attributes to the unit. 5. Create a new osg::StateSet and use the output texture of the unit as texture attribute. I was expecting a result similar to the following image: [Image: http://lh3.ggpht.com/_cd2T4Cr6euY/S_Z83Cus3EI/AAAAAAAAABw/UjiqKsw4er0/expected.jpg ] But the actual result looks like this: [Image: http://lh3.ggpht.com/_cd2T4Cr6euY/S_Z83OwkvkI/AAAAAAAAABs/eH588IWeXe8/actual.jpg ] My code is as follows: Code: .......................... const char* fpFront = "\n" "void main () {\n" "gl_FragColor = gl_Color;\n" "}\n"; const char* vpFront = "\n" "void main () {\n" "gl_FrontColor = gl_Vertex; \n" "gl_Position = ftransform();\n" "}\n"; .......................... // output unit osgPPU::UnitInOut* unitCullFront = new osgPPU::UnitInOut(); processor->addChild(unitCullFront); // output texture to render into osg::Texture2D* texCullFront = createRenderTexture(256, 256); //viewport osg::Viewport* vp = processor->getCamera()->getViewport(); //setup unit unitCullFront->setViewport(vp); unitCullFront->setOutputTextureType(osgPPU::UnitInOut::TEXTURE_2D); unitCullFront->setOutputTexture(texCullFront, 0); // setup shader osg::Program* programCullFront = new osg::Program(); osg::Shader* fpCullFront = new osg::Shader(osg::Shader::FRAGMENT); osg::Shader* vpCullFront = new osg::Shader(osg::Shader::VERTEX); fpCullFront->setShaderSource(fpFront); vpCullFront->setShaderSource(vpFront); programCullFront->addShader(fpCullFront); programCullFront->addShader(vpCullFront); // set shader as attribute unitCullFront->getOrCreateStateSet()->setAttributeAndModes(programCullFront); // cull face osg::CullFace* cullFrontFace = new osg::CullFace(osg::CullFace::FRONT); // set cullface as sttribute unitCullFront->getOrCreateStateSet()->setAttributeAndModes(cullFrontFace); // create the result state osg::StateSet* state = new osg::StateSet; // set output texture as texture attribute state->setTextureAttributeAndModes(0, texCullFront, osg::StateAttribute::ON); return state; Changing the last lines in the above code like this gives me the correct result: Code: state->setAttributeAndModes(cullFrontFace); state->setAttributeAndModes(programCullFront); instead of state->setTextureAttributeAndModes(0, texCullFront, osg::StateAttribute::ON); So the shader and the cullface attributes seem to work correctly. I was expecting the same results when applying the same properties to the unit and just using the output as a texture attribute? It would be great if anyone could give me a hint on what I'm doing wrong. Thank you! Cheers, Martin ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=28120#28120 _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

