# Configuring the reentry effects

### Prerequisites

[Setting up a mod in Unity](/doc/e361c8c3-8fe1-42e6-9596-fb789b913fe0) 

[Modeling the mesh in Blender](/doc/bcb638b8-8995-4c05-ac96-c898247fa1fd) 

[Configuring the part in Unity](/doc/30aca1ce-442f-4d41-9c57-86bbec2135bb) 

### Introduction

 ![Figure 1. Reentry effect envelope](https://docs.ksp2redux.org/api/files.get?sig=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJrZXkiOiJ1cGxvYWRzL2U4YmY4MDA3LWI4OWMtNDJiNy04MzRkLWUwZGQ5NjM2NGM2MC9iMWI0NTc1MS1jY2UwLTQ3MWYtYTk0Ny0yNzYzODUwYjc3NjIvaW1hZ2UucG5nIiwidHlwZSI6ImF0dGFjaG1lbnQiLCJpYXQiOjE3OTM1MDkyMDAsImV4cCI6MTc5MzU5NTYwMH0.SsusANK3ym3yFIOQmwkndQZGlYa3vNLz_TYtUVE4OHQ " =514x288")

Reentry effects for parts in KSP2 are based on a custom shader which creates some flames coming out of an envelope surrounding the part (see Figure 1).

This envelope is defined for each part using a set of what we'll call *reentry meshes.* These meshes are set up in order to have a *Level of Detail (LOD)* system where a high-fidelity mesh is used when looking at the part from very close and a less detailed when looking from afar.

### Reentry meshes

 ![Figure 2. Reentry mesh Blender modifiers](https://docs.ksp2redux.org/api/files.get?sig=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJrZXkiOiJ1cGxvYWRzL2U4YmY4MDA3LWI4OWMtNDJiNy04MzRkLWUwZGQ5NjM2NGM2MC8wYmIyY2I2ZC0xOTVmLTQxY2MtYjVhNy1lNDM0ZWE2NTY5MDIvaW1hZ2UucG5nIiwidHlwZSI6ImF0dGFjaG1lbnQiLCJpYXQiOjE3OTM1MDkyMDAsImV4cCI6MTc5MzU5NTYwMH0.P2FtT4dC0DK0iCoEGzL9k40GUWRpLYTSMjaVDaa79mk "right-50 =400x550")

As we have learned before, the main parts of a part's reentry effects are its *reentry meshes*, we'll see here a way to create them quite easily in Blender.

We will need 3 *reentry meshes* for each part, one per level of detail: high, medium and low. There is no hard rule on how many faces each mesh should have, but as a point of reference, for a quite large M-sized part I would go for meshes with about `5k`, `2k` and `1k` faces respectively.

To create a reentry mesh in Blender, follow these steps:


1. Create a copy of your part's mesh and name it anything you want (for example `part_name_lod_0` for the high level of detail mesh).
2. Scale up your new mesh by about `10%` (the exact number may vary; we want the reentry mesh to completely envelop the part without any part of the part's mesh sticking out).
3. Next, we want to turn the copied mesh into a "blob" that will surround the part, we can do so by applying a *Remesh* modifier to the mesh in Blender in *Voxel* mode (don't forget to turn on *Smooth Shading* in the modifier's options).
4. You can apply a few other modifiers to make the mesh look a bit better; I usually go with *Remesh* > *Decimate* > *Subdivision* > *Triangulate* (see Figure 2).
5. Finally make sure the mesh looks good, it shouldn't be too harsh/pointy and above all else the original part's mesh should not poke through the *reentry mesh*.
6. When finished, you can export your created mesh as a FBX file and repeat the preceding steps for all 3 reentry meshes (high, medium and low details).

### Setting up the reentry effects in Unity

For this section, we assume you have already set up your part in Unity, meaning you have a prefab for your part which has a child named `model` containing your part's mesh.

First of all, we need to set up a new *Material* for the reentry effect shader, this Material can be shared between all your parts. To do so you need to:


1. Create a new *Material* asset called `Reentry`, this can be in the `Assets/Parts` folder of your Unity project.
2. Set this *Material* to the `KSP2/Parts/Reentry` shader (provided in the Redux SDK).
3. Assign the texture called `Heat` from the Redux SDK to the *Texture* field of the Material.

 ![Figure 3. Fully set up reentry effects for a part](https://docs.ksp2redux.org/api/files.get?sig=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJrZXkiOiJ1cGxvYWRzL2U4YmY4MDA3LWI4OWMtNDJiNy04MzRkLWUwZGQ5NjM2NGM2MC82ZDU1NTk1Ny1iYTQ3LTQ1MTktYjJlNi03YjQwOTc3MmY2ZjMvaW1hZ2UucG5nIiwidHlwZSI6ImF0dGFjaG1lbnQiLCJpYXQiOjE3OTM1MDkyMDAsImV4cCI6MTc5MzU5NTYwMH0.cDW0yCBPVdba9CCjIuz8jgSZukLzd8r0DNq1nGj7xc8 " =2554x234")

Then, we will setup the reentry effects for the part:


 1. Drag your 3 *reentry meshes* FBX files as assets into Unity (into your part's folder if you created one for example).
 2. Create an *Empty* child to the `model` object in your part's prefab hierarchy, name it `lod_reentry`.
 3. Drag the 3 *reentry meshes* as children of the `lod_reentry` object.
 4. Unpack each mesh' prefab under *Prefab* in the contextual menu.
 5. Apply the `Reentry` material to each *reentry mesh.*
 6. Add a new `LOD Group` component to the `lod_reentry` object.
 7. Set `LOD 0` to a *Transition* of `50%` and set its *Renderer* to your high level of detail reentry mesh' `Mesh` `Renderer`.
 8. Set `LOD 1` to a *Transition* of `25%` and set its *Renderer* to your medium level of detail reentry mesh' `Mesh` `Renderer`.
 9. Set `LOD 2` to a *Transition* of `0%` and set its *Renderer* to your low level of detail reentry mesh' `Mesh` `Renderer`.
10. Click on *Recalculate Bounds* in the `LOD Group` above the list of LODs.
11. Make sure the `lod_reentry` object is enabled (the checkbox needs to be checked at the top of `Inspector` next to its name) before the next step.
12. Add a new `Reentry Mesh` component to the `lod_reentry` object.
13. Apply all *Overrides* in your part's root prefab.
14. Disable the visibility of the `lod_reentry` object by unchecking the checkbox at the top of `Inspector` next to its name.
15. Re-apply all *Overrides* in your part's root prefab.

If you followed all instructions correctly, your part's reentry effects should be set up now like what you can see in Figure 3. You can new rebuild your Addressables bundle and test the effects in game.