mgsx-dev/gdx-gltf

How to render a transparent object which receive shadows?

fgnm opened this issue · 1 comments

fgnm commented

I think that this issue is related to only AR applications, since in a normal 3D environment it's hard to find a use case. Anyway, I'd want to point out as a issue because I struggled a lot to make it working without a solution. Basically, in AR there isn't a "ground" model because the ground is the real world behind. For this reason 3d shadows cannot be casted because there's anything under the 3d model, it just floats in the air. To make shadows appear, a ground model must be added, but sholud be rendered with a transparent color and showing only shadows.

photo_2022-11-21_16-23-12

Currently both plane and the model belong to the same blender scene, but any of my attempt to produce a transparent palne under the model failed because as the plane become transparent also shadows desappears. Is there a way to achieve this result? If no, is it possible to add this as a feature?

Thanks a lot!

For you special case, i think you could do it with a custom shader for your plane which only output shadows. With blending enabled, you could output something like vec4(0.0, 0.0, 0.0, 1.0 - getShadow()). You don't need PBR shader to do so. You could use a custom shader based on default libgdx shader.

Since your request is not related to gdx-gltf, i'm closing it. We could still discuss about it on Discord if needed.