Skip to main content

Lighting

Types of lighting:
  • Real-time- calculates lighting every frame
  • Baked- pre-calculates lighting on the editor’s computer and generates light maps (textures that contain lighting and shading) which are overlaid on those objects
  • Mixed- combination of baked for static objects and real-time for dynamic objects
Types of lights:
  • Directional - Essentially the sun. There should be no more than 1 per scene. [Its rays are infinite, so its position does not matter but its rotation does.]
  • Point - projects light outward in all directions from the center. Simulates a lightbulb.
  • Spot - projects light outward from the center in a cone. Simulates a spotlight.
  • Area - projects light outward from a 2D rectangle or circle. Simulates a ceiling office light.

ideally all lights should be baked and no real-time lights should be used!!

Real-time lights in VRChat will either look terrible, tank your framerate, or usually both.

So how do you light dynamic objects? Light probes. These probes pre-calculate how an object would be lit at that probes location. Many of these probes are placed in a group, and when dynamic objects move through this group they blend the probes and are lit accordingly.

Reflection probes


Used for reflections. They act as a camera, taking 6 pictures from where they are placed (the 6 directions) and combining that data into a cubemap (a spherical image). Overlapping reflection probes blend.
DO NOT use screen space reflections in VR.

Reflection Probe Guide[gitlab.com]
Reflection Probe Box Projection[docs.unity3d.com]

Lighting settings

Go to Window>Rendering>Lighting Settings to bring up the window.

If your scene is completely indoors with no windows, turn off the skybox lighting.
If it is an outdoor scene, turn skybox lighting on and set the directional light source in the lighting settings.

 

Texels per unit

Texels are like pixels placed onto an object, and used to calculate the baked lighting. For many PC worlds I find ~30 texels per unit to be a sufficient compromise between quality and size.
Have your lights set to cast soft shadows.

To actually see how the lightmap texels will be projected onto your geometry, you can click the dropdown at the top of the Scene window (the one that is usually set to "Shaded") and set it to "Baked Lightmap".

To change the lightmap UVs of your mesh, you can do so in the model settings (click on the model in the Project window and change the Generate Lightmap UVs settings at the bottom of the Model tab).

While some objects with short shadows may be more accurately lit with hard shadows, soft shadows are more accurate across longer distances and look better at lower texel resolutions. Unity doesn’t include adaptive shadows out of the box like PCSS (Percentage Closeness Soft Shadows).
Next time you go in the sunlight, look at your shadow. Look at how the edges are sharp close to the origin (your feet) and get blurrier as you go up! That’s what techniques like PCSS emulate.

Do not overuse texels! The more texels you have, the larger in file size your lightmap(s) will be!

https://unity3d.com/how-to/progressive-lightmapper-optimization-tips

There are some situations where you would want to have a higher texel count because of overlapping lightmapping UVs (common with probuilder objects). UV overlap[docs.unity3d.com]

In your level design, avoid putting detailed shadows on the floor or low on the walls if your lighting is baked; the non-static models walking on top of those shadows won’t have those detailed shadows projected onto them.

Lightmap resolution

Controls the maximum resolution of the lightmap(s). Set it so that you only have one lightmap for optimal performance.

Bounces

Controls how many bounces a light ray will perform. [These take a long time to bake]
Most scenes shouldn’t need more than 2. [Exceptions would be scenes lit entirely indirectly.]

Occlusion Culling[docs.unity3d.com]

Set your static GameObjects to static [this will set the sub-parameters, occlusion and occludee static to true]. Then go to Windows>Rendering>Occlusion Culling, and hit bake before uploading your world.

Unity won’t render avatars the player can’t see; since rendering avatars is what tanks performance the most, good VRChat level design should subconsciously guide the player to look only at the other players they are interacting with, without rendering a bunch of poorly performing avatars in the background that they don’t care about.