[2.1] Strange behaviour in intersections of meshes Topic is solved

Problems building or running the engine, queries about how to use features etc.
Post Reply
gabbsson
Halfling
Posts: 65
Joined: Wed Aug 08, 2018 9:03 am
x 9

[2.1] Strange behaviour in intersections of meshes

Post by gabbsson »

Ogre Version: 2.1
Operating System: Ubuntu
Render System: OpenGL

Hello!

I'm having an issue where to meshes that intersect have trouble deciding whats on top.
This picture should explain what the problem is:
Image
The intersection should be a smooth line, not look as if they are melting together.

I'll keep looking for the cause, but I'd appreciate any help that would speed up solving the issue.

Cheers!

xrgo
OGRE Expert User
OGRE Expert User
Posts: 1137
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 164

Re: [2.1] Strange behaviour in intersections of meshes

Post by xrgo »

What's your near and far camera clipping distances?
Could be a precision problem

gabbsson
Halfling
Posts: 65
Joined: Wed Aug 08, 2018 9:03 am
x 9

Re: [2.1] Strange behaviour in intersections of meshes

Post by gabbsson »

xrgo wrote:
Mon Jul 01, 2019 2:08 pm
What's your near and far camera clipping distances?
Could be a precision problem
I was using:

Far 1000
Near 0.1

I changed it to 500 and 1 and its gone so you were correct! Thanks a ton for the quick response.

May I follow up with something; what are good values for near and far clip? Is there a rule of thumb for selecting them?

Edit:

Just for my own understanding, the near and far clip decide the precision of (z?)-depth? I kept experimenting and realized the less extreme clip distances I have the closer objects can be without acting strange (what looks like z-fighting)?

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 4355
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 884
Contact:

Re: [2.1] Strange behaviour in intersections of meshes

Post by dark_sylinc »

The near clip plane has a much more profound effect on the Z precision. This is because, unfortunately, the range [0;0.5] is occupied by [near; near*2.0]

In other words, more than half(*) of the available precision is dedicated to [near; near*2.0] which is absolutely overkill, and the rest of the precision is dedicated to [near *2.0; far).

So when you increase the near plane, you gain a ton of precision on things that are close to the camera.
Reducing the range between near and far also helps, obviously.

(*)It's more than half because of ]how floating point works (the link is for half floating point, but it perfectly applies to 32-bit floating point as well, just with higher precision).

Reverse Z was implemented in Ogre 2.2 and helps a lot with this issue, because it reverses the range: The range [0.5; 1.0] is occupied by [near *2.0; near], which means less than half of the available precision is dedicated to the often-most useless part.

Post Reply