Skip to content

ShadowMaps for custom wgslFn shaders #30685

@Spiri0

Description

@Spiri0

Description

I looked through the examples for shadows and didn't find one where a shadow map with a custom shader is used. Since WebGPU allows you to create multiple geometries with compute shaders in the GPU and also their worldMatrices and store these directly in structArrays in storageBuffers, there is a need to be able to use shadow maps in your own shaders.

I tried to use sampler_comparison but I get an error message. I have a modified example from the examples in which you can see what the shadow texture looks like. If I integrate the sampler into the shader, the shader no longer works.

https://codepen.io/Spiri0/pen/xbxreyr

Insert line 129 under line 137

Solution

Make sampler_comparison available for wgslFn so that you can use textureSampleCompare for shadowMaps in own shaders

Alternatives

I haven't an idea of a good alternative, if there is one.
sampler_comparison only appears in one place in the WGSLNodeBuilder. So I hope that it won't be too much work. I'm not very familiar with this part of the code, otherwise I would try to solve it by myself

Additional context

No response

Metadata

Metadata

Assignees

Labels

TSLThree.js Shading Language

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions