AlphaBlending and EarlyZ write
Hi everyone,
I'm trying to render alpha-blended geometry using a renderer architecture like the following:
- Render the depth into R32F
- Render the scene into normal RT (or directly into the framebuffer and resolve the texture)
- Accumulate the depth target and scene target to display fog based on distance.
Now rendering just the scene works fine with the alpha-blended objects.
However, rendering the alpha-blended objects into the depth target will result in a wrong depth at the alpha-blended parts of the geometry.
This means that the fog will be calculated correctly for the non alpha-blended geometry, but the alpha-blended parts have a wrong depth and thus the fog is displayed wrong for my trees.
What's the common approach to solve this problem?
regards
[Edited by - FoxHunter2 on August 7, 2008 1:13:38 PM]
Using alpha-testing will give you the right values in your depth-buffer, however this causes ugly hard edges. Alpha-to-coverage can help with that, though.
You could use alpha-testing just for rendering your depth...but that will cause artifacts in the pixels where alpha is between 0 and 1. You might be able to tweak your assets or your fog effect to make that look acceptable.
You could use alpha-testing just for rendering your depth...but that will cause artifacts in the pixels where alpha is between 0 and 1. You might be able to tweak your assets or your fog effect to make that look acceptable.
Does this mean there is no good solution to this problem?
How would I tweak my fog formula? The only way to apply the correct fog thickness is by the depth, which doesn't work in this case.
And by "tweak your assets" you mean to use more polygons for the trees (and thus the leaves) so that alpha blending is reduced to a minimum?
How do games like Crysis handle this? I don't think they can render just a bunch of highpoly trees, even when using instancing.
regards
How would I tweak my fog formula? The only way to apply the correct fog thickness is by the depth, which doesn't work in this case.
And by "tweak your assets" you mean to use more polygons for the trees (and thus the leaves) so that alpha blending is reduced to a minimum?
How do games like Crysis handle this? I don't think they can render just a bunch of highpoly trees, even when using instancing.
regards
What MJP talks about is all in the context of alpha testing. I'd suggest that you use alpha testing, and see if the result is acceptable.
Quote:Original post by FoxHunter2
Does this mean there is no good solution to this problem?
*shrug*
There might be better solutions that I don't know of, I'm certainly not the ultimate expert on this subject. [smile]
Personally I don't really consider alpha-to-coverage to be a bad solution...it's becoming very popular in games since it relieves you of all the hassles of alpha-blending while still looking better than alpha-testing.
Another alternative I didn't think of before is that you could render your alpha-blended geometry after the fog pass, and apply the fog directly. It would depend on how your fog algorithm works...but you might be able to get away with something lower quality that most people won't notice.
Quote:Original post by FoxHunter2
How do games like Crysis handle this? I don't think they can render just a bunch of highpoly trees, even when using instancing.
I'm not sure what they do. It's not regular alpha-testing, because enabling transparency AA doesn't seem to have any effect on the foliage.
Honestly you should reconsider doing what Crysis does, because you may not have the same budget on artist resources, performance resources. Especially if your fog is a simple fog that can be accurately computed per pixel (what we've always been doing).
Anyway :
- trees in crysis are alpha tested. The reason transparency aa is not apparent is for other reasons.
- alpha to coverage is only available in antialiased modes, but then you get other problems (very close to what you see with alpha blending) which can be solved only with dx10 (reading back individual samples color and depth applying fog to it then averaging them per pixel).
- Crysis did indeed have issues with semi-transparent objects (other than trees). The way they fixed it is by rendering the opaque objects first, apply the fog on that as you did. Then render the semi-transparent objects on the already fogged background with an approximation of fog per vertex or per pixel (which is the way everything has been done for ever). the approximation has to be accurate enough that a tree foliage doesn't look too different from the ground it is standing on.
LeGreg
Anyway :
- trees in crysis are alpha tested. The reason transparency aa is not apparent is for other reasons.
- alpha to coverage is only available in antialiased modes, but then you get other problems (very close to what you see with alpha blending) which can be solved only with dx10 (reading back individual samples color and depth applying fog to it then averaging them per pixel).
- Crysis did indeed have issues with semi-transparent objects (other than trees). The way they fixed it is by rendering the opaque objects first, apply the fog on that as you did. Then render the semi-transparent objects on the already fogged background with an approximation of fog per vertex or per pixel (which is the way everything has been done for ever). the approximation has to be accurate enough that a tree foliage doesn't look too different from the ground it is standing on.
LeGreg
Thanks everyone for the suggestions! They were all very helpful.
I helped myself by replacing the alpha-blended "6-plane-tree" with a low-poly palm that uses polygons to display the leaves, making alpha-blending unnecessary.
It even looks better in my opinion.
But I definitely will come back to your ideas when I will be forced to use some foliage.
I helped myself by replacing the alpha-blended "6-plane-tree" with a low-poly palm that uses polygons to display the leaves, making alpha-blending unnecessary.
It even looks better in my opinion.
But I definitely will come back to your ideas when I will be forced to use some foliage.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement