Skip to content

Commit

Permalink
Remove unnecessary branch in trail shader
Browse files Browse the repository at this point in the history
Branches have an outsize penalty in shaders as does discard. We don't
need the check that the fragment is in the region anyway ans the
rendering pipeline takes care of that for us, I think. At least I can
see no visual difference with it removed.

@jinhwanlazy please review
  • Loading branch information
kovidgoyal committed Dec 11, 2024
1 parent 29040d7 commit 4b12bff
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions kitty/trail_fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,5 @@ in vec2 frag_pos;
out vec4 final_color;

void main() {
if (cursor_edge_x[0] <= frag_pos.x && frag_pos.x <= cursor_edge_x[1] &&
cursor_edge_y[1] <= frag_pos.y && frag_pos.y <= cursor_edge_y[0]) {
discard;
} else {
final_color = vec4(trail_color, trail_opacity);
}
final_color = vec4(trail_color, trail_opacity);
}

0 comments on commit 4b12bff

Please sign in to comment.