Skip to content

Commit

Permalink
Update Material_Roughness_Fragment.glsl
Browse files Browse the repository at this point in the history
  • Loading branch information
erichlof authored Nov 25, 2024
1 parent 9a2ff60 commit 30ba1bf
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions shaders/Material_Roughness_Fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,6 @@ vec3 CalculateRadiance( out vec3 objectNormal, out vec3 objectColor, out float o
int previousIntersecType = -100;
hitType = -100;

int coatTypeIntersected = FALSE;
int bounceIsSpecular = TRUE;
int sampleLight = FALSE;
int willNeedReflectionRay = FALSE;
Expand Down Expand Up @@ -433,17 +432,21 @@ vec3 CalculateRadiance( out vec3 objectNormal, out vec3 objectColor, out float o

if (hitType == SPEC) // Ideal SPECULAR reflection
{

mask *= hitColor;
mask *= 1.25;

if (diffuseCount == 0 && rand() >= hitRoughness)
if (diffuseCount == 0 && rand() > (hitRoughness * hitRoughness))
{
mask *= 1.1;
rayDirection = reflect(rayDirection, nl); // reflect ray from metal surface
rayDirection = randomDirectionInSpecularLobe(rayDirection, hitRoughness * 0.9);
rayDirection = randomDirectionInSpecularLobe(rayDirection, hitRoughness == 0.1 ? 0.2 : hitRoughness * 0.8);
rayOrigin = x + nl * uEPS_intersect;
continue;
}

if (diffuseCount == 0)
mask /= max(0.7, 1.0 - (hitRoughness * hitRoughness));

diffuseCount++;

bounceIsSpecular = FALSE;
Expand Down Expand Up @@ -514,8 +517,6 @@ vec3 CalculateRadiance( out vec3 objectNormal, out vec3 objectColor, out float o

if (hitType == COAT) // Diffuse object underneath with ClearCoat on top
{
coatTypeIntersected = TRUE;

nc = 1.0; // IOR of Air
nt = 1.5; // IOR of Clear Coat
Re = calcFresnelReflectance(rayDirection, nl, nc, nt, ratioIoR);
Expand Down

0 comments on commit 30ba1bf

Please sign in to comment.