-
-
Notifications
You must be signed in to change notification settings - Fork 397
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
Shader-based gradients #677
Conversation
I managed to rewrite the Step & Dithering shaders (with their radial versions as well) without a for loop. This makes them work in the Web version with GLES2 and they should be a little more optimized now. I also rewrote the dithering textures loading logic, so that in the future we could allow the users to load their own dithering patterns, but that feature is outside the scope of this PR. I suppose some more UI/UX improvements are needed before merging. |
Having a selection, applying a dithering gradient, removing the selection and then going to the gradient dialog again causes the dithering shaders to "remember" the previous selection, even if there is no selection currently. This only happens with the two dithering shaders and only with the GLES2 renderer. Removing `uniform sampler2D dither_texture;` from the shader code seems to fix the issue, but that's obviously isn't what we want so a "proper" fix is included in this commit.
More optimized and works on the Web version with GLES2
Now all shaders work on the Web version and have been optimized.
ed1f708
to
4801f4a
Compare
Didn't change the dithering shaders because they seemed to give different results.
That's a good point. I changed how the preview looks in all shaders except the two dithering ones, because they seemed to give different results than they do now. Although I am a bit worried that the other gradients may give different results as well, but so far I haven't noticed anything. Ideally, making the preview look the same as the output should happen outside of shader code, but I'm not sure how that would work. |
Maybe using viewport with same size as canvas size? Place the preview inside there so we can see it being naturally pixelated |
This makes more sense because the smaller the number, the smaller the radius.
Should be good to merge now, if we want we can always make improvements later. |
Gradient generation is now shader based. This results in much faster speeds compared to the previous GDScript generation algorithm.
Apart from the significant performance increase, the new gradient generation system offers 6 types of gradients. Linear, Radial, Step, Radial Step, Dithering & Radial Dithering. The previous gradient system only generated Step gradients. A lot more freedom is given to the users as well. Now, they can tweak the angle of the gradient, the size, position, radius and center for the radial gradients, and the dithering matrix for the dithering gradients.
Textures of the bayer matrices taken from https://github.com/tromero/BayerMatrix
2022-04-24.21-14-18.mp4
Fixes #645, implements the first part of #628.