소스 검색

added geometric anti-aliasing

Emmett Lalish 5 년 전
부모
커밋
06b8143d9e
1개의 변경된 파일10개의 추가작업 그리고 2개의 파일을 삭제
  1. 10 2
      src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js

+ 10 - 2
src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js

@@ -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