Vixen
02b45cc4
csharp
public sealed class DepthOfFieldRenderer

Defocus, taken from the lens the frame is exposed through.

Read the guide page for this →

Remarks

Every number here comes off the view's Camera, and that is the point. A lens has one aperture: opening it brightens the image and shortens the depth of field together. Both Unreal and HDRP offer a physical camera mode for the same reason, and both also offer a manual one — this has only the physical, because the manual one is what lets an author write a camera that cannot exist and then wonder why the blur and the brightness disagree.

⚠ A frame with no lens is a frame with no defocus, not a frame with a default one. `Camera.HasLens` false, or a focus distance of zero, leaves every pixel sharp — which is what focusing at infinity means and what a project that has not asked for this should get.

⚠ It runs before the tonemap. Defocus is the lens spreading light across the sensor, which is scene-referred: a blurred highlight has to keep its energy so that averaging it with a dark neighbour gives the bright smear a lens gives, and after the curve it would give a grey one. It also has to run before !Bloom reads the image, or the glow is built from highlights the lens never focused there.

Fields and properties (6)

  • public required string Source

    The scene colour it defocuses.

  • public required string Depth

    The depth every pixel's distance is read from.

  • public RenderView? View

    The view whose camera carries the lens.

  • public int Samples

    How many samples the disc is gathered with.

  • public bool UseBladeShape

    Whether the bokeh takes the diaphragm's polygon rather than a circle.

  • public float MaximumRadius

    How wide the blur may get, in pixels.

Methods (3)

Used by (2)

  • PostEffectFactoryVixen.Rendering.PostFx
  • PostEffectTestsVixen.Rendering.PostFx.Tests