Working With Baked Lighting - pastasfuture/com.hauntedpsx.render-pipelines.psx GitHub Wiki
Unity's light baking systems have many different options to customize how they operate. However, for this render pipeline, some methods tend to work much better than others. Here we're going to show you how to set up your scene for baked lighting.
Shadow Mask Workflow
Shadow Mask allows baking shadows for up to 4 lights per surface. Static surfaces receive high quality Shadow Mask lightmap textures. These Shadow mask textures are sampled per-vertex if Shading Evaluation Mode is set to Per Vertex, or sampled per-pixel if Shading Evaluation Mode is set to Per Pixel. Dynamic objects will sample Shadow Mask values from the nearby Light Probe Group.
To use Shadow Mask shadows:
- Under Window->Rendering->Lighting: Go to the Mixed Lighting section, and turn ON Baked Global Illumination. Also set Lighting Mode to Shadow Mask.
- Make sure any Game Objects that you would like to receive Shadow Mask Lightmaps are set to Static. This should automatically set the following settings:
- Mesh Renderer->Lighting->Receive Shadows: True
- Mesh Renderer->Lighting->Contribute Global Illumination: True
- Mesh Renderer->Lighting->Receive Global Illumination: Lightmaps
- Make sure Generate Lightmap UVs is enabled in your model import settings
- Make sure the Min Lightmap Resolution is correct for your Window->rendering->Lighting->Lightmap Resolution setting.
- Make sure any dynamic Game Objects that you would like to receive Shadow Mask Probe data have the following settings:
- Mesh Renderer->Lighting->Receive Shadows: True
- Mesh Renderer->Lighting->Receive Global Illumination: Light Probes
- If your scene contains dynamic objects: make sure you have a Light Probe Group in your scene. GameObject->Light->Light Probe Group
- Make sure your scene has fairly good probe coverage. A probe every few meters is a reasonable choice for typically scaled games.
- For any light that you would like to case Shadow Mask shadows:
- Light->Mode: Mixed
- Light->Shadow Type: Hard Shadows or Soft Shadows
- Light->Realtime Shadows->Strength: This controls the amount lighting from this light will be darkened by Shadow Mask shadows. A value of 1.0 should be used for fully opaque shadows. Values < 1.0 can be used for stylistic purposes, but have no physical basis. Values < 1.0 are often used to cheaply approximate bounce light.
- Under Window->Rendering->Lighting: Click Generate Lighting and wait for the bake to complete.
For more information on the Shadow Mask feature in unity, visit: https://docs.unity3d.com/Manual/LightMode-Mixed-Shadowmask.html
Note: If ANY light source in your scene requests Shadow Mask, HPSXRP will use Shadow Mask mode for ALL Mixed light sources. You cannot have some lights set to Mixed and some lights set to baked. Of NO light sources request Shadow Mask, HPSXRP will automatically configure itself to expect Lighting Mode->Baked Indirect data.
Baked Indirect Workflow
With your scene open, make sure you have the lighting window / tab open. If it isn't, you can open it by clicking Window > Rendering > Lighting Settings
at the top of your Unity window.
In the Lighting Settings window, to get simple baked lighting working, you should
- Make sure
Realtime Global Illumination
andBaked Global Illumination
are both enabled. These are what give Unity the ability to use baked lighting rather than dynamic lighting. - Under the
Mixed Lighting
section, make sure yourLighting Mode
is set toBaked Indirect
.
Make sure your meshes have Contribute Global Illumination
set to true.
As long as your lights have their Mode
set to Baked
, the lightmapper should be able to bake your scene lighting with minimal issues.
For more info regarding lightmap baking and working with blend probes, refer to Unity's documentation on the subjects.