Last active
April 6, 2020 17:00
-
-
Save jimmyjonezz/7617162f38dd495f3ee6f73780f4d6db to your computer and use it in GitHub Desktop.
Alpha mask on shader for Godot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
shader_type canvas_item; | |
uniform sampler2D base_mask: texture; | |
uniform vec2 size; | |
uniform vec2 scale; | |
uniform vec2 position; | |
uniform vec2 region; | |
vec2 uv(vec2 uv) { | |
vec2 s = vec2(size.x / scale.x, size.x / scale.y); | |
vec2 p = vec2(position.x / (size.x / s.x), position.y / (size.y / s.y)); | |
return vec2(uv.x * s.x - p.x, uv.y * s.y - p.y); | |
} | |
void fragment() { | |
vec4 base = texture(TEXTURE, UV).rgba; | |
base.a = texture(base_mask, uv(UV)).a; | |
COLOR = base; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is not my code. I only collect.