Skip to content

Instantly share code, notes, and snippets.

@michlimlim
Created November 18, 2021 16:52
Show Gist options
  • Select an option

  • Save michlimlim/1ec0f5c8746c35882c3add1e23e715c8 to your computer and use it in GitHub Desktop.

Select an option

Save michlimlim/1ec0f5c8746c35882c3add1e23e715c8 to your computer and use it in GitHub Desktop.
linear gradients
float4 derive_color(float2 pixel_pos, float2 start, float2 end, float4 start_color, float4 end_color) {
float2 adjusted_end = end - start;
float h = dot(pixel_pos - start, adjusted_end) / dot(adjusted_end, adjusted_end);
return mix(start_color, end_color, h);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment