Unity Package Types
Typical Recommended Setup
You may create as many lights in your scene as you want, but all of them (except for 1) should be marked as “Baked”.
Only one Directional Light in the space may be set to “Mixed” and may also have “Soft Shadows” enabled. This main directional light will be used for real-time shadows on systems that match the system requirements.
For lightmapping, these are the settings you’ll need to make things work correctly in Spatial. You can open the lighting panel from the “Windows/Rendering/Lighting” menu bar item in the top.
- Mixed Lighting Mode: Use Shadowmask. Distance Shadowmask will produce incorrect results for mixed realtime and baked lighting.
- Lightmapper: GPU lightmapper is a lot faster than others. If your graphics card is not good enough to this, Unity will switch it to CPU automatically. (In the case, lower Max Lightmap Size and try again.)
- Direct Samples: 32 is default and good enough. You can decrease for the fast iteration and increase to have better result.
- Indirect Samples: 512 is default and good enough. If your scene doesn’t have much direct light and use bounced lights mostly, like indoor and sun light from outside is the only light source, and if you see noise on the lightmaps, increase this to 768 or 1024. Keep in mind that this will increase baking time a lot.
- Environment Samples: 256 is default and good enough. This is sample count of lights from your skybox. If you still see noises after increasing Indirect Samples, try increase this. This count is necessary when you have less light objects and most of lighting is done with skybox.
- Min/Max Bounces: 1 for min and 2 for max is default and good enough for outdoor environments. You may need to experiment with this value if your environment is mostly indoors with dark areas, which will utilize bounce calculations more effectively.
- Filtering: Auto is default and I’d recommend not to set this manually because it’s very easy to cause noises or artifacts with this Filtering option.
- Lightmap Resolution: 30 texels per unit is relatively good, but this varies depending on your environment’s physical dimensions. Our Public Park has 37 and it has 8 of 1k lightmaps. Our Agora has 27 and it has 9 of 2k lightmaps and 1 of 1k lightmap. You need to find the best number and it is important for efficient use of lightmaps. The larger your environment is, the lower your lightmap resolution will have to be, since having too many lightmap textures will use too much memory.
- Max Lightmap Size: Note that Unity bakes lightmaps per object. So if there’s not enough space for the lightmap to bake the object, Unity will create another lightmap so 1024 could waste more pixels than 2048. And if one object is very large, 1024 could be too small to bake details. (Unity will fit it to the max size). 4096 could take too much bandwidth for mobile devices, so 2048 is relatively good.
- Lightmap Compression: This compression option will just set the texture compression to ETC2 or DXT5. We’d recommend to use ASTC (ASTC6x6 or 8x8) instead. You can manually change the format manually in the texture settings after baking. (Note that once you bake lightmaps again, Unity will overwrite the format by this setting.)
- Directional Mode: Currently, only Non-directional is supported. Directional lightmaps will produce incorrect results.
- Lightmap Parameters: Use ‘Very Low’ when testing and ‘Medium’ will be enough for final. (’High’ if you’re a perfectionist. But it’s hard to notice the difference.)
Note that for objects to be included in the baked lightmap, they have to be marked as “Static”.
Troubleshooting - Asset Import Utility
To help creators optimize their builds to smoothly across all Spatial-supported devices, we introduced the Asset Import Utility in July 2023. In some instances it may cause unintended optimization of some project files and textures. Check out the Asset Import utility documentation for help with troubleshooting these optimization changes: Asset Import Utility: https://docs.spatial.io/faqs/asset-import-settings
My object isn’t receiving light-mapped shadows. How do I fix this?
Here’s all the individual settings you need to get an object to be lightmap-able:
- You’ll need to mark the object as Static:
- The mesh of the object will need a second set of UVs. In the model import setting, you can let Unity generate these UVs for you. “Manual” margin method is usually more space efficient.
- The light that is casting baked shadows needs to either be set to “Mixed” or “Baked” mode
Once you have all of these settings, re-bake your lightmaps.
My environment has no ambient color and the scene looks dark.
- About This could happen when you publish your space without LightingData. (This doesn’t happen in sandbox.)
Generate Lighting’ button in Lighting setting.
- Detail 1. Window - Rendering - Lighting to open Lighting window. 2. Go to Backed Lightmaps tab. 3. Press ‘Generate Lighting’ button and you’ll see LightingData is generated and assigned to the scene.
Skybox(panoramic) has a seamline.
Disable ‘Generate Mip Maps’ on your texture setting. This happens if your skybox(panoramic) texture has mipmaps.
Terrain isn’t rendered with normal maps on web and sandbox.
- Problem Terrain has normal maps but Spatial doesn’t render it on web and sandbox.
- Do not use MaskMap in your Terrain Layers.
- Use 4 or less Terrain Layers.
- WebGL has limited sampler state (16) and some variants of terrain shader use more than it. In this case, Unity fails to compile the variant and uses one of fallbacks.
- This compile fail doesn’t always happen. Some combinations between other graphics features like additional lights or lightmap modes generate different variants of terrain shader and some of it use more than 16 sampler state and fails to compile on web build.
- So as a generic solution, you can leave the MaskMap slot empty, or you’ll need to test whether the terrain appears okay in your scene.
- Also you should use 4 or less Terrain Layers to your Terrain for the same reason. https://docs.unity3d.com/Manual/class-TerrainLayer.html#Performance
(Thanks to Shawn Young for reporting this bug and providing screen capture images.)
Lightmap results are unsatisfactory.
Terrain appears Shiny.
The appearance of particles has changed.
Scripts that read textures or meshes no longer function properly.
- Typical Recommended Setup
- Lightmapping Settings
- Troubleshooting - Asset Import Utility
- Lighting FAQ
- My object isn’t receiving light-mapped shadows. How do I fix this?
- My environment has no ambient color and the scene looks dark.
- Skybox(panoramic) has a seamline.
- Terrain isn’t rendered with normal maps on web and sandbox.
- Lightmap results are unsatisfactory.
- Terrain appears Shiny.
- The appearance of particles has changed.
- Scripts that read textures or meshes no longer function properly.