-
-
Notifications
You must be signed in to change notification settings - Fork 864
wgpu: Apply color transform on gradient records #12573
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
base: master
Are you sure you want to change the base?
Conversation
6c8b131
to
d753ba3
Compare
😭 |
d753ba3
to
2c257d4
Compare
I'm afraid not, because it seems like the color transform must be taken into account while processing the gradient records. Since color transforms are available only during rendering, this cannot be performed during shape registration. |
I think it is still possible to utilize the texture method by changing how the gradient info is stored in the texture, encoding the For example, start with a simple gradient with two colors: For a gradient with multiple colors, let's imagine: You can picture baking 0.0 -> 1.0 for each interval into the texture, along with the colors for that interval. So for example: texture(10, 0) will be 0.0, with texture(10, 1) being solid red (color0) and texture(10, 2) being solid green (color1). However, this will result in some artifacting due to interpolating at the discontinuity from the end of one interval to the next, jumping directly from 1.0 to 0.0. To fix this, instead of encoding the Given the above example, texture(157, 0) would be ~0.75, which is halfway between 0.5 and 1.0 (colors 1 and 2). The code is something like:
As a bonus we don't have to encode the color indices separately, and no loop or branching is required to figure out the interpolation value. My only concern was that if there is enough precision in the texture to accommodate packing an exotic 16-color gradient ratio into an 8-bit channel, but I think this would be okay because the Flash Here's an ancient branch I had with this: 85f9694#diff-e630f4f0acc4a6d61f1f3ec1b5aa6cb5798d3054326b71e29ded3da7450f24bc |
2bd32d2
to
caa9399
Compare
Implemented @Herschel's suggestion and all tests pass on my end. From some reason they fail in CI, and I'm not sure why. |
caa9399
to
10c952d
Compare
Applied some fixes, and slightly tuned some image tests to make them pass. @Dinnerbone Can you please take a look? |
10c952d
to
3d0649b
Compare
Similar to #12549, just for the wgpu renderer.
Note that some of #9821 is reverted for this purpose.