Browse Source

Fixed anisotropy zero strength (#27164)

* fix ssl error

* fixed divide by zero

* updated screenshot

* fix screenshot
Emmett Lalish 1 year ago
parent
commit
164b23f2e7

BIN
examples/screenshots/webgl_loader_gltf_anisotropy.jpg


+ 1 - 1
package.json

@@ -44,7 +44,7 @@
     "test": "npm run lint && npm run test-unit",
     "build": "rollup -c utils/build/rollup.config.js",
     "build-module": "rollup -c utils/build/rollup.config.js --configOnlyModule",
-    "dev": "concurrently --names \"ROLLUP,HTTP\" -c \"bgBlue.bold,bgGreen.bold\" \"rollup -c utils/build/rollup.config.js -w -m inline\" \"servez -p 8080 --ssl\"",
+    "dev": "concurrently --names \"ROLLUP,HTTP\" -c \"bgBlue.bold,bgGreen.bold\" \"rollup -c utils/build/rollup.config.js -w -m inline\" \"servez -p 8080\"",
     "lint-core": "eslint src",
     "lint-addons": "eslint examples/jsm --ext .js --ignore-pattern libs --ignore-pattern ifc",
     "lint-examples": "eslint examples --ext .html",

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

@@ -133,8 +133,13 @@ material.roughness = min( material.roughness, 1.0 );
 	#endif
 
 	material.anisotropy = length( anisotropyV );
-	anisotropyV /= material.anisotropy;
-	material.anisotropy = saturate( material.anisotropy );
+
+	if( material.anisotropy == 0.0 ) {
+		anisotropyV = vec2( 1.0, 0.0 );
+	} else {
+		anisotropyV /= material.anisotropy;
+		material.anisotropy = saturate( material.anisotropy );
+	}
 
 	// Roughness along the anisotropy bitangent is the material roughness, while the tangent roughness increases with anisotropy.
 	material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );