Skip to content

Instantly share code, notes, and snippets.

@cenullum
Last active April 7, 2020 16:56
Show Gist options
  • Save cenullum/0972fb6cd5b7973165668712f7de78eb to your computer and use it in GitHub Desktop.
Save cenullum/0972fb6cd5b7973165668712f7de78eb to your computer and use it in GitHub Desktop.
Rectangle Hole Godot Engine Shader
shader_type canvas_item;
uniform vec2 size;
uniform vec2 scale;
uniform vec2 position;
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));
vec2 result = vec2(uv.x * s.x - p.x, uv.y * s.y - p.y);
if (result.x>=1.0 ||result.x<=0.0||result.y<=0.0||result.y>=1.0){
result.x=0.0;
}
return result;
}
void fragment() {
vec4 base = texture(TEXTURE, UV).rgba;
vec2 result_uv =uv(UV);
if(result_uv.x!=0.0){
base.a = 0.0;
}
COLOR = base;
}
@cenullum
Copy link
Author

cenullum commented Apr 6, 2020

bjhbjhb
uhıugyuyguyg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment