Author Topic: Transparent polygons sorting  (Read 3531 times)

Offline keaukraine

  • byte
  • *
  • Posts: 34
    • View Profile
Transparent polygons sorting
« on: May 02, 2011, 09:50:05 am »
Hi,
I have an object which has only transparent triangles in it. The problem is that triangles are messed up in JPCT-AE. Does it have option for better triangle sorting algorithm? If not, please take a look at it, because I've had this problem with my previous app and had to calculate z-order manually which I can't do in current situation.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Transparent polygons sorting
« Reply #1 on: May 02, 2011, 10:43:24 am »
There is no triangle sorting at all. All there is, is object sorting. The gpu renders geometry data in large lumps, i.e. not triangle by triangle like a software renderer (or the hybrid pipeline of desktop jPCT) would do it. Within the object, there's no sorting other than the order in which the object is stored in memory. There's no way to reorder this. The latest DX11 desktop gpus can do some fancy "order independant transparency", but current mobile hardware is far away from this. All you can do is do split your object into several ones and hope that you won't run into sorting issues with those which, as you've already experienced, might happen as well depending on the scene. Or maybe you can get away with additive blending as 1+2+4 is the same as 2+1+4, so order doesn't really matter in that case (except for framebuffer accuracy).

How does your object look like?

Offline keaukraine

  • byte
  • *
  • Posts: 34
    • View Profile
Re: Transparent polygons sorting
« Reply #2 on: May 04, 2011, 12:55:06 pm »
My object is a flower. Apparently I can't use additive blending for flower petals. Could you implement z-order sorting per object, triangle by triangle? All 3D engines that I've used before on PC handle transparent polygons sorting. Yes it may lead to some performance drop but in my case it's simply unusable.

Offline keaukraine

  • byte
  • *
  • Posts: 34
    • View Profile
Re: Transparent polygons sorting
« Reply #3 on: May 04, 2011, 08:34:31 pm »
I've tried to implement custom sorting by creating new Object3D and addTriangle() method but it appeared to be too slow.

EDIT: As I see IVertexController and GenericVertexController don't provide methods for modifying UVs of mesh. Would you kindly extend IVertexController interface to be able to modify UVs of mesh? This way it can be possible to implement transparency sorting.
« Last Edit: May 05, 2011, 08:48:39 am by keaukraine »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Transparent polygons sorting
« Reply #4 on: May 05, 2011, 04:54:58 pm »
You can modify UV by using the PolygonManager, but taken care to use the proper compilation mode and call touch after the modification. However, i don't understand how this can improve sorting!? Polygon sorting actually kills the pipeline. The desktop version can do that, but its not an option on Android....it's simply too slow. It requires to do all transformations for all vertices in software. I'm not sure, but i somehow doubt that any high level engine is doing this.
Wouldn't it be better to split the flower into different objects?