Skip to content

Commit 9a2e6c2

Browse files
committed
Revert "WebGPURenderer: Add SpotLight.map support (mrdoob#29989)"
This reverts commit e2e04d3.
1 parent 50c6e14 commit 9a2e6c2

File tree

7 files changed

+10
-305
lines changed

7 files changed

+10
-305
lines changed

examples/files.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,6 @@
335335
"webgpu_lights_physical",
336336
"webgpu_lights_rectarealight",
337337
"webgpu_lights_selective",
338-
"webgpu_lights_spotlight",
339338
"webgpu_lights_tiled",
340339
"webgpu_lines_fat_raycasting",
341340
"webgpu_lines_fat_wireframe",
-57.2 KB
Binary file not shown.

examples/webgpu_lights_spotlight.html

Lines changed: 0 additions & 252 deletions
This file was deleted.

src/nodes/accessors/Lights.js

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { uniform } from '../core/UniformNode.js';
22
import { renderGroup } from '../core/UniformGroupNode.js';
33
import { Vector3 } from '../../math/Vector3.js';
44
import { cameraViewMatrix } from './Camera.js';
5-
import { positionWorld } from './Position.js';
65

76
let uniformsLib;
87

@@ -18,37 +17,6 @@ function getLightData( light ) {
1817

1918
}
2019

21-
export function lightShadowMatrix( light ) {
22-
23-
const data = getLightData( light );
24-
25-
return data.shadowMatrix || ( data.shadowMatrix = uniform( 'mat4' ).setGroup( renderGroup ).onRenderUpdate( () => {
26-
27-
light.shadow.updateMatrices( light );
28-
29-
return light.shadow.matrix;
30-
31-
} ) );
32-
33-
}
34-
35-
export function lightProjectionUV( light ) {
36-
37-
const data = getLightData( light );
38-
39-
if ( data.projectionUV === undefined ) {
40-
41-
const spotLightCoord = lightShadowMatrix( light ).mul( positionWorld );
42-
43-
data.projectionUV = spotLightCoord.xyz.div( spotLightCoord.w );
44-
45-
46-
}
47-
48-
return data.projectionUV;
49-
50-
}
51-
5220
export function lightPosition( light ) {
5321

5422
const data = getLightData( light );

src/nodes/lighting/AnalyticLightNode.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@ class AnalyticLightNode extends LightingNode {
1919

2020
super();
2121

22+
this.updateType = NodeUpdateType.FRAME;
23+
2224
this.light = light;
2325

2426
this.color = new Color();
25-
this.colorNode = ( light && light.colorNode ) || uniform( this.color ).setGroup( renderGroup );
27+
this.colorNode = uniform( this.color ).setGroup( renderGroup );
2628

2729
this.baseColorNode = null;
2830

@@ -31,8 +33,6 @@ class AnalyticLightNode extends LightingNode {
3133

3234
this.isAnalyticLightNode = true;
3335

34-
this.updateType = NodeUpdateType.FRAME;
35-
3636
}
3737

3838
getCacheKey() {

src/nodes/lighting/ShadowNode.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Node from '../core/Node.js';
22
import { NodeUpdateType } from '../core/constants.js';
3+
import { uniform } from '../core/UniformNode.js';
34
import { float, vec2, vec3, vec4, If, int, Fn, nodeObject } from '../tsl/TSLBase.js';
45
import { reference } from '../accessors/ReferenceNode.js';
56
import { texture } from '../accessors/TextureNode.js';
@@ -16,7 +17,6 @@ import { HalfFloatType, LessCompare, RGFormat, VSMShadowMap, WebGPUCoordinateSys
1617
import { renderGroup } from '../core/UniformGroupNode.js';
1718
import { viewZToLogarithmicDepth } from '../display/ViewportDepthNode.js';
1819
import { objectPosition } from '../accessors/Object3DNode.js';
19-
import { lightShadowMatrix } from '../accessors/Lights.js';
2020

2121
const shadowWorldPosition = /*@__PURE__*/ vec3().toVar( 'shadowWorldPosition' );
2222

@@ -383,7 +383,7 @@ class ShadowNode extends Node {
383383
const shadowIntensity = reference( 'intensity', 'float', shadow ).setGroup( renderGroup );
384384
const normalBias = reference( 'normalBias', 'float', shadow ).setGroup( renderGroup );
385385

386-
const shadowPosition = lightShadowMatrix( light ).mul( shadowWorldPosition.add( transformedNormalWorld.mul( normalBias ) ) );
386+
const shadowPosition = uniform( shadow.matrix ).setGroup( renderGroup ).mul( shadowWorldPosition.add( transformedNormalWorld.mul( normalBias ) ) );
387387
const shadowCoord = this.setupShadowCoord( builder, shadowPosition );
388388

389389
//
@@ -446,9 +446,11 @@ class ShadowNode extends Node {
446446

447447
renderShadow( frame ) {
448448

449-
const { shadow, shadowMap } = this;
449+
const { shadow, shadowMap, light } = this;
450450
const { renderer, scene } = frame;
451451

452+
shadow.updateMatrices( light );
453+
452454
shadowMap.setSize( shadow.mapSize.width, shadow.mapSize.height );
453455

454456
renderer.render( scene, shadow.camera );

src/nodes/lighting/SpotLightNode.js

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import { uniform } from '../core/UniformNode.js';
44
import { smoothstep } from '../math/MathNode.js';
55
import { positionView } from '../accessors/Position.js';
66
import { renderGroup } from '../core/UniformGroupNode.js';
7-
import { lightViewPosition, lightTargetDirection, lightProjectionUV } from '../accessors/Lights.js';
8-
import { texture } from '../accessors/TextureNode.js';
7+
import { lightViewPosition, lightTargetDirection } from '../accessors/Lights.js';
98

109
class SpotLightNode extends AnalyticLightNode {
1110

@@ -71,18 +70,7 @@ class SpotLightNode extends AnalyticLightNode {
7170
decayExponent: decayExponentNode
7271
} );
7372

74-
let lightColor = colorNode.mul( spotAttenuation ).mul( lightAttenuation );
75-
76-
if ( light.map ) {
77-
78-
const spotLightCoord = lightProjectionUV( light );
79-
const projectedTexture = texture( light.map, spotLightCoord.xy ).onRenderUpdate( () => light.map );
80-
81-
const inSpotLightMap = spotLightCoord.mul( 2. ).sub( 1. ).abs().lessThan( 1. ).all();
82-
83-
lightColor = inSpotLightMap.select( lightColor.mul( projectedTexture ), lightColor );
84-
85-
}
73+
const lightColor = colorNode.mul( spotAttenuation ).mul( lightAttenuation );
8674

8775
const reflectedLight = builder.context.reflectedLight;
8876

0 commit comments

Comments
 (0)