Skip to content
Physically Based Auto Depth of Field
Share
Explore
Docs

Reference

Our API is built around the main pillars of the asset, providing you a seamless experience with your code.
System Globals
Turn the entire system, on or off
using UnityEngine;
using HIBIKIentertainment.DepthOfField;

public class APITestScript : MonoBehaviour
{
private void Start()
{
TurnDepthOfFieldSystemOnOrOff();
}
public void TurnDepthOfFieldSystemOnOrOff()
{
#if HE_HDRP || HE_URP
//Turns off the system
AutoDepthOfFieldAPI.SetSystemState(false);
//Turns on the system
AutoDepthOfFieldAPI.SetSystemState(true);
#endif

}
}
Remove all Physically Based Auto DoF systems
using UnityEngine;
using HIBIKIentertainment.DepthOfField;

public class APITestScript : MonoBehaviour
{
private void Start()
{
RemovePBDepthOfField();
}
public void RemovePBDepthOfField()
{
#if HE_HDRP || HE_URP
AutoDepthOfFieldAPI.RemoveAllDepthOfFieldComponents();
#endif
}
}
Feature Control
Add Auto Depth of field Volume Override at runtime
using UnityEngine;
using HIBIKIentertainment.DepthOfField;

public class APITestScript : MonoBehaviour
{
private void Start()
{
CreateNewOverrideVolume();
}
public void CreateNewOverrideVolume()
{
#if HE_HDRP
HDRPAutoDepthOfField depthOfField = HDRPAutoDepthOfField.Instance;
#elif HE_URP
URPAutoDepthOfField depthOfField = URPAutoDepthOfField.Instance;
#endif

#if HE_HDRP || HE_URP
if (depthOfField != null)
{
int volumeID = depthOfField.m_volumeDatabase.Count - 1;
volumeID++;
//Creates volume with default
AutoDepthOfFieldAPI.AddVolumeToDatabse(volumeID, AutoDepthOfFieldAPI.CreateOverrideVolume(transform.position, new Vector3(15f, 15f, 15f), transform.eulerAngles));
//Or
//Fill in other settings like preset to load by default, name of the object, the interaction tag and to enable gizmos
AutoDepthOfFieldAPI.AddVolumeToDatabse(volumeID, AutoDepthOfFieldAPI.CreateOverrideVolume(transform.position, new Vector3(15f, 15f, 15f), transform.eulerAngles, "Default", name, "Player", false));
}
#endif
}
}
Create a new Depth of field quality Database and apply it to the system.
using UnityEngine;
using HIBIKIentertainment.DepthOfField;
using UnityEngine.Rendering;

public class APITestScript : MonoBehaviour
{
private void Start()
{
ApplyNewDepthOfFieldQuality();
}
public void ApplyNewDepthOfFieldQuality()
{
#if HE_HDRP || HE_URP
//Creates new quality database
PBDOFConstants.DepthOfFieldQualityData newDOFQuality = new PBDOFConstants.DepthOfFieldQualityData
{
//Sets high quality to true
m_highQualityFilter = new BoolParameter(true, true),
//sets physically based to true (HDRP Only)
m_physicallyBased = new BoolParameter(true, true),
//Sets the quality to high
m_quality = new ClampedIntParameter(2, 0, 2)
};

AutoDepthOfFieldAPI.SetDepthOfFieldQuality(newDOFQuality);
#endif
}
}
Assign a preset to the system
This example just shows you how to set the first preset in the preset list
using UnityEngine;
using HIBIKIentertainment.DepthOfField;

public class APITestScript : MonoBehaviour
{
private void Start()
{
ApplyFirstPreset();
}
public void ApplyFirstPreset()
{
#if HE_HDRP || HE_URP
//Gets all the current presets
string[] presets = AutoDepthOfFieldAPI.GetPresets();
//Checks if there are any
if (presets.Length > 0)
{
///Applies the first preset to the depth of field system
AutoDepthOfFieldAPI.ApplyPreset(AutoDepthOfFieldAPI.GetPreset(presets[0]));
}
#endif
}
}
Debug info
Returns the current volume override data
It will return null if there is no player in any override volume
using UnityEngine;
using HIBIKIentertainment.DepthOfField;

public class APITestScript : MonoBehaviour
{
private void Start()
{
CreateNewOverrideVolume();
}
public void CreateNewOverrideVolume()
{
#if HE_HDRP || HE_URP
HDRPAutoDepthOfField depthOfField = HDRPAutoDepthOfField.Instance;
#elif HE_URP
URPAutoDepthOfField depthOfField = URPAutoDepthOfField.Instance;
#endif

if (depthOfField)
{
//Gets the current volume data that the player is in
PBDOFConstants.DepthOfFieldVolumeData currentVolumeData = AutoDepthOfFieldAPI.GetCurrentVolumeData(depthOfField.m_volumeDatabase);
//Now you can change the settings in this volume data at runtime
}
}
}


Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.