Bläddra i källkod

TSL: Fixing rbmax / rbmin calculation of `getParallaxCorrectNormal()`. (#34007)

Michael Herzog 2 veckor sedan
förälder
incheckning
b2b9e26aee

+ 1 - 1
examples/webgpu_materials_envmaps_bpcem.html

@@ -95,7 +95,7 @@
 				defaultMat.metalnessNode = float( 1 );
 
 				const boxProjectedMat = new THREE.MeshStandardNodeMaterial();
-				boxProjectedMat.envNode = pmremTexture( renderTarget.texture, getParallaxCorrectNormal( reflectVector, vec3( 200, 100, 100 ), vec3( 0, - 50, 0 ) ) );
+				boxProjectedMat.envNode = pmremTexture( renderTarget.texture, getParallaxCorrectNormal( reflectVector, vec3( 200, 200, 100 ), vec3( 0, - 50, 0 ) ) );
 				boxProjectedMat.roughnessNode = texture( rMap ).mul( roughnessUniform );
 				boxProjectedMat.metalnessNode = float( 1 );
 

+ 3 - 3
src/nodes/functions/material/getParallaxCorrectNormal.js

@@ -1,5 +1,5 @@
 import { positionWorld } from '../../accessors/Position.js';
-import { float, Fn, min, normalize, sub, vec3 } from '../../tsl/TSLBase.js';
+import { float, Fn, min, normalize, vec3 } from '../../tsl/TSLBase.js';
 
 /**
  * This computes a parallax corrected normal which is used for box-projected cube mapping (BPCEM).
@@ -21,8 +21,8 @@ import { float, Fn, min, normalize, sub, vec3 } from '../../tsl/TSLBase.js';
 const getParallaxCorrectNormal = /*@__PURE__*/ Fn( ( [ normal, cubeSize, cubePos ] ) => {
 
 	const nDir = normalize( normal ).toVar();
-	const rbmax = sub( float( 0.5 ).mul( cubeSize.sub( cubePos ) ), positionWorld ).div( nDir ).toVar();
-	const rbmin = sub( float( - 0.5 ).mul( cubeSize.sub( cubePos ) ), positionWorld ).div( nDir ).toVar();
+	const rbmax = cubeSize.mul( 0.5 ).add( cubePos ).sub( positionWorld ).div( nDir ).toVar();
+	const rbmin = cubeSize.mul( - 0.5 ).add( cubePos ).sub( positionWorld ).div( nDir ).toVar();
 	const rbminmax = vec3().toVar();
 	rbminmax.x = nDir.x.greaterThan( float( 0 ) ).select( rbmax.x, rbmin.x );
 	rbminmax.y = nDir.y.greaterThan( float( 0 ) ).select( rbmax.y, rbmin.y );

粤ICP备19079148号