neogir
Your asm ps shader represents a very common lightning model, nothing more.
Here it is:
extern float3 cAmbient : AMBIENT;
extern float3 cDiffuse : DIFFUSE;
extern float3 cSpecular: SPECULAR;
struct PSIn
{
float4 color : COLOR; // Color after vertex shader has executed
float3 normal : TEXCOORD0; // Vertex normal after vertex shader
float3 lightVec : TEXCOORD1; // The vector from the vertex
// in world space to the light source
float3 halfwayVec : TEXCOORD2;// The vector halfway between the "lightVec"
// and the vector from the vertex in world space to the eye
};
struct PSOut
{
float4 color : COLOR;
};
SuperPixelShader (PSin psIn)
{
float3 diffuse, specular;
PSOut psOut = (PSOut)0;
psIn.normal = normalize(psIn.normal);
psIn.lightVec = normalize(psIn.lightVec);
psIn.halfwayVec = normalize(psIn.halfwayVec);
specular = pow(max(dot(psIn.normal, psIn.halfwayVec), 0), 2) * cSpecular;
diffuse = max(dot(psIn.normal, psIn.lightVec), 0) * cDiffuse;
psOut.color.rgb = (diffuse * psIn.color.rgb) + (specular * psIn.color.rgb) + (cAmbient * psIn.color.rgb);
return psOut;
}
technique SuperlLighting
{
pass P0
{
// Set render states and declare vertex shader here
PixelShader = compile ps_2_0 SuperPixelShader; // Use pixel shader 2.0 -> v1.1 does not support max op
}
}
IMHO no one is writing vertex and pixel shaders in different languages (am I wrong here ) to avoid some nasty conjugation problem. I wonder what does the vertex shader look like