What would the process be if I wanted to animate the focal point of the DOF using the new post stack? Similalry do I need a different profile for every camera that I want a different focal distance?
Will the lens distrotion (Barrel Distortion), from the latest Standard Assets package be added to the stack at some point?
In case anyone else is interested, I found the answer here for animating (following a transform) the focal point:
https://forum.unity3d.com/threads/new-post-processing-stack-pre-release.435581/page-2
I’ve taken the code snippet from there, and added a control to focus on a transform. I love these effects, they’re fantastic, but I simply don’t understand why this isn’t simply a component. Every camera is going to need different settings, for the game camera and cutscenes, so the concept of the profiles is flawed. It’s added complexity to something so simple as setting a focal distance on a camera?! If I want a pre-set, I can just make prefab, why do I need profiles as well?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.PostProcessing;
[RequireComponent(typeof(PostProcessingBehaviour))]
public class PostProcessingController : MonoBehaviour {
public bool m_FocusOnTransform = true;
public Transform m_LookAt;
PostProcessingProfile m_Profile;
void OnEnable()
{
var behaviour = GetComponent<PostProcessingBehaviour>();
if (behaviour.profile == null)
{
enabled = false;
return;
}
m_Profile = Instantiate(behaviour.profile);
behaviour.profile = m_Profile;
}
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (m_FocusOnTransform)
FocusOnTransform ();
}
void FocusOnTransform()
{
var dof = m_Profile.depthOfField.settings;
dof.focusDistance = Vector3.Magnitude (this.transform.position - m_LookAt.position);
m_Profile.depthOfField.settings = dof;
}
}
1 Like
Profiles have the benefit of being able to easily tweak graphics settings while in the game, but you raise some good points.