Png alpha problems

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
Amt0571
Posts: 128
Joined: Mon Mar 06, 2006 6:29 pm

Png alpha problems

Post by Amt0571 »

A few time ago I had this problem with my scene when using alpha textures:

Image

I solved it by setting vinya->getMaterial(140).ZWriteEnable=false; where 140 is the tree material.

Anyway, I have added a few more alpha textures, and they exhibit the same problem, except that when I try to fix them like I did with the trees it makes no effect.

I'm using 3D Studio Max as a modeller and my3d as the file format. I have made sure that the alpha materials are correctly named (ej. "AlphaChannel-whatever"). Maybe I'm missing something...


Thanks!
Saturn
Posts: 418
Joined: Mon Sep 25, 2006 5:58 pm

Post by Saturn »

What material settings are you using?

Looks as if you don't set it as EMT_TRANSPARENT_ALPHA_CHANNEL. When you set material to this, then they are drawn in correct order, else they aren't.

For performance reasons, you should consider using EMT_TRANSPARENT_ALPHA_CHANNEL_REF. This doesn't do alpha blending, but rather alpha rejection, which doesn't need sorting either and is considerably faster.
Amt0571
Posts: 128
Joined: Mon Mar 06, 2006 6:29 pm

Post by Amt0571 »

They are set as EMT_TRANSPARENT_ALPHA_CHANNEL, since this is what the my3d exporter sets the transparent materials to (I've checked this using irrEdit.

Is there any way to make the exporter set them to TRANSPARENT_ALPHA_CHANNEL_REF? or at least, a way to do it manually later?

I've tried with vinya->getMaterial(140).setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF); but it gives me a compiling error.


Thanks for you help!
Youen
Posts: 4
Joined: Sun Nov 26, 2006 5:30 pm

Post by Youen »

what is the compiling error ?
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

because that should be
vinya->getMaterial(140).MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
Image
Image
Virion
Competition winner
Posts: 2149
Joined: Mon Dec 18, 2006 5:04 am

Post by Virion »

I do think there is sorting problem (perhaps a bug) with EMT_TRANSPARENT_ALPHA_CHANNEL

This is EMT_TRANSPARENT_ALPHA_CHANNEL

Image

and this is EMT_TRANSPARENT_ALPHA_CHANNEL_REF

Image

i'm fine with EMT_TRANSPARENT_ALPHA_CHANNEL_REF but sometimes I need EMT_TRANSPARENT_ALPHA_CHANNEL for half transparent texture and the problem above doesn't allow me to use it.
My company: https://kloena.com
My profile: https://zhieng.com
My co-working space: https://deskspace.info
My game engine: https://kemena3d.com
Bear_130278
Posts: 237
Joined: Mon Jan 16, 2006 1:18 pm
Location: Odessa,Russian Federation

Post by Bear_130278 »

BTW, i experienced the same problem with tga alpha + ALPHA_CHANNEL
It is only this way in 1.5 and 1.5.1

EMT_TRANSPARENT_ALPHA_CHANNEL_REF
Image

EMT_TRANSPARENT_ALPHA_CHANNEL
Image
Do you like VODKA???
Image
Image
hybrid
Admin
Posts: 14144
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You can enable ZWrite on the material once you set the scene paramater ENABLE_ZWRITE_ON_TRANSPARENT. That will often fix such problems. However, _REF is much faster.
Virion
Competition winner
Posts: 2149
Joined: Mon Dec 18, 2006 5:04 am

Post by Virion »

@hybrid:

after i set scene parameter to ENABLE_ZWRITE_ON_TRANSPARENT and enabled ZWrite, my creature's head was being 'eaten' by its leaves :lol:

EMT_TRANSPARENT_ALPHA_CHANNEL
Image

as for EMT_TRANSPARENT_ALPHA_CHANNEL_REF, there is also a problem (in OpenGL only) which is lighting will be disabled when material type is EMT_TRANSPARENT_ALPHA_CHANNEL_REF. set EMF_LIGHTING to true does not give any effect, the lighting is still disabled.
My company: https://kloena.com
My profile: https://zhieng.com
My co-working space: https://deskspace.info
My game engine: https://kemena3d.com
hybrid
Admin
Posts: 14144
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Did you check this with Irrlicht 1.6 code? Some things have been fixed with those materials.
Post Reply