Skip to content

Commit

Permalink
(#55) Use mix for flashlight effect
Browse files Browse the repository at this point in the history
  • Loading branch information
rexim committed Nov 20, 2019
1 parent 0395345 commit 3648c27
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/frag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ const float FLASHLIGHT_RADIUS = 200.0;
void main()
{
vec4 cursor = vec4(cursorPos.x, windowSize.y - cursorPos.y, 0.0, 1.0);
if (length(cursor - gl_FragCoord) < FLASHLIGHT_RADIUS) {
color = texture(tex, texcoord);
} else {
color = texture(tex, texcoord) - vec4(flShadow, flShadow, flShadow, 0.0);
}
color = mix(
texture(tex, texcoord), vec4(0.0, 0.0, 0.0, 0.0),
length(cursor - gl_FragCoord) < FLASHLIGHT_RADIUS ? 0.0 : flShadow);
}

0 comments on commit 3648c27

Please sign in to comment.