i've got somewhat of a nice shader running, take a look and try it in a level, i'm going to play with the intesity and stuff to get it just right and it'll be great:

Code:

/*

Code Created by Taco Cohen, and modified my Manga Page

*/

/***********************************************************************************************
/ Global Variables:
/***********************************************************************************************/
// Tweakables:
float4 SpecularIntensity = {2.0f, 2.0f, 2.0f, 2.0f}; // The intensity of the specular light.
float SpecularPower = 0.5f; // The specular power. Used as 'glossyness' factor.
//static const float4 SunColor = {0.3f, 0.3f, 0.3f, 0.3f}; // Color vector of the sunlight.

// Application fed data:
float4x4 matWorldViewProj; // World view projection matrix.
float4x4 matWorld; // World matrix.
float4x4 matWorldInv;
float4 vecAmbient; // Ambient color.
float4 vecLightPos;
float4 vecLight;
float vecLightColor;

texture entSkin1; // Color map.
sampler ColorMapSampler = sampler_state // Color map sampler.
{
Texture = <entSkin1>;
AddressU = Clamp;
AddressV = Clamp;
};

void SpecularVS(in float4 InPos : POSITION,
in float3 InNormal : NORMAL,
in float2 InTex : TEXCOORD0,

out float4 OutPos : POSITION,
out float2 OutTex : TEXCOORD0,
out float3 OutNormal: TEXCOORD1,
out float3 OutViewDir: TEXCOORD2)
{
// Transform the vertex from object space to clip space:
OutPos = mul(InPos, matWorldViewProj);

// Transform the normal from object space to world space:
OutNormal = normalize(mul(InNormal,matWorldInv));

// Calculate a vector from the vertex to the view:
OutViewDir = mul(vecLightPos, matWorld);

// Pass the texture coordinate to the pixel shader:
OutTex = InTex;
}


/***********************************************************************************************
/ Pixel Shader:
/***********************************************************************************************/
float4 SpecularPS( in float2 InTex : TEXCOORD0,
in float3 InNormal : TEXCOORD1,
in float4 InViewDir : TEXCOORD2) : COLOR
{
//SpecularIntensity += vecLightColor;
InNormal = normalize(InNormal);
// Calculate the ambient term:
float4 Ambient = vecLight;

// Calculate the diffuse term:
float4 Diffuse = saturate(dot(vecLightColor, InNormal));

// Fetch the pixel color from the color map:
//float4 Color = tex2D(ColorMapSampler, InTex);
float4 Color = tex2D(ColorMapSampler, InTex);

// Calculate the reflection vector:
float3 R = normalize(2 * dot(InNormal, vecLightColor + SpecularIntensity) * InNormal - SpecularIntensity);

// Calculate the speculate component:
//InViewDir = normalize(vecLight);
InViewDir = vecLightColor + SpecularIntensity *vecLight;
//float Specular = pow(saturate(dot(R, InViewDir)), SpecularPower) * SpecularIntensity;
float Specular = saturate(dot(R, InViewDir));
// Calculate final color:
return (Ambient + Diffuse + Specular) * Color;
}

/***********************************************************************************************
/ Technique:
/***********************************************************************************************/
technique SpecularTechnique
{
pass P0
{
VertexShader = compile vs_2_0 SpecularVS();
PixelShader = compile ps_2_0 SpecularPS();
}
}



note that i have no shader knowlede, if someone can help me perfect this you're welcome to


edit: code updated

Last edited by Manslayer101; 03/13/07 19:23.

- aka Manslayer101