godotengine / godotengine/godot
ViewportTexture shader parameter breaks after project reload
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
- Reproducible in v4.3.stable, v4.4.1.stable and v4.5.beta2
### System information
Godot v4.5.beta2 - Linux Mint 22.1 (Xia) on X11 - X11 display driver, Multi-window, 2 monitors - Vulkan (Forward+) - dedicated AMD Radeon RX 6800 XT (RADV NAVI21) - AMD Ryzen 5 3600 6-Core Processor (12 threads) - 31.28 GiB memory
### Issue description
Using a ViewportTexture as a shader parameter works until you reload the project, at which point it seems to be replaced with the broken purple pattern texture.
Working as intended:
After reload:
### Steps to reproduce
1. Create a SubViewport and put a Camera3D inside.
2. Create a quad MeshInstance3D and give it a new shader material with "Local to Scene" checked.
3. Add a shader script:
```
shader_type spatial;
uniform sampler2D ScreenTexture;
void vertex() { }
void fragment() {
ALBEDO = texture(ScreenTexture, UV).rgb;
}
```
4. Set the Screen Texture shader parameter to a ViewportTexture, choose the SubViewport.
5. Reload the project.
### Minimal reproduction project (MRP)
[viewporttexturetest.zip](https://github.com/user-attachments/files/21061379/viewporttexturetest.zip)
To reproduce you'll first need to clear and replace the shader's texture parameter with a new ViewportTexture.
Contributor guide
Research direction
Open the attached viewporttexturetest.zip minimal reproduction project and follow the listed steps with a SubViewport, Camera3D, quad MeshInstance3D, and shader material. First reproduce the broken purple texture after reloading the project; done means the ViewportTexture shader parameter remains valid after reload.
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
- 38/100