[osg-users] Render To Texture problem in a Reflection algorithm

2007-12-02 Thread zhangguilian
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
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Render To Texture problem in a Reflection algorithm

2007-12-02 Thread Himar Carmona
Hi,

   do both graphics cards support Frame_Buffer_object ? The problem could be
in the renderfallback (i.e. PIXEL_BUFFER_RTT) if they do not support it? Try
the different RTT methods if these seems to be the problem. Also , i think
you maust set the viewport for FBO to work (i suppose it is set in another
place also)...Also, you can set the notifylevel of OSG to WARN or DEBUG and
see what is really happens.

Good luck.
Himar.


2007/12/3, zhangguilian [EMAIL PROTECTED]:

  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

 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org