FilipeTessaro - Lenscraft: Autofocus, Lens Profiles and Lens Defects

Lenscraft is two components you put on whatever the player looks through: autofocus that does not jump, and a lens. The focus goes into the view itself, after every camera and post process volume, so it works with Camera, Cine Camera, Gameplay Cameras and custom camera managers.

Autofocus

  • Center of the screen, a point of the screen (crosshair, cursor), a subject or one of its bones, or a fixed distance

  • Five rays and the middle distance of the five: a thin post or a branch in front does not pull the focus

  • Traces through foliage and grass: in our test walk through 400 grass blades the focus stayed on the subject in 240 of 240 frames

  • Big changes must last 0.2 s before the focus moves, then it eases there like a focus puller's hand

  • Sequencer cuts and view target changes snap it, with no pull across the cut

  • Tested in the Game Animation Sample (Gameplay Cameras) on 5.6, 5.7 and 5.8

Six built-in lenses

  • Clean 35 mm, 16 mm Film, Anamorphic, Vintage Petzval, Super 8 and Telephoto

  • Each sets blades, cat's eye, swirl and squeeze on the engine's own physical depth of field

  • Make your own as a data asset; Intensity and the look can be keyed in Sequencer

Lens defects, one pass

  • Lateral chromatic aberration, set in pixels at the image corner (measured at 94% of the value asked)

  • Purple and green fringes on the blur, in front of and behind the focus. The engine does not have these

  • Barrel or pincushion distortion, scaled so no border shows

  • Optical vignette, film halation and grain

Cost (1080p, RTX 2070 Super)

  • 0.12 ms for the fringe, 0.06 to 0.09 ms for the lens pass

  • 15 to 31 µs of game thread for the autofocus

Movie Render Queue and Movie Render Graph

  • Grain keeps one pattern per output frame, so temporal samples add up to grain instead of averaging it away

  • Tested with the classic queue, the Movie Render Graph and TSR

In the box

  • Example map: the six lenses on one subject and a sequence that cuts between them

  • Everything open to Blueprint; console commands to try it in any project (Lenscraft.Try)

  • UE 5.6, 5.7 and 5.8. Windows; Linux builds

  • No engine changes, no material to edit

What it does not do: the bokeh shape comes from the engine's depth of field, which must be on (it is by default). Distortion is a single radial term. High resolution tiles in the Movie Render Queue were not tested.

The C++ source ships. Support by email: contato@tessaroapps.com.

PS: Feature requests are accepted!