Jump to content

Multiple passes and logarithmic depth


photo

Recommended Posts

Posted

I have a problem with multi-pass shaders and multiple viewports when trying to render to depth buffer from the pixel shaders. I need this for logarithmic depth. So in my pixel shaders I have the SV_DEPTH output:

 

float LogDepth : SV_DEPTH;

 

Which is written with:

 

Out.LogDepth = log2(input.LogDepth) / log2(CameraFarPlane/CameraNearPlane + 1);

 

input.LogDepth is computed in vertex shader and interpolated. Same as Unigine logarithmic depth. Every camera parameters are updated correctly to the shader constants buffer.

 

I have multiple layers on terrain which are rendered one on top of another. Depth state is created with D3D11_COMPARISON_LESS_EQUAL so layers on top are rendered with alpha blend to cover the ones underneath. All layers are using the same vertex shaders but different pixel shaders (of different complexity).

 

But when having multiple viewports the bottom layer is visible through (the black one in the screenshots bellow) as some sorts of z-fighting issue (see attached image).

 

Always the first layer (which contains a simple pixel shader) is showing through. If I disable this first layer and have layers with similar pixel shaders in complexity this is not happening.

 

This is happening only for multiple viewports and only when I am using logarithmic depth (when I am writting to SV_DEPTH). It happens on Windows 8 and 10, DirectX11 and on multiple models of NVIDIA hardware. This doesn’t seem to happen on ATI hardware. So maybe this is a driver issue.

 

Also when using D3DCOMPILE_OPTIMIZATION_LEVEL3 this is happen right away, while with D3DCOMPILE_OPTIMIZATION_LEVEL0 sometimes I need to move a around a lot, create other viewports etc. I see Unigine is using level0, any reason for this?

 

For a single viewport it doesn’t happen. But once I open a second or (sometimes) a third one this starts to happen. After that, even if I close the other viewports and leave only the first one, this is still happening once I move the camera around. I’ve debugged the code extensively (both mine and Unigine) and it seems that depth is properly cleared per frame, rendering states seem ok. I cannot use the Visual Studio debugger since this is taken a snapshot of a single window and the error doesn’t appear in that snapshot.

 

Do you know what may cause this? Did you encountered similar issues with multiple rendering passes and logarithmic depth?

 

post-1035-0-54067700-1468867981_thumb.jpg

Posted

Hi Adrian,

I'm afraid, we never encountered such issue. We are also removed Logarithmic depth from 2.3 SDK. Right now we are using only inverse Z buffer. Actually, that switch to inverse Z gave us more depth precision that logarithmic implementation. Inverse Z will be available together with 2.3 SDK update.

 

We also can provide you Unigine 2.3-beta SDK to test your use-case with new inverse Z depth. How do you think?

 

I see Unigine is using level0, any reason for this?

Starting with 2.3 if you will launch release build you will have level3, for debug builds we use level0. Level0 will give you slightly faster shaders compile time. 

 

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Posted

Ok, thanks for the heads up. The entire team probably will switch to 2.3 in the future. I will let you know if we need the beta version in advance. Currently we will deactivate logarithmic depth and wait for inverse z.

 

Regards,

Adrian

×
×
  • Create New...