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.