ShaderMaterial example with moving light and shadow

Hello.
It’s hard to find examples of ShaderMaterial.
What I want is an example of an object’s shadow moving when both a directional Light and a HemisphereLight move.
Of course, what you need is the object to which the ShaderMaterial is applied.
This is when ShaderMaterial is applied to objects such as dolls or cars.

Personally when I want a custom material using a lot of built-in materials features, I modify an built-in material using .onBeforeCompile.
See this example.

1 Like

It’s a good idea to change the parts you want before modifying the shader.
But I need a fragment shader.
Any fragment shader examples?

@11170
Don’t hesitate to use forum’s search.
https://discourse.threejs.org/search?q=onBeforeCompile%20fragmentShader
There are lots of topics and posts related to the using .onBeforeCompile for modifying of fragment shader.

1 Like

Thanks for advice.
I analysis the source and made the desired material.

index.html (9.0 KB)





Terrain_Snow_mask.bmp (256.1 KB)
Xbot.glb (2.8 MB)

1 Like