Problem with alpha texture

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
sylpheed
Posts: 25
Joined: Mon Nov 30, 2009 1:45 pm

Problem with alpha texture

Post by sylpheed »

I have a problem using a texture with alpha channel. If I use

Code: Select all

material.MaterialType = EMT_TRANSPARENT_ALPHA_CHANNEL;
then my mesh looks like this:

Image

You can see that background is shown in mesh edges. If I use

Code: Select all

material.MaterialType = EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
Then background is not shown in mesh edges, but I only get two levels of alpha value, so results are not smooth:

Image

I've tried with irr_material.MaterialTypeParam in first method, but can't get a decent results. Is there any way to get the mesh looking cool?

Thanks in advance
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Setting the MaterialTypeParam to something like 0.01f should do the job. What does it look like?
sylpheed
Posts: 25
Joined: Mon Nov 30, 2009 1:45 pm

Post by sylpheed »

It looks like this:

Image

Almost the same with MaterialTypeParam = 1.0. I would use shaders to fix this, but I'm using Irrlicht materials for whole scene, so I would have to implement a shader per object in the scene (lighting issues).
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Do you render the head with an alpha material as well? It looks like the browes are rendered first, and blended with the background. Only then the head is rendered. You need to either switch the head's materials, or change the render order (probably by rendering the browes in a second scene manager).
sylpheed
Posts: 25
Joined: Mon Nov 30, 2009 1:45 pm

Post by sylpheed »

hybrid wrote:Do you render the head with an alpha material as well? It looks like the browes are rendered first, and blended with the background. Only then the head is rendered. You need to either switch the head's materials, or change the render order (probably by rendering the browes in a second scene manager).
That's it! Now it renders fine. Sorry, it's my fault, I supposed Irrlicht would render mesh with no alpha first and then meshes with alpha, but I guess Irrlicht just order whole nodes.

Thanks for your help.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

No, solid meshes come first. That's why I assumed that the head also uses transparent materiuals (even if the transparency has no effect). I guess we could use a certain dependency marker in the scene node graph somehow. Well, other topic :wink:
Post Reply