Jump to content
  • Advertisement
Sign in to follow this  
j3p

DX11 Rendering textured leaves

This topic is 2518 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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...

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!