Merge pull request #51410 from clayjohn/GLES-blinn-phong

This commit is contained in:
Rémi Verschelde 2021-08-10 09:52:28 +02:00 committed by GitHub
commit 6518a61bd4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 20 deletions

View file

@ -275,13 +275,13 @@ void light_compute(
vec3 H = normalize(V + L);
float cNdotH = max(dot(N, H), 0.0);
float shininess = exp2(15.0 * (1.0 - roughness) + 1.0) * 0.25;
float blinn = pow(cNdotH, shininess) * cNdotL;
blinn *= (shininess + 8.0) * (1.0 / (8.0 * M_PI));
float blinn = pow(cNdotH, shininess);
blinn *= (shininess + 2.0) * (1.0 / (8.0 * M_PI));
specular_brdf_NL = blinn;
#endif
SRGB_APPROX(specular_brdf_NL)
specular_interp += specular_brdf_NL * light_color * attenuation * (1.0 / M_PI);
specular_interp += specular_brdf_NL * light_color * attenuation;
}
}
@ -1365,7 +1365,7 @@ LIGHT_SHADER_CODE
if (roughness > 0.0) {
#if defined(SPECULAR_SCHLICK_GGX)
#if defined(SPECULAR_SCHLICK_GGX) || defined(SPECULAR_BLINN) || defined(SPECULAR_PHONG)
vec3 specular_brdf_NL = vec3(0.0);
#else
float specular_brdf_NL = 0.0;
@ -1375,9 +1375,10 @@ LIGHT_SHADER_CODE
//normalized blinn
float shininess = exp2(15.0 * (1.0 - roughness) + 1.0) * 0.25;
float blinn = pow(cNdotH, shininess) * cNdotL;
blinn *= (shininess + 8.0) * (1.0 / (8.0 * M_PI));
specular_brdf_NL = blinn;
float blinn = pow(cNdotH, shininess);
blinn *= (shininess + 2.0) * (1.0 / (8.0 * M_PI));
specular_brdf_NL = blinn * diffuse_color * specular;
#elif defined(SPECULAR_PHONG)
@ -1385,8 +1386,9 @@ LIGHT_SHADER_CODE
float cRdotV = max(0.0, dot(R, V));
float shininess = exp2(15.0 * (1.0 - roughness) + 1.0) * 0.25;
float phong = pow(cRdotV, shininess);
phong *= (shininess + 8.0) * (1.0 / (8.0 * M_PI));
specular_brdf_NL = (phong) / max(4.0 * cNdotV * cNdotL, 0.75);
phong *= (shininess + 1.0) * (1.0 / (8.0 * M_PI));
specular_brdf_NL = phong * diffuse_color * specular;
#elif defined(SPECULAR_TOON)
@ -2170,8 +2172,7 @@ FRAGMENT_SHADER_CODE
#ifdef USE_VERTEX_LIGHTING
//vertex lighting
specular_light += specular_interp * specular_blob_intensity * light_att;
specular_light += specular_interp * albedo * specular * specular_blob_intensity * light_att;
diffuse_light += diffuse_interp * albedo * light_att;
#else

View file

@ -225,12 +225,12 @@ void light_compute(vec3 N, vec3 L, vec3 V, vec3 light_color, float roughness, in
vec3 H = normalize(V + L);
float cNdotH = max(dot(N, H), 0.0);
float shininess = exp2(15.0 * (1.0 - roughness) + 1.0) * 0.25;
float blinn = pow(cNdotH, shininess) * cNdotL;
blinn *= (shininess + 8.0) * (1.0 / (8.0 * M_PI));
float blinn = pow(cNdotH, shininess);
blinn *= (shininess + 2.0) * (1.0 / (8.0 * M_PI));
specular_brdf_NL = blinn;
#endif
specular += specular_brdf_NL * light_color * (1.0 / M_PI);
specular += specular_brdf_NL * light_color;
}
}
@ -1127,11 +1127,11 @@ LIGHT_SHADER_CODE
//normalized blinn
float shininess = exp2(15.0 * (1.0 - roughness) + 1.0) * 0.25;
float blinn = pow(cNdotH, shininess) * cNdotL;
blinn *= (shininess + 8.0) * (1.0 / (8.0 * M_PI));
float blinn = pow(cNdotH, shininess);
blinn *= (shininess + 2.0) * (1.0 / (8.0 * M_PI)); // Normalized NDF and Geometric term
float intensity = blinn;
specular_light += light_color * intensity * specular_blob_intensity * attenuation;
specular_light += light_color * intensity * specular_blob_intensity * attenuation * diffuse_color * specular;
#elif defined(SPECULAR_PHONG)
@ -1139,10 +1139,10 @@ LIGHT_SHADER_CODE
float cRdotV = max(0.0, dot(R, V));
float shininess = exp2(15.0 * (1.0 - roughness) + 1.0) * 0.25;
float phong = pow(cRdotV, shininess);
phong *= (shininess + 8.0) * (1.0 / (8.0 * M_PI));
float intensity = (phong) / max(4.0 * cNdotV * cNdotL, 0.75);
phong *= (shininess + 1.0) * (1.0 / (8.0 * M_PI)); // Normalized NDF and Geometric term
float intensity = phong;
specular_light += light_color * intensity * specular_blob_intensity * attenuation;
specular_light += light_color * intensity * specular_blob_intensity * attenuation * diffuse_color * specular;
#elif defined(SPECULAR_TOON)