Entity Skill in einem shader u. Beleuchtung

Posted By: xxxxxxx

Entity Skill in einem shader u. Beleuchtung - 02/07/11 20:07

Hallo,
ich hab heute die Grundanimationen zwischen meinen beiden Formen des Charakters fertiggestellt! Nun arbeite ich an einem schönen Übergang zwischen beiden(einmal normaler charakter und einmal charakter aus schwarzen steinen) zu machen da hab ich mir nen shader geschrieben, da ich keine erfahrung damit habe wusste ich nicht wie ich wie ich die entity skills rein tue hab schon im manual und in anderen shadern rein geguckt! Hier mein shader wenn ihr lachen wollt grin
Code:
#include <vecskill>
//float4 vecSkill41; 
texture entSkin1;
texture entSkin2;


const float4x4 matWorldViewProj;



sampler sBaseTex = sampler_state { Texture = <entSkin1>; MipFilter = Linear;	};
sampler sSkin2 = sampler_state { Texture = <entSkin2>; MipFilter = None;	};

void VSshade(in float4 InPos : POSITION,in float2 InTex	: TEXCOORD0, out float4 OutPos	: POSITION, out float2 OutTex : TEXCOORD0)
{
	OutPos = mul(InPos, matWorldViewProj);
	OutTex = InTex;
	
}

float4 transperens_PS(in float2 InTex : TEXCOORD0): COLOR
{
	float3 color = tex2D(sSkin2,InTex);
	if(color.x <= vecSkill41.x)
	{
		return tex2D(sBaseTex,InTex);
	}
	else
	{
		return float4(0,0,0,0);
	}
}

technique filter
{
	pass one
	{
		VertexShader = compile vs_1_0 VSshade();
		PixelShader = compile ps_1_0 transperens_PS();
	}
}


ich weiß wollte nich mehr so viel posten! aber da habe ich halt noch garkeine erfahrungen!
hoffe ihr findet den fehler!
mfg
xxxxxxx
Posted By: xxxxxxx

Re: Entity Skill in einem shader - 02/08/11 10:33

Sorry mir ist nen fehler unter laufen es müsste so heißen
Code:
float4 vecSkill41; 
texture entSkin1;
texture entSkin2;


const float4x4 matWorldViewProj;



sampler sBaseTex = sampler_state { Texture = <entSkin1>; MipFilter = Linear;	};
sampler sSkin2 = sampler_state { Texture = <entSkin2>; MipFilter = None;	};

void VSshade(in float4 InPos : POSITION,in float2 InTex	: TEXCOORD0, out float4 OutPos	: POSITION, out float2 OutTex : TEXCOORD0)
{
	OutPos = mul(InPos, matWorldViewProj);
	OutTex = InTex;
	
}

float4 transperens_PS(in float2 InTex : TEXCOORD0): COLOR
{
	float3 color = tex2D(sSkin2,InTex);
	if(color.x <= vecSkill41.x)
	{
		return tex2D(sBaseTex,InTex);
	}
	else
	{
		return float4(0,0,0,0);
	}
}

technique filter
{
	pass one
	{
		VertexShader = compile vs_1_0 VSshade();
		PixelShader = compile ps_1_0 transperens_PS();
	}
}


und außerdem kennen shader keine var, leider!
mfg
xxxxxxx
Posted By: xxxxxxx

Re: Entity Skill in einem shader - 02/08/11 15:13

So nun habe ich versucht eine beleuchtung hinzuzufügen mit DoLight und so weiter aber ich kriege es nicht hin köntet ihr mir sagen was ich falsch mache? hier nochma was zum lachen(ich habe noch einen zweiten filter hinzugefügt der aber eigentlich das gleiche nur umgekehrt macht wenn skill 42 1 ist)
Code:
#include <sun>
#include <light>
#include <normal>
texture entSkin1;
texture entSkin2;
float4 vecSkill41;

const float4x4 matWorldViewProj;	// World*view*projection matrix.


sampler sBaseTex = sampler_state { Texture = <entSkin1>; MipFilter = Linear;	};
sampler sSkin2 = sampler_state { Texture = <entSkin2>; MipFilter = None;	};

void VSshade(in float4 InPos : POSITION,in float2 InTex	: TEXCOORD0, in float3 InNormal: NORMAL, out float4 OutPos	: POSITION, out float2 OutTex : TEXCOORD0, out float3 OutLight: COLOR)
{
	OutPos = mul(InPos, matWorldViewProj);
	OutLight = DoLight(OutPos,InNormal,1) + DoSunLight(InNormal);
	OutTex = InTex;
}

float4 transperens_PS(in float2 InTex : TEXCOORD0, in float3 InLight: COLOR): COLOR
{
	float3 color = tex2D(sSkin2,InTex);
	float fValue = vecSkill41.x;
	float fValue2 = vecSkill41.y;
	if(fValue2 == 1)
	{
		if(color.x >= clamp(fValue - 0.05,-0.05,1))
		{
			return tex2D(sSkin2,sBaseTex) * InLight;
		}
		else
		{
			return float4(0,0,0,0);
		}
	}
	else
	{
		if(color.x <= fValue)
		{
			return tex2D(sSkin2,sBaseTex) * InLight;
		}
		else
		{
			return float4(0,0,0,0);
		}
	}
}

	technique filter
	{
		pass one
		{
			VertexShader = compile vs_2_0 VSshade();
			PixelShader = compile ps_2_0 transperens_PS();
		}
	}


mfg
xxxxxxx
Posted By: xxxxxxx

Re: Entity Skill in einem shader - 02/08/11 16:47

Kann mal bitte jemand helfen? Ich hab bei shadern wirklich sogut wie keine Arnung! Geht ich hab jetzt einfach einen tutorial shader meinen bedürfnissen angepasst.
mfg
xxxxxxx
© 2024 lite-C Forums