Problem With CameraNode and Shader

Hello every one:
I meets a problem with Camera Node and Shader.I use a cameranode to generate  
shadowmap,and make it used on the rendering of the main camera.
The problem is : no matter what I do (or set)  the 
"gl_ModelViewProjectionMatrix" in the shadowgen glsl shader always changed with 
main camera ......But it works perfect well without shader....strange.
Here is what I do to set the shadowgen cameranode:
  m_ShadowGenCamera->setClearColor(osg::Vec4(0.0f,0.0f,0.0f,0.0f));

  // set viewport
  m_ShadowGenCamera->setViewport(0,0,tex_width,tex_height);

  // set the camera to render before the main camera.
  m_ShadowGenCamera->setRenderOrder(osg::CameraNode::PRE_RENDER);

  // tell the camera to use OpenGL frame buffer object where supported.
  
m_ShadowGenCamera->setRenderTargetImplementation(osg::CameraNode::FRAME_BUFFER_OBJECT);

  // attach the texture and use it as the color buffer.
  m_ShadowGenCamera->attach(osg::CameraNode::COLOR_BUFFER, m_ShadowMap.get());

  m_ShadowGenCamera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);

If it's not possible to do so by setting some states....maybe I will need to 
write something like a drawcallback.
But here is another problem: I must set the drawcallback to a drawable.....in 
order to do so I must Deep Copy those drawables to a new subgraph, which is 
really expensive.
Because those drawables will be used both in shadowgen and main camera 
rendering.Is it possible to clone drawables with statesets but with out 
vertexarrays and other staff??
Any suggestion will be appreciated. Thanks ...
                                                                                
                                        WangMiao
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to