transparency fails?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
fitfool
Posts: 20
Joined: Sun Jul 15, 2007 5:40 am

transparency fails?

Post by fitfool »

Im trying to implement vertex transparancy in irrlicht but aren't getting any results, my mesh is still completely visible.

Heres what im doing now.

Code: Select all

GetSceneNode()->setMaterialTexture( 0, Core.CoreVideoDriver->getTexture(BOX_TEXTURE) );
	GetSceneNode()->getMaterial( 0 ).MaterialType = EMT_TRANSPARENT_VERTEX_ALPHA;
	GetSceneNode()->setMaterialFlag( EMF_LIGHTING, false );
GetSceneNode()->getMaterial( 0 ).AmbientColor.setAlpha( 100 );
Thanks ahead :)
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

I do not see any code which actually changes vertex color alpha and set it to transparent. If your vertices are not transparent, setting material to EMT_TRANSPARENT_VERTEX_ALPHA will do nothing.
fitfool
Posts: 20
Joined: Sun Jul 15, 2007 5:40 am

Post by fitfool »

I see, is there anyway i can just call GetSceneNode()->getMaterial( 0 ).AmbientColor.setAlpha( 100 ) and will make the whole mesh appear transparent? without having to iterate over all vertices and such?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

No, you can either use vertex alpha or texture alpha.
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

But you can use virtual void IMeshManipulator::setVertexColorAlpha (IMesh *mesh, s32 alpha)
fitfool
Posts: 20
Joined: Sun Jul 15, 2007 5:40 am

Post by fitfool »

Thanks, but what if i have muiltiple instances of that mesh and want to 'have' a different alpha for each?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Create a mesh copy for each one? If there are too many vertices to do y setVertexColor in each frame it seems like the only option. Or create separate textures and use alpha channel transparency, would require separate textures for each mesh, though.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Check out the shader example in the SDK (Number 10), that shows how to very easily manipulate alpha using shaders in Irrlicht.

You can create a vertex-only shader, and use as it's base material (The second to last parameter) EMT_TRANSPARENT_VERTEX_ALPHA, then output whatever vertex color you want based on a shader uniform. To use a vertex-only shader just use NULL for the pixel shader filename parameter in "addHighLevelShaderMaterialFromFiles". Vertex-only shaders are even supported on MX440's so you don't really have to worry about compatibility in this case.

Cheers
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
fitfool
Posts: 20
Joined: Sun Jul 15, 2007 5:40 am

Post by fitfool »

Hmm, i was hoping to avoid using shaders, ill try creating a new mesh instance for each, well... instance. Thanks a bunch

Hmm, btw, how should i use IMeshManipulator::setVertexColorAlpha? Is there any method within IAnimatedMesh were i can get() a IMeshManipulator?
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

You can get it in: ISceneManager::getMeshManipulator()
fitfool
Posts: 20
Joined: Sun Jul 15, 2007 5:40 am

Post by fitfool »

Works perfectly, thanks a bunch
Post Reply