In this tutorial we will go over the process of setting up breakable glass panels with 3ds Max. We will cover setting up material ID's for a variety of glass types, as well as the required steps for setting up your scene in order to successfully export your asset for CRYENGINE and get the desired result. The breakability of the asset all depends on the surface types we assign in CRYENGINE.
Pic1: In-game shot of the broken glass panes achieved using the Breakable Glass technology
This is covering the Breakable Glass Shader which is used to create dynamic and physically accurate fracturing for glass objects, while keeping the performance cost low.
Before you continue with this tutorial, make sure to have read and understood the following;
In order to avoid any issues there are a few limitations that need to be considered:
Pic2: Wireframe of the glass panels inside 3ds Max
As with any asset that's meant to be exported for CRYENGINE we first need to create a new folder within the engine's folder structure. This is where you will save any files related to your asset.
<Project Folder>\Assets\Objects\tutorials\breakable_glass\Bus_stop
Since this is not a modeling tutorial we will be using an already created bus stop model as it incorporates a few different uses for the breakable glass shader. So to start with save your *.max file in the new folder you just created.
Assuming you have a basic understanding of how the 3ds Max material editor works we will now set up the material for our asset. Start of by creating a new Multi/Sub-Object material with 8 sub-materials and name them accordingly. In this example we will call it bus_stop.
For this asset, we have 8 SubIDs detailing the different parts of the asset.
Pic3: The full material setup for the bus stop asset with 8 SubIDs
It's good practice to have your first material ID as the physics proxy material (this is used for hit detection, physics and so on). Also it's worth mentioning that our glass panels do not require a physics proxy to work, (as we will be physicalizing the visible mesh) but we will go over that later.
Now there are a few settings that need to be changed to set this up properly for CRYENGINE:
For the proxy SubID... (this is for the metal structure of the bus stop):
Pic4: Proxy ID Setup in 3ds Max
For our second material ID we will create the first glass material and name it Glass. This is for the advertisement panels on the side of the bus stop model. These will be clear glass examples. This is set up in a similar way to the proxy material (enabling physics) with the exception being that we select Default on the second drop-down menu.
For the glass SubID:
Pic5: 1st Breakable Glass ID (advertisements) Setup in 3ds Max
For this particular asset we want to have another Glass material for our main glass panels, and we will be using a set of textures to create the effect. We will create this for our third material ID and call it Glass_Ribbed. The setup for it is identical to the Glass ID2, however you can load up your textures in it, although that can be done later on in the CRYENGINE editor as well.
For the main breakable glass SubID:
Pic6: 2nd breakable glass material ID (main panels) in 3ds Max
The next set of SubID's are the basic setup for standard materials. These Should all have the Crytek Shader set and from the drop down list, select default. These IDs don't require any physicalization setup, since their collision setup will be handled by the main physics proxy: (SubID 1)
Pic7: Material setup for ID 4,5,6,7 (non-physicalized SubIDs)
ID8 The final SubID for this assets material. This is for the curved glass that we want to sit on the top front of the bus stop. The setup is the same as ID 4,5,6,7 but requires a special mention as this will be glass, but un-breakable.
This is pretty straight forward:
<YOUR_PROJECT_FOLDER\Assets\Objects\tutorials\breakable_glass\Bus_stop\bus_stop.mtl
Pic8: Material selected at the top level, ready for export
Moving on to the geometry setup, there are a few particular things about the glass object that need to be mentioned:
Once we are sure our asset follows the rules mentioned above we can go ahead and name the panels in a logical way so it's easier to troubleshoot just in case something goes wrong.
Also make sure the bus_stop Multi/Sub-object material is applied to our geometry, the correct ID's are assigned to the glass panels and no other piece of geometry other than the panels is using any of the breakable glass material ID's.
Pic9: Hierarchy setup
Note that the proxy is offset just for previewing purposes! Normally it should match the location of your render mesh.
For the main proxy mesh (metal bus stop) see above pic, we have separated the mesh into multiple nodes, rather than one big mesh. The reason behind this is the simpler the physics proxy is, the better it will perform (within the physics system). Note how it's made of multiple simple boxes.
All the proxies should be linked to the parent object (the visible mesh) which is then linked to the helper dummy. See the above picture for the schematic layout in 3ds Max.
To follow the rules of asset creation for CRYENGINE, we have made an LOD for the bus stop. This is a simplified model of the original mesh (LOD 0).
Again the LOD should be linked to the parent object (the visible mesh) which is then linked to the helper dummy.
We are now ready to export our geometry to the engine. In the CRYENGINE exporter:
We have now finished the setup for the 3ds Max portion of the tutorial. Below, we'll configure the materials for our breakable glass asset using the CRYENGINE material editor. This part of the tutorial will cover setting up the glass materials inside CRYENGINE so they actually function as intended. Although this is a simple process it is very important to go through it otherwise the breakable glass will not work.
There are two settings that we will need to change in order to get the glass materials working properly:
The first one is the shader that is responsible for the way the material is treated by the renderer, giving you access to the different parameters that control the look of glass surfaces within CRYENGINE.
After you opened up your scene select the Bus Stop material in the Material Editor and change the Shader to Glass for the Glass and Glass_Ribbed sub-ID’s.
For the Glass_unbreakable sub-ID we will set the Shader to Illum. The reason for that is we’re aiming to achieve the look of thick non transparent glass so the extra controls offered by the Glass shader don’t offer any benefit in this particular case.
Pic10: Screenshot of the individual Glass material sub-ID's inside CRYENGINE
The second setting that needs to be changed is the Surface type. This will enable the glass to break as well as the application of adequate decals when bullets hit the surface and also the particles created by the impact.
As mentioned in the previous part of the tutorial it is required that we assign unique surface types to each of our glass sub-materials in order to get them to work together properly.
The glass surface types available in CRYENGINE are the following:
The difference between _large and _small is in the amount of detail the glass fragments can have. The _small surface types have higher tessellation and higher detail in the chunks and it should be used in places where the player can get really close to the asset, while the _large ones are less expensive and should be used for more distant objects.
Safetyglass and Thin work in a similar way with the key difference being that Safetyglass keeps the textures applied to the material after breaking. This is important to achieve the desired result for our Glass_ribbed sub-material.
Glass_unbreakable is used in cases where it is not required or desired to break the glass but proper application of the impact decals and particles is still wanted.
Now we can continue setting up our materials with the correct surface types.
For the Glass sub-ID (ID 2) change the surface type to Glass_breakable_thin_small.
Now select the Glass_Ribbed (ID 3) and assign it the Glass_breakable_safetyglass_small and lastly for Glass_unbreakable (ID 8) change it to Glass_unbreakable.
Pic11: Screenshot of the Glass material set up with the right shader and surface type
If you have properly set up your Shader and Surface Type you should now have fully breakable glass panels in your scene.