WebGL/OpenGL billboard behavioral differences

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
LunaRebirth
Posts: 386
Joined: Sun May 11, 2014 12:13 am

WebGL/OpenGL billboard behavioral differences

Post by LunaRebirth »

Hi,

I am using OpenGL for desktop, and WebGL for Emscripten. There are a few major differences between the two when using the same code.

1.
OpenGL:
billboard->setPosition() works fine while incrementing the, for example, X axis by 0.1.
WebGL:
the billboard's position only updates every ~25, so in order to see a change in the X axis while trying to move a billboard, I must hold it's movement for a long time.

(Note: Actual mesh move ok, just not billboards. If I set the billboard a child of a mesh object and move the parent mesh, the billboard does not follow it's parent on WebGL)

2.
OpenGL:
does not render billboards with transparency.
I have set my billboard to use EMT_TRANSPARENT_ALPHA_CHANNEL, and tried setting it's color to any amount of alpha -- the image appears to have no affect by the transparency.
WebGL:
the image displays the alpha color correctly.

3.
OpenGL:
lightSceneNodes do not (really) affect billboards.
If I setMaterialFlag(EMF_LIGHTING, false), the billboard becomes black without a light source (as it should). But if I add a light at any position, with any amount of radius, the billboard becomes fully lit (it shouldn't). However, the light source's color correctly affects the color of the billboard.
WebGL:
the billboard correctly lights up by distance/radius of the light.

I am having a hard time tracing where these issues are coming from or if I'm missing some flag or something somewhere.
CuteAlien
Admin
Posts: 9646
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: WebGL/OpenGL billboard behavioral differences

Post by CuteAlien »

I don't have a test-case right now. But I found one bug - I had to switch to using Meshbuffers in that code (was necessary for WebGL) and forgot to set the meshbuffer to dirty on changes. And it changes pretty much every frame. That might explain part of it (at least point 1 might be fixed maybe). Please try newest version if it improved some things.
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
LunaRebirth
Posts: 386
Joined: Sun May 11, 2014 12:13 am

Re: WebGL/OpenGL billboard behavioral differences

Post by LunaRebirth »

I created a test case and uploaded it here:
https://www.mediafire.com/file/37rnkwxs ... t.zip/file

#1 is unsolved with the newest version.

#3 Actually works fine with the newest version.

In the test I've uploaded, notice a few things:
(1) bill->setColor on WebGL changed the billboards entire color (including it's black color), but did not on OpenGL.
(2) bill->setColor on WebGL also changed it's transparency, but did not on OpenGL.
(3) bill->setPosition on OpenGL moves the billboard, but does not on OpenGL.
CuteAlien
Admin
Posts: 9646
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: WebGL/OpenGL billboard behavioral differences

Post by CuteAlien »

About 2: Your example uses an image without alpha (the .bmp) - EMT_TRANSPARENT_ALPHA_CHANNEL uses the alpha channel of the image. The other image (fire.png) has some alpha - but it's a constant alpha value which is identical over the whole image. Which is what it shows. Use for example gimp and add some alpha at parts of it and you will see the alpha.

The behavior of changing the vertex color (which setColor does) in EMT_TRANSPARENT_ALPHA_CHANNEL is kinda undefined. OpenGL might be more correct according to documentation - hard to say. To be on the safe side use own shaders for materials - then you can decided to use or ignore the vertex-color. For example in WebGL the shader COGLES2TransparentAlphaChannel.fsh does set color in the first line to vVertexColor. If you set it to vec4(1,1,1,1) instead then it behaves like OpenGL here.

I'm not familiar with that zaki branch you are using. But from what I can see it doesn't seem to contain any commits from 2018 - so the fix I made earlier in the thread shouldn't be in there. Actually a lot should be missing in there... maybe the automatic update it claims to do isn't actually done?
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
Post Reply