3
\$\begingroup\$

I am trying to implement the Cook-Torrance model, and this is how I calculate the parameter Rs:

float Rs(float m,float F,vec3 N, vec3 L,vec3 V, vec3 H) { float result; float NdotV= dot(N,V); float NdotH= dot(N,H); float NdotL= dot(N,L); float VdotH= dot(V,H); float Geom= min(min(1.0, (2.0*NdotV*NdotH)/VdotH), (2.0*NdotL*NdotH)/VdotH); float Rough= pow(1.0/(pow(m,2.0)*pow(NdotH,4.0)), ( pow(NdotH,2.0)-1.0)/( pow(m,2.0)*pow(NdotH,2.0))); float Fresnel= F + pow(1.0-VdotH,5.0) * (1.0-F); return (Fresnel * Rough * Geom)/(NdotV*NdotL); } 

I apply this formula:

enter image description here

Where I set m to 0.5 and F0 to 2.0.

But I think it's wrong because I'm getting a black area where there should be the specular light:

enter image description here

PS: With OpenGL 2.1, GLSL 1.20.

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$
float Rough= pow(1.0/(pow(m,2.0)*pow(NdotH,4.0)), ( pow(NdotH,2.0)-1.0)/( pow(m,2.0)*pow(NdotH,2.0))); 

Does not correctly reflect the formula for the Roguhness term. It should be something like:

float Rough= (1.0/(pow(m,2.0)*pow(NdotH,4.0)) * exp ( pow(NdotH,2.0)-1.0)/( pow(m,2.0)*pow(NdotH,2.0))); 

that is, exp usually stands for e raised to the power x (e is the Euler number, the natural logarithm base, etc.)

\$\endgroup\$
0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.