VFX Research
Unreal & Unity, HLSL, C#, C++, Blueprint, Shader graph, Compute shaders...
Unreal & Unity, HLSL, C#, C++, Blueprint, Shader graph, Compute shaders...
Made with Unreal Engine 4.
2 solutions to paint on a world. The first favors performance and memory, the second has better vertical fidelity.
1st method - heightmap
2nd method - volume texture
This method uses a heightmap.
The mesh will be rendered as paint if a pixel's world space coordinate is lower than the value of the heightmap.
There are 2 components to this system:
It reads the heightmap from a render target and renders paint where needed.
Writes on the render target. We can't use a material to write on the render target here because materials would add pixel values on top of one another.
It is dispatched by an actor.
Compute shaders are not natively supported by Unreal. I'm using a plugin as a template here.
This method is very efficient : all of the paint information is stored in a 1024x1024 grayscale texture, and read/write operations are handled by the gpu.
This method uses a volume texture.
The mesh will be rendered as paint if a pixel's corresponding volume texture pixel is higher than an arbitrary number.
This allows for vertical gaps, and a "spreading" effect by using a gradient brush.
This system uses the 2 same components:
It uses world space coordinates to read the values on the volume texture, and renders as paint if the value is above 0.5.
Writes on a volume render target. Each thread writes the full height (64 pixels).
It is dispatched by an actor.
This method also uses the plugin as a template.
This method is less efficient : the volume texture is 1024x1024x64, and takes up ~80 megabytes of memory. Still, it uses the gpu for parallel computation, therefore not affecting performance that much.
Made with Unity.
An optimised solution to create an animated blood splatter without particles and using the power of the gpu.
The collisions are computed only once.
the blood looks black because of an encoding problem.
The shape of the mesh defines the shape of the blood splatter
Members of the class
Changing the mesh according to collision data
Blood animation
Clipping/coloration shader
The blood texture is generated procedurally to avoid repetition using a compute shader. It avoids unnecessary computation at runtime.
Generate the central splatter
Generate the blood lines
Combine
Fade according to distance
Add noise
Dispatching the shader
The feature took ~10 hours to develop, including the thinking of the concept and gathering of references.
The system could be further optimized by drawing the final blood texture on a large texture covering the entire level after the animation, to avoid unnecessary shader computations and to remove the vertices from the now inactive splatter of blood.
The noise function was taken from Shadertoy.