Flickering occurs when the viewpoint is moved Topic is solved

Problems building or running the engine, queries about how to use features etc.
Post Reply
yukkysaito
Gnoblar
Posts: 3
Joined: Sat Jul 02, 2022 6:30 pm

Flickering occurs when the viewpoint is moved

Post by yukkysaito »

Ogre Version: 1.12.1
Operating System: Ubuntu 20.04
Render System: :?:

Background
I posted an issue for Rviz, but moved it here because I thought it would be more appropriate for the OGRE community.
https://github.com/ros2/rviz/issues/875

Problem
Flickering occurs when the viewpoint is moved.
The problem seems to be that the drawing engine is working with floats, so if a large value (position) is pushed, the depth buffer is not accurate enough.
With small values there is no flickering.
However, it is a problem when the view point in rviz is close and it flickers.
Image

Please let me know if there is a better solution.

rpgplayerrobin
Gnoll
Posts: 617
Joined: Wed Mar 18, 2009 3:03 am
x 353

Re: Flickering occurs when the viewpoint is moved

Post by rpgplayerrobin »

This seems to be standard z-fighting, which can be solved in multiple ways.

One way is to move the vertices away from each other enough so it stops.
Another way is to use depth bias on the pass of the object you want to render "on-top".

Rendering them without depth write/check would obviously make them work as well, but that is mostly used for GUI, since 3D objects really need their depth write/check.

Even if you never use large values, z-fighting can still occur, so you must solve it in another way (some of which are above).

rpgplayerrobin
Gnoll
Posts: 617
Joined: Wed Mar 18, 2009 3:03 am
x 353

Re: Flickering occurs when the viewpoint is moved

Post by rpgplayerrobin »

You can also try to use reverse-z on the depth buffer. Though I have no idea how to do that in Ogre since I have not needed it.

More on the subject here:
https://en.wikipedia.org/wiki/Z-fighting

yukkysaito
Gnoblar
Posts: 3
Joined: Sat Jul 02, 2022 6:30 pm

Re: Flickering occurs when the viewpoint is moved

Post by yukkysaito »

Thank you for reply.
I resolved z-fighting problem by using setDepthBias().
https://ogrecave.github.io/ogre/api/1.1 ... c866198b67

I have one question.
what is the unit of constantBias? or how to determine this value?
When I set -1 ~ -100 to constantBias, it is not resolved.
When I set -1000, there is no flickering.

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

Re: Flickering occurs when the viewpoint is moved

Post by dark_sylinc »

I have one question.
what is the unit of constantBias? or how to determine this value?
When I set -1 ~ -100 to constantBias, it is not resolved.
When I set -1000, there is no flickering.

I wish that had a simple answer. The formula is known.

The answer is "it's the depth buffer value", which is in screen space and depth values are log-like but not exactly logarithmic. The actual "space" depends on near & clip planes, FOV, depth buffer format (16 unorm vs 24 unorm vs 32 bit float) and whether reverse depth was used.

I made a short test about constant bias:

as we needed to check the differences between regular and reverse depth for gz-rendering.

yukkysaito
Gnoblar
Posts: 3
Joined: Sat Jul 02, 2022 6:30 pm

Re: Flickering occurs when the viewpoint is moved

Post by yukkysaito »

@rpgplayerrobin @dark_sylinc
Thank you very much.
Your advise are helpful for me.

Post Reply