I attempted to make a shader in Unreal, with post-process volumes. this is done by creating a post-process material. I started by following the Kuwahara method, then added a distortion volume.
So to start, make a new material in unreal, then in the material editor change the material domain to post process. Then you can start adding nodes.
 |
Full Node Tree
|
The base of the Kuwahara material is two custom nodes connected to the scene texture. the first custom node is just called Kuwahara, it houses the code used to generate the filter, and the second references the scene UVs, this is so the filter is real-time, and changes with each camera move. The Kuwahara node has an input for the scenetexture, Uvs, radius, and veiwsize, these are array elements added in the material expression. the scene texture allows the node to reference the scene, and the radius refers to the "blobs" created by the Kuwahara filter. when the effect is applied in photography, it circulizes values based on the luminance of RGB values, creating something that's in between a blur and a posterize.
 |
| Kuwahara on a squirrel |
The vewisize input allows for the size/strength of the blur to change based on camera location. so when you're running around in unreal, whatever you're closest to has more detail, and things off in the distance are more blurry.
inside the Kuwahara node, you need to paste in a code that contains all the math.
 |
| It's blurry, I'm sorry 😕 |
This is the code for a directional Kuwahara filter with the Sobel function. To add in the direction, you split the radius into an x and y value
this allows you to distort in a specific direction, and make it look more like intentional paint strokes.
 |
| sobel function isolated |
The Sobel function is a way to preserve edges in the blur. this gets added directly into the main node, as well as a luminance function (which is a color node with a Dot) which turns the image black and white so the Sobel can detect edges, this then gets connected with a lerp to blend the two functions together.
This is the result of a directional Kuwahara filter! it's blocky and smudgy looking. pretty neat!
This is a VERY resource-heavy function, be careful, and save often.
 |
one of the many crashes
|
Not really impressionist though, so let's keep going.
you can use multiple post-process volumes in one scene, so the next volume is a paint layer that scumbles the image around.
This one doesn't require any code but starts out similarly to the kuwahara. this takes a normal mapa and multiplies it with the scene UVs before being fed back into the scene texture.
For fun, and because I didn't want to make a paintstroke material, I asked Dall E if it could generate a normal map based on impressionist painstrokes.
it can't.
So I found a brush stroke stock image, imported it into Photoshop to make it tile, and then switched to Substance Designer to create a normal map.
The result gives you a chunky and texturized scene that is highly customizable. However, I feel the issue with most paint shaders is that they look like a mess. paintings are intentional, every stroke is done for a REASON, so slapping on a random texture that doesn't align with the objects in the scene can make the result look lazy, or just bad.
 |
| UE scene with Paint Distortion |
 |
UE scene with kuwahara
and finally the same scene with both filters!
I am pretty happy with the result, but there are some things I would like to change
- the Sobel edge definition is not well defined, making the Kuwahara to blurry to stand on its own, I would like to incorporate another or better method of edge preservation in order to make the renders feel intentional, either a toon shader, redo the Sobel or something else entirely
- in paintings, colors are harmonious, they get sprinkled through the work even in places they don't belong in order to make the scene feel unified, I would like to find a way to add in a color "sprinkle", that would sample the colors in the scene and add them to other areas, for example, the box is blue, but everything else is grey. if this were a painting there would be blue visible on the floor
- some feature to control highlights and shadows, there are very few "extremes" in the scene and next to no true highlights.
- to condense the material. layering separate volumes is ok for now, but I want to create an easy-to-use and all-inclusive tool for other artists, the less set up the better so I need to find a way to condense these aspects into one volume.
|
References
Sam Gao's Ghibli Shader
More Sam Gao
Editing shaders in unreal
Unity Rain Drop Shader (good for learning how to overlay texture)
Another Unity Rain Shader
Kuwahara Filter Explained
Sobel Function Explained
Paint Shader
Comments
Post a Comment