Hi Robert,
thank you for this information. I did not know that I could do this, as
I'm an absolute newbie concerning shader stuff and was happy that I just
got it to work somehow ;)
I will try the approach with gl_ProjectionMatrix tomorrow, thank you :)
-Thorsten
Am 01.12.2010 20:51, schrieb Robert Osfield:
Hi Thorsten,
By default the OSG computes the near/far planes on the fly during the
cull traversal on every single frame. You can disable this.
Alternatively you could just use the gl_ProjectionMatrix directly on
the GPU to get the near/far planes - this is how I'd do it, far more
flexible and never needs any additional uniforms or callbacks.
Robert.
On Wed, Dec 1, 2010 at 6:15 PM, Thorsten Roth<[email protected]> wrote:
Hi,
I currently have a problem with a shader update callback I do not
understand. I have a vertex and fragment shader which calculate linear depth
in [0,1] for me, also respecting dynamic clipping planes. To achieve this, I
pass zNear and zFar as uniform parameters to the shader. To have them
updated, I have the following callback methods (zFar is looking
accordingly):
class UpdateShaderZNear: public osg::Uniform::Callback {
public:
virtual void operator()(osg::Uniform* uniform, osg::NodeVisitor* nv)
{
double x, zNear;
viewer->getCamera()->getProjectionMatrixAsPerspective(x,x,zNear,x);
uniform->set((float)zFar);
}
};
Now when I move my camera towards and away from the object, it seems like
the shader update is one frame (or so) "too late", as I get values that do
not correspond to the [0,1]-normalization and the problem disappears as soon
as the camera stops.
Is there any reason for that/does anyone have an idea what I'm doing wrong?
If more information or code is necessary, just tell me :-)
-Thorsten
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org