Rendering textured leaves

Started by
3 comments, last by j3p 12 years, 3 months ago
I knew I eventually would have a case that lead me here to ask for best practices. I have vegetation meshes that cannot be rendered correctly using sorting and alpha blending, since the leaves are just quads with alpha-enabled textures in a single mesh.

I read about linked list OIT in DX11 (https://graphics.sta...s-10-11-oit.pdf). At first I regarded this as the solution, but then I realized the memory requirements: over 120MB for full hd hdr(?) (and even more if I wanted to render a dense jungle)!! And I'm not sure about the performance either... Some say it's relatively bad.

A workaround: disabling z-writes, causes a lot artifacts, though.
[attachment=6827:render_ndepthw.png]

Regular blending. Most of the leaves are are covered by "transparent" triangles. Also, the ssao catches the edges of the quads...
[attachment=6828:render_depthw.png]

Any thoughts appreciated...
Advertisement
First render the opaque parts as usual with depth buffer writes enabled (discard non-opaque pixels in the shader), then render the transparent parts with depth buffer writes disabled (sorted from back to front if you can, also discard opaque pixels in the shader). Actually this is a quick method for rendering translucent objects in general, and it isn't perfect, but it's the most obvious workaround.

That said: you could also treat alpha as fully opaque and fully transparent (i.e. no in-between translucent values). In this case just discard pixels with alpha < 0.5 and then render the rest without any blending. This will avoid the headache of rendering translucent stuff in the first place and generally works for things like vegetation. It isn't perfect, but it's much easier, and texture filtering helps with not making it look very blocky.
Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.
Thanks for the answer! I tried what you proposed and the discard -statement proved to be working pretty fine! But as you said, it isn't perfect and there are still small issues with some of my models. But until I decide to reach a some level of perfection, it will do.
you should sort your drawcalls back to front for the transparent pass. that would fix the artifact in the first image where the far away tree draws through the close up tree. using the cutout method you will still get these artifacts around the edges of leaves if you dont. (if i understand correctly. these blending methods are pesky)
The palm in the background was drawn using instancing. I believe otherwise it would have been sorted correctly. I still need to work on some features.

This topic is closed to new replies.

Advertisement