I'm trying to create a ggx shader but when I run it at BRDF Explorer the main page remains white. I'm trying to find my error but I can't. Can anybody help me? below is my file
analytic
::begin parameters
float baseColor 0.001 .2 .1
float m 0.001 0.1 1.0
::end parameters
::begin shader
const float PI = 3.14;
vec3 BRDF( vec3 N, vec3 V, vec3 L, float m, float baseColor)
{
vec3 H = normalize(V+L);
float dotNL = clamp(dot(N,L), 0.0, 1.0);
float dotLH = clamp(dot(L,H), 0.0, 1.0);
float dotNH = clamp(dot(N,H), 0.0, 1.0);
float DotNH2 = dotNH * dotNH;
float m2 = m * m;
float D = m2 / (PI * pow(dotNH * dotNH * (m2 - 1) + 1, 2.0));
float Fresnel(float baseColor, float l, float h)
{
return baseColor + ( 1 - baseColor ) * pow( 1 - (dotNH), 5);
}
float F = Fresnel(baseColor, dotNH);
float ggx_visib(float dotNV, float m2)
{
return 1.0/(dotNV*(1.0-m2)+m2);
}
float g1i =ggx_visib(m, dotLH);
float g1o =ggx_visib(m, dotNV);
float G = g1i * g1o;
return D * G * F * (1.0 / (4.0 * dotNL * dotNV));
}
::end shader