summaryrefslogtreecommitdiff
path: root/intermediate/surface.glsl
diff options
context:
space:
mode:
Diffstat (limited to 'intermediate/surface.glsl')
-rw-r--r--intermediate/surface.glsl14
1 files changed, 10 insertions, 4 deletions
diff --git a/intermediate/surface.glsl b/intermediate/surface.glsl
index 2d5d470..5feb09f 100644
--- a/intermediate/surface.glsl
+++ b/intermediate/surface.glsl
@@ -137,10 +137,10 @@ float specular_brdf(vec2 uv, vec3 l, vec3 v, vec3 n) {
float D =
a2 / (pi * b * b);
float G = specular_G1(a, l, n) * specular_G1(a, v, n);
- float F0 = G;
+ float F0 = 0.04;
float F = F0 + (1.0 - F0) *
pow(2, ((-5.55473 * ndr - 6.98316), ndr));
- return (D * F * G) / (4.0 * ndl * ndv);
+ return (D * F * G) / (4.0 * ndl * ndv + 0.001);
}
void main() {
@@ -159,15 +159,21 @@ void main() {
vec3 col = texture(albedo, uv).rgb * material.albedo;
float cos_theta_i = max(dot(nrm, light_dir), 0.0);
vec3 view_dir = normalize(material.camera_pos - p);
+ float met = texture(metal, uv).r * material.metalness;
vec3 diffuse =
diffuse_brdf(uv) *
+ (1.0 - met) *
cos_theta_i;
- float spec =
+ vec3 spec =
+ mix(1.0.xxx, col, met) *
specular_brdf(uv, light_dir, view_dir, nrm) *
cos_theta_i;
+ vec3 ambient =
+ min(col, 0.05) *
+ texture(ao, uv).r;
- colour = vec4(diffuse + vec3(spec), 1.0);
+ colour = vec4(ambient + diffuse + spec, 1.0);
}
#endif