Does anyone have an example of how to use shadow maps with own shaders?

I’m looking for an example with shadow maps and custom shaders.
Does anyone have an interesting example?

1 Like

In TSL or old school materials? In the later, shadow map calculations depend on the light type and are done in the loops that iterate over every light in the scene - you can find a way of calculating shadow for each specific type of light in the RE_Direct and RE_Indirect methods.

Hi mjurczyk,

for wgslFn, i.e. TSL with wgsl raw code. I have a codePen here.

https://codepen.io/Spiri0/pen/VYwWRmL?editors=0010

But if I want to use sampler_comparison as sampler for the shadowMap depthTexture it crashes.
If you comment out the postProcessing at the end you will see the normal scene.
TSL buildIn functions don’t help me because I can’t use the worldMatrices of the geometry, but because I generate geometry with the GPU in compute shaders and also its worldMatrices and store them directly in storageBuffers, I really need the shadowMaps at the lowest level in the shader.