Some issues about transparency sorting.

Started by kiffa, March 25, 2013, 11:12:47 AM

Previous topic - Next topic

kiffa

I 'am making a car-racing game. I made a road with some buildings, these buildings are just planes with alpha textures(png), and all the buildings are combinded to one mesh. The problem is: i could see the far buildings through the near buildings.

。。。。。。。。。。。。。。。。。。。
。                                                   。
。(far building)        (near building)。   <----- look at
。                                                   。
。。。。。。。。。。。。。。。。。。。
               



EgonOlsen

#1
There can't be any sorting if everything is one large object. You have split the parts you want to have sorted into different objects.

kiffa

The road is a ring, and some roads may be too complex to split( will cause many small objs). Any other solutions?

。。。。。。
。            。
。A          。    <--- look at
。。。。。。
building-ring

Could i discard the "A" by Z-buffer?



EgonOlsen

Quote from: kiffa on March 26, 2013, 03:01:09 AM
Any other solutions?

Could i discard the "A" by Z-buffer?
No, because transparent objects don't write into the zbuffer. If they were, the transparent parts would be written into it too and that would cause gaps and holes in the scene where non should be.
To render transparent objects correctly, it has to be possible to sort them. If all is one large object, then it isn't possible to sort them. You don't have to split the road itself but the building somehow have to be split into several parts. I don't think that it's needed to split them per building though. Larger lumps should do fine.

kiffa

#4
Thanks, i will try to split the buildings or make them opacity or add an opacity wall behind them.

Another question: Is there any difference of performance between one large mesh and many split ones?

EgonOlsen

Yes. A large one will be faster in most cases because it requires less draw calls. This might change if it's very large and only a part of it will be visible. That that case, many smaller ones might be better.

kiffa

Can i do like this :

1, Rendering all opacity objs.

2, Sorting all transparent objs, then rendering them by 2 pass:
a, pass 1:
     Disable alpha blend, enable alpha test, enable zBuffer, enable zBuffer-writable, only rending the pixel with alpha>=1(means 100% opacity ).

b, pass 2:
     Enable alpha blend, enable alpha test, enable zBuffer, disable zBuffer-writable, only rending the pixel with alpha<1

EgonOlsen

You would have to do that in your own code, because jPCT-AE doesn't support alpha tests. It will that way in OpenGL ES 1.1 only too, because alpha tests have been removed from OpenGL ES 2.0 anyway. It's also overly complicated IMHO. Why don't you simply split the transparent parts in smaller ones and all is fine!?

kiffa

Oh, thanks! The reason are 3:

1, I want to study more (and not just make work done).

2, I hate to export/convert(to .ser)/import/add to world/manager plenty of objs...  I prefer to keep them as few as i can.

3, My artist partner hate splitting them(there are about 21 roads-scene).

EgonOlsen

You could try to find a way (using PolygonManager/IVertexController) to split them in code...