Hi Matt,
I use the blinn-phong algorithm that uses a halfway vector between the view and light directions.
Here is the code:
Code:
float4 BumpSpec_PS( in float2 InTexN : TEXCOORD0,
in float3 InHalfVec : TEXCOORD1,
in float InShadow : TEXCOORD2) : COLOR
{
float3 BumpNormal = 2 * tex2D(NormalMapSampler, InTexN.xy) - 1.0;
// Normalize halfway vector with cubemap:
// InHalfVec = 2 * texCUBE(NormalizationCubeMapSampler,2 * InHalfVec.xyz - 1) - 1; // doesn't work..
// Ordinary normalize:
InHalfVec = normalize(2 * InHalfVec - 1); // Works only in ps_2_0
// Calculate specular:
float Specular = pow(saturate(dot(BumpNormal, InHalfVec)), SpecPower);
// For debugging you can output the would-be normalized half vector:
// return float4(normalize(2 * InHalfVec - 1).xyz, 1); // How it should look
// return 2 * texCUBE(NormalizationCubeMapSampler, 2 * InHalfVec - 1) - 1; // How it looks with cubemap normalization.
return Specular.xxxx * InShadow * SpecularCoef;
}
Thanks for lookin into it. I could also post the whole shader, or even a demo implementation, if you can't find the error this way and you have the time to look at it..
I want my game to support ps_1_1 hardware and I'd like to enable normalmapping for the first LOD on those cards, so thats why I need ps_1_1 support.