SpecularBRDF.frag 576 B

123456789101112
  1. // Blinn Phong with emulated fresnel factor
  2. vec3 SpecularBRDF(vec3 normal, vec3 eyedir, vec3 lightdir, vec3 color, float roughness)
  3. {
  4. float exponentroughness = exp2(10. * roughness + 1.);
  5. // Half Light View direction
  6. vec3 H = normalize(eyedir + lightdir);
  7. float NdotH = clamp(dot(normal, H), 0., 1.);
  8. float normalisationFactor = (exponentroughness + 2.) / 8.;
  9. vec3 FresnelSchlick = color + (1.0f - color) * pow(1.0f - clamp(dot(eyedir, H), 0., 1.), 5.);
  10. return max(pow(NdotH, exponentroughness) * FresnelSchlick * normalisationFactor, vec3(0.));
  11. }