I feel like my light conservation math isn't correct, but I am not sure which part is wrong.
Is reflected light supposed to influence the diffuse light?
Does metalness only affect the reflected light or does it also affect ambient and diffuse light?
vec4 falbedo; // surface color
vec3 fnormal; // surface normal
vec3 ambientLight;
vec3 directionToCamera; // Camera normal
vec3 directionToLight; // Directional light normal
vec3 lightColor; // Directional light color
float metalness; // 0-1
float shininess; // 1-256
float subsurface; // 0-1
// Diffuse light
float lightNormalDot = dot(fnormal, directionToLight);
float lightIntensity = max(.0, lightNormalDot);
// Blinn–Phong reflection
vec3 halfway = normalize(directionToCamera + directionToLight);
float reflectionFactor = max(.0, dot(halfway, fnormal));
float reflection = pow(reflectionFactor, shininess);
vec3 res = falbedo.rgb * ambientLight;
res += subsurface * lightIntensity * lightColor * falbedo.rgb;
res += (1. - subsurface) * reflection * mix(lightColor, lightColor * falbedo.rgb, metalness);
gl_FragColor = vec4(res, falbedo.a);