2014-12-04 18:20:16 -05:00
|
|
|
// Blinn Phong with emulated fresnel factor
|
|
|
|
vec3 SpecularBRDF(vec3 normal, vec3 eyedir, vec3 lightdir, vec3 color, float roughness)
|
2014-04-06 17:57:54 -04:00
|
|
|
{
|
2014-12-04 18:09:15 -05:00
|
|
|
float exponentroughness = exp2(10. * roughness + 1.);
|
2014-04-06 17:57:54 -04:00
|
|
|
// Half Light View direction
|
|
|
|
vec3 H = normalize(eyedir + lightdir);
|
2014-12-05 11:48:56 -05:00
|
|
|
float NdotH = clamp(dot(normal, H), 0., 1.);
|
2014-12-04 18:09:15 -05:00
|
|
|
float normalisationFactor = (exponentroughness + 2.) / 8.;
|
2014-12-05 11:48:56 -05:00
|
|
|
vec3 FresnelSchlick = color + (1.0f - color) * pow(1.0f - clamp(dot(eyedir, H), 0., 1.), 5);
|
2014-12-04 18:09:15 -05:00
|
|
|
return max(pow(NdotH, exponentroughness) * FresnelSchlick * normalisationFactor, vec3(0.));
|
2014-04-06 17:57:54 -04:00
|
|
|
}
|