jPCT-AE - a 3d engine for Android > Support

Transparent plane and Polyline overlap

(1/2) > >>

atreyu64:
Hi,


I'm very new with jPCT and this is my first post.
So first congratulations for this great framework, easy to use even for a person not familiar at all with opengl like me, I really appreciate !

I'm planning to develop a kind of "virtual hiking guide" (for a french mountain), showing pathes with polylines and interest points (like mountain huts, lake names, ...) using plane billboards.
It works great and even an old android phone with sdk 2.3.3 can handle my 20000 polygons terrain, which is awesome. To be honest I've tried first another android opengl framework but it couldn't take that amount of polygons. JPCT seems the most performant one !

Anyway, the point is I have a transparency problem with my planes. When a polyline is behind a billboard plane, it is displayed as if it was "in front" of the plane.
I gess the problem comes from my plane transparency, which I have set this way (I need alpha channel) :


--- Code: ---Object3D plane = Primitives.getPlane(1, size);
if(TextureManager.getInstance().containsTexture(textureName) == false)
TextureManager.getInstance().addTexture(textureName, new Texture(bitmap, true));
plane.setTexture(textureName);
plane.setBillboarding(true);
plane.setTransparency(100);

--- End code ---

Note that I also scale the planse according to their distance to camera to make them look always at the same size on the screen, but I don't think it has a link with the issue.

And here is how I create my polylines :


--- Code: ---Polyline pathLine = new Polyline(pointsArray, color);
pathLine.setWidth(8f);
world.addPolyline(pathLine);
--- End code ---

Thanks in advance, and tell me if you need a screenshot, I don't know if what I'm saying is clear, my native language is french.

EgonOlsen:
I see...that's caused by the way in which transparent objects work in combination with the render order. Polylines will be drawn last, i.e. over the transparent objects. They do take the depth buffer into account, but transparent objects don't write into the depth buffer, so for the Polyline, they simply don't exist at all.
How many transparent objects are you using? If it's feasible, you can move them into a separate world instance (which uses the same camera settings as the main world) and render them after the opaque objects and the Polylines. That should fix the problem, but depending on how you are using transparent objects, it might not be very comfortable...i that case, i would have to change something in the render pipeline itself to fix this.

atreyu64:
Hi, thanks a lot for your answer.

Well, if you want to have an idea of how many transparent planes I need :



Is there a way to create transparency without alpha channel, using the setTransparency method but with another color than #0f0f0f ? I mean like if we were using a green screen ? It would be great because I need black color for my textures but I don't need some colors like green. I'll try to replace black pixels with a color a very little bit brighter than #0f0f0f. But antialiasing might ruin it all...

I'll keep you in touch if I find a solution, thanks again !

atreyu64:
Ok what I just said is stupid, if I use a "green screen" or any other color, it would be the same problem because we would still be dealing with transparent objects.
Sorry I'm not familiar at all with rendering concepts, it's very new for me.

atreyu64:
Hi, I tried what you suggested, using a second world for only transparent objects, and it works great !

Is it the correct way to do it ?


--- Code: ---fb.clear(back);
world.renderScene(fb); // my initial world
world2.renderScene(fb); // my world for transparent billboards
world.draw(fb);
world2.draw(fb);
fb.display();
--- End code ---

What about the performance hit of this method in terms of process and memory ? I didn't notice any change but I'm testing it on a Galaxy S3.

Anyway, thanks a lot for your help !

Navigation

[0] Message Index

[#] Next page

Go to full version