Hello,
i've got a problem with the evolved toon shader.
It's just working in the front and back view, but not at the side view.
//====================================================
// Toon shader
//====================================================
// By EVOLVED
// www.evolved-software.com
//====================================================
//--------------
// un-tweaks
//--------------
matrix WorldVP:WorldViewProjection;
matrix World:World;
matrix ViewInv:ViewInverse;
//--------------
// tweaks
//--------------
float3 LightPosition={0.0f,50.0f,-250.0f};
float EdgeDis=0.5f;
float4 EdgeColour={0.6, 0.0, 0.0, 0.1}; // full red, order is RGBA
//--------------
// Textures
//--------------
texture BaseTX <string Name="";>;
sampler2D Base = sampler_state
{
texture = <BaseTX>;
};
texture ShadeTX <string Name="";>;
sampler2D Shade = sampler_state
{
texture = <ShadeTX>;
MagFilter=None;
MinFilter=None;
MipFilter=None;
};
//--------------
// structs
//--------------
struct input
{
float4 Pos : POSITION ;
float2 UV : TEXCOORD ;
float3 Normal : NORMAL;
};
struct output
{
float4 OPos : POSITION ;
float2 uv : TEXCOORD0 ;
float2 Shade : TEXCOORD1 ;
};
struct output_Edge
{
float4 OPos : POSITION ;
float4 Edge : COLOR0 ;
};
//--------------
// vertex shader
//--------------
output VS(input IN)
{
output OUT;
OUT.OPos=mul(IN.Pos,WorldVP);
OUT.uv=IN.UV;
float3 WNor=mul(IN.Normal,World);
WNor=normalize(WNor);
float3 WPos=mul(IN.Pos,World);
float3 LightVec=LightPosition-WPos;
float3 LightDir=mul(LightVec,WNor)/2;
OUT.Shade.xy=saturate(LightDir/length(LightVec));
return OUT;
}
output_Edge VS_Edge(input IN)
{
output_Edge OUT;
float4 Vpos;
Vpos.xyz=IN.Pos+(IN.Normal*EdgeDis);Vpos.w=IN.Pos.w;
OUT.OPos=mul(Vpos,WorldVP);
OUT.Edge.xyzw=EdgeColour;
return OUT;
}
//--------------
// techniques
//--------------
technique Toon
{
pass p0
{
vertexShader = compile vs_1_1 VS();
Sampler[0] = <Base>;
ColorOp[0] = MODULATE;
ColorArg1[0] = TEXTURE;
Sampler[1] = <Shade>;
ColorOp[1] = MODULATE;
ColorArg1[1] = TEXTURE;
}
pass p1
{
vertexShader = compile vs_1_1 VS_Edge();
CullMode = Cw;
// Sampler[0] = null;
// Sampler[1] = null;
ColorOp[0] = disable;
ColorOp[1] = disable;
}
}
anyone know's why?
dbSetVector4(1,dbObjectPositionX(1),dbObjectPositionY(1),dbObjectPositionZ(1) - 20, 0);
dbSetEffectConstantVector(1,"LightPosition",1);
dbSetEffectConstantFloat(1, "EdgeDis", 0.5f);
dbSetEffectTechnique(1, "Toon");