|
@@ -1,7 +1,13 @@
|
|
|
export default /* glsl */`
|
|
|
PhysicalMaterial material;
|
|
|
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
|
|
|
-material.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );
|
|
|
+
|
|
|
+vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );
|
|
|
+float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
|
|
|
+
|
|
|
+material.specularRoughness = max( roughnessFactor, 0.0525 );// 0.0525 corresponds to the base mip of a 256 cubemap.
|
|
|
+material.specularRoughness += geometryRoughness;
|
|
|
+material.specularRoughness = min( material.specularRoughness, 1.0 );
|
|
|
|
|
|
#ifdef REFLECTIVITY
|
|
|
|
|
@@ -16,7 +22,9 @@ material.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );
|
|
|
#ifdef CLEARCOAT
|
|
|
|
|
|
material.clearcoat = saturate( clearcoat ); // Burley clearcoat model
|
|
|
- material.clearcoatRoughness = clamp( clearcoatRoughness, 0.04, 1.0 );
|
|
|
+ material.clearcoatRoughness = max( roughnessFactor, 0.0525 );
|
|
|
+ material.clearcoatRoughness += geometryRoughness;
|
|
|
+ material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
|
|
|
|
|
|
#endif
|
|
|
#ifdef USE_SHEEN
|