Shadow maps for cockpits were introduced some time ago, but I never explained in detail how to create them. These are the steps you'll have to follow to create shadow maps for cockpits:
1. Using Jeremy's XwaOptEditor, open the cockpit OPT and export it to OBJ. For this example I'll be using the MissileboatCockpit.OPT.
2. Import the OBJ in Blender (File->Import->OBJ) using the following settings:
3. We want to make a closed cockpit OBJ and we'll remove things we don't care about, like small details, the hull, wings, etc. This is what the Missileboat Cockpit OPT looks like at the beginning:
This is what it looks like after removing big things, like the hull, wings and other stuff that we don't care about:
Tutorial: How to Create Cockpit Shadow Maps
- blue_max
- Posts: 2283
- Joined: Wed Mar 20, 2019 5:12 am
4. Cockpits may have some gaps in areas that aren't normally visible, like these:
These holes need to be closed or they'll also create weird gaps in the projected shadows:
These holes need to be closed or they'll also create weird gaps in the projected shadows:
You do not have the required permissions to view the files attached to this post.
- blue_max
- Posts: 2283
- Joined: Wed Mar 20, 2019 5:12 am
5. Remove all the details and close any remaining gaps. This is how the cockpit looks now, notice all the buttons and DC elements:
This is what it looks like after removing all those small details:
This is what it looks like after removing all those small details:
You do not have the required permissions to view the files attached to this post.
- blue_max
- Posts: 2283
- Joined: Wed Mar 20, 2019 5:12 am
6. Export the OBJ using the following settings:
7. Name the OBJ "Ship-Name-Cockpit.OBJ" (in this case that would be MissileboatCockpit.obj) and put it in the ShadowMapping subdirectory.
8. Finally, test the shadow map in the game. If you notice that the map doesn't match the geometry, you may need to flip the axes. You can do that by flipping the OBJ itself, or you can do it in the material file for the cockpit by adding the "shadow_map_mult_x/y/z" setting in the [Default] section. For instance, XwingCockpit.mat has this section to flip the Z-axis of the shadow map:
For this example, I checked the yoke and the sticks on both sides, the shadows match, so we're good:
7. Name the OBJ "Ship-Name-Cockpit.OBJ" (in this case that would be MissileboatCockpit.obj) and put it in the ShadowMapping subdirectory.
8. Finally, test the shadow map in the game. If you notice that the map doesn't match the geometry, you may need to flip the axes. You can do that by flipping the OBJ itself, or you can do it in the material file for the cockpit by adding the "shadow_map_mult_x/y/z" setting in the [Default] section. For instance, XwingCockpit.mat has this section to flip the Z-axis of the shadow map:
Code: Select all
[Default]
Metallic = 0.4
Intensity = 0.8
Glossiness = 0.08
shadow_map_mult_z = -1
For this example, I checked the yoke and the sticks on both sides, the shadows match, so we're good:
You do not have the required permissions to view the files attached to this post.
- blue_max
- Posts: 2283
- Joined: Wed Mar 20, 2019 5:12 am
Notes:
* Don't worry about normals or UVs in the Shadow Map OBJ, we don't need them. In fact, the OBJ should only contain vertices and faces.
* The Shadow Map should only contain triangles. Blender can triangulate everything in the final export step, but if you're using other software you'll have to do that manually.
* Computing shadows does have some (minor) impact in performance. Obviously the more complex your shadow map is, the bigger the penalty. I've found that removing the wings, hull and other stuff doesn't really affect the shadows, and has a barely noticeable impact in performance. You may keep these elements, though.
* The shadow maps don't support S-Foils or other cockpit motion. So if you add the wings to your X-Wing shadow map, the shadow map won't move with the S-Foils, sorry!
* Don't worry about normals or UVs in the Shadow Map OBJ, we don't need them. In fact, the OBJ should only contain vertices and faces.
* The Shadow Map should only contain triangles. Blender can triangulate everything in the final export step, but if you're using other software you'll have to do that manually.
* Computing shadows does have some (minor) impact in performance. Obviously the more complex your shadow map is, the bigger the penalty. I've found that removing the wings, hull and other stuff doesn't really affect the shadows, and has a barely noticeable impact in performance. You may keep these elements, though.
* The shadow maps don't support S-Foils or other cockpit motion. So if you add the wings to your X-Wing shadow map, the shadow map won't move with the S-Foils, sorry!
- Vince T
- Posts: 14028
- Joined: Fri Apr 27, 2001 11:01 pm
- Contact:
@blue_max I'll move this tutorial over to the new Guides section 

Your ship, Captain. I need a drink. - Vince Trageton
Vince T's X-Wing HQ - where the bad guys get their gear
Vince T's X-Wing HQ - where the bad guys get their gear