[osg-users] Render To Texture problem in a Reflection algorithm
zhangguilian
zhangguilian at ict.ac.cn
Sun Dec 2 16:46:16 PST 2007
Hi,
In an algorithm of reflection I used Render To Texture, part of the code is:
Texture2D* reflectionTex=new Texture2D;//rtt texture
reflectionTex->setTextureSize(512, 512);
reflectionTex->setInternalFormat(GL_RGBA);
reflectionTex->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR);
reflectionTex->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);
reflectionTex->setWrap(osg::Texture2D::WRAP_S,osg::Texture2D::CLAMP_TO_EDGE);
reflectionTex->setWrap(osg::Texture2D::WRAP_T,osg::Texture2D::CLAMP_TO_EDGE);
CameraNode * rttcamera=new CameraNode;//rttcam
rttcamera->setCullingMode(CullSettings::NO_CULLING);
rttcamera->setCullingActive(false);
rttcamera->setClearMask(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
// rttcamera->setViewport(0,0,512,512);
rttcamera->setRenderOrder(CameraNode::PRE_RENDER);
rttcamera->setRenderTargetImplementation(CameraNode::FRAME_BUFFER_OBJECT,CameraNode::PIXEL_BUFFER_RTT);
rttcamera->attach(osg::CameraNode::COLOR_BUFFER,reflectionTex);
osg::ClipNode* clipNode = new osg::ClipNode;
osg::ClipPlane* clipplane = new osg::ClipPlane;
Plane pl(normal,point);
clipplane->setClipPlane(pl);
clipplane->setClipPlaneNum(0);
clipNode->addClipPlane(clipplane);
clipNode->addChild(reflectTransform);
rttcamera->addChild(clipNode);
I don't know why it running well on a GeForce 8800 GTS/PCI/SSE2 from NVIDIA Corporation but doesn't have any reflection effect on a GeForce4 MX 440/AGP/SSE2 from NVIDIA Corporation,
and while I add a line:rttcamera->setViewport(0,0,512,512),the later machine(GeForce4 MX 440/AGP/SSE2 from NVIDIA Corporation) can have reflect effect,but a strange phenomena appears:
an arbitrary window(relative or irrelative with the program) over it will destroy the reflction map and the area destroyed will move with the window over it
(once the window over it moves ,the destroyed area move too) , I don't know what have happend and I eagerly to know how to solve the problem.
Thanks very much!
zhangguilian
2007.12.3
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20071203/e14ac145/attachment.htm
More information about the osg-users
mailing list