godotengine / godotengine/godot
[C#] `uniform vec4 : source_color` cannot be `SetShaderParam()`'d with type `Vector4`. Vice versa, non-`source_color` can't be set with `Color`.
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
- Reproducible in 4.2.2 latest stable release (tested with mono).
### System information
Godot v4.2.2.stable.mono - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1080 (NVIDIA; 31.0.15.5176) - Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz (8 Threads)
### Issue description
Essentially as the title says. Godot's shading language has a vec4 type to represent a tuple of 4 floats. One would expect that this could be set by all the Godot types outlined in the docs, regardless of any hint_x decorators. I need to be able to set all vec4 shader parameters with one Godot type, the documentation implies that this should be possible. I am using C#, so I am not sure if this issue is just with C# or also gdscript.
### Steps to reproduce
1. Write a simple shader with some vec4 uniforms, one hinted as a colour.
```glsl
shader_type spatial;
uniform vec4 ColorHinted : source_color = vec4(1.0);
uniform vec4 ColorNotHinted = vec4(1.0);
// if you need to verify that values are/aren't being set
void fragment()
{
ALBEDO = ColorHinted.rgb;
//ALBEDO = ColorNotHinted.rgb;
}
```
2. Create a shader material and assign it the shader.
3. Access the shader material in code and try to set parameters.
```csharp
var colorValue = new Color(1.0f, 0.5f, 0.2f, 0.8f);
var vec4Value = new Vector4(0.5f, 0.7f, 0.6f, 0.2f);
// Doesn't work
material.SetShaderParameter("ColorHinted", vec4Value);
// Doesn't work
material.SetShaderParameter("ColorNotHinted", colorValue);
// Works
material.SetShaderParameter("ColorHinted", colorValue);
// Works
material.SetShaderParameter("ColorNotHinted", vec4Value);
```
### Minimal reproduction project (MRP)
N/A
Contributor guide
Assessment
This issue has not been assessed yet.