Created
October 13, 2023 16:30
-
-
Save gnysek/06f4dad247fad81b30dbbd31099fe593 to your computer and use it in GitHub Desktop.
rectangle clip/cut
This file contains hidden or 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
clip_x1 = 10; | |
clip_x2 = 500; | |
clip_y1 = 10; | |
clip_y2 = 100; | |
draw_set_color(c_white); | |
draw_set_alpha(1); | |
// set up shader: | |
shader_set(shd_clip_rect); | |
var u_bounds = shader_get_uniform(shd_clip_rect, "u_bounds"); | |
shader_set_uniform_f(u_bounds, clip_x1, clip_y1, clip_x2, clip_y2); | |
// draw things: | |
draw_text(mouse_x, mouse_y, "Lorem ipsum dolor sit amet\nLorem ipsum dolor sit amet\nLorem ipsum dolor sit amet\nLorem ipsum dolor sit amet"); | |
// finish: | |
shader_reset(); |
This file contains hidden or 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
varying vec2 v_vTexcoord; | |
varying vec4 v_vColour; | |
varying vec3 v_vPosition; | |
// | |
uniform vec4 u_bounds; | |
// | |
void main() { | |
vec4 col = v_vColour * texture2D(gm_BaseTexture, v_vTexcoord); | |
col.a *= float(v_vPosition.x >= u_bounds[0] && v_vPosition.y >= u_bounds[1] && v_vPosition.x < u_bounds[2] && v_vPosition.y < u_bounds[3]); | |
gl_FragColor = col; | |
} |
This file contains hidden or 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 VSH | |
// | |
attribute vec3 in_Position; | |
attribute vec4 in_Colour; | |
attribute vec2 in_TextureCoord; | |
// | |
varying vec4 v_vColour; | |
varying vec3 v_vPosition; | |
varying vec2 v_vTexcoord; | |
// | |
void main() { | |
v_vPosition = in_Position; | |
gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * vec4(in_Position.x, in_Position.y, in_Position.z, 1.0); | |
v_vColour = in_Colour; | |
v_vTexcoord = in_TextureCoord; | |
} | |
Author
gnysek
commented
Oct 13, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment