BRG Prototype Group
A ScriptableObject that groups prototypes for shared LOD bias, density, and shadow culling control. Assign one to the Prototype Group field on BRG Prototype Extra Data for each prefab you want to control together — then call the setters on the group to update every member at once.
The group's values split into two categories:
- Runtime-only (
lodBias,density,forceDisableShadows) — not serialized. They reset to their defaults at the start of every session, so re-apply them from your settings or bootstrap script if you need non-default values. - Authored (the shadow culling fields) — serialized on the asset and persist normally. Edit them in the inspector, or override them at runtime with the matching setters.
Create
Right-click in the Project window: Create > BRG Instanced Renderer > Prototype Group.
Public API
public class BRGPrototypeGroup : ScriptableObject
{
// runtime-only (not serialized, reset each session)
public float lodBias; // default 1
public float density; // default 1
public bool forceDisableShadows; // default false
// authored (serialized on the asset)
public bool useImproperShadowFrustumCulling; // default false
public float improperShadowFrustumPadding; // default 10
public bool useShadowCasterDistanceCulling; // default false
public bool useSceneShadowDistance; // default true
public float maxShadowDistance; // default 80
public void SetLodBias(float value);
public void SetDensity(float value);
public void SetShadowsEnabled(bool enabled);
public void SetImproperShadowFrustumCulling(bool enabled, float? padding = null);
public void SetShadowCasterDistanceCulling(bool enabled);
public void SetMaxShadowDistance(float distance, bool useScene = false);
}
SetLodBias
public void SetLodBias(float value)
Set the LOD bias for every prototype in this group. Clamped to >= 0. Default is 1.
> 1holds finer LODs to greater distances (higher quality, more cost).< 1drops to coarser LODs sooner (lower quality, cheaper).1= no change relative to the global / per-camera bias.
Composes multiplicatively with the existing LOD bias chain:
Effective LOD Bias = QualitySettings.lodBias × BRGCameraSettings.lodBiasMultiplier × group.lodBias
Applies to camera LOD selection, shadow LOD selection, and animated-crossfade LOD selection consistently.
// hold finer LODs at distance for hero foliage
heroFoliageGroup.SetLodBias(2f);
// drop to coarser LODs sooner for distant filler
fillerGroup.SetLodBias(0.5f);
SetDensity
public void SetDensity(float value)
Set the density scale for every prototype in this group. Clamped to 0–1. Default is 1.
1= full density (no instances culled).0= all instances culled.- Values in between cull a stable, hash-determined subset so the same instances drop out consistently from frame to frame.
// thin grass to 50% on Low quality
grassGroup.SetDensity(0.5f);
// restore full grass density on Ultra
grassGroup.SetDensity(1f);
A prototype is affected by density simply by belonging to a group whose density has been set below 1. There is no per-prototype "enable" checkbox.
SetShadowsEnabled
public void SetShadowsEnabled(bool enabled)
Toggle shadow casting for every prototype in this group. When re-enabled, prototypes go back to following their own source shadow casting mode.
Use this to build a graphics-quality toggle for shadow casters — for example, a "Grass Shadows" option that turns off shadow casting on all grass prototypes on Low quality without touching the prefabs themselves.
// disable grass shadows on Low quality
grassGroup.SetShadowsEnabled(false);
// re-enable them on High
grassGroup.SetShadowsEnabled(true);
Note
This triggers a batch rebuild, so use it for infrequent changes (a settings menu) rather than per frame.
Shadow Culling
Beyond fully disabling shadows, a group can cull shadow casters that are unlikely to contribute anything visible. These are lossy optimizations — they trade some shadow correctness for a significant cut in shadow culling and rasterization work, and are best suited to prototypes that cast short shadows (grass, small props, debris).
For lossless shadow culling that never drops a visible shadow, see Shadow Caster Occlusion on the Culling Config instead.
Unlike LOD bias and density, these settings are authored on the asset and persist between sessions. Edit them in the inspector, or drive them at runtime with the setters below.
Inspector Properties
| Property | Type | Default | Description |
|---|---|---|---|
| Use Improper Shadow Frustum Culling | bool | false | Drop shadow casters in this group once their bounds leave the camera frustum. Lossy — geometry outside the view stops casting shadows into it, most visible at low sun angles and when the camera rotates quickly. |
| Improper Shadow Frustum Padding | float (≥ 0) | 10m | Metres each camera frustum plane is pushed outward before the test, so casters just off-screen still cast. Raise this if shadows pop in at the screen edge. |
| Use Shadow Caster Distance Culling | bool | false | Stop prototypes in this group casting shadows past a distance from the camera. Also drops casters beyond that distance whose shadows would still reach into view, so very long shadows from far geometry disappear. |
| Use Scene Shadow Distance | bool | true | Take the distance from what the pipeline actually renders shadows to, instead of Max Shadow Distance below. Tracks the project's shadow settings, so it never goes stale. |
| Max Shadow Distance | float (≥ 0.01) | 80m | Explicit maximum shadow distance for every prototype in this group. Only used when Use Scene Shadow Distance is off. |
SetImproperShadowFrustumCulling
public void SetImproperShadowFrustumCulling(bool enabled, float? padding = null)
Enable or disable frustum-based shadow caster culling for the group. The optional padding is only written when supplied, so toggling the feature off and back on preserves the authored padding value. Applies live.
// enable with the authored padding
grassGroup.SetImproperShadowFrustumCulling(true);
// enable and widen the padding to 25m
grassGroup.SetImproperShadowFrustumCulling(true, 25f);
SetShadowCasterDistanceCulling
public void SetShadowCasterDistanceCulling(bool enabled)
Turn distance-based shadow caster culling on or off, leaving the authored distance and the scene-distance choice untouched.
grassGroup.SetShadowCasterDistanceCulling(true);
Note
This re-derives every active chunk — use it for infrequent changes (a settings menu), not per frame.
SetMaxShadowDistance
public void SetMaxShadowDistance(float distance, bool useScene = false)
Set an explicit shadow caster distance in metres and stop following the scene shadow distance. Pass useScene: true to follow the pipeline's shadow distance instead, in which case distance is ignored. Enables distance culling either way.
// explicit 40m cutoff
grassGroup.SetMaxShadowDistance(40f);
// follow the project's shadow distance instead
grassGroup.SetMaxShadowDistance(0f, useScene: true);
Usage Pattern
- Create one group asset per logical bucket you want to control (e.g.
Grass,Trees,SmallProps,HeroFoliage). - Assign each group to the relevant prefabs via the Prototype Group field on BRG Prototype Extra Data.
- From a settings / bootstrap script, call
SetLodBias()andSetDensity()on each group to apply the user's quality preferences.
public class GraphicsSettings : MonoBehaviour
{
public BRGPrototypeGroup grass;
public BRGPrototypeGroup trees;
public void ApplyQuality(QualityLevel level)
{
grass.SetDensity(level == QualityLevel.Low ? 0.4f : 1f);
grass.SetShadowsEnabled(level != QualityLevel.Low);
trees.SetLodBias(level == QualityLevel.Ultra ? 1.5f : 1f);
}
}
Notes
- LOD bias, density, and the shadows-enabled toggle are not serialized. They reset every session — your game / settings code is responsible for re-applying them after each play-mode entry or build launch. The shadow culling fields are authored on the asset and do persist.
- Setting a value before
BRGRendereris initialized is safe — the value lives on the group and is read when prototypes register. SetShadowsEnabled,SetShadowCasterDistanceCulling, andSetMaxShadowDistanceeach trigger a rebuild or re-derive of active chunks. Call them on quality-setting changes, not per frame.- Multiple prototypes can reference the same group; one
Set*call updates every member live. - LOD bias currently scales LOD screen-size thresholds. It does not rescale the separate distance-density ramp on BRG Prototype Extra Data / Density — those start/end distances stay fixed.
- Baked BRG Instance Group assets carry the group reference through the bake. Assets baked before this feature existed should be re-baked to pick up group support.