Skip to content

Instantly share code, notes, and snippets.

@MSGhero
Created September 25, 2024 03:46
Show Gist options
  • Save MSGhero/c090ab8ec822721eb46e9c7132806ee0 to your computer and use it in GitHub Desktop.
Save MSGhero/c090ab8ec822721eb46e9c7132806ee0 to your computer and use it in GitHub Desktop.
#ifdef GL_ES
precision mediump float;
#else
#define mediump
#endif
uniform sampler2D sheet; // spritesheet texture
uniform vec2 filterResolution; // size of filter
uniform vec2 sheetResolution; // native ACTUAL size of spritesheet
uniform vec2 maskXY; // xy of mask sprite
uniform sampler2D tex0;
varying vec2 tcoord;
varying vec4 color;
void main() {
vec4 texColor, maskColor;
texColor = texture2D(tex0, tcoord);
maskColor = texture2D(sheet, (tcoord * filterResolution + maskXY) / sheetResolution.x);
if (maskColor.a < 0.1) discard;
gl_FragColor = color * texColor;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment