Difference between revisions of "Lighting"

From Wolfire Games Wiki
Jump to: navigation, search
(Created page with "{{stub}} == Sunlight == The sun allows you to cast dynamic, single-directional light throughout a level. You can use it to simulate either a sun (more direct light) or a moon (m...")
 
(Gotchas)
 
(29 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
{{stub}}
 
{{stub}}
 +
 +
'''TODO''': Cover other level parameters, such as HDR points, saturation, and sky brightness. These parameters are covered in the [[Script Parameters]] page, so might want to take care to not duplicate too much of the information and maybe include a link to that page<br>
 +
'''TODO''': Expand sun section to say how to get a "sun" and a "moon" effect
  
 
== Sunlight ==
 
== Sunlight ==
The sun allows you to cast dynamic, single-directional light throughout a level. You can use it to simulate either a sun (more direct light) or a moon (more ambient light)
+
The sun allows you to cast dynamic, single-directional light throughout a level.<br>
 +
You can use it to simulate either a sun (more direct light) or a moon (more ambient light)
 +
 
 +
<br clear=all>
 +
[[Image:Sun_editor.jpg|left|thumb|The sun editor]]
 +
{{#ev:youtube
 +
|DUaBoNEUcVI
 +
|
 +
|right
 +
|Editing the sun and sky
 +
|frame
 +
|start=267
 +
}}
 +
 
 +
<br clear=all>
 +
=== How to adjust the sun ===
 +
* Select the sun in the sky (double click it)
 +
* Move it by clicking on the middle and dragging it around
 +
* Change the color by dragging the dot around the outer ring
 +
* Change the intensity by clicking ''just'' outside the outer ring and dragging it
 +
 
 +
To deselect the sun, double click well outside of the sun editor ('''Note''': the normal Q for "deselect all" isn't working right now)
 +
 
 +
=== How to edit the parameters directly ===
 +
If you have problems clicking it, or would prefer a numeric editor:
 +
* Press the <kbd>'''Y'''</kbd> key to open the Scenegraph
 +
* Expand '''level''' to find the Sun parameters
 +
 
 +
<br clear=all>
 +
 
 +
== Reflection Capture ==
 +
 
 +
Reflection capture objects are used for ambient lighting, reflections, and the color of the fog in each direction.
 +
 
 +
There are two kinds of reflection capture objects, ''Global Reflection'' and ''Local Reflection''. Both can be found under '''Load''' -> '''Lighting'''. A global reflection capture can be turned into a local one and vice versa by setting its ''Global'' script parameter to 1 or not.
 +
 
 +
=== Gotchas ===
 +
Reflection captures are updated when moved, and each new result builds on the results of the previous reflection capture. This can be used to achieve some desired effect, but can also make it harder to get what you want sometimes. Try playing around with changing the brightness of the sky, amount of fog etc. to get different effects.
  
Double click the sun in the sky to select it.
+
Certain [[Shader_And_Weather_Effects|level shaders]] will cause an issue where the sky will increase in brightness. To avoid this, disable the level shader temporarily. If the shader is important to include in the reflection capture, you can update it a single time by adjusting its position slightly within the Selected window.
Double click well outside of the sun editor to deselect it (the normal Q for "deselect all" isn't working right now)
 
  
Move the sun by clicking on the middle of it and dragging it around the sky.
+
=== Global reflection ===
Change the sun color by dragging the dot around the outer ring.
+
Global reflection captures are used for the entire level, and each level should have exactly one. Since it affects the entire level it is often placed in a location that represents some sort of "average" lighting for the level.
Change the sun intensity by clicking ''just'' outside the outer ring and drag it.
 
  
If you have problems clicking it, or would prefer a numeric editor, simply hit hit <kbd>Y</kbd> to open the scenegraph. Expand "level" to find the Sun parameters.
+
=== Local reflection ===
 +
Local reflection captures are used to change what the reflections look like in a specific region of the level. These are useful if there are caves or other types of areas where the ambient lighting changes significantly from the rest of the level. Move, rotate and scale the object to decide what part of the level should be affected.
  
 
== Point lights ==
 
== Point lights ==
 
Point lights allow you to cast omni-directional light from a point in the level.
 
Point lights allow you to cast omni-directional light from a point in the level.
 +
{{#ev:youtube
 +
|wOL0LJBRcas
 +
|
 +
|right
 +
|Adding and editing point lights
 +
|frame
 +
|start=64
 +
}}
  
Top Bar -> Load -> Lighting -> Dynamic Light. The cursor will turn into a plus symbol. Now click in level to place the dynamic light.
+
=== Adding a dynamic light: ===
 +
* '''Top Bar''' -> '''Load''' -> '''Lighting''' -> '''Dynamic Light'''
 +
* The cursor will turn into a plus symbol
 +
* Click in level to place the dynamic light
  
Double click the light, and hold E while clicking and dragging on its bounding box. This will let you increase the spread of its effect. Notice that the light has a logarithmic fall-off, so it's not likely to *look* much bigger on static objects in the scene.
+
=== Changing the size of a dynamic light ===
 +
* Select the light - <code>'''double click'''</code>
 +
* Hold <code>'''E'''</code> while clicking and dragging on its bounding box.
  
To add a color filter, select the light and hit CTRL + P. This will open the "color picker". Adjust this color with the color selector, or RGB at the bottom. This will filter the color that is projected. A "black" filter will remove all light, so the light will have no effect.
+
Note that this only changes the light's area of influence, not how much light it outputs.<br>
  
You can use the "overbright" in the color picker to increase the amount of light that is output. This will probably also cause a bloom effect from some of the reflected light.
+
=== Making a dynamic light brighter ===
 +
* Select the light - <code>'''double click'''</code>
 +
* Open the color picker - <code>'''Ctrl + P'''</code> (<code>'''Command + P'''</code> on mac)
 +
* Change the <code>'''Overbright'''</code> setting
  
If you need an "area light" (non-spherical) effect, you can either use shadow decals to shape the light, or you can place multiple dynamic light objects, or some combination of both. Be careful to both look at how the lights affect static objects in the scene, and how they affect characters that walk through them.
+
=== Adjusting dynamic light color: ===
 +
* Select the light
 +
* Hit <code>'''CTRL + P'''</code> (<code>'''command + P'''</code> on mac) to open the '''Color Picker'''.
 +
* Adjust the color with the color selector, or '''RGB''' at the bottom.
 +
 
 +
=== Shaping the dynamic light ===
 +
Dynamic lights are always spherical right now.
 +
If you need an "area light" effect that isn't a sphere, there are a few options:
 +
* Use [[Lighting#Shadow_decals|Shadow Decals]] to shape the light (you have to enable this in the level first. See [[Lighting#Dynamic_lights_and_shadows|this section below]])
 +
* Place multiple dynamic light objects
 +
* Some combination of both of the above
 +
 
 +
Be careful to both look at how the lights affect static objects in the scene, and how they affect characters that walk through them.
 +
 
 +
<br clear=all>
  
 
== Shadow decals ==
 
== Shadow decals ==
 +
Shadows from sunlight are taken care of automatically.
 +
 +
However this only allows one level of shadowing. This doesn't handle ambient occlusion (shadowing of indirect light reflections).
 +
 +
Shadow [[Custom Decals|decals]] ("Ambient Shadows") allow you to manually place decals which simulate this ambient occlusion effect.<br>
 +
This can help you visually anchor objects more realistically in the scene, and replicate effects like darkening around corners, and inside cubbyholes.
 +
 +
<br clear=all>
 +
{{#ev:youtube
 +
|wOL0LJBRcas
 +
|
 +
|right
 +
|Adding and editing ambient shadows
 +
|frame
 +
|start=15
 +
}}
  
Shadows from sunlight are taken care of automatically. However this only allows one level of shadowing, and doesn't handle ambient occlusion (shadowing of indirect light reflections). Shadow decals ("Ambient Shadows") allow you to manually place decals which simulate this ambient occlusion effect. This can help you visually anchor objects more realistically in the scene, and replicate effects like darkening around corners, and inside cubbyholes.
+
[[File:Ambient shadow decals.png|600px|Ambient Shadow Decals's effect on light]]
  
Top Bar -> Load -> Lighting -> Ambient Shadow. The cursor will turn into a plus symbol. Now click in level to place the ambient shadow decal.
+
<br clear=all>
 +
=== Adding a shadow decal: ===
  
Double click the ambient shadow decal, and hold E while clicking and dragging on its bounding box (or while shift + right-clicking and dragging on a side to only stretch in that direction). This will let you increase the spread of its effect.
+
* ''Top Bar -> Load -> Lighting -> Ambient Shadow''.<br>
 +
* The cursor will turn into a plus symbol.<br>
 +
* Now click in level to place the ambient shadow decal.
 +
 
 +
=== Resizing a shadow decal: ===
 +
 
 +
Double click the ambient shadow decal, and hold E while clicking and dragging on its bounding box (or while shift + right-clicking and dragging on a side to only stretch in that direction).<br>
 +
This will let you increase the spread of its effect.
  
 
'''Note''': Ambient shadow decals will not create shadows if they in direct light. This is because they're for simulating indirect shadowing. Direct shadowing is already handled by placing objects in the world.
 
'''Note''': Ambient shadow decals will not create shadows if they in direct light. This is because they're for simulating indirect shadowing. Direct shadowing is already handled by placing objects in the world.
  
=== Affect on dynamic lights ===
+
<br clear=all>
  
By default, no objects cast shadows from dynamic point lights. This is for performance reasons.
+
== Dynamic lights and shadows ==
 +
 
 +
By default, no objects cast shadows from dynamic point lights (besides the sun). This is for performance reasons.
  
 
Normally ambient shadow decals also will not create shadow from dynamic point lights, because that would be shading direct light, and they don't work that way.
 
Normally ambient shadow decals also will not create shadow from dynamic point lights, because that would be shading direct light, and they don't work that way.
Line 44: Line 139:
 
However you can use the <code>'''#SHADOW_POINT_LIGHTS'''</code> level Custom Shader to make it so shadow decals can shape point lights, so you can manually simulate this shadowing.
 
However you can use the <code>'''#SHADOW_POINT_LIGHTS'''</code> level Custom Shader to make it so shadow decals can shape point lights, so you can manually simulate this shadowing.
  
Hit <kbd>'''Y'''</kbd> to open the level's scenegraph, expand Script Params, and add a <code>'''Custom Shader'''</code> param, and hit Enter. Then type <code>'''#SHADOW_POINT_LIGHTS'''</code> in the value column and hit enterThis will make ambient shadows affect the direct light from dynamic lights, an let you sculpt the light they cast, or let you create manual shadows.
+
<br clear=all>
 +
[[File:Shadow point lights shader disabled.png|400px|without #SHADOW_POINT_LIGHTS]]
 +
[[File:Shadow_point_lights_shader.png|400px|#SHADOW_POINT_LIGHTS Custom Shader setting]]
 +
[[File:Shadow_point_lights_shader_enabled.png|400px|with #SHADOW_POINT_LIGHTS]]
 +
 
 +
<br clear=all>
 +
=== Making shadow decals affect dynamic lights: ===
 +
 
 +
* Hit <kbd>'''Y'''</kbd> to open the level's scenegraph
 +
* Expand Script Params
 +
* Add a <code>'''Custom Shader'''</code> param
 +
* Hit <code>Enter</code> (not <code>tab</code>!)
 +
* Type <code>'''#SHADOW_POINT_LIGHTS'''</code> in the value column and hit enter
 +
 
 +
This will make ambient shadows affect the direct light from dynamic lights, an let you sculpt the light they cast, or let you create manual shadows.
 +
 
 +
[[Category: Tutorials]]
 +
[[Category: Modding]]
 +
[[Category: Overgrowth]]

Latest revision as of 21:24, 12 July 2022

This article is a stub. You should help Wolfire by expanding it.

TODO: Cover other level parameters, such as HDR points, saturation, and sky brightness. These parameters are covered in the Script Parameters page, so might want to take care to not duplicate too much of the information and maybe include a link to that page
TODO: Expand sun section to say how to get a "sun" and a "moon" effect

Sunlight

The sun allows you to cast dynamic, single-directional light throughout a level.
You can use it to simulate either a sun (more direct light) or a moon (more ambient light)


The sun editor
Editing the sun and sky


How to adjust the sun

  • Select the sun in the sky (double click it)
  • Move it by clicking on the middle and dragging it around
  • Change the color by dragging the dot around the outer ring
  • Change the intensity by clicking just outside the outer ring and dragging it

To deselect the sun, double click well outside of the sun editor (Note: the normal Q for "deselect all" isn't working right now)

How to edit the parameters directly

If you have problems clicking it, or would prefer a numeric editor:

  • Press the Y key to open the Scenegraph
  • Expand level to find the Sun parameters


Reflection Capture

Reflection capture objects are used for ambient lighting, reflections, and the color of the fog in each direction.

There are two kinds of reflection capture objects, Global Reflection and Local Reflection. Both can be found under Load -> Lighting. A global reflection capture can be turned into a local one and vice versa by setting its Global script parameter to 1 or not.

Gotchas

Reflection captures are updated when moved, and each new result builds on the results of the previous reflection capture. This can be used to achieve some desired effect, but can also make it harder to get what you want sometimes. Try playing around with changing the brightness of the sky, amount of fog etc. to get different effects.

Certain level shaders will cause an issue where the sky will increase in brightness. To avoid this, disable the level shader temporarily. If the shader is important to include in the reflection capture, you can update it a single time by adjusting its position slightly within the Selected window.

Global reflection

Global reflection captures are used for the entire level, and each level should have exactly one. Since it affects the entire level it is often placed in a location that represents some sort of "average" lighting for the level.

Local reflection

Local reflection captures are used to change what the reflections look like in a specific region of the level. These are useful if there are caves or other types of areas where the ambient lighting changes significantly from the rest of the level. Move, rotate and scale the object to decide what part of the level should be affected.

Point lights

Point lights allow you to cast omni-directional light from a point in the level.

Adding and editing point lights

Adding a dynamic light:

  • Top Bar -> Load -> Lighting -> Dynamic Light
  • The cursor will turn into a plus symbol
  • Click in level to place the dynamic light

Changing the size of a dynamic light

  • Select the light - double click
  • Hold E while clicking and dragging on its bounding box.

Note that this only changes the light's area of influence, not how much light it outputs.

Making a dynamic light brighter

  • Select the light - double click
  • Open the color picker - Ctrl + P (Command + P on mac)
  • Change the Overbright setting

Adjusting dynamic light color:

  • Select the light
  • Hit CTRL + P (command + P on mac) to open the Color Picker.
  • Adjust the color with the color selector, or RGB at the bottom.

Shaping the dynamic light

Dynamic lights are always spherical right now. If you need an "area light" effect that isn't a sphere, there are a few options:

  • Use Shadow Decals to shape the light (you have to enable this in the level first. See this section below)
  • Place multiple dynamic light objects
  • Some combination of both of the above

Be careful to both look at how the lights affect static objects in the scene, and how they affect characters that walk through them.


Shadow decals

Shadows from sunlight are taken care of automatically.

However this only allows one level of shadowing. This doesn't handle ambient occlusion (shadowing of indirect light reflections).

Shadow decals ("Ambient Shadows") allow you to manually place decals which simulate this ambient occlusion effect.
This can help you visually anchor objects more realistically in the scene, and replicate effects like darkening around corners, and inside cubbyholes.


Adding and editing ambient shadows

Ambient Shadow Decals's effect on light


Adding a shadow decal:

  • Top Bar -> Load -> Lighting -> Ambient Shadow.
  • The cursor will turn into a plus symbol.
  • Now click in level to place the ambient shadow decal.

Resizing a shadow decal:

Double click the ambient shadow decal, and hold E while clicking and dragging on its bounding box (or while shift + right-clicking and dragging on a side to only stretch in that direction).
This will let you increase the spread of its effect.

Note: Ambient shadow decals will not create shadows if they in direct light. This is because they're for simulating indirect shadowing. Direct shadowing is already handled by placing objects in the world.


Dynamic lights and shadows

By default, no objects cast shadows from dynamic point lights (besides the sun). This is for performance reasons.

Normally ambient shadow decals also will not create shadow from dynamic point lights, because that would be shading direct light, and they don't work that way.

However you can use the #SHADOW_POINT_LIGHTS level Custom Shader to make it so shadow decals can shape point lights, so you can manually simulate this shadowing.


without #SHADOW_POINT_LIGHTS #SHADOW_POINT_LIGHTS Custom Shader setting with #SHADOW_POINT_LIGHTS


Making shadow decals affect dynamic lights:

  • Hit Y to open the level's scenegraph
  • Expand Script Params
  • Add a Custom Shader param
  • Hit Enter (not tab!)
  • Type #SHADOW_POINT_LIGHTS in the value column and hit enter

This will make ambient shadows affect the direct light from dynamic lights, an let you sculpt the light they cast, or let you create manual shadows.