Correct blending for a single object

Started by Rene, September 13, 2009, 21:11:27

Previous topic - Next topic

Rene

Hi all,

While working on blending in my engine, I wanted to render a transparent dice. Now I know if you want to render transparent surfaces correctly, you must draw the furthest surface first, and the nearest last. But how can I render the dice correctly? In the engine, all 'models' are stored in Vertex Buffer Objects. The only solution I can think of is to make the dice out of six different models, and render them in the correct order. But this isn't a very nice solution, especially not for other kinds of models. Does somebody know a better way to do this?

Thanks in advance.
When I am king, they shall not have bread and shelter only, but also teachings out of books, for a full belly is little worth where the mind is starved - Mark Twain

bobjob


use GL11.glEnable(GL11.GL_CULL_FACE);

then it will only draw the front facing poly's.

do you want to show all sides?
method 1:
then you can enable FRONT culling
draw the cube (so it draws inward facing quads). reset the culling to BACK
then draw the cube again (so it draws outward facing quads).

method 2:
or you can make a VBO cube that has two cubes one that faces out and one that faces in.
make sure to order the polies so that the quads facing in are drawn first.


method 1 requires more gl calls (so I assume it would be slower).
method 2 requires a bigger object as its 2 cubes not one (but this should be fine considiring cubes are very low poly)
either way both methods require culling to be enabled.

Rene

Thanks for your reply.

Quote from: bobjob on September 13, 2009, 21:35:53
do you want to show all sides?
Yeah, the idea is to show the pits on the other side of the dice, too.

Quote
method 1:
then you can enable FRONT culling
draw the cube (so it draws inward facing quads). reset the culling to BACK
then draw the cube again (so it draws outward facing quads).
This worked pretty well, but as you pointed out it is slower than the other method. Also, it doesn't fit very nice in the engine as it needs to change the Render States during the drawing pass. IMO, the drawing pass shouldn't do that.

Quote
method 2:
or you can make a VBO cube that has two cubes one that faces out and one that faces in.
make sure to order the polies so that the quads facing in are drawn first.
This is the method I'm going to use.
It works very well, thanks for the help!
When I am king, they shall not have bread and shelter only, but also teachings out of books, for a full belly is little worth where the mind is starved - Mark Twain