Transparency and Materials

From Xith3D Wiki

Jump to: navigation, search

Taken from Xith3D Forum (http://xith.org/forum)

[edit] Question

I want to set transparency for my shape but when I add a material to the appearance the transparency is not visible... / Why is the transparency not visible when a shape has a material ? / How to combine transparency and materials ?

[edit] Short answer

Material material = new Material();
// ....
material.setColorTarget(mat.DIFFUSE);

Now, transparency AND material are working together.

[edit] Long answer

In principle transparency and material are enemies in OpenGL. But transparency can (and IS in xith) be handled by the diffuse color of the material.

Not all colors are valid for all color models (called color target in xith). So simply try to use only Diffuse color and add the others, if needed and if they have any effect. And play with the color targets.

You can read the OpenGL redbook for more informations about how material colors are handled in OpenGL.



Thanks to : Jotschi for the question, Marvin Froehlich for the answer, Amos Wenger for putting it into the Wiki

Personal tools