Author Topic: Texture transparency problem  (Read 1584 times)

Offline kunong

  • byte
  • *
  • Posts: 4
    • View Profile
Texture transparency problem
« on: January 31, 2013, 06:48:02 pm »
I want to set texture with transparency on my tree model but look like it has a problem when displays.

This is the tree model I want to be.
Captured from Blender.


But when I import it to jPCT-ae it seems like the display has a problem.
Here this is an image I have captured from my device.

I have created texture with Texture(..., useAlpha) constructor and called
Object3D.setTransparencyMode(Object3D.TRANSPARENCY_MODE_DEFAULT);
Object3D.setTransparency(20);


And when I didn't call setTransparency method it will show like this.


Please suggest me how can I solve this problem because I can't continue my project with this.

Thanks for your help.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Texture transparency problem
« Reply #1 on: January 31, 2013, 08:23:36 pm »
Transparent polygons have to be sorted to ensure proper rendering order. This sorting happens per object and depth buffer writes are disabled when drawing them to prevent transparent sections from overlapping with the non-transparent ones.  In your case, the tree is one single object (or at least the top is), so there's nothing to sort. Depending on the way in which the tree has been modeled, the result might look fine from one angle and wrong from others. The easiest way to solve this, is to split the tree into several objects, i.e. make each "level" its own object.
However, due to the fact that the levels overlap, you might run into similar sorting issues with that in certain angles, but that might not be too much of an issue.

Blender itself might render it per polygon (which solves the sorting issue, but is too slow on a mobile device) or they are using alpha testing instead/in addition (which is somehow deprecated in OpenGL ES 1.x and has been removed in 2.0 due to severage performance impacts, which is why jPCT-AE doesn't support it)