Skip to content

Commit 4a35f6b

Browse files
committed
fix secondary parameter
1 parent ffcc906 commit 4a35f6b

File tree

2 files changed

+20
-22
lines changed

2 files changed

+20
-22
lines changed

examples/webgpu_custom_fog_background.html

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
<script type="importmap">
2626
{
2727
"imports": {
28-
"three": "../build/three.webgpu.js",
29-
"three/webgpu": "../build/three.webgpu.js",
30-
"three/tsl": "../build/three.tsl.js",
28+
"three": "../src/three.webgpu.js",
29+
"three/webgpu": "../src/three.webgpu.js",
30+
"three/tsl": "../src/three.tsl.js",
3131
"three/addons/": "./jsm/"
3232
}
3333
}
@@ -36,7 +36,7 @@
3636
<script type="module">
3737

3838
import * as THREE from 'three/webgpu';
39-
import { pass, color, rangeFogFactor } from 'three/tsl';
39+
import { pass, color, rangeFogFactor, context, uv, renderOutput } from 'three/tsl';
4040

4141
import { HDRLoader } from 'three/addons/loaders/HDRLoader.js';
4242

@@ -54,36 +54,34 @@
5454
camera.position.set( - 1.8, 0.6, 2.7 );
5555

5656
scene = new THREE.Scene();
57+
scene.background = new THREE.Color( 0x4080cc );
5758

5859
renderer = new THREE.WebGPURenderer( { antialias: true } );
5960
renderer.setPixelRatio( window.devicePixelRatio );
6061
renderer.setSize( window.innerWidth, window.innerHeight );
6162
renderer.setAnimationLoop( animate );
63+
renderer.outputColorSpace = THREE.LinearSRGBColorSpace;
6264
renderer.toneMapping = THREE.NoToneMapping; // apply tone mapping in post processing, instead
6365
document.body.appendChild( renderer.domElement );
6466

65-
// post processing
67+
renderer.contextNode = context( {
6668

67-
// render scene pass
68-
const scenePass = pass( scene, camera );
69-
const scenePassViewZ = scenePass.getViewZNode();
69+
getUV: () => {
7070

71-
// fog color
72-
const fogColor = color( 0x4080cc ); // in sRGB color space
71+
return uv();
7372

74-
// get fog factor from the scene pass context
75-
// equivalent to: scene.fog = new THREE.Fog( 0x4080cc, 2.7, 4 );
76-
const fogFactor = rangeFogFactor( 2.7, 4 ).context( { getViewZ: () => scenePassViewZ } );
73+
},
7774

78-
// tone-mapped scene pass
79-
const scenePassTM = scenePass.toneMapping( THREE.ACESFilmicToneMapping, 1 );
75+
getOutput: ( node, { material } ) => {
8076

81-
// mix fog using fog factor and fog color
82-
const compose = fogFactor.mix( scenePassTM, fogColor );
77+
const toneMapping = material.toneMapped ? THREE.NeutralToneMapping : THREE.NoToneMapping;
78+
const outputColorSpace = THREE.SRGBColorSpace;
8379

84-
postProcessing = new THREE.PostProcessing( renderer );
85-
postProcessing.outputColorTransform = true; // no tone mapping will be applied, only the default color space transform
86-
postProcessing.outputNode = compose;
80+
return renderOutput( node, toneMapping, outputColorSpace );
81+
82+
}
83+
84+
} );
8785

8886
//
8987

@@ -130,7 +128,7 @@
130128

131129
function animate() {
132130

133-
postProcessing.render();
131+
renderer.render( scene, camera );
134132

135133
}
136134

src/nodes/pmrem/PMREMNode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ class PMREMNode extends TempNode {
308308

309309
if ( uvNode === null && builder.context.getUV ) {
310310

311-
uvNode = builder.context.getUV( this );
311+
uvNode = builder.context.getUV( this, builder );
312312

313313
}
314314

0 commit comments

Comments
 (0)