I am trying to render an transparent object in opengl but sometimes the textures are visible through each other and sometimes they are not. As far as I know I have to render them from the back to the front and it is looking fine when I do it manually but only from a Specific perspective. Is there any method to calculate the order in which they should be rendererd?
Asked
Active
Viewed 1,260 times
0
-
Put your objects in a list/array and sort them by distance relative to the point of view. – Martijn Courteaux Nov 27 '13 at 23:16
-
I've heared that I can use the Display List to do this... – Busti Nov 27 '13 at 23:17
-
But how do I order them? – Busti Nov 27 '13 at 23:17
-
Assuming your objects have cartesian coordinates, (X, Y, Z), then you can just calculate the distances by using sqrt(x^2 + y^2 + z^2), where x, y, and z are the distances of the objects from the perspective. Then, order them in descending order. – scott_fakename Nov 27 '13 at 23:19
-
I could calculate the distances manually but I know that there is another methot featuring the z Buffer or the depth to do this. – Busti Nov 27 '13 at 23:20
-
see http://stackoverflow.com/questions/7655597/rendering-transparent-objects-in-opengl – vandale Nov 27 '13 at 23:24
-
I already tried that but it doesn't help :( – Busti Nov 27 '13 at 23:26
1 Answers
0
If you have transparent objects, then you need to use Depth Peeling or some other Order-independent transparency method in order to properly render them if you aren't going to sort them.

user1118321
- 25,567
- 4
- 55
- 86
-
-
OpenGL will draw the geometry. You need to set it up with the proper depth buffers, fragment shaders, etc. You will have to do work to make this happen. It won't be as simple as just setting some flags and rendering. – user1118321 Nov 28 '13 at 00:06