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

fix light calc with backlight #178

Merged
merged 1 commit into from
Apr 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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