Hello,
Is is possible to make a node with an alpha < 255 when the flag EMF_LIGHTING = true ?
I'm using meshManip->setVertexColorAlpha(mesh, alpha), but the node becomes transparent only if I put the flag on false.
Thanks for your help.
Lighting and alpha
Re: Lighting and alpha
Hm, it should usually depend on setting: material.BlendOperation = video::EBO_ADD;
Maybe material.ColorMaterial also plays a role.
Sadly I haven't put this stuff yet in MaterialViewer example. But on a quick test adding the line above in CMaterialControl::updateMaterial in that example allowed me to have transparency with or without lighting (should probaby also add bit more pattern to the background in that image to make it more visible - but stuff becomes gray).
I ony tested Irrlicht svn trunk version, not sure about 1.8
Maybe material.ColorMaterial also plays a role.
Sadly I haven't put this stuff yet in MaterialViewer example. But on a quick test adding the line above in CMaterialControl::updateMaterial in that example allowed me to have transparency with or without lighting (should probaby also add bit more pattern to the background in that image to make it more visible - but stuff becomes gray).
I ony tested Irrlicht svn trunk version, not sure about 1.8
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Lighting and alpha
Thanks, it works, but this way it actually applies the new alpha to every node using this mesh. I feel like this is a newbie mistake but I can't see how to solve it, in order to have only 1 mesh for which the new alpha applies.
Re: Lighting and alpha
Yeah, meshes are by default shared per node. And so if you change alpha in a mesh then then all nodes using that mesh change.
If you want to control it per model it works if you have only have colors (no textures) like:
material.ColorMaterial = video::ECM_NONE;
material.BlendOperation = video::EBO_ADD;
And then control it via the alpha of the DiffuseColor.
If you have textures (usual case...) things get more tricky. At that point I generally switch to shaders which are more flexible.
In theory you can also create mesh-copies and use one per node. Often meshes need very little memory (compare to for example textures), so creating copies isn't really that expensive. So you can have one copy per node for example. Or maybe if you have only need 1 transparent node create a mesh-copy for that one.
If you want to control it per model it works if you have only have colors (no textures) like:
material.ColorMaterial = video::ECM_NONE;
material.BlendOperation = video::EBO_ADD;
And then control it via the alpha of the DiffuseColor.
If you have textures (usual case...) things get more tricky. At that point I generally switch to shaders which are more flexible.
In theory you can also create mesh-copies and use one per node. Often meshes need very little memory (compare to for example textures), so creating copies isn't really that expensive. So you can have one copy per node for example. Or maybe if you have only need 1 transparent node create a mesh-copy for that one.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Lighting and alpha
Indeed I am using textures there.
According to the documentation it seems impossible to create a mesh copy for an animated mesh, am I right ?
According to the documentation it seems impossible to create a mesh copy for an animated mesh, am I right ?
Re: Lighting and alpha
I found out I could change the cache, so it seems to solve the problem, for every new node using the same mesh, every time it has a unique cache. I hope it's the correct way to do.
Re: Lighting and alpha
If it works it's correct ;-) And yeah, that might be the way to copy it, thought means having to load it a few times from disc then. I'd have to look up myself if there's another way for animated meshes (sorry, I don't use those much in my job I tend to work with static models). Probalby depends also a bit on the animation format you are using (skeleton meshes vs the mesh per frame animation formats).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Lighting and alpha
Great ! Then I will keep doing this.
I am using b3d format, with rigged meshes.
I am using b3d format, with rigged meshes.