Clip region shaders for GameMaker
A downloadable asset pack
Download NowName your own price
Quick links: related tutorial · GitHub repository
An example of implementing clipping for drawn graphics in GameMaker.
Download
Download NowName your own price
Click download now to get access to the following files:
draw_clip_gms1.gmz 16 kB
draw_clip_gms2.yyz 174 kB
Comments
Log in with itch.io to leave a comment.
Unfortunately as a beginner, I'm unable to get this working with 2.3+
I'd appreciate a refresher on this if you've got the time.
I've been trying to use gpu_set_blendmode, but can't get the shadow decal to clip on the object, and it's shading the background.
Added a separate GMS2 version.
Great example code.
When I imported into GMS2 and pressed play, the console was filled with this message:
```
Draw failed due to invalid input layout
```
The first example doesn’t clip as expected; it draws the outline for a rectangle and an outline for the circle but that’s it.
The problem occurs in obj_clip_rect_shd’s draw event, on line: draw_circle(mouse_x, mouse_y, mouse_r, false);
I expected it was an issue with the shader; when I comment out that draw_circle line, I don’t see the error anymore.
In rm_clip_rect_shd, I noticed a “Compatibility_Colour” layer is created with a depth of 2147483600, which I think is out of range in GameMaker Studio 2 so I set it to 999. This alone did not fix the problem.
I deleted the Compatibility_Instances_Depth_0 layer, create a new instance layer, and dragged obj_clip_rect_shd into it. Still did not remove the console message.
Finally, I edited shd_clip_rect and discovered that commenting out the line:
```
v_vTexcoord = in_TextureCoord;
```
resulted in no warning messages in the console and the shader worked.
I was just thinking how this could be used for blooming windows
What do you imagine this could be used for? :)
As the post mentions, it is most commonly used for UI elements, such as scrollable areas or minimaps.
There are numerous creative possibilities, however - e.g. "ibb & obb" uses clip regions heavily to achieve it's distinct art direction with parallax layers peeking through each other.