Vixen
02b45cc4
csharp
public readonly record struct MaterialSurface

What a material looks like, reduced to the four numbers a preview can shade with.

Read the guide page for this →

Remarks

A material flattened, and the flattening is the point. A MaterialContent is a feature tree that compiles to a shader variant with a constant buffer and a descriptor set — the thing MaterialRenderFeature draws with, and the thing an editor viewport has no compositor to draw with. This is the same material read for the question a viewport actually asks: what colour is it, how metallic, how rough, does it glow.

⚠ Lossy on purpose, and in one direction only. Textures are not sampled, normal maps and clear coat and sheen are not evaluated, and a shading model that is not the standard one is shaded as though it were. What survives is the metal-roughness workflow, which is what MetalRoughnessFeature and TexturedMetalRoughnessFeature are and what nearly every authored material is. A viewport that showed a red material as red, a metal as metal and a lava as glowing is most of the distance from "one flat grey" to "the game's picture"; the rest of that distance is the compositor's and stays there.

⚠ Default is fully rough and not MetalRoughnessFeature's half-rough default, and the two answer different questions. A feature's default is what a material that has a metal-roughness feature and did not set its roughness means. This one is what an entity naming no material at all means — and a fully rough dielectric shades to one directional term, which is exactly the picture the viewport drew before it could read a material. An entity without a material therefore looks the way it always did.

Fields and properties (7)

  • public Color4 BaseColour

    The albedo, linear.

  • public float Metalness

    How much of a conductor the surface is, 0..1.

  • public float Roughness

    Perceptual roughness, 0..1.

  • public Color3 Emissive

    What it emits on its own, linear, with intensity already folded in.

  • public static MaterialSurface Default

    What an entity naming no material is shaded as: a fully rough dielectric.

  • public const float DielectricF0

    The reflectance a dielectric shows head-on, which every surface here shares.

  • public bool IsEmissive

    Whether this emits any light of its own.

Methods (3)

  • public MaterialSurface(Color4 BaseColour, float Metalness, float Roughness, Color3 Emissive)

    What a material looks like, reduced to the four numbers a preview can shade with.

  • public static MaterialSurface Of(IReadOnlyList<IMaterialFeature>? features)

    The surface a material's features add up to.

  • public static MaterialSurface Of(MaterialContent? content)

    The surface a compiled material is shaded as.

Used by (7)

  • ISurfaceSourceVixen.Rendering
  • MaterialSurfaceTestsVixen.Rendering.Tests
  • MeshInstanceVixen.Rendering
  • ProjectSurfaceSourceVixen.Editor.Assets
  • SceneMaterialTestsVixen.Editor.SceneView.Tests
  • SceneMeshesVixen.Editor.SceneView
  • SurfacesVixen.Editor.SceneView.Tests