Skip to content
This repository has been archived by the owner on Jul 14, 2021. It is now read-only.

Commit

Permalink
Merge pull request #178 from ffreyer/lighting
Browse files Browse the repository at this point in the history
fix light calc with backlight
  • Loading branch information
SimonDanisch authored Apr 12, 2021
2 parents 2717d81 + f0f3568 commit d36b9ac
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion assets/shader/standard.frag
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ vec3 blinnphong(vec3 N, vec3 V, vec3 L, vec3 color){
float spec_coeff = pow(max(dot(H, N), 0.0), shininess);
if (diff_coeff <= 0.0 || isnan(spec_coeff))
spec_coeff = 0.0;

// final lighting model
return vec3(
ambient * color +
diffuse * diff_coeff * color +
specular * spec_coeff
);
Expand Down
4 changes: 2 additions & 2 deletions src/GLVisualize/visualize/surface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ function light_calc(x::Bool)
vec3 L = normalize(o_lightdir);
vec3 N = normalize(o_normal);
vec3 light1 = blinnphong(N, o_camdir, L, color.rgb);
color = vec4(light1, color.a) +
backlight * vec4(blinnphong(N, o_camdir, -L, color.rgb), color.a);
vec3 light2 = blinnphong(N, o_camdir, -L, color.rgb);
color = vec4(ambient * color.rgb + light1 + backlight * light2, color.a);
"""
else
""
Expand Down

0 comments on commit d36b9ac

Please # to comment.