|
@@ -117,6 +117,8 @@ StandardNode.prototype.build = function ( builder ) {
|
|
|
|
|
|
// parse all nodes to reuse generate codes
|
|
// parse all nodes to reuse generate codes
|
|
|
|
|
|
|
|
+ if ( this.mask ) this.mask.parse( builder );
|
|
|
|
+
|
|
this.color.parse( builder, { slot: 'color', context: contextGammaOnly } );
|
|
this.color.parse( builder, { slot: 'color', context: contextGammaOnly } );
|
|
this.roughness.parse( builder );
|
|
this.roughness.parse( builder );
|
|
this.metalness.parse( builder );
|
|
this.metalness.parse( builder );
|
|
@@ -141,6 +143,8 @@ StandardNode.prototype.build = function ( builder ) {
|
|
|
|
|
|
// build code
|
|
// build code
|
|
|
|
|
|
|
|
+ var mask = this.mask ? this.mask.buildCode( builder, 'f' ) : undefined;
|
|
|
|
+
|
|
var color = this.color.buildCode( builder, 'c', { slot: 'color', context: contextGammaOnly } );
|
|
var color = this.color.buildCode( builder, 'c', { slot: 'color', context: contextGammaOnly } );
|
|
var roughness = this.roughness.buildCode( builder, 'f' );
|
|
var roughness = this.roughness.buildCode( builder, 'f' );
|
|
var metalness = this.metalness.buildCode( builder, 'f' );
|
|
var metalness = this.metalness.buildCode( builder, 'f' );
|
|
@@ -194,8 +198,19 @@ StandardNode.prototype.build = function ( builder ) {
|
|
|
|
|
|
// add before: prevent undeclared material
|
|
// add before: prevent undeclared material
|
|
" PhysicalMaterial material;",
|
|
" PhysicalMaterial material;",
|
|
- " material.diffuseColor = vec3( 1.0 );",
|
|
|
|
|
|
+ " material.diffuseColor = vec3( 1.0 );"
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ if ( mask ) {
|
|
|
|
+
|
|
|
|
+ output.push(
|
|
|
|
+ mask.code,
|
|
|
|
+ 'if ( ' + mask.result + ' ) discard;'
|
|
|
|
+ );
|
|
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ output.push(
|
|
color.code,
|
|
color.code,
|
|
" vec3 diffuseColor = " + color.result + ";",
|
|
" vec3 diffuseColor = " + color.result + ";",
|
|
" ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",
|
|
" ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",
|
|
@@ -207,7 +222,7 @@ StandardNode.prototype.build = function ( builder ) {
|
|
|
|
|
|
metalness.code,
|
|
metalness.code,
|
|
" float metalnessFactor = " + metalness.result + ";"
|
|
" float metalnessFactor = " + metalness.result + ";"
|
|
- ];
|
|
|
|
|
|
+ );
|
|
|
|
|
|
if ( alpha ) {
|
|
if ( alpha ) {
|
|
|
|
|
|
@@ -215,7 +230,7 @@ StandardNode.prototype.build = function ( builder ) {
|
|
alpha.code,
|
|
alpha.code,
|
|
'#ifdef ALPHATEST',
|
|
'#ifdef ALPHATEST',
|
|
|
|
|
|
- 'if ( ' + alpha.result + ' <= ALPHATEST ) discard;',
|
|
|
|
|
|
+ ' if ( ' + alpha.result + ' <= ALPHATEST ) discard;',
|
|
|
|
|
|
'#endif'
|
|
'#endif'
|
|
);
|
|
);
|
|
@@ -403,6 +418,8 @@ StandardNode.prototype.copy = function ( source ) {
|
|
this.roughness = source.roughness;
|
|
this.roughness = source.roughness;
|
|
this.metalness = source.metalness;
|
|
this.metalness = source.metalness;
|
|
|
|
|
|
|
|
+ if ( source.mask ) this.mask = source.mask;
|
|
|
|
+
|
|
if ( source.alpha ) this.alpha = source.alpha;
|
|
if ( source.alpha ) this.alpha = source.alpha;
|
|
|
|
|
|
if ( source.normal ) this.normal = source.normal;
|
|
if ( source.normal ) this.normal = source.normal;
|
|
@@ -442,6 +459,8 @@ StandardNode.prototype.toJSON = function ( meta ) {
|
|
data.roughness = this.roughness.toJSON( meta ).uuid;
|
|
data.roughness = this.roughness.toJSON( meta ).uuid;
|
|
data.metalness = this.metalness.toJSON( meta ).uuid;
|
|
data.metalness = this.metalness.toJSON( meta ).uuid;
|
|
|
|
|
|
|
|
+ if ( this.mask ) data.mask = this.mask.toJSON( meta ).uuid;
|
|
|
|
+
|
|
if ( this.alpha ) data.alpha = this.alpha.toJSON( meta ).uuid;
|
|
if ( this.alpha ) data.alpha = this.alpha.toJSON( meta ).uuid;
|
|
|
|
|
|
if ( this.normal ) data.normal = this.normal.toJSON( meta ).uuid;
|
|
if ( this.normal ) data.normal = this.normal.toJSON( meta ).uuid;
|