Cook-Torrance problem

Started by
1 comment, last by TP. 12 years, 9 months ago
I searched threw loads of topics on the internet, but most implementations differ in details and as I am not an experienced shader programmer, I didn't find anything which helped me. In my search I did found the problem, but just not the solution. The problem is that the 'specular' part is very small (<0.01, and if I multiple it wilt 20.000.000, it shows something which looks somewhere near what I want), so I assume I somewhere need to switch something, or did a minimum or maximum wrong, but I don't know where... My code:

float4 CookPictureShader(VertexShaderOutput input) : COLOR0
{
float3 L = input.L;
float3 N = input.N;
float3 E = input.E;
float D = Roughness;
float F = R0;
float3 H = normalize(normalize(E)+L);
float HN = max(0.0000001f, dot(H,N));
float EN = max(0.0000001f, dot(E,N));
float LN = max(0.0000001f, dot(L,N));
float EH = max(0.0000001f, dot(E,H));
float G = min(1,min((2*HN*EN)/EH,(2*HN*LN)/EH));

float Specular = pow((D*F*G)/EN,SpecularPower);

return saturate(AmbientColor*AmbientIntensity + DiffuseColor*max(0,dot(N, L)) + SpecularColor*Specular);
}


Could anybody give me a hint? :)
Advertisement
Do you by any change have to do this for a school assignment?..
GBS

Do you by any change have to do this for a school assignment?..


Yes, and even the one you'll going to check. That is exactly why I only asked for a hint - it is altogether my responsibility to finish it, and my assignment. But I already solved it myself mysteriously :)

This topic is closed to new replies.

Advertisement