godotengine / godotengine/godot

Calling `VisualServer.canvas_item_add_clip_ignore()` does not ignore clipping on `CanvasItem`s

Open
#97,012 1 comment 0 reactions 0 assignees View on GitHub
bug documentation topic:2d topic:rendering
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

- Reproducible in 3.5.stable, 4.2.2.stable

### System information

Windows 10

### Issue description

The documentation for `VisualServer.canvas_item_add_clip_ignore()` states that it will cause the given `CanvasItem` to not be clipped by the VisualServer. The 4.x equivalent of `RenderingServer.canvas_item_add_clip_ignore()` even states that this only needs to be called once to cause it to ignore clipping completely.

However, when calling/setting this in any CanvasItem that is being clipped with `rect_clip_content = true`/`clip_contents = true` or with
```
# 3.5
VisualServer.canvas_item_set_custom_rect(get_canvas_item(), true, cliprect)
VisualServer.canvas_item_set_clip(get_canvas_item(), true)

# 4.x
RenderingServer.canvas_item_set_custom_rect(get_canvas_item(), true, cliprect)
RenderingServer.canvas_item_set_clip(get_canvas_item(), true)
```

this has no effect at all. The CanvasItem is still completely or partially clipped when it extends the bounds of a parent that is clipping it's content.

Below is the MRP in action. The red outlines are a visual representation of the `Rect2()`s that are being used to clip the content.

**3.5**
![canvas_item_add_rect_ignore_3](https://github.com/user-attachments/assets/eaadc722-63a0-4db3-b93e-85da4178bb3f)

**4.x**
![canvas_item_add_rect_ignore_4](https://github.com/user-attachments/assets/86d8dc69-b788-4b5a-b395-07a158c091f7)

In both examples the `PanelContainer` with the `Label` that reads **Ignores Clipping** has a script with the following:

```

func _ready() -> void:
VisualServer.canvas_item_add_clip_ignore(get_canvas_item(), true)

func _draw():
VisualServer.canvas_item_add_clip_ignore(get_canvas_item(), true)
```

But despite that the PanelContainer and the label are still invisible when outside of the given rect. Seeing as the PanelContainer with the script behaves the exact same as the PanelContainers without the `canvas_item_add_clip_ignore()` call, it seems the `add_clip_ignore()` doesn't work, or potentially works completely differently than it's documentation indicates.

I really thought I must have misunderstood how this function works, but after multiple hours of attempting different setups, the only reasonable explanation is that it doesn't have any effect and might be bugged.

### Steps to reproduce

1. Start the MRP
2. _(Optional) Drag the window to cause the nodes to call `_draw()`_
3. _(Optional) The `_draw()` call will cause the custom rect to update_
4. The PanelContainer with the text `Ignores Clipping` will be clipped when it is outside of the visiblity rect of the main `Control` node that has `rect_clip_content` enabled or has the custom_rect script, even though it calls `canvas_item_add_clip_ignore()` on itself.

### Minimal reproduction project (MRP)

[ClipIgnore3.x.zip](https://github.com/user-attachments/files/17003530/ClipIgnore3.x.zip)
[ClipIgnore4.x.zip](https://github.com/user-attachments/files/17003509/ClipIgnore4.x.zip)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.