Flora
Flora 6
Flora 6
  • Overview
  • Getting Started
  • Shaders and Materials
  • Tools
  • Rendering
    • Occlusion
  • Requirements
  • Components
    • Instanced Prototype
    • Instanced Mesh Container
    • Instanced Object Link
    • Instanced Terrain Foliage
    • Instancing Camera Settings
    • Instancing Scene Settings
Powered by GitBook
On this page
  • Overview
  • Key Features
  • Enums
  • Properties
  • Static Properties
  • Events
  • Example Usage
  1. Components

Instancing Scene Settings

A component that provides scene-wide configuration settings for instancing.

Overview

The InstancingSceneSettings component is designed to manage global settings that affect how instances are rendered and culled in a scene. These settings include the density of instances and the configuration of the main light for shadow casting.

Key Features

  • Global Instance Density: Control the overall density of instances in the scene.

  • Main Light Configuration: Manage the main light used for rendering shadows, with options for automatic or manual configuration.

  • Singleton: There is only one instance of the settings across all loaded scenes.

Enums

InstancingMainLightMode

Determines how the main light will be chosen for culling shadow casting instances:

  • Auto: Flora will update the main light if its state changes (default).

  • Manual: Flora will not update the main light automatically; it must be set manually.

Properties

  • GlobalInstanceDensity: Gets or sets the density of static instances in the scene. Valid values range from 0.0 to 1.0. Reducing this value can decrease culling work and GPU load, improving performance.

  • MainLightMode: Gets or sets the mode for updating the main light (Auto or Manual).

  • MainLightOverride: Gets or sets the main light used for instancing. Setting this value changes the mode to Manual.

Static Properties

  • Global: Returns the global instance of InstancingSceneSettings. There should be exactly one instance of this component across all loaded scenes.

Events

  • GlobalSceneSettingsChanged: Invoked when the global scene settings change.

Example Usage

Here's an example of how to use the InstancingSceneSettings component in a script:

using UnityEngine;
using MA.Flora;

public class SceneSettingsExample : MonoBehaviour
{
    void Start()
    {
        // Access the global instance of InstancingSceneSettings
        var settings = InstancingSceneSettings.Global;

        // Set the global instance density to 0.5
        settings.GlobalInstanceDensity = 0.5f;

        // Set the main light mode to Manual
        settings.MainLightMode = InstancingMainLightMode.Manual;

        // Set a specific light as the main light override
        settings.MainLightOverride = FindObjectOfType<Light>();
    }
}

By using the InstancingSceneSettings component, you can efficiently manage global instancing settings, ensuring optimal performance and visual quality across your scenes.

PreviousInstancing Camera Settings

Last updated 11 months ago