Suppose I want all my shadows to have a rainbow gradient. What’s the simplest way to do that in Three?
I’m guessing its either
- patching the shader to replace the shader code with my own
- using node materials and making my own node to compose with the rest
I’m fairly certain there’s no easier way, but would be pleasantly surprised if there were.
The way shadows currently work inside shader chunks lights_fragment_begin is the fragment tests for each light whether its shadowed, and then multiplies the light color by a shadow factor of
1.0 accordingly (or something between them in case of edges?).
I suppose instead of just multiplying the shadowed fragment’s light color by 0, you could instead edit the shaders to use that
1.0 shadow factor to glsl
mix() between standard light color and your rainbow effect color.
Naturally you’d have to write the rainbow color shading function yourself. Perhaps
vDirectionalShadowCoord can be of use to you.
Either way that sounds like a cool effect. Post a showcase when you get it done