Skip to content

Game.Rendering.BatchData

Assembly: Assembly-CSharp
Namespace: Game.Rendering

Type: struct

Base: System.ValueType

Summary:
BatchData is a compact, blittable data container used by the rendering pipeline to describe a single render batch's mesh, virtual-texture indices and sizing, LOD and shadow-related parameters, and miscellaneous render flags. This struct is intended for high-performance usage (ECS/jobs/Burst) and carries only value types (including Entity) to remain safe for native arrays and job usage. Modders can read and write these fields to control how a particular batch is rendered, but must respect expected ranges and semantics to avoid rendering artifacts or invalid references.


Fields

  • public Entity m_LodMesh
    Reference to the mesh entity used for this batch. This typically points to an entity that holds mesh/LOD data or a shared mesh resource. Do not set to an invalid Entity unless you also handle the render system-side checks.

  • public int m_VTIndex0
    Primary virtual-texture index (or page index) used by the batch. Used by the VT system to select which VT to sample from for material/textures.

  • public int m_VTIndex1
    Secondary virtual-texture index (if the material uses more than one VT). If not used, this is usually zero.

  • public float m_VTSizeFactor
    Scale factor applied to virtual-texture sampling or UV scaling. Values >1 increase sampling/resolution; values <=0 are invalid and should be avoided.

  • public BatchRenderFlags m_RenderFlags
    Bitflags controlling rendering behavior for the batch (e.g., enable/disable instancing, receive shadows, motion vectors, special material tweaks). The exact enum values are defined in BatchRenderFlags; check that enum for flag meanings.

  • public byte m_ShadowCastingMode
    Shadow casting mode encoded as a byte (maps to engine shadow modes such as Off, On, TwoSided, etc.). Use the same numeric mapping the render system expects.

  • public byte m_Layer
    Render layer index (0–255). Used to group or filter batches by layer (lighting, sorting, post processing groups, etc.).

  • public byte m_SubMeshIndex
    Index of the sub-mesh within the mesh to render. Range: 0–255; must be valid for the referenced mesh.

  • public byte m_MinLod
    Minimum LOD index at which this batch becomes valid. Use to prevent rendering this batch below a certain LOD.

  • public byte m_ShadowLod
    LOD index used specifically for shadow rendering. Allows selecting a different LOD for shadows than for the main pass.

  • public byte m_LodIndex
    Current LOD index for this batch. Used by the rendering/LOD systems to select appropriate geometry or material variants.

  • public float m_ShadowArea
    World-space area value used to determine shadowing importance or culling for shadow casters. Larger values generally mean stronger shadow consideration.

  • public float m_ShadowHeight
    Height-related parameter used for shadow projection or biasing. Units are world units; values depend on the scene scale and the shadow system's expectations.

Properties

  • None. This struct exposes only public fields; there are no properties defined.

Constructors

  • public BatchData()
    Implicit parameterless constructor provided by the CLR for structs. For explicit initialization, prefer aggregate initialization or set individual fields to appropriate values before usage. Example: var batch = new BatchData { m_LodMesh = meshEntity, m_VTIndex0 = 0, m_VTIndex1 = 0, m_VTSizeFactor = 1f, m_RenderFlags = BatchRenderFlags.None, m_ShadowCastingMode = 1, m_Layer = 0, m_SubMeshIndex = 0, m_MinLod = 0, m_ShadowLod = 0, m_LodIndex = 0, m_ShadowArea = 0f, m_ShadowHeight = 0f };

Methods

  • None. This is a plain data struct with no instance methods.

Usage Example

// Example: creating and populating a BatchData for use in a NativeArray or component
var batch = new BatchData
{
    m_LodMesh = meshEntity,        // previously obtained Entity for mesh
    m_VTIndex0 = 2,
    m_VTIndex1 = 0,
    m_VTSizeFactor = 1.0f,
    m_RenderFlags = BatchRenderFlags.EnableInstancing | BatchRenderFlags.ReceiveShadows,
    m_ShadowCastingMode = 1,      // follow engine's mapping for shadow modes
    m_Layer = 3,
    m_SubMeshIndex = 0,
    m_MinLod = 0,
    m_ShadowLod = 1,
    m_LodIndex = 0,
    m_ShadowArea = 12.5f,
    m_ShadowHeight = 2.0f
};

// Usage note: BatchData is blittable and suitable for storing in NativeArray<BatchData>
// or used inside ECS components that are processed in jobs. When modifying from jobs,
// ensure you follow concurrency rules (use proper change patterns / dependency handling).

Additional notes for modders: - Keep values valid for the rendering systems: invalid submesh indices, negative VT indices, or wrong entity references may cause missing geometry or rendering errors. - Because this struct is used in performance-critical paths, avoid adding managed references or non-blittable fields. - If you change any render flags or LOD values at runtime, ensure systems that cache derived data are updated or invalidated as needed.