Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

AnswerHub Maintenance

Background maintenance is scheduled to occur between 9 - 11am EDT on Tuesday, May 21. Site operation may be slower than normal during this time and a brief interruption in operation may be observed

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.

Product Version: Not Selected
more ▼

asked Jun 08 '14 at 01:21 PM in C++ Programming

avatar image

235 17 19 22

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

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.

more ▼

answered Jun 09 '14 at 08:41 PM

avatar image

401 16 22 31

avatar image Clapfoot Jun 09 '14 at 08:42 PM

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

avatar image LennardF1989 Jun 09 '14 at 08:49 PM

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.

avatar image Pseudocorpus Oct 14 '15 at 07:30 PM

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

avatar image theonecalledtom Jul 11 '16 at 06:21 PM

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

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question