Hi,
On 20/01/11 13:54, John Simpson wrote:
Hi,
I'm writing a laser range finder simulator using the depth component
of a scene.
I'm linearising the range in a fragment shader using..
linearRange = (2.0*near) /(far+near-(nonLinearRange*(far-near)))
I was hoping to display the foggy depth image by allowing the rtt
camera to calculate the near/far planes and pass these values to the
shader for use in the linearisation.
I had hoped that this would mean that the calculated range should
remain the same whether DO_NOT_COMPUTE_NEAR_FAR was set or not.
I'm getting the near/far numbers from
rttCamera->getProjectionMatrixAs Frustum and passing these to the
shaders in a viewer->frame loop using Uniform->set(), but the
linearised range is different dependent on DO_NOT_COMPUTE_NEAR_FAR.
I'm not 100% sure when the projection matrix is set, you might have to
split ->frame() into update(), cull(), then get the matrix and set the
uniform, then draw().
I can confirm that the near/far values change within the loop as the
scene changes.
But they might be one frame behind?
Is it valid to pass data to a shader using Uniform-set() in a
viewer->frame loop?
Yes.
Is my assumption that linearised range should be independent of
DO_NOT_COMPUTE_NEAR_FAR if the near/planes are passed to the
linearisation algorithm correct?
I think so, provided the algorithm is correct. But what are you setting
for near/far in the DO_NOT_COMPUTE_NEAR_FAR case? What is your
nonLinearRange value? Is it dependent on camera field of view?
Can anyone comment on the algorithm used (which seems to be generally
accepted)?
Not by heart, I'll have to search...
rgds
jp
Ta.
John
------------------ Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=35796#35796
_______________________________________________ osg-users mailing
list [email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
--
This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard.
The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html.
This message has been scanned for viruses and dangerous content by MailScanner,
and is believed to be clean. MailScanner thanks Transtec Computers for their support.
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org