Skip to content

Commit 59ea1d2

Browse files
committed
Fix depth of field demo
1 parent c5b5628 commit 59ea1d2

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

example/depthOfField.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as THREE from 'three';
22
import { FullScreenQuad } from 'three/examples/jsm/postprocessing/Pass.js';
33
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
44
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
5-
import { PathTracingRenderer, PhysicalPathTracingMaterial, PhysicalCamera, BlurredEnvMapGenerator } from '../src/index.js';
5+
import { PathTracingRenderer, PhysicalPathTracingMaterial, PhysicalCamera, BlurredEnvMapGenerator, GradientEquirectTexture } from '../src/index.js';
66
import { PathTracingSceneWorker } from '../src/workers/PathTracingSceneWorker.js';
77
import { RGBELoader } from 'three/examples/jsm/loaders/RGBELoader.js';
88
import { MeshoptDecoder } from 'three/examples/jsm/libs/meshopt_decoder.module.js';
@@ -53,14 +53,17 @@ async function init() {
5353

5454
scene = new THREE.Scene();
5555

56+
const gradientMap = new GradientEquirectTexture();
57+
gradientMap.topColor.set( 0x390f20 ).convertSRGBToLinear();
58+
gradientMap.bottomColor.set( 0x151b1f ).convertSRGBToLinear();
59+
gradientMap.update();
60+
5661
ptRenderer = new PathTracingRenderer( renderer );
5762
ptRenderer.camera = camera;
5863
ptRenderer.material = new PhysicalPathTracingMaterial();
5964
ptRenderer.tiles.set( params.tiles, params.tiles );
60-
ptRenderer.material.setDefine( 'FEATURE_GRADIENT_BG', 1 );
6165
ptRenderer.material.setDefine( 'FEATURE_MIS', 0 );
62-
ptRenderer.material.bgGradientTop.set( 0x390f20 ).convertSRGBToLinear();
63-
ptRenderer.material.bgGradientBottom.set( 0x151b1f ).convertSRGBToLinear();
66+
ptRenderer.material.backgroundMap = gradientMap;
6467

6568
fsQuad = new FullScreenQuad( new THREE.MeshBasicMaterial( {
6669
map: ptRenderer.target.texture,

src/materials/PhysicalPathTracingMaterial.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export class PhysicalPathTracingMaterial extends MaterialBase {
113113
114114
#if FEATURE_BACKGROUND_MAP
115115
116-
uniform vec3 backgroundMap;
116+
uniform sampler2D backgroundMap;
117117
118118
#endif
119119

src/textures/GradientEquirectTexture.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class GradientEquirectTexture extends ProceduralEquirectTexture {
1515
_direction.setFromSpherical( polar );
1616

1717
const t = _direction.y * 0.5 + 0.5;
18-
color.lerpColors( this.bottomColor, this.topColor, t * t );
18+
color.lerpColors( this.bottomColor, this.topColor, t );
1919

2020
};
2121

0 commit comments

Comments
 (0)