OpenGL creen space reflections artifacts/information loss

  Kiến thức lập trình

I have some troubles with reducing information loss for screen space reflections, but I am struggling little bit with how to deal with them as I already applying some of the methods to deal with information loss. I Artifacts I am currently getting are on the pictures.
Here is my full code for screen space reflections, but I don’t think there is any issues:

vec2 RayBinarySearch(inout vec3 RayP, inout vec3 RayD, float Dist)
{
    const uint StepsCount = 16;
    vec4  ProjectedCoord  = vec4(0.0);

    for(uint StepIdx = 0; StepIdx < StepsCount; StepIdx++)
    {
        vec4 ProjectedRayCoord = WorldUpdate.Proj * vec4(RayP, 1.0);
        ProjectedRayCoord   /= ProjectedRayCoord.w;
        ProjectedRayCoord.xy = ProjectedRayCoord.xy * vec2(0.5, -0.5) + 0.5;

        vec3 SampledPosWS = textureLod(GBuffer[0], ProjectedRayCoord.xy, 2).xyz;
        vec3 SampledPosVS = (WorldUpdate.DebugView * vec4(SampledPosWS, 1.0)).xyz;

        float Delta = RayP.z - SampledPosVS.z;

        RayD *= 0.5;
        if(Delta > 0.0)
            RayP += RayD;
        else
            RayP -= RayD;
    }

    ProjectedCoord = WorldUpdate.Proj * vec4(RayP, 1.0);
    ProjectedCoord = ProjectedCoord / ProjectedCoord.w;
    return ProjectedCoord.xy * vec2(0.5, -0.5) + 0.5;
}

bool ReflectedRayCast(inout vec2 ReflTextCoord, vec3 Coord, vec3 ReflDir)
{
    vec3  RayP = Coord.xyz;
    vec3  RayD = ReflDir*max(MinRayStep, -Coord.z)*RayStep;

    for(uint StepIdx = 0; StepIdx < MaxSteps; ++StepIdx)
    {
        RayP += RayD;
        
        vec4 ProjectedRayCoord = WorldUpdate.Proj * vec4(RayP, 1.0);
        ProjectedRayCoord   /= ProjectedRayCoord.w;
        ProjectedRayCoord.xy = ProjectedRayCoord.xy * vec2(0.5, -0.5) + 0.5;

        vec3 SampledPosWS = textureLod(GBuffer[0], ProjectedRayCoord.xy, 2).xyz;
        vec3 SampledPosVS = (WorldUpdate.DebugView * vec4(SampledPosWS, 1.0)).xyz;
        if(SampledPosVS.z > WorldUpdate.FarZ) break;

        float Delta = RayP.z - SampledPosVS.z;

        if(((RayD.z - Delta) < 1.2) && (Delta < 0.0))
        {
            ReflTextCoord = RayBinarySearch(RayP, RayD, RayStep);
            return true;
        }
    }

    return false;
}

This is how I am doing so:

vec2  ReflTextCoord;
ReflectedRayCast(ReflTextCoord, , ReflDirVS + Jitt);
{
vec3  SampledReflPosWS = texture(GBuffer[0], ReflTextCoord).xyz;
float L = distance(SampledReflPosWS, CoordWS.xyz);
L = clamp(L * 0.2, 0.0, 1.0);
float Error = 1.0 - L;

vec2  dReflCoord = smoothstep(0.2, 0.6, abs(vec2(0.5) - ReflTextCoord));
float ScreenEdgeFactor = clamp(1.0 - (dReflCoord.x + dReflCoord.y), 0.0, 1.0);
float ReflectionMultiplier = pow(Metallic, 3.0) * ScreenEdgeFactor * -ReflDirVS.z;
Diffuse = texture(GBuffer[3], clamp(ReflTextCoord, 0.0, 1.0)) * clamp(ReflectionMultiplier, 0.0, 0.9) * Error * Fresnel0;
}

This is what I get(it all looks like there is clamp issues, but I am already clamping):
enter image description here
enter image description here
enter image description here
Could it be that I am just doing something wrong with dealing with information loss on ssr? Or could be there something else that can help me to deal with them?

LEAVE A COMMENT