Skip to content

Game.Rendering.ShaderVariablesWind

Assembly:
Unknown (assembly not provided in source file; typically part of the game's runtime assemblies)

Namespace:
Game.Rendering

Type:
internal struct ShaderVariablesWind

Base:
System.ValueType (struct)

Summary:
This internal struct is a C# representation of a shader constant buffer used to pass wind-related data to GPU shaders. It is annotated with Unity's [GenerateHLSL] attribute which instructs the build to generate an HLSL cbuffer with the same layout. The generated cbuffer is emitted with exact packing rules and is bound to constant register 10 (constantRegister = 10). The struct contains four 4x4 matrices (_WindData_0.._WindData_3) commonly used to store wind vectors, transforms, or other 4x4 packed wind parameters. Keep the layout and field order intact — it must match the HLSL side exactly.


Fields

  • public UnityEngine.Matrix4x4 _WindData_0
    Matrix field 0. Part of the generated shader cbuffer. Typically used to store wind vectors/transform data in a 4x4 matrix layout.

  • public UnityEngine.Matrix4x4 _WindData_1
    Matrix field 1. Same usage as above; available to store additional wind parameters.

  • public UnityEngine.Matrix4x4 _WindData_2
    Matrix field 2. Additional storage for wind-related data.

  • public UnityEngine.Matrix4x4 _WindData_3
    Matrix field 3. Additional storage for wind-related data.

Notes on layout and size: each Matrix4x4 is 16 floats (64 bytes). With four matrices the total cbuffer data for this struct is 256 bytes. The GenerateHLSL attribute uses exact packing rules and generateCBuffer = true, so the C# layout is intended to map directly to the GPU constant buffer (register 10).

Properties

  • This struct defines no properties. Fields are public and are the intended means to populate the data.

Constructors

  • public ShaderVariablesWind() (implicit default)
    As a value type (struct), it has an implicit parameterless constructor that initializes all matrices to their default (Identity or zero depending on how Matrix4x4 default is used). No explicit constructors are defined in source.

Methods

  • None defined in the source. This struct is a plain data container intended for interop with generated HLSL.

Usage Example

Example showing how a mod or engine code could populate these matrices and push them to shaders using Unity's global matrix setters. Depending on HDRP/engine rendering code, the real engine may upload the full constant buffer directly; this example demonstrates a simple approach for modding purposes.

// Create and populate the struct
var windVars = new Game.Rendering.ShaderVariablesWind();
windVars._WindData_0 = Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0, Time.time * 10f, 0), Vector3.one);
windVars._WindData_1 = Matrix4x4.Scale(new Vector3(1.0f, 0.5f, 1.0f));
windVars._WindData_2 = Matrix4x4.identity;
windVars._WindData_3 = Matrix4x4.identity;

// Push individual matrices to shader globals (names match the fields generated into HLSL)
Shader.SetGlobalMatrix("_WindData_0", windVars._WindData_0);
Shader.SetGlobalMatrix("_WindData_1", windVars._WindData_1);
Shader.SetGlobalMatrix("_WindData_2", windVars._WindData_2);
Shader.SetGlobalMatrix("_WindData_3", windVars._WindData_3);

// Note: The engine may instead expect a single constant buffer upload to register 10.
// Use the engine's CommandBuffer/Rendering API or generated helper methods to upload the full cbuffer if available.

Additional notes for modders: - Do not change field names or ordering if you intend shaders generated by the build pipeline to interoperate with this struct. - The [GenerateHLSL] parameters: PackingRules.Exact, needAccessors = false, generateCBuffer = true, constantRegister = 10 — indicate exact layout and a dedicated constant register for this cbuffer. If you extend or replicate this layout in custom shaders, ensure the HLSL cbuffer matches exactly. - This type is internal in the game code; use caution when referencing or duplicating it in mods to avoid assembly/internal-access issues.