Fix Specular Blinn function
This commit is contained in:
parent
37b230fe3a
commit
334d41d7cc
@ -251,12 +251,10 @@ void light_compute(
|
|||||||
//normalized blinn always unless disabled
|
//normalized blinn always unless disabled
|
||||||
vec3 H = normalize(V + L);
|
vec3 H = normalize(V + L);
|
||||||
float cNdotH = max(dot(N, H), 0.0);
|
float cNdotH = max(dot(N, H), 0.0);
|
||||||
float cVdotH = max(dot(V, H), 0.0);
|
|
||||||
float cLdotH = max(dot(L, H), 0.0);
|
|
||||||
float shininess = exp2(15.0 * (1.0 - roughness) + 1.0) * 0.25;
|
float shininess = exp2(15.0 * (1.0 - roughness) + 1.0) * 0.25;
|
||||||
float blinn = pow(cNdotH, shininess);
|
float blinn = pow(cNdotH, shininess) * cNdotL;
|
||||||
blinn *= (shininess + 8.0) * (1.0 / (8.0 * M_PI));
|
blinn *= (shininess + 8.0) * (1.0 / (8.0 * M_PI));
|
||||||
specular_brdf_NL = (blinn) / max(4.0 * cNdotV * cNdotL, 0.75);
|
specular_brdf_NL = blinn;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SRGB_APPROX(specular_brdf_NL)
|
SRGB_APPROX(specular_brdf_NL)
|
||||||
@ -1270,9 +1268,9 @@ LIGHT_SHADER_CODE
|
|||||||
|
|
||||||
//normalized blinn
|
//normalized blinn
|
||||||
float shininess = exp2(15.0 * (1.0 - roughness) + 1.0) * 0.25;
|
float shininess = exp2(15.0 * (1.0 - roughness) + 1.0) * 0.25;
|
||||||
float blinn = pow(cNdotH, shininess);
|
float blinn = pow(cNdotH, shininess) * cNdotL;
|
||||||
blinn *= (shininess + 8.0) * (1.0 / (8.0 * M_PI));
|
blinn *= (shininess + 8.0) * (1.0 / (8.0 * M_PI));
|
||||||
specular_brdf_NL = (blinn) / max(4.0 * cNdotV * cNdotL, 0.75);
|
specular_brdf_NL = blinn;
|
||||||
|
|
||||||
#elif defined(SPECULAR_PHONG)
|
#elif defined(SPECULAR_PHONG)
|
||||||
|
|
||||||
@ -1547,7 +1545,7 @@ FRAGMENT_SHADER_CODE
|
|||||||
#endif // !USE_SHADOW_TO_OPACITY
|
#endif // !USE_SHADOW_TO_OPACITY
|
||||||
|
|
||||||
#ifdef BASE_PASS
|
#ifdef BASE_PASS
|
||||||
{
|
|
||||||
// IBL precalculations
|
// IBL precalculations
|
||||||
float ndotv = clamp(dot(normal, eye_position), 0.0, 1.0);
|
float ndotv = clamp(dot(normal, eye_position), 0.0, 1.0);
|
||||||
vec3 f0 = F0(metallic, specular, albedo);
|
vec3 f0 = F0(metallic, specular, albedo);
|
||||||
@ -1697,7 +1695,7 @@ FRAGMENT_SHADER_CODE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
#endif //BASE PASS
|
#endif //BASE PASS
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -2052,17 +2050,6 @@ FRAGMENT_SHADER_CODE
|
|||||||
specular_light += specular_interp * specular_blob_intensity * light_att;
|
specular_light += specular_interp * specular_blob_intensity * light_att;
|
||||||
diffuse_light += diffuse_interp * albedo * light_att;
|
diffuse_light += diffuse_interp * albedo * light_att;
|
||||||
|
|
||||||
// Same as above, needed for VERTEX_LIGHTING or else lights are too bright
|
|
||||||
const vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022);
|
|
||||||
const vec4 c1 = vec4(1.0, 0.0425, 1.04, -0.04);
|
|
||||||
vec4 r = roughness * c0 + c1;
|
|
||||||
float ndotv = clamp(dot(normal, eye_position), 0.0, 1.0);
|
|
||||||
float a004 = min(r.x * r.x, exp2(-9.28 * ndotv)) * r.x + r.y;
|
|
||||||
vec2 env = vec2(-1.04, 1.04) * a004 + r.zw;
|
|
||||||
|
|
||||||
vec3 f0 = F0(metallic, specular, albedo);
|
|
||||||
specular_light *= env.x * f0 + env.y;
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
//fragment lighting
|
//fragment lighting
|
||||||
light_compute(
|
light_compute(
|
||||||
|
@ -213,12 +213,10 @@ void light_compute(vec3 N, vec3 L, vec3 V, vec3 light_color, float roughness, in
|
|||||||
//normalized blinn always unless disabled
|
//normalized blinn always unless disabled
|
||||||
vec3 H = normalize(V + L);
|
vec3 H = normalize(V + L);
|
||||||
float cNdotH = max(dot(N, H), 0.0);
|
float cNdotH = max(dot(N, H), 0.0);
|
||||||
float cVdotH = max(dot(V, H), 0.0);
|
|
||||||
float cLdotH = max(dot(L, H), 0.0);
|
|
||||||
float shininess = exp2(15.0 * (1.0 - roughness) + 1.0) * 0.25;
|
float shininess = exp2(15.0 * (1.0 - roughness) + 1.0) * 0.25;
|
||||||
float blinn = pow(cNdotH, shininess);
|
float blinn = pow(cNdotH, shininess) * cNdotL;
|
||||||
blinn *= (shininess + 8.0) * (1.0 / (8.0 * M_PI));
|
blinn *= (shininess + 8.0) * (1.0 / (8.0 * M_PI));
|
||||||
specular_brdf_NL = (blinn) / max(4.0 * cNdotV * cNdotL, 0.75);
|
specular_brdf_NL = blinn;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
specular += specular_brdf_NL * light_color * (1.0 / M_PI);
|
specular += specular_brdf_NL * light_color * (1.0 / M_PI);
|
||||||
@ -1094,9 +1092,9 @@ LIGHT_SHADER_CODE
|
|||||||
|
|
||||||
//normalized blinn
|
//normalized blinn
|
||||||
float shininess = exp2(15.0 * (1.0 - roughness) + 1.0) * 0.25;
|
float shininess = exp2(15.0 * (1.0 - roughness) + 1.0) * 0.25;
|
||||||
float blinn = pow(cNdotH, shininess);
|
float blinn = pow(cNdotH, shininess) * cNdotL;
|
||||||
blinn *= (shininess + 8.0) * (1.0 / (8.0 * M_PI));
|
blinn *= (shininess + 8.0) * (1.0 / (8.0 * M_PI));
|
||||||
float intensity = (blinn) / max(4.0 * cNdotV * cNdotL, 0.75);
|
float intensity = blinn;
|
||||||
|
|
||||||
specular_light += light_color * intensity * specular_blob_intensity * attenuation;
|
specular_light += light_color * intensity * specular_blob_intensity * attenuation;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user