-
Notifications
You must be signed in to change notification settings - Fork 497
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
Color in GLTF-File #804
Comments
Hey, color interpretation in Unity depends on the set color space in Unity, which slot that color is on, and potentially other factors. The data can end up being different to what is in the glTF file, because colors are always stored in srgb-linear in glTF, but not in Unity ("it depends"). However, the appearance should always be correct, since we're taking care of the appropriate conversions on both import and export. Do you have a file where you get a visual difference before/after import? If so, would be great if you could upload it here, and include Unity version, SRP version, Unity color space setting, and repro steps :) Thanks! |
Hey, I will try to explain the situation. I am loading a GLTF file at runtime in Unity in the browser. I have created an HTML, JavaScript, and CSS UI where you can select colors. To adjust the color from the input field, I get the color value directly from the material of the object in the GLTF file from its JSON to visualize exactly the color of the object in Unity. Therefore, I don’t want to communicate with Unity back and forth when I already have the color available in the JSON of the GLTF file. However, this value is not the same as in Unity. I realized that in Unity, the colors from the imported model are color-corrected, while in the GLTF file they are not. When I take the RGB values from the GLTF file, the color in Unity appears darker and does not match its import. Yes, I had already suspected that this is a problem with color correction itself. My thought was that there might be a calculation for color correction, or does Unity handle this on its own? My Unity version is 2022.2.1f1, and I am using the built-in render pipeline. Cheers, |
@MarcusGT076 can this issue be closed? Did my explanation above help? |
Hey there, yes thank you for your detailed answer :) At least it was possible to take the color from the GLTF-File itself and recalculate its colors. Thanks for youre help! |
Sounds good! The exact conversion depends on a number of factors, like which colorspace the monitor you're at is in, which colorspace your color picker is in, and so on. Also, pow(2.2) is an approximation; the exact math is a bit more involved: |
Hello together,
i have a problem with the colors on import. When i import a gltf file into unity i have a slight different color value as in the gltf file.
As example the red value in the baseColorValue in the gltf-file is : 0.7647669911384583,
in unity it has a color value on red channel in the material with : 0.8884587.
Where did the difference come from ? How are the colors are calculated in unity that i can reproduce the color value exact as it is in unity ?
I dont want to read out the color value from unity itself, because i want to take it from the .gltf file itself for visualize it in html.
Cheers,
Marcus
The text was updated successfully, but these errors were encountered: