Skip to content

Commit

Permalink
FogNode: Use getViewZ() in context instead of viewZ as Node
Browse files Browse the repository at this point in the history
  • Loading branch information
sunag committed Mar 13, 2024
1 parent 3cc2006 commit f9af5f0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion examples/jsm/nodes/fog/FogNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,17 @@ class FogNode extends Node {

getViewZNode( builder ) {

return ( builder.context.viewZ || positionView.z ).negate();
let viewZ;

const getViewZ = builder.context.getViewZ;

if ( getViewZ !== undefined ) {

viewZ = getViewZ( this );

}

return ( viewZ || positionView.z ).negate();

}

Expand Down
2 changes: 1 addition & 1 deletion examples/webgpu_custom_fog_background.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@

// get fog factor from scene pass context
// equivalent to: scene.fog = new THREE.Fog( 0x0066ff, 2.7, 4 );
const fogFactor = rangeFog( null, 2.7, 4 ).context( { viewZ: scenePassViewZ } );
const fogFactor = rangeFog( null, 2.7, 4 ).context( { getViewZ: () => scenePassViewZ } );

// tone mapping scene pass
const scenePassTM = scenePass.toneMapping( THREE.ACESFilmicToneMapping );
Expand Down

0 comments on commit f9af5f0

Please sign in to comment.