Instancing Camera Settings

An optional Unity component that affects how a camera renders instances.

Overview

The InstancingCameraSettings component integrates with a Camera component to customize instance rendering settings. By adjusting these settings, you can optimize rendering performance and visual quality for instances within your scene.

Key Features

  • Occlusion Modes: Choose between different occlusion culling methods to optimize rendering.

  • LOD Bias: Adjust the Level of Detail (LOD) bias for finer control over instance rendering.

  • Cross-Fade Animations: Configure cross-fade animation durations for smoother LOD transitions.

  • Instance Rendering Control: Enable or disable instance rendering for the camera.

Enums

InstancingOcclusionMode

Specifies the instancing camera's occlusion mode:

  • None: Don't use occlusion culling.

  • Umbra: Use Unity's CPU-based baked static occlusion system.

  • HierarchicalDepth: Use the GPU-based occlusion system.

CrossFadeAnimatedDurationMode

Specifies the mode for the cross-fade animation duration:

  • Global: Use the global cross-fade animation duration (LODGroup.crossFadeAnimationDuration).

  • Camera: Use a custom cross-fade animation duration for the camera.

Properties

  • OcclusionMode: Gets or sets the occlusion mode for this camera.

  • MinimumScreenSize: Gets or sets the minimum screen size for culling instance renderers.

  • DisableInstanceRendering: Gets or sets whether instancing is enabled for this camera.

  • LODBiasScale: Gets or sets the LOD bias for this camera.

  • CrossFadeAnimatedDurationMode: Gets or sets the cross-fade animation mode for this camera.

  • CrossFadeAnimatedDuration: Gets or sets the cross-fade animation duration for this camera.

Example Usage

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

using UnityEngine;
using MA.Flora;

public class CameraSettingsExample : MonoBehaviour
{
    public InstancingCameraSettings cameraSettings;

    void Start()
    {
        // Set the occlusion mode to GPU Hi-Z
        cameraSettings.OcclusionMode = InstancingOcclusionMode.HierarchicalDepth;

        // Set the minimum screen size for culling
        cameraSettings.MinimumScreenSize = 0.0001f;

        // Enable instance rendering for this camera
        cameraSettings.DisableInstanceRendering = false;

        // Set the LOD bias scale
        cameraSettings.LODBiasScale = 1.5f;

        // Use a custom cross-fade animation duration
        cameraSettings.CrossFadeAnimatedDurationMode = CrossFadeAnimatedDurationMode.Camera;
        cameraSettings.CrossFadeAnimatedDuration = 0.5f;
    }
}

By using the InstancingCameraSettings component, you can optimize instance rendering for specific cameras in your scene, ensuring efficient use of resources and high visual quality.

Last updated