Files
com.misaki.hdrp-toon/Runtime/UTS Renderer/UTSToonmapping/UTSTonemapping.cs
Misaki eacbbc9b8b Organize folder structure;
Update RimLighting;
2025-02-04 21:21:44 +09:00

47 lines
1.5 KiB
C#

using System;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
[Serializable, VolumeComponentMenu("Post-processing/UTS Tonemapping")]
public sealed class UTSTonemapping : CustomPostProcessVolumeComponent, IPostProcessComponent
{
[Tooltip("Controls the intensity of the effect.")]
public BoolParameter state = new BoolParameter(false, BoolParameter.DisplayType.EnumPopup);
private Material _material;
public bool IsActive() => _material != null && state.value;
public override CustomPostProcessInjectionPoint injectionPoint => CustomPostProcessInjectionPoint.AfterPostProcess;
const string Shader_Name = "Hidden/Shader/UTSTonemapping";
public override void Setup()
{
if (Shader.Find(Shader_Name) != null)
{
_material = CoreUtils.CreateEngineMaterial(Shader_Name);
}
else
{
Debug.LogError($"Unable to find shader '{Shader_Name}'. Post Process Volume UTSToonmapping is unable to load. To fix this, please edit the 'kShaderName' constant in UTSToonmapping.cs or change the name of your custom post process shader.");
}
}
public override void Render(CommandBuffer cmd, HDCamera camera, RTHandle source, RTHandle destination)
{
if (_material == null || !state.value)
{
return;
}
_material.SetTexture("_MainTex", source);
HDUtils.DrawFullScreen(cmd, _material, destination);
}
public override void Cleanup()
{
CoreUtils.Destroy(_material);
}
}