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 

Prevention of near plane culling while moving camera


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


Joined: 20 Mar 2009
Posts: 128

PostPosted: Sat Mar 10, 2018 7:57 am    Post subject:
Prevention of near plane culling while moving camera
Reply with quote

Hi,

In my dynamic scene (objects can be added or removed) I use a perspective projection and automatic near and far plane calculation. To prevent during camera movement culling of objects between the camera and the near plane I calculate before each camera movement if there are objects in the pyramid built by the camera's location and the near plane. This is done by using a polytope intersector. If there are objects in-between I limit the camera movement.

If the movement of the camera is moderate everything works fine but if there are big steps in the camera movement I still see near plane culling (for one frame or so). Because due to the camera movement the near plane will also change and therefore my calculation is slightly wrong for the next frame, I suppose. But this change of the near plane will only be calculated in the next cull traversal and my correction will be again corrected in the next movement and therefore the flicker, I guess.

I have already tried to use a slightly larger FOV or further near plane for the pyramid but this does not really help (the flicker can still be seen). Especially when the camera is looking more parallel to the scene.

I fear that I have to give up automatic near and far calculation or what are you doing in such a case?

If I have to give up automatic near-far calculation I basically have to do before finalising the camera movement a new near-far calculation and if there are still collisions limit or correct the camera movement or adjust the near plane. But this basically means that I have to run my own cull traversal. Or are there any other solutions?

PS: As the scene is dynamic I cannot pre-calculate the near and far planes.

Thank you for your suggestions in advance!

Cheers,
Hartwig
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12148

PostPosted: Sat Mar 10, 2018 1:05 pm    Post subject:
Prevention of near plane culling while moving camera
Reply with quote

Hi Hartwig,

By default the OSG automatically adjust the near and far planes on
each new frame, so I'm surprised you are trying to do this yourself.
The controls for this can be found in include/osg/CullSettings:

enum ComputeNearFarMode
{
DO_NOT_COMPUTE_NEAR_FAR = 0,
COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES,
COMPUTE_NEAR_FAR_USING_PRIMITIVES,
COMPUTE_NEAR_USING_PRIMITIVES
};

void setComputeNearFarMode(ComputeNearFarMode cnfm) {
_computeNearFar=cnfm; applyMaskAction(COMPUTE_NEAR_FAR_MODE); }
ComputeNearFarMode getComputeNearFarMode() const { return
_computeNearFar;}

osg::Camera subclasses from osg::CullSettings so you use this
directly. The default is COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES.

Another area I think is useful to clarify is that there is difference
between culling and clipping:

Culling is done by the scene graph during the cull traversal and
is done be testing the view frustum against the bounding sphere's of
nodes in the scene.

Clipping is done by the GPU during rasterization of primitives,
this is where the near/far values affect the result, so clipping
happens at a per fragment basis.

If whole objects disappear at once when they shouldn't be then this is
likely an issue with Culling, most likely due to a bounding volume for
a subgraph being incorrect for some reason. Using vertex shaders to
move objects might be the cause this issue. Using
Drawable::setInitBound() or better a
Drawable::ComputeBoundingBoxCallback to provide the dimensions that
the drawable will have once the vertex shader is taken into account.

If objects get clipping out fragment by fragment then it's an issue of
near or far plane clipping. Again it can be caused by bounding volume
issues as the the OSG compute near/far code needs valid bounding
volume sizes to do it's compute work. However, the near plane can
only be pulled in so far before the near/far ratio grows too high to
cause depth precision problems. so has to be clamped. The
osg::CullSettings::setNearFar() ratio can be adjusted to make this
clamping more or less conservative. The default ratio is 0.0005.

If you have a scene with a massive near/far range (think space sims)
then it be necessary to use a non linear depth buffer or depth
portioning.

Robert.


Robert


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


Joined: 20 Mar 2009
Posts: 128

PostPosted: Sat Mar 10, 2018 5:02 pm    Post subject:
Reply with quote

Hi,

sorry not to be precise. I actually meant clipping.

When the camera is placed perpendicular to the scene (a large plane with some objects on it) everything can be seen. If the camera is looking at the scene under an angle of 70 degrees (between look-vector and plane's normal) the lower part (or better the lower element fragments) is clipped(!).

I know it has to do with the clear/far ratio and therefore I would like to limit the camera movement. To do so I am checking if there are primitives that are going to be clipped. If this is the case I backtrack the camera.
But this leads to some flicker.

How can I implement a logarithmic z-buffer when not using shaders?


Thank you!

Cheers,
Hartwig
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12148

PostPosted: Sat Mar 10, 2018 5:38 pm    Post subject:
Prevention of near plane culling while moving camera
Reply with quote

Hi Hartwig,

On 10 March 2018 at 17:02, Hartwig Wiesmann <> wrote:
Quote:
When the camera is placed perpendicular to the scene (a large plane with some objects on it) everything can be seen. If the camera is looking at the scene under an angle of 70 degrees (between look-vector and plane's normal) the lower part (or better the lower element fragments) is clipped(!).

Could you post a couple of screenshots to illustrate what you mean as
it's so open ended about what you scene could be.


Quote:
I know it has to do with the clear/far ratio and therefore I would like to limit the camera movement. To do so I am checking if there are primitives that are going to be clipped. If this is the case I backtrack the camera.
But this leads to some flicker.

Limiting the camera view also doesn't seem like a great approach, my
guess is that it would feel unnatural for users having the camera
behave in none obvious ways.

Quote:
How can I implement a logarithmic z-buffer when not using shaders?

You can't implement it without shaders. The best you can do is
multi-pass depth partition approach. osgViewer has support for
dividing up a view into multiple depth partition. Go have a look
through the headers and the osgdepthpartition example.

However, before you start looking into anything fancy I'd suggest
getting to bottom of what the problems you are seeing first - it might
be something really simple can be done to improve things without doing
anything complicated.

Robert.


------------------
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 Camera clear color cdp97531 General 1 Sat Dec 01, 2018 8:15 am View latest post
No new posts Camera movement when depending on 3rd... njr3 General 0 Wed Nov 28, 2018 9:46 pm View latest post
No new posts Camera movement when depending on 3rd... njr3 General 0 Wed Nov 28, 2018 9:44 pm View latest post
No new posts Camera movement when depending on 3rd... njr3 General 0 Wed Nov 28, 2018 9:43 pm View latest post
No new posts Camera movement when depending on 3rd... njr3 General 0 Wed Nov 28, 2018 9:41 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