Advertisement

Screen Space Reflections and 1 year long headache

Started by July 07, 2017 11:33 PM
19 comments, last by WFP 7 years, 7 months ago

Crap!  Sorry again for the delay, let's see if we can get you sorted out :)

If this is a full-screen pass, I would suggest trying the position reconstruction from my other post and see how that works out for you.  Also - are you sure that the water surface is written to the depth buffer?  If the game draws it as a transparent surface, it may disable writes when drawing it.  That would mean you're actually using the land surface underneath the water as the reflection start point.  I would first try using the projected view ray I mentioned and see if that gets you anywhere:


o10 = mul(modelView, v0.xyzw); //viewPosition
o10 = float4(o10.xy / o10.z, 1.0f, o10.w);

If you're doing the SSR as part of the water shader itself, i.e. at the same time as drawing the transformed water geometry, you should be able to calculate the view space position and pass it through to the pixel shader, then use that value directly instead of combining it with a linearized depth value.

Let me know if any of that helps.

That's awesome mate. I've tried your suggestions but it's now a striped mess :)

dirt3_game_2017_07_12_15_40_15_282.png

and this is the depth buffer I'm sampling from (scaled values to actually see anything)

dirt3_game_2017_07_12_15_34_32_086.png

Advertisement

Is there a particular reason you're negating these values?


traceScreenSpaceRay(-rayOriginVS, -rayDirectionVS

 

Just now, WFP said:

Is there a particular reason you're negating these values?



traceScreenSpaceRay(-rayOriginVS, -rayDirectionVS

 

This is what DarkStarSword(3DMigoto dev) suggested, so I left it untouched as well as these lines


float rayLength = ((csOrig.z + csDir.z * far) > -near) ? (-near - csOrig.z) / csDir.z : far;

It was originally like below, as far as I remember:


float rayLength = ((csOrig.z + csDir.z * far) < near) ? (near - csOrig.z) / csDir.z : far;

 

For thoroughness's sake, would you mind switching them back to non-negated versions and seeing if that helps?  Could you also test with the original rayLength code?

Does the game use a right- or left-handed coordinate system?

I've changed it back, but it introduced even more artiffacts. The stripes became circles. I assume it's due to the low poly mesh of the water surface ( fyi, water is split into 12 shaders depending on whether it's deep, shore rainy or even if the car is in it or not, so the poly count differs).

I've moved division by Z to the pixel shader and I've got the same result as in my recent screenshot.

Advertisement

I believe the coord system is lefthanded.

dirt3_game_2017_07_12_16_29_29_338.png

As you can see the boat is visible, but shifted upwards. The rock's reflection is still not visible.

Admittedly, I've done very little with stereo rendering, but perhaps this offset needs to be accounted for in your vertex shader?


	float4 stereo = StereoParams.Load(0);
	float separation = stereo.x * (leftEye ? -1 : 1);
	float convergence = stereo.y;
	viewPosition.x += separation * convergence * inverseProj._m00;

The view ray you create in the vertex shader may need to be adjusted similarly to align correctly.  Just kinda guessing at the moment :)

The stereo fix (added by DSS) should have no effect when rendering to mono, but I commented it to be sure. The result is the same unfortunately.

Is there any chance that you could install dirt3 and try my shaders yourself?

Debugging is easier than during game developement, as you just press F9 to see the changes.

I won't have time to do a full install and all that, but if you can grab a capture with RenderDoc (or a few captures with different deficiencies showing), I might be able to step through the shader that way and see what could be going on.  Can't promise when I'll have a lot of focused time to sit down with it, but I'll try to as soon as I can.

This topic is closed to new replies.

Advertisement