Update custom pass to global custom pass

This commit is contained in:
Misaki
2024-10-23 20:15:07 +09:00
parent e441bb7911
commit d0554a73bb
64 changed files with 949 additions and 46128 deletions

View File

@@ -2,7 +2,6 @@ using System;
using UnityEditor;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
namespace Unity.Toonshader
{
@@ -10,8 +9,7 @@ namespace Unity.Toonshader
public class UTSRenderer : VolumeComponent
{
// flags
bool m_initialized = false;
bool m_srpCallbackInitialized = false;
bool _initialized = false;
const int kAdjustmentCurvePrecision = 128;
@@ -24,12 +22,12 @@ namespace Unity.Toonshader
const string kIgnoreVolumeExposurePropName = "_ToonIgnoreExposureMultiplier";
[SerializeField]
internal float[] m_ExposureArray;
internal float[] _ExposureArray;
[SerializeField]
internal float m_Max, m_Min;
internal float _Max, _Min;
CustomPassVolume customPassVolume = new();
UTSOutlinePass outlinePass = new();
//CustomPassVolume customPassVolume = new();
//UTSOutlinePass outlinePass = new();
#if UNITY_EDITOR
#pragma warning restore CS0414
@@ -89,7 +87,7 @@ namespace Unity.Toonshader
Initialize();
if (!m_initialized)
if (!_initialized)
{
return;
}
@@ -100,20 +98,20 @@ namespace Unity.Toonshader
if (curve == null || curve.length == 0)
{
m_Min = 0f;
m_Max = 0f;
_Min = 0f;
_Max = 0f;
for (var i = 0; i < kAdjustmentCurvePrecision; i++)
m_ExposureArray[i] = 0.0f;
_ExposureArray[i] = 0.0f;
}
else
{
m_Min = curve[0].time;
m_Max = curve[curve.length - 1].time;
var step = (m_Max - m_Min) / (kAdjustmentCurvePrecision - 1f);
_Min = curve[0].time;
_Max = curve[curve.length - 1].time;
var step = (_Max - _Min) / (kAdjustmentCurvePrecision - 1f);
for (var i = 0; i < kAdjustmentCurvePrecision; i++)
m_ExposureArray[i] = curve.Evaluate(m_Min + step * i);
_ExposureArray[i] = curve.Evaluate(_Min + step * i);
}
@@ -132,9 +130,9 @@ namespace Unity.Toonshader
m_isCompiling = false;
}
#endif
Shader.SetGlobalFloatArray(kExposureArrayPropName, m_ExposureArray);
Shader.SetGlobalFloat(kExposureMinPropName, m_Min);
Shader.SetGlobalFloat(kExposureMaxPropName, m_Max);
Shader.SetGlobalFloatArray(kExposureArrayPropName, _ExposureArray);
Shader.SetGlobalFloat(kExposureMinPropName, _Min);
Shader.SetGlobalFloat(kExposureMaxPropName, _Max);
Shader.SetGlobalInt(kExposureAdjustmentPropName, toonEVAdjustment.value ? 1 : 0);
Shader.SetGlobalInt(kToonLightFilterPropName, lightIntensityLimiter.value ? 1 : 0);
Shader.SetGlobalInt(kIgnoreVolumeExposurePropName, ignoreVolumeExposure.value ? 1 : 0);
@@ -148,7 +146,7 @@ namespace Unity.Toonshader
void Initialize()
{
if (m_initialized)
if (_initialized)
{
return;
}
@@ -159,12 +157,12 @@ namespace Unity.Toonshader
return;
#endif
if (m_ExposureArray == null || m_ExposureArray.Length != kAdjustmentCurvePrecision)
if (_ExposureArray == null || _ExposureArray.Length != kAdjustmentCurvePrecision)
{
m_ExposureArray = new float[kAdjustmentCurvePrecision];
_ExposureArray = new float[kAdjustmentCurvePrecision];
}
m_initialized = true;
_initialized = true;
}
protected override void OnDestroy()
@@ -173,11 +171,11 @@ namespace Unity.Toonshader
Release();
}
void Release()
new void Release()
{
if (m_initialized)
if (_initialized)
{
m_ExposureArray = null;
_ExposureArray = null;
Shader.SetGlobalFloat(kExposureMinPropName, 0);
Shader.SetGlobalFloat(kExposureMaxPropName, 0);
Shader.SetGlobalInt(kExposureAdjustmentPropName, 0);
@@ -186,8 +184,8 @@ namespace Unity.Toonshader
Shader.SetGlobalFloat(kCompensationPropName, 0);
}
m_initialized = false;
_initialized = false;
base.Release();
}
private void Reset()