godotengine / godotengine/godot
Tearing when using UV to access an array of sampler2d's
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
Reproducible in: 4.3stable and 4.4dev3
### System information
Godot v4.3.stable - Windows 10.0.26100 - Vulkan (Forward+) - dedicated AMD Radeon RX 6600 (Advanced Micro Devices, Inc.; 32.0.12011.1036) - 12th Gen Intel(R) Core(TM) i3-12100F (8 Threads)
### Issue description
I wrote a short shader to have a mesh sample one image when UV.x < 0.5, and another image otherwise.
Here it is:
```
shader_type spatial;
uniform sampler2D[2] images : source_color;
void fragment() {
ALBEDO = texture(images[int(step(0.5, UV.x))], UV).rgb;
}
```
But when you put it on a mesh and fill the array with two different images it looks something like this:

I expected a clean line in the middle separating the two images, like this:

The code for the above:
```
shader_type spatial;
uniform sampler2D[2] images : source_color;
vec3 get_color(int index, vec2 uv) {
if(index == 1) {
return texture(images[1], uv).rgb;
}
return texture(images[0], uv).rgb;
}
void fragment() {
ALBEDO = get_color(int(step(0.5, UV.x)), UV);
}
```
### Steps to reproduce
After you open the MRP, the issue should be visible immediately.
### Minimal reproduction project (MRP)
[MRP_bug.zip](https://github.com/user-attachments/files/17430209/MRP_bug.zip)
Contributor guide
Research direction
Open MRP_bug.zip and reproduce the artifact using the first shader with the sampler2d array, then compare it with the helper-function shader shown in the report. Confirm the behavior on the reported Godot versions and Vulkan setup; done means the two images meet at a clean line without tearing.
Written by the indexing model from the issue text.
Assessment
- 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