I've imported a tree into Godot from Blender using the Sapling add on. I made the tree and leaves meshes and exported as obj with a diffuse texture for both. Importing into Godot, added the textures as the albedo, but my leaves look as if the Alpha isn't working. Any thoughts? Am I missing a setting/checkbox...something?
Issue with alpha mapped texture
There's a checkbox that will enable the SpatialMaterial
to render transparent textures. You'll likely want to change the transparent mode as well.
Perfect! That did it. Thanks so much Twisted!
- Edited
So I never thought I would have to resurrect my own thread (my very first on this forum too), but I'm actually finding another issue with my trees that I'm making now.
Now when I'm importing my trees from Blender, for my leaves, when I turn Transparent on, and also check the draw depth to opaque, the leaves show up great now, however, they no longer cast a shadow.
When transparent is not checked, the leaves DO cast a shadow, but look like they do in the initial pic on this post. Check transparent, and the leaves look good, but shadows go away.
Any thoughts? @TwistedTwigleg
- Edited
This is notoriously hard to do in older engines. Typically transparent objects don't write to the depth buffer, which can cause issues like you see for cut out objects like leaves. In most cases all the opaque geometry is drawn first (with depth checking and writing enabled) and then transparent objects are drawn without depth writing (only depth checking) in back to front order. This is okay for mostly transparent objects (such as glass) which don't need to cast a shadow. However, it doesn't work well for masked images (like leaves, chain fencing, etc.).
I haven't been working with the Godot source code, so I don't know how hard this would be to fix. If I recall correctly, even Unity had issues with this as recently as a few years ago but it has pretty good support in Unreal. Also, maybe Godot does support it with some combination of parameters. It also looks like you can write to a depth buffer in a custom shader, so it may be possible to fix this yourself with your own shader. I haven't looked into it too far but it may be worth exploring if there is no built-in option.
@cybereality thanks so much for your insight! You actually got me on the right path! I knew I had seen similar options. In the parameters the Depth Draw Mode was set to opaque only. I changed it to Opaque Pre-Pass, and voila!
Thanks again!
- Edited
Oh wow! Great to see it's supported, didn't even check there before. Cheers.
- Edited
Awesome! I'm glad you guys figured it out! (And now I know how to use transparent objects with shadows, which I didn't know before :smile:)