Help with GPU Pro 5 Hi-Z Screen Space Reflections

Started by
77 comments, last by WFP 9 years, 2 months ago

Hi WilliamHamilton,

Your formula to get tmpRay is wrong based on what you posted. You are using max() twice when it should really be


float3 tmpRay = intersectDepthPlane(o, d, min(max(ray.z, minZ.r), minZ.g));

This ensures the value is confined between the minimum and maximum of the hi-z buffer values for that pixel.

I'm using Load for every texture retrieval in my ray tracing steps, so that shouldn't be the issue as long as you are calculating the load position correctly.

I think your cross epsilon value may be too high. Please see my comments on Post 56 of this thread (http://www.gamedev.net/topic/658702-help-with-gpu-pro-5-hi-z-screen-space-reflections/?view=findpost&p=5189285).

Hope that helps,

WFP

Advertisement

I will try to continu on this way thanks.

About performances did you reach the same results as the author? Did you use regular Pixel Shader or Compute? With which hardware, resolution, tech (OGL, D)...?

How many pass did you have?

- HiZ

- PreIntegration

- PreConvolution

- RayTracing + Cone Tracing ? (on 1 or 2 steps ?)

- Final Rendering :)

4, 5, 6 ?

Hi WilliamHamilton,

Yes the performance I'm getting out of the effect in most cases is pretty good. I set my maximum iterations to 128, but usually the result is found in under 16 steps. I'm doing the entire effect in pixel shaders only. I'm using an NVIDIA GTX 760 on my desktop and an AMD 5770M on my laptop. I run my test scene at 1536x864, but mostly just to make sure my effects can handle awkward resolutions. My renderer uses DirectX 11 only.

The major passes you listed are all the ones I have in this effect (5). Of course, may of those have several passes to them as the downsample into smaller mip channels, but you listed all the big steps. I do split ray tracing and cone tracing into two separate passes. This is mainly because I've been meaning to go back and interject a pass between them to do some extra processing on the ray tracing buffer. This would be things like filling in small gaps of missed rays and maybe adding temporal stability, etc.

Thanks,

WFP

I'm again working on this effect and I'm stuck with the hidden-geometry problem.

How do you detect in the HiZRayTrace procedure if an intersection is invalid because of hidden geometry?

Here is a screenshot where the problem is clearly visible:

DevShot%2019%20%28Hidden%20Geometry%20Pr

At the marked areas there should actually no reflection. How can I solve this?

Moreover the following code part for ray traversal behind geometry does not work for me:


// Does not work for me: I get lots of artifacts and the ray traversal is not correct
vec3 tmpRay = IntersectDepthPlane(rayOrigin, rayDir, clamp(rayPos.z, zMinMax.r, zMinMax.g)); // MIN/MAX

// Only the minimal Z version works for me:
vec3 tmpRay = IntersectDepthPlane(rayOrigin, rayDir, max(rayPos.z, zMinMax.r)); // MIN

Hi LukasBanana,

If I'm looking at your scene correctly, it looks like those reflections are from rays that are traveling back towards the camera. I disallow such cases in my scene, and honestly between fall back methods like parallax corrected cube maps, I don't think I miss those reflections all that much (i.e., a player wouldn't notice them, I don't think). If you want to disallow rays traveling back towards the camera, you can use a dot product in the ray tracing step to detect and early exit if the ray is pointing backwards. If you absolutely want rays to be able to travel backwards, you'll have to do some additional processing for cases like what you're experiencing. It's been a while since I've read the chapter, so I can't remember if the author gave tips for this or not, but I think earlier in this thread someone else had rays coming back towards the camera, so maybe something in one of those posts would be helpful? I think it was jgrenier, so maybe look over his posts, but again I'm not positive.

Hope you get it straightened out smile.png

Hi, the red rectangle on the left marks indeed rays moving towards the camera.

I do this with a linear ray march. But the rectangle on the right shows the rays, computed with Hi-Z ray tracing.

Yasin Uludag talks about a way to travel rays behind geometry, but he does not explain it in detail.

Only that a min- and max Hi-Z buffer is required, and that it's quite complicated.

Anyway I won't spent much more time on this problem before I complete my Bachelor thesis.

Greetings,

Lukas

Hi Lukas,
I don't have my code in front of me at the moment, but a few things I can think of.

What format is your HiZ buffer? I'm storing scene depth in a DXGI_D32_FLOAT format, so use DXGI_FORMAT_R32G32 for my min/max HiZ buffer to make sure I can get the depth as accurate as possible.

Also, what MIP level (HiZ start) are you starting at and what is the highest level you let the effect run to (HiZ stop)?

Tracing behind objects should work in a lot of cases if you have the buffer constructed properly and have followed the code in this thread. There are still cases where it will fail, but that's always going to be the case for screen space effects where you're trying to reconstruct data that isn't available.

-WFP

I'm using R32G32 Float as well, and the min and max Z values are available to me in the final shader stage.

I start with the MIP level 2 and I stop when the MIP level reached 0.

Hi Lukas,

The best I can tell you right now are the values I'm using for my setup:


static const float HIZ_START_LEVEL = 0.0f; // always start <= HIZ_STOP_LEVEL
static const float HIZ_STOP_LEVEL = 0.0f; // set higher to use less iterations - quality vs performance tradeoff
static const float HIZ_MAX_LEVEL = float(cb_mipCount);
static const float2 HIZ_CROSS_EPSILON = float2(texelWidth, texelHeight) * 0.5f; // just needs to make sure in the next pixel, not skipping them entirely
static const uint MAX_ITERATIONS = 128u; // a good balance of quality vs performance - most common cases will not use anywhere near this full value
static const float2 hiZSize = cb_screenSize / exp2(HIZ_START_LEVEL);

I know you've said you can't share your code until your thesis is complete, but unfortunately I can't help much more without being able to see what you've got so far. If something changes, definitely post your code here and I'd be happy to review it.

Thanks,

WFP

This topic is closed to new replies.

Advertisement