|
@@ -44,9 +44,27 @@ class MeshPhysicalNodeMaterial extends MeshStandardNodeMaterial {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ get useClearcoat() {
|
|
|
|
+
|
|
|
|
+ return this.clearcoat > 0 || this.clearcoatNode !== null;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ get useIridescence() {
|
|
|
|
+
|
|
|
|
+ return this.iridescence > 0 || this.iridescenceNode !== null;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ get useSheen() {
|
|
|
|
+
|
|
|
|
+ return this.sheen > 0 || this.sheenNode !== null;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
setupLightingModel( /*builder*/ ) {
|
|
setupLightingModel( /*builder*/ ) {
|
|
|
|
|
|
- return new PhysicalLightingModel(); // @TODO: Optimize shader using parameters.
|
|
|
|
|
|
+ return new PhysicalLightingModel( this.useClearcoat, this.useSheen, this.useIridescence );
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -58,29 +76,41 @@ class MeshPhysicalNodeMaterial extends MeshStandardNodeMaterial {
|
|
|
|
|
|
// CLEARCOAT
|
|
// CLEARCOAT
|
|
|
|
|
|
- const clearcoatNode = this.clearcoatNode ? float( this.clearcoatNode ) : materialClearcoat;
|
|
|
|
- const clearcoatRoughnessNode = this.clearcoatRoughnessNode ? float( this.clearcoatRoughnessNode ) : materialClearcoatRoughness;
|
|
|
|
|
|
+ if ( this.useClearcoat ) {
|
|
|
|
+
|
|
|
|
+ const clearcoatNode = this.clearcoatNode ? float( this.clearcoatNode ) : materialClearcoat;
|
|
|
|
+ const clearcoatRoughnessNode = this.clearcoatRoughnessNode ? float( this.clearcoatRoughnessNode ) : materialClearcoatRoughness;
|
|
|
|
+
|
|
|
|
+ stack.assign( clearcoat, clearcoatNode );
|
|
|
|
+ stack.assign( clearcoatRoughness, clearcoatRoughnessNode );
|
|
|
|
|
|
- stack.assign( clearcoat, clearcoatNode );
|
|
|
|
- stack.assign( clearcoatRoughness, clearcoatRoughnessNode );
|
|
|
|
|
|
+ }
|
|
|
|
|
|
// SHEEN
|
|
// SHEEN
|
|
|
|
|
|
- const sheenNode = this.sheenNode ? vec3( this.sheenNode ) : materialSheen;
|
|
|
|
- const sheenRoughnessNode = this.sheenRoughnessNode ? float( this.sheenRoughnessNode ) : materialSheenRoughness;
|
|
|
|
|
|
+ if ( this.useSheen ) {
|
|
|
|
|
|
- stack.assign( sheen, sheenNode );
|
|
|
|
- stack.assign( sheenRoughness, sheenRoughnessNode );
|
|
|
|
|
|
+ const sheenNode = this.sheenNode ? vec3( this.sheenNode ) : materialSheen;
|
|
|
|
+ const sheenRoughnessNode = this.sheenRoughnessNode ? float( this.sheenRoughnessNode ) : materialSheenRoughness;
|
|
|
|
+
|
|
|
|
+ stack.assign( sheen, sheenNode );
|
|
|
|
+ stack.assign( sheenRoughness, sheenRoughnessNode );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
|
|
// IRIDESCENCE
|
|
// IRIDESCENCE
|
|
|
|
|
|
- const iridescenceNode = this.iridescenceNode ? float( this.iridescenceNode ) : materialIridescence;
|
|
|
|
- const iridescenceIORNode = this.iridescenceIORNode ? float( this.iridescenceIORNode ) : materialIridescenceIOR;
|
|
|
|
- const iridescenceThicknessNode = this.iridescenceThicknessNode ? float( this.iridescenceThicknessNode ) : materialIridescenceThickness;
|
|
|
|
|
|
+ if ( this.useIridescence ) {
|
|
|
|
+
|
|
|
|
+ const iridescenceNode = this.iridescenceNode ? float( this.iridescenceNode ) : materialIridescence;
|
|
|
|
+ const iridescenceIORNode = this.iridescenceIORNode ? float( this.iridescenceIORNode ) : materialIridescenceIOR;
|
|
|
|
+ const iridescenceThicknessNode = this.iridescenceThicknessNode ? float( this.iridescenceThicknessNode ) : materialIridescenceThickness;
|
|
|
|
+
|
|
|
|
+ stack.assign( iridescence, iridescenceNode );
|
|
|
|
+ stack.assign( iridescenceIOR, iridescenceIORNode );
|
|
|
|
+ stack.assign( iridescenceThickness, iridescenceThicknessNode );
|
|
|
|
|
|
- stack.assign( iridescence, iridescenceNode );
|
|
|
|
- stack.assign( iridescenceIOR, iridescenceIORNode );
|
|
|
|
- stack.assign( iridescenceThickness, iridescenceThicknessNode );
|
|
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|