Lighting and Fog - naelstrof/ChurnVectorSDK GitHub Wiki

Configuring Lighting and Fog for scenes

Churn vector uses HDRP and Baked Indirect lighting to light its scenes. Note that the following guide is fairly basic in comparison to just how much you can do with HDRP and guides on youtube and such from other Unity develops are entirely applicable here if you prefer those.

The lighting setup we use generally includes:

  1. An overall scene lighting settings asset
  2. A global volume with a listener script (this is used for user settings like motion blur)
  3. A Sky and Fog Volume which controls fog and lighting conditions
  4. Light probes
  5. Reflection probes
  6. A sun if the scene is outdoors

Running through these in order:

Scene Lighting settings

The scene lighting settings can be found in the rightmost pane under "Lighting". If this is not visible go to window > panels > lighting to add it. For the final bake your settings will be dependent on the size and style of map. As an examplem these are the values used for the Office map.

image

For the purposes of developing a new map you will likely want to lower these values to something fast to bake like this:

image

The results will not look great but you can confirm everything is working by using low quality settings as there are a number of places that the shaders we use may fail to display properly (outlined in the FAQ)

Some setup

Before we go and actually set up the lighting theres one crucial step I want to make mention of. Its mentioned in another document somewhere but just to be sure: Your materials MUST have a mask map set. By default the shader we have, defaults to grey which will cause all of your materials to bake really strangely and come out looking terrible.

If you have texture sets that didn't come with a mask map you will need to create a solid green texture with transparency for them to show up properly. The transparency of this image is going to control how shiny things are so play around with the values to get it right and go slap it on everything.

The global volume

The global volume is an element in the scene heirarchy which contains a "Volume" and a "Volume Setting Listener script" image

Make sure this is on the default layer in the inspector or it will not work

The settings for this are a little much to individually address so the following images outline what this should look like for the purposes of it working but nothing is preventing you from customising this.

Note that you will need to click "new" in the volume profile and create a profile object to set these settings correctly and ensure that the Priority is 1 and not 0

image

The Sky and Fog Volume

Same deal as the above, this is another element in the scene with a "Volume" component on it but this time we are going to be controlling the Fog and sky values.

This one should be Priority 0

As before these are some general settings you can use but nothing is preventing you from changing these to alter your maps visuals.

image

Light probes

Light probes are a thing you can research as a general Unity skill HOWEVER we have included a script to automate generating these that you can find at Tools > ChurnVector > Generate Light Probes

That said, this is not something you can just, run, without knowing a little bit about it.

The script places light probes with a set density on any surface it finds. By default its configured to work in small indoor maps like the ones we included in the base game. If you go and run it without modifying this value on a large open map you're going to end up looking like this

image

Baking the above results in a 1gb light data asset which is absurd. To alter this all you need to do is open the script and change the following values to something larger to get a less dense result (theres more you can play around with as well but this is the fastest way to make larger maps more optimised)

image

Reflection probes

Reflection probes need to be manually added and are used for reflective surfaces to have something to, reflect. In order to add these create a new empty in your hierarchy and then create another empty underneath it. In the second empty add a component "Reflection Probe" and from now on, duplicate that empty to create more probes.

Reflection probes are edited by hitting the three dots icon (see image) and can be altered in size by hitting the small boxes on each side of the visual element. If you don't see anything in scene make sure gizmos are turned on (also image)

image

A good rule of thumb here is to use as few of these as possible without overlapping them or having a probe go through a wall. For outdoor scenes you probably won't want to add these on the outside of buildings as thats really hard to get right, just stick with interiors and around important objects.

THE SUN THE SUN THE SUN

For outdoor scenes you will likely want a sun, the default one provided by unity works fine but if you find its too bright lower the intensity OR modify the exposure settings in the Sky and Fog Volume. A value of 20 is a good intensity for a sun.

Actually baking the lighting

Tools > Churn Vector > Update Lighting to bake a new lightmap for your scene. If you find this is taking too long consider lowering some of the lighting settings you set above such as the lightmap resolution or samples.

Baking high quality lighting can take a long time so its best to ensure everything is working with basic settings before increasing them.

A note about baked lighting when it comes to Global Illumination

By far the most costly part of baking a lightmap is the global illumination, this is both processing intensive and uses a TON of your RAM when doing so. A single 2k lightmap will result in 6gb of your RAM being used for the GI portion of it pre compression and Unity bakes all of them at once, if you find you are running out of memory you can try increasing your systems paging file size or lowering the lightmap size.

To help limit the amount of GI calculations you need to run, make sure that you are setting the static flags for Contributing to GI correctly, you shouldn't have props and non geo assets marked for it.

An easy way to tell if you have something wrongly marked for GI is to enable "Baked lightmap" in your viewport shaders to see whats going to be included

image

FAQ

My scene has a fog volume but nothing I do makes it visible

Turn on the effects by hitting this button image

After a light bake some or all of my stuff is solid black or very dark

image

This happens when an objects material does not have a MaskMap to give it values for masking. If you do not have a maskmap for your materials the simplest sollution is to make a solid green texture and assign that as the MaskMap for the objects material.

Just be aware - the Alpha channel on the mask map is the shinyness of the object so you will want to also set your transparency to how shiny you want something.

Unity crashes while finishing a bake

Theres a few reasons this can happen, you might be running out of RAM or memory. Check your editor log for more information. Things you can try that I've found can help are

  • Close unity and re-open it prior to doing any baking so theres as little memory being used as possible
  • Delete the folder the light bake creates and clear your GI cache between settings changes (I've run into crashes where these two fixed them)