Download

controlling depth-precision

Hi,

In our spacesim we have a lot of celestial-objects, which have to be scaled to very big extends in order to achieve an effect like orbiting a spaceship around a planet.
Some celestial-objects like suns are assembled in a blueprint with static meshes and particle effects.
The spaceship itself does not move. I am transforming and scaling all universe-actors into a virtual-moving spaceship-space in the renderpipeline, just before they are rendered.

Unfortunately, as we move farther away from a sun, we notice, that the precision of the depth-buffer is not high enough to depth-sort meshes and particles correctly, e.g. some particles, which should be behind the mesh, are suddenly completely visible rendered in front of the mesh.
It seems that there is a maximum depth-value I am not allowed to surpass, as it looks like a wall I am diverging from.

I understand, that there probably does not exist a generic solution for depth-clipping issues, but:

Can anyone point me in a direction how those issues can be fixed ?

As I have hacked some sort of render-layer feature into the engine in order to get the universe scaled before it is being rendered, I would be able to change the depth-precision for those universe-actors because I can identify them in the renderpipeline.

But I have only medium rendering-experience, so I have no clue how to change the projection-matrix so that universe-actors for example would have another depth-range than normal (=ship-) actors.

Any chance for me to get this running without becoming a shader- or renderer-pro :slight_smile: ?

For example: there is a Z_PRECISION macro being used in FPerspectiveMatrix, which basically completes to zero.

What would be the difference if I change that to another value ?

Is there an easy-to-medium way to control how z-values are distributed in the available depth-range at all ?

In 4.8, some code went in to get better precision for objects being rendered far from origin, but that did unfortunately not change anything of the clipping-problems.

And, what is for example the farthest Z-value I would be able to use, without getting precision issues ?
Can this be calculated at all :slight_smile: ?

I really do not expect a final answer, but currently any hint would help^^

Thanks.

I’m so interested in this, but I think the only way to make this happen would be to add a logarithmic Z buffer to the unreal engine. So far I think it would need to be placed in DepthRendering.cpp, just not sure where to override the Z-buffer.

I’ve found this thread Flicking large scale object - Rendering - Unreal Engine Forums

But not solutions. (I also posted a comment in that thread).

[EDIT] Looks like Ryanb just posted a vertex shader that can manipulate the mesh and pull it closer to the camera.