Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save martinlaxenaire/90f1edabc0c92fe92b26d6bc9fb192a6 to your computer and use it in GitHub Desktop.
Save martinlaxenaire/90f1edabc0c92fe92b26d6bc9fb192a6 to your computer and use it in GitHub Desktop.
Mixing two vec4 textures based on alpha in GLSL
// mix foreground and background based on foreground alpha value
vec4 finalColor;
finalColor.rgb = foreground.rgb + (background.rgb * (1.0 - foreground.a));
finalColor.a = foreground.a + (background.a * (1.0 - foreground.a));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment