diff --git a/examples/js/nodes/materials/PhongNode.js b/examples/js/nodes/materials/PhongNode.js index a88183bbf1b2f0..dce7b040a8e627 100644 --- a/examples/js/nodes/materials/PhongNode.js +++ b/examples/js/nodes/materials/PhongNode.js @@ -45,21 +45,20 @@ THREE.PhongNode.prototype.build = function ( builder ) { "#endif", - THREE.ShaderChunk[ "common" ], - THREE.ShaderChunk[ "fog_pars_vertex" ], - THREE.ShaderChunk[ "morphtarget_pars_vertex" ], - THREE.ShaderChunk[ "skinning_pars_vertex" ], - THREE.ShaderChunk[ "shadowmap_pars_vertex" ], - THREE.ShaderChunk[ "logdepthbuf_pars_vertex" ] - + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include " ].join( "\n" ) ); var output = [ - THREE.ShaderChunk[ "beginnormal_vertex" ], - THREE.ShaderChunk[ "morphnormal_vertex" ], - THREE.ShaderChunk[ "skinbase_vertex" ], - THREE.ShaderChunk[ "skinnormal_vertex" ], - THREE.ShaderChunk[ "defaultnormal_vertex" ], + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", "#ifndef FLAT_SHADED", // Normal computed with derivatives when FLAT_SHADED @@ -67,7 +66,7 @@ THREE.PhongNode.prototype.build = function ( builder ) { "#endif", - THREE.ShaderChunk[ "begin_vertex" ] + "#include " ]; if ( transform ) { @@ -80,16 +79,16 @@ THREE.PhongNode.prototype.build = function ( builder ) { } output.push( - THREE.ShaderChunk[ "morphtarget_vertex" ], - THREE.ShaderChunk[ "skinning_vertex" ], - THREE.ShaderChunk[ "project_vertex" ], - THREE.ShaderChunk[ "fog_vertex" ], - THREE.ShaderChunk[ "logdepthbuf_vertex" ], + " #include ", + " #include ", + " #include ", + " #include ", + " #include ", " vViewPosition = - mvPosition.xyz;", - THREE.ShaderChunk[ "worldpos_vertex" ], - THREE.ShaderChunk[ "shadowmap_vertex" ] + " #include ", + " #include " ); code = output.join( "\n" ); @@ -141,28 +140,28 @@ THREE.PhongNode.prototype.build = function ( builder ) { material.requestAttribs.transparent = alpha != undefined; material.addFragmentPars( [ - THREE.ShaderChunk[ "common" ], - THREE.ShaderChunk[ "fog_pars_fragment" ], - THREE.ShaderChunk[ "bsdfs" ], - THREE.ShaderChunk[ "lights_pars" ], - THREE.ShaderChunk[ "lights_phong_pars_fragment" ], - THREE.ShaderChunk[ "shadowmap_pars_fragment" ], - THREE.ShaderChunk[ "logdepthbuf_pars_fragment" ] + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include " ].join( "\n" ) ); var output = [ - // prevent undeclared normal - THREE.ShaderChunk[ "normal_flip" ], - THREE.ShaderChunk[ "normal_fragment" ], + // prevent undeclared normal + "#include ", + "#include ", - // prevent undeclared material + // prevent undeclared material " BlinnPhongMaterial material;", color.code, " vec3 diffuseColor = " + color.result + ";", " ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );", - THREE.ShaderChunk[ "logdepthbuf_fragment" ], + "#include ", specular.code, " vec3 specular = " + specular.result + ";", @@ -209,7 +208,7 @@ THREE.PhongNode.prototype.build = function ( builder ) { 'material.specularShininess = shininess;', 'material.specularStrength = specularStrength;', - THREE.ShaderChunk[ "lights_template" ] + "#include " ); if ( light ) { @@ -297,10 +296,10 @@ THREE.PhongNode.prototype.build = function ( builder ) { } output.push( - THREE.ShaderChunk[ "premultiplied_alpha_fragment" ], - THREE.ShaderChunk[ "tonemapping_fragment" ], - THREE.ShaderChunk[ "encodings_fragment" ], - THREE.ShaderChunk[ "fog_fragment" ] + "#include ", + "#include ", + "#include ", + "#include " ); code = output.join( "\n" ); diff --git a/examples/js/nodes/materials/SpriteNode.js b/examples/js/nodes/materials/SpriteNode.js index 8ad946029e417f..9ed09b29112c4f 100644 --- a/examples/js/nodes/materials/SpriteNode.js +++ b/examples/js/nodes/materials/SpriteNode.js @@ -33,11 +33,11 @@ THREE.SpriteNode.prototype.build = function ( builder ) { ] ) ); material.addVertexPars( [ - THREE.ShaderChunk[ "fog_pars_vertex" ], + "#include " ].join( "\n" ) ); output = [ - THREE.ShaderChunk[ "begin_vertex" ] + "#include " ]; if ( transform ) { @@ -51,8 +51,8 @@ THREE.SpriteNode.prototype.build = function ( builder ) { output.push( - THREE.ShaderChunk[ "project_vertex" ], - THREE.ShaderChunk[ "fog_vertex" ], + "#include ", + "#include ", 'mat4 modelViewMtx = modelViewMatrix;', 'mat4 modelMtx = modelMatrix;', @@ -106,12 +106,10 @@ THREE.SpriteNode.prototype.build = function ( builder ) { 'gl_Position = projectionMatrix * modelViewMtx * modelMtx * vec4( position, 1.0 );' ); - code = output.join( "\n" ); - } else { material.addFragmentPars( [ - THREE.ShaderChunk[ "fog_pars_fragment" ] + "#include ", ].join( "\n" ) ); // parse all nodes to reuse generate codes @@ -139,12 +137,10 @@ THREE.SpriteNode.prototype.build = function ( builder ) { } - output.push( THREE.ShaderChunk[ "fog_fragment" ] ); - - code = output.join( "\n" ); + output.push( "#include " ); } - return code; + return output.join( "\n" ); }; diff --git a/examples/js/nodes/materials/StandardNode.js b/examples/js/nodes/materials/StandardNode.js index 02a4682b6291b1..62c0d097fc5362 100644 --- a/examples/js/nodes/materials/StandardNode.js +++ b/examples/js/nodes/materials/StandardNode.js @@ -50,21 +50,24 @@ THREE.StandardNode.prototype.build = function ( builder ) { "#endif", - THREE.ShaderChunk[ "common" ], - THREE.ShaderChunk[ "fog_pars_vertex" ], - THREE.ShaderChunk[ "morphtarget_pars_vertex" ], - THREE.ShaderChunk[ "skinning_pars_vertex" ], - THREE.ShaderChunk[ "shadowmap_pars_vertex" ], - THREE.ShaderChunk[ "logdepthbuf_pars_vertex" ] + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include " ].join( "\n" ) ); var output = [ - THREE.ShaderChunk[ "beginnormal_vertex" ], - THREE.ShaderChunk[ "morphnormal_vertex" ], - THREE.ShaderChunk[ "skinbase_vertex" ], - THREE.ShaderChunk[ "skinnormal_vertex" ], - THREE.ShaderChunk[ "defaultnormal_vertex" ], + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", "#ifndef FLAT_SHADED", // Normal computed with derivatives when FLAT_SHADED @@ -72,7 +75,7 @@ THREE.StandardNode.prototype.build = function ( builder ) { "#endif", - THREE.ShaderChunk[ "begin_vertex" ] + "#include " ]; if ( transform ) { @@ -85,16 +88,16 @@ THREE.StandardNode.prototype.build = function ( builder ) { } output.push( - THREE.ShaderChunk[ "morphtarget_vertex" ], - THREE.ShaderChunk[ "skinning_vertex" ], - THREE.ShaderChunk[ "project_vertex" ], - THREE.ShaderChunk[ "fog_vertex" ], - THREE.ShaderChunk[ "logdepthbuf_vertex" ], + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", " vViewPosition = - mvPosition.xyz;", - THREE.ShaderChunk[ "worldpos_vertex" ], - THREE.ShaderChunk[ "shadowmap_vertex" ] + "#include ", + "#include " ); code = output.join( "\n" ); @@ -175,19 +178,20 @@ THREE.StandardNode.prototype.build = function ( builder ) { "#endif", - THREE.ShaderChunk[ "common" ], - THREE.ShaderChunk[ "fog_pars_fragment" ], - THREE.ShaderChunk[ "bsdfs" ], - THREE.ShaderChunk[ "lights_pars" ], - THREE.ShaderChunk[ "lights_physical_pars_fragment" ], - THREE.ShaderChunk[ "shadowmap_pars_fragment" ], - THREE.ShaderChunk[ "logdepthbuf_pars_fragment" ] + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include " ].join( "\n" ) ); var output = [ // prevent undeclared normal - THREE.ShaderChunk[ "normal_flip" ], - THREE.ShaderChunk[ "normal_fragment" ], + " #include ", + " #include ", // prevent undeclared material " PhysicalMaterial material;", @@ -197,7 +201,7 @@ THREE.StandardNode.prototype.build = function ( builder ) { " vec3 diffuseColor = " + color.result + ";", " ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );", - THREE.ShaderChunk[ "logdepthbuf_fragment" ], + "#include ", roughness.code, " float roughnessFactor = " + roughness.result + ";", @@ -283,7 +287,7 @@ THREE.StandardNode.prototype.build = function ( builder ) { } output.push( - THREE.ShaderChunk[ "lights_template" ] + "#include " ); if ( light ) { @@ -377,10 +381,10 @@ THREE.StandardNode.prototype.build = function ( builder ) { } output.push( - THREE.ShaderChunk[ "premultiplied_alpha_fragment" ], - THREE.ShaderChunk[ "tonemapping_fragment" ], - THREE.ShaderChunk[ "encodings_fragment" ], - THREE.ShaderChunk[ "fog_fragment" ] + "#include ", + "#include ", + "#include ", + "#include " ); code = output.join( "\n" );