godotengine / godotengine/godot

`CanvasGroup` does not include the full extents of any control nodes drawing outside their rect

Open
#112,758 0 comments 0 reactions 0 assignees View on GitHub
bug confirmed topic:2d topic:rendering
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

Reproducible in:
- v4.6.dev [bd2ca13c6] (master)
- v4.5.stable.official [876b29033]

### System information

Godot v4.6.dev (bd2ca13c6) - Nobara Linux 42 (KDE Plasma Desktop Edition) on Wayland - X11 display driver, Multi-window, 1 monitor - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3070 (nvidia; 580.105.08) - AMD Ryzen 9 5900X 12-Core Processor (24 threads) - 31.25 GiB memory

### Issue description

When putting a Control node that draws outside its bounds - be it through `_draw()` or otherwise, such as a panel's stylebox utilizing skew or expand margins - under a CanvasGroup node, not all of the control node's drawn visuals will be included.

This can be seen by increasing the CanvasGroup's fit margin.

https://github.com/user-attachments/assets/1d0f77a7-5492-4736-a5ca-e2205bbb20e1

### Steps to reproduce

1. Download and open the MRP.
2. Increase the fit margin of the CanvasGroup root node in the scene.
3. Observe that more of the control's custom `draw_rect()` call is now visible.

### Minimal reproduction project (MRP)

[canvas-group-control-draw.zip](https://github.com/user-attachments/files/23546442/canvas-group-control-draw.zip)

Contributor guide

Open the contributing guide

Research direction

Start with the attached minimal reproduction project, focusing on the CanvasGroup root, its fit margin, and the Control node's custom draw_rect() output. Reproduce the clipping with the fit margin unchanged, then verify that the full visuals drawn outside the Control rect are included without requiring an increased fit margin.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
computer-graphics, game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.