2
0
sunag 5 жил өмнө
parent
commit
5dc078a9d6

+ 14 - 0
examples/jsm/nodes/accessors/NormalNode.js

@@ -29,6 +29,20 @@ NormalNode.prototype.getShared = function () {
 
 };
 
+NormalNode.prototype.build = function ( builder, output, uuid, ns ) {
+
+	var contextNormal = builder.context[ this.scope + 'Normal' ];
+
+	if ( contextNormal ) {
+
+		return contextNormal.build( builder, output, uuid, ns );
+
+	}
+
+	return TempNode.prototype.build.call( this, builder, output, uuid );
+
+}
+
 NormalNode.prototype.generate = function ( builder, output ) {
 
 	var result;

+ 1 - 1
examples/jsm/nodes/accessors/ReflectNode.js

@@ -54,7 +54,7 @@ ReflectNode.prototype.generate = function ( builder, output ) {
 
 			case ReflectNode.VECTOR:
 
-				var viewNormalNode = builder.context.viewNormal || new NormalNode( NormalNode.VIEW );
+				var viewNormalNode = new NormalNode( NormalNode.VIEW );
 				var roughnessNode = builder.context.roughness;
 
 				var viewNormal = viewNormalNode.build( builder, 'v3' );

+ 2 - 0
examples/jsm/nodes/materials/nodes/StandardNode.js

@@ -135,6 +135,7 @@ StandardNode.prototype.build = function ( builder ) {
 			roughness: specularRoughness,
 			bias: new SpecularMIPLevelNode( specularRoughness ),
 			viewNormal: new ExpressionNode( 'normal', 'v3' ),
+			worldNormal: new ExpressionNode( 'inverseTransformDirection( geometry.normal, viewMatrix )', 'v3' ),
 			gamma: true
 		};
 
@@ -146,6 +147,7 @@ StandardNode.prototype.build = function ( builder ) {
 			roughness: clearcoatRoughness,
 			bias: new SpecularMIPLevelNode( clearcoatRoughness ),
 			viewNormal: new ExpressionNode( 'clearcoatNormal', 'v3' ),
+			worldNormal: new ExpressionNode( 'inverseTransformDirection( geometry.clearcoatNormal, viewMatrix )', 'v3' ),
 			gamma: true
 		};
 

+ 4 - 0
examples/jsm/nodes/misc/TextureCubeUVNode.js

@@ -84,11 +84,14 @@ TextureCubeUVNode.Nodes = ( function () {
 
 	var bilinearCubeUV = new FunctionNode(
 		`TextureCubeUVData bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {
+
 			float face = getFace(direction);
 			float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);
 			mipInt = max(mipInt, cubeUV_minMipLevel);
 			float faceSize = exp2(mipInt);
+
 			float texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);
+
 			vec2 uv = getUV(direction, face) * (faceSize - 1.0);
 			vec2 f = fract(uv);
 			uv += 0.5 - f;
@@ -103,6 +106,7 @@ TextureCubeUVNode.Nodes = ( function () {
 			uv.y += filterInt * 2.0 * cubeUV_minTileSize;
 			uv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize);
 			uv *= texelSize;
+ 
 			vec4 tl = texture2D(envMap, uv);
 			uv.x += texelSize;
 			vec4 tr = texture2D(envMap, uv);