translucency/transparency

Started by
3 comments, last by Android_s 17 years, 4 months ago
Hi, I'm trying to have all my objects drawn to be translucent. Is this possible with using alpha/additive blending ? For example, all the things i'm drawing i set the alpha channel to 0.5, then i turne blending on. This works fine, except for the fact when i have a grid with a cube on top of it (the grid blends fine through the cube) when i move the grid so that the cube comes _under_ the grid, and i turn blending off, it is still transparent! How is this possible ? I hope you understand what i'm trying to say here. regards, 3dnewbie
Advertisement
What do you mean by grid? Is is a "grid" texture and you have your alpha channel set up to match the grid? You might need to set the glBlendFunc() parameters, if i remember correctly it's glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); (hmm?) =/

You might have the transparency sorting problem aswell. Make sure you draw all your transparent surfaces back to front, or you may get wierd resuslts when seeing a transparent surface through another transparent surface.

Wait, you said you turned off transparency? Hmm, i have no idea why that happens...are you really sure everything is set up the way you think it is? =)
----------------------------------------------------------------------------------------------------------------------"Ask not what humanity can do for you, ask what you can do for humanity." - By: Richard D. Colbert Jr.
Transparency is generally not done with "additive" blending. Also, in order for the blending to be correct, you must draw alpha-blended triangles after opaque triangles, and draw the farthest ones first.

BTW, "transparent" is the correct term. "translucent" means that light passes through but details are obscured. Colored glass is "transparent". Paper is "translucent".
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
ok, so a good analogy would be that translucent is stained glass for example?

the 'grid' i'm referring to is just a matrix i'm drawing with quads and lines, like a vector (think gibson :-).

so the normal rule with using 'alpha' blending is that all translucent surfaces must be drawn after the non-translucent surface. but what if like here, i want everything to be translucent?

i also am not sure about this whole drawing polygons in a certain order. i mean, i kind of get it, but isn't (non-textured at least) a polygon either seeing it from the back or the front, always the same ? and if i would need to do it, how? in my case i'm drawing a whole lot of quads and gl_lines, do i need to also draw these correct? i am writing some cubes as well, i bet i do need to write these in order? I must admit i don't see anything 'weird' about them yet..

thank you very much for any explanation
Quote:
ok, so a good analogy would be that translucent is stained glass for example?

Transparent... =)

Well, to be strict, you should first render all your opaque polygons front to back, then you render your transparent back to front...
This involves sorting your polygons after their depth, and if you want to be really strict, split polygons that intersect other polygons...

However this is not often done in realtime systems (not that i know at least) because it *can* be a rather expensive operation. If you've ever played "GTA:Vice City" you can see some wird effects when seeing trees through other trees or plants...this is happening because they didn't sort the transparent surfaces...

In your case you should at least sort the transparent surfaces and then render them correctly, even the cube's surfaces. =)
There are a few ways to do this, but it often involves checking the polygon's vertices depth and then approximate where it's depth would be. Then you use a fast sorting algorithm (qsort for example?) and then render them.
----------------------------------------------------------------------------------------------------------------------"Ask not what humanity can do for you, ask what you can do for humanity." - By: Richard D. Colbert Jr.

This topic is closed to new replies.

Advertisement