Forum

User toggles object transparency?

20 August 2016 00:13 #11310
I have a scene with buttons elsewhere on the page that allow the user to change object colors via m_mat.set_diffuse_color.

I'd like to do the same with transparency. Objects saved in blender with transparency display nicely with blend4web, but I don't know how to change the transparency setting dynamically.

I read the section here https://www.blend4web.com/doc/en/materials.html and see that the material alpha value is not used by the engine. I don't see how to use the alpha channel of a texture. I couldn't see anything further in the API.

Thanks!
20 August 2016 05:41 #11312
Figured it out. Being a relative blender newbie hurts me too.

In Blender:
Set material alpha to 0.
Add a texture.
Texture alpha factor now controls transparency.
20 August 2016 06:17 #11313
Oops, that was dumb. The even easier way is just to take advantage of the A in RGBA

set_diffuse_color(obj, mat_name, color) where color is RGBA
20 August 2016 08:28 #11314
Hey Joel, and welcome to the Blend4Web forums!

Glad you figured it out! See also the dedicated code snippet for material API usage.
Development Lead | Twitter
 
Please register or log in to leave a reply.