How to Add a New Map
This tutorial works with LGSVL Simulator release 2019.05.
This document will describe how to create a new map in the LGSVL Simulator.
(Link) Adding a new map in LGSVL Simulator.
The following text is a list of the steps described in the above video.
- Launch LGSVL Simulator from the Unity Editor (as described here).
- In the top menu, select File -> New Scene or Ctrl+N
- Create your new map folders in Assets/External/Environments/NewMap with /Models/Materials and /Prefabs in this root folder
- It is helpful to clone the CubeTown repository as an example scene to see how all Simulator features are setup and assets organized.
- Import assets you created or obtained into the Unity Editor.
- Move models, textures, materials and any other assets you need into the /NewMap folders. The new map should have no asset dependencies from folders outside of /NewMap.
- Do not include script files or non-HDRP shaders. If you need scripts in your scene, you will need to place in the source files of the LGSVL Simulator and build your own binaries.
- If your assets have non-standard shaders you will need to change them to the Unity Standard shader before converting to HDRP.
- Once all non Standard shaders are changed, you can convert the materials to HDRP materials.
- Select all materials.
- Select Edit -> Render Pipeline -> Upgrade Selected Materials to High Definition Materials. If the materials are all using Standard shaders, all shader settings will be converted with little need for adjustment.
- Be sure all materials have GPU instancing checked.
- Now we can start building the new map.
Creating the scene#
- Delete the MapHolder object in the Hierarchy Panel. This will be added back with the annotation tool later.
- Create an Object to hold the mesh data for your map. Name it the same as your folder, e.g. NewMap. Zero out the transform position/rotation: 0,0,0 and scale: 1,1,1.
- Save the scene in the root of the /NewMap, naming exactly the same, NewMap.scene. Delete or move any other scene files out of this root folder.
- Open the Annotation Tool, select Simulator -> Annotation Tool, and click Create Map Holder. This will add the correct holder for annotation named already the same as your map scene name.
- Save the scene again. Do this often. You should always be hitting Ctrl+S during development.
- Create the scene by adding meshes and colliders to the NewMap mesh holder object as children. You can further organize by making secondary holder objects, e.g., Roads, Buildings, Props. Just be sure to zero transforms for holder objects.
- Once organized and positioned, select the root holder object and check static in the top right of the Inspector Panel. Then, open the static menu and uncheck Off Mesh Link Generation and Batching Static. HDRP supports GPU instancing materials OR Batching, not both. GPU instancing is more performant.
- Then select all mesh holder root objects that you do not want pedestrians to walk on, e.g., Props, Buildings, Signs, and uncheck Navigation Static. This will make Nav Meshes ignore these mesh types.
- Add the TimeOfDayLight.cs component to all meshes that will emit light, not building windows. Then add a light component object as a child of this light.
- Add TimeOfDayBuilding.cs to the building holder.
- Be sure you apply black textures to the emission component of the meshes you don't want to emit and create an emission map for the ones you do want to light during the night.
- Set semantic tags for the holder objects OR the objects themselves, not both. Code will search and apply tags to materials from parent, down to all child objects.
- Set physics layers for all meshes to default. Be sure to do this from the root object so all child objects get set. Purchased assets may have very odd tags and physics layers that you will need to fix.
- Change all road material shaders to ShaderGraphs -> EnvironmentSimulation for environmental effects to work on road surfaces.
- Add mesh colliders to all meshes that need physics collisions, especially roads.
Extra Steps not in video#
- Add the RainVolume.cs to the mesh of the road or empty objects in the scene to have rain particles spawn in the map.
- Select Window -> AI -> Navigation.
- Select Object tab in this panel.
- Select groups of meshes, not their holders, e.g., road, sidewalk, grass, curb meshes.
- In the Object tab in Navigation, set the meshes to the types.
- Select the Bake tab.
- Click the Bake button. This creates a nav mesh that gets saved in the /NewMap folder.
- Select Window -> Rendering -> Occlusion Culling.
- Select Bake tab.
- Click the Bake button. This creates an occlusion object that helps with frame rate.
Finalize other map features#
- Select MapOrigin object in the Hierarchy Panel.
- Set Northing, Easting, UTM and TimeZone.
- Set NPC settings for the map.
- Edit SpawnInfo position and rotation. This object(s) will determine where the EGO vehicle(s) will spawn.
- Save the scene.
- Select Simulator -> Build...
- Select NewMap and build your amazing map.
Thanks for following this tutorial!