godotengine / godotengine/godot
SubViewport: Clip Only children does not render transparency correctly
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
- Reproducible in: 4.0 stable until 4.7.2.stable [ed1daf0bf].
### System information
Godot v4.7.2.stable.mono - Windows 11 (build 26200) - Multi-window, 4 monitors - OpenGL 3 (Compatibility) - NVIDIA GeForce RTX 4060 (NVIDIA; 32.0.15.9649) - AMD Ryzen 5 3600 6-Core Processor (12 threads) - 31.93 GiB memory - WASAPI (48000 Hz, Stereo/mono)
### Issue description
Children nodes of a transparent `SubViewport` that has `clip_children` set to `ClipChildrenMode.CLIP_CHILDREN_ONLY` will have their rendered color set to black, but still respects alpha, instead of being completely transparent.
This does not happen when the clipping node does not have any children.
The Bug:
Expected:
### Steps to reproduce
1. Add a `SubViewportContainer` to the scene
2. Add a `SubViewport` to the container as a child to `SubViewportContainer`
3. Set `SubViewport`'s `transparent` property ON.
4. Add any node that renders as a child to the `SubViewport` (`Panel`, `TextureRect`, `Sprite2D`, etc.)
5. Add any texture to the node in Step 4 if necessary, otherwise skip.
6. Set Step 4 node's `clip_children` property to "Clip Only" (`ClipChildrenMode.CLIP_CHILDREN_ONLY`)
7. Add any node that renders as child to the Step 4 node
8. Add any texture to the node in Step 7 if necessary
Instead of it clipping properly, the entire clipping object will tint black instead of being transparent as intended.
### Minimal reproduction project (MRP)
[subview-clip-bug.zip](https://github.com/user-attachments/files/31422837/subview-clip-bug.zip)
Note: not contained in folder. Extract inside a folder.
Contributor guide
Research direction
Start by extracting and running the linked minimal reproduction project, then reproduce the issue with a transparent SubViewport and ClipChildrenMode.CLIP_CHILDREN_ONLY. Trace the SubViewport and child clipping render path, and verify that clipped children become transparent rather than black while preserving the expected rendering behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100