OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

How to query calczulated zNear zFar?


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
wernerM
User


Joined: 06 Feb 2013
Posts: 76

PostPosted: Thu May 17, 2018 2:12 pm    Post subject:
How to query calczulated zNear zFar?
Reply with quote

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 -

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 11758

PostPosted: Thu May 17, 2018 4:50 pm    Post subject:
How to query calczulated zNear zFar?
Reply with quote

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 <> wrote:
Quote:
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 -







------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
wernerM
User


Joined: 06 Feb 2013
Posts: 76

PostPosted: Fri May 18, 2018 12:22 pm    Post subject:
How to query calczulated zNear zFar?
Reply with quote

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:
Quote:
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 <> wrote:
Quote:
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 -











------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts Need your help with zNear / zFar calc... wernerM General 0 Thu May 03, 2018 1:45 pm View latest post
No new posts How to query height of terrain given ... vinothrajendran4 VirtualPlanetBuilder [vpb] 0 Tue Mar 14, 2017 2:43 pm View latest post
No new posts OcclusionQueryNode: do not retrieve t... scrawl Submission 1 Thu Feb 25, 2016 4:41 pm View latest post
No new posts Check for presence of occlusion query... scrawl Submission 1 Sun Dec 06, 2015 5:28 pm View latest post
No new posts "LOS" materail query mgreene General 10 Thu Aug 20, 2015 7:58 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP