Jump to content

Use of OpacityTexture, Functionality and Blender export


Recommended Posts

I've been experimenting with the ability to use the opacityTexture with materials. And I have a couple of questions.

First, what is the functionality of the opacityTexture in BJS. In the PG demo of fire, it appears to be acting as an alpha map that gives a general shape of the flame.

Candle stick

However, when I try to use the same flame and alpha map on a simple plane in a playground - I just get the square image of fire

Simple plane

Why? Does the use of .opacityTextures require the fireMaterial script? If it does, that is not indicated in the docs.


Secondly, I tried using the same two textures in Blender - see result below. A simple plane has one material with two textures - flame and opacity.- and as you can see both have an impact on what is rendered.

However, when I export the plane to .babylon I get this curious comment:


WARNING: Opacity non-std way to indicate opacity, use material alpha to also use Opacity texture

Looking at the .babylon file the material only contains the flame texture - no reference at all to the opacity texture used.

What does that mean? And how do I export these alpha map textures from Blender ?

Edit: I have the opacity texture exporting now by changing the value of the "alpha" in image below to 1.  But I still get the warning message and the result viewed in the sandbox is just the square plane with the flame texture

cheers, gryff :)


Link to comment
Share on other sites

@JCPalmer: no rush Jeff :)  But I would like to know why that simple PG demo of the plane seems to do nothing. I'm using the BJS resource textures - so ... ?

Maybe my coding is wacko or maybe the "opacityTexture" delivers something  I am not anticipating :wacko:. But until the demo works, the issue with the warning is a moot point.

cheers, gryff :)

Link to comment
Share on other sites

Opacity texture means "get the alpha channel from this texture and ignore the rgb"
It is a bit confusing.
I did not know this.
a .useGreenFromOpacityTextureAsAlpha or something like that would be a good option I think. :)

A black/white opacity texture is easy to save in a small jpeg, so it is logical to use B/W jpeg for opacity texture and not an alpha from a png.
So, the candle opacity texture does not work because it does not have alpha.

Link to comment
Share on other sites

15 minutes ago, BitOfGold said:

Opacity texture means "get the alpha channel from this texture and ignore the rgb"

@BitOfGold : And that is what I am expecting - and got in Blender (see image above)

The "candleOpacity" texture - is a B/W image, though a .png rather than .jpg. Here it is :


And it works i with the "candle" PG I link to above - but not with the simple plane PG I created. Which is why I asked if it requires the fireMaterial.js script.

cheers, gryff :)

Link to comment
Share on other sites

Ok so the fireMaterial is not required :)


But the opacityTexture wants a texture with alpha channel by default. The CandleOpacity.png has no alpha channel.

But no worry I got you covered: you can ask the texture to use RGB value (the luminance) to act as alpha like this:


opacityTexture.getAlphafromRGB is the key here :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...