Skip to content

Commit

Permalink
smooth out material roughness transitions from 0.0 to 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
erichlof authored Nov 30, 2024
1 parent f712162 commit f19a672
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions shaders/Material_Roughness_Fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ vec3 CalculateRadiance( out vec3 objectNormal, out vec3 objectColor, out float o
{
mask *= 1.1;
rayDirection = reflect(rayDirection, nl); // reflect ray from metal surface
rayDirection = randomDirectionInSpecularLobe(rayDirection, hitRoughness == 0.1 ? 0.2 : hitRoughness * 0.8);
rayDirection = randomDirectionInSpecularLobe(rayDirection, hitRoughness == 0.1 ? 0.25 : hitRoughness * 0.8);
rayOrigin = x + nl * uEPS_intersect;
continue;
}
Expand Down Expand Up @@ -489,7 +489,7 @@ vec3 CalculateRadiance( out vec3 objectNormal, out vec3 objectColor, out float o
{
reflectionMask = mask * Re;
reflectionRayDirection = reflect(rayDirection, nl); // reflect ray from surface
reflectionRayDirection = randomDirectionInSpecularLobe(reflectionRayDirection, hitRoughness * 0.9);
reflectionRayDirection = randomDirectionInSpecularLobe(reflectionRayDirection, hitRoughness * 0.8);
reflectionRayOrigin = x + nl * uEPS_intersect;
willNeedReflectionRay = TRUE;
}
Expand All @@ -505,7 +505,7 @@ vec3 CalculateRadiance( out vec3 objectNormal, out vec3 objectColor, out float o
mask *= Tr;

rayDirection = refract(rayDirection, nl, ratioIoR);
rayDirection = randomDirectionInSpecularLobe(rayDirection, hitRoughness * 0.5);
rayDirection = randomDirectionInSpecularLobe(rayDirection, hitRoughness * 0.4);
rayOrigin = x - nl * uEPS_intersect;

if (diffuseCount == 1 && isReflectionTime == FALSE)
Expand All @@ -526,7 +526,7 @@ vec3 CalculateRadiance( out vec3 objectNormal, out vec3 objectColor, out float o
{
reflectionMask = mask * Re;
reflectionRayDirection = reflect(rayDirection, nl); // reflect ray from surface
reflectionRayDirection = randomDirectionInSpecularLobe(reflectionRayDirection, hitRoughness * 0.9);
reflectionRayDirection = randomDirectionInSpecularLobe(reflectionRayDirection, hitRoughness * 0.8);
reflectionRayOrigin = x + nl * uEPS_intersect;
willNeedReflectionRay = TRUE;
}
Expand Down Expand Up @@ -582,7 +582,7 @@ vec3 CalculateRadiance( out vec3 objectNormal, out vec3 objectColor, out float o
mask *= hitColor;

rayDirection = reflect(rayDirection, nl); // reflect ray from metal surface
rayDirection = randomDirectionInSpecularLobe(rayDirection, hitRoughness * 0.9);
rayDirection = randomDirectionInSpecularLobe(rayDirection, hitRoughness == 0.1 ? 0.25 : hitRoughness * 0.8);
rayOrigin = x + nl * uEPS_intersect;
continue;

Expand Down

0 comments on commit f19a672

Please sign in to comment.