Skip to content

Commit 2344891

Browse files
authored
Examples: Fix webgpu_tsl_procedural_terrain warning (#29574)
* ShadowNode: Use `transformedNormalWorld` * getGeometryRoughness: Return 0. if there is no normal buffer * update screenshot
1 parent b378fba commit 2344891

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed
-24 Bytes
Loading

src/nodes/functions/material/getGeometryRoughness.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import { normalView } from '../../accessors/Normal.js';
2-
import { Fn } from '../../tsl/TSLBase.js';
2+
import { float, Fn } from '../../tsl/TSLBase.js';
33

4-
const getGeometryRoughness = /*@__PURE__*/ Fn( () => {
4+
const getGeometryRoughness = /*@__PURE__*/ Fn( ( builder ) => {
5+
6+
if ( builder.geometry.hasAttribute( 'normal' ) === false ) {
7+
8+
return float( 0 );
9+
10+
}
511

612
const dxy = normalView.dFdx().abs().max( normalView.dFdy().abs() );
713
const geometryRoughness = dxy.x.max( dxy.y ).max( dxy.z );

src/nodes/lighting/ShadowNode.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { float, vec2, vec3, vec4, If, int, Fn, nodeObject } from '../tsl/TSLBase
55
import { reference } from '../accessors/ReferenceNode.js';
66
import { texture } from '../accessors/TextureNode.js';
77
import { positionWorld } from '../accessors/Position.js';
8-
import { normalWorld } from '../accessors/Normal.js';
8+
import { transformedNormalWorld } from '../accessors/Normal.js';
99
import { mix, fract, step, max, clamp, sqrt } from '../math/MathNode.js';
1010
import { add, sub } from '../math/OperatorNode.js';
1111
import { DepthTexture } from '../../textures/DepthTexture.js';
@@ -289,7 +289,7 @@ class ShadowNode extends Node {
289289

290290
const position = object.material.shadowPositionNode || positionWorld;
291291

292-
let shadowCoord = uniform( shadow.matrix ).setGroup( renderGroup ).mul( position.add( normalWorld.mul( normalBias ) ) );
292+
let shadowCoord = uniform( shadow.matrix ).setGroup( renderGroup ).mul( position.add( transformedNormalWorld.mul( normalBias ) ) );
293293

294294
let coordZ;
295295

0 commit comments

Comments
 (0)