could somone help me to take away the outline pass in this:
/*****************************************************
Cartoon.fx - Cartoon Shader
By: Preston "NWC_Omega" Chaderton
This is a little shader that gives an object a little
more "cartoony" appearance. It doesn't smoothly shade
the model like normal and it gives it an outline.
The first pass draws the object. It accesses a certain
area on the shading texture (toon.dds) based on the
diffuse value generated by a single light. It then blends
this with the specified base texture (base.dds) to create
the cartoon like shading.
With the second pass, it draws the outline. It pushes
each vertex along it's normal by a certain amount, then
draws the object with a cw cull. This gives it a basic
outline, which, while it doesn't look the best, does it's
job.
It was created in FX Composer and then in Notepad for use in
Dark Basic Pro. It compiles under VS 1.1 and PS 1.1 for the
less powerful computers.
It runs at 350 FPS on my Intel Celeron 1.3 Ghrz, 512 MB
Ram, NVIDIA GeForce FX 5200 when applied to a sphere
with 3278 triangles in a test program running at
640x480x32.
****************************************************/
// light direction (view space)
float3 lightDir = {0.577, -0.577, 0.577};
// light intensity
float4 I_a = { 0.1f, 0.1f, 0.1f, 1.0f }; // ambient
float4 I_d = { 1.0f, 1.0f, 1.0f, 1.0f }; // diffuse
float4 I_s = { 1.0f, 1.0f, 1.0f, 1.0f }; // specular
// material reflectivity
float4 k_a = { 1.0f, 1.0f, 1.0f, 1.0f};
float4 k_d = {1.0f, 1.0f, 1.0f, 1.0f};
float4 k_s = { 1.0f, 1.0f, 1.0f, 1.0f};
int n = 32;
// texture
texture Tex0 <
string texturetype = "2D" ;
string name = "base.dds";
>;
texture Tex1 <
string texturetype = "2D" ;
string name = "toon.dds";
>;
// transformations
float4x4 World : WORLD;
float4x4 View : VIEW;
float4x4 Projection : PROJECTION;
struct VS_OUTPUT
{
float4 Pos : POSITION;
float4 Diff : COLOR0;
float4 Spec : COLOR1;
float2 Tex : TEXCOORD0;
float2 TexB : TEXCOORD1;
};
VS_OUTPUT VS(
float3 Pos : POSITION,
float3 Norm : NORMAL,
float2 Tex : TEXCOORD0)
{
VS_OUTPUT Out = (VS_OUTPUT)0;
float3 L = -lightDir;
float4x4 WorldView = mul(World, View);
float3 P = mul(float4(Pos, 1), (float4x3)WorldView); // position (view space)
float3 N = normalize(mul(Norm, (float3x3)World)); // normal (view space)
float3 R = normalize(2 * dot(N, L) * N - L); // reflection vector (view space)
float3 V = -normalize(P); // view direction (view space)
Out.Pos = mul(float4(P, 1), Projection); // position (projected)
Out.Diff = I_a * k_a + I_d * k_d * max(0, dot(N, L)); // diffuse + ambient
Out.Spec = I_s * k_s * pow(max(0, dot(R, V)), n/4); // specular
Out.Tex = Tex;
Out.TexB = Out.Diff.r;
return Out;
}
VS_OUTPUT OUTLINEVS(
float3 Pos : POSITION,
float3 Norm : NORMAL,
float2 Tex : TEXCOORD0)
{
VS_OUTPUT Out = (VS_OUTPUT)0;
float3 L = -lightDir;
float4x4 WorldView = mul(World, View);
float3 N = normalize(mul(Norm, (float3x3)WorldView)); // normal (view space)
float3 P = mul(float4(Pos, 1), (float4x3)WorldView) + .030 * N;
float3 R = normalize(2 * dot(N, L) * N - L); // reflection vector (view space)
float3 V = -normalize(P); // view direction (view space)
Out.Pos = mul(float4(P, 1), Projection); // position (projected)
Out.Diff = (0.01,0.01,0.01,1); // diffuse + ambient
Out.Spec = I_s * k_s * pow(max(0, dot(R, V)), n/4); // specular
Out.Tex = Tex;
return Out;
}
sampler MainSamp = sampler_state
{
Texture = (Tex0);
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
};
sampler ToonSamp = sampler_state
{
Texture = (Tex1);
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
AddressU = CLAMP;
AddressV = CLAMP;
AddressW = CLAMP;
};
float4 PS(
float4 Diff : COLOR0,
float4 Spec : COLOR1,
float2 Tex : TEXCOORD0,
float2 TexB : TEXCOORD1) : COLOR
{
float2 TexC = (TexB.x,0);
return tex2D(MainSamp, Tex)*tex2D(ToonSamp,TexB);
}
float4 OUTLINEPS() : COLOR
{
float4 ReturnThis = (0.01f,0.01f,0.01f,0.01f);
return ReturnThis;
}
technique TVertexAndPixelShader
{
pass P0
{
// shaders
VertexShader = compile vs_1_1 VS();
PixelShader = compile ps_1_1 PS();
}
pass P1
{
VertexShader = compile vs_1_1 OUTLINEVS();
PixelShader = compile ps_1_1 OUTLINEPS();
ZEnable = true;
ZWriteEnable = true;
CullMode = cw;
AlphaBlendEnable = false;
}
}
shader?
It's from the ultimate shader pack
I tried many times, but had no result.
Thanks for help!