Shader kills transparency

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
Siebenschläfer
Posts: 34
Joined: Thu Feb 05, 2009 11:37 am
Location: Koblenz, Germany

Shader kills transparency

Post by Siebenschläfer »

Hello,

I made a billboard covered with a texture where all black parts are transparent.

Code: Select all

					IBillboardSceneNode* videoLeftNode = Smgr->addBillboardSceneNode(0, core::dimension2d<f32>(60, 60), vector3df(0,0,0));
					
					videoLeftNode->setMaterialFlag(video::EMF_LIGHTING, false);
					videoLeftNode->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF);


					leftVideoTexture = Driver->getTexture("media/particle.jpg");

					videoLeftNode->setMaterialTexture(0, leftVideoTexture );

					Driver->makeColorKeyTexture( leftVideoTexture, video::SColor( 0, 0, 0, 0 ) );
so everything is working perfect. But I have to flip the texture on the billboard, what I used a shader for:

Code: Select all

ShadManager->flipTextureOnNodeVertically( videoLeftNode );
Vertex:

Code: Select all

void main() 
{
		vec4 flipPos = gl_MultiTexCoord0;
		
		flipPos.x = -gl_MultiTexCoord0.x;
				
		gl_TexCoord[0] = flipPos;
			
		gl_Position = ftransform();
} 
Fragment:

Code: Select all

uniform sampler2D RTTexture;
	
	void main()
	{
		vec4 color = texture2D( RTTexture, gl_TexCoord[0].st );
		
		gl_FragColor = color;
	}
It flips my texture as I desire but now the transparency of the black parts is gone, the black is still visible again.
What do I need to do to avoid that?

Cheers
Siebenschläfer
Think Tannenzäpfle!
Siebenschläfer
Posts: 34
Joined: Thu Feb 05, 2009 11:37 am
Location: Koblenz, Germany

Post by Siebenschläfer »

ok, the mistake was that I had to consider the resulting texture from the shader operation must be EMT_TRANSPARENT_ALPHA_CHANNEL_REF :idea:
Think Tannenzäpfle!
Post Reply