Problem with alpha texture [SOLVED]

Problems building or running the engine, queries about how to use features etc.
Post Reply
User avatar
pezzzz
Gnoblar
Posts: 16
Joined: Fri Aug 28, 2009 11:40 am

Problem with alpha texture [SOLVED]

Post by pezzzz » Fri Aug 28, 2009 2:43 pm

I'm having a strange problem using png texture with alpha channel.

This scene has:
- black background
- one big plane far from camera
- some little planes in the foreground, created in the same way

I'm using Linux, with Ogre 1.6.2 and nvidia 9600GT

Same texture in the bug plane and in little planes
Image

Another test with camera in a different position and less little planes
Image

In this test the big plane has a different dexture
Image


As you can see, some planes do a good alpha blend, other have a black background instead of transparent background, other blend good with some planes and bad with other (2nd example). If I change background color of the viewport to a COLOR, some little planes show this COLOR as background.
3rd example: two different materials, with two different texture (both png with alpha channel) and all planes' backgrounds became the same color as the viewport background.

P.S.: I'm sorry for my bad english.

Alessandro
Last edited by pezzzz on Fri Aug 28, 2009 3:50 pm, edited 1 time in total.
0 x

User avatar
pezzzz
Gnoblar
Posts: 16
Joined: Fri Aug 28, 2009 11:40 am

Re: Problem with alpha texture

Post by pezzzz » Fri Aug 28, 2009 2:45 pm

This is the material script:

Ball is for little planes, Bg is for the big plane

Code: Select all

material Sphere/Ball
{
	technique
	{
		pass
		{
			ambient 0.7 0.7 0.7
			cull_hardware none
			scene_blend alpha_blend
			texture_unit
			{
				texture love.png
				//tex_address_mode mirror
			}
		}
	}
}

material Sphere/Bg
{
        technique
        {
                pass
                {
                        ambient 0.7 0.7 0.7
                        cull_hardware none
                        scene_blend alpha_blend
                        texture_unit
                        {
                                texture placeHolder.png
                                tex_address_mode mirror
                                scene_blend alpha_blend
                        }
                }
        }
}
This is the texture:
Image

***
Another test, with little planes aligned:
Image

In this example, it seems that some planes make the plane behind "transparent".
0 x
Alessandro Pezzato
Image

User avatar
nullsquared
Old One
Posts: 3245
Joined: Tue Apr 24, 2007 8:23 pm
Location: NY, NY, USA

Re: Problem with alpha texture

Post by nullsquared » Fri Aug 28, 2009 3:38 pm

You need "depth_write off". That plus "scene_blend add" tells Ogre to sort the transparent objects back-to-front, otherwise you'll get incorrect blending as you can currently see :mrgreen:
0 x

User avatar
pezzzz
Gnoblar
Posts: 16
Joined: Fri Aug 28, 2009 11:40 am

Re: Problem with alpha texture

Post by pezzzz » Fri Aug 28, 2009 3:48 pm

Thank you for the fast response!
This material works fine:

Code: Select all

material Sphere/Ball
{
	technique
	{
		pass
		{
			ambient 0.7 0.7 0.7
			cull_hardware none
			scene_blend alpha_blend
			depth_write off // <===== WHAT I NEEDED
			texture_unit
			{
				texture love.png
			}
		}
	}
}
0 x
Alessandro Pezzato
Image

Post Reply