MaterialAsset

PBR Metallic-Roughness material (glTF 2.0 default model). Texture references are optional; when null the corresponding factor is used directly. GetContent builds the descriptor set the renderer binds per submesh.

Properties

BaseColorFactor

(Vector4) { get; set } = new(1f, 1f, 1f, 1f): RGBA base color factor. Multiplied with the base color texture sample if present.

MetallicFactor

(float) { get; set } = 1.0f: Metallic factor in [0,1]. Multiplied with the B channel of the metallic-roughness texture.

RoughnessFactor

(float) { get; set } = 1.0f: Roughness factor in [0,1]. Multiplied with the G channel of the metallic-roughness texture.

EmissiveFactor

(Vector3) { get; set } = new(0f, 0f, 0f): Emissive RGB factor. Multiplied with the emissive texture sample if present.

BaseColorTexture

(AssetReference?) { get; set }: Optional sRGB base color texture.

MetallicRoughnessTexture

(AssetReference?) { get; set }: Optional metallic-roughness texture (B = metallic, G = roughness, linear).

NormalTexture

(AssetReference?) { get; set }: Optional tangent-space normal map.

OcclusionTexture

(AssetReference?) { get; set }: Optional ambient-occlusion texture (R channel, linear).

EmissiveTexture

(AssetReference?) { get; set }: Optional sRGB emissive texture.

Public Methods

InvalidateCacheEntry

public static void InvalidateCacheEntry(Guid assetId)

Removes the cached MaterialResource for assetId and disposes it. Call this when an asset is reimported so the next access rebuilds it.

Parameters:

  • assetId (Guid): Identifier of the material asset.

ClearCache

public static void ClearCache()

Disposes all cached material resources and clears the cache. Call this on Vulkan device teardown.

EvictResourcesFor

public static void EvictResourcesFor(MaterialDescriptorContext context)

Disposes and forgets every resource built against context. Called when a context is disposed, because its descriptor pool dies with it and any cached set allocated from that pool would be dangling.

Parameters:

  • context (MaterialDescriptorContext): The context being torn down.

GetContent

public MaterialResource? GetContent(MaterialDescriptorContext context)

Builds, or returns from cache, the descriptor set bound at set 1 for this material. The returned resource is owned by the cache — do not dispose it.

Parameters:

  • context (MaterialDescriptorContext): The layout, pool and fallback textures shared by all materials.

Returns: MaterialResource?

  • The material's GPU resource, or null when no material is stored under this id.

Load

public static MaterialAsset? Load(Guid assetId)

Reads a material's stored property values from its artifact.

Parameters:

  • assetId (Guid): Identifier of the material asset.

Returns: MaterialAsset?

  • The material, or null when it is unknown or its artifact cannot be read.