Skip to content

Instantly share code, notes, and snippets.

@Polkm
Created June 14, 2015 22:55
Show Gist options
  • Save Polkm/eecab43d1e022c4763d8 to your computer and use it in GitHub Desktop.
Save Polkm/eecab43d1e022c4763d8 to your computer and use it in GitHub Desktop.
extern number testDepth;
extern Image depthMap;
vec4 effect(vec4 color, Image texture, vec2 tc, vec2 sc) {
sc = sc / vec2(1024, 512); // Size of my canvas
sc.y = 1 - sc.y; // Flip the y axis
vec4 d = Texel(depthMap, sc);
// If the sprite's depth is less than the static depth map then hide it
if (testDepth < d.r * 256 + d.g * 256 * 256) {
color.a = 0.2; // Make the sprite's pixel look like it's behind a wall
};
return color * Texel(texture, tc);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment