This commit is contained in:
CortexCore
2023-10-20 19:31:12 +08:00
parent 5cd094ed9a
commit a160813262
1878 changed files with 630581 additions and 4485 deletions

View File

@@ -0,0 +1,21 @@
{
"name": "MK.Glow.URP.Editor",
"references": [
"GUID:c579267770062bf448e75eb160330b7f",
"GUID:bf0220fd1bb918740b112a52cefae584",
"GUID:3eae0364be2026648bf74846acb8a731",
"GUID:cb19445e095596046a336416b28b0cc9",
"GUID:df380645f10b7bc4b97d4f5eb6303d95"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -0,0 +1,387 @@
//////////////////////////////////////////////////////
// MK Glow Editor URP //
// //
// Created by Michael Kremmel //
// www.michaelkremmel.de //
// Copyright © 2021 All rights reserved. //
//////////////////////////////////////////////////////
#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.Rendering;
using UnityEngine;
using MK.Glow.Editor;
namespace MK.Glow.URP.Editor
{
using Tooltips = MK.Glow.Editor.EditorHelper.EditorUIContent.Tooltips;
#if UNITY_2022_2_OR_NEWER
[CustomEditor(typeof(MK.Glow.URP.MKGlow))]
#else
[VolumeComponentEditor(typeof(MK.Glow.URP.MKGlow))]
#endif
internal class MKGlowEditor : VolumeComponentEditor
{
//Behaviors
private SerializedDataParameter _showEditorMainBehavior;
private SerializedDataParameter _showEditorBloomBehavior;
private SerializedDataParameter _showEditorLensSurfaceBehavior;
private SerializedDataParameter _showEditorLensFlareBehavior;
private SerializedDataParameter _showEditorGlareBehavior;
private SerializedDataParameter _isInitialized;
//Main
private SerializedDataParameter _allowGeometryShaders;
private SerializedDataParameter _allowComputeShaders;
private SerializedDataParameter _renderPriority;
private SerializedDataParameter _debugView;
private SerializedDataParameter _quality;
private SerializedDataParameter _antiFlickerMode;
private SerializedDataParameter _workflow;
private SerializedDataParameter _selectiveRenderLayerMask;
private SerializedDataParameter _anamorphicRatio;
private SerializedDataParameter _lumaScale;
private SerializedDataParameter _blooming;
//Bloom
private SerializedDataParameter _bloomThreshold;
private SerializedDataParameter _bloomScattering;
private SerializedDataParameter _bloomIntensity;
//Lens Surface
private SerializedDataParameter _allowLensSurface;
private SerializedDataParameter _lensSurfaceDirtTexture;
private SerializedDataParameter _lensSurfaceDirtIntensity;
private SerializedDataParameter _lensSurfaceDiffractionTexture;
private SerializedDataParameter _lensSurfaceDiffractionIntensity;
//Lens Flare
private SerializedDataParameter _allowLensFlare;
private SerializedDataParameter _lensFlareStyle;
private SerializedDataParameter _lensFlareGhostFade;
private SerializedDataParameter _lensFlareGhostIntensity;
private SerializedDataParameter _lensFlareThreshold;
private SerializedDataParameter _lensFlareScattering;
private SerializedDataParameter _lensFlareColorRamp;
private SerializedDataParameter _lensFlareChromaticAberration;
private SerializedDataParameter _lensFlareGhostCount;
private SerializedDataParameter _lensFlareGhostDispersal;
private SerializedDataParameter _lensFlareHaloFade;
private SerializedDataParameter _lensFlareHaloIntensity;
private SerializedDataParameter _lensFlareHaloSize;
//Glare
private SerializedDataParameter _allowGlare;
private SerializedDataParameter _glareBlend;
private SerializedDataParameter _glareIntensity;
private SerializedDataParameter _glareThreshold;
private SerializedDataParameter _glareScattering;
private SerializedDataParameter _glareAngle;
private SerializedDataParameter _glareStyle;
private SerializedDataParameter _glareStreaks;
private SerializedDataParameter _glareSample0Scattering;
private SerializedDataParameter _glareSample0Intensity;
private SerializedDataParameter _glareSample0Angle;
private SerializedDataParameter _glareSample0Offset;
private SerializedDataParameter _glareSample1Scattering;
private SerializedDataParameter _glareSample1Intensity;
private SerializedDataParameter _glareSample1Angle;
private SerializedDataParameter _glareSample1Offset;
private SerializedDataParameter _glareSample2Scattering;
private SerializedDataParameter _glareSample2Intensity;
private SerializedDataParameter _glareSample2Angle;
private SerializedDataParameter _glareSample2Offset;
private SerializedDataParameter _glareSample3Scattering;
private SerializedDataParameter _glareSample3Intensity;
private SerializedDataParameter _glareSample3Angle;
private SerializedDataParameter _glareSample3Offset;
PropertyFetcher<MK.Glow.URP.MKGlow> propertyFetcher;
public override void OnEnable()
{
propertyFetcher = new PropertyFetcher<MK.Glow.URP.MKGlow>(serializedObject);
//Editor
_showEditorBloomBehavior = Unpack(propertyFetcher.Find(x => x.showEditorBloomBehavior));
_showEditorMainBehavior = Unpack(propertyFetcher.Find(x => x.showEditorMainBehavior));
_showEditorBloomBehavior = Unpack(propertyFetcher.Find(x => x.showEditorBloomBehavior));
_showEditorLensSurfaceBehavior = Unpack(propertyFetcher.Find(x => x.showEditorLensSurfaceBehavior));
_showEditorLensFlareBehavior = Unpack(propertyFetcher.Find(x => x.showEditorLensFlareBehavior));
_showEditorGlareBehavior = Unpack(propertyFetcher.Find(x => x.showEditorGlareBehavior));
_isInitialized = Unpack(propertyFetcher.Find(x => x.isInitialized));
//Main
_allowGeometryShaders = Unpack(propertyFetcher.Find(x => x.allowGeometryShaders));
_allowComputeShaders = Unpack(propertyFetcher.Find(x => x.allowComputeShaders));
_renderPriority = Unpack(propertyFetcher.Find(x => x.renderPriority));
_debugView = Unpack(propertyFetcher.Find(x => x.debugView));
_quality = Unpack(propertyFetcher.Find(x => x.quality));
_antiFlickerMode = Unpack(propertyFetcher.Find(x => x.antiFlickerMode));
_workflow = Unpack(propertyFetcher.Find(x => x.workflow));
_selectiveRenderLayerMask = Unpack(propertyFetcher.Find(x => x.selectiveRenderLayerMask));
_anamorphicRatio = Unpack(propertyFetcher.Find(x => x.anamorphicRatio));
_lumaScale = Unpack(propertyFetcher.Find(x => x.lumaScale));
_blooming = Unpack(propertyFetcher.Find(x => x.blooming));
//Bloom
_bloomThreshold = Unpack(propertyFetcher.Find(x => x.bloomThreshold));
_bloomScattering = Unpack(propertyFetcher.Find(x => x.bloomScattering));
_bloomIntensity = Unpack(propertyFetcher.Find(x => x.bloomIntensity));
_allowLensSurface = Unpack(propertyFetcher.Find(x => x.allowLensSurface));
_lensSurfaceDirtTexture = Unpack(propertyFetcher.Find(x => x.lensSurfaceDirtTexture));
_lensSurfaceDirtIntensity = Unpack(propertyFetcher.Find(x => x.lensSurfaceDirtIntensity));
_lensSurfaceDiffractionTexture = Unpack(propertyFetcher.Find(x => x.lensSurfaceDiffractionTexture));
_lensSurfaceDiffractionIntensity = Unpack(propertyFetcher.Find(x => x.lensSurfaceDiffractionIntensity));
_allowLensFlare = Unpack(propertyFetcher.Find(x => x.allowLensFlare));
_lensFlareStyle = Unpack(propertyFetcher.Find(x => x.lensFlareStyle));
_lensFlareGhostFade = Unpack(propertyFetcher.Find(x => x.lensFlareGhostFade));
_lensFlareGhostIntensity = Unpack(propertyFetcher.Find(x => x.lensFlareGhostIntensity));
_lensFlareThreshold = Unpack(propertyFetcher.Find(x => x.lensFlareThreshold));
_lensFlareScattering = Unpack(propertyFetcher.Find(x => x.lensFlareScattering));
_lensFlareColorRamp = Unpack(propertyFetcher.Find(x => x.lensFlareColorRamp));
_lensFlareChromaticAberration = Unpack(propertyFetcher.Find(x => x.lensFlareChromaticAberration));
_lensFlareGhostCount = Unpack(propertyFetcher.Find(x => x.lensFlareGhostCount));
_lensFlareGhostDispersal = Unpack(propertyFetcher.Find(x => x.lensFlareGhostDispersal));
_lensFlareHaloFade = Unpack(propertyFetcher.Find(x => x.lensFlareHaloFade));
_lensFlareHaloIntensity = Unpack(propertyFetcher.Find(x => x.lensFlareHaloIntensity));
_lensFlareHaloSize = Unpack(propertyFetcher.Find(x => x.lensFlareHaloSize));
_allowGlare = Unpack(propertyFetcher.Find(x => x.allowGlare));
_glareBlend = Unpack(propertyFetcher.Find(x => x.glareBlend));
_glareIntensity = Unpack(propertyFetcher.Find(x => x.glareIntensity));
_glareThreshold = Unpack(propertyFetcher.Find(x => x.glareThreshold));
_glareScattering = Unpack(propertyFetcher.Find(x => x.glareScattering));
_glareStyle = Unpack(propertyFetcher.Find(x => x.glareStyle));
_glareStreaks = Unpack(propertyFetcher.Find(x => x.glareStreaks));
_glareAngle = Unpack(propertyFetcher.Find(x => x.glareAngle));
_glareSample0Scattering = Unpack(propertyFetcher.Find(x => x.glareSample0Scattering));
_glareSample0Intensity = Unpack(propertyFetcher.Find(x => x.glareSample0Intensity));
_glareSample0Angle = Unpack(propertyFetcher.Find(x => x.glareSample0Angle));
_glareSample0Offset = Unpack(propertyFetcher.Find(x => x.glareSample0Offset));
_glareSample1Scattering = Unpack(propertyFetcher.Find(x => x.glareSample1Scattering));
_glareSample1Intensity = Unpack(propertyFetcher.Find(x => x.glareSample1Intensity));
_glareSample1Angle = Unpack(propertyFetcher.Find(x => x.glareSample1Angle));
_glareSample1Offset = Unpack(propertyFetcher.Find(x => x.glareSample1Offset));
_glareSample2Scattering = Unpack(propertyFetcher.Find(x => x.glareSample2Scattering));
_glareSample2Intensity = Unpack(propertyFetcher.Find(x => x.glareSample2Intensity));
_glareSample2Angle = Unpack(propertyFetcher.Find(x => x.glareSample2Angle));
_glareSample2Offset = Unpack(propertyFetcher.Find(x => x.glareSample2Offset));
_glareSample3Scattering = Unpack(propertyFetcher.Find(x => x.glareSample3Scattering));
_glareSample3Intensity = Unpack(propertyFetcher.Find(x => x.glareSample3Intensity));
_glareSample3Angle = Unpack(propertyFetcher.Find(x => x.glareSample3Angle));
_glareSample3Offset = Unpack(propertyFetcher.Find(x => x.glareSample3Offset));
}
public override void OnInspectorGUI()
{
serializedObject.Update();
if(_isInitialized.value.boolValue == false)
{
_bloomIntensity.value.floatValue = 1f;
_bloomIntensity.overrideState.boolValue = true;
_lensSurfaceDirtIntensity.value.floatValue = 2.5f;
_lensSurfaceDirtIntensity.overrideState.boolValue = true;
_lensSurfaceDiffractionIntensity.value.floatValue = 2f;
_lensSurfaceDiffractionIntensity.overrideState.boolValue = true;
_lensFlareGhostIntensity.value.floatValue = 1.0f;
_lensFlareGhostIntensity.overrideState.boolValue = true;
_lensFlareHaloIntensity.value.floatValue = 1.0f;
_lensFlareHaloIntensity.overrideState.boolValue = true;
_glareSample0Intensity.value.floatValue = 1.0f;
_glareSample0Intensity.overrideState.boolValue = true;
_glareSample1Intensity.value.floatValue = 1.0f;
_glareSample1Intensity.overrideState.boolValue = true;
_glareSample2Intensity.value.floatValue = 1.0f;
_glareSample2Intensity.overrideState.boolValue = true;
_glareSample3Intensity.value.floatValue = 1.0f;
_glareSample3Intensity.overrideState.boolValue = true;
_isInitialized.value.boolValue = true;
}
EditorHelper.VerticalSpace();
EditorHelper.EditorUIContent.IsNotSupportedWarning();
EditorHelper.EditorUIContent.XRUnityVersionWarning();
if(_workflow.value.enumValueIndex == 1)
{
EditorHelper.EditorUIContent.SelectiveWorkflowDeprecated();
}
if(EditorHelper.HandleBehavior(_showEditorMainBehavior.value.serializedObject.targetObject, EditorHelper.EditorUIContent.mainTitle, "", _showEditorMainBehavior.value, null))
{
PropertyField(_allowGeometryShaders, Tooltips.allowGeometryShaders);
PropertyField(_allowComputeShaders, Tooltips.allowComputeShaders);
PropertyField(_renderPriority, Tooltips.renderPriority);
PropertyField(_debugView, Tooltips.debugView);
PropertyField(_quality, Tooltips.quality);
PropertyField(_antiFlickerMode, Tooltips.antiFlickerMode);
PropertyField(_workflow, Tooltips.workflow);
EditorHelper.EditorUIContent.SelectiveWorkflowVRWarning((Workflow)_workflow.value.enumValueIndex);
if(_workflow.value.enumValueIndex == 1)
{
PropertyField(_selectiveRenderLayerMask, Tooltips.selectiveRenderLayerMask);
}
PropertyField(_anamorphicRatio, Tooltips.anamorphicRatio);
PropertyField(_lumaScale, Tooltips.lumaScale);
if(_renderPriority.value.enumValueIndex != 2 && _workflow.value.enumValueIndex != 2)
PropertyField(_blooming, Tooltips.blooming);
EditorHelper.VerticalSpace();
}
if(EditorHelper.HandleBehavior(_showEditorBloomBehavior.value.serializedObject.targetObject, EditorHelper.EditorUIContent.bloomTitle, "", _showEditorBloomBehavior.value, null))
{
if(_workflow.value.enumValueIndex == 0)
PropertyField(_bloomThreshold, Tooltips.bloomThreshold);
PropertyField(_bloomScattering, Tooltips.bloomScattering);
PropertyField(_bloomIntensity, Tooltips.bloomIntensity);
_bloomIntensity.value.floatValue = Mathf.Max(0, _bloomIntensity.value.floatValue);
EditorHelper.VerticalSpace();
}
if(EditorHelper.HandleBehavior(_showEditorLensSurfaceBehavior.value.serializedObject.targetObject, EditorHelper.EditorUIContent.lensSurfaceTitle, "", _showEditorLensSurfaceBehavior.value, _allowLensSurface.value))
{
using (new EditorGUI.DisabledScope(!_allowLensSurface.value.boolValue))
{
EditorHelper.DrawHeader(EditorHelper.EditorUIContent.dirtTitle);
PropertyField(_lensSurfaceDirtTexture, Tooltips.lensSurfaceDirtTexture);
PropertyField(_lensSurfaceDirtIntensity, Tooltips.lensSurfaceDirtIntensity);
_lensSurfaceDirtIntensity.value.floatValue = Mathf.Max(0, _lensSurfaceDirtIntensity.value.floatValue);
EditorGUILayout.Space();
EditorHelper.DrawHeader(EditorHelper.EditorUIContent.diffractionTitle);
PropertyField(_lensSurfaceDiffractionTexture, Tooltips.lensSurfaceDiffractionTexture);
PropertyField(_lensSurfaceDiffractionIntensity, Tooltips.lensSurfaceDiffractionIntensity);
_lensSurfaceDiffractionIntensity.value.floatValue = Mathf.Max(0, _lensSurfaceDiffractionIntensity.value.floatValue);
}
EditorHelper.VerticalSpace();
}
if(Compatibility.CheckLensFlareFeatureSupport() && _quality.value.intValue <= 4)
{
if(EditorHelper.HandleBehavior(_showEditorLensFlareBehavior.value.serializedObject.targetObject, EditorHelper.EditorUIContent.lensFlareTitle, "", _showEditorLensFlareBehavior.value, _allowLensFlare.value))
{
using (new EditorGUI.DisabledScope(!_allowLensFlare.value.boolValue))
{
PropertyField(_lensFlareStyle, Tooltips.lensFlareStyle);
if(_workflow.value.enumValueIndex == 0)
PropertyField(_lensFlareThreshold, Tooltips.lensFlareThreshold);
PropertyField(_lensFlareScattering, Tooltips.lensFlareScattering);
PropertyField(_lensFlareColorRamp, Tooltips.lensFlareColorRamp);
PropertyField(_lensFlareChromaticAberration, Tooltips.lensFlareChromaticAberration);
EditorGUILayout.Space();
EditorHelper.DrawHeader(EditorHelper.EditorUIContent.ghostsTitle);
if(_lensFlareStyle.value.enumValueIndex == 0)
{
PropertyField(_lensFlareGhostFade, Tooltips.lensFlareGhostFade);
PropertyField(_lensFlareGhostCount, Tooltips.lensFlareGhostCount);
PropertyField(_lensFlareGhostDispersal, Tooltips.lensFlareGhostDispersal);
}
PropertyField(_lensFlareGhostIntensity, Tooltips.lensFlareGhostIntensity);
_lensFlareGhostIntensity.value.floatValue = Mathf.Max(0, _lensFlareGhostIntensity.value.floatValue);
EditorGUILayout.Space();
EditorHelper.DrawHeader(EditorHelper.EditorUIContent.haloTitle);
if(_lensFlareStyle.value.enumValueIndex == 0)
{
PropertyField(_lensFlareHaloFade, Tooltips.lensFlareHaloFade);
PropertyField(_lensFlareHaloSize, Tooltips.lensFlareHaloSize);
}
PropertyField(_lensFlareHaloIntensity, Tooltips.lensFlareHaloIntensity);
_lensFlareHaloIntensity.value.floatValue = Mathf.Max(0, _lensFlareHaloIntensity.value.floatValue);
}
EditorHelper.VerticalSpace();
}
}
else
{
EditorHelper.DrawSplitter();
EditorHelper.EditorUIContent.LensFlareFeatureNotSupportedWarning();
}
if(Compatibility.CheckGlareFeatureSupport() && _quality.value.intValue <= 4)
{
if(EditorHelper.HandleBehavior(_showEditorGlareBehavior.value.serializedObject.targetObject, EditorHelper.EditorUIContent.glareTitle, "", _showEditorGlareBehavior.value, _allowGlare.value))
{
using (new EditorGUI.DisabledScope(!_allowGlare.value.boolValue))
{
PropertyField(_glareStyle, Tooltips.glareStyle);
if(_workflow.value.enumValueIndex == 0)
PropertyField(_glareThreshold, Tooltips.glareThreshold);
if(_glareStyle.value.enumValueIndex == 0)
PropertyField(_glareStreaks, Tooltips.glareStreaks);
PropertyField(_glareBlend, Tooltips.glareBlend);
PropertyField(_glareAngle, Tooltips.glareAngle);
PropertyField(_glareScattering, Tooltips.glareScattering);
PropertyField(_glareIntensity, Tooltips.glareIntensity);
_glareScattering.value.floatValue = Mathf.Max(0, _glareScattering.value.floatValue);
_glareIntensity.value.floatValue = Mathf.Max(0, _glareIntensity.value.floatValue);
if(_glareStyle.value.enumValueIndex == 0)
{
EditorGUILayout.Space();
EditorHelper.DrawHeader(EditorHelper.EditorUIContent.sample0Title);
PropertyField(_glareSample0Scattering, Tooltips.glareSample0Scattering);
PropertyField(_glareSample0Angle, Tooltips.glareSample0Angle);
PropertyField(_glareSample0Offset, Tooltips.glareSample0Offset);
PropertyField(_glareSample0Intensity, Tooltips.glareSample0Intensity);
_glareSample0Intensity.value.floatValue = Mathf.Max(0, _glareSample0Intensity.value.floatValue);
if(_glareStreaks.value.intValue >= 2)
{
EditorGUILayout.Space();
EditorHelper.DrawHeader(EditorHelper.EditorUIContent.sample1Title);
PropertyField(_glareSample1Scattering, Tooltips.glareSample1Scattering);
PropertyField(_glareSample1Angle, Tooltips.glareSample1Angle);
PropertyField(_glareSample1Offset, Tooltips.glareSample1Offset);
PropertyField(_glareSample1Intensity, Tooltips.glareSample1Intensity);
_glareSample1Intensity.value.floatValue = Mathf.Max(0, _glareSample1Intensity.value.floatValue);
}
if(_glareStreaks.value.intValue >= 3)
{
EditorGUILayout.Space();
EditorHelper.DrawHeader(EditorHelper.EditorUIContent.sample2Title);
PropertyField(_glareSample2Scattering, Tooltips.glareSample2Scattering);
PropertyField(_glareSample2Angle, Tooltips.glareSample2Angle);
PropertyField(_glareSample2Offset, Tooltips.glareSample2Offset);
PropertyField(_glareSample2Intensity, Tooltips.glareSample2Intensity);
_glareSample2Intensity.value.floatValue = Mathf.Max(0, _glareSample2Intensity.value.floatValue);
}
if(_glareStreaks.value.intValue >= 4)
{
EditorGUILayout.Space();
EditorHelper.DrawHeader(EditorHelper.EditorUIContent.sample3Title);
PropertyField(_glareSample3Scattering, Tooltips.glareSample3Scattering);
PropertyField(_glareSample3Angle, Tooltips.glareSample3Angle);
PropertyField(_glareSample3Offset, Tooltips.glareSample3Offset);
PropertyField(_glareSample3Intensity, Tooltips.glareSample3Intensity);
_glareSample3Intensity.value.floatValue = Mathf.Max(0, _glareSample3Intensity.value.floatValue);
}
}
}
}
EditorHelper.VerticalSpace();
}
else
{
EditorHelper.DrawSplitter();
EditorHelper.EditorUIContent.GlareFeatureNotSupportedWarning();
}
EditorHelper.DrawSplitter();
serializedObject.ApplyModifiedProperties();
}
}
}
#endif

View File

@@ -0,0 +1,365 @@
//////////////////////////////////////////////////////
// MK Glow Editor URP //
// //
// Created by Michael Kremmel //
// www.michaelkremmel.de //
// Copyright © 2021 All rights reserved. //
//////////////////////////////////////////////////////
#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.Rendering;
using UnityEngine;
using MK.Glow.Editor;
namespace MK.Glow.URP.Editor
{
using Tooltips = MK.Glow.Editor.EditorHelper.EditorUIContent.Tooltips;
[CustomEditor(typeof(MK.Glow.URP.MKGlowRendererFeature))]
internal class MKGlowRendererFeatureEditor : UnityEditor.Editor
{
//Behaviors
private SerializedProperty _showEditorMainBehavior;
private SerializedProperty _showEditorBloomBehavior;
private SerializedProperty _showEditorLensSurfaceBehavior;
private SerializedProperty _showEditorLensFlareBehavior;
private SerializedProperty _showEditorGlareBehavior;
private SerializedProperty _workMode;
//Main
private SerializedProperty _allowGeometryShaders;
private SerializedProperty _allowComputeShaders;
private SerializedProperty _renderPriority;
private SerializedProperty _debugView;
private SerializedProperty _quality;
private SerializedProperty _antiFlickerMode;
private SerializedProperty _workflow;
private SerializedProperty _selectiveRenderLayerMask;
private SerializedProperty _anamorphicRatio;
private SerializedProperty _lumaScale;
private SerializedProperty _blooming;
//Bloom
private SerializedProperty _bloomThreshold;
private SerializedProperty _bloomScattering;
private SerializedProperty _bloomIntensity;
//Lens Surface
private SerializedProperty _allowLensSurface;
private SerializedProperty _lensSurfaceDirtTexture;
private SerializedProperty _lensSurfaceDirtIntensity;
private SerializedProperty _lensSurfaceDiffractionTexture;
private SerializedProperty _lensSurfaceDiffractionIntensity;
//Lens Flare
private SerializedProperty _allowLensFlare;
private SerializedProperty _lensFlareStyle;
private SerializedProperty _lensFlareGhostFade;
private SerializedProperty _lensFlareGhostIntensity;
private SerializedProperty _lensFlareThreshold;
private SerializedProperty _lensFlareScattering;
private SerializedProperty _lensFlareColorRamp;
private SerializedProperty _lensFlareChromaticAberration;
private SerializedProperty _lensFlareGhostCount;
private SerializedProperty _lensFlareGhostDispersal;
private SerializedProperty _lensFlareHaloFade;
private SerializedProperty _lensFlareHaloIntensity;
private SerializedProperty _lensFlareHaloSize;
//Glare
private SerializedProperty _allowGlare;
private SerializedProperty _glareBlend;
private SerializedProperty _glareIntensity;
private SerializedProperty _glareThreshold;
private SerializedProperty _glareScattering;
private SerializedProperty _glareAngle;
private SerializedProperty _glareStyle;
private SerializedProperty _glareStreaks;
private SerializedProperty _glareSample0Scattering;
private SerializedProperty _glareSample0Intensity;
private SerializedProperty _glareSample0Angle;
private SerializedProperty _glareSample0Offset;
private SerializedProperty _glareSample1Scattering;
private SerializedProperty _glareSample1Intensity;
private SerializedProperty _glareSample1Angle;
private SerializedProperty _glareSample1Offset;
private SerializedProperty _glareSample2Scattering;
private SerializedProperty _glareSample2Intensity;
private SerializedProperty _glareSample2Angle;
private SerializedProperty _glareSample2Offset;
private SerializedProperty _glareSample3Scattering;
private SerializedProperty _glareSample3Intensity;
private SerializedProperty _glareSample3Angle;
private SerializedProperty _glareSample3Offset;
public void OnEnable()
{
//Editor
_showEditorMainBehavior = serializedObject.FindProperty("showEditorMainBehavior");
_showEditorBloomBehavior = serializedObject.FindProperty("showEditorBloomBehavior");
_showEditorLensSurfaceBehavior = serializedObject.FindProperty("showEditorLensSurfaceBehavior");
_showEditorLensFlareBehavior = serializedObject.FindProperty("showEditorLensFlareBehavior");
_showEditorGlareBehavior = serializedObject.FindProperty("showEditorGlareBehavior");
_workMode = serializedObject.FindProperty("workmode");
//Main
_allowGeometryShaders = serializedObject.FindProperty("allowGeometryShaders");
_allowComputeShaders = serializedObject.FindProperty("allowComputeShaders");
_renderPriority = serializedObject.FindProperty("renderPriority");
_debugView = serializedObject.FindProperty("debugView");
_quality = serializedObject.FindProperty("quality");
_antiFlickerMode = serializedObject.FindProperty("antiFlickerMode");
_workflow = serializedObject.FindProperty("workflow");
_selectiveRenderLayerMask = serializedObject.FindProperty("selectiveRenderLayerMask");
_anamorphicRatio = serializedObject.FindProperty("anamorphicRatio");
_lumaScale = serializedObject.FindProperty("lumaScale");
_blooming = serializedObject.FindProperty("blooming");
//Bloom
_bloomThreshold = serializedObject.FindProperty("bloomThreshold");
_bloomScattering = serializedObject.FindProperty("bloomScattering");
_bloomIntensity = serializedObject.FindProperty("bloomIntensity");
_allowLensSurface = serializedObject.FindProperty("allowLensSurface");
_lensSurfaceDirtTexture = serializedObject.FindProperty("lensSurfaceDirtTexture");
_lensSurfaceDirtIntensity = serializedObject.FindProperty("lensSurfaceDirtIntensity");
_lensSurfaceDiffractionTexture = serializedObject.FindProperty("lensSurfaceDiffractionTexture");
_lensSurfaceDiffractionIntensity = serializedObject.FindProperty("lensSurfaceDiffractionIntensity");
_allowLensFlare = serializedObject.FindProperty("allowLensFlare");
_lensFlareStyle = serializedObject.FindProperty("lensFlareStyle");
_lensFlareGhostFade = serializedObject.FindProperty("lensFlareGhostFade");
_lensFlareGhostIntensity = serializedObject.FindProperty("lensFlareGhostIntensity");
_lensFlareThreshold = serializedObject.FindProperty("lensFlareThreshold");
_lensFlareScattering = serializedObject.FindProperty("lensFlareScattering");
_lensFlareColorRamp = serializedObject.FindProperty("lensFlareColorRamp");
_lensFlareChromaticAberration = serializedObject.FindProperty("lensFlareChromaticAberration");
_lensFlareGhostCount = serializedObject.FindProperty("lensFlareGhostCount");
_lensFlareGhostDispersal = serializedObject.FindProperty("lensFlareGhostDispersal");
_lensFlareHaloFade = serializedObject.FindProperty("lensFlareHaloFade");
_lensFlareHaloIntensity = serializedObject.FindProperty("lensFlareHaloIntensity");
_lensFlareHaloSize = serializedObject.FindProperty("lensFlareHaloSize");
_allowGlare = serializedObject.FindProperty("allowGlare");
_glareBlend = serializedObject.FindProperty("glareBlend");
_glareIntensity = serializedObject.FindProperty("glareIntensity");
_glareThreshold = serializedObject.FindProperty("glareThreshold");
_glareScattering = serializedObject.FindProperty("glareScattering");
_glareStyle = serializedObject.FindProperty("glareStyle");
_glareStreaks = serializedObject.FindProperty("glareStreaks");
_glareAngle = serializedObject.FindProperty("glareAngle");
_glareSample0Scattering = serializedObject.FindProperty("glareSample0Scattering");
_glareSample0Intensity = serializedObject.FindProperty("glareSample0Intensity");
_glareSample0Angle = serializedObject.FindProperty("glareSample0Angle");
_glareSample0Offset = serializedObject.FindProperty("glareSample0Offset");
_glareSample1Scattering = serializedObject.FindProperty("glareSample1Scattering");
_glareSample1Intensity = serializedObject.FindProperty("glareSample1Intensity");
_glareSample1Angle = serializedObject.FindProperty("glareSample1Angle");
_glareSample1Offset = serializedObject.FindProperty("glareSample1Offset");
_glareSample2Scattering = serializedObject.FindProperty("glareSample2Scattering");
_glareSample2Intensity = serializedObject.FindProperty("glareSample2Intensity");
_glareSample2Angle = serializedObject.FindProperty("glareSample2Angle");
_glareSample2Offset = serializedObject.FindProperty("glareSample2Offset");
_glareSample3Scattering = serializedObject.FindProperty("glareSample3Scattering");
_glareSample3Intensity = serializedObject.FindProperty("glareSample3Intensity");
_glareSample3Angle = serializedObject.FindProperty("glareSample3Angle");
_glareSample3Offset = serializedObject.FindProperty("glareSample3Offset");
}
public override void OnInspectorGUI()
{
serializedObject.Update();
EditorGUILayout.PropertyField(_workMode, Tooltips.workmode);
if(_workMode.enumValueIndex == 0)
{
serializedObject.ApplyModifiedProperties();
UnityEditor.EditorGUILayout.LabelField("Settings are controlled by your Post Processing Volumes.");
return;
}
else
{
UnityEditor.EditorGUILayout.LabelField("Post Processing API is skipped entirely. Global setup is enabled.");
}
EditorHelper.VerticalSpace();
EditorHelper.EditorUIContent.IsNotSupportedWarning();
EditorHelper.EditorUIContent.XRUnityVersionWarning();
if(_workflow.enumValueIndex == 1)
{
EditorHelper.EditorUIContent.SelectiveWorkflowDeprecated();
}
if(EditorHelper.HandleBehavior(_showEditorMainBehavior.serializedObject.targetObject, EditorHelper.EditorUIContent.mainTitle, "", _showEditorMainBehavior, null))
{
EditorGUILayout.PropertyField(_allowGeometryShaders, Tooltips.allowGeometryShaders);
EditorGUILayout.PropertyField(_allowComputeShaders, Tooltips.allowComputeShaders);
EditorGUILayout.PropertyField(_renderPriority, Tooltips.renderPriority);
EditorGUILayout.PropertyField(_debugView, Tooltips.debugView);
EditorGUILayout.PropertyField(_quality, Tooltips.quality);
EditorGUILayout.PropertyField(_antiFlickerMode, Tooltips.antiFlickerMode);
EditorGUILayout.PropertyField(_workflow, Tooltips.workflow);
EditorHelper.EditorUIContent.SelectiveWorkflowVRWarning((Workflow)_workflow.enumValueIndex);
if(_workflow.enumValueIndex == 1)
{
EditorGUILayout.PropertyField(_selectiveRenderLayerMask, Tooltips.selectiveRenderLayerMask);
}
EditorGUILayout.PropertyField(_anamorphicRatio, Tooltips.anamorphicRatio);
EditorGUILayout.PropertyField(_lumaScale, Tooltips.lumaScale);
if(_renderPriority.enumValueIndex != 2 && _workflow.enumValueIndex != 2)
EditorGUILayout.PropertyField(_blooming, Tooltips.blooming);
EditorHelper.VerticalSpace();
}
if(EditorHelper.HandleBehavior(_showEditorBloomBehavior.serializedObject.targetObject, EditorHelper.EditorUIContent.bloomTitle, "", _showEditorBloomBehavior, null))
{
if(_workflow.enumValueIndex == 0)
EditorGUILayout.PropertyField(_bloomThreshold, Tooltips.bloomThreshold);
EditorGUILayout.PropertyField(_bloomScattering, Tooltips.bloomScattering);
EditorGUILayout.PropertyField(_bloomIntensity, Tooltips.bloomIntensity);
_bloomIntensity.floatValue = Mathf.Max(0, _bloomIntensity.floatValue);
EditorHelper.VerticalSpace();
}
if(EditorHelper.HandleBehavior(_showEditorLensSurfaceBehavior.serializedObject.targetObject, EditorHelper.EditorUIContent.lensSurfaceTitle, "", _showEditorLensSurfaceBehavior, _allowLensSurface))
{
using (new EditorGUI.DisabledScope(!_allowLensSurface.boolValue))
{
EditorHelper.DrawHeader(EditorHelper.EditorUIContent.dirtTitle);
EditorGUILayout.PropertyField(_lensSurfaceDirtTexture, Tooltips.lensSurfaceDirtTexture);
EditorGUILayout.PropertyField(_lensSurfaceDirtIntensity, Tooltips.lensSurfaceDirtIntensity);
_lensSurfaceDirtIntensity.floatValue = Mathf.Max(0, _lensSurfaceDirtIntensity.floatValue);
EditorGUILayout.Space();
EditorHelper.DrawHeader(EditorHelper.EditorUIContent.diffractionTitle);
EditorGUILayout.PropertyField(_lensSurfaceDiffractionTexture, Tooltips.lensSurfaceDiffractionTexture);
EditorGUILayout.PropertyField(_lensSurfaceDiffractionIntensity, Tooltips.lensSurfaceDiffractionIntensity);
_lensSurfaceDiffractionIntensity.floatValue = Mathf.Max(0, _lensSurfaceDiffractionIntensity.floatValue);
}
EditorHelper.VerticalSpace();
}
if(Compatibility.CheckLensFlareFeatureSupport() && _quality.intValue <= 4)
{
if(EditorHelper.HandleBehavior(_showEditorLensFlareBehavior.serializedObject.targetObject, EditorHelper.EditorUIContent.lensFlareTitle, "", _showEditorLensFlareBehavior, _allowLensFlare))
{
using (new EditorGUI.DisabledScope(!_allowLensFlare.boolValue))
{
EditorGUILayout.PropertyField(_lensFlareStyle, Tooltips.lensFlareStyle);
if(_workflow.enumValueIndex == 0)
EditorGUILayout.PropertyField(_lensFlareThreshold, Tooltips.lensFlareThreshold);
EditorGUILayout.PropertyField(_lensFlareScattering, Tooltips.lensFlareScattering);
EditorGUILayout.PropertyField(_lensFlareColorRamp, Tooltips.lensFlareColorRamp);
EditorGUILayout.PropertyField(_lensFlareChromaticAberration, Tooltips.lensFlareChromaticAberration);
EditorGUILayout.Space();
EditorHelper.DrawHeader(EditorHelper.EditorUIContent.ghostsTitle);
if(_lensFlareStyle.enumValueIndex == 0)
{
EditorGUILayout.PropertyField(_lensFlareGhostFade, Tooltips.lensFlareGhostFade);
EditorGUILayout.PropertyField(_lensFlareGhostCount, Tooltips.lensFlareGhostCount);
EditorGUILayout.PropertyField(_lensFlareGhostDispersal, Tooltips.lensFlareGhostDispersal);
}
EditorGUILayout.PropertyField(_lensFlareGhostIntensity, Tooltips.lensFlareGhostIntensity);
_lensFlareGhostIntensity.floatValue = Mathf.Max(0, _lensFlareGhostIntensity.floatValue);
EditorGUILayout.Space();
EditorHelper.DrawHeader(EditorHelper.EditorUIContent.haloTitle);
if(_lensFlareStyle.enumValueIndex == 0)
{
EditorGUILayout.PropertyField(_lensFlareHaloFade, Tooltips.lensFlareHaloFade);
EditorGUILayout.PropertyField(_lensFlareHaloSize, Tooltips.lensFlareHaloSize);
}
EditorGUILayout.PropertyField(_lensFlareHaloIntensity, Tooltips.lensFlareHaloIntensity);
_lensFlareHaloIntensity.floatValue = Mathf.Max(0, _lensFlareHaloIntensity.floatValue);
}
EditorHelper.VerticalSpace();
}
}
else
{
EditorHelper.DrawSplitter();
EditorHelper.EditorUIContent.LensFlareFeatureNotSupportedWarning();
}
if(Compatibility.CheckGlareFeatureSupport() && _quality.intValue <= 4)
{
if(EditorHelper.HandleBehavior(_showEditorGlareBehavior.serializedObject.targetObject, EditorHelper.EditorUIContent.glareTitle, "", _showEditorGlareBehavior, _allowGlare))
{
using (new EditorGUI.DisabledScope(!_allowGlare.boolValue))
{
EditorGUILayout.PropertyField(_glareStyle, Tooltips.glareStyle);
if(_workflow.enumValueIndex == 0)
EditorGUILayout.PropertyField(_glareThreshold, Tooltips.glareThreshold);
if(_glareStyle.enumValueIndex == 0)
EditorGUILayout.PropertyField(_glareStreaks, Tooltips.glareStreaks);
EditorGUILayout.PropertyField(_glareBlend, Tooltips.glareBlend);
EditorGUILayout.PropertyField(_glareAngle, Tooltips.glareAngle);
EditorGUILayout.PropertyField(_glareScattering, Tooltips.glareScattering);
EditorGUILayout.PropertyField(_glareIntensity, Tooltips.glareIntensity);
_glareScattering.floatValue = Mathf.Max(0, _glareScattering.floatValue);
_glareIntensity.floatValue = Mathf.Max(0, _glareIntensity.floatValue);
if(_glareStyle.enumValueIndex == 0)
{
EditorGUILayout.Space();
EditorHelper.DrawHeader(EditorHelper.EditorUIContent.sample0Title);
EditorGUILayout.PropertyField(_glareSample0Scattering, Tooltips.glareSample0Scattering);
EditorGUILayout.PropertyField(_glareSample0Angle, Tooltips.glareSample0Angle);
EditorGUILayout.PropertyField(_glareSample0Offset, Tooltips.glareSample0Offset);
EditorGUILayout.PropertyField(_glareSample0Intensity, Tooltips.glareSample0Intensity);
_glareSample0Intensity.floatValue = Mathf.Max(0, _glareSample0Intensity.floatValue);
if(_glareStreaks.intValue >= 2)
{
EditorGUILayout.Space();
EditorHelper.DrawHeader(EditorHelper.EditorUIContent.sample1Title);
EditorGUILayout.PropertyField(_glareSample1Scattering, Tooltips.glareSample1Scattering);
EditorGUILayout.PropertyField(_glareSample1Angle, Tooltips.glareSample1Angle);
EditorGUILayout.PropertyField(_glareSample1Offset, Tooltips.glareSample1Offset);
EditorGUILayout.PropertyField(_glareSample1Intensity, Tooltips.glareSample1Intensity);
_glareSample1Intensity.floatValue = Mathf.Max(0, _glareSample1Intensity.floatValue);
}
if(_glareStreaks.intValue >= 3)
{
EditorGUILayout.Space();
EditorHelper.DrawHeader(EditorHelper.EditorUIContent.sample2Title);
EditorGUILayout.PropertyField(_glareSample2Scattering, Tooltips.glareSample2Scattering);
EditorGUILayout.PropertyField(_glareSample2Angle, Tooltips.glareSample2Angle);
EditorGUILayout.PropertyField(_glareSample2Offset, Tooltips.glareSample2Offset);
EditorGUILayout.PropertyField(_glareSample2Intensity, Tooltips.glareSample2Intensity);
_glareSample2Intensity.floatValue = Mathf.Max(0, _glareSample2Intensity.floatValue);
}
if(_glareStreaks.intValue >= 4)
{
EditorGUILayout.Space();
EditorHelper.DrawHeader(EditorHelper.EditorUIContent.sample3Title);
EditorGUILayout.PropertyField(_glareSample3Scattering, Tooltips.glareSample3Scattering);
EditorGUILayout.PropertyField(_glareSample3Angle, Tooltips.glareSample3Angle);
EditorGUILayout.PropertyField(_glareSample3Offset, Tooltips.glareSample3Offset);
EditorGUILayout.PropertyField(_glareSample3Intensity, Tooltips.glareSample3Intensity);
_glareSample3Intensity.floatValue = Mathf.Max(0, _glareSample3Intensity.floatValue);
}
}
}
}
EditorHelper.VerticalSpace();
}
else
{
EditorHelper.DrawSplitter();
EditorHelper.EditorUIContent.GlareFeatureNotSupportedWarning();
}
EditorHelper.DrawSplitter();
serializedObject.ApplyModifiedProperties();
}
}
}
#endif

View File

@@ -0,0 +1,52 @@
//////////////////////////////////////////////////////
// MK Glow Range Drawer //
// //
// Created by Michael Kremmel //
// www.michaelkremmel.de //
// Copyright © 2021 All rights reserved. //
//////////////////////////////////////////////////////
#if UNITY_EDITOR
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using UnityEditor.Rendering;
using UnityEngine.Rendering;
namespace MK.Glow.URP
{
[VolumeParameterDrawer(typeof(MK.Glow.URP.MKGlow.MinMaxRangeParameter))]
internal class MinMaxRangeVolumeParameterDrawer : VolumeParameterDrawer
{
public override bool OnGUI(SerializedDataParameter property, GUIContent title)
{
//MinMaxRangeAttribute range = attribute as MinMaxRangeAttribute;
MinMaxRangeAttribute range = property.GetAttribute<MinMaxRangeAttribute>();
SerializedProperty minRange = property.value.FindPropertyRelative("minValue");
SerializedProperty maxRange = property.value.FindPropertyRelative("maxValue");
float minValue = minRange.floatValue;
float maxValue = maxRange.floatValue;
Rect startRect = EditorGUILayout.GetControlRect();
Rect minRect = new Rect(EditorGUIUtility.labelWidth + EditorGUIUtility.fieldWidth * 0.75f, startRect.y, EditorGUIUtility.fieldWidth, startRect.height);
float p = minRect.x + EditorGUIUtility.standardVerticalSpacing * 2f + EditorGUIUtility.fieldWidth;
Rect sliderRect = new Rect(p, startRect.y, EditorGUIUtility.currentViewWidth - p - EditorGUIUtility.fieldWidth * 1.5f, startRect.height);
Rect maxRect = new Rect(sliderRect.x + sliderRect.width + EditorGUIUtility.standardVerticalSpacing * 2f, startRect.y, EditorGUIUtility.fieldWidth, startRect.height);
EditorGUI.LabelField(startRect, title.text);
minValue = EditorGUI.FloatField(minRect, minValue);
EditorGUI.MinMaxSlider(sliderRect, ref minValue, ref maxValue, range.minLimit, range.maxLimit);
maxValue = EditorGUI.FloatField(maxRect, maxValue);
minRange.floatValue = minValue;
maxRange.floatValue = maxValue;
return true;
}
}
}
#endif

View File

@@ -0,0 +1,46 @@
//////////////////////////////////////////////////////
// MK Glow Range Drawer //
// //
// Created by Michael Kremmel //
// www.michaelkremmel.de //
// Copyright © 2020 All rights reserved. //
//////////////////////////////////////////////////////
#if UNITY_EDITOR
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
namespace MK.Glow.URP
{
[CustomPropertyDrawer(typeof(MinMaxRangeAttribute))]
internal class MinMaxRendererFeatureRangeDrawer : PropertyDrawer
{
public override void OnGUI( Rect startRect, SerializedProperty property, GUIContent label )
{
EditorGUI.BeginProperty(startRect, label, property);
MinMaxRangeAttribute range = attribute as MinMaxRangeAttribute;
SerializedProperty minRange = property.FindPropertyRelative("minValue");
SerializedProperty maxRange = property.FindPropertyRelative("maxValue");
float minValue = minRange.floatValue;
float maxValue = maxRange.floatValue;
Rect minRect = new Rect(EditorGUIUtility.labelWidth + EditorGUIUtility.fieldWidth * 0.33f, startRect.y, EditorGUIUtility.fieldWidth, startRect.height);
float p = minRect.x + EditorGUIUtility.standardVerticalSpacing * 2f + EditorGUIUtility.fieldWidth;
Rect sliderRect = new Rect(p, startRect.y, startRect.width - p - EditorGUIUtility.fieldWidth + EditorGUIUtility.standardVerticalSpacing * 5f, startRect.height);
Rect maxRect = new Rect(sliderRect.x + sliderRect.width + EditorGUIUtility.standardVerticalSpacing * 2f, startRect.y, EditorGUIUtility.fieldWidth, startRect.height);
EditorGUI.LabelField(startRect, label);
minValue = EditorGUI.FloatField(minRect, minValue);
EditorGUI.MinMaxSlider(sliderRect, ref minValue, ref maxValue, range.minLimit, range.maxLimit);
maxValue = EditorGUI.FloatField(maxRect, maxValue);
minRange.floatValue = minValue;
maxRange.floatValue = maxValue;
EditorGUI.EndProperty();
}
}
}
#endif

View File

@@ -0,0 +1,28 @@
//////////////////////////////////////////////////////
// MK Glow Sprite Shader Editor //
// //
// Created by Michael Kremmel //
// www.michaelkremmel.de //
// Copyright © 2021 All rights reserved. //
//////////////////////////////////////////////////////
#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.Rendering;
using UnityEngine;
using MK.Glow.Editor;
namespace MK.Glow.URP.Editor
{
public class SpriteShaderEditor : MaterialEditor
{
public override void OnInspectorGUI ()
{
base.OnInspectorGUI();
RenderQueueField();
EnableInstancingField();
}
}
}
#endif

View File

@@ -0,0 +1,561 @@
//////////////////////////////////////////////////////
// MK Glow URP Volume Component //
// //
// Created by Michael Kremmel //
// www.michaelkremmel.de //
// Copyright © 2021 All rights reserved. //
//////////////////////////////////////////////////////
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
namespace MK.Glow.URP
{
[ExecuteInEditMode, VolumeComponentMenu("Post-processing/MK/MKGlow")]
public class MKGlow : VolumeComponent, IPostProcessComponent, MK.Glow.ISettings
{
[System.Serializable]
public sealed class RenderPriorityParameter : VolumeParameter<RenderPriority>
{
public override void Interp(RenderPriority from, RenderPriority to, float t)
{
value = t > 0 ? to : from;
}
}
[System.Serializable]
public sealed class Texture2DParameter : VolumeParameter<Texture2D>
{
public override void Interp(Texture2D from, Texture2D to, float t)
{
value = t > 0 ? to : from;
}
}
[System.Serializable]
public sealed class DebugViewParameter : VolumeParameter<MK.Glow.DebugView>
{
public override void Interp(MK.Glow.DebugView from, MK.Glow.DebugView to, float t)
{
value = t > 0 ? to : from;
}
}
[System.Serializable]
public sealed class QualityParameter : VolumeParameter<MK.Glow.Quality>
{
public override void Interp(MK.Glow.Quality from, MK.Glow.Quality to, float t)
{
value = t > 0 ? to : from;
}
}
[System.Serializable]
public sealed class AntiFlickerModeParameter : VolumeParameter<MK.Glow.AntiFlickerMode>
{
public override void Interp(MK.Glow.AntiFlickerMode from, MK.Glow.AntiFlickerMode to, float t)
{
value = t > 0 ? to : from;
}
}
[System.Serializable]
public sealed class WorkflowParameter : VolumeParameter<MK.Glow.Workflow>
{
public override void Interp(MK.Glow.Workflow from, MK.Glow.Workflow to, float t)
{
value = t > 0 ? to : from;
}
}
[System.Serializable]
public sealed class LayerMaskParameter : VolumeParameter<LayerMask>
{
public override void Interp(LayerMask from, LayerMask to, float t)
{
value = t > 0 ? to : from;
}
}
[System.Serializable]
public sealed class MinMaxRangeParameter : VolumeParameter<MK.Glow.MinMaxRange>
{
public override void Interp(MK.Glow.MinMaxRange from, MK.Glow.MinMaxRange to, float t)
{
m_Value.minValue = Mathf.Lerp(from.minValue, to.minValue, t);
m_Value.maxValue = Mathf.Lerp(from.maxValue, to.maxValue, t);
}
}
[System.Serializable]
public sealed class GlareStyleParameter : VolumeParameter<GlareStyle>
{
public override void Interp(GlareStyle from, GlareStyle to, float t)
{
value = t > 0 ? to : from;
}
}
[System.Serializable]
public sealed class LensFlareStyleParameter : VolumeParameter<LensFlareStyle>
{
public override void Interp(LensFlareStyle from, LensFlareStyle to, float t)
{
value = t > 0 ? to : from;
}
}
#if UNITY_EDITOR
public BoolParameter showEditorMainBehavior = new BoolParameter(true);
public BoolParameter showEditorBloomBehavior = new BoolParameter(false);
public BoolParameter showEditorLensSurfaceBehavior = new BoolParameter(false);
public BoolParameter showEditorLensFlareBehavior = new BoolParameter(false);
public BoolParameter showEditorGlareBehavior = new BoolParameter(false);
/// <summary>
/// Keep this value always untouched, editor internal only
/// </summary>
public BoolParameter isInitialized = new BoolParameter(false, true);
#endif
//Main
public BoolParameter allowGeometryShaders = new BoolParameter(true);
public BoolParameter allowComputeShaders = new BoolParameter(true);
public RenderPriorityParameter renderPriority = new RenderPriorityParameter() { value = RenderPriority.Balanced };
public DebugViewParameter debugView = new DebugViewParameter() { value = MK.Glow.DebugView.None };
public QualityParameter quality = new QualityParameter() { value = MK.Glow.Quality.High };
public AntiFlickerModeParameter antiFlickerMode = new AntiFlickerModeParameter() { value = MK.Glow.AntiFlickerMode.Balanced };
public WorkflowParameter workflow = new WorkflowParameter() { value = MK.Glow.Workflow.Threshold };
public LayerMaskParameter selectiveRenderLayerMask = new LayerMaskParameter() { value = -1 };
[Range(-1f, 1f)]
public ClampedFloatParameter anamorphicRatio = new ClampedFloatParameter(0, -1, 1);
[Range(0f, 1f)]
public ClampedFloatParameter lumaScale = new ClampedFloatParameter(0.5f, 0, 1);
[Range(0f, 1f)]
public ClampedFloatParameter blooming = new ClampedFloatParameter(0, 0, 1);
//Bloom
[MK.Glow.MinMaxRange(0, 10)]
public MinMaxRangeParameter bloomThreshold = new MinMaxRangeParameter() { value = new MinMaxRange(1.25f, 10f) };
[Range(1f, 10f)]
public ClampedFloatParameter bloomScattering = new ClampedFloatParameter(7, 1, 10);
public FloatParameter bloomIntensity = new FloatParameter(0);
//LensSurface
public BoolParameter allowLensSurface = new BoolParameter(false, true);
public Texture2DParameter lensSurfaceDirtTexture = new Texture2DParameter();
public FloatParameter lensSurfaceDirtIntensity = new FloatParameter(0);
public Texture2DParameter lensSurfaceDiffractionTexture = new Texture2DParameter();
public FloatParameter lensSurfaceDiffractionIntensity = new FloatParameter(0);
//LensFlare
public BoolParameter allowLensFlare = new BoolParameter(false, true);
public LensFlareStyleParameter lensFlareStyle = new LensFlareStyleParameter() { value = LensFlareStyle.Average };
[Range(0f, 25f)]
public ClampedFloatParameter lensFlareGhostFade = new ClampedFloatParameter(10, 0, 25);
public FloatParameter lensFlareGhostIntensity = new FloatParameter(0);
[MK.Glow.MinMaxRange(0, 10)]
public MinMaxRangeParameter lensFlareThreshold = new MinMaxRangeParameter() { value = new MinMaxRange(1.3f, 10f) };
[Range(0f, 8f)]
public ClampedFloatParameter lensFlareScattering = new ClampedFloatParameter(5, 0, 8);
public Texture2DParameter lensFlareColorRamp = new Texture2DParameter();
[Range(-100f, 100f)]
public ClampedFloatParameter lensFlareChromaticAberration = new ClampedFloatParameter(53, -100, 100);
[Range(0, 5)]
public ClampedIntParameter lensFlareGhostCount = new ClampedIntParameter(3, 0, 5);
[Range(-1f, 1f)]
public ClampedFloatParameter lensFlareGhostDispersal = new ClampedFloatParameter(0.6f, -1, 1);
[Range(0f, 25f)]
public ClampedFloatParameter lensFlareHaloFade = new ClampedFloatParameter(2, 0, 25);
public FloatParameter lensFlareHaloIntensity = new FloatParameter(2);
[Range(0f, 1f)]
public ClampedFloatParameter lensFlareHaloSize = new ClampedFloatParameter(0.4f, 0, 1);
//Glare
public BoolParameter allowGlare = new BoolParameter(false, true);
[Range(0.0f, 1.0f)]
public ClampedFloatParameter glareBlend = new ClampedFloatParameter(0.33f, 0, 1);
public FloatParameter glareIntensity = new FloatParameter(1);
[Range(0.0f, 360.0f)]
public ClampedFloatParameter glareAngle = new ClampedFloatParameter(0, 0, 360);
[MK.Glow.MinMaxRange(0, 10)]
public MinMaxRangeParameter glareThreshold = new MinMaxRangeParameter() { value = new MinMaxRange(1.25f, 10f)};
[Range(1, 4)]
public ClampedIntParameter glareStreaks = new ClampedIntParameter(4, 1, 4);
[Range(0.0f, 4.0f)]
public ClampedFloatParameter glareScattering = new ClampedFloatParameter(2, 0, 4);
public GlareStyleParameter glareStyle = new GlareStyleParameter() { value = GlareStyle.DistortedCross };
//Sample0
[Range(0f, 10f)]
public ClampedFloatParameter glareSample0Scattering = new ClampedFloatParameter(5, 0, 10);
[Range(0f, 360f)]
public ClampedFloatParameter glareSample0Angle = new ClampedFloatParameter(0, 0, 360);
public FloatParameter glareSample0Intensity = new FloatParameter(0);
[Range(0f, 10f)]
public ClampedFloatParameter glareSample0Offset = new ClampedFloatParameter(0, 0, 10);
//Sample1
[Range(0f, 10f)]
public ClampedFloatParameter glareSample1Scattering = new ClampedFloatParameter(5, 0, 10);
[Range(0f, 360f)]
public ClampedFloatParameter glareSample1Angle = new ClampedFloatParameter(45, 0, 360);
public FloatParameter glareSample1Intensity = new FloatParameter(0);
[Range(0f, 10f)]
public ClampedFloatParameter glareSample1Offset = new ClampedFloatParameter(0, 0, 10);
//Sample0
[Range(0f, 10f)]
public ClampedFloatParameter glareSample2Scattering = new ClampedFloatParameter(5, 0, 10);
[Range(0f, 360f)]
public ClampedFloatParameter glareSample2Angle = new ClampedFloatParameter(90, 0, 360);
public FloatParameter glareSample2Intensity = new FloatParameter(0);
[Range(0f, 10f)]
public ClampedFloatParameter glareSample2Offset = new ClampedFloatParameter(0, 0, 10);
//Sample0
[Range(0f, 10f)]
public ClampedFloatParameter glareSample3Scattering = new ClampedFloatParameter(5, 0, 10);
[Range(0f, 360f)]
public ClampedFloatParameter glareSample3Angle = new ClampedFloatParameter(135, 0, 360);
public FloatParameter glareSample3Intensity = new FloatParameter(0);
[Range(0f, 10f)]
public ClampedFloatParameter glareSample3Offset = new ClampedFloatParameter(0, 0, 10);
public bool IsActive() => Compatibility.IsSupported && (bloomIntensity.value > 0 || allowLensFlare.value && (lensFlareGhostIntensity.value > 0 || lensFlareHaloIntensity.value > 0) || allowGlare.value && glareIntensity.value > 0 && (glareSample0Intensity.value > 0 || glareSample1Intensity.value > 0 || glareSample2Intensity.value > 0 || glareSample3Intensity.value > 0));
public bool IsTileCompatible() => true;
/////////////////////////////////////////////////////////////////////////////////////////////
// Settings
/////////////////////////////////////////////////////////////////////////////////////////////
public bool GetAllowGeometryShaders()
{
return false;
}
public bool GetAllowComputeShaders()
{
return false;
}
public RenderPriority GetRenderPriority()
{
return renderPriority.value;
}
public MK.Glow.DebugView GetDebugView()
{
return debugView.value;
}
public MK.Glow.Quality GetQuality()
{
return quality.value;
}
public MK.Glow.AntiFlickerMode GetAntiFlickerMode()
{
return antiFlickerMode.value;
}
public MK.Glow.Workflow GetWorkflow()
{
return workflow.value;
}
public LayerMask GetSelectiveRenderLayerMask()
{
return selectiveRenderLayerMask.value;
}
public float GetAnamorphicRatio()
{
return anamorphicRatio.value;
}
public float GetLumaScale()
{
return lumaScale.value;
}
public float GetBlooming()
{
return blooming.value;
}
//Bloom
public MK.Glow.MinMaxRange GetBloomThreshold()
{
return bloomThreshold.value;
}
public float GetBloomScattering()
{
return bloomScattering.value;
}
public float GetBloomIntensity()
{
return bloomIntensity.value;
}
//LensSurface
public bool GetAllowLensSurface()
{
return allowLensSurface.value;
}
public Texture2D GetLensSurfaceDirtTexture()
{
return lensSurfaceDirtTexture.value;
}
public float GetLensSurfaceDirtIntensity()
{
return lensSurfaceDirtIntensity.value;
}
public Texture2D GetLensSurfaceDiffractionTexture()
{
return lensSurfaceDiffractionTexture.value;
}
public float GetLensSurfaceDiffractionIntensity()
{
return lensSurfaceDiffractionIntensity.value;
}
//LensFlare
public bool GetAllowLensFlare()
{
return allowLensFlare.value;
}
public LensFlareStyle GetLensFlareStyle()
{
return lensFlareStyle.value;
}
public float GetLensFlareGhostFade()
{
return lensFlareGhostFade.value;
}
public float GetLensFlareGhostIntensity()
{
return lensFlareGhostIntensity.value;
}
public MK.Glow.MinMaxRange GetLensFlareThreshold()
{
return lensFlareThreshold.value;
}
public float GetLensFlareScattering()
{
return lensFlareScattering.value;
}
public Texture2D GetLensFlareColorRamp()
{
return lensFlareColorRamp.value;
}
public float GetLensFlareChromaticAberration()
{
return lensFlareChromaticAberration.value;
}
public int GetLensFlareGhostCount()
{
return lensFlareGhostCount.value;
}
public float GetLensFlareGhostDispersal()
{
return lensFlareGhostDispersal.value;
}
public float GetLensFlareHaloFade()
{
return lensFlareHaloFade.value;
}
public float GetLensFlareHaloIntensity()
{
return lensFlareHaloIntensity.value;
}
public float GetLensFlareHaloSize()
{
return lensFlareHaloSize.value;
}
public void SetLensFlareGhostFade(float fade)
{
lensFlareGhostFade.value = fade;
}
public void SetLensFlareGhostCount(int count)
{
lensFlareGhostCount.value = count;
}
public void SetLensFlareGhostDispersal(float dispersal)
{
lensFlareGhostDispersal.value = dispersal;
}
public void SetLensFlareHaloFade(float fade)
{
lensFlareHaloFade.value = fade;
}
public void SetLensFlareHaloSize(float size)
{
lensFlareHaloSize.value = size;
}
//Glare
public bool GetAllowGlare()
{
return allowGlare.value;
}
public float GetGlareBlend()
{
return glareBlend.value;
}
public float GetGlareIntensity()
{
return glareIntensity.value;
}
public float GetGlareAngle()
{
return glareAngle.value;
}
public MK.Glow.MinMaxRange GetGlareThreshold()
{
return glareThreshold.value;
}
public int GetGlareStreaks()
{
return glareStreaks.value;
}
public void SetGlareStreaks(int count)
{
glareStreaks.value = count;
}
public float GetGlareScattering()
{
return glareScattering.value;
}
public GlareStyle GetGlareStyle()
{
return glareStyle.value;
}
//Sample0
public float GetGlareSample0Scattering()
{
return glareSample0Scattering.value;
}
public float GetGlareSample0Angle()
{
return glareSample0Angle.value;
}
public float GetGlareSample0Intensity()
{
return glareSample0Intensity.value;
}
public float GetGlareSample0Offset()
{
return glareSample0Offset.value;
}
public void SetGlareSample0Scattering(float scattering)
{
glareSample0Scattering.value = scattering;
}
public void SetGlareSample0Angle(float angle)
{
glareSample0Angle.value = angle;
}
public void SetGlareSample0Intensity(float intensity)
{
glareSample0Intensity.value = intensity;
}
public void SetGlareSample0Offset(float offset)
{
glareSample0Offset.value = offset;
}
//Sample1
public float GetGlareSample1Scattering()
{
return glareSample1Scattering.value;
}
public float GetGlareSample1Angle()
{
return glareSample1Angle.value;
}
public float GetGlareSample1Intensity()
{
return glareSample1Intensity.value;
}
public float GetGlareSample1Offset()
{
return glareSample1Offset.value;
}
public void SetGlareSample1Scattering(float scattering)
{
glareSample1Scattering.value = scattering;
}
public void SetGlareSample1Angle(float angle)
{
glareSample1Angle.value = angle;
}
public void SetGlareSample1Intensity(float intensity)
{
glareSample1Intensity.value = intensity;
}
public void SetGlareSample1Offset(float offset)
{
glareSample1Offset.value = offset;
}
//Sample2
public float GetGlareSample2Scattering()
{
return glareSample2Scattering.value;
}
public float GetGlareSample2Angle()
{
return glareSample2Angle.value;
}
public float GetGlareSample2Intensity()
{
return glareSample2Intensity.value;
}
public float GetGlareSample2Offset()
{
return glareSample2Offset.value;
}
public void SetGlareSample2Scattering(float scattering)
{
glareSample2Scattering.value = scattering;
}
public void SetGlareSample2Angle(float angle)
{
glareSample2Angle.value = angle;
}
public void SetGlareSample2Intensity(float intensity)
{
glareSample2Intensity.value = intensity;
}
public void SetGlareSample2Offset(float offset)
{
glareSample2Offset.value = offset;
}
//Sample3
public float GetGlareSample3Scattering()
{
return glareSample3Scattering.value;
}
public float GetGlareSample3Angle()
{
return glareSample3Angle.value;
}
public float GetGlareSample3Intensity()
{
return glareSample3Intensity.value;
}
public float GetGlareSample3Offset()
{
return glareSample3Offset.value;
}
public void SetGlareSample3Scattering(float scattering)
{
glareSample3Scattering.value = scattering;
}
public void SetGlareSample3Angle(float angle)
{
glareSample3Angle.value = angle;
}
public void SetGlareSample3Intensity(float intensity)
{
glareSample3Intensity.value = intensity;
}
public void SetGlareSample3Offset(float offset)
{
glareSample3Offset.value = offset;
}
}
}

View File

@@ -0,0 +1,695 @@
//////////////////////////////////////////////////////
// MK Glow URP Renderer Feature //
// //
// Created by Michael Kremmel //
// www.michaelkremmel.de //
// Copyright © 2021 All rights reserved. //
//////////////////////////////////////////////////////
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
using System;
namespace MK.Glow.URP
{
public class MKGlowRendererFeature : ScriptableRendererFeature, MK.Glow.ISettings
{
/////////////////////////////////////////////////////////////////////////////////////////////
// Renderer Feature Only Properties
/////////////////////////////////////////////////////////////////////////////////////////////
#if UNITY_EDITOR
public bool showEditorMainBehavior = true;
public bool showEditorBloomBehavior;
public bool showEditorLensSurfaceBehavior;
public bool showEditorLensFlareBehavior;
public bool showEditorGlareBehavior;
#endif
public enum Workmode
{
[UnityEngine.InspectorName("Post-Process Volumes")]
PostProcessVolumes = 0,
[UnityEngine.InspectorName("Global")]
Global = 1
};
public Workmode workmode = Workmode.PostProcessVolumes;
//Main
public bool allowGeometryShaders = true;
public bool allowComputeShaders = true;
public RenderPriority renderPriority = RenderPriority.Balanced;
public DebugView debugView = MK.Glow.DebugView.None;
public Quality quality = MK.Glow.Quality.High;
public AntiFlickerMode antiFlickerMode = AntiFlickerMode.Balanced;
public Workflow workflow = MK.Glow.Workflow.Threshold;
public LayerMask selectiveRenderLayerMask = -1;
[Range(-1f, 1f)]
public float anamorphicRatio = 0f;
[Range(0f, 1f)]
public float lumaScale = 0.5f;
[Range(0f, 1f)]
public float blooming = 0f;
//Bloom
[MK.Glow.MinMaxRange(0, 10)]
public MinMaxRange bloomThreshold = new MinMaxRange(1.25f, 10f);
[Range(1f, 10f)]
public float bloomScattering = 7f;
public float bloomIntensity = 1f;
//LensSurface
public bool allowLensSurface = false;
public Texture2D lensSurfaceDirtTexture;
public float lensSurfaceDirtIntensity = 2.5f;
public Texture2D lensSurfaceDiffractionTexture;
public float lensSurfaceDiffractionIntensity = 2.0f;
//LensFlare
public bool allowLensFlare = false;
public LensFlareStyle lensFlareStyle = LensFlareStyle.Average;
[Range(0f, 25f)]
public float lensFlareGhostFade = 10.0f;
public float lensFlareGhostIntensity = 1.0f;
[MK.Glow.MinMaxRange(0, 10)]
public MinMaxRange lensFlareThreshold = new MinMaxRange(1.3f, 10f);
[Range(0f, 8f)]
public float lensFlareScattering = 5f;
public Texture2D lensFlareColorRamp;
[Range(-100f, 100f)]
public float lensFlareChromaticAberration = 53f;
[Range(1, 4)]
public int lensFlareGhostCount = 3;
[Range(-1f, 1f)]
public float lensFlareGhostDispersal = 0.6f;
[Range(0f, 25f)]
public float lensFlareHaloFade = 2f;
public float lensFlareHaloIntensity = 1.0f;
[Range(0f, 1f)]
public float lensFlareHaloSize = 0.4f;
//Glare
public bool allowGlare = false;
[Range(0.0f, 1.0f)]
public float glareBlend = 0.33f;
public float glareIntensity = 1f;
[Range(0.0f, 360.0f)]
public float glareAngle = 0f;
[MK.Glow.MinMaxRange(0, 10)]
public MinMaxRange glareThreshold = new MinMaxRange(1.25f, 10f);
[Range(1, 4)]
public int glareStreaks = 4;
public GlareStyle glareStyle = GlareStyle.DistortedCross;
[Range(0.0f, 4.0f)]
public float glareScattering = 2f;
//Sample0
[Range(0f, 10f)]
public float glareSample0Scattering = 5f;
[Range(0f, 360f)]
public float glareSample0Angle = 0f;
public float glareSample0Intensity = 1f;
[Range(-5f, 5f)]
public float glareSample0Offset = 0f;
//Sample1
[Range(0f, 10f)]
public float glareSample1Scattering = 5f;
[Range(0f, 360f)]
public float glareSample1Angle = 45f;
public float glareSample1Intensity = 1f;
[Range(-5f, 5f)]
public float glareSample1Offset = 0f;
//Sample0
[Range(0f, 10f)]
public float glareSample2Scattering = 5f;
[Range(0f, 360f)]
public float glareSample2Angle = 90f;
public float glareSample2Intensity = 1f;
[Range(-5f, 5f)]
public float glareSample2Offset = 0f;
//Sample0
[Range(0f, 10f)]
public float glareSample3Scattering = 5f;
[Range(0f, 360f)]
public float glareSample3Angle = 135f;
public float glareSample3Intensity = 1f;
[Range(-5f, 5f)]
public float glareSample3Offset = 0f;
/////////////////////////////////////////////////////////////////////////////////////////////
// Settings
/////////////////////////////////////////////////////////////////////////////////////////////
public bool GetAllowGeometryShaders()
{
return false;
}
public bool GetAllowComputeShaders()
{
return false;
}
public RenderPriority GetRenderPriority()
{
return renderPriority;
}
public MK.Glow.DebugView GetDebugView()
{
return debugView;
}
public MK.Glow.Quality GetQuality()
{
return quality;
}
public MK.Glow.AntiFlickerMode GetAntiFlickerMode()
{
return antiFlickerMode;
}
public MK.Glow.Workflow GetWorkflow()
{
return workflow;
}
public LayerMask GetSelectiveRenderLayerMask()
{
return selectiveRenderLayerMask;
}
public float GetAnamorphicRatio()
{
return anamorphicRatio;
}
public float GetLumaScale()
{
return lumaScale;
}
public float GetBlooming()
{
return blooming;
}
//Bloom
public MK.Glow.MinMaxRange GetBloomThreshold()
{
return bloomThreshold;
}
public float GetBloomScattering()
{
return bloomScattering;
}
public float GetBloomIntensity()
{
return bloomIntensity;
}
//LensSurface
public bool GetAllowLensSurface()
{
return allowLensSurface;
}
public Texture2D GetLensSurfaceDirtTexture()
{
return lensSurfaceDirtTexture;
}
public float GetLensSurfaceDirtIntensity()
{
return lensSurfaceDirtIntensity;
}
public Texture2D GetLensSurfaceDiffractionTexture()
{
return lensSurfaceDiffractionTexture;
}
public float GetLensSurfaceDiffractionIntensity()
{
return lensSurfaceDiffractionIntensity;
}
//LensFlare
public bool GetAllowLensFlare()
{
return allowLensFlare;
}
public LensFlareStyle GetLensFlareStyle()
{
return lensFlareStyle;
}
public float GetLensFlareGhostFade()
{
return lensFlareGhostFade;
}
public float GetLensFlareGhostIntensity()
{
return lensFlareGhostIntensity;
}
public MK.Glow.MinMaxRange GetLensFlareThreshold()
{
return lensFlareThreshold;
}
public float GetLensFlareScattering()
{
return lensFlareScattering;
}
public Texture2D GetLensFlareColorRamp()
{
return lensFlareColorRamp;
}
public float GetLensFlareChromaticAberration()
{
return lensFlareChromaticAberration;
}
public int GetLensFlareGhostCount()
{
return lensFlareGhostCount;
}
public float GetLensFlareGhostDispersal()
{
return lensFlareGhostDispersal;
}
public float GetLensFlareHaloFade()
{
return lensFlareHaloFade;
}
public float GetLensFlareHaloIntensity()
{
return lensFlareHaloIntensity;
}
public float GetLensFlareHaloSize()
{
return lensFlareHaloSize;
}
public void SetLensFlareGhostFade(float fade)
{
lensFlareGhostFade = fade;
}
public void SetLensFlareGhostCount(int count)
{
lensFlareGhostCount = count;
}
public void SetLensFlareGhostDispersal(float dispersal)
{
lensFlareGhostDispersal = dispersal;
}
public void SetLensFlareHaloFade(float fade)
{
lensFlareHaloFade = fade;
}
public void SetLensFlareHaloSize(float size)
{
lensFlareHaloSize = size;
}
//Glare
public bool GetAllowGlare()
{
return allowGlare;
}
public float GetGlareBlend()
{
return glareBlend;
}
public float GetGlareIntensity()
{
return glareIntensity;
}
public float GetGlareAngle()
{
return glareAngle;
}
public MK.Glow.MinMaxRange GetGlareThreshold()
{
return glareThreshold;
}
public int GetGlareStreaks()
{
return glareStreaks;
}
public void SetGlareStreaks(int count)
{
glareStreaks = count;
}
public float GetGlareScattering()
{
return glareScattering;
}
public GlareStyle GetGlareStyle()
{
return glareStyle;
}
//Sample0
public float GetGlareSample0Scattering()
{
return glareSample0Scattering;
}
public float GetGlareSample0Angle()
{
return glareSample0Angle;
}
public float GetGlareSample0Intensity()
{
return glareSample0Intensity;
}
public float GetGlareSample0Offset()
{
return glareSample0Offset;
}
public void SetGlareSample0Scattering(float scattering)
{
glareSample0Scattering = scattering;
}
public void SetGlareSample0Angle(float angle)
{
glareSample0Angle = angle;
}
public void SetGlareSample0Intensity(float intensity)
{
glareSample0Intensity = intensity;
}
public void SetGlareSample0Offset(float offset)
{
glareSample0Offset = offset;
}
//Sample1
public float GetGlareSample1Scattering()
{
return glareSample1Scattering;
}
public float GetGlareSample1Angle()
{
return glareSample1Angle;
}
public float GetGlareSample1Intensity()
{
return glareSample1Intensity;
}
public float GetGlareSample1Offset()
{
return glareSample1Offset;
}
public void SetGlareSample1Scattering(float scattering)
{
glareSample1Scattering = scattering;
}
public void SetGlareSample1Angle(float angle)
{
glareSample1Angle = angle;
}
public void SetGlareSample1Intensity(float intensity)
{
glareSample1Intensity = intensity;
}
public void SetGlareSample1Offset(float offset)
{
glareSample1Offset = offset;
}
//Sample2
public float GetGlareSample2Scattering()
{
return glareSample2Scattering;
}
public float GetGlareSample2Angle()
{
return glareSample2Angle;
}
public float GetGlareSample2Intensity()
{
return glareSample2Intensity;
}
public float GetGlareSample2Offset()
{
return glareSample2Offset;
}
public void SetGlareSample2Scattering(float scattering)
{
glareSample2Scattering = scattering;
}
public void SetGlareSample2Angle(float angle)
{
glareSample2Angle = angle;
}
public void SetGlareSample2Intensity(float intensity)
{
glareSample2Intensity = intensity;
}
public void SetGlareSample2Offset(float offset)
{
glareSample2Offset = offset;
}
//Sample3
public float GetGlareSample3Scattering()
{
return glareSample3Scattering;
}
public float GetGlareSample3Angle()
{
return glareSample3Angle;
}
public float GetGlareSample3Intensity()
{
return glareSample3Intensity;
}
public float GetGlareSample3Offset()
{
return glareSample3Offset;
}
public void SetGlareSample3Scattering(float scattering)
{
glareSample3Scattering = scattering;
}
public void SetGlareSample3Angle(float angle)
{
glareSample3Angle = angle;
}
public void SetGlareSample3Intensity(float intensity)
{
glareSample3Intensity = intensity;
}
public void SetGlareSample3Offset(float offset)
{
glareSample3Offset = offset;
}
class MKGlowRenderPass : ScriptableRenderPass, MK.Glow.ICameraData
{
private MK.Glow.URP.MKGlow _mKGlowVolumeComponent = null;
private MK.Glow.URP.MKGlow mKGlowVolumeComponent
{
get
{
_mKGlowVolumeComponent = VolumeManager.instance.stack.GetComponent<MK.Glow.URP.MKGlow>();
return _mKGlowVolumeComponent;
}
}
internal Effect effect = new Effect();
internal ScriptableRenderer scriptableRenderer;
internal MK.Glow.ISettings settingsRendererFeature = null;
internal Workmode workmode = Workmode.PostProcessVolumes;
private RenderTarget sourceRenderTarget, destinationRenderTarget;
private RenderingData _renderingData;
private MK.Glow.ISettings _settingsPostProcessingVolume = null;
private MK.Glow.ISettings _activeSettings = null;
private RenderTextureDescriptor _sourceDescriptor;
private readonly int _rendererBufferID = Shader.PropertyToID("_MKGlowScriptableRendererOutput");
private readonly string _profilerName = "MKGlow";
private Material _copyMaterial;
private readonly Shader _copyShader = Shader.Find("Hidden/MK/Glow/URP/Copy");
private readonly int _mainTexID = Shader.PropertyToID("_MainTex");
public MKGlowRenderPass()
{
this.renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing;
this._copyMaterial = new Material(_copyShader) { hideFlags = HideFlags.HideAndDontSave };
}
public void Dispose()
{
PipelineExtensions.Destroy(_copyMaterial);
}
public override void Configure(CommandBuffer cmd, RenderTextureDescriptor cameraTextureDescriptor)
{
_sourceDescriptor = cameraTextureDescriptor;
}
#if UNITY_2021_3_OR_NEWER
public override void OnCameraSetup(CommandBuffer cmd, ref RenderingData renderingData)
{
base.OnCameraSetup(cmd, ref renderingData);
#if UNITY_2022_1_OR_NEWER
sourceRenderTarget.renderTargetIdentifier = scriptableRenderer.cameraColorTargetHandle;
#else
sourceRenderTarget.renderTargetIdentifier = scriptableRenderer.cameraColorTarget;
#endif
}
#endif
private static Mesh _fullScreenMesh;
public static Mesh fullscreenMesh
{
get
{
if (_fullScreenMesh != null)
return _fullScreenMesh;
float topV = 1.0f;
float bottomV = 0.0f;
_fullScreenMesh = new Mesh { name = "Fullscreen Quad" };
_fullScreenMesh.SetVertices(new List<Vector3>
{
new Vector3(-1.0f, -1.0f, 0.0f),
new Vector3(-1.0f, 1.0f, 0.0f),
new Vector3(1.0f, -1.0f, 0.0f),
new Vector3(1.0f, 1.0f, 0.0f)
});
_fullScreenMesh.SetUVs(0, new List<Vector2>
{
new Vector2(0.0f, bottomV),
new Vector2(0.0f, topV),
new Vector2(1.0f, bottomV),
new Vector2(1.0f, topV)
});
_fullScreenMesh.SetIndices(new[] { 0, 1, 2, 2, 1, 3 }, MeshTopology.Triangles, 0, false);
_fullScreenMesh.UploadMeshData(true);
return _fullScreenMesh;
}
}
public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
{
if(workmode == Workmode.PostProcessVolumes)
{
if(mKGlowVolumeComponent == null || renderingData.cameraData.camera == null)
return;
if(!mKGlowVolumeComponent.IsActive())
return;
}
else
{
if(renderingData.cameraData.camera == null)
return;
}
_settingsPostProcessingVolume = mKGlowVolumeComponent;
_activeSettings = workmode == Workmode.PostProcessVolumes ? _settingsPostProcessingVolume : settingsRendererFeature;
CommandBuffer cmd = CommandBufferPool.Get(_profilerName);
_renderingData = renderingData;
#if !UNITY_2021_3_OR_NEWER
sourceRenderTarget.renderTargetIdentifier = scriptableRenderer.cameraColorTarget;
#endif
destinationRenderTarget.identifier = _rendererBufferID;
#if UNITY_2018_2_OR_NEWER
destinationRenderTarget.renderTargetIdentifier = new RenderTargetIdentifier(destinationRenderTarget.identifier, 0, CubemapFace.Unknown, -1);
#else
destinationRenderTarget.renderTargetIdentifier = new RenderTargetIdentifier(destinationRenderTarget.identifier);
#endif
cmd.GetTemporaryRT(destinationRenderTarget.identifier, _sourceDescriptor, FilterMode.Bilinear);
cmd.SetGlobalTexture(_mainTexID, sourceRenderTarget.renderTargetIdentifier);
cmd.SetRenderTarget(destinationRenderTarget.renderTargetIdentifier, 0, CubemapFace.Unknown, -1);
cmd.DrawMesh(fullscreenMesh, Matrix4x4.identity, _copyMaterial, 0, 0);
effect.Build(destinationRenderTarget, sourceRenderTarget, _activeSettings, cmd, this, renderingData.cameraData.camera);
cmd.ReleaseTemporaryRT(destinationRenderTarget.identifier);
context.ExecuteCommandBuffer(cmd);
cmd.Clear();
CommandBufferPool.Release(cmd);
}
/////////////////////////////////////////////////////////////////////////////////////////////
// Camera Data
/////////////////////////////////////////////////////////////////////////////////////////////
public int GetCameraWidth()
{
return _renderingData.cameraData.cameraTargetDescriptor.width;
}
public int GetCameraHeight()
{
return _renderingData.cameraData.cameraTargetDescriptor.height;
}
public bool GetStereoEnabled()
{
#if UNITY_2020_2_OR_NEWER
return _renderingData.cameraData.xrRendering;
#else
return _renderingData.cameraData.isStereoEnabled;
#endif
}
public float GetAspect()
{
return _renderingData.cameraData.camera.aspect;
}
public Matrix4x4 GetWorldToCameraMatrix()
{
return _renderingData.cameraData.camera.worldToCameraMatrix;
}
public bool GetOverwriteDescriptor()
{
return false;
}
public UnityEngine.Rendering.TextureDimension GetOverwriteDimension()
{
return UnityEngine.Rendering.TextureDimension.Tex2D;
}
public int GetOverwriteVolumeDepth()
{
return 1;
}
public bool GetTargetTexture()
{
return _renderingData.cameraData.camera.targetTexture != null ? true : false;
}
}
private MKGlowRenderPass _mkGlowRenderPass;
private readonly string _componentName = "MKGlow";
public override void Create()
{
_mkGlowRenderPass = new MKGlowRenderPass();
_mkGlowRenderPass.effect.Enable(RenderPipeline.SRP);
_mkGlowRenderPass.settingsRendererFeature = this;
}
public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
{
name = _componentName;
_mkGlowRenderPass.workmode = workmode;
_mkGlowRenderPass.ConfigureInput(ScriptableRenderPassInput.Color);
if(workmode == Workmode.Global)
{
_mkGlowRenderPass.scriptableRenderer = renderer;
renderer.EnqueuePass(_mkGlowRenderPass);
}
else
{
if(renderingData.cameraData.postProcessEnabled)
{
_mkGlowRenderPass.scriptableRenderer = renderer;
renderer.EnqueuePass(_mkGlowRenderPass);
}
}
}
protected override void Dispose(bool disposing)
{
_mkGlowRenderPass?.effect.Disable();
_mkGlowRenderPass?.Dispose();
_mkGlowRenderPass = null;
}
}
}

View File

@@ -0,0 +1,59 @@
Shader "Hidden/MK/Glow/URP/Copy"
{
SubShader
{
Tags {"LightMode" = "Always" "RenderType"="Opaque" "PerformanceChecks"="False"}
Cull Off ZWrite Off ZTest Always
Pass
{
Name "MK Glow Copy"
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 2.0
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
struct Attributes
{
float4 positionHCS : POSITION;
float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct Varyings
{
float4 positionCS : SV_POSITION;
float2 uv : TEXCOORD0;
UNITY_VERTEX_OUTPUT_STEREO
};
Varyings vert(Attributes input)
{
Varyings output;
UNITY_SETUP_INSTANCE_ID(input);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
output.positionCS = float4(input.positionHCS.xyz, 1.0);
#if UNITY_UV_STARTS_AT_TOP
output.positionCS.y *= -1;
#endif
output.uv = input.uv;
return output;
}
TEXTURE2D_X(_MainTex);
SAMPLER(sampler_MainTex);
half4 frag (Varyings input) : SV_Target
{
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
return SAMPLE_TEXTURE2D_X(_MainTex, sampler_MainTex, input.uv);
}
ENDHLSL
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff