Page 1 of 1

Transparency

Posted: Fri Aug 08, 2008 12:43 pm
by Chupacapra
How can I make a transparent(invisible) material for 3D objects?

Posted: Fri Aug 08, 2008 4:39 pm
by Kjell
Hello Chupacapra,

Right click on the color property of a Material to open up the Alpha dialogue. Alternatively you can use a ZExpression component to set the Alpha value with the following script.

Code: Select all

MyMaterial.Color.A = 128/256;
In this example the name of the Material is "MyMaterial", and I'm setting the alpha value to 0.5 ( 128/256 ).

Welcome to the ZGE community :)
Kjell

Posted: Sat Aug 09, 2008 11:58 am
by Chupacapra
Hello Kjell,

I tried it with different values but there is no transparency effect.(It's either black or white) What did I make wrong??

Posted: Sat Aug 09, 2008 1:09 pm
by Kjell
Hi Chupacapra,

Sorry, I forgot to mention that you need to set the Blend property to for example "Alpha/One" for it to work :oops: When Blend is set to None, the Alpha value is not taken in consideration.

Good luck ~
K

Posted: Sat Aug 09, 2008 3:04 pm
by Chupacapra
Thank you,

But i tried it again and nothing happened(same problem as before). I tested the alpha values -1, 0, 0.5 and 1 with each blend option. Not any combination had a transparency effect. :(

C

Posted: Sat Aug 09, 2008 3:45 pm
by Kjell
Hi Chupacapra,

Hmm, I wonder if it's a hardware problem. Can you try out the attached example ( exe + source )? What you should be seeing is a rotating ( double-sided ) cube fading in and out in front of a colorful background.

Regards,
K

Posted: Sat Aug 09, 2008 6:12 pm
by Chupacapra
OK, now it works :D

I reduced the alpha value to 0.0015, put the tick in "DrawBackFace" and removed the tick from ZBuffer.

Thank you very much.

Posted: Tue Dec 30, 2008 11:22 pm
by Tischk
What if I want to change the alpha on one model when theres several other models with the same material?

Posted: Wed Dec 31, 2008 12:39 am
by Kjell
Hi Tischk,

There are a couple of ways you can go about this. One is to put the Material Component in the Model's Definitions ( so each Clone has their own instance of the Material assigned ), another is to use a RenderSetColor Component after UseMaterial with some kind of Condition to pick out the desired Clone(s) .. or you could use a ModelState.

These kind of situations always require a bit of creative thinking, even when you're just writing C++ / Delphi.

Good luck ~
K

Posted: Wed Dec 31, 2008 11:59 am
by Tischk
Kjell wrote:Hi Tischk,

There are a couple of ways you can go about this. One is to put the Material Component in the Model's Definitions ( so each Clone has their own instance of the Material assigned ), another is to use a RenderSetColor Component after UseMaterial with some kind of Condition to pick out the desired Clone(s) .. or you could use a ModelState.

These kind of situations always require a bit of creative thinking, even when you're just writing C++ / Delphi.

Good luck ~
K
Thank you. I got one more question. How do I remove a model with code?

Posted: Wed Dec 31, 2008 12:15 pm
by kattle87
the (only) way is:
use the condition component and put the "RemoveModel" component inside "On-True". You can also use some kind of global variable and put the condition inside the model (in case you need to eliminate some clones).

The scripting language is under development so it might be easier in the future :)

Posted: Wed Dec 31, 2008 12:22 pm
by Tischk
kattle87 wrote:the (only) way is:
use the condition component and put the "RemoveModel" component inside "On-True". You can also use some kind of global variable and put the condition inside the model (in case you need to eliminate some clones).

The scripting language is under development so it might be easier in the future :)
Ah okay. That is abit exhausting. ;P

Posted: Thu Jan 01, 2009 2:17 pm
by jph_wacheski
you can also remove all the instances of a single type of model using the RemoveAllModels component, use the pulldown list,. I find this one sometimes quite usefull.

most of the materials I use are pure white with alpha set to 1,. I then use the RenderSetColor in the render events of the Models to set the actual color and alpha values,. in this way you reall only need a few materials for the blend modes and textures you want,. .