I found this toon shader in an old thread:
http://forum.thegamecreators.com/?m=forum_view&t=89364&b=1 and opened it in Dark Shader. It looks quite good but I can't get it working in FPSC since it is referring to a base texture that is easy to define in Dark Shader but not so easy to set for any model in FPSC (models become white in FPSC).
The exported fx file look like this:
//
// FX Effect file - Cartoon
//
// Constants
matrix wvp : WorldViewProjection;
matrix world : World;
matrix worldIT : WorldIT;
float4 eyePos : EyePosition;
float4 lhtDir < string UIDirectional = "Light Direction"; > = { 0.136083, -0.952579, 0.272166, 0.000000 };
// Model and Texture Names
string XFile = "default.x";
texture toonshade < string name = "shade.jpg"; string ResourceName = ""; >;
texture toonedge < string name = "edge.jpg"; string ResourceName = "Edge.jpg"; >;
//Our base texture
texture basetex < string name = "base.jpg"; string ResourceName = "Aiko_D.dds"; >;
technique ToonWithTex
{
pass p0
{
VertexShaderConstant[0] = <wvp>;
VertexShaderConstant[4] = <worldIT>;
VertexShaderConstant[8] = <world>;
VertexShaderConstant[12] = <eyePos>;
VertexShaderConstant[13] = <lhtDir>;
VertexShader =
asm
{
// v0 -- position
// v3 -- normal
vs.1.1
dcl_position v0
dcl_normal v3
dcl_texcoord0 v6
// transform position
dp4 oPos.x, v0, c0
dp4 oPos.y, v0, c1
dp4 oPos.z, v0, c2
dp4 oPos.w, v0, c3
// transform normal
dp3 r0.x, v3, c8
dp3 r0.y, v3, c9
dp3 r0.z, v3, c10
// normalize normal
dp3 r0.w, r0, r0
rsq r0.w, r0.w
mul r0, r0, r0.w
// compute world space position
dp4 r1.x, v0, c8
dp4 r1.y, v0, c9
dp4 r1.z, v0, c10
dp4 r1.w, v0, c11
// vector from point to eye
add r2, c12, -r1
// normalize e
dp3 r2.w, r2, r2
rsq r2.w, r2.w
mul r2, r2, r2.w
// e dot n
dp3 oT1.x, r0, r2
// l dot n
dp3 oT2.x, r0, -c13
//Dump our basetex's coords into oT0.
mov oT0, v6
};
Texture[2] = <toonshade>;
Texture[1] = <toonedge>;
Texture[0] = <basetex>;
MinFilter[0] = Linear;
MagFilter[0] = Linear;
MipFilter[0] = Linear;
MinFilter[1] = Linear;
MagFilter[1] = Linear;
MipFilter[1] = Linear;
MinFilter[2] = Linear;
MagFilter[2] = Linear;
MipFilter[2] = Linear;
AddressU[2] = Clamp;
AddressV[2] = Clamp;
AddressU[1] = Clamp;
AddressV[1] = Clamp;
AddressU[0] = Wrap;
AddressV[0] = Wrap;
ColorOp[0] = SelectArg1;
ColorArg1[0] = Texture;
ColorOp[1] = Modulate;
ColorArg1[1] = Texture;
ColorArg2[1] = Current;
ColorOp[2] = Lerp;
ColorArg1[2]= Texture;
ColorArg2[2] = Current;
}
}
The area that probably needs fixing is around
//Our base texture where it is looking for Aiko_D.dds at the moment.
The attached file has two needed images (shade and egde).
Can anyone make this FPSC compatible so that the shader automatically locates the relevant model texture?