Просмотр исходного кода

ClusteredLightsNode: Fix point light distance attenuation (#33679)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
mrdoob 2 недель назад
Родитель
Сommit
69fe335784

+ 2 - 2
examples/jsm/tsl/lighting/ClusteredLightsNode.js

@@ -1,7 +1,7 @@
 import { DataTexture, FloatType, RGBAFormat, Vector2, Vector3, LightsNode, NodeUpdateType } from 'three/webgpu';
 
 import {
-	attributeArray, nodeProxy, int, float, vec3, ivec2, ivec4, uniform, Break, Loop, positionView,
+	attributeArray, nodeProxy, int, float, vec3, vec4, ivec2, ivec4, uniform, Break, Loop, positionView,
 	Fn, If, Return, textureLoad, instanceIndex, screenCoordinate, directPointLight,
 	renderGroup,
 	min, max, pow, log, clamp, dot
@@ -306,7 +306,7 @@ class ClusteredLightsNode extends LightsNode {
 		const dataB = textureLoad( this._lightsTexture, ivec2( index, 1 ) );
 
 		const position = dataA.xyz;
-		const viewPosition = this._cameraViewMatrix.mul( position );
+		const viewPosition = this._cameraViewMatrix.mul( vec4( position, 1.0 ) ).xyz;
 		const distance = dataA.w;
 		const color = dataB.rgb;
 		const decay = dataB.w;

BIN
examples/screenshots/webgpu_lights_clustered.jpg


粤ICP备19079148号