Hello, here is my custom Live for Speed cartoon post-processing shader. It is very simple because I am a complete newbie in HLSL language. For best results, edit line 18 to match your preferred resolution:
I built a bit upon that cartoon shader
I found the contour convolution giving too much noise as usual when things move, so I found a way to add a 3x3 blur pass before the cartoon processing, so the rendering feels a bit smoother
I also boosted color saturation a bit
this is still very dirty code, dont laugh too much, I know almost nothing in glsl and this langage has so much constraints.
Still, this could be refined by adding a larger precomputed matrix to allow larger blur
also another blur pass might be good to smooth things out a bit more.
Thanks, looks better I experimented with Gaussian kernel too, but tried 5x5 kernels and run out of instruction limit, so I left it There is only one thing, there are some "division by zero" warnings, during shader compilation.
Edit: looks like noise can be reduced using in-game texture filtering settings too
well, after some rest, I am not rly sure my thing actually does anything good
those zero divide errors maybe just make the shader bypass the blur and any better feeling is achieved with texture filtering settings
A different approach with post processed textures (.dds) and a contour filter would give better results
I dont rly like cartoon rendering, it reminds me old bad experiences at work as I have been working on some TV cartoon serie made in 3D with cartoon post processes, and that was a predicted total fail.
But I have a passion for post processing since forever, and noise as the primordial soup from wich harmony emerges.
I may have another try at it. sorry for the noise.
I see cartoon shading when i close my eyes so I had another go.
I could implement a 5x5 blur matrix and remove those zero division warnings
All works good now, but i had to remove gamma correction to avoid instructions limit
Now the best result are achieved with help from texture filtering options
be sure to set options - graphics - texture filtering to max and the 4 Mip bias settings below to zero 0.0.
This give the smoothest render
edit: made it a bit more light, updated screenshot
Good job, looks awesome I must admit, I hoped that somebody will upgrade the shader, when I uploaded it. I will try to get better in HLSL and would like to experiment with different stylized shaders in the future.
am still far to understand all the mechanics of hlsl and the render pipe.
but I pushed things a bit more and integrated a 5x5 blur in the world2 shader before the edge detection to make things a bit smoother.
For now it will affect simple surface with no reflection. Other surface may look a bit too much edged.
2 files have changed, World2.psh and PostProcess.psh
as usual, backup ur shader folder, and replace the to shaders by those in the archive, renaming them accordingly
check options->graphics
texture filtering / AF to 4x
all 4 Mip biases below to 0.0
Adding more detail will make far things more outlined and things will become unreadable and noisy. Try and find ur preference.
Next idea is to change detail as object get farther, something with a z buffer, when I can figure it out how to do that in hlsl plumbing, and an antialiasing pass or whatever to remove last bits of noise and flicker.
No sure I go this far however, mojo might burnout.
I used a post-processing shader only, to keep it lightweight and because it can be turned off in-game. Of course, it has just a rough color-based approximation of contours. On the other hand, if you are not "afraid" to modify other shaders, IMHO there might be a better-looking solution using Sobel kernels over a depth-map to compute "real" depth-based contours. In that case, pixel shaders (before post-processing shader) must be modified to expose per-texel depth information. I am not sure what LFS does with the alpha-channel. If it is not necessary for some LFS algorithms, depth can be stored directly as a result alpha and the post-processing shader can apply Sobel kernels convolution on it (no gaussian smoothing is needed in this case).
However, if the alpha channel is used (I am not sure, when I visualized the channel, there is some data already), things are getting much more difficult. In such case RGBAD (D for depth) data must be compressed into RGBA (compression should be ok, toon shading uses color quantization anyway) and then decompressed back in the post-processing shader. For example RGBAD -> HSDA (hue, saturation, depth, alpha).
Hello, here is another artistic stylized shader for LFS, this time inspired by historic etching technique. For best results, edit line 18 to match your preferred resolution: