Professional Documents
Culture Documents
::::: :::::
Car destruction has been done a lot of times before in a lot of engines and dates back
to the dawn of the first racing games. The purpose of this document is to find a solution
to do procedural car deformation of the metal, and the destruction of other parts in the
unreal 4 engine.
This includes:
The result will be a blueprint within a small game in which you can shoot blocks at a
car and make it fall down slopes or other objects.
We’re trying to research how far you can push realistic metal destruction within unreal.
The biggest research area is the bending of metal plates in unreal. This will have the
biggest impact on the look and feel of the destruction of the entire car.
- Breaking of glass
- Suspension of wheels
- Sounds on impact
- Bringing it together in an interactable scene
We have gone through a long process of trial and error before we reached a model that
works. There are as always different ways with each their own pros and cons to achieve
our goal. These are the things we could do:
Deformation
We could use decals that spawn on impact to displace the vertices of the object.
We could use morph targets to have lots of control over our deformation. On flipside we
do have always the same deformation, and so we lose the feel of our procedural damage.
We could use a soft body plug in called flex. This will result in the same soft body
simulation as used by beam ng. As a con we do have the problem that this is physX driven,
en will work very poorly on non-Nvidia cars. This a different branch of unreal used for
cloth simulation, fluid simulation and soft body physics based on the physics simulation
of constrained particles.
We could also make a model that is filled with bones and displace the bones when something
hits them. The problem with this is very little control and lots of work for skinning,
etc.
Breaking glass
The breaking glass can be done with destruction models within unreal. If the glass can
be destroyed on a more local level, an extra level of destruction would be needed. This
is fairly simple to implement and does not need a lot of explenation.
Wheel suspension is achieved with a physics constraint and soft limits. It requires a
bit of value tweaking, but is not undoable.
Interior parts
The interior parts are done with simple static meshes who are simulated with physics and
held in place by physics constraints. These will also shift the weight around in the
car, making the engine heavier, and the seats lights.
Particle effects
There are some object particle emitters present in the blueprint to spew out particles
when an object breaks.
Damage in texture
We achieved the damage in the textures by using a mask that we histogram through. This
mask is used with an extra normal map on each material instance and with some metal and
base color values. If a plate gets hit, more and more paint chips off.
Research details
Deformation
1. Decal deformation
The first way we tried to simulate deformation is with a decal that gets spawned upon
impact with a mesh. This decal would then displace the vertices on the mesh.
- The collision mesh itself does not deform, the effect is purely visual. This means
we would have to find other ways make the deformation realistic.
- Constant raycasting and detecting collisions might have a severe performance
impact.
- The decals would need to be persistent and will have a performance impact when a
lot of them are spawned.
- The decals could already include changes in the texture. Effectively making the
deformation not just in the geometry, but also making it pop in the texture.
- This also means a more detailed deformation as a normal can also be included.
- Finally we also have more control over how our deformation could look like.
- A mesh would spawn a lot of decals when coming to a standstill. This is simply
because the mesh does a lot of small collisions before stopping. This makes the
normal look very weird as if it was flipped. This could be limited in the
blueprint.
- Finding a way to make the decal influence the vertex shader was unsuccessful. We
tried workaround using the Gbuffer and the calling that channel in the shader.
But we could not find a node for that.
- It looked weird overall, not having the desired effect.
The second way was NVidia flex. This looked very promising because of its tech demo.
This tech demo included cloth physics, which could be used for tearing away leather on
the seats. It also included plastic deformation. This means that for example a plate
with plastic deformation could bend and spring back, but when it gets bend over a certain
threshold, it would stay bent. This deformation model could be injected with the
parameters for metal and could have performant steady results.
The documentation however stated that plastic deformation was not yet integrated in
unreal engine 4. So that means we could not use it.
- NVidia GPU specific. This means that AMD and other users will have terrible
performance with CPU based physX.
- Quick integration. An entire car model can be made in 3D studio Max, imported in
unreal, and made into a Flex model with the click of a button. This makes the
process very fast, and makes it possible for outside parties to easily import
custom models into the tech demo.
- Reliable results. Judging from the cloth simulation, the results are consistent
and have good performance. The cloth behaved in a non-jittery way and seemed to
behave nicely.
- Good self-collision. The cloth models reacted to each other in a nice controlled
way, without clipping or considerable glitches. If this could be done with plastic
deformation the result would be very pleasing.
- We could maybe use cloth with a high enough stiffness. But after tweaking results,
cloth would react more as an elastic membrane than a stiff deformable metal.
- A non-Flex mesh would clip through the cloth when falling on it and make the plate
spasm out of control, effectively breaking the simulation.
- Making deformable metal is practically impossible without the plastic deformation
model.
The second method had more pleasing result. It made a nice ripple effect when a box was
shot at it from different sides, like the hood of a car would do on a frontal collision.
But due to the high damping this also meant that the plate would remain stationary in
mid-air. Another problem would be that if a box was placed on top of the metal plate,
the box would seemingly “melt” through the plate. This is because the box keeps offsetting
the damped bone, because the bone does as matter of fact not give a force back to the
box that keeps it floating, it only stops the velocity of the box.
We would need to make the abovementioned method have actual physics that makes it fall
down. And for that we have found the following workaround:
We would create a blueprint with the mesh of the hood with fitting collision mesh (now
called the mesh), and the skeletal mesh of the hood (now called the skeletal).
Then we would give the mesh simple physics and a standard weight that would be conform
with the actual weight of a standard hood.
Every tick we now teleport the skeletal to the position and rotation of the mesh. We
also make the mesh invisible in game.
The result is that the skeletal now has the appearance to fall and collide with other
skeletals. While in reality this is driven by the mesh that does the collisions in the
background. To make the skeletal deform upon impact it is imperial that the collision
of the mesh itself is somewhat “sloppy”. This also good for performance because high
precision collisions are not required.
Upon impact the skeletal would slightly clip through the other skeletal and make each
other displace the bones. The higher the velocity, and this the impact, the more the two
meshes clip through each other and the bigger the deformation in the two skeletals. When
the velocity is low enough, no deformation is present.
Quick recap
Skeletal with high damping -> teleported to -> mesh with physics.
Breaking glass
Suspension
The suspension was done fairly easily by simply using a physics constraint which is
locked on the x and y axis and has a soft limit in the z axis (locally simulated), and
which is also locked in the angular axis, except the y axis, also locally simulated.
This makes the automatically roll on its wheels when a force is applied, adding more
realism. A brake could easily be simulated with applying more angular damping to the
physics constraint.
Simulated the actual contraction of the spring mesh wise cannot be done using this method
and would require a scaling bone to work.
Interior parts
Solid parts
This includes parts that can be considered stationary inside a car. These meshes
have a tendency to stay in the car and deform.
This includes:
- The dashboard
- Engine housing and cables
- Trunk housing
Breakable parts
This includes parts that can sometimes deform and fly out of the car when
sufficient force is applied. These objects may come loose while the inside is
still enclosed (doors locked) and wreak havoc inside.
This includes:
- The engines
- Spare wheel in the trunk
- Steering wheel
- 5 seats
- Shifting stick
Loose parts
These are loose objects that are inside the car and fly out very easily. This
list includes random clutter, like a box or a can of cola.
These parts, except the loose parts, are kept in place using a breakable physics
constraint. When the constraint is broken and particle effect will also be played that
spews out bits and pieces of the connection. Some parts are connected with multiple
constraints and may hinge when one of the constraints break. Like a bolt breaking, but
other bolts hanging on.
Particle effects
Breaking particles are spawned when a physics constraint breaks. This includes the lights
and the grill.
This adds the dramatic effect of actual small parts coming off. These small parts
include, broken metal, small bent pipes, wire parts, etc. The effect is achieved using
mesh particle emitters that get spawned during runtime.
Damage in texture
The actual damage in the texture is achieved by using an extra universal mask and some
bended metal normal maps to blend in when a component gets hit. We us a damage parameter
that increase with and amount depending on the strength of the impact. When something
hits the component, the chipped metal and bending normals pop into effect and make for
a more realistic destruction material overall.
Overview
Conclusion
The current model is not very user friendly and rather complex. To get a custom model
working, you would need to build it from the ground up, with all problems in between.
It’s also really hard to automate the process since the actual placement of hinges and
bones depends entirely on how the car is built and where the car should deform. Similar
looking cars could share bone structures, but they would have to be a close fit.
I’ve had a lot of fun working on this project and will probably revisit it sometime in
the future. I’ve learned an enormous amount about unreal 4 during the time I worked on
this. The experiment I’ve made is not entirely usable, as there are still problems with
2 cars colliding, but I think it can be done with some more scripting and detecting
objects from different actors.