Re: [osg-users] osg::PPU texel 0,0 in depthbuffer is wrong

2012-10-05 Thread Sergey Polischuk
Hi Check texture wrap mode, it can be set to clamp_to_border, with some border color. Does it work okay when sampling other texture areas? Dont know if it can cause problem, but texture(...) call returns vec4, and you are sampling single component texture. I believe it returns (depth, 0, 0, 1), but who knows. And you'd better use #version directive, as nvidia drivers can compile a lot of stuff without it, but it can work not the way you would expect. 05.10.2012, 15:36, "Peterakos" hay...@gmail.com:Hello.i use UnitCameraAttachmentBypass to retrieve depth buffer from camera, while rendering cow.osg.After that i pass it to a UnitInOut which uses fragment shader to change the result.I have noticed there is a problem when i try to retrieve the 0,0 texel from depth texture in fragment shader.Even though the cow is in the middle of the screen, the texel's 0,0 depth is always grey.Here is the frag shader code which shows the problem:uniform sampler2D depth_texture;void main(){gl_FragColor = texture(depth_texture, vec2(0.0, 0.0));}I attach the depth buffer.thnx.,___osg-users mailing listosg-users@lists.openscenegraph.orghttp://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


Re: [osg-users] osg::PPU texel 0,0 in depthbuffer is wrong

2012-10-05 Thread Peterakos
Hello.

This is what i use for depth texture creation:

osg::Texture2D* texture2D = new osg::Texture2D;
texture2D-setTextureSize(tex_width, tex_height);
texture2D-setInternalFormat(GL_RGBA);
texture2D-setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR);
texture2D-setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);
texture2D-setWrap( osg::Texture::WRAP_S, osg::Texture::REPEAT );
texture2D-setWrap( osg::Texture::WRAP_R, osg::Texture::REPEAT );
texture2D-setInternalFormat(GL_DEPTH_COMPONENT);

I have also attached an image which shows that the fragment shader result.
If you watch closely in the middle, you will notice that the image is
separated into 4 pieces.

What i do is creating a UnitInOut which receives the depth buffer and
writing each pixel result to gl_FragData[0].
As you can see in the picture, i paint as red the pixels which have depth
value 1.
But when i access these pixels while another pixel is being iterated, i get
different depth value.

Why is this happening ?

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