GTA V: Glass crash data guide.
Updated: May 2022 (see below)
Vehicle model usually includes a set of glass objects (windscreen, rear windscreen, door windows) that can be crashed with several shots or during impact with other objects. This includes rendering of shatter-glass effect on glass objects and involves making of holes that can expand up to boundaries of the window. The technical background of this process is hidden inside the game and shaders code, and the data required for this logic is stored inside *.yft files. The data is not explicitly bind to the object itself, instead it just defines the boundary limits for the crash glass holes. The image below shows an original windscreen (orange) with original crash boundary data (red) and a modified windscreen (orange: it's moved aside and rotated), while crash data still makes crash holes in this object with original boundaries:
Glass shatter pattern is imported into the scene as object.crash geometry (e.g. "windscreen.crash") and contains a vertex-color painted template for glass shattering. This "crash data" object can be a child of an associated geometry object or a child of an associated collision object, it doesn't matter. Glass shattering requires a collision, so you can't have a glass shatter on an object, say, "extra_2" unless you create an "extra_2 [COL]" collision.
Some objects that don't need a shatter pattern (e.g. a glass-only object that can be smashed completely, or a small glass over headlights or siren lights) can be used with no shatter-glass painted object. To enable shatter effect on these objects, you should add a Crash user-defined option on an associated collision object. In case your collision object is a compound node, make sure to toggle COL state first. Here's an example of user-defined options on windscreen object:
Exporter will create blank crash data for such an object. This object will still trace bullets and will crash and will show crash holes, but you will miss the small boundary of glass on borders of this object when glass is smashed completely.
Note, you do not need to assign "Crash" user-defined option onto a COL object if you have a "some_name.crash" geometry object in scene. Availability of this object will automatically trigger glass shattering logic on a parent geometry/collision.
An ability to draw crash holes is a exclusive feature of vehicle_vehglass and vehicle_vehglass_inner shaders. Other shaders does not seem to support this option.
Since geometry part can use multiple materials (e.g. outer glass and inner glass), you have to explicitly specify the material that will use glass-crash logic. This is also the case when just one material is used. In case of windscreen and door windows, an "outer" glass should be used for glass-crash. To specify the exporter that some material will be used in glass-crash logic, assign "Crash" user-defined property on material too:
Important: game stores and uses glass-crash logic in model.yft file, not in high-resolution model_hi.yft. Thus, you have to ensure your glass-crash material is actually used on a low-res model, so it is exported into model.yft file.
It is strongly recommended to use exactly the same set of materials on L0 and L1 models (hi-res and low-res models), so both model.yft and model_hi.yft will get exactly the same set of materials stored inside.
You can create a palette of polygons hidden deep inside a mesh (where these are not visible) on, say, chassis L0 and chassis L1 meshes, and assign each available material onto one poly of this palette. This will force ZModeler to export model with all of your materials. If you add some new material in scene, add it into palette on L0 and L1.
ZModeler does not validates materials pack when exporting hi-res and low-res models, as these are separated independent routines.
When in-game glass-crash is detected, the game will drop rendering of hi-res geometry associated with respective object (it will stop drawing windscreen from model_hi.yft when you shot windscreen) and will render associated low-res geometry (probably with glass-crash) instead.
[Guide] GTA V: Glass crash data (Updated May.2022)
Re: [Guide] GTA V: Glass crash data (Updated May.2022)
Update: May 2022.
Glass shatter pattern is now created as geometry object in scene (e.g. "windscreen.crash"). This object is a flat surface with Default Material assigned. It does not require texture or mapping, instead, it has vertices color painted on it. Vertices color is used to create a shatter pattern for an associated object.
Vertex color paint specifies whether the geometry of original glass object will retain as pieces of shattered glass or will disappear (e.g. window fragment can disappear leaving some pieces of shatter glass on boundaries). The white color on pattern specifies the retained geometry. The black color allows game to remove underlying piece of geometry. Shades of grey let the game create a fuzzy shattered boundary between retained geometry and removed pieces, so it looks natural.
Note, the shatter pattern can partly cover an associated glass object if you need to specify only a small area that should retain when glass is crashed. This is the case with open-top vehicles' door windows when only lower-part border of door window is retained and the rest disappears fully.
The .crash object
The ".crash" object (you can use the short name ".crash" instead of "windscreen.crash" for example) is placed in hierarchy as a child of an associated geometry object that will crash. You can put it as a child of an associated collision object too, it doesn't matter. Note again, that glass shattering requires an object to have a collision, so if you have a ".crash" as a child of "windscreen" but have no "windscreen [COL]", nothing will happen in game.
The geometry of the .crash object should be a flat surface. It could be made of triangles or quads, it doesn't matter. The object should be rectangular, as it represents a "pattern texture". The most important is to lay object properly on X and Y axes. Location of axes on an object itself is insignificant, the exporter prefers lower-left corner of the grid object, but it's not important at all. The X and Y axes are for shatter rectangle's width and height directions and they must align with X and Y object axes. The following image shows correct and incorrect setup of grid object:
Create\Surface\Grid tool can create you a perfect template object. Amount of intermediate steps on horizontal and vertical axes of the grid is not that significant, as the game has build-in scale which is 40 steps (rows or columns) per 1 meter. Thus, for example, to cover a 2m x 1.5m glass object with .crash grid object, you should create a grid with 80 columns and 60 rows. Important: you can't have more than 253 columns in a grid, so you can't create a shatter template for extra-wide objects. However, you are not limited with rows. Given that, you can rotate axes 90 degrees, so X axis (left-right) and Y axis (up-down) are swapped. Take a look on the image below, it shows a correct setup for extra-wide glass object:
You can paint shatter-glass template with Surface -> Paint -> Color tool after switching an object to vertices level. Mind the paint tool need a camera-facing surface in order to paint vertices, so you might need to flip visible side of an object first. This is solely for paint tool to act. On export, the visible side of .crash object is insignificant.
Tips
1. Imported glass shatter objects are hidden, you can use "Show all" button to see them.
2. Visible side of shatter object is insignificant, so you might see the back-face of imported shatter objects on left or right side of the vehicle.
3. Always pay attention to local axes of created grid object: create grid in Front view, so it resides on X and Y initially.
4. In most of cases, shatter glass .crash object should cover respective glass geometry object with some extra threshold.
5. You can assign user-defined property UV onto .crash object to specify a shatter-glass texture scale that will be applied to an associated material in game. Note, the game uses UV#2 mapping on geometry object to apply shatter-glass texture FX, so you can control the scale of shatter texture with "UV" user-defined property.
Glass shatter pattern is now created as geometry object in scene (e.g. "windscreen.crash"). This object is a flat surface with Default Material assigned. It does not require texture or mapping, instead, it has vertices color painted on it. Vertices color is used to create a shatter pattern for an associated object.
Vertex color paint specifies whether the geometry of original glass object will retain as pieces of shattered glass or will disappear (e.g. window fragment can disappear leaving some pieces of shatter glass on boundaries). The white color on pattern specifies the retained geometry. The black color allows game to remove underlying piece of geometry. Shades of grey let the game create a fuzzy shattered boundary between retained geometry and removed pieces, so it looks natural.
Note, the shatter pattern can partly cover an associated glass object if you need to specify only a small area that should retain when glass is crashed. This is the case with open-top vehicles' door windows when only lower-part border of door window is retained and the rest disappears fully.
The .crash object
The ".crash" object (you can use the short name ".crash" instead of "windscreen.crash" for example) is placed in hierarchy as a child of an associated geometry object that will crash. You can put it as a child of an associated collision object too, it doesn't matter. Note again, that glass shattering requires an object to have a collision, so if you have a ".crash" as a child of "windscreen" but have no "windscreen [COL]", nothing will happen in game.
The geometry of the .crash object should be a flat surface. It could be made of triangles or quads, it doesn't matter. The object should be rectangular, as it represents a "pattern texture". The most important is to lay object properly on X and Y axes. Location of axes on an object itself is insignificant, the exporter prefers lower-left corner of the grid object, but it's not important at all. The X and Y axes are for shatter rectangle's width and height directions and they must align with X and Y object axes. The following image shows correct and incorrect setup of grid object:
Create\Surface\Grid tool can create you a perfect template object. Amount of intermediate steps on horizontal and vertical axes of the grid is not that significant, as the game has build-in scale which is 40 steps (rows or columns) per 1 meter. Thus, for example, to cover a 2m x 1.5m glass object with .crash grid object, you should create a grid with 80 columns and 60 rows. Important: you can't have more than 253 columns in a grid, so you can't create a shatter template for extra-wide objects. However, you are not limited with rows. Given that, you can rotate axes 90 degrees, so X axis (left-right) and Y axis (up-down) are swapped. Take a look on the image below, it shows a correct setup for extra-wide glass object:
You can paint shatter-glass template with Surface -> Paint -> Color tool after switching an object to vertices level. Mind the paint tool need a camera-facing surface in order to paint vertices, so you might need to flip visible side of an object first. This is solely for paint tool to act. On export, the visible side of .crash object is insignificant.
Tips
1. Imported glass shatter objects are hidden, you can use "Show all" button to see them.
2. Visible side of shatter object is insignificant, so you might see the back-face of imported shatter objects on left or right side of the vehicle.
3. Always pay attention to local axes of created grid object: create grid in Front view, so it resides on X and Y initially.
4. In most of cases, shatter glass .crash object should cover respective glass geometry object with some extra threshold.
5. You can assign user-defined property UV onto .crash object to specify a shatter-glass texture scale that will be applied to an associated material in game. Note, the game uses UV#2 mapping on geometry object to apply shatter-glass texture FX, so you can control the scale of shatter texture with "UV" user-defined property.