Adventure Creator Wikia

Post Processing Stack v1

This script updates the active post-processing profile with the AC-calculated depth-of-field focus distance.

To use:

  1. Download and install Unity's Post Processing Stack asset here
  2. Attach the Post Processing Behaviour component to AC's MainCamera, and enable Depth Of Field in the profile
  3. Attach the script below to the MainCamera as well

CopyDOF.cs:

using UnityEngine;
using UnityEngine.PostProcessing;
using AC;

public class CopyDOF : MonoBehaviour
{

    public float fStop = 2f;
    private PostProcessingProfile profile;

    private void Start ()
    {
        profile = GetComponent <PostProcessingBehaviour>().profile;
    }


    private void Update ()
    {
        DepthOfFieldModel.Settings dofSettings = profile.depthOfField.settings;
        dofSettings.focusDistance = KickStarter.mainCamera.GetFocalDistance ();
        dofSettings.aperture = fStop;
        dofSettings.useCameraFov = true;
        profile.depthOfField.settings = dofSettings;
    }

}

Post Processing Stack v2

To use:

  1. Download and install Unity's Post Processing Stack v2 asset from Github here (Note: Installing via package currently causes problems)
  2. Attach the Post Processing Layer component to AC's MainCamera, and add a global Post Processing Volume in the scene that the MainCamera makes use of
  3. Add a Depth Of Field effect to the Post Processing Volume and override the Focus Distance property
  4. Attach the script below to the same GameObject and assign the Profile field

CopyDOFv2.cs:

using UnityEngine;
using UnityEngine.Rendering.PostProcessing;
using AC;

public class CopyDOFv2 : MonoBehaviour
{

    [SerializeField] private PostProcessProfile profile;


    private void Update ()
    {
        DepthOfField dofSettings = profile.GetSetting <DepthOfField>();
        dofSettings.focusDistance.value = KickStarter.mainCamera.GetFocalDistance ();
    }
    
}