Created
August 25, 2020 04:00
-
-
Save jessevanherk/9e15da67ae4a8b4d64424702d9695be4 to your computer and use it in GitHub Desktop.
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; | |
// this is a simple godot shader to clip (or crop or mask) a sprite to a smaller area | |
// pass in 4 values representing the left, right, top, bottom extents to clip to. | |
// they should be values between 0 and 1 because we're working with an UV texture. | |
uniform float left_clip = 0.0; | |
uniform float right_clip = 1.0; | |
uniform float top_clip = 0.0; | |
uniform float bottom_clip = 1.0; | |
void fragment() { | |
if(UV.x > right_clip) { | |
discard; | |
} | |
if(UV.x <= left_clip) { | |
discard; | |
} | |
if(UV.y > bottom_clip) { | |
discard; | |
} | |
if(UV.y <= top_clip) { | |
discard; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment