Surface Lighting
Overview
All UIBlocks support lighting through the Surface property and can be configured to use one of several surface presets and/or lighting models — see Surface and LightingModel for more details.
Currently only the built-in render pipeline using forward rendering is supported for lighting.
Things to Consider
Real-time lighting is an advanced and complex topic. When a surface reacts to lighting, the final rendered color no longer depends only on the properties of the surface itself, but also on the environment. Consequently, there are many variables and factors that can affect the final output, such as:
- The intensity and color of ambient light
- The intensity, color, and other properties of non-ambient (e.g. directional, point, spot, etc.) lights as well as where the lights are in relation to the object and camera
- The values for the different project lighting settings, whether the project is using linear or gamma color space, etc.
Additionally, there is a delicate balance between performance, quality, and complexity. Depending on the types of devices being targeted, it may not be feasible to get the exact desired outcome while achieving an acceptable frame rate. There are many different approaches to achieve better performance in these scenarios, including lowering the lighting quality settings of the project, using cheaper lighting models that do approximate calculations to get a "good enough" result, reducing the complexity of the scene, etc. There is no "correct" approach, as this depends entirely on the project and specific scenario.
All of this applies equally to lit Nova
content. Achieving a desired style/look may require iteration, testing in the lit environment, and testing on the target device(s) to ensure performance is acceptable.
Configurations
Surface Presets
Nova provides a variety of pre-defined effects for common surfaces:
- Unlit
- Matte
- Plastic
- Rubber
- Glossy
- Brushed Metal
- Polished Metal
In code, these are exposed as static methods on the Surface struct
. For example, setting a UIBlock to use the Rubber
preset would look like:
uiBlock.Surface = Surface.Rubber();
Lighting Models
Nova supports a number of common lighting models:
- Unlit
- Lambert
- Blinn Phong
- Standard
- Standard Specular
A lighting model and its parameters can be configured explicitly. For example, setting a UIBlock to use the BlinnPhong lighting model with Specular and Gloss values of 0.5
would look like:
uiBlock.Surface.BlinnPhong = new BlinnPhong(0.5f, 0.5f);
As the Lambert lighting model does not have additional parameters, setting a UIBlock to use the Lambert
lighting model would simply be:
uiBlock.Surface.LightingModel = LightingModel.Lambert;
Note
By default, Nova
does not include any lit shaders in builds and will prompt you to include a lighting model if it is used in the editor. Lighting models can be marked to be included in builds via the project setting Nova > Rendering > Included Lighting Models
.
Shadows
Casting Shadows
All UIBlocks can cast shadows. This can be enabled or disabled per-UIBlock via the ShadowCastingMode property:
uiBlock.Surface.ShadowCastingMode = ShadowCastingMode.On;
Receiving Shadows
As Unity's built in render pipeline does not support receiving shadows on transparent content, Nova's support for receiving shadows is limited:
Block | Support |
---|---|
UIBlock2D | Not supported. |
TextBlock | Not supported. |
UIBlock3D | Supported on opaque blocks (when the alpha of Color is 1 ) |
uiBlock.Surface.ReceiveShadows = true;