transparent shader

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
irrlichtfan
Posts: 10
Joined: Tue Jan 20, 2009 2:40 pm

transparent shader

Post by irrlichtfan »

i have troubles with shaders that inherit from video::EMT_TRANSPARENT_ALPHA_CHANNEL.
it is generated with this statement and the final display is rather strange.

Code: Select all

shieldShaderInst = new CShieldShader(IRRINST);
	shaderId[(int)EST_SHIELD] = gpu->addHighLevelShaderMaterialFromFiles(
		G_XFXSHIELD, "VS", video::EVST_VS_2_0,
		G_XFXSHIELD, "PS", video::EPST_PS_2_0,
		shieldShaderInst, video::EMT_TRANSPARENT_ALPHA_CHANNEL);
the shader looks like this:

Code: Select all

float4x4 world;
float4x4 view;
float4x4 proj;
float texScale;
float time;


// Eingabe des Vertex-Shaders
struct VSIn
{
	float4 pos		: POSITION;	// Position der Vertizes
	float4 diff		: COLOR0;
	float3 normal	: NORMAL0;
	float2 texColor	: TEXCOORD0;	// Farbtextur
};

// Ausgabe des Vertex-Shaders
struct VSOut
{
	float4 pos		: POSITION0;	
	float4 diff		: COLOR0;
	float2 texColor : TEXCOORD0;
};

VSOut VS(VSIn In)
{
	VSOut Out;
	
	float4 pos = In.pos;// + float4(normalize(In.normal), 0.0f) * sin(time);//sin((time + In.pos.x + In.pos.z + In.pos.y) * 0.5f);
	pos = mul(pos, world);
	pos = mul(pos, view);
	pos = mul(pos, proj);
	Out.pos = pos;

	Out.diff = In.diff;
	Out.texColor = In.texColor / texScale;
	
	
	return Out;
}

// Ausgabe des Pixel-Shaders
struct PSOut
{
	float4 color : COLOR0;
};

// Sampler fuer Texturen
sampler2D tex0;		// Farbtextur

PSOut PS(VSOut In)
{
	PSOut Out;
	
	In.texColor = In.texColor + time / 20.0f;
	float4 pic = tex2D(tex0, In.texColor);
	float4 pic2 = tex2D(tex0, In.texColor - time / 10.0f);
	
	float4 high = pic + pic2;
	high = pow(high, 10);
	Out.color = pic + pic2 * 2.0f + high * 2.0f;
	//Out.color.a = pic.a + pic2.a;
	Out.color.a = 0.7f;
	return Out;
}

it strangely depends on the view, whether it is transparent or not.
Image
Image
Image
Post Reply