gryff Posted March 30, 2017 Share Posted March 30, 2017 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: Quote 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 Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted March 30, 2017 Share Posted March 30, 2017 For the warning piece, I have too many files open today to talk about. Quote Link to comment Share on other sites More sharing options...
gryff Posted March 31, 2017 Author Share Posted March 31, 2017 @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 . But until the demo works, the issue with the warning is a moot point. cheers, gryff Quote Link to comment Share on other sites More sharing options...
BitOfGold Posted March 31, 2017 Share Posted March 31, 2017 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.http://www.babylonjs-playground.com/#WVLHH#6 Quote Link to comment Share on other sites More sharing options...
gryff Posted March 31, 2017 Author Share Posted March 31, 2017 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 : Texture 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 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 31, 2017 Share Posted March 31, 2017 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: http://www.babylonjs-playground.com/#2L1MHP#1 opacityTexture.getAlphafromRGB is the key here BitOfGold and gryff 2 Quote Link to comment Share on other sites More sharing options...
gryff Posted March 31, 2017 Author Share Posted March 31, 2017 19 minutes ago, Deltakosh said: opacityTexture.getAlphafromRGB is the key here @Deltakosh My crap programming skill strikes again TY DK!! Now to see how far I can push this cheers, gryff Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 31, 2017 Share Posted March 31, 2017 My pleasure my friend! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.