فهرست منبع

BasicNode: Fix undefined normal in fragment shader

Signed-off-by: martinRenou <[email protected]>
martinRenou 5 سال پیش
والد
کامیت
1ecfea07d9
1فایلهای تغییر یافته به همراه20 افزوده شده و 1 حذف شده
  1. 20 1
      examples/jsm/nodes/materials/nodes/BasicNode.js

+ 20 - 1
examples/jsm/nodes/materials/nodes/BasicNode.js

@@ -54,11 +54,17 @@ BasicNode.prototype.generate = function ( builder ) {
 		}
 		}
 
 
 		output.push(
 		output.push(
+			"#include <morphtarget_vertex>",
+			"#include <skinning_vertex>",
 			"#include <project_vertex>",
 			"#include <project_vertex>",
+			"#include <fog_vertex>",
+			"#include <logdepthbuf_vertex>",
+			"#include <clipping_planes_vertex>",
 
 
-			" vViewPosition = - mvPosition.xyz;",
+			"	vViewPosition = - mvPosition.xyz;",
 
 
 			"#include <worldpos_vertex>",
 			"#include <worldpos_vertex>",
+			"#include <shadowmap_vertex>"
 		);
 		);
 
 
 		code = output.join( "\n" );
 		code = output.join( "\n" );
@@ -78,7 +84,20 @@ BasicNode.prototype.generate = function ( builder ) {
 
 
 		builder.requires.transparent = alpha !== undefined;
 		builder.requires.transparent = alpha !== undefined;
 
 
+		builder.addParsCode( [
+			"varying vec3 vViewPosition;",
+
+			"#ifndef FLAT_SHADED",
+
+			" varying vec3 vNormal;",
+
+			"#endif",
+		].join( "\n" ) );
+
 		var output = [
 		var output = [
+			// add before: prevent undeclared normal
+			"#include <normal_fragment_begin>",
+
 			color.code,
 			color.code,
 		];
 		];