Technical art
Car Shader Damage
A damage (impact) system implemented through a shader
Description

Project: Personal
Instruments used: UE5, Blender, Photoshop
Car Shader Damage System
This is a damage (impact) system implemented through a shader: bullet holes, scratches, dents from collisions, broken glass, etc. The system provides two approaches with the ability to switch between them: using render targets and using decals. Each of these systems has its own pros and cons in terms of both visuals and performance. This is an overview of the first approach.
Render Targets. General structure:
  • Brush Material
  • Material Function
  • Blueprints
Brush Material
This material is used to create a render target via the "Draw Material to Render Target" function during a hit in Blueprints. Its main function is positioning damage masks on the RT using the component's UV coordinates.
To create variability, 3x3 texture masks are used, and in this material, random sampling of specific sections is performed, along with random rotation and scaling.
Instead of 3x3 masks, you also can switch to using a Texture Array.
This brush material is versatile and configured for damage from both collisions and bullets, and it works for both opaque and translucent materials.
Material Function
This is a MF that can be connected to any material where damage is to be applied. The shader receives a render target, which updates after each collision or shot. There is a switch for glass. Masks from the RT are used as alpha values for lerping the material’s original attributes with new ones.
One of the mask channels (G in my case) is used for opaque objects as a height map to construct normals and create a depth effect (important for bullet impacts). Directly passing a normal map complicates the creation of an additional RT and requires transforming the normal map properly due to the varying orientations of UV shells in the unwrap, which needs to be handled for correct object display.
Blueprints
A special component was created to implement the system on different actors. It includes functions for initializing dynamic objects (RTs and DMIs), applying collision and bullet damage to materials, and more.
Conclusion
The shader damage system offers flexible customization and works well visually on vehicles, but it also has several significant drawbacks, both visually and, primarily, in terms of performance. Because of this, the system has been enhanced with the option (currently manual) to switch to using mesh decals for individual components.
MMSHVYREV@GMAIL.COM
+381 62 9758559
Novi Sad, Serbia
© 2024 Maksim Shvyrev
Made on
Tilda