Outline-Shader + Alpha-Skin at Models????

Posted By: Espér

Outline-Shader + Alpha-Skin at Models???? - 04/01/09 17:05

ok.. after bumping, i try my luck here...

I use this shadercode ( thx to cowabanga ):
Code:
float4x4 matWorldViewProj;

struct VS_IN 
{
	float4 pos : POSITION;
	float4 nrm : NORMAL;
};

struct VS_OUT 
{
	float4 oPos : POSITION;
	float4 oC0 : COLOR0;
	float4 oC1 : COLOR1;
};

VS_OUT OutlineVS (VS_IN In, uniform float scale, uniform float3 rgb)
{
	VS_OUT Out;
	In.pos.xyz += In.nrm.xyz*scale;
	Out.oPos = mul(In.pos,matWorldViewProj);
	Out.oC0 = Out.oC1 = float4(rgb,1.0);
	return Out;
}

technique test
{
	pass p1
	{
		CullMode = CCW;
	}
	pass p0
	{
		CullMode = CW;
		VertexShader = compile vs_2_0 OutlineVS(0.5,float3(0.0,0,0)); // thickness , rgb
	}
}




Now i recognized:
If i use a model, with an alpha-TGA File as Skin.. the complete model is Transparent like the alpha.. but completely black...

Any idea how to add the Alpha-TGA Support to that shader???
Posted By: Quad

Re: Outline-Shader + Alpha-Skin at Models???? - 04/01/09 19:45

im not very good at shaders but:
Code:
float4x4 matWorldViewProj;

struct VS_IN 
{
	float4 pos : POSITION;
	float4 nrm : NORMAL;
	float4 iC0 : COLOR0;
	float4 iC1 : COLOR1;
};

struct VS_OUT 
{
	float4 oPos : POSITION;
	float4 oC0 : COLOR0;
	float4 oC1 : COLOR1;
};

VS_OUT OutlineVS (VS_IN In, uniform float scale, uniform float3 rgb)
{
	VS_OUT Out;
	In.pos.xyz += In.nrm.xyz*scale;
	Out.oPos = mul(In.pos,matWorldViewProj);
	Out.oC0 = float4(rgb,1.0);
	Out.oC1 = In.iC1;
	return Out;
}

float4 OutlinePS(VS_OUT In) : COLOR
{   
	return In.oC1;
}

technique test
{
	pass p1
	{
		CullMode = CCW;
	}
	pass p0
	{
		CullMode = CW;
		VertexShader = compile vs_2_0 OutlineVS(0.2,float3(0.0,0,0)); // thickness , rgb
		PixelShader = compile ps_2_0 OutlinePS();
	}
}


edit: 1 made the thickness 0.2, change with your value.
Posted By: xXxGuitar511

Re: Outline-Shader + Alpha-Skin at Models???? - 04/01/09 20:40

try adding zWriteEnable = true; to both passes.
Posted By: Espér

Re: Outline-Shader + Alpha-Skin at Models???? - 04/01/09 20:44

where????
I´m absolute Noob in Shader Coding..
Posted By: WretchedSid

Re: Outline-Shader + Alpha-Skin at Models???? - 04/02/09 10:27

Here:
Code:
technique test
{
	pass p1
	{
                zWriteEnable = true;
		CullMode = CCW;
	}
	pass p0
	{
                zWriteEnable = true;
		CullMode = CW;
		VertexShader = compile vs_2_0 OutlineVS(0.5,float3(0.0,0,0)); // thickness , rgb
	}
}

Posted By: Espér

Re: Outline-Shader + Alpha-Skin at Models???? - 04/02/09 12:56

Hmm.. isn´t working right:


That crystal spider has to be Semi-transparent ( and not black >.< )..

Here´s the model file (tga textures included ):
>> Gegner.rar <<
Posted By: Espér

Re: Outline-Shader + Alpha-Skin at Models???? - 04/20/09 22:44

ok.. the problem still exists...

any idea how to fix that?
Posted By: rojart

Re: Outline-Shader + Alpha-Skin at Models???? - 04/21/09 01:20

Hi,
Check this 022_Kristallspinnenbaby2.mdl converted model by me, maybe work it now.
I´ve just converted the normals on your model.
© 2023 lite-C Forums