We found a reflection issue on the clear coat materials that when enabling the fog, the color on the clear coat surface would be too bright and like a mirror.
Here I will offer what I found and a solution for this issue and hopefully it could help you. And I hope the Unreal Team could see it and fix the bug on the mainstream as soon as possible because there might be a lot of people are still suffering from the issue as well.
After investigating the shader code of ray-tracing reflections, I found the following code from RayTracingReflections.usf causes the issue.
// Now accumulate the radiance coming through this path segment into the full path radiance.
// In the case of clear coat material: the fog is applied once for both bottom and top layer using the main top layer refelction path.
float3 PathSegmentRadiance = TopLayerRadiance * TopLayerReflectionEventThroughput + BottomLayerRadiance;
PathSegmentRadiance = PathSegmentRadiance * HeightFogInscatteringAndTransmittance.a + HeightFogInscatteringAndTransmittance.rgb;
PathRadiance += PathSegmentRadiance * PathThroughput;
// Update the path throughput according to fog and material top layer reflection event.
PathThroughput *= HeightFogInscatteringAndTransmittance.a * TopLayerReflectionEventThroughput;
The reason why it’s wrong is that they thought every bounce of reflection likes the following schematic diagram:
But the truth is:
Thus, I modified the shader code as following and it solved the issue well:
// Now accumulate the radiance coming through this path segment into the full path radiance.
// In the case of clear coat material: the fog is applied once for both bottom and top layer using the main top layer refelction path.
float3 PathSegmentRadiance = TopLayerRadiance + HeightFogInscatteringAndTransmittance.rgb;
PathSegmentRadiance = PathSegmentRadiance * TopLayerReflectionEventThroughput;
PathSegmentRadiance += BottomLayerRadiance;
PathRadiance += PathSegmentRadiance * PathThroughput;
// Update the path throughput according to fog and material top layer reflection event.
PathThroughput *= HeightFogInscatteringAndTransmittance.a * TopLayerReflectionEventThroughput;
Examples after the fix: