Trouble with 2D override material

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
Auria
Competition winner
Posts: 120
Joined: Wed Feb 18, 2009 1:11 am
Contact:

Trouble with 2D override material

Post by Auria »

Hi everyone,

irrLicht 1.7 introduced a 2D override material, to tweak the way GUI stuff is drawn (our main motivation with this, atm, is to use smooth scaling interpolation instead of the default blocky scaling)

For reference, the menu usually looks like:

http://3.bp.blogspot.com/_im4Yv1xoVXw/S ... h/STK2.jpg

The code I added to get the 2D override material running is :

Code: Select all

    m_video_driver->enableMaterial2D();
    video::SMaterial& material2D = m_video_driver->getMaterial2D();
    material2D.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
    material2D.setFlag(video::EMF_BILINEAR_FILTER, true);
    material2D.AmbientColor = SColor(255,255,255,255);
    material2D.DiffuseColor = SColor(255,255,255,255);
    material2D.EmissiveColor = SColor(255,0,0,0);
    material2D.GouraudShading = false;
    material2D.Shininess = 0.0f;
However, I get this : http://img686.imageshack.us/img686/6779 ... 6at101.png

I tried a few variations, especially with colors, but nothing seems to have any impact on the outcome.

Any idea would be welcome!
Thanks
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Well, the 2d modes and the material overrides might mix in a very strange way. Best is to use EMT_SOLID for the material, the other settings are taken from the draw methods anyway. The override material is for setting thickness, anti-aliasing, wireframe, filters, etc.
Please have a look at example 6, I've added an example for the 2d override material where it enables filtering together with texture alpha. Maybe I should fix the material type to EMT_SOLID to make it less complicated - however it might be really interesting to have certain effects from the material type properties. Maybe someone else also has an opinion :)
Auria
Competition winner
Posts: 120
Joined: Wed Feb 18, 2009 1:11 am
Contact:

Post by Auria »

Hi Hybrid,

thanks for the tips. It seems like the material must be explicitely enabled and disabled every frame before and after doing 2D rendering, otherwise this weird effect happens.

Now our GUI mostly looks good throughout :) there is only one place where it screws up, and it's when we're overlaying GUI elements on top of a 3D scene. For some reason, the whitish effects strikes back then. :(
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Ok, I'll add a test case and see what goes wrong there. Probably some renderstate caching which breaks some setup.
Post Reply