EMT_TRANSPARENT_VERTEX_ALPHA

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
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

EMT_TRANSPARENT_VERTEX_ALPHA

Post by mongoose7 »

I've been fooling around with the OBJ loader and shaders and I found some weird behaviour. That is, I set the colour in the pixel shader to a flat colour, well, white. But my object, a cube, has black artifacts. I think this is due to the base material being EMT_TRANSPARENT_VERTEX_ALPHA. Looking at the code, it sets blending, which is OK, but it also sets other stuff in the texture environment that I don't understand but that I guess is related to multi-texturing.

My point. I'm trying to control the output using a shader but I get these side effects. I suppose I could change to EMT_ONETEXTURE_BLEND but I really don't see why the other code is in Irrlicht. After all, Doom3 came out in 2004 and I don't think it does any multitexturing. In fact, I think 4 texture units have been available for a very long time.

In summary, do we really need that texture environment code or does it truly belong to another time?
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: EMT_TRANSPARENT_VERTEX_ALPHA

Post by Nadro »

This is fixed in trunk (OGL driver).
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: EMT_TRANSPARENT_VERTEX_ALPHA

Post by mongoose7 »

OK, thanks. Do we have a date for the release of 1.9?
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: EMT_TRANSPARENT_VERTEX_ALPHA

Post by Nadro »

Sorry, but not yet. We had plan for release v1.9 in summer, but due to lack of time we must delay this release for some months.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: EMT_TRANSPARENT_VERTEX_ALPHA

Post by mongoose7 »

Summer is still 5 weeks away :wink:
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: EMT_TRANSPARENT_VERTEX_ALPHA

Post by hendu »

Can you link the commit?
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: EMT_TRANSPARENT_VERTEX_ALPHA

Post by Nadro »

This is initial commit:
http://sourceforge.net/p/irrlicht/code/4403/
in the next commits we slightly improved some things related to this stuff. At now I see a bug in trunk with grab/drop base material (missing drop in destructor).

Anyway I think that the best solution for base material is available in COGLES2Driver and I'll implement it in standard OGL. At now I'm finishing my game, so in upcoming days I'll have more free time for irr dev, so I'll be able to send some fixes on the repo.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: EMT_TRANSPARENT_VERTEX_ALPHA

Post by mongoose7 »

This works, but the comments in IMaterialRendererServices.h are now out of date.
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: EMT_TRANSPARENT_VERTEX_ALPHA

Post by Nadro »

Thanks, I'll fix comments after apply these changes into D3D9 driver.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: EMT_TRANSPARENT_VERTEX_ALPHA

Post by Nadro »

In the latest trunk OpenGL handles base material in the same way as OpenGL ES2.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: EMT_TRANSPARENT_VERTEX_ALPHA

Post by mongoose7 »

I'm wondering about the texture_env_combine code in COpenGLMaterialRenderer.h. I have a simple setup, one transparent object in front of another. In the simplest case, one object is white and the other one is black. The black object appears black when in front/behind the white one (there is no ordering of transparent objects). But using (SRC_ALPHA, ONE_MINUS_SRC_ALPHA) you would expect, say, white*0.5 + black*0.5. So I thought I'd try some experiments in the shader.
Colour = (1, 1, 1, 1) both objects are white, even though background is black!
Colour = (1, 1, 1, 0.5) neither object appears in front of the black background.
Colour = (.5, .5, .5, 1) both objects appear with colour (.5, .5, .5).
Colour = (.5, .5, .5, .5) neither object appears in front of the black background.
It looks as if we are modulating and not blending!
BTW Material.DiffuseColor is (.8, .8, .8 ) though it shouldn't have any effect. There is a white texture bound to Unit 0 and a grey texture bound to Unit 1. Textures are also bound to Units 2 and 3.

Though I believe that texture_env_combine is used in terrain rendering, there is no such example in the Irrlicht code. The only appearance of the transparent modes is in the per-pixel lighting example and the material renderer example. I think that TRANSPARENT_VERTEX_ALPHA may need the combiner in order to use the vertex alpha, though the OBJ loader actually sets alpha in the Material.DiffuseColor and not the vertex colour.

tl;dr I think Irrlicht doesn't allow more than one transparent (occluding) object.
Post Reply