Rust Wiki

Depth Of Field

rust-wiki_dof_header2.jpg

DOF Settings

Enable camera depth of field by using the command dof 1. Use dof 0 to disable it.

Aperture

dof_aper <amount> - Sets the focus range for the camera's depth of field, i.e. the area size which is in focus.

Smaller values produce a wider area of focus, higher values create a narrower focus range.

Blur Amount

dof_blur <amount> - Specifies the amount of blur applied to the out of focus areas.

Decent results can be achieved by matching the blur amount to the aperture, then adjusting from there.

Sample Count

dof_kernel <0-3> - Modifies the sample count for the depth of field's blur to obtain smoother results.

  • 0 = 28 samples (default)
  • 1 = 64 samples
  • 2 = 128 samples
  • 3 = 512 samples

Focus Modes

There are currently three modes for camera depth of field - auto, manual and target focus.

Use the command dof_mode <0-2> to switch between modes. 0 = auto, 1 = manual, 2 = target.

Auto Focus

This is the default mode for depth of field. Focus distance is automatically adjusted to a point of interest being looked at in the centermost part of the screen - e.g. an entity (player, npc, deployable, etc) or a world object.

Auto focus is generally good for achieving quick results, but it's not perfect. For finer control use manual mode.

Manual Focus

Manual mode allows setting focus to a specific distance from the camera by using the focus distance command and adjusting the time it takes to reach that distance by using the focus time command.

Target Focus

Target mode allows the depth of field's focus distance to be locked onto a specified entity or object, either during demo playback or live gameplay. To set a focus target, use one of the following methods:

dof_focus_lookingat - Sets the focus target to the entity which the camera is looking at.

dof_focus_target <entityID> - Sets the focus target to a specified entity ID. Use the command ent_find_radius <number> during demo playback to print out a list of entity names + IDs in a defined radius near the camera's current position.

Be sure to set focus distance to '0' in order for the focus to be locked at the origin of your specified target. The cambone command is also useful for locking focus to a particular bone.

You can also use nudging to offset the focus distance, if desired.

Focus Settings

The following commands are mostly applicable to manual mode:dof_mode 1

Focus Distance

dof_focus_dist <amount> - Distance from camera to focus - measured in units.

Parsing the command without an amount specified will print the current focus distance in the console.

Focus Time

dof_focus_time <amount> - The time it takes (in seconds) to reach a new focus distance. 0 will be an instant change.

Useful for lerping between focus points triggered either by a bind or when nudging the focus distance. This command can also be used in auto mode for smoother focus alterations.

Focus Nudging

dof_nudge <amount> - Incrementally modify the focus distance by a specified amount. Both positive + and negative - values are accepted in the amount parameter, e.g. dof_nudge 1.5 will increase the focus distance by 1.5 units and dof_nudge -1.5 will decrease it by 1.5 units.

Nudging is also useful when applied as a bind. You can pull focus by setting nudge amounts to the mousewheel

Example: bind mousewheelup "dof_nudge 1.5" and bind mousewheeldown "dof_nudge -1.5"

Focus Debug

dof_debug <1/0> - Enable/disable a debug depth pass; a monochromatic display of the current focus settings.

This command is useful for previewing the DOF's focus range and achieving precise focus distances in manual mode.

Black indicates areas in focus, white indicates areas out of focus.

Example:

rust-wiki_dof_debug-preview.jpg