Hi Nick,

ShadowComparison = true 
causes opengl to use result of TexFilter(depth_at_texel > depth_map_coord_r) 

ShadowComparison = false 
causes opengl to use TexFilter( depth_at_texel ) value. 

To display depth texture on some hud its neccessary to turn ShadowComparison 
off. Its kinda tricky because it has to be also on for use with shadow mapping.
I used to apply special callback that was used to change the mode to draw 
shadow map on the screen. See osgShadow/DebugShadowMap.cpp 
DrawableDrawWithDepthShadowComparisonOffCallback callback

Wojtek


From: Trajce Nikolov 
Sent: Monday, January 11, 2010 10:31 PM
To: OpenSceneGraph Users 
Subject: Re: [osg-users] Depth buffer for shadow mapping


Hi, 


I am trying to do the same. I noticed two methods of Texture2D.   
texShadowMap->setShadowComparison(true);
texShadowMap->setShadowTextureMode(Texture2D::LUMINANCE);


what are these doing? Also, what is to be done to display the depth texture on 
screen. 
Thanks
Nick

http://www.linkedin.com/in/tnick
Sent from Ünalan, İstanbul, Turkey 


On Mon, Jan 11, 2010 at 11:27 PM, Mourad Boufarguine 
<mourad.boufargu...@gmail.com> wrote:

  Hi Dominic, 


  AFAIK, the png plugin does not support writing depth image. Try the tiff 
plugin in svn/trunk ; a recent submission made it write depth images, and it 
works for me.


  Mourad


  On Mon, Jan 11, 2010 at 4:17 PM, Dominic Stalder <dominic.stal...@bluewin.ch> 
wrote:

    Hi there

    I have the following RTT method:

       ref_ptr<Image> image = new Image;
       image->allocateImage(osgViewer->width(), osgViewer->height(), 1, 
GL_RGBA, GL_UNSIGNED_BYTE);

       // resets the size of the texture
       texture->setTextureSize(osgViewer->width(), osgViewer->height());

       // sets the clear mask the depth buffer
       camera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

       // sets the clear color to white
       camera->setClearColor(Vec4(1.0, 1.0, 1.0, 1.0));

       ...matrices and viewport...

       // sets the reference frame to an absolute coordinate frame
       camera->setReferenceFrame(Camera::ABSOLUTE_RF_INHERIT_VIEWPOINT);

       // sets the texture camera to render before rendering to the screen
       camera->setRenderOrder(Camera::PRE_RENDER);

       // sets the rendering target of the texture camera to the frame buffer 
object (FBO)
       camera->setRenderTargetImplementation(Camera::FRAME_BUFFER_OBJECT);

       // attaches the texture to the texture camera (important: samples 
mustn't be greater than zero)
       // buffer component, texture, level, face, mip map generation, samples, 
color samples
       camera->attach(Camera::COLOR_BUFFER, image.get(), 0, 0);

       // adds the node to the texture camera (this node will be rendered to 
the texture)
       camera->addChild(node);

       // adds the texture camera to the root node
       root->addChild(camera);

    If I write this image to file, it works great, I have my "balance" in the 
middle of the image --> see attachment color_buffer.png. Now I would like to 
write the depth buffer to the image (just for debugging, afterward I write it 
to the texture), so I change the following lines:

    image->allocateImage(osgViewer->width(), osgViewer->height(), 1, GL_RGBA, 
GL_UNSIGNED_BYTE); --> image->allocateImage(osgViewer->width(), 
osgViewer->height(), 1, GL_DEPTH_COMPONENT, GL_FLOAT);

    camera->attach(Camera::COLOR_BUFFER, image.get(), 0, 0); --> 
camera->attach(Camera::DEPTH_BUFFER, image.get(), 0, 0);

    After that I get the image depth_buffer.png, but this isn't correct, is it?

    The texture looks like this, is it correct?

       // creates the texture for the shadow map
       texShadowMap = new Texture2D;
       texShadowMap->setInternalFormat(GL_DEPTH_COMPONENT);
       texShadowMap->setShadowComparison(true);
       texShadowMap->setShadowTextureMode(Texture2D::LUMINANCE);
       texShadowMap->setFilter(Texture2D::MIN_FILTER, Texture2D::LINEAR);
       texShadowMap->setFilter(Texture2D::MAG_FILTER, Texture2D::LINEAR);
       texShadowMap->setWrap(Texture2D::WRAP_S, Texture2D::CLAMP_TO_BORDER);
       texShadowMap->setWrap(Texture2D::WRAP_T, Texture2D::CLAMP_TO_BORDER);
       texShadowMap->setBorderColor(Vec4(1.0, 1.0, 1.0, 1.0));

    What am I doing wrong in this function?

    Thanks a lot
    Dominic


    _______________________________________________
    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






--------------------------------------------------------------------------------


_______________________________________________
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

Reply via email to