From 51161b5b7afaf82fc5ec3ab0f20dd9b2a2dfbcd2 Mon Sep 17 00:00:00 2001 From: w1n7er87 Date: Thu, 14 Dec 2023 20:20:45 +0100 Subject: [PATCH] renamed MatPassID --- Unity/Assets/Scripts/SCHIZO/VFX/ARGCensor.cs | 12 ++++++------ Unity/Assets/Scripts/SCHIZO/VFX/ColorTint.cs | 4 ++-- ...MatPassID.cs => CustomMaterialPropertyBlock.cs} | 2 +- ...cs.meta => CustomMaterialPropertyBlock.cs.meta} | 0 Unity/Assets/Scripts/SCHIZO/VFX/ImageOverlay.cs | 10 +++++----- Unity/Assets/Scripts/SCHIZO/VFX/NoiseVignette.cs | 8 ++++---- Unity/Assets/Scripts/SCHIZO/VFX/SchizoVFXStack.cs | 14 +++++++------- Unity/Assets/Scripts/SCHIZO/VFX/TwoColorTint.cs | 6 +++--- Unity/Assets/Scripts/SCHIZO/VFX/VFXComponent.cs | 8 ++++---- 9 files changed, 32 insertions(+), 32 deletions(-) rename Unity/Assets/Scripts/SCHIZO/VFX/{MatPassID.cs => CustomMaterialPropertyBlock.cs} (93%) rename Unity/Assets/Scripts/SCHIZO/VFX/{MatPassID.cs.meta => CustomMaterialPropertyBlock.cs.meta} (100%) diff --git a/Unity/Assets/Scripts/SCHIZO/VFX/ARGCensor.cs b/Unity/Assets/Scripts/SCHIZO/VFX/ARGCensor.cs index e49fad2c..890e89db 100644 --- a/Unity/Assets/Scripts/SCHIZO/VFX/ARGCensor.cs +++ b/Unity/Assets/Scripts/SCHIZO/VFX/ARGCensor.cs @@ -14,7 +14,7 @@ public class ARGCensor : MonoBehaviour public float scale = 1.3f; public float frameChangeInterval = 0.08f; - private MatPassID matPassID; + private CustomMaterialPropertyBlock propBlock; private float lastUpdate; private float lastRnd; @@ -24,7 +24,7 @@ public void Awake() { _ = SchizoVFXStack.Instance; - matPassID = new MatPassID(effectMaterial); + propBlock = new CustomMaterialPropertyBlock(effectMaterial); lastUpdate = Time.time; arrayDepth = ((Texture2DArray) effectMaterial.GetTexture(_texID)).depth; @@ -49,11 +49,11 @@ public void LateUpdate() float opacity = Mathf.Clamp01((1f / pos.z) * fadeOutStartDistance); - matPassID.SetVector("_ScreenPosition", new Vector4(pos.x, pos.y, pos.z, lastRnd)); - matPassID.SetFloat("_Strength", opacity); - matPassID.SetFloat("_Scale", scale); + propBlock.SetVector("_ScreenPosition", new Vector4(pos.x, pos.y, pos.z, lastRnd)); + propBlock.SetFloat("_Strength", opacity); + propBlock.SetFloat("_Scale", scale); - SchizoVFXStack.Instance.RenderEffect(matPassID); + SchizoVFXStack.Instance.RenderEffect(propBlock); } } } diff --git a/Unity/Assets/Scripts/SCHIZO/VFX/ColorTint.cs b/Unity/Assets/Scripts/SCHIZO/VFX/ColorTint.cs index 6a42565c..bd39bf3d 100644 --- a/Unity/Assets/Scripts/SCHIZO/VFX/ColorTint.cs +++ b/Unity/Assets/Scripts/SCHIZO/VFX/ColorTint.cs @@ -11,8 +11,8 @@ public class ColorTint : VFXComponent public override void SetProperties() { base.SetProperties(); - matPassID.SetColor("_Color", color); - matPassID.PassID = (int) blendMode; + propBlock.SetColor("_Color", color); + propBlock.PassID = (int) blendMode; } } } diff --git a/Unity/Assets/Scripts/SCHIZO/VFX/MatPassID.cs b/Unity/Assets/Scripts/SCHIZO/VFX/CustomMaterialPropertyBlock.cs similarity index 93% rename from Unity/Assets/Scripts/SCHIZO/VFX/MatPassID.cs rename to Unity/Assets/Scripts/SCHIZO/VFX/CustomMaterialPropertyBlock.cs index e1b51c65..a491dac4 100644 --- a/Unity/Assets/Scripts/SCHIZO/VFX/MatPassID.cs +++ b/Unity/Assets/Scripts/SCHIZO/VFX/CustomMaterialPropertyBlock.cs @@ -6,7 +6,7 @@ namespace SCHIZO.VFX /// /// Material Properties can be set via , , , methods. /// - public sealed class MatPassID(Material material) + public sealed class CustomMaterialPropertyBlock(Material material) { public int PassID { get; set; } diff --git a/Unity/Assets/Scripts/SCHIZO/VFX/MatPassID.cs.meta b/Unity/Assets/Scripts/SCHIZO/VFX/CustomMaterialPropertyBlock.cs.meta similarity index 100% rename from Unity/Assets/Scripts/SCHIZO/VFX/MatPassID.cs.meta rename to Unity/Assets/Scripts/SCHIZO/VFX/CustomMaterialPropertyBlock.cs.meta diff --git a/Unity/Assets/Scripts/SCHIZO/VFX/ImageOverlay.cs b/Unity/Assets/Scripts/SCHIZO/VFX/ImageOverlay.cs index f4b843ba..554185cf 100644 --- a/Unity/Assets/Scripts/SCHIZO/VFX/ImageOverlay.cs +++ b/Unity/Assets/Scripts/SCHIZO/VFX/ImageOverlay.cs @@ -21,12 +21,12 @@ public class ImageOverlay : VFXComponent public override void SetProperties() { base.SetProperties(); - matPassID.PassID = (int) blendMode; + propBlock.PassID = (int) blendMode; image.wrapMode = wrapMode; - matPassID.SetTexture("_Image", image); - matPassID.SetVector("_Position", new Vector4(position.x, position.y, 0f, 0f)); - matPassID.SetFloat("_Strength", strength); - matPassID.SetFloat("_Scale", scale); + propBlock.SetTexture("_Image", image); + propBlock.SetVector("_Position", new Vector4(position.x, position.y, 0f, 0f)); + propBlock.SetFloat("_Strength", strength); + propBlock.SetFloat("_Scale", scale); } } } diff --git a/Unity/Assets/Scripts/SCHIZO/VFX/NoiseVignette.cs b/Unity/Assets/Scripts/SCHIZO/VFX/NoiseVignette.cs index bf884d4a..5176c94d 100644 --- a/Unity/Assets/Scripts/SCHIZO/VFX/NoiseVignette.cs +++ b/Unity/Assets/Scripts/SCHIZO/VFX/NoiseVignette.cs @@ -33,10 +33,10 @@ private TriValidationResult ValidateNormalMap() public override void SetProperties() { base.SetProperties(); - matPassID.SetTexture("_Image", noiseTexture); - matPassID.SetTexture("_Displacement", displacementNormal); - matPassID.SetFloat("_DispStrength", displacementStrength); - matPassID.SetFloat("_Strength", strength); + propBlock.SetTexture("_Image", noiseTexture); + propBlock.SetTexture("_Displacement", displacementNormal); + propBlock.SetFloat("_DispStrength", displacementStrength); + propBlock.SetFloat("_Strength", strength); } } } diff --git a/Unity/Assets/Scripts/SCHIZO/VFX/SchizoVFXStack.cs b/Unity/Assets/Scripts/SCHIZO/VFX/SchizoVFXStack.cs index 6de650bd..7d10dce6 100644 --- a/Unity/Assets/Scripts/SCHIZO/VFX/SchizoVFXStack.cs +++ b/Unity/Assets/Scripts/SCHIZO/VFX/SchizoVFXStack.cs @@ -16,17 +16,17 @@ public static SchizoVFXStack Instance } } - private static readonly List effectMaterials = []; + private static readonly List propertyBlocks = []; - public void RenderEffect(MatPassID m) + public void RenderEffect(CustomMaterialPropertyBlock m) { - if (effectMaterials.Contains(m)) return; - effectMaterials.Add(m); + if (propertyBlocks.Contains(m)) return; + propertyBlocks.Add(m); } private void OnRenderImage(RenderTexture source, RenderTexture destination) { - if (effectMaterials.Count == 0) + if (propertyBlocks.Count == 0) { Graphics.Blit(source, destination); return; @@ -37,7 +37,7 @@ private void OnRenderImage(RenderTexture source, RenderTexture destination) Graphics.CopyTexture(source, tempA); bool startedWithA = true; - foreach (MatPassID effectMaterial in effectMaterials) + foreach (CustomMaterialPropertyBlock effectMaterial in propertyBlocks) { Graphics.Blit(startedWithA ? tempA : tempB, startedWithA ? tempB : tempA, effectMaterial.ApplyProperties(out int passID), passID); startedWithA = !startedWithA; @@ -46,6 +46,6 @@ private void OnRenderImage(RenderTexture source, RenderTexture destination) Graphics.Blit(startedWithA ? tempA : tempB, destination); RenderTexture.ReleaseTemporary(tempA); RenderTexture.ReleaseTemporary(tempB); - effectMaterials.Clear(); + propertyBlocks.Clear(); } } diff --git a/Unity/Assets/Scripts/SCHIZO/VFX/TwoColorTint.cs b/Unity/Assets/Scripts/SCHIZO/VFX/TwoColorTint.cs index 14793617..e4a8fc9e 100644 --- a/Unity/Assets/Scripts/SCHIZO/VFX/TwoColorTint.cs +++ b/Unity/Assets/Scripts/SCHIZO/VFX/TwoColorTint.cs @@ -13,9 +13,9 @@ public class TwoColorTint : VFXComponent public override void SetProperties() { base.SetProperties(); - matPassID.SetColor("_Color", innerColor); - matPassID.SetColor("_Color0", outerColor); - matPassID.SetFloat("_Strength", strength); + propBlock.SetColor("_Color", innerColor); + propBlock.SetColor("_Color0", outerColor); + propBlock.SetFloat("_Strength", strength); } } } diff --git a/Unity/Assets/Scripts/SCHIZO/VFX/VFXComponent.cs b/Unity/Assets/Scripts/SCHIZO/VFX/VFXComponent.cs index 8b9144d6..27d896ce 100644 --- a/Unity/Assets/Scripts/SCHIZO/VFX/VFXComponent.cs +++ b/Unity/Assets/Scripts/SCHIZO/VFX/VFXComponent.cs @@ -11,7 +11,7 @@ public abstract class VFXComponent : MonoBehaviour // ReSharper disable once RedundantNameQualifier [global::TriInspector.ReadOnly] public Material material; - [HideInInspector] public MatPassID matPassID; + [HideInInspector] public CustomMaterialPropertyBlock propBlock; #if UNITY_EDITOR [OnValueChanged(nameof(SetNewResultTexture))] @@ -26,7 +26,7 @@ private void OnValidate() if (previewResult == null || ((previewImage.height != previewResult.height) || (previewImage.width != previewResult.width))) SetNewResultTexture(); SetProperties(); RenderTexture tempResult = RenderTexture.GetTemporary(previewImage.width, previewImage.height, 0, RenderTextureFormat.ARGBHalf); - Graphics.Blit(previewImage, tempResult, matPassID.ApplyProperties(out int passID), passID); + Graphics.Blit(previewImage, tempResult, propBlock.ApplyProperties(out int passID), passID); Graphics.ConvertTexture(tempResult, previewResult); tempResult.Release(); } @@ -40,13 +40,13 @@ private void SetNewResultTexture() public virtual void SetProperties() { - matPassID ??= new MatPassID(material); + propBlock ??= new CustomMaterialPropertyBlock(material); } public virtual void Update() { SetProperties(); - SchizoVFXStack.Instance.RenderEffect(matPassID); + SchizoVFXStack.Instance.RenderEffect(propBlock); } } }