Implementations of a godot cel/toon shader and a pixelate shader.
I found the pixelated shader here and translated the toon shader from this.
It makes the picture look cartoonish.
It can toon accroding to HSV or according to RGB, with a switch shader param use_hsv
.
(Seem that HSV look better on this particular pic?)
The toon shader has two parameters,
use_hsv
:
if true, will use HSV, else uses RGB to toon.
nColors
:
Technically this is the amount of colors present in the picture. It will be used to determine how much sheering needs to be done.
However, this parameter does not have to be an integer, it will look better when nColors
is a suitable float. Just slide in the editor to find the value with the least "noise", that would (usually) be the best for you.
It pixelates the picture. The picture that we just tooned will now look like this
or this
The pixelate shader has two parameters,
x_size
and y_size
they are just the pixel size. (These pixel-size values can be quite small, as the size of an entire picture is (1.0, 1.0)
.)
It's quite self-explanatory. There is one scene called Demo. Use your own picture as the texture of ToonRect
, make sure that PixelatedRect
is on top of your ToonRect
. You can change the visibility of PixelateRect
if you so desire.
In Project -> Project Settings -> Display -> Window
, change width
and height
to match your picture.
Play the Demo scene, with your picture as the texture
of ToonRect
. You can change the visibility of PixelateRect
. Don't forget to tune the shader params to make it look better!
Finally, press enter after the scene starts to save the generated image to res://save.png
You will notice that the pixelated image is still I'm trying to find some ways to export the final pixelated image as a "proper" .png or something like it, with no success (which would be overwhelmingly useful for me, and many other idie game developers). There is definitely a way, still working on it. PRs are welcome.