I need some help rendering this model right. It`s a palm tree, made of
a single mesh.
I am using BlendState.AlphaBlend before drawing it, but it looks wrong.
I know that transparent models should be ordered and all, but since all
the leaves are on a single mesh, how can i render it correctly? Here is
a short video, so you can see for yourself.
Please log in or register to post a reply.
For alphablending to work you would have to sort the triangles, so that
is not an option.
Use AlphaTest with a reasonable AlphaRef limit (aka only draw pixels
above X alpha)
You could use a modeling tool to split up the leaves into separate
pieces that you can then sort (this may not fix the problem 100%). You
could use alpha-test as Brac suggested (indeed this is how many, many
games draw vegetation). If you’re comfortable with shaders,
rendertargets and so forth, you could also explore more advanced
techniques such as depth
or the newer stochastic
Thank you for the replies.
Isn`t order independent transparency a bit expensive? Anyway, might be
a bit out of my league. I did write some basic shaders, but still pretty
new to them.
Someone suggested that i should use a two pass rendering technique:
* Pass 1: draw the solid part: alpha blending disabled, alpha test set
to only accept the 100% opaque areas, and depth buffer enabled
* Pass 2: draw the fringes: alpha blending enabled, alpha test set to
only accept pixels with alpha < 1, depth buffer enabled, depth writes
Would this work in my case?
EDIT: just tried the default AlphaTestEffect. It`s way better, of
course, but i still get some pixels wrong. Here`s a screen:
Again, would that two pass render help here?
That will help somewhat. The sorting will definitely be correct in the
opaque areas, but it will still be wrong in the translucent areas. But
if the translucent areas are only a thin fringe around the edges of the
leaves, it might not be very noticable.
It will also help performance (probably). The two-pass method is likely
to be faster than rendering everything transparently because on the
second pass, you’ll be getting early-Z-culling from the depth laid down
in the first pass. YMMV though.
As for the order-independent techniques, yes they will be more expensive
on the GPU. They can still be useful for cases where correctness is a
must and per-object or per-poly sorting isn’t going to cut it, or is
prohibitively expensive. But it’s just one more tool in the toolbox.
Thank you. I really appreciate your help, guys.
Thanks a lot!
It`s not hard to write that shader, i can do it, but i cant texture
these tree models right in my custom shader yet, since they have 2-3
textures, and there`s just 1 mesh. But at least i know im going in a