Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Don't forget to read Tuesday's email newsletter for your chance to win a free copy of Construct 2!


Rendering textured leaves


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 fanwars   Members   -  Reputation: 1021

Like
0Likes
Like

Posted 21 January 2012 - 11:28 AM

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

Regular blending. Most of the leaves are are covered by "transparent" triangles. Also, the ssao catches the edges of the quads...
render_depthw.png

Any thoughts appreciated...

Sponsor:

#2 Sik_the_hedgehog   Crossbones+   -  Reputation: 1813

Like
1Likes
Like

Posted 21 January 2012 - 02:24 PM

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.

#3 fanwars   Members   -  Reputation: 1021

Like
0Likes
Like

Posted 21 January 2012 - 03:51 PM

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.

#4 bzroom   Members   -  Reputation: 647

Like
0Likes
Like

Posted 21 January 2012 - 06:23 PM

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)

#5 fanwars   Members   -  Reputation: 1021

Like
0Likes
Like

Posted 22 January 2012 - 01:37 AM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS