Browse Source

Simplify with new shader chunks (#22271)

WestLangley 4 years ago
parent
commit
ddc86e8de3

+ 1 - 13
src/renderers/shaders/ShaderLib/meshmatcap_frag.glsl.js

@@ -7,19 +7,6 @@ uniform sampler2D matcap;
 
 varying vec3 vViewPosition;
 
-#ifndef FLAT_SHADED
-
-	varying vec3 vNormal;
-
-	#ifdef USE_TANGENT
-
-		varying vec3 vTangent;
-		varying vec3 vBitangent;
-
-	#endif
-
-#endif
-
 #include <common>
 #include <dithering_pars_fragment>
 #include <color_pars_fragment>
@@ -28,6 +15,7 @@ varying vec3 vViewPosition;
 #include <alphamap_pars_fragment>
 
 #include <fog_pars_fragment>
+#include <normal_pars_fragment>
 #include <bumpmap_pars_fragment>
 #include <normalmap_pars_fragment>
 #include <logdepthbuf_pars_fragment>

+ 2 - 26
src/renderers/shaders/ShaderLib/meshmatcap_vert.glsl.js

@@ -3,24 +3,12 @@ export default /* glsl */`
 
 varying vec3 vViewPosition;
 
-#ifndef FLAT_SHADED
-
-	varying vec3 vNormal;
-
-	#ifdef USE_TANGENT
-
-		varying vec3 vTangent;
-		varying vec3 vBitangent;
-
-	#endif
-
-#endif
-
 #include <common>
 #include <uv_pars_vertex>
 #include <color_pars_vertex>
 #include <displacementmap_pars_vertex>
 #include <fog_pars_vertex>
+#include <normal_pars_vertex>
 #include <morphtarget_pars_vertex>
 #include <skinning_pars_vertex>
 
@@ -36,19 +24,7 @@ void main() {
 	#include <skinbase_vertex>
 	#include <skinnormal_vertex>
 	#include <defaultnormal_vertex>
-
-	#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED
-
-		vNormal = normalize( transformedNormal );
-
-		#ifdef USE_TANGENT
-
-			vTangent = normalize( transformedTangent );
-			vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
-
-		#endif
-
-	#endif
+	#include <normal_vertex>
 
 	#include <begin_vertex>
 	#include <morphtarget_vertex>

+ 1 - 13
src/renderers/shaders/ShaderLib/meshphysical_frag.glsl.js

@@ -48,19 +48,6 @@ uniform float opacity;
 
 varying vec3 vViewPosition;
 
-#ifndef FLAT_SHADED
-
-	varying vec3 vNormal;
-
-	#ifdef USE_TANGENT
-
-		varying vec3 vTangent;
-		varying vec3 vBitangent;
-
-	#endif
-
-#endif
-
 #include <common>
 #include <packing>
 #include <dithering_pars_fragment>
@@ -79,6 +66,7 @@ varying vec3 vViewPosition;
 #include <envmap_physical_pars_fragment>
 #include <fog_pars_fragment>
 #include <lights_pars_begin>
+#include <normal_pars_fragment>
 #include <lights_physical_pars_fragment>
 #include <shadowmap_pars_fragment>
 #include <bumpmap_pars_fragment>

+ 2 - 26
src/renderers/shaders/ShaderLib/meshphysical_vert.glsl.js

@@ -3,19 +3,6 @@ export default /* glsl */`
 
 varying vec3 vViewPosition;
 
-#ifndef FLAT_SHADED
-
-	varying vec3 vNormal;
-
-	#ifdef USE_TANGENT
-
-		varying vec3 vTangent;
-		varying vec3 vBitangent;
-
-	#endif
-
-#endif
-
 #ifdef USE_TRANSMISSION
 
 	varying vec4 vWorldPosition;
@@ -28,6 +15,7 @@ varying vec3 vViewPosition;
 #include <displacementmap_pars_vertex>
 #include <color_pars_vertex>
 #include <fog_pars_vertex>
+#include <normal_pars_vertex>
 #include <morphtarget_pars_vertex>
 #include <skinning_pars_vertex>
 #include <shadowmap_pars_vertex>
@@ -45,19 +33,7 @@ void main() {
 	#include <skinbase_vertex>
 	#include <skinnormal_vertex>
 	#include <defaultnormal_vertex>
-
-#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED
-
-	vNormal = normalize( transformedNormal );
-
-	#ifdef USE_TANGENT
-
-		vTangent = normalize( transformedTangent );
-		vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
-
-	#endif
-
-#endif
+	#include <normal_vertex>
 
 	#include <begin_vertex>
 	#include <morphtarget_vertex>

+ 1 - 13
src/renderers/shaders/ShaderLib/normal_frag.glsl.js

@@ -9,21 +9,9 @@ uniform float opacity;
 
 #endif
 
-#ifndef FLAT_SHADED
-
-	varying vec3 vNormal;
-
-	#ifdef USE_TANGENT
-
-		varying vec3 vTangent;
-		varying vec3 vBitangent;
-
-	#endif
-
-#endif
-
 #include <packing>
 #include <uv_pars_fragment>
+#include <normal_pars_fragment>
 #include <bumpmap_pars_fragment>
 #include <normalmap_pars_fragment>
 #include <logdepthbuf_pars_fragment>

+ 2 - 26
src/renderers/shaders/ShaderLib/normal_vert.glsl.js

@@ -7,22 +7,10 @@ export default /* glsl */`
 
 #endif
 
-#ifndef FLAT_SHADED
-
-	varying vec3 vNormal;
-
-	#ifdef USE_TANGENT
-
-		varying vec3 vTangent;
-		varying vec3 vBitangent;
-
-	#endif
-
-#endif
-
 #include <common>
 #include <uv_pars_vertex>
 #include <displacementmap_pars_vertex>
+#include <normal_pars_vertex>
 #include <morphtarget_pars_vertex>
 #include <skinning_pars_vertex>
 #include <logdepthbuf_pars_vertex>
@@ -37,19 +25,7 @@ void main() {
 	#include <skinbase_vertex>
 	#include <skinnormal_vertex>
 	#include <defaultnormal_vertex>
-
-#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED
-
-	vNormal = normalize( transformedNormal );
-
-	#ifdef USE_TANGENT
-
-		vTangent = normalize( transformedTangent );
-		vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
-
-	#endif
-
-#endif
+	#include <normal_vertex>
 
 	#include <begin_vertex>
 	#include <morphtarget_vertex>