JustInvoke / Randomation-Vehicle-Physics

Vehicle physics system for the Unity engine.
https://justinvoke.com/game-assets/#randomation-vehicle-physics
865 stars 184 forks source link

Damage Should Create Paint Scratches #9

Open JustInvoke opened 7 years ago

JustInvoke commented 7 years ago

The VehicleDamage script only takes care of deforming meshes and detaching parts of vehicles. It should scratch the paint too. I haven't been able to think of a good way to go about this, beyond perhaps using a method similar to the way tire marks are created.

The scratch generations must be handled with care as to not lead to excessive garbage collection.


Another idea I got from a comment on a YouTube on a video about car damage in Unity is to use the vertex colors as a mask to reveal a texture containing scratches. The vertices that are displaced in a collision could have their colors changed. This method would also require a custom shader.

Each channel of the vertex color could correspond to a unique texture representing the direction of the scratches. For example, you could have vertical and horizontal paint scratch textures on the material, corresponding to the U and V directions in texture space. The R and G or B values of the vertex colors could be linked to each of the textures, and the shader could blend between the scratch textures based on the colors. Upon collision, the relative velocity of the impact could somehow be transformed into texture space/UV coordinates and stored in the RG values of the colors.