aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--shaders/cook_torrance.frag9
1 files changed, 7 insertions, 2 deletions
diff --git a/shaders/cook_torrance.frag b/shaders/cook_torrance.frag
index c0c666c..f6c6048 100644
--- a/shaders/cook_torrance.frag
+++ b/shaders/cook_torrance.frag
@@ -152,8 +152,8 @@ vec3 cook_torrance_IBL(
152 vec3 albedo, float metallic, float roughness, float occlusion, 152 vec3 albedo, float metallic, float roughness, float occlusion,
153 float NdotV, 153 float NdotV,
154 vec3 irradiance, vec3 prefiltered_env, vec2 BRDF_env) { 154 vec3 irradiance, vec3 prefiltered_env, vec2 BRDF_env) {
155 vec3 F0 = mix(vec3(0.04), albedo, metallic); 155 vec3 F0 = mix(vec3(0.04), albedo, metallic); // albedo = F0 for metals
156 vec3 F = fresnel_schlick_roughness(F0, NdotV, roughness); 156 vec3 F = fresnel_schlick_roughness(F0, NdotV, roughness);
157 vec3 Kd = (vec3(1.0) - F) * (1.0 - metallic); 157 vec3 Kd = (vec3(1.0) - F) * (1.0 - metallic);
158 // A non-HDR environment map essentially has the 1/pi baked in as it does not 158 // A non-HDR environment map essentially has the 1/pi baked in as it does not
159 // use physical units. See: 159 // use physical units. See:
@@ -204,6 +204,11 @@ void main()
204 // to use all maps. 204 // to use all maps.
205 // https://sketchfab.com/models/b81008d513954189a063ff901f7abfe4 205 // https://sketchfab.com/models/b81008d513954189a063ff901f7abfe4
206#if HAS_NORMAL_MAP 206#if HAS_NORMAL_MAP
207 // Spec: "After dequantization, texel values MUST be mapped as follows:
208 // red [0.0 .. 1.0] to X [-1 .. 1],
209 // green [0.0 .. 1.0] to Y [-1 .. 1],
210 // blue (0.5 .. 1.0] to Z ( 0 .. 1].
211 // Normal textures SHOULD NOT contain blue values less than or equal to 0.5."
207 vec3 normalMapSample = texture(NormalMap, Texcoord).xyz * 2.0 - 1.0; 212 vec3 normalMapSample = texture(NormalMap, Texcoord).xyz * 2.0 - 1.0;
208 vec3 N = get_ws_normal(Normal, normalMapSample); 213 vec3 N = get_ws_normal(Normal, normalMapSample);
209#elif HAS_NORMALS 214#elif HAS_NORMALS