How can I create a Canvas Clipping Region?

I was wondering if there is some neat trick I’m missing to make a Canvas have a clipping region?

Basically this means I can set a region on the canvas, when something is drawn outside this region, it is clipped appropriately. I looked at SetClip but that only allows you to set a max width and height, not an X/Y position, and generally produces weird results (even when I Flush between different clip sizes).

Is using multiple RenderTargets really the only other way? Or is there something even more low-level than Canvas I can utilize to render textures, which does support clipping appropriately?

For a scenario: I’ve drawn a 100x25 texture on the Canvas on position (10,10), this is supposed to be a button. I then draw text on top of it using a generated bitmap font. The goal is then to set the Clipping Region to (10,10,100,125), and anything drawn (partially) outside those bounds isn’t rendered.

I looked into this awhile back. As far as I can tell, there is no way to clip the canvas right now. It looks like there was some left over functionality of this feature in FCanvas::PushMaskRegion/PopMaskRegion, but they are not exposed as part of the engine API and if you examine the source code it looks like the back end logic isn’t hooked up.

In the mean time, you can clip textures by playing around with the U, V, UL, VL parameters passed into DrawTexture. Thats how I worked around it. Unfortunately, this won’t work for clipping texture.

It would be great actually if someone on the Unreal team can weigh in on this. Hope that helps.

I mean that my work around won’t work for clipping text, not texture.

Yea, luckily I’m using a bitmap font renderer, so all characters are essentially DrawTexture calls. Canvas clipping would be ideal, but is also sort of lazy, as messing with UV’s is a perfectly fine solution.

Over one year later and still no solution for this? Just commenting to remove the resolved-status… because this is by no means resolved.

Bump on this - would be really nice. My UI is non Slate and I need to clip F/UCanvas rendered text too!