asny / three-d

2D/3D renderer - makes it simple to draw stuff across platforms (including web)
MIT License
1.29k stars 109 forks source link

Add Shadow Catcher material support #420

Open george-lim opened 10 months ago

george-lim commented 10 months ago

Hey there!

It would be super awesome if you could add a shadow catcher material or property to the material so that we can have built-in support for materials that catch shadows but are unaffected by light. I don't think that's possible to do right now without making a custom shader, and I've been struggling with that using the core library haha (I looked at the logo example, as well as source for Physical Material but a lot of it feels very foreign to me)

My goal is to have a transparent ground plane catch shadows from a 3D model, but ignore other lighting. If you could build this feature in natively that would be awesome 🙏

Lots of other renderers have built-in support for this, like Unity and Three.js :)

asny commented 9 months ago

I'm not sure I understand 🤔 what will you use the catched shadows for? It sounds a bit like a shadow map, which is already supported. Or maybe it's a bit different but I guess you can use the same approach, ie render the shadow into a render target and use that result as a texture.

george-lim commented 9 months ago

It's to implement something like this, where I have the transparent floor that catches shadows, but doesn't itself emit light (otherwise the floor would brighten, removing the illusion of the floor being the same color as the background)

Screenshot 2023-12-25 at 2 52 18 PM

I managed to figure this one out using a custom shader, but I'm still having trouble with Mixamo animations which is a blocker for me if you have time to take a look 🙏

I think we can close this issue for now since I managed to find a way around it

asny commented 7 months ago

Yeah, ok, that's a very special use-case, but let's leave it open, this is probably a fun task to do 🙂