Improved sprite rotation

Hi,

since there has been some progress in this field, will we get an improved sprites rotation that evens out jaggy edges ? Oh, and a numeric input would be nice :smiley:

Yes, there is progress on this topic: floating selection with rotation. I should also improve the brush rotation. Concerning jaggies I need to do some experiments. There algorithms like ā€œrotspriteā€ but yet I did not try all this myself. Still working on lots of refactoring along with adding the floating selection stuff. Letā€™s see how all this is going.

Jan also please consider better graphic scaling especially going from a larger graphic to a smaller one. If done right this would help me expodentially.

Iā€™ve looked briefly into the newer rotating algorithms, but from what I saw I think that the best approach would be to offer different algorithms to chose from (for both rotation and scaling). None of these offers a best solution with every image, so chances are that one has to try them all and keep the best results.

In Photoshop, for example, when it comes to scaling one usually tries out all the various algorithms available in the scale dialog, tweaks the various settings, and sees which one works best for a given image.

My impression is that currently there is no perfect rotating or scaling algorithm for pixel art ā€” and probably thereā€™ll never be one, because of the very nature of pixel art being based on subtle vision perception effects resulting from fine tuning adjacent pixels by hand.

@Morintari: can you give an example where it should work better? Larger to smaller should be good atm, but there are better algorithms for upscaling today but this is not what you mentioned.

Yes when working on a stereo image the image must be identical when scaled smaller. If you need a visual reference I can provide one thank you Jan any help is greatly appreciated.

Jan I think I may have a solution. We both know when you scale something you throw away information to make it smaller. what if there was a way to mark like highlight the information that you want weā€™ll call that boundary the information that you donā€™t want weā€™ll call that space.Now you just highlight the boundary and leave the space that can be thrown away to be smaller.Now you could just scale that but leave the selected information in tact while throwing away the space. You could call this smart scaling. Iā€™m sure there are many applications for this not just 3-D Thanks Jan any help is greatly appreciated.

The easiest way I see that we can do this without too much of an interface is we can make the option through the layers pallete and menu. Please let me exsplain. In the layers pallete a user could hide all layers except the top 2 the top layer would be the layer that would have the ā€œboundryā€ infomation the layer directly below it would be the ā€œimage layerā€.the user would then go up to the layers pallete and select ā€œsmart scallingā€. a dialog would come up asking the user which color or colors did he use for the boundry. On that dialog there would be a button that reads render. and voilia smart scaling with minimal interface. As usual any help is greatly appriciated.Your the best Jan thank you for all you have done in the past.

@Morintari, this approach seems overtly complicated, especially the inter-layer part.

It seems like what you really mean is a masking-based approach to scaling. I think that using selections is the simplest thing ā€” i.e. only pixels inside the selection mask get scaled. For more complex uses, it should be up to the user to create a custom shape to delineate the mask, and use it as a reference to create selections and apply them across different layers.

Preserving information during scaling seems difficult to achieve via algorithms, whereas just keeping a copy of the original image and reapplying selected parts from it on the scaled versions seems easier to do on the user side, manually.

I too would love to see advanced interpolation options in Pro Motion, for transforms.

Better algos for transforms in Pro Motion means users would need less third party niche tools, like Rotsprite.

Preserving information during scalingā€¦

Made me think of Photoshopā€™s ā€œsmart objectsā€ feature.
FYI - In PS, any layer can be converted into a smart object.
Doing this encapsulates that layer in a new document. It becomes a document within a document.
You can no longer draw in that layer or directly edit it in the parent document but you can transform it all you want, lossless. In order to edit the pixels in your new smart object you must open it just like you do any document.
When you open and save changes made to the smart object layerā€™s content, it automatically updates inside the original parent document. This means you can scale and rotate those pixels as many times as you want without continually degrading the pixel information.

While smart objects are absolutely vital to how Photoshop is used these days, this type of feature isnā€™t needed for Pro Motion, imo.
But this type of thing is likely whatā€™s required to be able to ā€œpreserveā€ information during transforms.

Using RotSprite or something similar (need to do experiments) is planned for the new transformation tool set. Donā€™t know if all this will work. Iā€™m looking for algorithms that can do the job well not only when rotating but also with free transform.

Awesome as always Jan@cosmigo. You never disappoint!

Here are some Ideas that I found, one I donā€™t understand and the other I do.

Hereā€™s the one that I donā€™t understand.

https://colececil.io/blog/2017/scaling-pixel-art-without-destroying-it/

the one that I do understand is this

http://www.drpetter.se/project_vectorize.html

What I see out of this one is there can be a basic scaling and rotation and there can be a smart scaling and rotation .The smart scaling turns the graphic into a vector and lets you render it. You can continue to render it at little or no cost to cpu when you are done, you can then throw away the vector information and just leave the rendering/s.

Thanks for the resources. Very interesting!

Jan@Cosmigo I should be thanking you for the awesome program! At any rate your more than welcome!

That is a quite famous article on how to use shaders to scale pixel art in video games without degrading images quality. The first part of the article goes through the classic scaling algorithms (like the ones which Photoshop presents you with when you scale an image) and presents an overview of how those algorithms operate on the pixels to scale the image.

In the second part it goes into the details of how he implemented a shader for scaling pixel art (actually, more than one shader, but since they work together they can be considered as one). Video game engines rely a lot on shaders for special effects, boths in 3D and 2D games. In that article, the shaders are for the Unity engine.

The powerful aspect about shaders is that they operate directly on the graphic card processor unit (GPU), which has some dedicate technologies for handling 3D rendering, and shaders are one of them. Shaders are fast and can be used for a moltitude of effects, from water waves effects, fire, smoke, to 2D images manipulation. So the author thought of using shaders for scaling pixel art in a smart way, letting the GPU handle the details.

Unfortunately, programming shaders is a bit of a pain ā€” they have a limited language, and itā€™s hard to use. Itā€™s all to do with low level manipulation of vertexs, and involve lotā€™s of math notions (trigonometry mostly, I think).

In any case, all game engine offer a way to scale images, and usually they employ algorithms like those mentioned in the first part, which donā€™t work really good for pixel art.

As for the vector approach of the second article, well of course vector images can be rotated and scaled without any losses. There are tools to convert a pixel art image to a vector image (e.g. SVG) so that the image retains itā€™s pixel blocks style (i.e. no attempt to smoothen edges), But the hard part is optimizing that SVG, so itā€™s not a huge collection of squares.

The problem with vector images is that they can be computationally expensive, because theyā€™re made of relative coordinates for lines, esges, curves, filled surfaces and colors, which is why they scale losslessy. Also, not all game engines support vector images.

Iā€™ve experimented converting pixel art to SVG vectors, and I like the fact that you can include them scaled-up inside a document and still retain that retro-look delivered by the square pixels. But when you rotate them the retro effect vanishes because the squares are no longer perpendicular.

Some videogames exploit similar techniques successfully, and manage to find a balance between ā€œpureā€ retro-school pixel art and more modern approaches by mixing 2D images and a 3D scebe, using shaders, lights and ambience, and even mixing images with different pixel proportions.

Thank you tajmone for your explanation. much appreciated.

Adding to the pile - https://en.wikipedia.org/wiki/Pixel-art_scaling_algorithms

Check out Fast Rotsprite.

HOLD ON. What do we have here? Does anyone use this?
https://www.cosmigo.com/pixel_animation_software/plugins/available-plugins

Loads current frame and can spit out a resulting image right into PMNG. Still talks successfully to PMNG. Just tested it.
Still figuring it out, not sure it does what Iā€™m after.

@jan.cosmigo How viable is it implement a plugin as a native tool into PMNG? Does it just depend on how the plugin is written?

Blockquote
I recently got the sources of the plugin from the author and the plan is indeed to include the algorithm or something similar with 7.3 .
At the moment Iā€™m working on a multi transformation tool like the ā€œFree transformationā€ of Photoshop. The algorithm used in the plugin is used for rotation operations and I want to use it for when you only rotate and scale the image without modifying one of the four corner points separately.