Transparency

All topics about ZGameEditor goes here.

Moderator: Moderators

Post Reply
Chupacapra
Posts: 4
Joined: Fri Aug 08, 2008 12:34 pm

Transparency

Post by Chupacapra »

How can I make a transparent(invisible) material for 3D objects?
User avatar
Kjell
Posts: 1883
Joined: Sat Feb 23, 2008 11:15 pm

Post 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
Attachments
Material.gif
Material.gif (5.11 KiB) Viewed 13820 times
Chupacapra
Posts: 4
Joined: Fri Aug 08, 2008 12:34 pm

Post 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??
User avatar
Kjell
Posts: 1883
Joined: Sat Feb 23, 2008 11:15 pm

Post 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
Chupacapra
Posts: 4
Joined: Fri Aug 08, 2008 12:34 pm

Post 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
User avatar
Kjell
Posts: 1883
Joined: Sat Feb 23, 2008 11:15 pm

Post 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
Attachments
Alpha.jpg
Alpha.jpg (37.99 KiB) Viewed 13800 times
Alpha.zip
(37.78 KiB) Downloaded 537 times
Chupacapra
Posts: 4
Joined: Fri Aug 08, 2008 12:34 pm

Post 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.
Tischk
Posts: 8
Joined: Tue Dec 30, 2008 6:19 pm
Contact:

Post by Tischk »

What if I want to change the alpha on one model when theres several other models with the same material?
User avatar
Kjell
Posts: 1883
Joined: Sat Feb 23, 2008 11:15 pm

Post 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
Tischk
Posts: 8
Joined: Tue Dec 30, 2008 6:19 pm
Contact:

Post 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?
kattle87
Posts: 402
Joined: Wed Sep 26, 2007 9:06 am
Location: Italy

Post 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 :)
In the fall of 1972 President Nixon announced that the rate of increase of inflation was decreasing. This was the first time a sitting president used the third derivative to advance his case for reelection.
-=Hugo Rossi=-
Tischk
Posts: 8
Joined: Tue Dec 30, 2008 6:19 pm
Contact:

Post 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
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post 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,. .
iterationGAMES.com
Post Reply