Vixen
02b45cc4
csharp
public sealed class IrradianceFieldTexture

The GPU's copy of an IrradianceField: four pool volumes and an index.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

The field itself references no device, and this is why. Everything about what a field says — the brick layout, the borders, the dilation, the refinement, the filler — is arithmetic with closed-form answers, and it lives in an assembly that could not open a device if it wanted to. What is left over is this: allocate, pack, stage, copy, and name. The same split as GlobalDistanceFieldTexture, for the same reason.

Four volumes for a payload of fourteen numbers, not six. The constant term takes three channels and validity rides in its fourth; each colour channel's three linear coefficients take a volume, and the sun's shadow rides in the red one's fourth. Two more textures for two scalars would be two more fetches at every shaded pixel for numbers that fit in alpha channels nothing else wanted.

A texture per coefficient set rather than one atlas, because a three-dimensional texture cannot be an array layer — the same constraint that makes the distance-field clipmap a texture per level.

The index volume is point sampled and always half-precision. Interpolating two slot indices gives a third that means nothing, so it never filters — which removes the only reason to want the wider format. What it holds is a pool origin in texels and a brick size in cells, and half represents integers exactly to 2048, well past what a pool that fits in memory can reach. Upload refuses a pool larger than that rather than storing a texel origin that rounds.

Fields and properties (10)

  • public IrradianceField Field

    The field this mirrors.

  • public bool IsCreated

    Whether the textures exist yet.

  • public int Uploads

    How many times the whole field has been copied up.

  • public SamplerHandle Sampler

    How the pool volumes are sampled.

  • public SamplerHandle PointSampler

    How the index volume is sampled.

  • public PixelFormat Format

    What each pool sample is stored as. Fixed once the textures exist.

  • public bool PoolIsWritten

    Whether a compute shader writes the pool instead of this copying it up.

  • public TextureHandle Indirection

    The index volume.

  • public TextureViewHandle IndirectionView

    The index volume's view.

  • public const ResourceState PoolIsBeingWritten

    What the pool is in while a dispatch owns it — writable, and readable by the next one.

Methods (14)

  • public IrradianceFieldTexture(IrradianceField field)

    Mirrors one field.

  • public TextureHandle Pool(int channel)

    One of the four pool volumes.

  • public TextureViewHandle PoolView(int channel)

    One pool volume's view, which is what a descriptor actually holds.

  • public void Upload(IGraphicsDevice graphics, ICommandList commands)

    Copies the whole field up, creating the textures if they are not there.

  • public void TransitionPool(ICommandList commands, ResourceState before, ResourceState after)

    Moves the four pool volumes from one state to another, in one barrier.

  • public void OrderPool(ICommandList commands)

    Orders everything written to the pool so far against whatever reads it next.

  • public bool RecordReadback(ICommandList commands)

    Records a copy of the whole pool back into host memory.

  • public bool TryRead(Span<IrradianceProbe> probes)

    Decodes what the last RecordReadback copied.

  • public void Apply(ParameterCollection parameters, string shaderName)

    Writes the names a shader reads the field through.

  • public static string PoolBinding(int channel, string shaderName)

    The shader's name for one of the pool volumes.

  • public static string IndirectionBinding(string shaderName)

    The shader's name for the index volume.

  • public static string SamplerBinding(string shaderName)

    The shader's name for the sampler the pool volumes share.

  • public static string PointSamplerBinding(string shaderName)

    The shader's name for the sampler the index volume uses.

  • public void Dispose()

    Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Used by (12)

  • ArenaIlluminationThirdPersonShooter
  • ForwardFrameTestsVixen.Rendering.Tests
  • IrradianceBounceDeviceTestsVixen.Graphics.Golden.Tests
  • IrradianceFieldFillVixen.Rendering
  • IrradianceFieldRendererVixen.Rendering
  • IrradianceFieldRepairVixen.Rendering
  • IrradianceFieldTextureTestsVixen.Rendering.Tests
  • IrradianceFillDeviceTestsVixen.Graphics.Golden.Tests
  • IrradianceRepairDeviceTestsVixen.Graphics.Golden.Tests
  • IrradianceShadingDeviceTestsVixen.Graphics.Golden.Tests
  • ReflectionTraceDeviceTestsVixen.Graphics.Golden.Tests
  • ScreenProbeTraceDeviceTestsVixen.Graphics.Golden.Tests