Skip to content

Instantly share code, notes, and snippets.

@SpineyPete
Created July 28, 2017 12:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SpineyPete/203d1b2e94000237168db3fe16e4a3f3 to your computer and use it in GitHub Desktop.
Save SpineyPete/203d1b2e94000237168db3fe16e4a3f3 to your computer and use it in GitHub Desktop.
Metallic BRDF
float PhongBase(vec3 viewdir, vec3 lightdir, vec3 normal) {
return max(-dot(viewdir, reflect(lightdir, normal)), 0.0);
}
// Analytic specular without ambient specular might look better like this.
float HalfPhongBase(vec3 viewdir, vec3 lightdir, vec3 normal) {
return -dot(viewdir, reflect(lightdir, normal)) / 2 + 0.5;
}
// Something to approximate the longer tail
// and tigher highlight of metalic surfaces.
float MetallicPow(float x, float pwr) {
pwr = (pwr * x) - (pwr + 1.0);
return (-x / pwr);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment