Class RenderMaterial
Namespace: ValveResourceFormat.Renderer.Materials
Assembly: Renderer.dll
Material with shader, textures, and render state for GPU rendering.
public class RenderMaterialInheritance
Constructors
RenderMaterial(Material, RendererContext, Dictionary<string, byte>?)
Initializes a new instance of the class from a parsed material resource, loading its shader and applying render state.
[SetsRequiredMembers]
public RenderMaterial(Material material, RendererContext rendererContext, Dictionary<string, byte>? shaderArguments)Parameters
material Material
The parsed Source 2 material data.
rendererContext RendererContext
The renderer context used to load shaders and textures.
shaderArguments Dictionary<string, byte>?
Optional caller-supplied static combo overrides that take precedence over the material's own arguments.
RenderMaterial(Shader)
Initializes a new instance of the class wrapping an existing shader with an empty material.
[SetsRequiredMembers]
public RenderMaterial(Shader shader)Parameters
shader Shader
The shader to use for rendering.
Fields
PerShaderSortIdRange
The sort ID range allocated per unique shader program, used to group draw calls by shader while preserving random ordering within a group.
public const int PerShaderSortIdRange = 10000Field Value
Properties
DoNotCastShadows
Gets a value indicating whether geometry using this material should be excluded from shadow passes.
public bool DoNotCastShadows { get; }Property Value
IsAlphaTest
Gets a value indicating whether this material uses alpha-to-coverage alpha testing.
public bool IsAlphaTest { get; }Property Value
IsCs2Water
Gets a value indicating whether this material uses the CS2 water rendering path.
public bool IsCs2Water { get; }Property Value
IsOverlay
Gets or sets a value indicating whether this material is rendered as a screen-space or world-space overlay (polygon-offset, no depth write).
public bool IsOverlay { get; set; }Property Value
IsToolsMaterial
Gets a value indicating whether this is a tools-only material that should not appear in normal rendering.
public bool IsToolsMaterial { get; }Property Value
IsTranslucent
Gets a value indicating whether this material uses any blending mode that requires back-to-front ordering.
public bool IsTranslucent { get; }Property Value
Material
Gets the underlying parsed data.
public Material Material { get; }Property Value
Matrices
Gets the map of matrix uniform names to their current values for this material.
public Dictionary<string, Matrix4x4> Matrices { get; }Property Value
Shader
Gets the used to render this material.
public required Shader Shader { get; init; }Property Value
SortId
Gets a value used to bucket this material into draw-call sort bins; derived from the shader program handle and a random offset.
public int SortId { get; }Property Value
Textures
Gets the map of texture uniform names to the bound objects for this material.
public Dictionary<string, RenderTexture> Textures { get; }Property Value
Dictionary<string, RenderTexture>
VertexAnimation
Gets a value indicating whether this material drives vertex animation (foliage or morph-based).
public bool VertexAnimation { get; }Property Value
Methods
LoadRenderState()
Load or reload render state from material data.
public void LoadRenderState()PostRender()
Restores render state and unbinds textures after the draw call for this material has completed.
public void PostRender()Render(Shader?)
Binds textures, sets material uniforms, and applies blend/depth render state for this material.
public void Render(Shader? shader = null)Parameters
shader Shader?
The shader to use for this draw call, or null to use .

