[Ch28] Objects with texture alpha
cleverpanda opened this issue · 1 comments
cleverpanda commented
I'm unable to render models with textures that have alpha, which I thing is a big problem for things like foliage. It currently renders alpha black.
I tried copying the glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); from the particle code and disabling after in the renderGeometry method but this results in a black object.
lwjglgamedev commented
Hi,
This is a normal issue in deferred rendering. The problem is that the render targets do not store alpha info (it makes no sense). If you want to add support for transparencies you can:
- Render transparent objects after the lighting stage is done.
- Abort rendering of transparent objects (based on a minium value). In order ofr this to work, objects with transparencies must be the last to be rendered. I've got a sample here in the Vulkan book for this: https://github.com/lwjglgamedev/vulkanbook/tree/master/bookcontents/chapter-09. Although it uses Vulkan, you can get an idea.
In any case, I'm currently refactoring the book, I will try to explain this better in the new version.