October 31, 2010, 11:36am
I’ve a bunch of trees made up of two quads, which are scattered over the terrain. The SimpleTextured material with alpha.
The problem i’m having with them are twofold (but related i believe).
If one tree is in front of the other, the tree in the background is not visible where the forward quad covers it, even where it’s all non opaque.
If i use shadows (pssm for example), the shadow is blocked out in a similar way.
In JME2 this could be solved by changing the TestFunction. Looking into the RenderState class, there is such an enum (TestFunc), but it never seems to be used. How is it meant to be used?
Set them to trasnparent bucket if not done already
October 31, 2010, 12:06pm
Thanks for the quick and accurate reply!
October 31, 2010, 5:06pm
@rickard Are you saying PSSM works correctly with transparent objects?
That would be strange because that’s something I have in my todo stack
Ah, no i’m not saying that. I just didn’t mention it since i had already read about it in another thread
Sorry for the confusion.
( I’m actually not using pssm atm, just turned it on for a test drive. )
October 31, 2010, 5:43pm
Too bad i thought someone else had made my work
I’m afraid i’ve made this issue appear, again.
Since i implemented the geometry instancing (see User Code), i’ve noticed the same issue, even though transparent bucket is on.
See image for reference:
A batch now consists of three trees, and in some cases the transparent polys stop the polys behind them from being drawn, and in some cases not. I could understand if it happened all the time, but there are apparently “Good” batches too.
Does it have to do with the index buffer? That in some cases i just get lucky that the polys get drawn in the “correct” order?
There is not way to fix this issue at the moment. It is the alpha sorting problem which is very known in 3D rendering.
If you render the closer trees first, then they will write to the depth buffer so anything behind them won’t get drawn.
You have several options:
sort the polygons back-to-front in your batch
use alpha to coverage (but it requires anti-aliasing to be enabled)
use alpha test
use two-pass vegetation rendering
That gives me some key words to google for.