Skip to content

Commit 041d928

Browse files
takahiroxabernier
authored andcommitted
MMDLoader: Handle shininess properly (mrdoob#23889)
MMDToonMaterial is derived from MeshToon/Phong/MatcapMaterial. Similar to MeshPhongMaterial, shininess should have lower limit to prevent pow(0.0, 0.0) in the shader code.
1 parent bc11d94 commit 041d928

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

examples/jsm/loaders/MMDLoader.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2133,7 +2133,6 @@ class MMDToonMaterial extends ShaderMaterial {
21332133
// merged from MeshToon/Phong/MatcapMaterial
21342134
const exposePropertyNames = [
21352135
'specular',
2136-
'shininess',
21372136
'opacity',
21382137
'diffuse',
21392138

@@ -2188,6 +2187,25 @@ class MMDToonMaterial extends ShaderMaterial {
21882187

21892188
}
21902189

2190+
// Special path for shininess to handle zero shininess properly
2191+
this._shininess = 30;
2192+
Object.defineProperty( this, 'shininess', {
2193+
2194+
get: function () {
2195+
2196+
return this._shininess;
2197+
2198+
},
2199+
2200+
set: function ( value ) {
2201+
2202+
this._shininess = value;
2203+
this.uniforms.shininess.value = Math.max( this._shininess, 1e-4 ); // To prevent pow( 0.0, 0.0 )
2204+
2205+
},
2206+
2207+
} );
2208+
21912209
Object.defineProperty(
21922210
this,
21932211
'color',

0 commit comments

Comments
 (0)