[osg-users] How to query calczulated zNear zFar?

Werner Modenbach Werner.Modenbach at texion.eu
Fri May 18 05:21:21 PDT 2018


Sorry, I forgot something:
As I found out in debugging cullVisitor, the projectionMatrix of the
child camera gets updated shortly before leaving the apply() method of
the camera. Where does this modified matrix go? I can't find it in the
camera later.

============================

Hi Robert,

thanks for your answer and your willingness for doing some addition to
the software for helping me.

I do not really understand, why the main camera having a scene gets its
projection Matrix updated
from cullVisitor (to conform to calculated zNear and zFar) but if I move
the scene from main camera
to a child camera I have no chance to get zNear/zFar form anywhere.
These values are very useful and/or necessary in many cases ambient
shadow, DoF and others.
The complete deferred shading idea is based on this scheme.
I cruised the Internet for a solution and discovered that many people
are having the same problem like me.
Even in your examples you always calculate the scenes bounding sphere
and derive zNear/zFar from there
which is far from optimal bounds calculated by the cull visitor in
various display situations.

So, yes, having a callback giving me the chance to retrieve those values
would be great. And I think not just for me.

Many thanks in advance.

- Werner -

Am 17.05.2018 um 18:49 schrieb Robert Osfield:
> Hi Werner,
>
> You have a complicated enough scheme that just reading a general
> description really isn't sufficient to understand what is being down
> when etc.  So best I can is provide general suggests.
>
> Would a CullSettings::ClampProjectionMatrixCallback help?  Might
> enable you to intercept or set the values and do what you want with
> them.  This will be called in Cull traversal at the appropriate time.
> I don't recall the details, it's probably well over a decade since I
> looked at this code.
>
> Robert.
>
>
>
> On 17 May 2018 at 15:11, Werner Modenbach <Werner.Modenbach at texion.eu> wrote:
>> Dear all,
>>
>> I hope someone can help me.
>> I'm really desperate. I can't find the right way retrieving zNear and zFar
>> values
>> from a child camera.
>> I'm debugging now since many days already without success.
>> I have a deferred rendering scene. The main camera doesn't have my scane as
>> child but the rtt-camera.
>> rtt-camera is set RELATIVE_RF, so it is controlled by the camera manipulator
>> of the main camera.
>>
>> What I found out so far:
>> - The viewer calls "renderingTraversals()"
>> - The renderer calls "cull()" which starts a cullVisitor.
>> - When the cullVisitor reaches my child camera it multiplies view and
>> projection matrices and collects correct
>>    zNear and zFar values from the cameras child = my scene.
>> - at the and of apply(const osg::Camera&) the method "popProjectionMatrix()"
>> is called which cals "clampProJectionMatrix(...)"
>> - There the projection matrix is modified the correct way according to zNear
>> and zFar.
>> - I have set a CullCallback and a PreDrawCallback at my child camera but
>> none of them can extract zNear and zFar from the cameras ProjectionMatrix.
>>
>> Is there any other way to get these values which get obviously calculated
>> the correct way?
>> I can't find anything in the Internet or in the examples.
>>
>> Many thanks for any hint.
>>
>> - Werner -
>>
>>
>>
>> _______________________________________________
>> osg-users mailing list
>> osg-users at lists.openscenegraph.org
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org





More information about the osg-users mailing list