Skip to content

WebGPU: Support shadow.biasNode for dynamic bias control via NodeMaterial system #31191

Open
@ligaofeng0901

Description

@ligaofeng0901

Description

Currently, shadow.bias in three.js is a static numeric value, which makes it difficult to control shadow quality dynamically.
A static bias value introduces a trade-off:
Too small: Causes severe shadow artifacts (e.g. shadow acne), especially when the light hits surfaces at a steep angle.
Too large: Leads to floating shadows (peter-panning), which breaks immersion and realism.
These issues are especially hard to mitigate in dynamic or stylized scenes, where camera and light movement are frequent and bias requirements change per frame or per surface.

Solution

The API may be like this

light.shadow.biasNode = dot(normal, xx) ....;

This would coexist with the existing shadow.bias number fallback, with the node-based version taking precedence if defined.

in this file https://github.com/mrdoob/three.js/blob/master/src/nodes/lighting/ShadowNode.js#L330
change code in this line to

const bias = shadow.biasNode || reference( 'bias', 'float', shadow ).setGroup( renderGroup );

Maybe some other files like CSMShaderNode also should add some code to support it.

Alternatives

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions