Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to get color data from an array of source_color type in shader. #76157

Closed
SneaK1ng opened this issue Apr 17, 2023 · 5 comments · Fixed by #74937
Closed

Unable to get color data from an array of source_color type in shader. #76157

SneaK1ng opened this issue Apr 17, 2023 · 5 comments · Fixed by #74937

Comments

@SneaK1ng
Copy link

SneaK1ng commented Apr 17, 2023

Godot version

v4.1.dev.custom_build.a7276f1ce

System information

Win10, AMD 2600, GeForce GTX 1060, Vulkan API 1.3.205

Issue description

I can't get correct color data from an array of source_color type.
The color data is saved as Color in the file:
shader_parameter/palette = [Color (1, 0, 0, 1), Color (0, 1, 0, 1), Color (0, 0, 1, 1)]
Shouldn't it be saved as PackedColorArray?

Steps to reproduce

1.Declare an array of source_color type.
2.Set colors.

Minimal reproduction project

shadertest.zip

@SneaK1ng
Copy link
Author

May be related to #76135

@clayjohn
Copy link
Member

Yes, looks like a duplicate of #76135 which will be fixed by #74937

@bitsawer
Copy link
Member

bitsawer commented Apr 17, 2023

Not completely fixed by #74937. That PR will fix some conversions, but the problem here seems to be that the serialized shader_parameter/palette does not have the correct type, it loses it somewhere during the saving process. Manually editing the

shader_parameter/palette = [Color (1, 0, 0, 1), Color (0, 1, 0, 1), Color (0, 0, 1, 1)]

into

shader_parameter/palette = PackedColorArray(1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1)

fixes things temporarily until next scene save. I checked with a debugger and the type is correct most of the way (PACKED_COLOR_ARRAY), but in the end it is serialized and then loaded as generic Variant::Type::ARRAY containing variant Color objects (which is not the same as PACKED_COLOR_ARRAY), which will not convert properly into a vec4 uniform field (due to Variant conversion rules).

I'll dig in some more and comment later.

@bitsawer
Copy link
Member

Updated #74937 to fully fix this issue, at least for now.

@Calinou
Copy link
Member

Calinou commented Apr 17, 2023

@Calinou Calinou closed this as not planned Won't fix, can't repro, duplicate, stale Apr 17, 2023
@AThousandShips AThousandShips added this to the 4.1 milestone Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants