How to Add a New Map#
This document will describe how to create a new map in the SVL Simulator.
(Link) Adding a new map in SVL Simulator.
The following text is a list of the steps described in the above video.
- Launch SVL 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 SVL 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.
- 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.
NavMesh must be baked if you want pedestrians to be able to move in your environment. Occlusion Culling can help improve performance on complex scenes.
- 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.
These steps have to be performed if you want rain to be stopped by obstacles (e.g. roofs).
- Locate all meshes that should stop rain.
- Review import settings for each mesh - in Model tab, the Read/Write Enabled option must be enabled.
- Select meshes one by one, or select their common hierarchy parent.
- Note: you can have multiple colliders on multiple objects on the scene.
- Note: if you choose to use the parent, all children meshes will be treated as single, merged collider.
- In the Inspector, select Add Component -> Rain Collider.
- In the newly added component, change Resolution based on mesh size - larger meshes should use higher resolution.
- Note: unless the mesh covers a large area, resolution of 128 or lower is usually enough.
- Click "Calculate Size" and make sure that calculated value does not exceed Memory Limit.
- After all colliders have been added, save the scene.
- 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. If you want multiple spawn points, duplicate this object and move to another position on the map.
- If importing or creating HDMap annotations, rotate all map objects so map North faces in the -X coordinate in Unity Scene View (see here). Use the simulator tool to rotate the scene to the correct position at Simulator -> Editor Tools -> Scene Type -> RotateSceneView and then the Run button.
- Make all scene objects a child of a empty game object at origin, rotate and then remove parent.
- Save the scene.
- Select Simulator -> Build...
- Select NewMap and click the Build button.
Map Preview is a feature in simulator to force a camera position and rotation for AssetBundle preview images in the web user interface.
Create a empty game object and place it at the root of the scene.
Add MapPreview.cs to the new object.
Rotate and Position the object in the editor z forward and Y up at the position you want.
You can view the scene from the object by selecting the menu GameObject -> Align View to Selected.
Save the scene.
Build the environment map bundle.
Upload to your SVL Simulator account.
See the preview image in the web user interface.