# How to have point of view independent Screen Space Reflection deepness

With regular raymarching algorithm we can fade the reflected pixel based on the number of iterations used when looping. I can’t use an iteration number when doing both hierarchical z (HiZ) and raymarching loop for refinement as the two loops did not work the same. Using a global iteration value produces incoherent fading.

To obtain a fading aspect that works for both I’m using this : SSRcolor = float4(Color,1-abs(SSray.z-D)*500);

Where color is the color of the scene (multilayer), SSray.z is the depth when the ray hits something in one layer, D is the initial depth from where the ray started. 500 accounts for the depth difference compared to 1. 500 gives good results for my needs but it can be more for more fading or less for less fading.

A problem I have when using an iteration or depth-based fading is that the fading ratio is POV dependent as shown in picture. For iterations I guess you are doing more loop rounds when closer and for Depth-based fading the closer you are the bigger SSray.z-D must be.

Is it possible to make the fading POV independent? Taking the constant 500 as a starting point can we design a formula for it taking into account the distance to POV or something like that.

• Depth does not change with point of view. It does change with view angle, since it's only measured along the "forward" direction, unlike distance, which is the full length of the ray. Have you tried using ray length instead of depth for this purpose? Commented Oct 20, 2022 at 12:57
• I'll check that. thanks Commented Oct 20, 2022 at 15:32
• It works a little bit better with the length but the fading is still not constant upon moving. It's full opaque when I go far from the scene. Is it important to mention my raymarching is made in screen space? Commented Oct 20, 2022 at 15:57
• after some try in either screen/view/world space the result with the length is almost the same. In between I have observed that it is better to have a raymarching step dependent on the position in view space to have better sampling for far objects to avoid the "sliced" look. Some work still need to find where is the fading problem. Commented Oct 21, 2022 at 8:47
• View and World Space are in the same units, so of course the length is the same between them. Commented Oct 21, 2022 at 9:33

As stated in the comments using the length of the ray from start to the hit point was better working but not fully satisfying. What works the best for me is to make this length relative to the maximum expected length. Something like:

 float3 RayStart = float3(Input.TexCoord.xy, Depth); //I'm doing SSR in screen space
float3 RayEnd = RayStart + RayDir*MaxDistance
float MaxLength = length(RayEnd-RayStart);

float3 RayHit = RayStart;
do SSR stuff until RayHit find something


  get PosV as the starting position of the ray (in view space for me at this stage).