Skip to content

Instantly share code, notes, and snippets.

@SpineyPete
SpineyPete / phong_metal.glsl
Created July 28, 2017 12:13
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
@SpineyPete
SpineyPete / colorspaces.glsl
Last active June 9, 2017 13:57
Colorspace Conversions
#version 330
// Colorspace conversions, I haven't checked the validity of this stuff.
// Some of them cause discolorations when transformed to and back so I'm
// probably doing wrong things that I don't understand -- Caveat emptor.
// CIELab XYZ
// ----------
// Matrices borrowed from Fundamentals Of Computer Graphics (3rd edition).