Compute gradients in Oklab color space#2055
Conversation
|
I added a small example to experiment with the outcome. What I also noticed is that the stop order is somewhat confusing because the first stop at 0.0 does not denote the left but the right side. Not sure if that is intentional or a bug … |
It depends on the specified angle. |
18a78ed to
e3c16df
Compare
There was a problem hiding this comment.
We need to enable OkLab gradients only if the web-colors feature is enabled.
This can be checked at compile-time with the GAMMA_CORRECTION constant. If it's true, the new OkLab shader should be used. If it's false, the current shader should be used instead.
|
Let me give that a shot. |
hecrj
left a comment
There was a problem hiding this comment.
I have split the shader code and used a bit of macro magic to conditionally reassemble it based on the color::GAMMA_CORRECTION value.
I have also simplified the example a bit!
Hopefully I didn't break anything. Give it a test, let me know, and we can merge this!
13163de to
f83fb9b
Compare
|
LGTM, tested on MacOS (m1) & windows 10, no issues. |
Also from my side, thanks for picking it up. Since you also do the phase shift by pi to have start on the left side, do you consider it … weird as well? |
An angle of 0 radians will "point" to the top-center of a `Rectangle` and then increase clockwise.
|
@matze You are right. In the web, it seems an angle of 0 "points up". @bungoboingo I have fine-tuned/simplified the |
|
@bungoboingo Makes sense! We have to keep in mind that the Y axis is inverted in I think the angle defining the |

This is the simple port of https://www.shadertoy.com/view/ttcyRS to compute quad gradients in Oklab as discussed in #2043. I have very little experience with iced internals nor wgsl in general, so don't hesitate to redo as you see fit.