Rasagar/Library/PackageCache/com.unity.render-pipelines.high-definition/Editor/PostProcessing/Templates/CustomPostProcessingVolume.template
2024-08-26 23:07:20 +03:00

44 lines
1.7 KiB
Plaintext

using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
using System;
[Serializable, VolumeComponentMenu("Post-processing/Custom/#NAME#")]
public sealed class #SCRIPTNAME# : CustomPostProcessVolumeComponent, IPostProcessComponent
{
[Tooltip("Controls the intensity of the effect.")]
public ClampedFloatParameter intensity = new ClampedFloatParameter(0f, 0f, 1f);
Material m_Material;
public bool IsActive() => m_Material != null && intensity.value > 0f;
// Do not forget to add this post process in the Custom Post Process Orders list (Project Settings > Graphics > HDRP Global Settings).
public override CustomPostProcessInjectionPoint injectionPoint => CustomPostProcessInjectionPoint.AfterPostProcess;
const string kShaderName = "Hidden/Shader/#SCRIPTNAME#";
public override void Setup()
{
if (Shader.Find(kShaderName) != null)
m_Material = new Material(Shader.Find(kShaderName));
else
Debug.LogError($"Unable to find shader '{kShaderName}'. Post Process Volume #NAME# is unable to load. To fix this, please edit the 'kShaderName' constant in #NAME#.cs or change the name of your custom post process shader.");
}
public override void Render(CommandBuffer cmd, HDCamera camera, RTHandle source, RTHandle destination)
{
if (m_Material == null)
return;
m_Material.SetFloat("_Intensity", intensity.value);
m_Material.SetTexture("_MainTex", source);
HDUtils.DrawFullScreen(cmd, m_Material, destination, shaderPassId: 0);
}
public override void Cleanup()
{
CoreUtils.Destroy(m_Material);
}
}