-
-
Notifications
You must be signed in to change notification settings - Fork 383
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
Implement cleanEdge rotation and scaling #794
Implement cleanEdge rotation and scaling #794
Conversation
Testing the bird sprite from one of the examples and rotating it to 315 degrees, the result seems quite different from the video posted by the developer. At first I thought there was something wrong with my modification, because I added NN into the shader, but I also tested it on another Godot project using the original version of the shader on a Sprite node, and then rendered the game window with the viewport stretch node, and the result also appears to be different from the video, and quite similar to Pixelorama, maybe even a bit worse. So my implementation may not be so wrong after all? It could be possible that the sprite has slightly different colors that the original, or that the degree or the pivot are different. Testing this is a bit hard without an example project from the creator, but my main goal right now is to figure out if my implementation of the algorithm is correct and if it looks good. If the result is desirable, then we should go ahead and merge, even if there may be slight differences from the results generated by the original shader here and there. |
Does the image size match with the one provided in the video example ? Maybe the author used bigger sample images |
this is really cool to see! Some notes on implementation that might be useful for optimization sake, etc. (which you may be doing, i havent checked the code. also some of this is mentioned briefly in the comments, but i figured id mention anyway):
(If it would be useful, i can upload a barebones godot project with the algorithm, just to compare against) There are likely some further optimizations I could do, someone with more technical knowledge of shaders might have some insight. There's some ideas regarding dFdx/dFdy and texelFetch that I'm going to look into. |
@torcado194 Thank you for your comments! :D |
I went ahead and implemented scaling using cleanEdge as well, as the 7th interpolation option in the Scale image dialog. Unfortunately, this means that I had to uncomment the CLEANUP-related code in the shader, which I think made the shader a bit slower than it was. I exposed slopes and cleanup as uniforms, since Godot 3 does not support defines. Hopefully I did it right. Cleanup is false on rotation, and true on scaling. Scaling definitely takes a bit of time, especially if there are a lot of frames and layers, so I would advice caution when using cleanEdge for large projects. But it seems to work pretty well and the results are beautiful.
|
I think it's ready to get merged. The results seem to be fine and I don't see any issues with the implementation. My only worry is that Pixelorama may take longer to open now on slower hardware, but maybe loading the shader only when the scale or rotate dialog first opens could be a good solution, instead of using So I will go ahead and merge it now. Consider this a Christmas gift. :D Big thanks to torcado for the shader and for making it open source! |
Implements #793.
Clean4xCleanEdge is a new pixel art rotation algorithm in the form of a shader by torcado. See https://cohost.org/torcado/post/621636-clean4x-a-pixel-art and https://twitter.com/torcado/status/1603530954038992896 for more details.Since the developer said that the code is public, I took the liberty of attempting to implement it in Pixelorama. Unfortunately, there was no way to rotate with the shader itself, so I'm attempting to combine it with nearest neighbor rotation. I'm not sure that I'm doing a good job though, since the results seem different that the ones shown by torcado. Which is why I'm opening this as a PR, to get more feedback of whether this is correct or not, and if anyone has any ideas of how else we could handle this, you can give it a shot.
EDIT: The clean4x algorithm has been updated and renamed to cleanEdge. The new code can be found here, along with a new website where you can import sprites and rotate and/or scale them with cleanEdge: http://torcado.com/cleanEdge/