Class ShaderDataProvider
Namespace: ValveResourceFormat.IO
Assembly: ValveResourceFormat.dll
Provides shader data by querying compiled shader files, with optional fallback to basic hardcoded mappings.
public class ShaderDataProvider : IShaderDataProviderInheritance
object ← ShaderDataProvider
Implements
Constructors
ShaderDataProvider(IFileLoader, bool)
Initializes a new instance of the ShaderDataProvider class.
public ShaderDataProvider(IFileLoader fileLoader, bool useFallback = true)Parameters
fileLoader IFileLoader
The file loader used to load shader files.
useFallback bool
Whether to use the basic provider as a fallback when shader files are unavailable.
Methods
GetBlendState(Material, IReadOnlyDictionary<string, long>?)
Gets the blend state of a material for the default dynamic combo.
public RsBlendStateDesc GetBlendState(Material material, IReadOnlyDictionary<string, long>? combos = null)Parameters
material Material
The material.
combos IReadOnlyDictionary<string, long>?
Integer parameters overriding those of the material, as F_ features or S_ and D_ combos.
Returns
Remarks
Returns the basic provider's guess if available. The blend state compiled into the shader is not used, see ShaderDataProvider.GetCompiledBlendState(Material, IReadOnlyDictionary<string, long>?).
GetCompiledBlendState(Material, IReadOnlyDictionary<string, long>?)
Gets the blend state compiled into the pixel shader render state for the default dynamic combo.
public RsBlendStateDesc? GetCompiledBlendState(Material material, IReadOnlyDictionary<string, long>? combos = null)Parameters
material Material
The material.
combos IReadOnlyDictionary<string, long>?
Integer parameters overriding those of the material, as F_ features or S_ and D_ combos.
Returns
The compiled blend state, or null if the shader or its static combo is not available.
Remarks
This is the state of the pass the combo was compiled for, not how the material blends: deferred shaders compile their GBuffer write state, translucent combos may leave blending off for the pass to set, and alpha tested combos that discard do not enable alpha to coverage.
GetInputsForTexture(string, Material)
Gets the input texture channels and names for a given texture type in a material.
public IEnumerable<(ChannelMapping Channel, string Name)> GetInputsForTexture(string textureType, Material material)Parameters
textureType string
The type of texture to query.
material Material
The material containing the texture.
Returns
IEnumerable<(ChannelMapping Channel, string Name)>
A collection of channel mappings and their corresponding input names.
Remarks
Returns texture inputs for the specified texture type, falling back to basic provider if available.
GetIntAttributes(Material, IReadOnlyDictionary<string, long>?)
Gets the integer attributes of a material combined with those of its shader, the material taking precedence.
public IReadOnlyDictionary<string, long> GetIntAttributes(Material material, IReadOnlyDictionary<string, long>? combos = null)Parameters
material Material
The material.
combos IReadOnlyDictionary<string, long>?
Overrides for the integer parameters of the material.
Returns
IReadOnlyDictionary<string, long>
Remarks
Reads the constant attributes compiled into the pixel shader, falling back to basic provider for the attributes the shader does not compile to a constant.
GetMaterialFeatureState(Material)
Extracts the material feature state from integer parameters.
public static IDictionary<string, byte> GetMaterialFeatureState(Material material)Parameters
material Material
The material to extract feature state from.
Returns
IDictionary<string, byte>
A dictionary of feature names (with 'F_' prefix) and their values.
GetStaticConfiguration_ForFeatureState(VfxProgramData, VfxProgramData, IDictionary<string, byte>, IDictionary<string, byte>?)
Produce a static configuration that fits the material's feature state. This configuration can be used to select one of the static variants contained in the shader file.
public static (int[] StaticConfig, long StaticComboId) GetStaticConfiguration_ForFeatureState(VfxProgramData features, VfxProgramData program, IDictionary<string, byte> featureParams, IDictionary<string, byte>? staticParams = null)Parameters
features VfxProgramData
Features vcs file that contains the feature definitions.
program VfxProgramData
Stage for which the configuration will be generated.
featureParams IDictionary<string, byte>
Feature parameters have the 'F_' prefix.
staticParams IDictionary<string, byte>?
Statics (not tied to a feature) that you want to override. Static parameters have the 'S_' prefix.
Returns
(int[] StaticConfig, long StaticComboId)
A tuple containing the static configuration array and the corresponding static combo identifier.
GetSuffixForInputTexture(string, Material)
Gets the file suffix for a given input texture name.
public string? GetSuffixForInputTexture(string inputName, Material material)Parameters
inputName string
The name of the input texture.
material Material
The material containing the texture.
Returns
string?
The suffix string for the input texture, or null if not found.
Remarks
Returns the filename suffix for the input texture, falling back to basic provider if available.
ResolveStaticConfiguration(VfxProgramData, VfxProgramData, IDictionary<string, byte>, IDictionary<string, byte>?)
Produce the static configuration that a material's feature state selects, reduced by the combo rules when the configuration the features produce was not compiled.
public static (int[] StaticConfig, long StaticComboId) ResolveStaticConfiguration(VfxProgramData features, VfxProgramData program, IDictionary<string, byte> featureParams, IDictionary<string, byte>? staticParams = null)Parameters
features VfxProgramData
Features vcs file that contains the feature definitions.
program VfxProgramData
Stage for which the configuration will be generated.
featureParams IDictionary<string, byte>
Feature parameters have the 'F_' prefix.
staticParams IDictionary<string, byte>?
Statics (not tied to a feature) that you want to override. Static parameters have the 'S_' prefix.
Returns
(int[] StaticConfig, long StaticComboId)
The static configuration and its static combo identifier, which may still be missing from program if reducing did not help.
TryReduceStaticConfiguration(VfxProgramData, int[], out int[])
Removes switches that would point to a non-existent static combo.
public static bool TryReduceStaticConfiguration(VfxProgramData program, int[] staticConfiguration, out int[] reducedConfiguration)Parameters
program VfxProgramData
The file that contains the combos and combo rules.
staticConfiguration int[]
The original static configuration.
reducedConfiguration int[]
The reduced configuration with invalid switches removed.
Returns
bool
True if the configuration was modified, false otherwise.

