
Painterly SBR Plugin
Stroke-based rendering inside Unreal Engine 5's composition phase: stacked paint layers, coherent stroke placement from two compute-shader passes, flow maps and order-independent translucency. Master thesis.
Description
Inspired during the research I did for the painterly look of our "Obscura" game master project, for my master thesis I decided to go one step further than just a Kuwahara filter. In it I explored SBR (stroke-based rendering) within Unreal Engine 5.
The plugin's painterly pipeline happens mostly within the composition phase, concretely after Motion-Blur and before Tone-Mapping. The artist has to create and stack multiple paint layers on top of each other, emulating the real life painting process. The plugin supports curved and elongated paint strokes.
Firstly, the pipeline creates a canvas. The user can choose a custom canvas texture, choose one of many presets or blend in a Kuwahara filtered version of the scene colour (great for hiding holes). Upon this canvas, all paint layers colour and height information gets drawn onto, according to their blend settings.
The placement of the paint strokes was the hardest part. They had to stay temporally and spatially coherent, the biggest challenge lying within achieving a uniform stroke density across the three dimensional scene. I could either go with relying on motion vectors, using them to push strokes around, like it was done in the game "11-11: Memories Retold", or I could calculate positions inside the scene beforehand, using the object space within the composition phase, as it was done in Garcia et al.'s paper "Coherent Mark-based Stylization of 3D Scenes at the Compositing Stage". In the end I chose the second option, which on the one hand didn’t have some issues the first approach has, like not knowing when strokes have to spawn in or out and keeping density uniform when zooming in, but on the other hand was rather hard to implement.
The placement happens in a fractal grid pattern inside the object space (not world space, so that the strokes follow deforming or moving meshes). As I did not have this position data available in any of the built-in Unreal buffers in the composition phase, I had to add an additional mesh pass into the pipeline. To keep density uniform between these grid patterns, the system always calculates multiple octaves, offset from the one giving the most equal density and smoothly blends between them.
Calculating the placement positions happens in two compute shader passes. The first pass lets all pixels "vote" for their desired grid positions (multiple octaves) and enters them into a linked list. It also gives each grid position a weight, according to their octave and their scene depth. The second pass projects that grid position onto the geometry, by averaging the world position of all pixels that voted for that grid cell. It also calculates the final weight, by seeing how many of the possible voters actually voted for the grid cell, smoothly blending strokes out on edges before they disappear.
Later on these calculated positions are used to drive stroke placement and opacity. The plugin also calculates a flow map and density map per layer, giving the user a wide range of options how strokes should flow and where they should be placed (colour, depth bands; luminance, depth Sobel). After being placed, the strokes inside the stroke buffer get elongated along that flow map and finally drawn for order independent translucency inside a raster and resolve pass.
The final plugin still comes with some issues, like flickering when using the LOD settings, performance issues when using too many layers and I could not yet figure out how to support DLSS or TSR with the current implementation. However, writing the plugin was a very educational experience, and I might polish it in the near future and put it on the marketplace.
Media

Impressionistic Preset




Anchor fractalization and placement visualized
Impressionistic preset under motion (LOD Settings still introduce some noise)

Sky with luminosity flow map

Bottom Layer of Impressionistic Preset

Internally generated flow map

Internally generated intensity map
Settings inside one paint layer struct

Prototype screenshot

