No, it isn't. Should it be? I tried to draw the scenegraph in my first message, but it's not easy just using text. If you want more code, please tell me.
Åsa -----Ursprungligt meddelande----- Från: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] För J.P. Delport Skickat: den 7 november 2008 09:42 Till: OpenSceneGraph Users Ämne: Re: [osg-users] Render to texture problem Hi, is your RTT camera the child of anything? I'm just guessing without having an example to run. jp Engvall Åsa wrote: > I thought that the texture must be in RGBA to be used in a shader. The > callback was just for debugging, so I didn't think so much about the > format. Now I have changed to RGBA format in the callback too. I have > also set the viewer to singlethreaded, using this command: > viewer.setThreadingModel(osgViewer::Viewer::SingleThreaded); > > Unfortunately, the texture is still gray. > > Åsa > > -----Ursprungligt meddelande----- > Från: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] För J.P. Delport > Skickat: den 7 november 2008 08:22 > Till: OpenSceneGraph Users > Ämne: Re: [osg-users] Render to texture problem > > Hi, > > any reason why you have RGBA texture, but RGB in callback? > > jp > > Engvall Åsa wrote: >> Hi! >> >> I want to render the scene to a texture and use the texture in a shader. >> The texture image is saved to file by a postdraw callback, so I can >> look at it. I'm doing something wrong because the texture becomes all gray. >> >> My scene graph looks like this: >> >> RTT camera root >> | | >> \ / >> world >> >> The main viewer looks at the root and the shader program is applied >> to the root stateset. Below is a code snippet. >> >> I would be very grateful if somebody could point out what I'm doing wrong. >> Thanks in advance, >> >> Åsa Engvall >> >> >> // Create a scene texture. >> osg::Texture2D* texture = new osg::Texture2D; >> texture->setResizeNonPowerOfTwoHint(false); >> texture->setTextureSize(traits->width, traits->height); >> texture->setInternalFormat(GL_RGBA); >> texture->setFilter(osg::Texture2D::MIN_FILTER, >> texture->osg::Texture2D::NEAREST); >> texture->setFilter(osg::Texture2D::MAG_FILTER, >> texture->osg::Texture2D::NEAREST); >> osg::Image* textureImage = new osg::Image; >> textureImage->allocateImage(traits->width, traits->height, 1, >> textureImage->GL_RGBA, >> GL_UNSIGNED_BYTE); >> texture->setImage(0, textureImage); >> >> // Add program and uniforms to the root's stateset. >> osg::StateSet* state = root->getOrCreateStateSet(); >> state->addUniform(numberOfTimeStepsU); >> state->addUniform(timeConstantU); >> state->addUniform(frameTimeU); >> state->addUniform(sceneTextureU); >> state->addUniform(prevModelViewMatrixU); >> state->addUniform(prevModelViewProjectionMatrixU); >> state->setAttributeAndModes(motionBlurProgram, >> state->osg::StateAttribute::ON); setTextureAttributeAndModes(0, >> state->texture, osg::StateAttribute::ON); >> >> // Create a camera that renders the scene to a texture. >> osg::Camera* RTTcamera = new osg::Camera; >> RTTcamera->setReferenceFrame(osg::Transform::ABSOLUTE_RF); >> RTTcamera->setClearColor(osg::Vec4(1,1,1,1)); >> RTTcamera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); >> RTTcamera->setViewport(0, 0, traits->width, traits->height); >> RTTcamera->setComputeNearFarMode(osg::Camera::DO_NOT_COMPUTE_NEAR_FAR >> RTTcamera->) ; setRenderOrder(osg::Camera::PRE_RENDER); >> RTTcamera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OB >> RTTcamera->J ECT); attach(osg::Camera::COLOR_BUFFER, texture); >> RTTcamera->addChild(world); attach(osg::Camera::COLOR_BUFFER, >> RTTcamera->textureImage); setPostDrawCallback(new >> RTTcamera->ScreenShotCallback(traits->width, >> traits->height, *textureImage, GL_RGB, GL_UNSIGNED_BYTE)); >> >> >> >> --------------------------------------------------------------------- >> - >> -- >> >> _______________________________________________ >> osg-users mailing list >> [email protected] >> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph. >> org > > -- > This message is subject to the CSIR's copyright terms and conditions, e-mail > legal notice, and implemented Open Document Format (ODF) standard. > The full disclaimer details can be found at > http://www.csir.co.za/disclaimer.html. > > This message has been scanned for viruses and dangerous content by > MailScanner, and is believed to be clean. MailScanner thanks Transtec > Computers for their support. > > _______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph. > org _______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph. > org -- This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard. The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html. This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. MailScanner thanks Transtec Computers for their support. _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

