Hello,
I am completely confused about the Z-Buffer. I thought it is non-linear but now
I read a lot in forums and now I am not sure about that. The reason about this
question is I want render linear depth values into a texture. I think, I can do
it with this shader:
varying float depth;
uniform float near;
uniform float far;
void main(void)
{
vec4 viewPos = gl_ModelViewMatrix * gl_Vertex;
depth = (-viewPos.z-near)/(far-near);
gl_Position = ftransform();
};
varying float depth;
void main(void)
{
gl_FragDepth = depth;
}
But the poor think is all other shader will be overwritten.
Now I use this:
_rendertarget->setInternalFormat(GL_DEPTH_COMPONENT);
_cam->setClearMask(GL_DEPTH_BUFFER_BIT);
_cam->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
_cam->attach(osg::Camera::DEPTH_BUFFER, _rendertarget);
_cam->setRenderOrder(::osg::Camera::PRE_RENDER, 0);
But this is nonlinear, isn't it?
I hope someone can help me about this.
Thanke you very much.
Martin
--
NEU: FreePhone - 0ct/min Handyspartarif mit Geld-zurück-Garantie!
Jetzt informieren: http://www.gmx.net/de/go/freephone
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org