Baking lights and shadows - InfinaMii/MK8-Mod-Docs GitHub Wiki
In order for this to work, you must download an older version of blender.
BLENDER 3.5 AND ABOVE WILL NOT WORK!Before completing this guide, it is expected that you have basic knowledge of 3D modelling and use of Blender (e.g. UV editing).
Some useful tutorials can be found here.
Put simply, baking is storing information from a 3D mesh onto a 2D texture. This can range from normal baking (which stores surface details as directions) to shadow baking (which stores lights as a value from 0 to 1). For this guide, we will be baking three things:
- Shadows
- These are stored as a value from 0 (black) to 1 (white), which is determined by how much sunlight part of an object is recieving
- Ambient Occlusion
- Similar to shadows, however stores how exposed to the environment part of an object is (for example, the texture would get darker where an object touches the wall)
- Light Map
- Colored textures that includes every light (besides the sun) that affects an object
Performing real-time calculations for lighting, even if it takes less work to set up, take a lot of power and have a negative effect on the game's performance. Mario Kart 8 instead takes advantage of baking its lighting into textures, so lighting doesn't need to be calculated for large static parts of the course. This leaves only moving objects, such as racers and other course obstacles, which need to have their lighting calculated.
Because of this, baking your lighting and shadows well has a huge impact on how good your course will look.
In this guide you will learn how to bake the lights, shadows and ambient occlusion as textures for use in your Mario Kart 8 courses.
We will be using a custom Blender add-on in order to automate a lot of the process. It can be downloaded here.
This is based on Rodmjorgeh's guide, which includes instructions on how to do all of these steps manually.
If you would like to have finer control over how your course looks I recommend reading his guide as it explains what many of Blender's parameters do.
To begin with, we will load our model into a new Blender scene.
If you are baking a course from Mario Kart 8, open its course_model.szs file.
You can then expand the "Models" folder, right-click on its contents, and export them as a .dae file.
When exporting a model it will also export every texture that it uses, so MAKE SURE TO CREATE A NEW FOLDER!
If you are NOT using a model from Track Studio, export your course model as a .dae file by going to File > Export > Collada (.dae).
This is for two reasons:- Changes made to the bake model (including crashes/corruptions) don't affect our main file
- Any modifiers on our objects will get applied automatically
We can also delete the default cube model, camera and light as we won't be using these.
Make sure that the Clip Start and Clip End values in the View tab of the sidebar (opened by pressing N) are around 2 m and 100000 m respectively.
Your scene should now look something like this:

By pressing on the arrow to the right of the viewport shading modes, you will open a new menu where we can enable things such as textures.
Select Texture under the color options, and your model should have its textures restored!
Right now we are on Solid mode, but there are other important modes as well.
Material Preview is where we can view everything about the materials including reflections, normal maps, colors etc.
Rendered will let us see how lights and shadows affect our scene, which will later get applied to our bake textures.
For now though, we are going to stay on Solid as this allows us to see how the bake maps look under our UV Map without needing to import it to Track Studio.
If everything looks too dark on Solid mode, click the sphere and select the lighting mode below.
Mario Kart 8 uses average normals on its objects, so we'll use it too.
This makes sure things such as the player having shadows cast from models and map objects works correctly.
Select every object by pressing A, and enter Edit Mode by pressing Tab or selecting it in the Mode drop-down in the top-left corner of your screen.
Now that you're in Edit Mode, press A again to select everything and then go to Mesh > Normals (or Alt + N) > Average > Face Area. Now the normals of every mesh in the scene has been recalculated.
In order to bake maps, we need to change our render engine.
By default your project will be using Eevee, but we need to change it to Cycles. On the right-hand side, go to Render Properties and choose Cycles under the Render Engine dropdown.
Make sure your viewport shading mode is NOT set to Rendered, otherwise this could cause Blender to freeze or lag.
Now there should be more options to choose from. If possible, choose GPU Compute under the Device dropdown. This will allow our bake to complete faster and provide better results.
You will also need to change which render device you are using. Go to Edit > Preferences > System, and along the top change the Cycles Render Device to whichever device is supported.
If you are given the choice between CUDA and OptiX, choose OptiX as it is the faster of the two.
We still need some light shining through the scene, so let’s add a Sun.
We can add a new sun to our scene by going to Add (or Shift + A) > Light > Sun.
Before doing this, it's best to organise your scene into collections so it is easier to access the objects we need.
On the top right, right-click on Scene Collection > New Collection, and put all of the objects in your track there. We can also create one for our Sun and other light objects.
We will now change the direction the sun shines. Open the Object Properties window (the orange square icon on the right) and choose a rotation that fits with your course. You can also rotate the sun by moving the yellow dot in the scene, or by pressing R and moving the mouse.
For sunset course, the X and Y rotation would be further from 0 than usual.
If you feel like you need to throw more lights into the scene, go for it!
You can add Point, Spot or Area lighs by going to Add (or Shift + A) > Light and selecting the light of your choice.
Don't be afraid to go with high values for the strength of these lights, as course models are so big that you might need to reach megawatts (MW) in order for it to be visible on your bake map.
For our environment, we will recreate the skybox used in game.
In order to do this, we need to add a Sphere. Press Add (Shift + A) > Mesh > UV Sphere and scale this Sphere until it covers the entire track.
Next, we need to create a material for this sphere because we want to choose a color for it.
The color needs to be the same as the skybox color. For example, a sunset requires the sky color to be purple, because the skybox that is going to be used - the Animal Crossing (Autumn version) skybox - is mostly purple.
Next, under its Object Properties, go to Visibility > Ray Visibility and uncheck Shadow.
This object will only be used for lightmaps, so you can hide the object for now.
What this will do is make the whole course fit with the environment around it, creating reflections and making shadows more inline with the sky color.
Notice that it’s easier to see the pixels in the darker shadows on the right and harder to see the actual texture?
Courses in Mario Kart 8 usually have more than just diffuse (color) textures applied to them.
These additional textures can be used to enhance our bake and give it more detail.
If your texture has normal maps, you'll need to apply them in the Shading tab.
This will affect all types of baking and make the normal maps pop more in-game.
To do this, go to the Material Properties tab and scroll down to Normal. Here we need to select Normal Map, and then click on the Color property and select Image Texture. We can now select our normal map texture or open it if you haven't already added it to your scene.
Feel free to change the Strength values if you feel like it needs more depth.
Some Mario Kart 8 models also have emission models attached to them. This is most commonly used for things like dash panels, monitors, and blue lines on anti-gravity roads.
These might not appear in Blender when you import your model, so make sure the texture is attached to your material's emission node in the Material Properties tab.
You can also mess with the Emission Strength for brighter bakes. I like to go with 5.00 most of the time.
Less common are Transmission textures. These are used for things like fabric, where light passes through some of it.
This should also be plugged into the Emission node (but with less strength), as well as the Transmission node.
Now that we've set up our scene, we can finally begin the process of baking.
In order for our bakes to appear, we need to create an image where it can store its information.
Luckily, this is included in the add-on we installed earlier.
Press N to open the sidebar, and select "MK8" on the right. You should now be able to see all of the options the tool provides.
Right now, we want to press "Add Bake UV Map to Selected". This will add a second UV map to all of our meshes and select it.
We also want to press "Add Bake Texture Map to Selected". In the bottom left of our viewport, there should be a small black box. Expand it, and we can see extra settings for this texture.
The Texture Width and Texture Height parameters control the image's resolution. Larger images will provide higher resolution bakes, but will take longer to process.
The most common size for these is 4K (4096x4096) and other powers of 2, but don’t be afraid of choosing odd numbers. Just make sure it’s higher than 1k for better baking quality.
The other option is Texture Name. If you only plan to make one bake texture you can leave this as-is, but if you want to create different bake textures for different objects make sure to select the objects you want and enter a different name for each bake.
Now the mesh should've turned black. Don't worry - this is normal! This happens because when rendering in Solid mode, it will automatically use the selected image rather than the image attached to the Texture node.
This is why we used Solid mode rather than Material Preview earlier - it allows us to see our bakes directly in Blender and make sure everything looks right. If you want to see your textures again, you can switch to Material Preview mode.
There are a lot of ways to go around this, but first we need to clarify a few things.
While UV Unwrapping, any UV island (a connected group of faces) that is smaller than 1 pixel doesn't count towards baking and is left black. Make sure every island is large enough to bake.
If you feel like there are too many objects and faces to bake in one texture, don't worry - you can use more than bake texture.
Just make sure the ones you've selected have the exact same baking image. Storing objects with the same baking image in separate collections can help with this a ton.
Also, make sure you press "Select Bake" in the add-on's panel before unwrapping any UVs, in case you end up replacing the texture's UV by accident!
With this out of the way, read all of these options carefully to decide what will be best to suit your needs:
Select every mesh with the same baking image and go to Edit Mode (press TAB), and select everything. Hit U > Smart UV Project. A small pop-up will appear, with additional settings. Island Margin is how separated each UV island will be. This shouldn’t be at 0, but also not too far off, so 0.001-0.005 is enough. Angle Limit depends on the type of mesh, but generally 30º is fine.
Select every mesh with the same baking image and go to the UV Editing tab at the top. Click on the scene (right) and press A to select every face on your meshes.
Now press U (or go to UV > Unwrap) and select Smart UV Project. This should cause a window to appear where you can configure UV projection settings.
Change the Island Margin value. This shouldn't be at 0, but it also shouldn't be too big, so enter a value between 0.001 - 0.005.
Angle Limit depends on the type of mesh, but generally a value of 30º is fine.
Press OK, and look at your UV window on the left.
It should look similar to this:
Looks kinda jumbled up and messy, right? Don't worry, bakes are like that.
You can scale some of the island if you think they are too small, and check if they should be bigger or smaller using UV Sync Selection:
This syncs your UV selection with your Edit Mode selection in the scene so you know which face is which.
You might need to repeat the Clip Start/End settings from Getting Started again in the scene view window on the right in order to see your meshes correctly.
A different way to use UV Projection would be to do this per-object, rather than all at once. You can then place the UV islands wherever you like, and continue with the process until you've filled the whole image.
This process, although more tedious and time-consuming, gives you more control over what meshes get prioritised on the bake.
The most common and most useful add-on for what we’re trying to do is UV Packer. It’s perfect because it’s free! You can download it here: UV-Packer for Blender. Follow the steps that the page provides to install the add-on successfully. After the installation, go on the UV Editor and press N. A menu will pop up on the right with a new UV-Packer tab. All you need to do is select the corresponding image size and a big enough padding, something like 8 should work, and hit Pack. This should give out a good arrangement of UV Islands, but as always, you can change however you please.
If Blender's built-in tools aren't giving you what you want, you can install external add-ons to get what you need.
The most common and useful add-on for what we're doing is UV Packer, which can be downloaded here.
After installing, go to the UV editor window and press N. A menu should appear on the right, with a new "UV Packer" tab.
All we need to do is select the correct image size and large enough padding (something like 8 should work) and select "Pack". This should gibe a good arrangement of UV islands, but as always you can change these to your liking.
The generated UV map should look similar to this:
Usually we would configure render settings manually for each bake type, but thanks to the add-on we installed we don't have to do this.
What we do need to do however is choose a render preset.
In the Bake Tools panel, there are a few buttons under Render Settings - Daytime Preset, Sunset Preset and Nighttime Preset. Press whichever button relates to the time of day your scene will be in.
This preset will configure a lot of the important settings for you, but if you want a finer control over the look of your track see the Rendering Setup and Sun Settings sections of Rodmjorgeh's guide.
We did it! We've done everything required to create bake maps just like the base game.
Back in the Bake Tools panel, make sure the skybox we created is selected in the Skybox field.
This makes sure our skybox isn't affected by any of the changes that happen when selecting our bake type.
Now, select what type of bake you would like to perform in the drop-down beneath the Bake button. This will automatically change the material and render settings to match how this bake would look in Mario Kart 8.
Before we start baking, make sure that you press "Select Bake" to make sure the bake texture and UV is selected - this ensures we don't accidentally overwrite one of our other textures or bake over the texture in the wrong place.
Make sure you've saved your bake textures whenever you start a new type of bake!
Now we can press the "Bake" button in the panel to start baking!
If the button is greyed out, this is because you have selected objects that aren't meshes. You can deselect them by pressing the "Deselect Non-Mesh Objects" button in the Object Tools panel above.
After your bake has finished, check if there are any black spots visible in Solid mode.
This will be because the UV Island in this position is less than 1 pixel, so scale it up and hit bake again.
If you feel like the bake has too much noise, don't worry - we will tackle that in the next chapter.
Once you have completed your desired bake type, click on the folder icon beneath Export and select the folder you would like your bake textures to be saved in.
Now select all of the objects which you would like to save the bakes for, and press "Export Bake Textures". Make sure the bake type drop-down matches the type of texture you just baked so the files get named correctly!
They should now be saved in the folder you selected, and be named based on what type of texture you baked.
This guide only covers the process of baking your course. For details on how to combine these textures and import them into Track Studio, view rodmjorgeh's guide here.
There is one more thing we can do with the add-on though, so come back once you get to the "Sun Direction" section:
In Track Studio, you will be able to edit the course's bgenv file, which deals with the course's lighting. Under Course Environment in MainLight0 (the sun), one of the values is Direction.
To get these values from Blender, first select your Sun.
In our add-on panel we should now have access to two buttons: "Direction > Sun" and "Sun > Direction". To copy our sun's rotation to Track Studio, we want to press the "Sun > Direction" button.
Now, copy the X, Y and Z values above to our MainLight0 in the same order. This will make the sun in our Mario Kart 8 course point in the same direction as our shadows do in our bake textures.
If you would like to copy an existing course's sun direction into Blender to see how it looks, copy the values from Track Studio to the panel and then, with your sun selected, press "Direction > Sun".
This will change your sun's rotation to match the direction of the sun in your chosen Mario Kart 8 course.