Skip to content

Commit

Permalink
Merge pull request #51411 from clayjohn/VULKAN-blinn-phong
Browse files Browse the repository at this point in the history
[4.0] Make Blinn and Phong specular modes take albedo into account
  • Loading branch information
akien-mga authored Aug 10, 2021
2 parents ac1dab5 + fa962ff commit afb4092
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,22 +208,20 @@ void light_compute(vec3 N, vec3 L, vec3 V, float A, vec3 light_color, float atte

//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 intensity = blinn;
float blinn = pow(cNdotH, shininess);
blinn *= (shininess + 2.0) * (1.0 / (8.0 * M_PI));

specular_light += light_color * intensity * attenuation * specular_amount;
specular_light += light_color * attenuation * specular_amount * blinn * albedo * unpackUnorm4x8(orms).w;

#elif defined(SPECULAR_PHONG)

vec3 R = normalize(-reflect(L, N));
float cRdotV = clamp(A + dot(R, V), 0.0, 1.0);
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));

specular_light += light_color * intensity * attenuation * specular_amount;
specular_light += light_color * attenuation * specular_amount * phong * albedo * unpackUnorm4x8(orms).w;

#elif defined(SPECULAR_TOON)

Expand Down

0 comments on commit afb4092

Please sign in to comment.