Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
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
8 changes: 4 additions & 4 deletions impeller/entity/shaders/linear_gradient_fill.frag
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ in vec2 v_position;
out vec4 frag_color;

void main() {
float len = length(frag_info.end_point - frag_info.start_point);
float dot = dot(v_position - frag_info.start_point,
frag_info.end_point - frag_info.start_point);
float t = dot / (len * len);
vec2 start_to_end = frag_info.end_point - frag_info.start_point;
vec2 start_to_position = v_position - frag_info.start_point;
float t =
dot(start_to_position, start_to_end) / dot(start_to_end, start_to_end);
frag_color = IPSampleLinearWithTileMode(
texture_sampler, vec2(t, 0.5), frag_info.texture_sampler_y_coord_scale,
frag_info.half_texel, frag_info.tile_mode);
Expand Down
8 changes: 4 additions & 4 deletions impeller/entity/shaders/linear_gradient_ssbo_fill.frag
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ in vec2 v_position;
out vec4 frag_color;

void main() {
float len = length(frag_info.end_point - frag_info.start_point);
float dot = dot(v_position - frag_info.start_point,
frag_info.end_point - frag_info.start_point);
float t = dot / (len * len);
vec2 start_to_end = frag_info.end_point - frag_info.start_point;
vec2 start_to_position = v_position - frag_info.start_point;
float t =
dot(start_to_position, start_to_end) / dot(start_to_end, start_to_end);

if ((t < 0.0 || t > 1.0) && frag_info.tile_mode == kTileModeDecal) {
frag_color = vec4(0);
Expand Down