Rust has an Opacity Issue
Kulltero opened this issue · 0 comments
What?
Rust CUI Image's Opacity is Skewed in a major way, this makes it very difficult to work with for anything beyond a simple UI, i especially noticed this while working on the demo for the Animation Fork #41 and it took about half a day for me to figure out what it was (and wasnt), there also doesnt seem to be any actual workaround.
Examples
first here is a simple test case. the simplest way of demonstrating this is using white gradient going from alpha0 to alpha1
the bottom image is a rust CustomUI with a black opaque square as a background and a RawImage component. the top image is added in after taking a screenshot. both images are the same image, the only difference is the bottom one is rendered through rust CUI
Example 2
a moment of silence for the 8 hours i lost trying to debug and fix this issue
Left Image is Rust CUI, Right image is original
the left not only shows that low opacity is presented way more opaque than it should, it also shows artifacting on very low opacity < 0.1
the original image has no artifacting, even when zoomed in (source resolution is 512x512px)
the intention was to use this as a box shadow, but that isnt really possible with how it looks in rust
i thought it was faulty Gamma Correction
But it isnt. colors work fine even with proper opacity. a square with white color at 50% opacity looks the same in rust as in the original image, but as soon as we you use an image with the color white at 50% opacity it becomes skewed again
square 1 and 3 are the exact same image, though the differnce is a bit more subtle we can still see the image rendered through rust is brighter than it should be. this happnes with both RawImage and Image
i havent really found an exact cause for this, i was able to confirm that loading the image into a texture and then extracting it doesnt alter it, meaning its likely a fault in the individual shader that renders unity UGUI. there have been some posts about faulty transparency when switching from linear to gamma colorspace, but thats something i havent been able to confirm applies here
i'm aware that images loaded from the web can have quality issues, but i confirmed that this behaviour is identical with both images from the web and images loaded through the server, the screenshots were also made with the game set to the highest quality.