Vixen
02b45cc4
csharp
public static class MaterialCompiler

Turns an authored MaterialDescriptor into the Material a render feature draws with.

Read the guide page for this →

Remarks

The whole of what a material system does, in one function: a list of features becomes a ShaderComposition that selects the shaders implementing them, and their values become a ParameterCollection keyed by the names those shaders will have once composed. From there it is the existing machinery — the composition goes into the effect key, the key resolves to an effect, the effect's layout writes the parameters.

No compiler runs here, and that is the design. The names are predicted from Raven's qualification rule rather than read out of a compiled shader, so a material can be authored and serialised on a machine that has never compiled one — and a shipping build, which must not link the compiler at all, can still build the key that finds the baked effect. What keeps the prediction honest is the checked-in reflection: see MaterialReflectionTests, which holds this against what Raven actually emits.

Every slot the library declares is bound, whether the material uses it or not. Raven rejects a compilation with an unfilled slot wherever it is declared (RVN2073), which is right — a slot with no implementation is a shader that cannot be emitted — and it means a complete composition is one that answers for the whole library rather than only for the shaders this material reaches. The unused ones take IdentitySurface, whose contribution is nothing.

Fields and properties (19)

  • public const string DefaultShadingShader

    The shading model a compilation gets where nothing chose one.

  • public const string IdentityShader

    The shader that fills a slot nothing else does.

  • public const string EmptyFieldShader

    The shader that fills a distance-field slot for a project that traces nothing.

  • public const string EmptyIrradianceShader

    The shader that fills an irradiance slot for a project with no field.

  • public const string EmptyPunctualShadowShader

    The shader that fills a punctual-shadow slot for a frame with no atlas.

  • public const string EmptyDirectionalShadowShader

    What fills directionalShadow where a project renders no virtual shadow map.

  • public const string PunctualShadowShader

    The shader that fills it by sampling PunctualShadowRenderer's atlas.

  • public const string VirtualShadowShader

    The shader that fills directionalShadow by sampling phase 7's virtual map.

  • public const string EmptySurfaceCacheShader

    The shader that fills a surface-cache slot for a project with no cache — every hit answers black, which is every tracer's answer before doc 19 § L4 existed.

  • public const string SurfaceCacheShader

    The shader that fills a surface-cache slot by sampling § L4's card atlas.

  • public const string RayQueryFieldShader

    The shader that fills a distance-field slot with doc 19 § L6's hardware tracer — a ray query against the scene's acceleration structure, behind HasRayTracing.

  • public const string EmptyReflectionMissShader

    The shader that fills a reflection-miss slot for a project with no far field at all — black, the answer of a scene with neither probes nor sky.

  • public const string SkyReflectionMissShader

    The shader that fills a reflection-miss slot with one colour of sky — what every reflection in doc 06 sees beyond the probes today. The probe-backed implementation replaces it without the kernel changing, which is the slot's point.

  • public const string IrradianceFieldShader

    The shader that fills an irradiance slot by reading doc 19 § L2's field.

  • public const string ChainShader

    The chain a material's features are composed through.

  • public const string ForwardIrradianceSlot

    The forward pass's irradiance slot, qualified — what a project overrides to turn GI on.

  • public const string ForwardDistanceFieldSlot

    The forward pass's distance-field slot, qualified — what turns ambient occlusion on.

  • public const string ForwardPunctualShadowSlot

    The forward pass's punctual-shadow slot, qualified — what stops a lamp at a wall.

  • public const string ForwardDirectionalShadowSlot

    The forward pass's directional-shadow slot, qualified — what puts phase 7's map behind the sun.

Methods (4)

  • public static ShaderComposition PassComposition(string slot, string filler)

    A pass's composition, with every slot it did not name filled by its default.

  • public static ShaderComposition PassComposition(params ReadOnlySpan<(string Slot, string Filler)> overrides)

    The same composition, for a pass that cares about several slots.

  • public static ShaderComposition PassComposition()

    Every slot filled by its default, for a pass that composes none of them.

  • public static MaterialCompilation Compile(MaterialDescriptor descriptor, IReadOnlyDictionary<string, string>? slots = null)

    Compiles a descriptor, or reports why it cannot be.

Used by (51, showing 40)

  • ArenaThirdPersonShooter
  • ArenaIlluminationThirdPersonShooter
  • DevelopmentEffectsThirdPersonShooter
  • AccelerationStructureDeviceTestsVixen.Graphics.Golden.Tests
  • AssetMaterialSourceVixen.Engine.Renderer
  • ClusteredShadingDeviceTestsVixen.Graphics.Golden.Tests
  • ComposeSlotInventoryTestsVixen.Rendering.Tests
  • ComputeRendererVixen.Rendering
  • DistanceFieldAoRendererVixen.Rendering.PostFx
  • DistanceFieldDeviceTestsVixen.Graphics.Golden.Tests
  • ForwardFrameTestsVixen.Rendering.Tests
  • FullScreenRendererVixen.Rendering
  • GpuClusterRasterVixen.Rendering
  • GpuClusterSoftwareRasterVixen.Rendering
  • GpuClusterVisibilityVixen.Rendering
  • GpuCullingVixen.Rendering
  • GpuDrawArgumentsVixen.Rendering
  • GpuVisibilityTilesVixen.Rendering
  • HiZPyramidVixen.Rendering
  • IndirectDiffuseRendererVixen.Rendering.PostFx
  • IrradianceBounceDeviceTestsVixen.Graphics.Golden.Tests
  • IrradianceFieldFillVixen.Rendering
  • IrradianceFieldRendererVixen.Rendering
  • IrradianceFieldRepairVixen.Rendering
  • IrradianceShadingDeviceTestsVixen.Graphics.Golden.Tests
  • MaterialCompilerTestsVixen.Rendering.Tests
  • MaterialContentVixen.Rendering
  • MaterialReflectionTestsVixen.Rendering.Tests
  • MaterialRenderFeatureVixen.Rendering
  • ParticleSpriteMaterialVixen.Rendering
  • ReflectionRendererDeviceTestsVixen.Graphics.Golden.Tests
  • ReflectionTraceDeviceTestsVixen.Graphics.Golden.Tests
  • ReflectionTraceFillVixen.Rendering
  • ScreenProbeAccumulateFillVixen.Rendering
  • ScreenProbeFilterFillVixen.Rendering
  • ScreenProbeResolveVixen.Rendering
  • ScreenProbeTraceDeviceTestsVixen.Graphics.Golden.Tests
  • ScreenProbeTraceFillVixen.Rendering
  • ScreenProbeUpsampleCompileTestsVixen.Graphics.Golden.Tests
  • ScreenProbeUpsampleRendererVixen.Rendering.PostFx