├── CustomEffects.meta ├── CustomEffects ├── EdgeDetection.meta ├── EdgeDetection │ ├── EdgeDetection.cs │ ├── EdgeDetection.cs.meta │ ├── EdgeDetectionRenderFeature.cs │ └── EdgeDetectionRenderFeature.cs.meta ├── Grayscale.meta ├── Grayscale │ ├── Grayscale.cs │ ├── Grayscale.cs.meta │ ├── GrayscaleRenderFeature.cs │ └── GrayscaleRenderFeature.cs.meta ├── GrayscaleCS.meta ├── GrayscaleCS │ ├── GrayscaleCS.cs │ ├── GrayscaleCS.cs.meta │ ├── GrayscaleCSRenderFeature.cs │ └── GrayscaleCSRenderFeature.cs.meta ├── OilPaint.meta ├── OilPaint │ ├── OilPaint.cs │ ├── OilPaint.cs.meta │ ├── OilPaintRenderFeature.cs │ └── OilPaintRenderFeature.cs.meta ├── Pencil.meta ├── Pencil │ ├── Pencil.cs │ ├── Pencil.cs.meta │ ├── PencilRenderFeature.cs │ └── PencilRenderFeature.cs.meta ├── RadialBlur.meta └── RadialBlur │ ├── RadialBlur.cs │ ├── RadialBlur.cs.meta │ ├── RadialBlurRenderFeature.cs │ └── RadialBlurRenderFeature.cs.meta ├── CustomPass.cs ├── CustomPass.cs.meta ├── CustomRenderFeature.cs ├── CustomRenderFeature.cs.meta ├── Kino.meta ├── Kino ├── AnalogGlitch.meta ├── AnalogGlitch │ ├── AnalogGlitch.cs │ ├── AnalogGlitch.cs.meta │ ├── AnalogGlitchRenderFeature.cs │ └── AnalogGlitchRenderFeature.cs.meta ├── Contour.meta ├── Contour │ ├── Contour.cs │ ├── Contour.cs.meta │ ├── ContourRenderFeature.cs │ └── ContourRenderFeature.cs.meta ├── DigitalGlitch.meta ├── DigitalGlitch │ ├── DigitalGlitch.cs │ ├── DigitalGlitch.cs.meta │ ├── DigitalGlitchRenderFeature.cs │ └── DigitalGlitchRenderFeature.cs.meta ├── Streak.meta ├── Streak │ ├── Streak.cs │ ├── Streak.cs.meta │ ├── StreakRenderFeature.cs │ └── StreakRenderFeature.cs.meta ├── WaterColor.meta └── WaterColor │ ├── WaterColor.cs │ ├── WaterColor.cs.meta │ ├── WaterColorRenderFeature.cs │ └── WaterColorRenderFeature.cs.meta ├── LICENSE ├── README.md ├── Reshade.meta ├── Reshade ├── ADOF.meta ├── ADOF │ ├── ADOF.cs │ ├── ADOF.cs.meta │ ├── ADOFRenderFeature.cs │ └── ADOFRenderFeature.cs.meta ├── AdaptiveFog.meta ├── AdaptiveFog │ ├── AdaptiveFog.cs │ ├── AdaptiveFog.cs.meta │ ├── AdaptiveFogRenderFeature.cs │ └── AdaptiveFogRenderFeature.cs.meta ├── AdaptiveSharpen.meta ├── AdaptiveSharpen │ ├── AdaptiveSharpen.cs │ ├── AdaptiveSharpen.cs.meta │ ├── AdaptiveSharpenRenderFeature.cs │ └── AdaptiveSharpenRenderFeature.cs.meta ├── Cartoon.meta ├── Cartoon │ ├── Cartoon.cs │ ├── Cartoon.cs.meta │ ├── CartoonRenderFeature.cs │ └── CartoonRenderFeature.cs.meta ├── Clarity2.meta ├── Clarity2 │ ├── Clarity2.cs │ ├── Clarity2.cs.meta │ ├── Clarity2RenderFeature.cs │ └── Clarity2RenderFeature.cs.meta ├── FakeHDR.meta └── FakeHDR │ ├── FakeHDR.cs │ ├── FakeHDR.cs.meta │ ├── FakeHDRRenderFeature.cs │ └── FakeHDRRenderFeature.cs.meta ├── Resources.meta └── Resources ├── Shaders.meta ├── Shaders ├── ADOF.shader ├── ADOF.shader.meta ├── AdaptiveFog.shader ├── AdaptiveFog.shader.meta ├── AdaptiveSharpen.shader ├── AdaptiveSharpen.shader.meta ├── AnalogGlitch.shader ├── AnalogGlitch.shader.meta ├── Cartoon.shader ├── Cartoon.shader.meta ├── Clarity2.shader ├── Clarity2.shader.meta ├── Common.hlsl ├── Common.hlsl.meta ├── Contour.shader ├── Contour.shader.meta ├── DigitalGlitch.shader ├── DigitalGlitch.shader.meta ├── EdgeDetection.shader ├── EdgeDetection.shader.meta ├── FakeHDR.shader ├── FakeHDR.shader.meta ├── Grayscale.shader ├── Grayscale.shader.meta ├── GrayscaleCS.compute ├── GrayscaleCS.compute.meta ├── OilPaint.shader ├── OilPaint.shader.meta ├── Pencil.shader ├── Pencil.shader.meta ├── RadialBlur.shader ├── RadialBlur.shader.meta ├── Streak.shader ├── Streak.shader.meta ├── WaterColor.shader └── WaterColor.shader.meta ├── Textures.meta └── Textures ├── WaterColorNoise.png └── WaterColorNoise.png.meta /CustomEffects.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ecf713da755c3b9488e599bcff13ae71 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /CustomEffects/EdgeDetection.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0dcc17e4f28a4e74ca0c48a2d0959204 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /CustomEffects/EdgeDetection/EdgeDetection.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Rendering; 3 | using UnityEngine.Rendering.Universal; 4 | 5 | #if UNITY_EDITOR 6 | using UnityEditor.Rendering; 7 | #endif 8 | 9 | [System.Serializable, VolumeComponentMenu("Post-processing Custom/EdgeDetection")] 10 | public class EdgeDetection : VolumeComponent, IPostProcessComponent 11 | { 12 | public BoolParameter enable = new BoolParameter(false); 13 | 14 | [Tooltip("Controls the blending between the original and the edge color.")] 15 | public ClampedFloatParameter intensity = new ClampedFloatParameter(0.5f, 0f, 1f); 16 | 17 | [Tooltip("Defines the edge thickness.")] 18 | public MinFloatParameter thickness = new MinFloatParameter(1, 0); 19 | 20 | [Tooltip("Define the threshold of the normal difference in degrees.")] 21 | public FloatRangeParameter normalThreshold = new FloatRangeParameter(new Vector2(1, 2), 0, 360); 22 | 23 | [Tooltip("Define the threshold of the depth difference in world units.")] 24 | public FloatRangeParameter depthThreshold = new FloatRangeParameter(new Vector2(0.1f, 0.11f), 0, 1); 25 | 26 | [Tooltip("Define the edge color.")] 27 | public ColorParameter color = new ColorParameter(Color.black, true, false, true); 28 | 29 | #region IPostProcessComponent 30 | public bool IsActive() => enable.value && intensity.value > 0f; 31 | public bool IsTileCompatible() => false; 32 | #endregion 33 | } 34 | 35 | #if UNITY_EDITOR 36 | [VolumeComponentEditor(typeof(EdgeDetection))] 37 | class EdgeDetectionEditor : VolumeComponentEditor 38 | { 39 | SerializedDataParameter intensity; 40 | SerializedDataParameter thickness; 41 | SerializedDataParameter normalThreshold; 42 | SerializedDataParameter depthThreshold; 43 | SerializedDataParameter color; 44 | 45 | public override void OnEnable() 46 | { 47 | var edgeDetection = (EdgeDetection)target; 48 | edgeDetection.enable.value = true; 49 | edgeDetection.enable.overrideState = true; 50 | 51 | var o = new PropertyFetcher(serializedObject); 52 | intensity = Unpack(o.Find(x => x.intensity)); 53 | thickness = Unpack(o.Find(x => x.thickness)); 54 | normalThreshold = Unpack(o.Find(x => x.normalThreshold)); 55 | depthThreshold = Unpack(o.Find(x => x.depthThreshold)); 56 | color = Unpack(o.Find(x => x.color)); 57 | } 58 | 59 | public override void OnInspectorGUI() 60 | { 61 | PropertyField(intensity); 62 | PropertyField(thickness); 63 | PropertyField(normalThreshold); 64 | PropertyField(depthThreshold); 65 | PropertyField(color); 66 | } 67 | } 68 | #endif 69 | 70 | -------------------------------------------------------------------------------- /CustomEffects/EdgeDetection/EdgeDetection.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 277fe81ef8b8b0548a8c32ac172ae69a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /CustomEffects/EdgeDetection/EdgeDetectionRenderFeature.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Rendering; 3 | using UnityEngine.Rendering.Universal; 4 | 5 | public class EdgeDetectionRenderFeature : CustomRenderFeature 6 | { 7 | protected override CustomPass CreatePass(RenderPassEvent renderPassEvent) 8 | { 9 | return new EdgeDetectionPass(renderPassEvent); 10 | } 11 | } 12 | 13 | public class EdgeDetectionPass : CustomPass 14 | { 15 | public override string GetShaderPath() => "Hidden/PostProcessing/EdgeDetection"; 16 | public override string renderTag => "Render EdgeDetection Effects"; 17 | 18 | public EdgeDetectionPass(RenderPassEvent renderPassEvent) : base(renderPassEvent) { } 19 | 20 | static class ShaderPropertyID 21 | { 22 | internal static readonly int MainTex = Shader.PropertyToID("_MainTex"); 23 | 24 | internal readonly static int Intensity = Shader.PropertyToID("_Intensity"); 25 | internal readonly static int Threshold = Shader.PropertyToID("_Threshold"); 26 | internal readonly static int Thickness = Shader.PropertyToID("_Thickness"); 27 | internal readonly static int Color = Shader.PropertyToID("_Color"); 28 | } 29 | 30 | protected override void Render(CommandBuffer cmd, ref RenderingData renderingData) 31 | { 32 | material.SetFloat(ShaderPropertyID.Intensity, volumeComponent.intensity.value); 33 | material.SetFloat(ShaderPropertyID.Thickness, volumeComponent.thickness.value); 34 | Vector2 normalThreshold = volumeComponent.normalThreshold.value; 35 | Vector2 depthThreshold = volumeComponent.depthThreshold.value; 36 | Vector4 threshold = new Vector4(Mathf.Cos(normalThreshold.y * Mathf.Deg2Rad), Mathf.Cos(normalThreshold.x * Mathf.Deg2Rad), depthThreshold.x, depthThreshold.y); 37 | material.SetVector(ShaderPropertyID.Threshold, threshold); 38 | material.SetColor(ShaderPropertyID.Color, volumeComponent.color.value); 39 | 40 | cmd.SetGlobalTexture(ShaderPropertyID.MainTex, source); 41 | cmd.Blit(source, destination, material); 42 | } 43 | } -------------------------------------------------------------------------------- /CustomEffects/EdgeDetection/EdgeDetectionRenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b62c83076d7281d44aa9fd7dd65afa15 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /CustomEffects/Grayscale.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 729eaa1e3bee1bd4fac8cdadff3a3398 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /CustomEffects/Grayscale/Grayscale.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Rendering; 3 | using UnityEngine.Rendering.Universal; 4 | 5 | #if UNITY_EDITOR 6 | using UnityEditor.Rendering; 7 | #endif 8 | 9 | [System.Serializable, VolumeComponentMenu("Post-processing Custom/Grayscale")] 10 | public class Grayscale : VolumeComponent, IPostProcessComponent 11 | { 12 | public BoolParameter enable = new BoolParameter(false); 13 | 14 | [Range(0f, 1f)] 15 | public ClampedFloatParameter blendRate = new ClampedFloatParameter(0.5f, 0f, 1f); 16 | 17 | #region IPostProcessComponent 18 | public bool IsActive() => enable.value && blendRate.value > 0f; 19 | public bool IsTileCompatible() => false; 20 | #endregion 21 | } 22 | 23 | #if UNITY_EDITOR 24 | [VolumeComponentEditor(typeof(Grayscale))] 25 | class GrayscaleEditor : VolumeComponentEditor 26 | { 27 | SerializedDataParameter blendRate; 28 | 29 | public override void OnEnable() 30 | { 31 | var component = (Grayscale)target; 32 | component.enable.value = true; 33 | component.enable.overrideState = true; 34 | 35 | var o = new PropertyFetcher(serializedObject); 36 | blendRate = Unpack(o.Find(x => x.blendRate)); 37 | } 38 | 39 | public override void OnInspectorGUI() 40 | { 41 | PropertyField(blendRate); 42 | } 43 | } 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /CustomEffects/Grayscale/Grayscale.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 01fdf3a459df2ba49979745e4a8bdcb8 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /CustomEffects/Grayscale/GrayscaleRenderFeature.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Rendering; 3 | using UnityEngine.Rendering.Universal; 4 | 5 | public class GrayscaleRenderFeature : CustomRenderFeature 6 | { 7 | protected override CustomPass CreatePass(RenderPassEvent renderPassEvent) 8 | { 9 | return new GrayscalePass(renderPassEvent); 10 | } 11 | } 12 | 13 | public class GrayscalePass : CustomPass 14 | { 15 | public override string GetShaderPath() => "Hidden/PostProcessing/Grayscale"; 16 | public override string renderTag => "Render Grayscale Effects"; 17 | 18 | public GrayscalePass(RenderPassEvent renderPassEvent) : base(renderPassEvent) { } 19 | 20 | static class ShaderPropertyID 21 | { 22 | internal static readonly int MainTex = Shader.PropertyToID("_MainTex"); 23 | 24 | internal static readonly int Blend = Shader.PropertyToID("_Blend"); 25 | } 26 | 27 | protected override void Render(CommandBuffer cmd, ref RenderingData renderingData) 28 | { 29 | material.SetFloat(ShaderPropertyID.Blend, volumeComponent.blendRate.value); 30 | 31 | cmd.SetGlobalTexture(ShaderPropertyID.MainTex, source); 32 | cmd.Blit(source, destination, material); 33 | } 34 | } -------------------------------------------------------------------------------- /CustomEffects/Grayscale/GrayscaleRenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 989a66363be1efe4daa2dea4004c60c2 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /CustomEffects/GrayscaleCS.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d8c0cbb04a889b24da66089b49226550 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /CustomEffects/GrayscaleCS/GrayscaleCS.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Rendering; 3 | using UnityEngine.Rendering.Universal; 4 | 5 | #if UNITY_EDITOR 6 | using UnityEditor.Rendering; 7 | #endif 8 | 9 | [System.Serializable, VolumeComponentMenu("Post-processing Custom/GrayscaleCS")] 10 | public class GrayscaleCS : VolumeComponent, IPostProcessComponent 11 | { 12 | public BoolParameter enable = new BoolParameter(false); 13 | 14 | [Range(0f, 1f)] 15 | public ClampedFloatParameter blendRate = new ClampedFloatParameter(0.5f, 0f, 1f); 16 | 17 | #region IPostProcessComponent 18 | public bool IsActive() => enable.value && blendRate.value > 0f; 19 | public bool IsTileCompatible() => false; 20 | #endregion 21 | } 22 | 23 | #if UNITY_EDITOR 24 | [VolumeComponentEditor(typeof(GrayscaleCS))] 25 | class GrayscaleCSEditor : VolumeComponentEditor 26 | { 27 | SerializedDataParameter blendRate; 28 | 29 | public override void OnEnable() 30 | { 31 | var grayscale = (GrayscaleCS)target; 32 | grayscale.enable.value = true; 33 | grayscale.enable.overrideState = true; 34 | 35 | var o = new PropertyFetcher(serializedObject); 36 | blendRate = Unpack(o.Find(x => x.blendRate)); 37 | } 38 | 39 | public override void OnInspectorGUI() 40 | { 41 | PropertyField(blendRate); 42 | } 43 | } 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /CustomEffects/GrayscaleCS/GrayscaleCS.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f2d6d9b66ad1e8c4a8953cb006c635db 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /CustomEffects/GrayscaleCS/GrayscaleCSRenderFeature.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Rendering; 3 | using UnityEngine.Rendering.Universal; 4 | 5 | public class GrayscaleCSRenderFeature : CustomRenderFeature 6 | { 7 | [SerializeField] 8 | ComputeShader shader; 9 | 10 | protected override CustomPass CreatePass(RenderPassEvent renderPassEvent) 11 | { 12 | settings.renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing; 13 | 14 | var pass = new GrayscaleCSPass(settings.renderPassEvent); 15 | pass.computeShader = shader; 16 | return pass; 17 | } 18 | } 19 | 20 | public class GrayscaleCSPass : CustomPass 21 | { 22 | public override string GetShaderPath() => "GrayscaleCS"; 23 | public override string renderTag => "Render Grayscale Effects"; 24 | 25 | public GrayscaleCSPass(RenderPassEvent renderPassEvent) : base(renderPassEvent) { } 26 | 27 | static class ShaderPropertyID 28 | { 29 | internal static readonly int MainTex = Shader.PropertyToID("_MainTex"); 30 | internal static readonly int Source = Shader.PropertyToID("_SourceTex"); 31 | internal static readonly int Result = Shader.PropertyToID("_ResultTex"); 32 | 33 | internal static readonly int Blend = Shader.PropertyToID("_Blend"); 34 | } 35 | 36 | public ComputeShader computeShader; 37 | string kernelName = "GrayscaleCS"; 38 | int kernelIndex = -1; 39 | public override void Init(string shaderPath) 40 | { 41 | if (computeShader != null && computeShader.HasKernel(kernelName)) { 42 | kernelIndex = computeShader.FindKernel(kernelName); 43 | } 44 | } 45 | 46 | public override bool IsValid() 47 | { 48 | return kernelIndex != -1; 49 | } 50 | 51 | protected override void Render(CommandBuffer cmd, ref RenderingData renderingData) 52 | { 53 | var descriptor = renderingData.cameraData.cameraTargetDescriptor; 54 | var width = descriptor.width; 55 | var height = descriptor.height; 56 | 57 | cmd.GetTemporaryRT(ShaderPropertyID.Result, width, height, 0, FilterMode.Point, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default, 1, true); 58 | var rtResult = new RenderTargetIdentifier(ShaderPropertyID.Result); 59 | 60 | cmd.SetComputeTextureParam(computeShader, kernelIndex, ShaderPropertyID.MainTex, source); 61 | cmd.SetComputeTextureParam(computeShader, kernelIndex, ShaderPropertyID.Result, rtResult); 62 | cmd.SetComputeFloatParam(computeShader, ShaderPropertyID.Blend, volumeComponent.blendRate.value); 63 | 64 | cmd.DispatchCompute(computeShader, kernelIndex, width, height, 1); 65 | cmd.Blit(rtResult, destination); 66 | 67 | cmd.ReleaseTemporaryRT(ShaderPropertyID.Result); 68 | } 69 | } -------------------------------------------------------------------------------- /CustomEffects/GrayscaleCS/GrayscaleCSRenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 829a5ae5f14a59548b8cf09b906eab9a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /CustomEffects/OilPaint.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3be4ff7c8b4662b4ab2ab59fe075b40b 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /CustomEffects/OilPaint/OilPaint.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Rendering; 3 | using UnityEngine.Rendering.Universal; 4 | 5 | #if UNITY_EDITOR 6 | using UnityEditor.Rendering; 7 | #endif 8 | 9 | [System.Serializable, VolumeComponentMenu("Post-processing Custom/OilPaint")] 10 | public class OilPaint : VolumeComponent, IPostProcessComponent 11 | { 12 | public BoolParameter enable = new BoolParameter(false); 13 | 14 | [Range(0, 16), Tooltip("Brush Radius")] 15 | public IntParameter radius = new IntParameter(8); 16 | 17 | #region IPostProcessComponent 18 | public bool IsActive() => enable.value && radius.value > 0; 19 | public bool IsTileCompatible() => false; 20 | #endregion 21 | } 22 | 23 | #if UNITY_EDITOR 24 | [VolumeComponentEditor(typeof(OilPaint))] 25 | class OilPaintEditor : VolumeComponentEditor 26 | { 27 | SerializedDataParameter radius; 28 | 29 | public override void OnEnable() 30 | { 31 | var oilPaint = (OilPaint)target; 32 | oilPaint.enable.value = true; 33 | oilPaint.enable.overrideState = true; 34 | 35 | var o = new PropertyFetcher(serializedObject); 36 | radius = Unpack(o.Find(x => x.radius)); 37 | } 38 | 39 | public override void OnInspectorGUI() 40 | { 41 | PropertyField(radius); 42 | } 43 | } 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /CustomEffects/OilPaint/OilPaint.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9f0c2918f6f87b841974eb10cebe2404 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /CustomEffects/OilPaint/OilPaintRenderFeature.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Rendering; 3 | using UnityEngine.Rendering.Universal; 4 | 5 | public class OilPaintRenderFeature : CustomRenderFeature 6 | { 7 | protected override CustomPass CreatePass(RenderPassEvent renderPassEvent) 8 | { 9 | return new OilPaintPass(renderPassEvent); 10 | } 11 | } 12 | 13 | public class OilPaintPass : CustomPass 14 | { 15 | public override string GetShaderPath() => "Hidden/PostProcessing/OilPaint"; 16 | public override string renderTag => "Render OilPaint Effects"; 17 | 18 | public OilPaintPass(RenderPassEvent renderPassEvent) : base(renderPassEvent) { } 19 | 20 | static class ShaderPropertyID 21 | { 22 | internal static readonly int MainTex = Shader.PropertyToID("_MainTex"); 23 | 24 | internal static readonly int Radius = Shader.PropertyToID("_Radius"); 25 | } 26 | 27 | protected override void Render(CommandBuffer cmd, ref RenderingData renderingData) 28 | { 29 | material.SetFloat(ShaderPropertyID.Radius, volumeComponent.radius.value); 30 | 31 | cmd.SetGlobalTexture(ShaderPropertyID.MainTex, source); 32 | cmd.Blit(source, destination, material); 33 | } 34 | } -------------------------------------------------------------------------------- /CustomEffects/OilPaint/OilPaintRenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 07de5c92906326143bef32ac099d600c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /CustomEffects/Pencil.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bd9464fda082f9a4fba1aa8639fff438 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /CustomEffects/Pencil/Pencil.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Rendering; 3 | using UnityEngine.Rendering.Universal; 4 | 5 | #if UNITY_EDITOR 6 | using UnityEditor.Rendering; 7 | #endif 8 | 9 | [System.Serializable, VolumeComponentMenu("Post-processing Custom/Pencil")] 10 | public class Pencil : VolumeComponent, IPostProcessComponent 11 | { 12 | public BoolParameter enable = new BoolParameter(false); 13 | 14 | [Tooltip("Gradient Threshold")] 15 | public ClampedFloatParameter gradThreshold = new ClampedFloatParameter(0.01f, 0.00001f, 0.01f); 16 | [Tooltip("Color Threshold")] 17 | public ClampedFloatParameter colorThreshold = new ClampedFloatParameter(0.8f, 0f, 1f); 18 | public ClampedFloatParameter sensivity = new ClampedFloatParameter(10f, 0f, 100f); 19 | 20 | #region IPostProcessComponent 21 | public bool IsActive() => enable.value; 22 | public bool IsTileCompatible() => false; 23 | #endregion 24 | } 25 | 26 | #if UNITY_EDITOR 27 | [VolumeComponentEditor(typeof(Pencil))] 28 | class PencilEditor : VolumeComponentEditor 29 | { 30 | SerializedDataParameter gradThreshold; 31 | SerializedDataParameter colorThreshold; 32 | SerializedDataParameter sensivity; 33 | 34 | public override void OnEnable() 35 | { 36 | var pencil = (Pencil)target; 37 | pencil.enable.value = true; 38 | pencil.enable.overrideState = true; 39 | 40 | var o = new PropertyFetcher(serializedObject); 41 | gradThreshold = Unpack(o.Find(x => x.gradThreshold)); 42 | colorThreshold = Unpack(o.Find(x => x.colorThreshold)); 43 | sensivity = Unpack(o.Find(x => x.sensivity)); 44 | } 45 | 46 | public override void OnInspectorGUI() 47 | { 48 | PropertyField(gradThreshold); 49 | PropertyField(colorThreshold); 50 | PropertyField(sensivity); 51 | } 52 | } 53 | #endif 54 | 55 | -------------------------------------------------------------------------------- /CustomEffects/Pencil/Pencil.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ba1799745d5ee25489322cbf96308bc4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /CustomEffects/Pencil/PencilRenderFeature.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Rendering; 3 | using UnityEngine.Rendering.Universal; 4 | 5 | public class PencilRenderFeature : CustomRenderFeature 6 | { 7 | protected override CustomPass CreatePass(RenderPassEvent renderPassEvent) 8 | { 9 | return new PencilPass(renderPassEvent); 10 | } 11 | } 12 | 13 | public class PencilPass : CustomPass 14 | { 15 | public override string GetShaderPath() => "Hidden/PostProcessing/Pencil"; 16 | public override string renderTag => "Render Pencil Effects"; 17 | 18 | public PencilPass(RenderPassEvent renderPassEvent) : base(renderPassEvent) { } 19 | 20 | static class ShaderPropertyID 21 | { 22 | internal static readonly int MainTex = Shader.PropertyToID("_MainTex"); 23 | 24 | internal static readonly int GradThreshold = Shader.PropertyToID("_GradThreshold"); 25 | internal static readonly int ColorThreshold = Shader.PropertyToID("_ColorThreshold"); 26 | internal static readonly int Sensivity = Shader.PropertyToID("_Sensivity"); 27 | } 28 | 29 | protected override void Render(CommandBuffer cmd, ref RenderingData renderingData) 30 | { 31 | material.SetFloat(ShaderPropertyID.GradThreshold, volumeComponent.gradThreshold.value); 32 | material.SetFloat(ShaderPropertyID.ColorThreshold, volumeComponent.colorThreshold.value); 33 | material.SetFloat(ShaderPropertyID.Sensivity, volumeComponent.sensivity.value); 34 | 35 | cmd.SetGlobalTexture(ShaderPropertyID.MainTex, source); 36 | cmd.Blit(source, destination, material); 37 | } 38 | } -------------------------------------------------------------------------------- /CustomEffects/Pencil/PencilRenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: be6e2e1fa3a50e24884c3fbcdc37b2fe 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /CustomEffects/RadialBlur.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4c780110c7095f94e8e29ae23ef15d23 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /CustomEffects/RadialBlur/RadialBlur.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Rendering; 3 | using UnityEngine.Rendering.Universal; 4 | 5 | #if UNITY_EDITOR 6 | using UnityEditor.Rendering; 7 | #endif 8 | 9 | [System.Serializable, VolumeComponentMenu("Post-processing Custom/RadialBlur")] 10 | public class RadialBlur : VolumeComponent, IPostProcessComponent 11 | { 12 | public BoolParameter enable = new BoolParameter(false); 13 | 14 | [Range(0f, 1f)] 15 | public ClampedFloatParameter blurRadius = new ClampedFloatParameter(0.025f, 0f, 1f); 16 | [Range(2, 30)] 17 | public ClampedIntParameter iteration = new ClampedIntParameter(10, 2, 30); 18 | [Range(0f, 1f)] 19 | public ClampedFloatParameter radialCenterX = new ClampedFloatParameter(0.5f, 0f, 1f); 20 | [Range(0f, 1f)] 21 | public ClampedFloatParameter radialCenterY = new ClampedFloatParameter(0.5f, 0f, 1f); 22 | 23 | #region IPostProcessComponent 24 | public bool IsActive() => enable.value; 25 | public bool IsTileCompatible() => false; 26 | #endregion 27 | } 28 | 29 | #if UNITY_EDITOR 30 | [VolumeComponentEditor(typeof(RadialBlur))] 31 | class RadialBlurEditor : VolumeComponentEditor 32 | { 33 | SerializedDataParameter blurRadius; 34 | SerializedDataParameter iteration; 35 | SerializedDataParameter radialCenterX; 36 | SerializedDataParameter radialCenterY; 37 | 38 | public override void OnEnable() 39 | { 40 | var radialBlur = (RadialBlur)target; 41 | radialBlur.enable.value = true; 42 | radialBlur.enable.overrideState = true; 43 | 44 | var o = new PropertyFetcher(serializedObject); 45 | blurRadius = Unpack(o.Find(x => x.blurRadius)); 46 | iteration = Unpack(o.Find(x => x.iteration)); 47 | radialCenterX = Unpack(o.Find(x => x.radialCenterX)); 48 | radialCenterY = Unpack(o.Find(x => x.radialCenterY)); 49 | } 50 | 51 | public override void OnInspectorGUI() 52 | { 53 | PropertyField(blurRadius); 54 | PropertyField(iteration); 55 | PropertyField(radialCenterX); 56 | PropertyField(radialCenterY); 57 | } 58 | } 59 | #endif 60 | 61 | -------------------------------------------------------------------------------- /CustomEffects/RadialBlur/RadialBlur.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a8ac87cc9b21fb84794e7121a5b92884 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /CustomEffects/RadialBlur/RadialBlurRenderFeature.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Rendering; 3 | using UnityEngine.Rendering.Universal; 4 | 5 | public class RadialBlurRenderFeature : CustomRenderFeature 6 | { 7 | protected override CustomPass CreatePass(RenderPassEvent renderPassEvent) 8 | { 9 | return new RadialBlurPass(renderPassEvent); 10 | } 11 | } 12 | 13 | public class RadialBlurPass : CustomPass 14 | { 15 | public override string GetShaderPath() => "Hidden/PostProcessing/RadialBlur"; 16 | public override string renderTag => "Render RadialBlur Effects"; 17 | 18 | public RadialBlurPass(RenderPassEvent renderPassEvent) : base(renderPassEvent) { } 19 | 20 | static class ShaderPropertyID 21 | { 22 | internal static readonly int MainTex = Shader.PropertyToID("_MainTex"); 23 | 24 | internal static readonly int BlurRadius = Shader.PropertyToID("_BlurRadius"); 25 | internal static readonly int Iteration = Shader.PropertyToID("_Iteration"); 26 | internal static readonly int RadialCenterX = Shader.PropertyToID("_RadialCenterX"); 27 | internal static readonly int RadialCenterY = Shader.PropertyToID("_RadialCenterY"); 28 | } 29 | 30 | protected override void Render(CommandBuffer cmd, ref RenderingData renderingData) 31 | { 32 | material.SetFloat(ShaderPropertyID.BlurRadius, volumeComponent.blurRadius.value); 33 | material.SetFloat(ShaderPropertyID.Iteration, volumeComponent.iteration.value); 34 | material.SetFloat(ShaderPropertyID.RadialCenterX, volumeComponent.radialCenterX.value); 35 | material.SetFloat(ShaderPropertyID.RadialCenterY, volumeComponent.radialCenterY.value); 36 | 37 | cmd.SetGlobalTexture(ShaderPropertyID.MainTex, source); 38 | cmd.Blit(source, destination, material); 39 | } 40 | } -------------------------------------------------------------------------------- /CustomEffects/RadialBlur/RadialBlurRenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0168dab0bdcf5b7459d8656d3717c837 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /CustomPass.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Rendering; 3 | using UnityEngine.Rendering.Universal; 4 | 5 | public class CustomPass : ScriptableRenderPass where T : VolumeComponent, IPostProcessComponent 6 | { 7 | protected T volumeComponent; 8 | CustomRenderFeature.Settings settings; 9 | 10 | public virtual string GetShaderPath() { return null; } 11 | public virtual string renderTag => "Render Custom Effects"; 12 | public FilterMode filterMode { get; set; } 13 | 14 | protected Material material; 15 | protected RenderTargetIdentifier source; 16 | protected RenderTargetIdentifier destination; 17 | 18 | public CustomPass(RenderPassEvent renderPassEvent) 19 | { 20 | this.renderPassEvent = renderPassEvent; 21 | } 22 | 23 | public void Setup(CustomRenderFeature.Settings featureSettings) 24 | { 25 | settings = featureSettings; 26 | renderPassEvent = featureSettings.renderPassEvent; 27 | } 28 | 29 | public override void OnCameraSetup(CommandBuffer cmd, ref RenderingData renderingData) 30 | { 31 | RenderTextureDescriptor blitTargetDescriptor = renderingData.cameraData.cameraTargetDescriptor; 32 | blitTargetDescriptor.depthBufferBits = 0; 33 | 34 | var isSourceAndDestinationSameTarget = settings.sourceType == settings.destinationType && 35 | (settings.sourceType == CustomRenderFeature.BufferType.CameraColor || settings.sourceTexture == settings.destinationTexture); 36 | 37 | var renderer = renderingData.cameraData.renderer; 38 | 39 | if (settings.sourceType == CustomRenderFeature.BufferType.CameraColor) { 40 | source = renderer.cameraColorTargetHandle; 41 | } 42 | else { 43 | var sourceId = Shader.PropertyToID(settings.sourceTexture); 44 | cmd.GetTemporaryRT(sourceId, blitTargetDescriptor, filterMode); 45 | source = new RenderTargetIdentifier(sourceId); 46 | } 47 | 48 | if (isSourceAndDestinationSameTarget) { 49 | destination = source; 50 | } 51 | else { 52 | var destinationId = Shader.PropertyToID(settings.destinationTexture); 53 | cmd.GetTemporaryRT(destinationId, blitTargetDescriptor, filterMode); 54 | destination = new RenderTargetIdentifier(destinationId); 55 | } 56 | } 57 | 58 | public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) 59 | { 60 | if (!renderingData.cameraData.postProcessEnabled || !IsValid()) 61 | return; 62 | 63 | var stack = VolumeManager.instance.stack; 64 | volumeComponent = stack.GetComponent(); 65 | if (volumeComponent == null || !volumeComponent.IsActive()) return; 66 | 67 | var cmd = CommandBufferPool.Get(renderTag); 68 | Render(cmd, ref renderingData); 69 | context.ExecuteCommandBuffer(cmd); 70 | CommandBufferPool.Release(cmd); 71 | } 72 | 73 | public virtual bool IsValid() 74 | { 75 | return material != null; 76 | } 77 | 78 | public virtual void Init(string shaderPath) 79 | { 80 | var shader = Shader.Find(shaderPath); 81 | if (shader == null) 82 | return; 83 | 84 | material = CoreUtils.CreateEngineMaterial(shader); 85 | } 86 | 87 | public virtual void Release() { if (material != null) CoreUtils.Destroy(material); } 88 | protected virtual void Render(CommandBuffer cmd, ref RenderingData renderingData) { } 89 | } 90 | -------------------------------------------------------------------------------- /CustomPass.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2de1ae6facb5fb441a225f478bf72ffc 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /CustomRenderFeature.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Rendering; 3 | using UnityEngine.Rendering.Universal; 4 | 5 | public class CustomRenderFeature : ScriptableRendererFeature where T : VolumeComponent, IPostProcessComponent 6 | { 7 | public enum BufferType 8 | { 9 | CameraColor, 10 | Custom 11 | } 12 | 13 | [System.Serializable] 14 | public class Settings 15 | { 16 | public RenderPassEvent renderPassEvent = RenderPassEvent.AfterRenderingOpaques; 17 | public BufferType sourceType = BufferType.CameraColor; 18 | public BufferType destinationType = BufferType.CameraColor; 19 | public string sourceTexture = "_SourceTexture"; 20 | public string destinationTexture = "_DestinationTexture"; 21 | } 22 | public Settings settings = new Settings(); 23 | 24 | CustomPass pass; 25 | public override void Create() 26 | { 27 | pass = CreatePass(settings.renderPassEvent); 28 | pass.Init(pass.GetShaderPath()); 29 | } 30 | 31 | protected override void Dispose(bool disposing) 32 | { 33 | pass?.Release(); 34 | } 35 | 36 | protected virtual CustomPass CreatePass(RenderPassEvent renderPassEvent) { return null; } 37 | 38 | public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) 39 | { 40 | pass.Setup(settings); 41 | renderer.EnqueuePass(pass); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /CustomRenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: db83a4684f1e2974a9bcc409ec9b1822 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Kino.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5944f92649588b84b91bb154625ac146 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Kino/AnalogGlitch.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 68a5780831cfc3f479b4e09cd526e0f3 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Kino/AnalogGlitch/AnalogGlitch.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Rendering; 3 | using UnityEngine.Rendering.Universal; 4 | 5 | #if UNITY_EDITOR 6 | using UnityEditor.Rendering; 7 | #endif 8 | 9 | [System.Serializable, VolumeComponentMenu("Post-processing Custom/AnalogGlitch")] 10 | public class AnalogGlitch : VolumeComponent, IPostProcessComponent 11 | { 12 | public BoolParameter enable = new BoolParameter(false); 13 | 14 | [Range(0, 1), Tooltip("Scan line jitter")] 15 | public FloatParameter scanLineJitter = new FloatParameter(0.5f); 16 | 17 | [Range(0, 1), Tooltip("Vertical jump")] 18 | public FloatParameter verticalJump = new FloatParameter(0.1f); 19 | 20 | [Range(0, 1), Tooltip("Vertical jump")] 21 | public FloatParameter horizontalShake = new FloatParameter(0.1f); 22 | 23 | [Range(0, 1), Tooltip("Color Drift")] 24 | public FloatParameter colorDrift = new FloatParameter(0.2f); 25 | 26 | #region IPostProcessComponent 27 | public bool IsActive() => enable.value; 28 | public bool IsTileCompatible() => false; 29 | #endregion 30 | } 31 | 32 | #if UNITY_EDITOR 33 | [VolumeComponentEditor(typeof(AnalogGlitch))] 34 | class AnalogGlitchEditor : VolumeComponentEditor 35 | { 36 | SerializedDataParameter scanLineJitter; 37 | SerializedDataParameter verticalJump; 38 | SerializedDataParameter horizontalShake; 39 | SerializedDataParameter colorDrift; 40 | 41 | public override void OnEnable() 42 | { 43 | var glitch = (AnalogGlitch)target; 44 | glitch.enable.value = true; 45 | glitch.enable.overrideState = true; 46 | 47 | var o = new PropertyFetcher(serializedObject); 48 | scanLineJitter = Unpack(o.Find(x => x.scanLineJitter)); 49 | verticalJump = Unpack(o.Find(x => x.verticalJump)); 50 | horizontalShake = Unpack(o.Find(x => x.horizontalShake)); 51 | colorDrift = Unpack(o.Find(x => x.colorDrift)); 52 | } 53 | 54 | public override void OnInspectorGUI() 55 | { 56 | PropertyField(scanLineJitter); 57 | PropertyField(verticalJump); 58 | PropertyField(horizontalShake); 59 | PropertyField(colorDrift); 60 | } 61 | } 62 | #endif 63 | 64 | -------------------------------------------------------------------------------- /Kino/AnalogGlitch/AnalogGlitch.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 83d82e840a798354d8e38ede0d9ac904 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Kino/AnalogGlitch/AnalogGlitchRenderFeature.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Rendering; 3 | using UnityEngine.Rendering.Universal; 4 | 5 | public class AnalogGlitchRenderFeature : CustomRenderFeature 6 | { 7 | protected override CustomPass CreatePass(RenderPassEvent renderPassEvent) 8 | { 9 | return new AnalogGlitchPass(renderPassEvent); 10 | } 11 | } 12 | 13 | public class AnalogGlitchPass : CustomPass 14 | { 15 | public override string GetShaderPath() => "Hidden/PostProcessing/AnalogGlitch"; 16 | public override string renderTag => "Render AnalogGlitch Effects"; 17 | 18 | public AnalogGlitchPass(RenderPassEvent renderPassEvent) : base(renderPassEvent) { } 19 | 20 | static class ShaderPropertyID 21 | { 22 | internal static readonly int MainTex = Shader.PropertyToID("_MainTex"); 23 | 24 | internal static readonly int ScanLineJitter = Shader.PropertyToID("_ScanLineJitter"); 25 | internal static readonly int VerticalJump = Shader.PropertyToID("_VerticalJump"); 26 | internal static readonly int HorizontalShake = Shader.PropertyToID("_HorizontalShake"); 27 | internal static readonly int ColorDrift = Shader.PropertyToID("_ColorDrift"); 28 | } 29 | 30 | float verticalJumpTime; 31 | protected override void Render(CommandBuffer cmd, ref RenderingData renderingData) 32 | { 33 | verticalJumpTime += Time.deltaTime * volumeComponent.verticalJump.value * 11.3f; 34 | 35 | var sl_thresh = Mathf.Clamp01(1.0f - volumeComponent.scanLineJitter.value * 1.2f); 36 | var sl_disp = 0.002f + Mathf.Pow(volumeComponent.scanLineJitter.value, 3) * 0.05f; 37 | var vj = new Vector2(volumeComponent.verticalJump.value, verticalJumpTime); 38 | var cd = new Vector2(volumeComponent.colorDrift.value * 0.04f, Time.time * 606.11f); 39 | 40 | material.SetVector(ShaderPropertyID.ScanLineJitter, new Vector2(sl_disp, sl_thresh)); 41 | material.SetVector(ShaderPropertyID.VerticalJump, vj); 42 | material.SetFloat(ShaderPropertyID.HorizontalShake, volumeComponent.horizontalShake.value * 0.2f); 43 | material.SetVector(ShaderPropertyID.ColorDrift, cd); 44 | 45 | cmd.SetGlobalTexture(ShaderPropertyID.MainTex, source); 46 | cmd.Blit(source, destination, material); 47 | } 48 | } -------------------------------------------------------------------------------- /Kino/AnalogGlitch/AnalogGlitchRenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4dff402a28b79b24d842eb1ede472b1e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Kino/Contour.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d2de2d27c54d1ee46b1ac95c7d317ef8 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Kino/Contour/Contour.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Rendering; 3 | using UnityEngine.Rendering.Universal; 4 | 5 | #if UNITY_EDITOR 6 | using UnityEditor.Rendering; 7 | #endif 8 | 9 | [System.Serializable, VolumeComponentMenu("Post-processing Custom/Contour")] 10 | public class Contour : VolumeComponent, IPostProcessComponent 11 | { 12 | public BoolParameter enable = new BoolParameter(false); 13 | 14 | [Tooltip("Line Color")] 15 | public ColorParameter lineColor = new ColorParameter(Color.black); 16 | [Tooltip("Background Color")] 17 | public ColorParameter bgColor = new ColorParameter(new Color(1, 1, 1, 0)); 18 | [Tooltip("Lower Threshold")] 19 | public ClampedFloatParameter lowerThreshold = new ClampedFloatParameter(0.05f, 0f, 1f); 20 | [Tooltip("Upper Threshold")] 21 | public ClampedFloatParameter upperThreshold = new ClampedFloatParameter(0.5f, 0f, 1f); 22 | [Tooltip("Color Sensitivity")] 23 | public ClampedFloatParameter colorSensitivity = new ClampedFloatParameter(0f, 0f, 1f); 24 | [Tooltip("Depth Sensitivity")] 25 | public ClampedFloatParameter depthSensitivity = new ClampedFloatParameter(1f, 0f, 1f); 26 | [Tooltip("Normal Sensitivity")] 27 | public ClampedFloatParameter normalSensitivity = new ClampedFloatParameter(0f, 0f, 1f); 28 | [Tooltip("Falloff Depth")] 29 | public FloatParameter falloffDepth = new FloatParameter(40f); 30 | 31 | #region IPostProcessComponent 32 | public bool IsActive() => enable.value; 33 | public bool IsTileCompatible() => false; 34 | #endregion 35 | } 36 | 37 | #if UNITY_EDITOR 38 | [VolumeComponentEditor(typeof(Contour))] 39 | class ContourEditor : VolumeComponentEditor 40 | { 41 | SerializedDataParameter lineColor; 42 | SerializedDataParameter bgColor; 43 | SerializedDataParameter lowerThreshold; 44 | SerializedDataParameter upperThreshold; 45 | SerializedDataParameter colorSensitivity; 46 | SerializedDataParameter depthSensitivity; 47 | SerializedDataParameter normalSensitivity; 48 | SerializedDataParameter falloffDepth; 49 | 50 | public override void OnEnable() 51 | { 52 | var contour = (Contour)target; 53 | contour.enable.value = true; 54 | contour.enable.overrideState = true; 55 | 56 | var o = new PropertyFetcher(serializedObject); 57 | lineColor = Unpack(o.Find(x => x.lineColor)); 58 | bgColor = Unpack(o.Find(x => x.bgColor)); 59 | lowerThreshold = Unpack(o.Find(x => x.lowerThreshold)); 60 | upperThreshold = Unpack(o.Find(x => x.upperThreshold)); 61 | colorSensitivity = Unpack(o.Find(x => x.colorSensitivity)); 62 | depthSensitivity = Unpack(o.Find(x => x.depthSensitivity)); 63 | normalSensitivity = Unpack(o.Find(x => x.normalSensitivity)); 64 | falloffDepth = Unpack(o.Find(x => x.falloffDepth)); 65 | } 66 | 67 | public override void OnInspectorGUI() 68 | { 69 | PropertyField(lineColor); 70 | PropertyField(bgColor); 71 | PropertyField(lowerThreshold); 72 | PropertyField(upperThreshold); 73 | PropertyField(colorSensitivity); 74 | PropertyField(depthSensitivity); 75 | PropertyField(normalSensitivity); 76 | PropertyField(falloffDepth); 77 | } 78 | } 79 | #endif 80 | 81 | -------------------------------------------------------------------------------- /Kino/Contour/Contour.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9311bb1bccc6d394abd7fa52bc9c811b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Kino/Contour/ContourRenderFeature.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Rendering; 3 | using UnityEngine.Rendering.Universal; 4 | 5 | public class ContourRenderFeature : CustomRenderFeature 6 | { 7 | protected override CustomPass CreatePass(RenderPassEvent renderPassEvent) 8 | { 9 | return new ContourPass(renderPassEvent); 10 | } 11 | } 12 | 13 | public class ContourPass : CustomPass 14 | { 15 | public override string GetShaderPath() => "Hidden/PostProcessing/Contour"; 16 | public override string renderTag => "Render Contour Effects"; 17 | 18 | public ContourPass(RenderPassEvent renderPassEvent) : base(renderPassEvent) { } 19 | 20 | static class ShaderPropertyID 21 | { 22 | internal static readonly int MainTex = Shader.PropertyToID("_MainTex"); 23 | 24 | internal static readonly int Color = Shader.PropertyToID("_Color"); 25 | internal static readonly int Background = Shader.PropertyToID("_Background"); 26 | internal static readonly int Threshold = Shader.PropertyToID("_Threshold"); 27 | internal static readonly int InvRange = Shader.PropertyToID("_InvRange"); 28 | internal static readonly int ColorSensitivity = Shader.PropertyToID("_ColorSensitivity"); 29 | internal static readonly int DepthSensitivity = Shader.PropertyToID("_DepthSensitivity"); 30 | internal static readonly int NormalSensitivity = Shader.PropertyToID("_NormalSensitivity"); 31 | internal static readonly int InvFallOff = Shader.PropertyToID("_InvFallOff"); 32 | } 33 | 34 | public override void OnCameraSetup(CommandBuffer cmd, ref RenderingData renderingData) 35 | { 36 | base.OnCameraSetup(cmd, ref renderingData); 37 | 38 | if (volumeComponent != null) { 39 | if (volumeComponent.normalSensitivity.value > 0f) { 40 | ConfigureInput(ScriptableRenderPassInput.Normal); 41 | } 42 | else if (volumeComponent.depthSensitivity.value > 0f) { 43 | ConfigureInput(ScriptableRenderPassInput.Depth); 44 | } 45 | } 46 | } 47 | 48 | protected override void Render(CommandBuffer cmd, ref RenderingData renderingData) 49 | { 50 | material.SetColor(ShaderPropertyID.Color, volumeComponent.lineColor.value); 51 | material.SetColor(ShaderPropertyID.Background, volumeComponent.bgColor.value); 52 | material.SetFloat(ShaderPropertyID.Threshold, volumeComponent.lowerThreshold.value); 53 | material.SetFloat(ShaderPropertyID.InvRange, 1 / (volumeComponent.upperThreshold.value - volumeComponent.lowerThreshold.value)); 54 | material.SetFloat(ShaderPropertyID.ColorSensitivity, volumeComponent.colorSensitivity.value); 55 | material.SetFloat(ShaderPropertyID.DepthSensitivity, volumeComponent.depthSensitivity.value * 2f); 56 | material.SetFloat(ShaderPropertyID.NormalSensitivity, volumeComponent.normalSensitivity.value); 57 | material.SetFloat(ShaderPropertyID.InvFallOff, 1 / volumeComponent.falloffDepth.value); 58 | 59 | if (volumeComponent.colorSensitivity.value > 0f) 60 | material.EnableKeyword("_CONTOUR_COLOR"); 61 | else 62 | material.DisableKeyword("_CONTOUR_COLOR"); 63 | 64 | if (volumeComponent.depthSensitivity.value > 0f) 65 | material.EnableKeyword("_CONTOUR_DEPTH"); 66 | else 67 | material.DisableKeyword("_CONTOUR_DEPTH"); 68 | 69 | if (volumeComponent.normalSensitivity.value > 0f) 70 | material.EnableKeyword("_CONTOUR_NORMAL"); 71 | else 72 | material.DisableKeyword("_CONTOUR_NORMAL"); 73 | 74 | cmd.SetGlobalTexture(ShaderPropertyID.MainTex, source); 75 | cmd.Blit(source, destination, material); 76 | } 77 | } -------------------------------------------------------------------------------- /Kino/Contour/ContourRenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b0b696f6ec84e0e4f871a40797c06116 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Kino/DigitalGlitch.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 685bfdc850bd3ec4482e3afe5af090b9 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Kino/DigitalGlitch/DigitalGlitch.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Rendering; 3 | using UnityEngine.Rendering.Universal; 4 | 5 | #if UNITY_EDITOR 6 | using UnityEditor.Rendering; 7 | #endif 8 | 9 | [System.Serializable, VolumeComponentMenu("Post-processing Custom/DigitalGlitch")] 10 | public class DigitalGlitch : VolumeComponent, IPostProcessComponent 11 | { 12 | public BoolParameter enable = new BoolParameter(false); 13 | 14 | [Range(0, 1), Tooltip("Intensity")] 15 | public FloatParameter intensity = new FloatParameter(0.02f); 16 | 17 | #region IPostProcessComponent 18 | public bool IsActive() => enable.value && intensity.value > 0f; 19 | public bool IsTileCompatible() => false; 20 | #endregion 21 | } 22 | 23 | #if UNITY_EDITOR 24 | [VolumeComponentEditor(typeof(DigitalGlitch))] 25 | class DigitalGlitchEditor : VolumeComponentEditor 26 | { 27 | SerializedDataParameter intensity; 28 | 29 | public override void OnEnable() 30 | { 31 | var glitch = (DigitalGlitch)target; 32 | glitch.enable.value = true; 33 | glitch.enable.overrideState = true; 34 | 35 | var o = new PropertyFetcher(serializedObject); 36 | intensity = Unpack(o.Find(x => x.intensity)); 37 | } 38 | 39 | public override void OnInspectorGUI() 40 | { 41 | PropertyField(intensity); 42 | } 43 | } 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /Kino/DigitalGlitch/DigitalGlitch.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f2488f2c785d78d458a8d8a23a8b4781 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Kino/DigitalGlitch/DigitalGlitchRenderFeature.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Rendering; 3 | using UnityEngine.Rendering.Universal; 4 | 5 | public class DigitalGlitchRenderFeature : CustomRenderFeature 6 | { 7 | protected override CustomPass CreatePass(RenderPassEvent renderPassEvent) 8 | { 9 | return new DigitalGlitchPass(renderPassEvent); 10 | } 11 | } 12 | 13 | public class DigitalGlitchPass : CustomPass 14 | { 15 | public override string GetShaderPath() => "Hidden/PostProcessing/DigitalGlitch"; 16 | public override string renderTag => "Render DigitalGlitch Effects"; 17 | 18 | Texture2D noiseTexture; 19 | RenderTexture trashFrame1; 20 | RenderTexture trashFrame2; 21 | public DigitalGlitchPass(RenderPassEvent renderPassEvent) : base(renderPassEvent) { 22 | noiseTexture = new Texture2D(64, 32, TextureFormat.ARGB32, false); 23 | noiseTexture.hideFlags = HideFlags.DontSave; 24 | noiseTexture.wrapMode = TextureWrapMode.Clamp; 25 | noiseTexture.filterMode = FilterMode.Point; 26 | 27 | trashFrame1 = new RenderTexture(Screen.width, Screen.height, 0); 28 | trashFrame2 = new RenderTexture(Screen.width, Screen.height, 0); 29 | trashFrame1.hideFlags = HideFlags.DontSave; 30 | trashFrame2.hideFlags = HideFlags.DontSave; 31 | } 32 | 33 | static class ShaderPropertyID 34 | { 35 | internal static readonly int MainTex = Shader.PropertyToID("_MainTex"); 36 | 37 | internal static readonly int Intensity = Shader.PropertyToID("_Intensity"); 38 | internal static readonly int NoiseTex = Shader.PropertyToID("_NoiseTex"); 39 | internal static readonly int TrashTex = Shader.PropertyToID("_TrashTex"); 40 | } 41 | 42 | Color GetRandomColor() 43 | { 44 | return new Color(Random.value, Random.value, Random.value, Random.value); 45 | } 46 | 47 | void UpdateNoiseTexture() 48 | { 49 | var color = GetRandomColor(); 50 | for (int y = 0; y < noiseTexture.height; y++) { 51 | for (int x = 0; x < noiseTexture.width; x++) { 52 | if (Random.value > 0.89f) 53 | color = GetRandomColor(); 54 | noiseTexture.SetPixel(x, y, color); 55 | } 56 | } 57 | 58 | noiseTexture.Apply(); 59 | } 60 | 61 | protected override void Render(CommandBuffer cmd, ref RenderingData renderingData) 62 | { 63 | if (Random.value > Mathf.Lerp(0.9f, 0.5f, volumeComponent.intensity.value)) 64 | UpdateNoiseTexture(); 65 | 66 | var frameCount = Time.frameCount; 67 | if (frameCount % 13 == 0) 68 | cmd.Blit(source, trashFrame1); 69 | if (frameCount % 73 == 0) 70 | cmd.Blit(source, trashFrame2); 71 | var trashFrame = Random.value > 0.5f ? trashFrame1 : trashFrame2; 72 | 73 | material.SetFloat(ShaderPropertyID.Intensity, volumeComponent.intensity.value); 74 | material.SetTexture(ShaderPropertyID.NoiseTex, noiseTexture); 75 | material.SetTexture(ShaderPropertyID.TrashTex, trashFrame); 76 | material.EnableKeyword("APPLY_FORWARD_FOG"); 77 | 78 | cmd.SetGlobalTexture(ShaderPropertyID.MainTex, source); 79 | cmd.Blit(source, destination, material); 80 | } 81 | 82 | public override void Release() 83 | { 84 | if (noiseTexture != null) { 85 | #if UNITY_EDITOR 86 | Object.DestroyImmediate(noiseTexture); 87 | #else 88 | Object.Destroy(noiseTexture); 89 | #endif 90 | } 91 | 92 | if (trashFrame1 != null) 93 | trashFrame1.Release(); 94 | if (trashFrame2 != null) 95 | trashFrame2.Release(); 96 | } 97 | } -------------------------------------------------------------------------------- /Kino/DigitalGlitch/DigitalGlitchRenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f7f65b3b1bedb544983761beb601631b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Kino/Streak.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6a805c1a02a01aa428b919c7e537d988 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Kino/Streak/Streak.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Rendering; 3 | using UnityEngine.Rendering.Universal; 4 | 5 | #if UNITY_EDITOR 6 | using UnityEditor.Rendering; 7 | #endif 8 | 9 | [System.Serializable, VolumeComponentMenu("Post-processing Custom/Streak")] 10 | public class Streak : VolumeComponent, IPostProcessComponent 11 | { 12 | public BoolParameter enable = new BoolParameter(false); 13 | 14 | [Range(0, 5)] public FloatParameter threshold = new FloatParameter(0.75f); 15 | [Range(0, 1)] public FloatParameter stretch = new FloatParameter(0.5f); 16 | [Range(0, 1)] public FloatParameter intensity = new FloatParameter(0.25f); 17 | [ColorUsage(false)] public ColorParameter tint = new ColorParameter(new Color(0.55f, 0.55f, 1f)); 18 | 19 | #region IPostProcessComponent 20 | public bool IsActive() => enable.value; 21 | public bool IsTileCompatible() => false; 22 | #endregion 23 | } 24 | 25 | #if UNITY_EDITOR 26 | [VolumeComponentEditor(typeof(Streak))] 27 | class StreakEditor : VolumeComponentEditor 28 | { 29 | SerializedDataParameter threshold; 30 | SerializedDataParameter stretch; 31 | SerializedDataParameter intensity; 32 | SerializedDataParameter tint; 33 | 34 | public override void OnEnable() 35 | { 36 | var streak = (Streak)target; 37 | streak.enable.value = true; 38 | streak.enable.overrideState = true; 39 | 40 | var o = new PropertyFetcher(serializedObject); 41 | threshold = Unpack(o.Find(x => x.threshold)); 42 | stretch = Unpack(o.Find(x => x.stretch)); 43 | intensity = Unpack(o.Find(x => x.intensity)); 44 | tint = Unpack(o.Find(x => x.tint)); 45 | } 46 | 47 | public override void OnInspectorGUI() 48 | { 49 | PropertyField(threshold); 50 | PropertyField(stretch); 51 | PropertyField(intensity); 52 | PropertyField(tint); 53 | } 54 | } 55 | #endif 56 | 57 | -------------------------------------------------------------------------------- /Kino/Streak/Streak.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: adf0a935ff975bb4ea15fd8d2ffe4e6b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Kino/Streak/StreakRenderFeature.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Rendering; 3 | using UnityEngine.Rendering.Universal; 4 | 5 | public class StreakRenderFeature : CustomRenderFeature 6 | { 7 | protected override CustomPass CreatePass(RenderPassEvent renderPassEvent) 8 | { 9 | return new StreakPass(renderPassEvent); 10 | } 11 | } 12 | 13 | public class StreakPass : CustomPass 14 | { 15 | public override string GetShaderPath() => "Hidden/PostProcessing/Streak"; 16 | public override string renderTag => "Render Streak Effects"; 17 | 18 | const int MaxMipLevel = 16; 19 | int[] _mipWidth; 20 | int[] _rtMipDown; 21 | int[] _rtMipUp; 22 | public StreakPass(RenderPassEvent renderPassEvent) : base(renderPassEvent) { 23 | _mipWidth = new int[MaxMipLevel]; 24 | _rtMipDown = new int[MaxMipLevel]; 25 | _rtMipUp = new int[MaxMipLevel]; 26 | 27 | for (var i = 0; i < MaxMipLevel; i++) { 28 | _rtMipDown[i] = Shader.PropertyToID("_MipDown" + i); 29 | _rtMipUp[i] = Shader.PropertyToID("_MipUp" + i); 30 | } 31 | } 32 | 33 | static class ShaderPropertyID 34 | { 35 | internal static readonly int MainTex = Shader.PropertyToID("_MainTex"); 36 | internal static readonly int HighTex = Shader.PropertyToID("_HighTex"); 37 | 38 | internal static readonly int Threshold = Shader.PropertyToID("_Threshold"); 39 | internal static readonly int Stretch = Shader.PropertyToID("_Stretch"); 40 | internal static readonly int Intensity = Shader.PropertyToID("_Intensity"); 41 | internal static readonly int Color = Shader.PropertyToID("_Color"); 42 | } 43 | 44 | protected override void Render(CommandBuffer cmd, ref RenderingData renderingData) 45 | { 46 | ref var cameraData = ref renderingData.cameraData; 47 | var w = cameraData.camera.scaledPixelWidth; 48 | var h = cameraData.camera.scaledPixelHeight; 49 | 50 | material.SetFloat(ShaderPropertyID.Threshold, volumeComponent.threshold.value); 51 | material.SetFloat(ShaderPropertyID.Stretch, volumeComponent.stretch.value); 52 | material.SetFloat(ShaderPropertyID.Intensity, volumeComponent.intensity.value); 53 | material.SetColor(ShaderPropertyID.Color, volumeComponent.tint.value); 54 | 55 | // Calculate the mip widths. 56 | _mipWidth[0] = w; 57 | for (var i = 1; i < MaxMipLevel; i++) 58 | _mipWidth[i] = _mipWidth[i - 1] / 2; 59 | 60 | // Apply the prefilter and store into MIP 0. 61 | var height = h / 2; 62 | cmd.SetGlobalTexture(ShaderPropertyID.MainTex, source); 63 | cmd.GetTemporaryRT(_rtMipDown[0], _mipWidth[0], height, 0, FilterMode.Bilinear, RenderTextureFormat.ARGBHalf, RenderTextureReadWrite.Default); 64 | cmd.Blit(source, _rtMipDown[0], material, 0); 65 | 66 | // Build the MIP pyramid. 67 | var level = 1; 68 | for (; level < MaxMipLevel && _mipWidth[level] > 7; level++) { 69 | cmd.GetTemporaryRT(_rtMipDown[level], _mipWidth[level], height, 0, FilterMode.Bilinear, RenderTextureFormat.ARGBHalf, RenderTextureReadWrite.Default); 70 | cmd.SetGlobalTexture(ShaderPropertyID.MainTex, _rtMipDown[level - 1]); 71 | cmd.Blit(_rtMipDown[level - 1], _rtMipDown[level], material, 1); 72 | } 73 | // MIP 0 is not needed at this point. 74 | cmd.ReleaseTemporaryRT(_rtMipDown[level]); 75 | 76 | // Upsample and combine. 77 | var lastRT = _rtMipDown[--level]; 78 | for (level--; level >= 1; level--) { 79 | cmd.GetTemporaryRT(_rtMipUp[level], _mipWidth[level], height, 0, FilterMode.Bilinear, RenderTextureFormat.ARGBHalf, RenderTextureReadWrite.Default); 80 | cmd.SetGlobalTexture(ShaderPropertyID.MainTex, lastRT); 81 | cmd.SetGlobalTexture(ShaderPropertyID.HighTex, _rtMipDown[level]); 82 | cmd.Blit(lastRT, _rtMipUp[level], material, 2); 83 | 84 | cmd.ReleaseTemporaryRT(_rtMipDown[level]); 85 | cmd.ReleaseTemporaryRT(lastRT); 86 | 87 | lastRT = _rtMipUp[level]; 88 | } 89 | 90 | // Final composition. 91 | cmd.SetGlobalTexture(ShaderPropertyID.MainTex, lastRT); 92 | cmd.SetGlobalTexture(ShaderPropertyID.HighTex, source); 93 | cmd.Blit(lastRT, destination, material, 3); 94 | 95 | cmd.ReleaseTemporaryRT(lastRT); 96 | cmd.EndSample("Streak"); 97 | } 98 | } -------------------------------------------------------------------------------- /Kino/Streak/StreakRenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 06e9a9efe5f61ff4aba7162fc362335f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Kino/WaterColor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d9dfac696d621a447add69ed340063d7 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Kino/WaterColor/WaterColor.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Rendering; 3 | using UnityEngine.Rendering.Universal; 4 | 5 | #if UNITY_EDITOR 6 | using UnityEditor.Rendering; 7 | #endif 8 | 9 | [System.Serializable, VolumeComponentMenu("Post-processing Custom/WaterColor")] 10 | public class WaterColor : VolumeComponent, IPostProcessComponent 11 | { 12 | public BoolParameter enable = new BoolParameter(false); 13 | 14 | public ColorParameter fillColor = new ColorParameter(new Color(0.9f, 0.8f, 1f, 0.8f)); 15 | public ColorParameter edgeColor = new ColorParameter(new Color(0.1f, 0.1f, 0.3f)); 16 | public FloatParameter edgeContrast = new FloatParameter(1f); 17 | public FloatParameter blurWidth = new FloatParameter(0.1f); 18 | public FloatParameter blurFrequency = new FloatParameter(0.2f); 19 | public FloatParameter hueShift = new FloatParameter(0.2f); 20 | public FloatParameter interval = new FloatParameter(0.5f); 21 | public IntParameter iteration = new IntParameter(20); 22 | 23 | #region IPostProcessComponent 24 | public bool IsActive() => enable.value; 25 | public bool IsTileCompatible() => false; 26 | #endregion 27 | } 28 | 29 | #if UNITY_EDITOR 30 | [VolumeComponentEditor(typeof(WaterColor))] 31 | class WaterColorEditor : VolumeComponentEditor 32 | { 33 | SerializedDataParameter fillColor; 34 | SerializedDataParameter edgeColor; 35 | SerializedDataParameter edgeContrast; 36 | SerializedDataParameter blurWidth; 37 | SerializedDataParameter blurFrequency; 38 | SerializedDataParameter hueShift; 39 | SerializedDataParameter interval; 40 | SerializedDataParameter iteration; 41 | 42 | public override void OnEnable() 43 | { 44 | var component = (WaterColor)target; 45 | component.enable.value = true; 46 | component.enable.overrideState = true; 47 | 48 | var o = new PropertyFetcher(serializedObject); 49 | fillColor = Unpack(o.Find(x => x.fillColor)); 50 | edgeColor = Unpack(o.Find(x => x.edgeColor)); 51 | edgeContrast = Unpack(o.Find(x => x.edgeContrast)); 52 | blurWidth = Unpack(o.Find(x => x.blurWidth)); 53 | blurFrequency = Unpack(o.Find(x => x.blurFrequency)); 54 | hueShift = Unpack(o.Find(x => x.hueShift)); 55 | interval = Unpack(o.Find(x => x.interval)); 56 | iteration = Unpack(o.Find(x => x.iteration)); 57 | iteration = Unpack(o.Find(x => x.iteration)); 58 | } 59 | 60 | public override void OnInspectorGUI() 61 | { 62 | PropertyField(fillColor); 63 | PropertyField(edgeColor); 64 | PropertyField(edgeContrast); 65 | PropertyField(blurWidth); 66 | PropertyField(blurFrequency); 67 | PropertyField(hueShift); 68 | PropertyField(interval); 69 | PropertyField(iteration); 70 | } 71 | } 72 | #endif 73 | 74 | -------------------------------------------------------------------------------- /Kino/WaterColor/WaterColor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6485ede11c2d9cd41867ecd360e32d52 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Kino/WaterColor/WaterColorRenderFeature.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Rendering; 3 | using UnityEngine.Rendering.Universal; 4 | 5 | public class WaterColorRenderFeature : CustomRenderFeature 6 | { 7 | [SerializeField] 8 | public Texture2D noiseTex; 9 | 10 | protected override CustomPass CreatePass(RenderPassEvent renderPassEvent) 11 | { 12 | var pass = new WaterColorPass(renderPassEvent); 13 | pass.noiseTex = noiseTex; 14 | return pass; 15 | } 16 | } 17 | 18 | public class WaterColorPass : CustomPass 19 | { 20 | public override string GetShaderPath() => "Hidden/PostProcessing/WaterColor"; 21 | public override string renderTag => "Render WaterColor Effects"; 22 | 23 | public Texture2D noiseTex; 24 | 25 | public WaterColorPass(RenderPassEvent renderPassEvent) : base(renderPassEvent) { } 26 | 27 | static class ShaderPropertyID 28 | { 29 | internal static readonly int MainTex = Shader.PropertyToID("_MainTex"); 30 | internal static readonly int NoiseTex = Shader.PropertyToID("_NoiseTex"); 31 | 32 | internal static readonly int FillColor = Shader.PropertyToID("_FillColor"); 33 | internal static readonly int EdgeColor = Shader.PropertyToID("_EdgeColor"); 34 | internal static readonly int EffectParams = Shader.PropertyToID("_EffectParams"); 35 | internal static readonly int Interval = Shader.PropertyToID("_Interval"); 36 | internal static readonly int Iteration = Shader.PropertyToID("_Iteration"); 37 | } 38 | 39 | protected override void Render(CommandBuffer cmd, ref RenderingData renderingData) 40 | { 41 | material.SetColor(ShaderPropertyID.FillColor, volumeComponent.fillColor.value); 42 | material.SetColor(ShaderPropertyID.EdgeColor, volumeComponent.edgeColor.value); 43 | material.SetVector(ShaderPropertyID.EffectParams, new Vector4( 44 | volumeComponent.edgeContrast.value, 45 | volumeComponent.blurWidth.value, 46 | Mathf.Exp(volumeComponent.blurFrequency.value - 0.5f) * 6f, 47 | volumeComponent.hueShift.value)); 48 | material.SetFloat(ShaderPropertyID.Interval, volumeComponent.interval.value); 49 | material.SetInt(ShaderPropertyID.Iteration, volumeComponent.iteration.value); 50 | 51 | cmd.SetGlobalTexture(ShaderPropertyID.MainTex, source); 52 | cmd.SetGlobalTexture(ShaderPropertyID.NoiseTex, noiseTex); 53 | cmd.Blit(source, destination, material); 54 | } 55 | } -------------------------------------------------------------------------------- /Kino/WaterColor/WaterColorRenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dc8dbbf4186dbec4c9373e2037277eb4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 8izips 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PostProcessingURP 2 | Integrated effects from different sources into unity URP format 3 | 4 | # Effect List 5 | 6 | original screenshot without Effect 7 | 8 | 9 | ## Kino : from [keijiro's repositry](https://github.com/keijiro) 10 | 11 |
ScreenShots 12 | 13 | | Effect | ScreenShot | 14 | ----|---- 15 | | Analog Glitch | | 16 | | Contour | | 17 | | Digital Glitch | | 18 | | Streak | | 19 | | Watercolor | | 20 |
21 | 22 | ## Reshade : from [crosire's repositry](https://github.com/crosire/reshade-shaders) 23 | 24 |
ScreenShots 25 | 26 | | Effect | ScreenShot | 27 | ----|---- 28 | | Adaptive Fog | | 29 | | Adaptive Sharpen | | 30 | | Cartoon | | 31 | | Clarity2 | | 32 | | Fake HDR | | 33 |
34 | 35 | ## ShadersLab & ETC : from [shaderslab example](http://www.shaderslab.com) 36 | 37 |
ScreenShots 38 | 39 | | Effect | ScreenShot | 40 | ----|---- 41 | | Edge Detection | | 42 | | Grayscale | | 43 | | GrayscaleCS (using compute shader) | | 44 | | Oil Paint | | 45 | | Pencil | | 46 | | Radial Blur | | 47 |
48 | -------------------------------------------------------------------------------- /Reshade.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4165b3abfb5c8ae49a59a16b181447d8 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Reshade/ADOF.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 81d90e5a954ac9144ab4916e2302f15a 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Reshade/ADOF/ADOF.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Rendering; 3 | using UnityEngine.Rendering.Universal; 4 | 5 | #if UNITY_EDITOR 6 | using UnityEditor.Rendering; 7 | #endif 8 | 9 | [System.Serializable, VolumeComponentMenu("Post-processing Custom/ADOF")] 10 | public class ADOF : VolumeComponent, IPostProcessComponent 11 | { 12 | public BoolParameter enable = new BoolParameter(false); 13 | 14 | public BoolParameter enableAutoFocus = new BoolParameter(true); 15 | public Vector2Parameter autoFocusCenter = new Vector2Parameter(new Vector2(0.5f, 0.5f)); 16 | public ClampedFloatParameter autoFocusRadius = new ClampedFloatParameter(0.6f, 0f, 1f); 17 | public ClampedFloatParameter autoFocusSpeed = new ClampedFloatParameter(0.1f, 0.05f, 1f); 18 | public ClampedFloatParameter manualFocusDepth = new ClampedFloatParameter(0.001f, 0f, 1f); 19 | public ClampedFloatParameter nearBlurCurve = new ClampedFloatParameter(6f, 0.5f, 6f); 20 | public ClampedFloatParameter farBlurCurve = new ClampedFloatParameter(1.5f, 0.5f, 6f); 21 | public ClampedFloatParameter hyperFocus = new ClampedFloatParameter(0.1f, 0f, 1f); 22 | public ClampedFloatParameter renderResolutionMult = new ClampedFloatParameter(0.5f, 0.5f, 1f); 23 | public ClampedFloatParameter shapeRadius = new ClampedFloatParameter(20.5f, 0f, 100f); 24 | public ClampedFloatParameter smootheningAmount = new ClampedFloatParameter(4.0f, 0f, 200f); 25 | public ClampedFloatParameter bokehIntensity = new ClampedFloatParameter(0.3f, 0f, 1f); 26 | public ClampedIntParameter bokehMode = new ClampedIntParameter(2, 0, 3); 27 | public ClampedIntParameter shapeVertices = new ClampedIntParameter(6, 3, 9); 28 | public ClampedIntParameter shapeQuality = new ClampedIntParameter(5, 2, 25); 29 | public ClampedFloatParameter shapeCurvatureAmount = new ClampedFloatParameter(1f, -1f, 1f); 30 | public ClampedFloatParameter shapeRotation = new ClampedFloatParameter(0f, 0f, 360f); 31 | public ClampedFloatParameter shapeAnamorphRatio = new ClampedFloatParameter(1f, 0f, 1f); 32 | public BoolParameter enableChromaticAberration = new BoolParameter(true); 33 | public ClampedFloatParameter shapeChromaAmount = new ClampedFloatParameter(-0.1f, -1f, 1f); 34 | public ClampedIntParameter shapeChromaMode = new ClampedIntParameter(2, 0, 2); 35 | 36 | #region IPostProcessComponent 37 | public bool IsActive() => enable.value; 38 | public bool IsTileCompatible() => false; 39 | #endregion 40 | } 41 | 42 | #if UNITY_EDITOR 43 | [VolumeComponentEditor(typeof(ADOF))] 44 | class ADOFEditor : VolumeComponentEditor 45 | { 46 | SerializedDataParameter enableAutoFocus; 47 | SerializedDataParameter autoFocusCenter; 48 | SerializedDataParameter autoFocusRadius; 49 | SerializedDataParameter autoFocusSpeed; 50 | SerializedDataParameter manualFocusDepth; 51 | SerializedDataParameter nearBlurCurve; 52 | SerializedDataParameter farBlurCurve; 53 | SerializedDataParameter hyperFocus; 54 | SerializedDataParameter renderResolutionMult; 55 | SerializedDataParameter shapeRadius; 56 | SerializedDataParameter smootheningAmount; 57 | SerializedDataParameter bokehIntensity; 58 | SerializedDataParameter bokehMode; 59 | SerializedDataParameter shapeVertices; 60 | SerializedDataParameter shapeQuality; 61 | SerializedDataParameter shapeCurvatureAmount; 62 | SerializedDataParameter shapeRotation; 63 | SerializedDataParameter shapeAnamorphRatio; 64 | SerializedDataParameter enableChromaticAberration; 65 | SerializedDataParameter shapeChromaAmount; 66 | SerializedDataParameter shapeChromaMode; 67 | 68 | ADOF _instance; 69 | public override void OnEnable() 70 | { 71 | _instance = (ADOF)target; 72 | _instance.enable.value = true; 73 | _instance.enable.overrideState = true; 74 | 75 | var o = new PropertyFetcher(serializedObject); 76 | enableAutoFocus = Unpack(o.Find(x => x.enableAutoFocus)); 77 | autoFocusCenter = Unpack(o.Find(x => x.autoFocusCenter)); 78 | autoFocusRadius = Unpack(o.Find(x => x.autoFocusRadius)); 79 | autoFocusSpeed = Unpack(o.Find(x => x.autoFocusSpeed)); 80 | manualFocusDepth = Unpack(o.Find(x => x.manualFocusDepth)); 81 | nearBlurCurve = Unpack(o.Find(x => x.nearBlurCurve)); 82 | farBlurCurve = Unpack(o.Find(x => x.farBlurCurve)); 83 | hyperFocus = Unpack(o.Find(x => x.hyperFocus)); 84 | renderResolutionMult = Unpack(o.Find(x => x.renderResolutionMult)); 85 | shapeRadius = Unpack(o.Find(x => x.shapeRadius)); 86 | smootheningAmount = Unpack(o.Find(x => x.smootheningAmount)); 87 | bokehIntensity = Unpack(o.Find(x => x.bokehIntensity)); 88 | bokehMode = Unpack(o.Find(x => x.bokehMode)); 89 | shapeVertices = Unpack(o.Find(x => x.shapeVertices)); 90 | shapeQuality = Unpack(o.Find(x => x.shapeQuality)); 91 | shapeCurvatureAmount = Unpack(o.Find(x => x.shapeCurvatureAmount)); 92 | shapeRotation = Unpack(o.Find(x => x.shapeRotation)); 93 | shapeAnamorphRatio = Unpack(o.Find(x => x.shapeAnamorphRatio)); 94 | enableChromaticAberration = Unpack(o.Find(x => x.enableChromaticAberration)); 95 | shapeChromaAmount = Unpack(o.Find(x => x.shapeChromaAmount)); 96 | shapeChromaMode = Unpack(o.Find(x => x.shapeChromaMode)); 97 | } 98 | 99 | public override void OnInspectorGUI() 100 | { 101 | PropertyField(enableAutoFocus); 102 | if (_instance.enableAutoFocus.value) { 103 | PropertyField(autoFocusCenter); 104 | PropertyField(autoFocusRadius); 105 | PropertyField(autoFocusSpeed); 106 | } 107 | 108 | PropertyField(manualFocusDepth); 109 | PropertyField(nearBlurCurve); 110 | PropertyField(farBlurCurve); 111 | PropertyField(hyperFocus); 112 | PropertyField(renderResolutionMult); 113 | PropertyField(shapeRadius); 114 | PropertyField(smootheningAmount); 115 | PropertyField(bokehIntensity); 116 | PropertyField(bokehMode); 117 | PropertyField(shapeVertices); 118 | PropertyField(shapeQuality); 119 | PropertyField(shapeCurvatureAmount); 120 | PropertyField(shapeRotation); 121 | PropertyField(shapeAnamorphRatio); 122 | 123 | PropertyField(enableChromaticAberration); 124 | if (_instance.enableChromaticAberration.value) { 125 | PropertyField(shapeChromaAmount); 126 | PropertyField(shapeChromaMode); 127 | } 128 | } 129 | } 130 | #endif 131 | 132 | -------------------------------------------------------------------------------- /Reshade/ADOF/ADOF.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0a036e2381da8834f8b981fc54e74155 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Reshade/ADOF/ADOFRenderFeature.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Rendering; 3 | using UnityEngine.Rendering.Universal; 4 | 5 | public class ADOFRenderFeature : CustomRenderFeature 6 | { 7 | protected override CustomPass CreatePass(RenderPassEvent renderPassEvent) 8 | { 9 | return new ADOFPass(renderPassEvent); 10 | } 11 | } 12 | 13 | public class ADOFPass : CustomPass 14 | { 15 | public override string GetShaderPath() => "Hidden/PostProcessing/ADOF"; 16 | public override string renderTag => "Render ADOF Effects"; 17 | 18 | public ADOFPass(RenderPassEvent renderPassEvent) : base(renderPassEvent) { } 19 | 20 | static class ShaderPropertyID 21 | { 22 | internal static readonly int MainTex = Shader.PropertyToID("_MainTex"); 23 | 24 | internal static readonly int Blend = Shader.PropertyToID("_Blend"); 25 | } 26 | 27 | protected override void Render(CommandBuffer cmd, ref RenderingData renderingData) 28 | { 29 | //material.SetFloat(ShaderPropertyID.Blend, volumeComponent.blendRate.value); 30 | 31 | cmd.SetGlobalTexture(ShaderPropertyID.MainTex, source); 32 | cmd.Blit(source, destination, material); 33 | } 34 | } -------------------------------------------------------------------------------- /Reshade/ADOF/ADOFRenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0374737799eb4c34ab999cb143337793 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Reshade/AdaptiveFog.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b3e21dc7256db8349b3981c188d50443 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Reshade/AdaptiveFog/AdaptiveFog.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Rendering; 3 | using UnityEngine.Rendering.Universal; 4 | 5 | #if UNITY_EDITOR 6 | using UnityEditor.Rendering; 7 | #endif 8 | 9 | [System.Serializable, VolumeComponentMenu("Post-processing Custom/AdaptiveFog")] 10 | public class AdaptiveFog : VolumeComponent, IPostProcessComponent 11 | { 12 | public BoolParameter enable = new BoolParameter(false); 13 | 14 | [Tooltip("Color of the fog")] 15 | public ColorParameter fogColor = new ColorParameter(new Color(0.9f, 0.9f, 0.9f)); 16 | [Range(0f, 1f), Tooltip("The maximum fog factor. 1.0 makes distant objects completely fogged out, a lower factor will shimmer them through the fog")] 17 | public FloatParameter maxFogFactor = new FloatParameter(1f); 18 | [Range(0f, 175f), Tooltip("The curve how quickly distant objects get fogged. A low value will make the fog appear just slightly. A high value will make the fog kick in rather quickly. The max value in the rage makes it very hard in general to view any objects outside fog")] 19 | public FloatParameter fogCurve = new FloatParameter(0.25f); 20 | [Range(0f, 1f), Tooltip("Start of the fog. 0.0 is at the camera, 1.0 is at the horizon, 0.5 is halfway towards the horizon. Before this point no fog will appear")] 21 | public FloatParameter fogStart = new FloatParameter(0.5f); 22 | [Range(0f, 50f), Tooltip("Threshold for what is a bright light (that causes bloom) and what isn't")] 23 | public FloatParameter bloomThreshold = new FloatParameter(10.25f); 24 | [Range(0f, 100f), Tooltip("Strength of the bloom")] 25 | public FloatParameter bloomPower = new FloatParameter(10.0f); 26 | [Range(0f, 1f), Tooltip("Width of the bloom")] 27 | public FloatParameter bloomWidth = new FloatParameter(0.2f); 28 | 29 | #region IPostProcessComponent 30 | public bool IsActive() => enable.value; 31 | public bool IsTileCompatible() => false; 32 | #endregion 33 | } 34 | 35 | #if UNITY_EDITOR 36 | [VolumeComponentEditor(typeof(AdaptiveFog))] 37 | class AdaptiveFogEditor : VolumeComponentEditor 38 | { 39 | SerializedDataParameter fogColor; 40 | SerializedDataParameter maxFogFactor; 41 | SerializedDataParameter fogCurve; 42 | SerializedDataParameter fogStart; 43 | SerializedDataParameter bloomThreshold; 44 | SerializedDataParameter bloomPower; 45 | SerializedDataParameter bloomWidth; 46 | 47 | public override void OnEnable() 48 | { 49 | var adaptiveFog = (AdaptiveFog)target; 50 | adaptiveFog.enable.value = true; 51 | adaptiveFog.enable.overrideState = true; 52 | 53 | var o = new PropertyFetcher(serializedObject); 54 | fogColor = Unpack(o.Find(x => x.fogColor)); 55 | maxFogFactor = Unpack(o.Find(x => x.maxFogFactor)); 56 | fogCurve = Unpack(o.Find(x => x.fogCurve)); 57 | fogStart = Unpack(o.Find(x => x.fogStart)); 58 | bloomThreshold = Unpack(o.Find(x => x.bloomThreshold)); 59 | bloomPower = Unpack(o.Find(x => x.bloomPower)); 60 | bloomWidth = Unpack(o.Find(x => x.bloomWidth)); 61 | } 62 | 63 | public override void OnInspectorGUI() 64 | { 65 | PropertyField(fogColor); 66 | PropertyField(maxFogFactor); 67 | PropertyField(fogCurve); 68 | PropertyField(fogStart); 69 | PropertyField(bloomThreshold); 70 | PropertyField(bloomPower); 71 | PropertyField(bloomWidth); 72 | } 73 | } 74 | #endif 75 | 76 | -------------------------------------------------------------------------------- /Reshade/AdaptiveFog/AdaptiveFog.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 484206edaa3cdb641bbd8c68ab27d519 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Reshade/AdaptiveFog/AdaptiveFogRenderFeature.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Rendering; 3 | using UnityEngine.Rendering.Universal; 4 | 5 | public class AdaptiveFogRenderFeature : CustomRenderFeature 6 | { 7 | protected override CustomPass CreatePass(RenderPassEvent renderPassEvent) 8 | { 9 | return new AdaptiveFogPass(renderPassEvent); 10 | } 11 | } 12 | 13 | public class AdaptiveFogPass : CustomPass 14 | { 15 | public override string GetShaderPath() => "Hidden/PostProcessing/AdaptiveFog"; 16 | public override string renderTag => "Render AdaptiveFog Effects"; 17 | 18 | public AdaptiveFogPass(RenderPassEvent renderPassEvent) : base(renderPassEvent) { } 19 | 20 | static class ShaderPropertyID 21 | { 22 | internal static readonly int MainTex = Shader.PropertyToID("_MainTex"); 23 | 24 | internal static readonly int FogColor = Shader.PropertyToID("_FogColor"); 25 | internal static readonly int MaxFogFactor = Shader.PropertyToID("_MaxFogFactor"); 26 | internal static readonly int FogCurve = Shader.PropertyToID("_FogCurve"); 27 | internal static readonly int FogStart = Shader.PropertyToID("_FogStart"); 28 | internal static readonly int BloomThreshold = Shader.PropertyToID("_BloomThreshold"); 29 | internal static readonly int BloomPower = Shader.PropertyToID("_BloomPower"); 30 | internal static readonly int BloomWidth = Shader.PropertyToID("_BloomWidth"); 31 | } 32 | 33 | protected override void Render(CommandBuffer cmd, ref RenderingData renderingData) 34 | { 35 | material.SetColor(ShaderPropertyID.FogColor, volumeComponent.fogColor.value); 36 | material.SetFloat(ShaderPropertyID.MaxFogFactor, volumeComponent.maxFogFactor.value); 37 | material.SetFloat(ShaderPropertyID.FogCurve, volumeComponent.fogCurve.value); 38 | material.SetFloat(ShaderPropertyID.FogStart, volumeComponent.fogStart.value); 39 | material.SetFloat(ShaderPropertyID.BloomThreshold, volumeComponent.bloomThreshold.value); 40 | material.SetFloat(ShaderPropertyID.BloomPower, volumeComponent.bloomPower.value); 41 | material.SetFloat(ShaderPropertyID.BloomWidth, volumeComponent.bloomWidth.value); 42 | 43 | cmd.SetGlobalTexture(ShaderPropertyID.MainTex, source); 44 | cmd.Blit(source, destination, material); 45 | } 46 | } -------------------------------------------------------------------------------- /Reshade/AdaptiveFog/AdaptiveFogRenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2ec4d6db488a841419c3b001038004a4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Reshade/AdaptiveSharpen.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3c16453f6a85dd74bbc13552e18f290b 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Reshade/AdaptiveSharpen/AdaptiveSharpen.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Rendering; 3 | using UnityEngine.Rendering.Universal; 4 | 5 | #if UNITY_EDITOR 6 | using UnityEditor.Rendering; 7 | #endif 8 | 9 | [System.Serializable, VolumeComponentMenu("Post-processing Custom/AdaptiveSharpen")] 10 | public class AdaptiveSharpen : VolumeComponent, IPostProcessComponent 11 | { 12 | public BoolParameter enable = new BoolParameter(false); 13 | 14 | public ClampedFloatParameter curveHeight = new ClampedFloatParameter(1f, 0.01f, 2f); 15 | public ClampedFloatParameter curveSlope = new ClampedFloatParameter(0.5f, 0.01f, 2f); 16 | public ClampedFloatParameter lightOvershoot = new ClampedFloatParameter(0.003f, 0.001f, 0.1f); 17 | public ClampedFloatParameter lightCompressionLow = new ClampedFloatParameter(0.167f, 0f, 1f); 18 | public ClampedFloatParameter lightCompressionHigh = new ClampedFloatParameter(0.334f, 0f, 1f); 19 | public ClampedFloatParameter darkOvershoot = new ClampedFloatParameter(0.009f, 0.001f, 0.1f); 20 | public ClampedFloatParameter darkCompressionLow = new ClampedFloatParameter(0.250f, 0f, 1f); 21 | public ClampedFloatParameter darkCompressionHigh = new ClampedFloatParameter(0.5f, 0f, 1f); 22 | public ClampedFloatParameter scaleLim = new ClampedFloatParameter(0.1f, 0.01f, 1f); 23 | public ClampedFloatParameter scaleCompressionSlope = new ClampedFloatParameter(0.056f, 0f, 1f); 24 | public ClampedFloatParameter powerMeanP = new ClampedFloatParameter(0.7f, 0.01f, 1f); 25 | public BoolParameter fastOperation = new BoolParameter(false); 26 | 27 | #region IPostProcessComponent 28 | public bool IsActive() => enable.value; 29 | public bool IsTileCompatible() => false; 30 | #endregion 31 | } 32 | 33 | #if UNITY_EDITOR 34 | [VolumeComponentEditor(typeof(AdaptiveSharpen))] 35 | class AdaptiveSharpenEditor : VolumeComponentEditor 36 | { 37 | SerializedDataParameter curveHeight; 38 | SerializedDataParameter curveSlope; 39 | SerializedDataParameter lightOvershoot; 40 | SerializedDataParameter lightCompressionLow; 41 | SerializedDataParameter lightCompressionHigh; 42 | SerializedDataParameter darkOvershoot; 43 | SerializedDataParameter darkCompressionLow; 44 | SerializedDataParameter darkCompressionHigh; 45 | SerializedDataParameter scaleLim; 46 | SerializedDataParameter scaleCompressionSlope; 47 | SerializedDataParameter powerMeanP; 48 | SerializedDataParameter fastOperation; 49 | 50 | public override void OnEnable() 51 | { 52 | var component = (AdaptiveSharpen)target; 53 | component.enable.value = true; 54 | component.enable.overrideState = true; 55 | 56 | var o = new PropertyFetcher(serializedObject); 57 | curveHeight = Unpack(o.Find(x => x.curveHeight)); 58 | curveSlope = Unpack(o.Find(x => x.curveSlope)); 59 | lightOvershoot = Unpack(o.Find(x => x.lightOvershoot)); 60 | lightCompressionLow = Unpack(o.Find(x => x.lightCompressionLow)); 61 | lightCompressionHigh = Unpack(o.Find(x => x.lightCompressionHigh)); 62 | darkOvershoot = Unpack(o.Find(x => x.darkOvershoot)); 63 | darkCompressionLow = Unpack(o.Find(x => x.darkCompressionLow)); 64 | darkCompressionHigh = Unpack(o.Find(x => x.darkCompressionHigh)); 65 | scaleLim = Unpack(o.Find(x => x.scaleLim)); 66 | scaleCompressionSlope = Unpack(o.Find(x => x.scaleCompressionSlope)); 67 | powerMeanP = Unpack(o.Find(x => x.powerMeanP)); 68 | fastOperation = Unpack(o.Find(x => x.fastOperation)); 69 | } 70 | 71 | public override void OnInspectorGUI() 72 | { 73 | PropertyField(curveHeight); 74 | PropertyField(curveSlope); 75 | PropertyField(lightOvershoot); 76 | PropertyField(lightCompressionLow); 77 | PropertyField(lightCompressionHigh); 78 | PropertyField(darkOvershoot); 79 | PropertyField(darkCompressionLow); 80 | PropertyField(darkCompressionHigh); 81 | PropertyField(scaleLim); 82 | PropertyField(scaleCompressionSlope); 83 | PropertyField(powerMeanP); 84 | PropertyField(fastOperation); 85 | } 86 | } 87 | #endif 88 | 89 | -------------------------------------------------------------------------------- /Reshade/AdaptiveSharpen/AdaptiveSharpen.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fd92161d9cb52c94b82d3cc9513a1b35 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Reshade/AdaptiveSharpen/AdaptiveSharpenRenderFeature.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Rendering; 3 | using UnityEngine.Rendering.Universal; 4 | 5 | public class AdaptiveSharpenRenderFeature : CustomRenderFeature 6 | { 7 | protected override CustomPass CreatePass(RenderPassEvent renderPassEvent) 8 | { 9 | return new AdaptiveSharpenPass(renderPassEvent); 10 | } 11 | } 12 | 13 | public class AdaptiveSharpenPass : CustomPass 14 | { 15 | public override string GetShaderPath() => "Hidden/PostProcessing/AdaptiveSharpen"; 16 | public override string renderTag => "Render AdaptiveSharpen Effects"; 17 | 18 | public AdaptiveSharpenPass(RenderPassEvent renderPassEvent) : base(renderPassEvent) { } 19 | 20 | static class ShaderPropertyID 21 | { 22 | internal static readonly int MainTex = Shader.PropertyToID("_MainTex"); 23 | internal static readonly int TempTex = Shader.PropertyToID("_TempTex"); 24 | 25 | internal static readonly int CurveHeight = Shader.PropertyToID("_CurveHeight"); 26 | internal static readonly int CurveSlope = Shader.PropertyToID("_CurveSlope"); 27 | internal static readonly int LightOvershoot = Shader.PropertyToID("_LightOvershoot"); 28 | internal static readonly int LightCompressionLow = Shader.PropertyToID("_LightCompressionLow"); 29 | internal static readonly int LightCompressionHigh = Shader.PropertyToID("_LightCompressionHigh"); 30 | internal static readonly int DarkOvershoot = Shader.PropertyToID("_DarkOvershoot"); 31 | internal static readonly int DarkCompressionLow = Shader.PropertyToID("_DarkCompressionLow"); 32 | internal static readonly int DarkCompressionHigh = Shader.PropertyToID("_DarkCompressionHigh"); 33 | internal static readonly int ScaleLim = Shader.PropertyToID("_ScaleLim"); 34 | internal static readonly int ScaleCompressionSlope = Shader.PropertyToID("_ScaleCompressionSlope"); 35 | internal static readonly int PowerMeanP = Shader.PropertyToID("_PowerMeanP"); 36 | } 37 | 38 | protected override void Render(CommandBuffer cmd, ref RenderingData renderingData) 39 | { 40 | var descriptor = renderingData.cameraData.cameraTargetDescriptor; 41 | 42 | material.SetFloat(ShaderPropertyID.CurveHeight, volumeComponent.curveHeight.value); 43 | material.SetFloat(ShaderPropertyID.CurveSlope, volumeComponent.curveSlope.value); 44 | material.SetFloat(ShaderPropertyID.LightOvershoot, volumeComponent.lightOvershoot.value); 45 | material.SetFloat(ShaderPropertyID.LightCompressionLow, volumeComponent.lightCompressionLow.value); 46 | material.SetFloat(ShaderPropertyID.LightCompressionHigh, volumeComponent.lightCompressionHigh.value); 47 | material.SetFloat(ShaderPropertyID.DarkOvershoot, volumeComponent.darkOvershoot.value); 48 | material.SetFloat(ShaderPropertyID.DarkCompressionLow, volumeComponent.darkCompressionLow.value); 49 | material.SetFloat(ShaderPropertyID.DarkCompressionHigh, volumeComponent.darkCompressionHigh.value); 50 | material.SetFloat(ShaderPropertyID.ScaleLim, volumeComponent.scaleLim.value); 51 | material.SetFloat(ShaderPropertyID.ScaleCompressionSlope, volumeComponent.scaleCompressionSlope.value); 52 | material.SetFloat(ShaderPropertyID.PowerMeanP, volumeComponent.powerMeanP.value); 53 | 54 | if (volumeComponent.fastOperation.value) 55 | material.EnableKeyword("FastOps"); 56 | else 57 | material.DisableKeyword("FastOps"); 58 | 59 | cmd.SetGlobalTexture(ShaderPropertyID.MainTex, source); 60 | cmd.GetTemporaryRT(ShaderPropertyID.TempTex, descriptor); 61 | var temp = new RenderTargetIdentifier(ShaderPropertyID.TempTex); 62 | cmd.Blit(source, temp, material, 0); 63 | 64 | cmd.SetGlobalTexture(ShaderPropertyID.TempTex, temp); 65 | cmd.Blit(source, destination, material, 1); 66 | 67 | cmd.ReleaseTemporaryRT(ShaderPropertyID.TempTex); 68 | } 69 | } -------------------------------------------------------------------------------- /Reshade/AdaptiveSharpen/AdaptiveSharpenRenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 842e1aa3aad5f4f40b6e6884f147a022 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Reshade/Cartoon.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6dec2c25c0b2a3c48bf9d2f0ef8efc3b 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Reshade/Cartoon/Cartoon.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Rendering; 3 | using UnityEngine.Rendering.Universal; 4 | 5 | #if UNITY_EDITOR 6 | using UnityEditor.Rendering; 7 | #endif 8 | 9 | [System.Serializable, VolumeComponentMenu("Post-processing Custom/Cartoon")] 10 | public class Cartoon : VolumeComponent, IPostProcessComponent 11 | { 12 | public BoolParameter enable = new BoolParameter(false); 13 | 14 | [Range(0.1f, 10f), Tooltip("Amount of effect you want")] 15 | public ClampedFloatParameter power = new ClampedFloatParameter(1.5f, 0.1f, 10f); 16 | [Range(0.1f, 6f), Tooltip("Raise this to filter out fainter edges. You might need to increase the power to compensate. Whole numbers are faster")] 17 | public ClampedFloatParameter edgeSlope = new ClampedFloatParameter(1.5f, 0.1f, 6f); 18 | 19 | #region IPostProcessComponent 20 | public bool IsActive() => enable.value; 21 | public bool IsTileCompatible() => false; 22 | #endregion 23 | } 24 | 25 | #if UNITY_EDITOR 26 | [VolumeComponentEditor(typeof(Cartoon))] 27 | class CartoonEditor : VolumeComponentEditor 28 | { 29 | SerializedDataParameter power; 30 | SerializedDataParameter edgeSlope; 31 | 32 | public override void OnEnable() 33 | { 34 | var cartoon = (Cartoon)target; 35 | cartoon.enable.value = true; 36 | cartoon.enable.overrideState = true; 37 | 38 | var o = new PropertyFetcher(serializedObject); 39 | power = Unpack(o.Find(x => x.power)); 40 | edgeSlope = Unpack(o.Find(x => x.edgeSlope)); 41 | } 42 | 43 | public override void OnInspectorGUI() 44 | { 45 | PropertyField(power); 46 | PropertyField(edgeSlope); 47 | } 48 | } 49 | #endif 50 | 51 | -------------------------------------------------------------------------------- /Reshade/Cartoon/Cartoon.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3b15fa29c24265644af38566edd6ba96 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Reshade/Cartoon/CartoonRenderFeature.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Rendering; 3 | using UnityEngine.Rendering.Universal; 4 | 5 | public class CartoonRenderFeature : CustomRenderFeature 6 | { 7 | protected override CustomPass CreatePass(RenderPassEvent renderPassEvent) 8 | { 9 | return new CartoonPass(renderPassEvent); 10 | } 11 | } 12 | 13 | public class CartoonPass : CustomPass 14 | { 15 | public override string GetShaderPath() => "Hidden/PostProcessing/Cartoon"; 16 | public override string renderTag => "Render Cartoon Effects"; 17 | 18 | public CartoonPass(RenderPassEvent renderPassEvent) : base(renderPassEvent) { } 19 | 20 | static class ShaderPropertyID 21 | { 22 | internal static readonly int MainTex = Shader.PropertyToID("_MainTex"); 23 | 24 | internal static readonly int Power = Shader.PropertyToID("_Power"); 25 | internal static readonly int EdgeSlope = Shader.PropertyToID("_EdgeSlope"); 26 | } 27 | 28 | protected override void Render(CommandBuffer cmd, ref RenderingData renderingData) 29 | { 30 | material.SetFloat(ShaderPropertyID.Power, volumeComponent.power.value); 31 | material.SetFloat(ShaderPropertyID.EdgeSlope, volumeComponent.edgeSlope.value); 32 | 33 | cmd.SetGlobalTexture(ShaderPropertyID.MainTex, source); 34 | cmd.Blit(source, destination, material); 35 | } 36 | } -------------------------------------------------------------------------------- /Reshade/Cartoon/CartoonRenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6d14a26ba5b1fd54d84860feec7eddcd 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Reshade/Clarity2.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f04d931a1419cc7439b032bfbbb7824a 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Reshade/Clarity2/Clarity2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityEngine.Rendering; 4 | using UnityEngine.Rendering.Universal; 5 | 6 | #if UNITY_EDITOR 7 | using UnityEditor.Rendering; 8 | #endif 9 | 10 | [System.Serializable, VolumeComponentMenu("Post-processing Custom/Clarity2")] 11 | public class Clarity2 : VolumeComponent, IPostProcessComponent 12 | { 13 | public BoolParameter enable = new BoolParameter(false); 14 | 15 | public enum BlendMode 16 | { 17 | SoftLight, 18 | Overlay, 19 | HardLight, 20 | Multiply, 21 | VividLight, 22 | LinearLight, 23 | Addition 24 | } 25 | [Serializable] 26 | public sealed class BlendModeParameter : VolumeParameter { } 27 | 28 | public ClampedIntParameter radius = new ClampedIntParameter(3, 0, 4); 29 | public ClampedIntParameter offset = new ClampedIntParameter(2, 1, 5); 30 | public BlendModeParameter blendMode = new BlendModeParameter { value = BlendMode.HardLight}; 31 | public ClampedIntParameter blendIfDark = new ClampedIntParameter(50, 0, 255); 32 | public ClampedIntParameter blendIfLight = new ClampedIntParameter(205, 0, 255); 33 | public ClampedFloatParameter blendIfRange = new ClampedFloatParameter(0.2f, 0f, 1f); 34 | public ClampedFloatParameter strength = new ClampedFloatParameter(0.4f, 0f, 1f); 35 | public ClampedFloatParameter maskContrast = new ClampedFloatParameter(0f, 0f, 1f); 36 | public ClampedFloatParameter darkIntensity = new ClampedFloatParameter(0.4f, 0f, 10f); 37 | public ClampedFloatParameter lightIntensity = new ClampedFloatParameter(0f, 0f, 10f); 38 | public ClampedFloatParameter ditherStrength = new ClampedFloatParameter(1f, 0f, 10f); 39 | 40 | #region IPostProcessComponent 41 | public bool IsActive() => enable.value; 42 | public bool IsTileCompatible() => false; 43 | #endregion 44 | } 45 | 46 | #if UNITY_EDITOR 47 | [VolumeComponentEditor(typeof(Clarity2))] 48 | class Clarity2Editor : VolumeComponentEditor 49 | { 50 | SerializedDataParameter radius; 51 | SerializedDataParameter offset; 52 | SerializedDataParameter blendMode; 53 | SerializedDataParameter blendIfDark; 54 | SerializedDataParameter blendIfLight; 55 | SerializedDataParameter blendIfRange; 56 | SerializedDataParameter strength; 57 | SerializedDataParameter maskContrast; 58 | SerializedDataParameter darkIntensity; 59 | SerializedDataParameter lightIntensity; 60 | SerializedDataParameter ditherStrength; 61 | 62 | public override void OnEnable() 63 | { 64 | var component = (Clarity2)target; 65 | component.enable.value = true; 66 | component.enable.overrideState = true; 67 | 68 | var o = new PropertyFetcher(serializedObject); 69 | radius = Unpack(o.Find(x => x.radius)); 70 | offset = Unpack(o.Find(x => x.offset)); 71 | blendMode = Unpack(o.Find(x => x.blendMode)); 72 | blendIfDark = Unpack(o.Find(x => x.blendIfDark)); 73 | blendIfLight = Unpack(o.Find(x => x.blendIfLight)); 74 | blendIfRange = Unpack(o.Find(x => x.blendIfRange)); 75 | strength = Unpack(o.Find(x => x.strength)); 76 | maskContrast = Unpack(o.Find(x => x.maskContrast)); 77 | darkIntensity = Unpack(o.Find(x => x.darkIntensity)); 78 | lightIntensity = Unpack(o.Find(x => x.lightIntensity)); 79 | ditherStrength = Unpack(o.Find(x => x.ditherStrength)); 80 | } 81 | 82 | public override void OnInspectorGUI() 83 | { 84 | PropertyField(radius); 85 | PropertyField(offset); 86 | PropertyField(blendMode); 87 | PropertyField(blendIfDark); 88 | PropertyField(blendIfLight); 89 | PropertyField(blendIfRange); 90 | PropertyField(strength); 91 | PropertyField(maskContrast); 92 | PropertyField(darkIntensity); 93 | PropertyField(lightIntensity); 94 | PropertyField(ditherStrength); 95 | } 96 | } 97 | #endif 98 | 99 | -------------------------------------------------------------------------------- /Reshade/Clarity2/Clarity2.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5988aa6d626c7ea43a87632ce628a807 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Reshade/Clarity2/Clarity2RenderFeature.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Rendering; 3 | using UnityEngine.Rendering.Universal; 4 | 5 | public class Clarity2RenderFeature : CustomRenderFeature 6 | { 7 | protected override CustomPass CreatePass(RenderPassEvent renderPassEvent) 8 | { 9 | return new Clarity2Pass(renderPassEvent); 10 | } 11 | } 12 | 13 | public class Clarity2Pass : CustomPass 14 | { 15 | public override string GetShaderPath() => "Hidden/PostProcessing/Clarity2"; 16 | public override string renderTag => "Render Clarity2 Effects"; 17 | 18 | public Clarity2Pass(RenderPassEvent renderPassEvent) : base(renderPassEvent) { } 19 | 20 | static class ShaderPropertyID 21 | { 22 | internal static readonly int MainTex = Shader.PropertyToID("_MainTex"); 23 | internal static readonly int Temp1Tex = Shader.PropertyToID("_Temp1Tex"); 24 | internal static readonly int Temp2Tex = Shader.PropertyToID("_Temp2Tex"); 25 | 26 | internal static readonly int Offset = Shader.PropertyToID("_Offset"); 27 | internal static readonly int BlendIfDark = Shader.PropertyToID("_BlendIfDark"); 28 | internal static readonly int BlendIfLight = Shader.PropertyToID("_BlendIfLight"); 29 | internal static readonly int BlendIfRange = Shader.PropertyToID("_BlendIfRange"); 30 | internal static readonly int Strength = Shader.PropertyToID("_Strength"); 31 | internal static readonly int MaskContrast = Shader.PropertyToID("_MaskContrast"); 32 | internal static readonly int DarkIntensity = Shader.PropertyToID("_DarkIntensity"); 33 | internal static readonly int LightIntensity = Shader.PropertyToID("_LightIntensity"); 34 | internal static readonly int DitherStrength = Shader.PropertyToID("_DitherStrength"); 35 | } 36 | 37 | protected override void Render(CommandBuffer cmd, ref RenderingData renderingData) 38 | { 39 | var descriptor = renderingData.cameraData.cameraTargetDescriptor; 40 | 41 | material.SetInt(ShaderPropertyID.Offset, volumeComponent.offset.value); 42 | material.SetInt(ShaderPropertyID.BlendIfDark, volumeComponent.blendIfDark.value); 43 | material.SetInt(ShaderPropertyID.BlendIfLight, volumeComponent.blendIfLight.value); 44 | material.SetFloat(ShaderPropertyID.BlendIfRange, volumeComponent.blendIfRange.value); 45 | material.SetFloat(ShaderPropertyID.Strength, volumeComponent.strength.value); 46 | material.SetFloat(ShaderPropertyID.MaskContrast, volumeComponent.maskContrast.value); 47 | material.SetFloat(ShaderPropertyID.DarkIntensity, volumeComponent.darkIntensity.value); 48 | material.SetFloat(ShaderPropertyID.LightIntensity, volumeComponent.lightIntensity.value); 49 | material.SetFloat(ShaderPropertyID.DitherStrength, volumeComponent.ditherStrength.value); 50 | 51 | switch (volumeComponent.radius.value) { 52 | case 0: material.EnableKeyword("RADIUS_ZERO"); break; 53 | case 1: material.EnableKeyword("RADIUS_ONE"); break; 54 | case 2: material.EnableKeyword("RADIUS_TWO"); break; 55 | case 3: material.EnableKeyword("RADIUS_THEREE"); break; 56 | case 4: material.EnableKeyword("RADIUS_FOUR"); break; 57 | } 58 | 59 | switch (volumeComponent.blendMode.value) { 60 | case Clarity2.BlendMode.SoftLight: material.EnableKeyword("BLENDMODE_SOFTLIGHT"); break; 61 | case Clarity2.BlendMode.Overlay: material.EnableKeyword("BLENDMODE_OVERLAY"); break; 62 | case Clarity2.BlendMode.HardLight: material.EnableKeyword("BLENDMODE_HARDLIGHT"); break; 63 | case Clarity2.BlendMode.Multiply: material.EnableKeyword("BLENDMODE_MULTIPLY"); break; 64 | case Clarity2.BlendMode.VividLight: material.EnableKeyword("BLENDMODE_VIVIDLIGHT"); break; 65 | case Clarity2.BlendMode.LinearLight: material.EnableKeyword("BLENDMODE_LINEARLIGHT"); break; 66 | case Clarity2.BlendMode.Addition: material.EnableKeyword("BLENDMODE_ADDITION"); break; 67 | } 68 | 69 | cmd.SetGlobalTexture(ShaderPropertyID.MainTex, source); 70 | cmd.GetTemporaryRT(ShaderPropertyID.Temp1Tex, descriptor.width / 2, descriptor.height / 2, 0, FilterMode.Point, RenderTextureFormat.ARGB32); 71 | cmd.GetTemporaryRT(ShaderPropertyID.Temp2Tex, descriptor.width / 2, descriptor.height / 2, 0, FilterMode.Point, RenderTextureFormat.ARGB32); 72 | var temp1 = new RenderTargetIdentifier(ShaderPropertyID.Temp1Tex); 73 | var temp2 = new RenderTargetIdentifier(ShaderPropertyID.Temp2Tex); 74 | cmd.SetGlobalTexture(ShaderPropertyID.Temp1Tex, temp1); 75 | cmd.SetGlobalTexture(ShaderPropertyID.Temp2Tex, temp2); 76 | cmd.Blit(source, temp1, material, 0); 77 | cmd.Blit(temp1, temp2, material, 1); 78 | cmd.Blit(temp2, temp1, material, 2); 79 | cmd.Blit(source, destination, material, 3); 80 | 81 | cmd.ReleaseTemporaryRT(ShaderPropertyID.Temp1Tex); 82 | cmd.ReleaseTemporaryRT(ShaderPropertyID.Temp2Tex); 83 | } 84 | } -------------------------------------------------------------------------------- /Reshade/Clarity2/Clarity2RenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 449460a0f4818404eac5c2fd2e7be437 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Reshade/FakeHDR.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b6b7003fc68886547a97e538224b81d0 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Reshade/FakeHDR/FakeHDR.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Rendering; 3 | using UnityEngine.Rendering.Universal; 4 | 5 | #if UNITY_EDITOR 6 | using UnityEditor.Rendering; 7 | #endif 8 | 9 | [System.Serializable, VolumeComponentMenu("Reshade/FakeHDR")] 10 | public class FakeHDR : VolumeComponent, IPostProcessComponent 11 | { 12 | public BoolParameter enable = new BoolParameter(false); 13 | 14 | [Range(0f, 8f), Tooltip("Power")] 15 | public ClampedFloatParameter power = new ClampedFloatParameter(1.3f, 0f, 8f); 16 | 17 | [Range(0f, 8f), Tooltip("Radius 1")] 18 | public ClampedFloatParameter radius1 = new ClampedFloatParameter(0.793f, 0f, 8f); 19 | 20 | [Range(0f, 8f), Tooltip("Raising this seems to make the effect stronger and also brighter.")] 21 | public ClampedFloatParameter radius2 = new ClampedFloatParameter(0.87f, 0f, 8f); 22 | 23 | #region IPostProcessComponent 24 | public bool IsActive() => this.enable.value; 25 | public bool IsTileCompatible() => false; 26 | #endregion 27 | } 28 | 29 | #if UNITY_EDITOR 30 | [VolumeComponentEditor(typeof(FakeHDR))] 31 | class FakeHDREditor : VolumeComponentEditor 32 | { 33 | SerializedDataParameter power; 34 | SerializedDataParameter radius1; 35 | SerializedDataParameter radius2; 36 | 37 | public override void OnEnable() 38 | { 39 | var grayscale = (FakeHDR)target; 40 | grayscale.enable.value = true; 41 | grayscale.enable.overrideState = true; 42 | 43 | var o = new PropertyFetcher(serializedObject); 44 | power = Unpack(o.Find(x => x.power)); 45 | radius1 = Unpack(o.Find(x => x.radius1)); 46 | radius2 = Unpack(o.Find(x => x.radius2)); 47 | } 48 | 49 | public override void OnInspectorGUI() 50 | { 51 | PropertyField(power); 52 | PropertyField(radius1); 53 | PropertyField(radius2); 54 | } 55 | } 56 | #endif -------------------------------------------------------------------------------- /Reshade/FakeHDR/FakeHDR.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 85d225a5a00ceaf4db6c9689a01fdf49 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Reshade/FakeHDR/FakeHDRRenderFeature.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Rendering; 3 | using UnityEngine.Rendering.Universal; 4 | 5 | public class FakeHDRRenderFeature : CustomRenderFeature 6 | { 7 | protected override CustomPass CreatePass(RenderPassEvent renderPassEvent) 8 | { 9 | return new FakeHDRPass(renderPassEvent); 10 | } 11 | } 12 | 13 | public class FakeHDRPass : CustomPass 14 | { 15 | public override string GetShaderPath() => "Hidden/PostProcessing/FakeHDR"; 16 | public override string renderTag => "Render FakeHDR Effects"; 17 | 18 | public FakeHDRPass(RenderPassEvent renderPassEvent) : base(renderPassEvent) { } 19 | 20 | static class ShaderPropertyID 21 | { 22 | internal static readonly int MainTex = Shader.PropertyToID("_MainTex"); 23 | 24 | internal static readonly int HDRPower = Shader.PropertyToID("_HDRPower"); 25 | internal static readonly int Radius1 = Shader.PropertyToID("_Radius1"); 26 | internal static readonly int Radius2 = Shader.PropertyToID("_Radius2"); 27 | } 28 | 29 | protected override void Render(CommandBuffer cmd, ref RenderingData renderingData) 30 | { 31 | material.SetFloat(ShaderPropertyID.HDRPower, volumeComponent.power.value); 32 | material.SetFloat(ShaderPropertyID.Radius1, volumeComponent.radius1.value); 33 | material.SetFloat(ShaderPropertyID.Radius2, volumeComponent.radius2.value); 34 | 35 | cmd.SetGlobalTexture(ShaderPropertyID.MainTex, source); 36 | cmd.Blit(source, destination, material); 37 | } 38 | } -------------------------------------------------------------------------------- /Reshade/FakeHDR/FakeHDRRenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9fab23a22287af24687884644efb49e6 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6ded079593f971b4c84b04c6092e9312 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Resources/Shaders.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4100e0e9060955f449b71d297a51080a 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Resources/Shaders/ADOF.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/PostProcessing/ADOF" 2 | { 3 | HLSLINCLUDE 4 | Texture2D _MainTex; 5 | SamplerState sampler_MainTex; 6 | float _Blend; 7 | 8 | #include "Common.hlsl" 9 | 10 | float4 Frag0(v2f i) : SV_Target 11 | { 12 | float4 color = _MainTex.Sample(sampler_MainTex, i.texcoord); 13 | float luminance = dot(color.rgb, float3(0.2126729, 0.7151522, 0.0721750)); 14 | color.rgb = lerp(color.rgb, luminance.xxx, _Blend.xxx); 15 | return color; 16 | } 17 | ENDHLSL 18 | 19 | SubShader 20 | { 21 | Cull Off ZWrite Off ZTest Always 22 | 23 | Pass 24 | { 25 | HLSLPROGRAM 26 | #pragma vertex Vert 27 | #pragma fragment Frag0 28 | ENDHLSL 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /Resources/Shaders/ADOF.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b923f78853c7825448b20efd1310b4e3 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Resources/Shaders/AdaptiveFog.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/PostProcessing/AdaptiveFog" 2 | { 3 | HLSLINCLUDE 4 | Texture2D _MainTex; 5 | SamplerState sampler_MainTex; 6 | float4 _MainTex_TexelSize; 7 | 8 | float _BloomThreshold; 9 | float _BloomPower; 10 | float _BloomWidth; 11 | float4 _FogColor; 12 | float _MaxFogFactor; 13 | float _FogCurve; 14 | float _FogStart; 15 | 16 | #include "Common.hlsl" 17 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl" 18 | 19 | float4 Frag(v2f i) : SV_Target 20 | { 21 | float4 color = _MainTex.Sample(sampler_MainTex, i.texcoord); 22 | float depth = LinearEyeDepth(SampleSceneDepth(i.texcoord), _ZBufferParams); 23 | 24 | float3 blurColor2 = 0; 25 | float3 blurtemp = 0; 26 | const float maxDistance = 8 * _BloomWidth; 27 | float curDistance = 0; 28 | const float sampleCount = 25.0; 29 | const float2 blurtempvalue = i.texcoord * _MainTex_TexelSize.xy * _BloomWidth; 30 | float2 bloomSample = float2(2.5, -2.5); 31 | float2 bloomSampleValue = float2(0, 0); 32 | 33 | for (bloomSample.x = (2.5); bloomSample.x > -2.0; bloomSample.x = bloomSample.x - 1.0) 34 | { 35 | bloomSampleValue.x = bloomSample.x * blurtempvalue.x; 36 | float2 distancetemp = bloomSample.x * bloomSample.x * _BloomWidth; 37 | 38 | for (bloomSample.y = (-2.5); bloomSample.y < 2.0; bloomSample.y = bloomSample.y + 1.0) 39 | { 40 | distancetemp.y = bloomSample.y * bloomSample.y; 41 | curDistance = (distancetemp.y * _BloomWidth) + distancetemp.x; 42 | bloomSampleValue.y = bloomSample.y * blurtempvalue.y; 43 | blurtemp = _MainTex.Sample(sampler_MainTex, i.texcoord + bloomSampleValue).rgb; 44 | blurColor2.rgb += lerp(blurtemp.rgb, color.rgb, sqrt(curDistance / maxDistance)); 45 | } 46 | } 47 | blurColor2.rgb = (blurColor2.rgb / (sampleCount - (_BloomPower - _BloomThreshold * 5))); 48 | 49 | float bloomAmount = (dot(color.rgb, float3(0.299f, 0.587f, 0.114f))); 50 | float4 blurColor = float4(blurColor2.rgb * (_BloomPower + 4.0), 1.0); 51 | blurColor = saturate(lerp(color, blurColor, bloomAmount)); 52 | 53 | float fogFactor = clamp(saturate(depth - _FogStart) * _FogCurve, 0.0, _MaxFogFactor); 54 | 55 | return saturate(lerp(color, lerp(blurColor, _FogColor, fogFactor), fogFactor)); 56 | } 57 | ENDHLSL 58 | 59 | SubShader 60 | { 61 | Cull Off ZWrite Off ZTest Always 62 | 63 | Pass 64 | { 65 | HLSLPROGRAM 66 | #pragma vertex Vert 67 | #pragma fragment Frag 68 | ENDHLSL 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Resources/Shaders/AdaptiveFog.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 623495c6708adac47b4fdfb900adccff 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Resources/Shaders/AdaptiveSharpen.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/PostProcessing/AdaptiveSharpen" 2 | { 3 | HLSLINCLUDE 4 | Texture2D _MainTex; 5 | SamplerState sampler_MainTex; 6 | Texture2D _TempTex; 7 | SamplerState sampler_TempTex; 8 | 9 | float4 _MainTex_TexelSize; 10 | 11 | float _CurveHeight; 12 | float _CurveSlope; 13 | float _LightOvershoot; 14 | float _LightCompressionLow; 15 | float _LightCompressionHigh; 16 | float _DarkOvershoot; 17 | float _DarkCompressionLow; 18 | float _DarkCompressionHigh; 19 | float _ScaleLim; 20 | float _ScaleCompressionSlope; 21 | float _PowerMeanP; 22 | 23 | #include "Common.hlsl" 24 | 25 | // Helper functions 26 | #define sqr(a) ( (a) * (a) ) 27 | #define max4(a,b,c,d) ( max(max(a, b), max(c, d)) ) 28 | 29 | #define texc(x,y) ( _MainTex_TexelSize.xy * float2(x, y) + i.texcoord ) 30 | //#define getB(x,y) ( saturate(_MainTex.Sample(sampler_MainTex, texc(x, y))).rgb ) 31 | #define getB(x,y) ( _MainTex.Sample(sampler_MainTex, texc(x, y)).rgb ) 32 | #define getT(x,y) ( _TempTex.Sample(sampler_TempTex, texc(x, y)).xy ) 33 | // Component-wise distance 34 | #define b_diff(pix) ( abs(blur - c[pix]) ) 35 | // Weighted power mean 36 | #define wpmean(a,b,w) ( pow(abs(w) * pow(abs(a), _PowerMeanP) + abs(1 - w) * pow(abs(b), _PowerMeanP), (1.0 / _PowerMeanP)) ) 37 | // Center pixel diff 38 | #define mdiff(a,b,c,d,e,f,g) ( abs(luma[g] - luma[a]) + abs(luma[g] - luma[b]) \ 39 | + abs(luma[g] - luma[c]) + abs(luma[g] - luma[d]) \ 40 | + 0.5*(abs(luma[g] - luma[e]) + abs(luma[g] - luma[f])) ) 41 | 42 | #define soft_if(a,b,c) ( saturate((a + b + c + 0.056) * rcp(abs(maxedge) + 0.03) - 0.85) ) 43 | 44 | #ifdef FastOps 45 | float soft_lim(float v, float s) 46 | { 47 | const float vs = v / s; 48 | const float vs2 = sqr(vs); 49 | return saturate(abs(vs) * (27 + vs2) / (27 + 9 * vs2)) * s; 50 | } 51 | float2 soft_lim(float2 v, float2 s) 52 | { 53 | const float2 vs = v / s; 54 | const float2 vs2 = sqr(vs); 55 | return saturate(abs(vs) * (27 + vs2) / (27 + 9 * vs2)) * s; 56 | } 57 | float3 soft_lim(float3 v, float3 s) 58 | { 59 | const float3 vs = v / s; 60 | const float3 vs2 = sqr(vs); 61 | return saturate(abs(vs) * (27 + vs2) / (27 + 9 * vs2)) * s; 62 | } 63 | float4 soft_lim(float4 v, float4 s) 64 | { 65 | const float4 vs = v / s; 66 | const float4 vs2 = sqr(vs); 67 | return saturate(abs(vs) * (27 + vs2) / (27 + 9 * vs2)) * s; 68 | } 69 | 70 | // Approx of x = tanh(x/y)*y + 0.5/2^bit-depth, y = min(L_overshoot, D_overshoot) 71 | #define min_overshoot ( min(abs(_LightOvershoot), abs(_DarkOvershoot)) ) 72 | #define fskip_th ( 0.114 * pow(min_overshoot, 0.676) + 3.20e-4 ) // 10-bits 73 | #else 74 | float soft_lim(float v, float s) 75 | { 76 | const float sv = exp(2 * min(abs(v), s * 24) / s); 77 | return (sv - 1) / (sv + 1) * s; 78 | } 79 | float2 soft_lim(float2 v, float2 s) 80 | { 81 | const float2 sv = exp(2 * min(abs(v), s * 24) / s); 82 | return (sv - 1) / (sv + 1) * s; 83 | } 84 | float3 soft_lim(float3 v, float3 s) 85 | { 86 | const float3 sv = exp(2 * min(abs(v), s * 24) / s); 87 | return (sv - 1) / (sv + 1) * s; 88 | } 89 | float4 soft_lim(float4 v, float4 s) 90 | { 91 | const float4 sv = exp(2 * min(abs(v), s * 24) / s); 92 | return (sv - 1) / (sv + 1) * s; 93 | } 94 | 95 | // x = tanh(x/y)*y + 0.5/2^bit-depth, y = 0.0001 96 | #define fskip_th ( 0.000110882 ) // 14-bits 97 | #endif 98 | 99 | 100 | float2 Frag0(v2f i) : SV_Target 101 | { 102 | // Get points and clip out of range values (BTB & WTW) 103 | // [ c9 ] 104 | // [ c1, c2, c3 ] 105 | // [ c10, c4, c0, c5, c11 ] 106 | // [ c6, c7, c8 ] 107 | // [ c12 ] 108 | const float3 c[13] = { getB(0, 0), getB(-1, -1), getB(0, -1), 109 | getB(1, -1), getB(-1, 0), getB(1, 0), getB(-1, 1), getB(0, 1), 110 | getB(1, 1), getB(0, -2), getB(-2, 0), getB(2, 0), getB(0, 2) }; 111 | 112 | // Colour to luma, fast approx gamma, avg of rec. 709 & 601 luma coeffs 113 | const float luma = sqrt(dot(float3(0.2558, 0.6511, 0.0931), sqr(c[0]))); 114 | 115 | // Blur, gauss 3x3 116 | const float3 blur = (2 * (c[2] + c[4] + c[5] + c[7]) + (c[1] + c[3] + c[6] + c[8]) + 4 * c[0]) / 16; 117 | 118 | // Contrast compression, center = 0.5, scaled to 1/3 119 | // !!! could pre-calc the static value math here (eg: 4.0/15.0 = 0.2666666666666667) 120 | // !!! but might lead to decimal rounding / truncation (like MS Calculator did above). 121 | // !!! but the rounding might be within tolerance. Pre-calc'ing 4/15 & -37/15 would 122 | // !!! save 2 calc's per call here. Maybe have it pre-calc if fast_ops flag is 123 | // !!! set, that way fast_ops will trim calculation cycles while fast_ops false 124 | // !!! will try to go with more detail by doing the calculations on-the-fly each time? 125 | const float compVal1 = 4.0 / 15.0; 126 | const float compVal2 = -37.0 / 15.0; 127 | const float c_comp = saturate(compVal1 + 0.9 * exp2(dot(blur, compVal2))); 128 | 129 | // Edge detection 130 | // Relative matrix weights 131 | // [ 1 ] 132 | // [ 4, 5, 4 ] 133 | // [ 1, 5, 6, 5, 1 ] 134 | // [ 4, 5, 4 ] 135 | // [ 1 ] 136 | const float edge = length(1.38 * (b_diff(0)) 137 | + 1.15 * (b_diff(2) + b_diff(4) + b_diff(5) + b_diff(7)) 138 | + 0.92 * (b_diff(1) + b_diff(3) + b_diff(6) + b_diff(8)) 139 | + 0.23 * (b_diff(9) + b_diff(10) + b_diff(11) + b_diff(12))); 140 | 141 | return float2(edge * c_comp, luma); 142 | } 143 | 144 | float4 Frag1(v2f i) : SV_Target 145 | { 146 | float3 origsat = getB(0, 0); 147 | 148 | // Get texture points, .x = edge, .y = luma 149 | // [ d22 ] 150 | // [ d24, d9, d23 ] 151 | // [ d21, d1, d2, d3, d18 ] 152 | // [ d19, d10, d4, d0, d5, d11, d16 ] 153 | // [ d20, d6, d7, d8, d17 ] 154 | // [ d15, d12, d14 ] 155 | // [ d13 ] 156 | const float2 d[25] = { getT(0, 0), getT(-1,-1), getT(0,-1), getT(1,-1), getT(-1, 0), 157 | getT(1, 0), getT(-1, 1), getT(0, 1), getT(1, 1), getT(0,-2), 158 | getT(-2, 0), getT(2, 0), getT(0, 2), getT(0, 3), getT(1, 2), 159 | getT(-1, 2), getT(3, 0), getT(2, 1), getT(2,-1), getT(-3, 0), 160 | getT(-2, 1), getT(-2,-1), getT(0,-3), getT(1,-2), getT(-1,-2) }; 161 | 162 | // Allow for higher overshoot if the current edge pixel is surrounded by similar edge pixels 163 | const float maxedge = max4(max4(d[1].x,d[2].x,d[3].x,d[4].x), max4(d[5].x,d[6].x,d[7].x,d[8].x), 164 | max4(d[9].x,d[10].x,d[11].x,d[12].x), d[0].x); 165 | 166 | // [ x ] 167 | // [ z, x, w ] 168 | // [ z, z, x, w, w ] 169 | // [ y, y, y, 0, y, y, y ] 170 | // [ w, w, x, z, z ] 171 | // [ w, x, z ] 172 | // [ x ] 173 | const float sbe = soft_if(d[2].x,d[9].x, d[22].x) * soft_if(d[7].x,d[12].x,d[13].x) // x dir 174 | + soft_if(d[4].x,d[10].x,d[19].x) * soft_if(d[5].x,d[11].x,d[16].x) // y dir 175 | + soft_if(d[1].x,d[24].x,d[21].x) * soft_if(d[8].x,d[14].x,d[17].x) // z dir 176 | + soft_if(d[3].x,d[23].x,d[18].x) * soft_if(d[6].x,d[20].x,d[15].x); // w dir 177 | 178 | #ifdef FastOps 179 | const float2 cs = lerp(float2(_LightCompressionLow, _DarkCompressionLow), 180 | float2(_LightCompressionHigh, _DarkCompressionHigh), saturate(1.091 * sbe - 2.282)); 181 | #else 182 | const float2 cs = lerp(float2(_LightCompressionLow, _DarkCompressionLow), 183 | float2(_LightCompressionHigh, _DarkCompressionHigh), smoothstep(2, 3.1, sbe)); 184 | #endif 185 | 186 | float luma[25] = { d[0].y, d[1].y, d[2].y, d[3].y, d[4].y, 187 | d[5].y, d[6].y, d[7].y, d[8].y, d[9].y, 188 | d[10].y, d[11].y, d[12].y, d[13].y, d[14].y, 189 | d[15].y, d[16].y, d[17].y, d[18].y, d[19].y, 190 | d[20].y, d[21].y, d[22].y, d[23].y, d[24].y }; 191 | 192 | // Pre-calculated default squared kernel weights 193 | const float3 W1 = float3(0.5, 1.0, 1.41421356237); // 0.25, 1.0, 2.0 194 | const float3 W2 = float3(0.86602540378, 1.0, 0.54772255751); // 0.75, 1.0, 0.3 195 | 196 | // Transition to a concave kernel if the center edge val is above thr 197 | #ifdef FastOps 198 | const float3 dW = sqr(lerp(W1, W2, saturate(2.4 * d[0].x - 0.82))); 199 | #else 200 | const float3 dW = sqr(lerp(W1, W2, smoothstep(0.3, 0.8, d[0].x))); 201 | #endif 202 | 203 | const float mdiff_c0 = 0.02 + 3 * (abs(luma[0] - luma[2]) + abs(luma[0] - luma[4]) 204 | + abs(luma[0] - luma[5]) + abs(luma[0] - luma[7]) 205 | + 0.25 * (abs(luma[0] - luma[1]) + abs(luma[0] - luma[3]) 206 | + abs(luma[0] - luma[6]) + abs(luma[0] - luma[8]))); 207 | 208 | // Use lower weights for pixels in a more active area relative to center pixel area 209 | // This results in narrower and less visible overshoots around sharp edges 210 | float weights[12] = { (min(mdiff_c0 / mdiff(24, 21, 2, 4, 9, 10, 1), dW.y)), // c1 211 | (dW.x), // c2 212 | (min(mdiff_c0 / mdiff(23, 18, 5, 2, 9, 11, 3), dW.y)), // c3 213 | (dW.x), // c4 214 | (dW.x), // c5 215 | (min(mdiff_c0 / mdiff(4, 20, 15, 7, 10, 12, 6), dW.y)), // c6 216 | (dW.x), // c7 217 | (min(mdiff_c0 / mdiff(5, 7, 17, 14, 12, 11, 8), dW.y)), // c8 218 | (min(mdiff_c0 / mdiff(2, 24, 23, 22, 1, 3, 9), dW.z)), // c9 219 | (min(mdiff_c0 / mdiff(20, 19, 21, 4, 1, 6, 10), dW.z)), // c10 220 | (min(mdiff_c0 / mdiff(17, 5, 18, 16, 3, 8, 11), dW.z)), // c11 221 | (min(mdiff_c0 / mdiff(13, 15, 7, 14, 6, 8, 12), dW.z)) }; // c12 222 | 223 | weights[0] = (max(max((weights[8] + weights[9]) / 4, weights[0]), 0.25) + weights[0]) / 2; 224 | weights[2] = (max(max((weights[8] + weights[10]) / 4, weights[2]), 0.25) + weights[2]) / 2; 225 | weights[5] = (max(max((weights[9] + weights[11]) / 4, weights[5]), 0.25) + weights[5]) / 2; 226 | weights[7] = (max(max((weights[10] + weights[11]) / 4, weights[7]), 0.25) + weights[7]) / 2; 227 | 228 | // Calculate the negative part of the laplace kernel and the low threshold weight 229 | float lowthrsum = 0; 230 | float weightsum = 0; 231 | float neg_laplace = 0; 232 | 233 | // modified - Craig - Jul 5th, 2020 234 | [unroll] for (int pix = 0; pix < 12; ++pix) 235 | { 236 | // !!! pre-calc (weights[pix]*lowthr) once, 237 | // !!! then use twice to save an extra calc per-loop 238 | #ifdef FastOps 239 | float lowthr = clamp((13.2 * d[pix + 1].x - 0.221), 0.01, 1); 240 | float weighted_lowthr = weights[pix] * lowthr; 241 | neg_laplace += sqr(luma[pix + 1]) * weighted_lowthr; 242 | #else 243 | float t = saturate((d[pix + 1].x - 0.01) / 0.09); 244 | float lowthr = t * t * (2.97 - 1.98 * t) + 0.01; // t*t*(3 - a*3 - (2 - a*2)*t) + a 245 | float weighted_lowthr = weights[pix] * lowthr; 246 | neg_laplace += pow(abs(luma[pix + 1]) + 0.06, 2.4) * weighted_lowthr; 247 | #endif 248 | weightsum += weighted_lowthr; 249 | lowthrsum += lowthr / 12; 250 | } 251 | 252 | #ifdef FastOps 253 | neg_laplace = sqrt(neg_laplace / weightsum); 254 | #else 255 | neg_laplace = pow(abs(neg_laplace / weightsum), (1.0 / 2.4)) - 0.06; 256 | #endif 257 | 258 | // Compute sharpening magnitude function 259 | const float sharpen_val = _CurveHeight / (_CurveHeight * _CurveSlope * pow(abs(d[0].x), 3.5) + 0.625); 260 | 261 | // Calculate sharpening diff and scale 262 | float sharpdiff = (d[0].y - neg_laplace) * (lowthrsum * sharpen_val + 0.01); 263 | 264 | // Skip limiting on flat areas where sharpdiff is low 265 | [branch] if (abs(sharpdiff) > fskip_th) 266 | { 267 | // Calculate local near min & max, partial sort 268 | // Manually unrolled outer loop, solves OpenGL slowdown 269 | { 270 | float temp; int i; int ii; 271 | 272 | // 1st iteration 273 | [unroll] for (i = 0; i < 24; i += 2) 274 | { 275 | temp = luma[i]; 276 | luma[i] = min(luma[i], luma[i + 1]); 277 | luma[i + 1] = max(temp, luma[i + 1]); 278 | } 279 | [unroll] for (ii = 24; ii > 0; ii -= 2) 280 | { 281 | temp = luma[0]; 282 | luma[0] = min(luma[0], luma[ii]); 283 | luma[ii] = max(temp, luma[ii]); 284 | 285 | temp = luma[24]; 286 | luma[24] = max(luma[24], luma[ii - 1]); 287 | luma[ii - 1] = min(temp, luma[ii - 1]); 288 | } 289 | 290 | // 2nd iteration 291 | [unroll] for (i = 1; i < 23; i += 2) 292 | { 293 | temp = luma[i]; 294 | luma[i] = min(luma[i], luma[i + 1]); 295 | luma[i + 1] = max(temp, luma[i + 1]); 296 | } 297 | [unroll] for (ii = 23; ii > 1; ii -= 2) 298 | { 299 | temp = luma[1]; 300 | luma[1] = min(luma[1], luma[ii]); 301 | luma[ii] = max(temp, luma[ii]); 302 | 303 | temp = luma[23]; 304 | luma[23] = max(luma[23], luma[ii - 1]); 305 | luma[ii - 1] = min(temp, luma[ii - 1]); 306 | } 307 | 308 | #if (fast_ops != 1) // 3rd iteration 309 | [unroll] for (i = 2; i < 22; i += 2) 310 | { 311 | temp = luma[i]; 312 | luma[i] = min(luma[i], luma[i + 1]); 313 | luma[i + 1] = max(temp, luma[i + 1]); 314 | } 315 | [unroll] for (ii = 22; ii > 2; ii -= 2) 316 | { 317 | temp = luma[2]; 318 | luma[2] = min(luma[2], luma[ii]); 319 | luma[ii] = max(temp, luma[ii]); 320 | 321 | temp = luma[22]; 322 | luma[22] = max(luma[22], luma[ii - 1]); 323 | luma[ii - 1] = min(temp, luma[ii - 1]); 324 | } 325 | #endif 326 | } 327 | 328 | // Calculate tanh scale factors 329 | #ifdef FastOps 330 | const float nmax = (max(luma[23], d[0].y) * 2 + luma[24]) / 3; 331 | const float nmin = (min(luma[1], d[0].y) * 2 + luma[0]) / 3; 332 | 333 | const float min_dist = min(abs(nmax - d[0].y), abs(d[0].y - nmin)); 334 | float pos_scale = min_dist + _LightOvershoot; 335 | float neg_scale = min_dist + _DarkOvershoot; 336 | #else 337 | const float nmax = (max(luma[22] + luma[23] * 2, d[0].y * 3) + luma[24]) / 4; 338 | const float nmin = (min(luma[2] + luma[1] * 2, d[0].y * 3) + luma[0]) / 4; 339 | 340 | const float min_dist = min(abs(nmax - d[0].y), abs(d[0].y - nmin)); 341 | float pos_scale = min_dist + min(_LightOvershoot, 1.0001 - min_dist - d[0].y); 342 | float neg_scale = min_dist + min(_DarkOvershoot, 0.0001 + d[0].y - min_dist); 343 | #endif 344 | 345 | // modified - Craig - Jul 5th, 2020 346 | // !!! pre-calc scale_lim_temp once, use twice 347 | const float scale_lim_temp = _ScaleLim * (1 - _ScaleCompressionSlope); 348 | pos_scale = min(pos_scale, scale_lim_temp + pos_scale * _ScaleCompressionSlope); 349 | neg_scale = min(neg_scale, scale_lim_temp + neg_scale * _ScaleCompressionSlope); 350 | 351 | // modified - Craig - Jul 5th, 2020 352 | // pre-calc min / max sharpdiff used twice each below 353 | const float maxsharpdiff = max(sharpdiff, 0); 354 | const float minsharpdiff = min(sharpdiff, 0); 355 | sharpdiff = wpmean(maxsharpdiff, soft_lim(maxsharpdiff, pos_scale), cs.x) 356 | - wpmean(minsharpdiff, soft_lim(minsharpdiff, neg_scale), cs.y); 357 | } 358 | 359 | // Compensate for saturation loss/gain while making pixels brighter/darker 360 | //const float sharpdiff_lim = saturate(d[0].y + sharpdiff) - d[0].y; 361 | const float sharpdiff_lim = d[0].y + sharpdiff - d[0].y; 362 | 363 | return float4(d[0].y + (sharpdiff_lim * 3 + sharpdiff) / 4 + (origsat - d[0].y) * ((d[0].y + max(sharpdiff_lim * 0.9, sharpdiff_lim) * 1.03 + 0.03) / (d[0].y + 0.03)), 1); 364 | } 365 | ENDHLSL 366 | 367 | SubShader 368 | { 369 | Cull Off ZWrite Off ZTest Always 370 | 371 | Pass 372 | { 373 | HLSLPROGRAM 374 | #pragma multi_compile _ FastOps 375 | #pragma vertex Vert 376 | #pragma fragment Frag0 377 | ENDHLSL 378 | } 379 | 380 | Pass 381 | { 382 | HLSLPROGRAM 383 | #pragma multi_compile _ FastOps 384 | #pragma vertex Vert 385 | #pragma fragment Frag1 386 | ENDHLSL 387 | } 388 | } 389 | } -------------------------------------------------------------------------------- /Resources/Shaders/AdaptiveSharpen.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c74eef516694c9248b1eb6d77e0a0fe4 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Resources/Shaders/AnalogGlitch.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/PostProcessing/AnalogGlitch" 2 | { 3 | HLSLINCLUDE 4 | Texture2D _MainTex; 5 | SamplerState sampler_MainTex; 6 | 7 | float2 _ScanLineJitter; // (displacement, threshold) 8 | float2 _VerticalJump; // (amount, time) 9 | float _HorizontalShake; 10 | float2 _ColorDrift; // (amount, time) 11 | float4 _Time; 12 | 13 | #include "Common.hlsl" 14 | 15 | float nrand(float x, float y) 16 | { 17 | return frac(sin(dot(float2(x, y), float2(12.9898, 78.233))) * 43758.5453); 18 | } 19 | 20 | float4 Frag(v2f i) : SV_Target 21 | { 22 | float u = i.texcoord.x; 23 | float v = i.texcoord.y; 24 | 25 | // Scan line jitter 26 | float jitter = nrand(v, _Time.x) * 2 - 1; 27 | jitter *= step(_ScanLineJitter.y, abs(jitter)) * _ScanLineJitter.x; 28 | 29 | // Vertical jump 30 | float jump = lerp(v, frac(v + _VerticalJump.y), _VerticalJump.x); 31 | 32 | // Horizontal shake 33 | float shake = (nrand(_Time.x, 2) - 0.5) * _HorizontalShake; 34 | 35 | // Color drift 36 | float drift = sin(jump + _ColorDrift.y) * _ColorDrift.x; 37 | 38 | float4 src1 = _MainTex.Sample(sampler_MainTex, frac(float2(u + jitter + shake, jump))); 39 | float4 src2 = _MainTex.Sample(sampler_MainTex, frac(float2(u + jitter + shake + drift, jump))); 40 | 41 | return float4(src1.r, src2.g, src1.b, 1); 42 | } 43 | ENDHLSL 44 | 45 | SubShader 46 | { 47 | Cull Off ZWrite Off ZTest Always 48 | 49 | Pass 50 | { 51 | HLSLPROGRAM 52 | #pragma vertex Vert 53 | #pragma fragment Frag 54 | ENDHLSL 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /Resources/Shaders/AnalogGlitch.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 52c9566c1dbb4b34ba4cb7a1c1987baa 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Resources/Shaders/Cartoon.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/PostProcessing/Cartoon" 2 | { 3 | HLSLINCLUDE 4 | Texture2D _MainTex; 5 | SamplerState sampler_MainTex; 6 | float4 _MainTex_TexelSize; 7 | 8 | float _Power; 9 | float _EdgeSlope; 10 | 11 | #include "Common.hlsl" 12 | 13 | float4 Frag(v2f i) : SV_Target 14 | { 15 | float3 color = _MainTex.Sample(sampler_MainTex, i.texcoord).rgb; 16 | 17 | float3 CoefLuma2 = float3(0.2126, 0.7152, 0.0722); //Values to calculate luma with 18 | 19 | float3 color1 = _MainTex.Sample(sampler_MainTex, i.texcoord + _MainTex_TexelSize.xy).rgb; 20 | float diff1 = dot(CoefLuma2, color1); 21 | float3 color2 = _MainTex.Sample(sampler_MainTex, i.texcoord - _MainTex_TexelSize.xy).rgb; 22 | diff1 = dot(float4(CoefLuma2, -1.0), float4(color2, diff1)); 23 | 24 | float3 color3 = _MainTex.Sample(sampler_MainTex, i.texcoord + float2(_MainTex_TexelSize.x, -_MainTex_TexelSize.y)).rgb; 25 | float diff2 = dot(CoefLuma2, color3); 26 | float3 color4 = _MainTex.Sample(sampler_MainTex, i.texcoord + float2(-_MainTex_TexelSize.x, _MainTex_TexelSize.y)).rgb; 27 | diff2 = dot(float4(CoefLuma2, -1.0), float4(color4, diff2)); 28 | 29 | float edge = dot(float2(diff1, diff2), float2(diff1, diff2)); 30 | color -= pow(abs(edge), _EdgeSlope) * _Power; 31 | 32 | return saturate(float4(color, 1.0)); 33 | } 34 | 35 | ENDHLSL 36 | 37 | SubShader 38 | { 39 | Cull Off ZWrite Off ZTest Always 40 | 41 | Pass 42 | { 43 | HLSLPROGRAM 44 | #pragma vertex Vert 45 | #pragma fragment Frag 46 | ENDHLSL 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Resources/Shaders/Cartoon.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 08706ba5409cce14ca8b335f78f34e72 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Resources/Shaders/Clarity2.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/PostProcessing/Clarity2" 2 | { 3 | HLSLINCLUDE 4 | Texture2D _MainTex; 5 | SamplerState sampler_MainTex; 6 | Texture2D _Temp1Tex; 7 | SamplerState sampler_Temp1Tex; 8 | Texture2D _Temp2Tex; 9 | SamplerState sampler_Temp2Tex; 10 | 11 | float4 _MainTex_TexelSize; 12 | 13 | int _Offset; 14 | int _BlendIfDark; 15 | int _BlendIfLight; 16 | float _BlendIfRange; 17 | float _Strength; 18 | float _MaskContrast; 19 | float _DarkIntensity; 20 | float _LightIntensity; 21 | float _DitherStrength; 22 | 23 | #define Luma float3(0.32786885,0.655737705,0.0163934436) 24 | 25 | //Offset Values 26 | #define Offset02y _MainTex_TexelSize.y*1.1824255238 27 | #define Offset03y _MainTex_TexelSize.y*3.0293122308 28 | #define Offset04y _MainTex_TexelSize.y*5.0040701377 29 | 30 | #define Offset02x _MainTex_TexelSize.x*1.1824255238 31 | #define Offset03x _MainTex_TexelSize.x*3.0293122308 32 | #define Offset04x _MainTex_TexelSize.x*5.0040701377 33 | 34 | #define OffsetA2y _MainTex_TexelSize.y*1.4584295168 35 | #define OffsetA3y _MainTex_TexelSize.y*3.40398480678 36 | #define OffsetA4y _MainTex_TexelSize.y*5.3518057801 37 | #define OffsetA5y _MainTex_TexelSize.y*7.302940716 38 | #define OffsetA6y _MainTex_TexelSize.y*9.2581597095 39 | 40 | #define OffsetA2x _MainTex_TexelSize.x*1.4584295168 41 | #define OffsetA3x _MainTex_TexelSize.x*3.40398480678 42 | #define OffsetA4x _MainTex_TexelSize.x*5.3518057801 43 | #define OffsetA5x _MainTex_TexelSize.x*7.302940716 44 | #define OffsetA6x _MainTex_TexelSize.x*9.2581597095 45 | 46 | #define OffsetB2y 1.4895848401*_MainTex_TexelSize.y 47 | #define OffsetB3y 3.4757135714*_MainTex_TexelSize.y 48 | #define OffsetB4y 5.4618796741*_MainTex_TexelSize.y 49 | #define OffsetB5y 7.4481042327*_MainTex_TexelSize.y 50 | #define OffsetB6y 9.4344079746*_MainTex_TexelSize.y 51 | #define OffsetB7y 11.420811147*_MainTex_TexelSize.y 52 | #define OffsetB8y 13.4073334*_MainTex_TexelSize.y 53 | #define OffsetB9y 15.3939936778*_MainTex_TexelSize.y 54 | #define OffsetB10y 17.3808101174*_MainTex_TexelSize.y 55 | #define OffsetB11y 19.3677999584*_MainTex_TexelSize.y 56 | 57 | #define OffsetB2x 1.4895848401*_MainTex_TexelSize.x 58 | #define OffsetB3x 3.4757135714*_MainTex_TexelSize.x 59 | #define OffsetB4x 5.4618796741*_MainTex_TexelSize.x 60 | #define OffsetB5x 7.4481042327*_MainTex_TexelSize.x 61 | #define OffsetB6x 9.4344079746*_MainTex_TexelSize.x 62 | #define OffsetB7x 11.420811147*_MainTex_TexelSize.x 63 | #define OffsetB8x 13.4073334*_MainTex_TexelSize.x 64 | #define OffsetB9x 15.3939936778*_MainTex_TexelSize.x 65 | #define OffsetB10x 17.3808101174*_MainTex_TexelSize.x 66 | #define OffsetB11x 19.3677999584*_MainTex_TexelSize.x 67 | 68 | #define OffsetC2y _MainTex_TexelSize.y*1.4953705027 69 | #define OffsetC3y _MainTex_TexelSize.y*3.4891992113 70 | #define OffsetC4y _MainTex_TexelSize.y*5.4830312105 71 | #define OffsetC5y _MainTex_TexelSize.y*7.4768683759 72 | #define OffsetC6y _MainTex_TexelSize.y*9.4707125766 73 | #define OffsetC7y _MainTex_TexelSize.y*11.4645656736 74 | #define OffsetC8y _MainTex_TexelSize.y*13.4584295168 75 | #define OffsetC9y _MainTex_TexelSize.y*15.4523059431 76 | #define OffsetC10y _MainTex_TexelSize.y*17.4461967743 77 | #define OffsetC11y _MainTex_TexelSize.y*19.4401038149 78 | #define OffsetC12y _MainTex_TexelSize.y*21.43402885 79 | #define OffsetC13y _MainTex_TexelSize.y*23.4279736431 80 | #define OffsetC14y _MainTex_TexelSize.y*25.4219399344 81 | #define OffsetC15y _MainTex_TexelSize.y*27.4159294386 82 | 83 | #define OffsetC2x _MainTex_TexelSize.x*1.4953705027 84 | #define OffsetC3x _MainTex_TexelSize.x*3.4891992113 85 | #define OffsetC4x _MainTex_TexelSize.x*5.4830312105 86 | #define OffsetC5x _MainTex_TexelSize.x*7.4768683759 87 | #define OffsetC6x _MainTex_TexelSize.x*9.4707125766 88 | #define OffsetC7x _MainTex_TexelSize.x*11.4645656736 89 | #define OffsetC8x _MainTex_TexelSize.x*13.4584295168 90 | #define OffsetC9x _MainTex_TexelSize.x*15.4523059431 91 | #define OffsetC10x _MainTex_TexelSize.x*17.4461967743 92 | #define OffsetC11x _MainTex_TexelSize.x*19.4401038149 93 | #define OffsetC12x _MainTex_TexelSize.x*21.43402885 94 | #define OffsetC13x _MainTex_TexelSize.x*23.4279736431 95 | #define OffsetC14x _MainTex_TexelSize.x*25.4219399344 96 | #define OffsetC15x _MainTex_TexelSize.x*27.4159294386 97 | 98 | #define OffsetD2y _MainTex_TexelSize.y*1.4953705027 99 | #define OffsetD3y _MainTex_TexelSize.y*3.4891992113 100 | #define OffsetD4y _MainTex_TexelSize.y*5.4830312105 101 | #define OffsetD5y _MainTex_TexelSize.y*7.4768683759 102 | #define OffsetD6y _MainTex_TexelSize.y*9.4707125766 103 | #define OffsetD7y _MainTex_TexelSize.y*11.4645656736 104 | #define OffsetD8y _MainTex_TexelSize.y*13.4584295168 105 | #define OffsetD9y _MainTex_TexelSize.y*15.4523059431 106 | #define OffsetD10y _MainTex_TexelSize.y*17.4461967743 107 | #define OffsetD11y _MainTex_TexelSize.y*19.4661974725 108 | #define OffsetD12y _MainTex_TexelSize.y*21.4627427973 109 | #define OffsetD13y _MainTex_TexelSize.y*23.4592916956 110 | #define OffsetD14y _MainTex_TexelSize.y*25.455844494 111 | #define OffsetD15y _MainTex_TexelSize.y*27.4524015179 112 | #define OffsetD16y _MainTex_TexelSize.y*29.4489630909 113 | #define OffsetD17y _MainTex_TexelSize.y*31.445529535 114 | #define OffsetD18y _MainTex_TexelSize.y*33.4421011704 115 | 116 | #define OffsetD2x _MainTex_TexelSize.x*1.4953705027 117 | #define OffsetD3x _MainTex_TexelSize.x*3.4891992113 118 | #define OffsetD4x _MainTex_TexelSize.x*5.4830312105 119 | #define OffsetD5x _MainTex_TexelSize.x*7.4768683759 120 | #define OffsetD6x _MainTex_TexelSize.x*9.4707125766 121 | #define OffsetD7x _MainTex_TexelSize.x*11.4645656736 122 | #define OffsetD8x _MainTex_TexelSize.x*13.4584295168 123 | #define OffsetD9x _MainTex_TexelSize.x*15.4523059431 124 | #define OffsetD10x _MainTex_TexelSize.x*17.4461967743 125 | #define OffsetD11x _MainTex_TexelSize.x*19.4661974725 126 | #define OffsetD12x _MainTex_TexelSize.x*21.4627427973 127 | #define OffsetD13x _MainTex_TexelSize.x*23.4592916956 128 | #define OffsetD14x _MainTex_TexelSize.x*25.455844494 129 | #define OffsetD15x _MainTex_TexelSize.x*27.4524015179 130 | #define OffsetD16x _MainTex_TexelSize.x*29.4489630909 131 | #define OffsetD17x _MainTex_TexelSize.x*31.445529535 132 | #define OffsetD18x _MainTex_TexelSize.x*33.4421011704 133 | 134 | //Dithering Noise 135 | #define noiseR float(frac((cos(dot(texcoord, float2(12.9898,78.233)))) * 43758.5453 + texcoord.x)*0.015873)-0.0079365 136 | #define noiseG float(frac((cos(dot(texcoord, float2(-12.9898,78.233)))) * 43758.5453 + texcoord.x)*0.015873)-0.0079365 137 | #define noiseB float(frac((sin(dot(texcoord, float2(12.9898,-78.233)))) * 43758.5453 + texcoord.x)*0.015873)-0.0079365 138 | 139 | #include "Common.hlsl" 140 | 141 | float4 Clarity0(v2f i) : SV_Target 142 | { 143 | float4 color = _MainTex.Sample(sampler_MainTex, i.texcoord * _Offset); 144 | 145 | return color; 146 | } 147 | 148 | float4 Clarity1(v2f i) : SV_Target 149 | { 150 | float4 blur = _Temp1Tex.Sample(sampler_Temp1Tex, i.texcoord); 151 | 152 | float2 texcoord = i.texcoord; 153 | float2 coordOffset; 154 | 155 | #ifdef RADIUS_TWO 156 | static const float offset[11] = { 0.0, OffsetB2y, OffsetB3y, OffsetB4y, OffsetB5y, OffsetB6y, OffsetB7y, OffsetB8y, OffsetB9y, OffsetB10y, OffsetB11y }; 157 | static const float weight[11] = { 0.06649, 0.1284697563, 0.111918249, 0.0873132676, 0.0610011113, 0.0381655709, 0.0213835661, 0.0107290241, 0.0048206869, 0.0019396469, 0.0006988718 }; 158 | static const int loopCount = 11; 159 | #elif RADIUS_THEREE 160 | static const float offset[15] = { 0.0, OffsetC2y, OffsetC3y, OffsetC4y, OffsetC5y, OffsetC6y, OffsetC7y, OffsetC8y, OffsetC9y, OffsetC10y, OffsetC11y, OffsetC12y, OffsetC13y, OffsetC14y, OffsetC15y }; 161 | static const float weight[15] = { 0.0443266667, 0.0872994708, 0.0820892038, 0.0734818355, 0.0626171681, 0.0507956191, 0.0392263968, 0.0288369812, 0.0201808877, 0.0134446557, 0.0085266392, 0.0051478359, 0.0029586248, 0.0016187257, 0.0008430913 }; 162 | static const int loopCount = 15; 163 | #elif RADIUS_FOUR 164 | static const float offset[18] = { 0.0, OffsetD2y, OffsetD3y, OffsetD4y, OffsetD5y, OffsetD6y, OffsetD7y, OffsetD8y, OffsetD9y, OffsetD10y, OffsetD11y, OffsetD12y, OffsetD13y, OffsetD14y, OffsetD15y, OffsetD16y, OffsetD17y, OffsetD18y }; 165 | static const float weight[18] = { 0.033245, 0.0659162217, 0.0636705814, 0.0598194658, 0.0546642566, 0.0485871646, 0.0420045997, 0.0353207015, 0.0288880982, 0.0229808311, 0.0177815511, 0.013382297, 0.0097960001, 0.0069746748, 0.0048301008, 0.0032534598, 0.0021315311, 0.0013582974 }; 166 | static const int loopCount = 18; 167 | #elif RADIUS_ONE 168 | static const float offset[6] = { 0.0, OffsetA2y, OffsetA3y, OffsetA4y, OffsetA5y, OffsetA6y }; 169 | static const float weight[6] = { 0.13298, 0.23227575, 0.1353261595, 0.0511557427, 0.01253922, 0.0019913644 }; 170 | static const int loopCount = 6; 171 | #else 172 | static const float offset[4] = { 0.0, Offset02y, Offset03y, Offset04y }; 173 | static const float weight[4] = { 0.39894, 0.2959599993, 0.0045656525, 0.00000149278686458842 }; 174 | static const int loopCount = 4; 175 | #endif 176 | blur *= weight[0]; 177 | 178 | [loop] 179 | for (int i = 1; i < loopCount; ++i) { 180 | coordOffset = float2(0.0, offset[i]); 181 | blur += _Temp1Tex.SampleLevel(sampler_Temp1Tex, (texcoord + coordOffset) * weight[i], 0); 182 | blur += _Temp1Tex.SampleLevel(sampler_Temp1Tex, (texcoord - coordOffset) * weight[i], 0); 183 | } 184 | 185 | return blur; 186 | } 187 | 188 | float4 Clarity2(v2f i) : SV_Target 189 | { 190 | float4 blur = _Temp2Tex.Sample(sampler_Temp2Tex, i.texcoord); 191 | 192 | float2 texcoord = i.texcoord; 193 | float2 coordOffset; 194 | 195 | #ifdef RADIUS_TWO 196 | static const float offset[11] = { 0.0, OffsetB2x, OffsetB3x, OffsetB4x, OffsetB5x, OffsetB6x, OffsetB7x, OffsetB8x, OffsetB9x, OffsetB10x, OffsetB11x }; 197 | static const float weight[11] = { 0.06649, 0.1284697563, 0.111918249, 0.0873132676, 0.0610011113, 0.0381655709, 0.0213835661, 0.0107290241, 0.0048206869, 0.0019396469, 0.0006988718 }; 198 | static const int loopCount = 11; 199 | #elif RADIUS_THEREE 200 | static const float offset[15] = { 0.0, OffsetC2x, OffsetC3x, OffsetC4x, OffsetC5x, OffsetC6x, OffsetC7x, OffsetC8x, OffsetC9x, OffsetC10x, OffsetC11x, OffsetC12x, OffsetC13x, OffsetC14x, OffsetC15x }; 201 | static const float weight[15] = { 0.0443266667, 0.0872994708, 0.0820892038, 0.0734818355, 0.0626171681, 0.0507956191, 0.0392263968, 0.0288369812, 0.0201808877, 0.0134446557, 0.0085266392, 0.0051478359, 0.0029586248, 0.0016187257, 0.0008430913 }; 202 | static const int loopCount = 15; 203 | #elif RADIUS_FOUR 204 | static const float offset[18] = { 0.0, OffsetD2x, OffsetD3x, OffsetD4x, OffsetD5x, OffsetD6x, OffsetD7x, OffsetD8x, OffsetD9x, OffsetD10x, OffsetD11x, OffsetD12x, OffsetD13x, OffsetD14x, OffsetD15x, OffsetD16x, OffsetD17x, OffsetD18x }; 205 | static const float weight[18] = { 0.033245, 0.0659162217, 0.0636705814, 0.0598194658, 0.0546642566, 0.0485871646, 0.0420045997, 0.0353207015, 0.0288880982, 0.0229808311, 0.0177815511, 0.013382297, 0.0097960001, 0.0069746748, 0.0048301008, 0.0032534598, 0.0021315311, 0.0013582974 }; 206 | static const int loopCount = 18; 207 | #elif RADIUS_ONE 208 | static const float offset[6] = { 0.0, OffsetA2x, OffsetA3x, OffsetA4x, OffsetA5x, OffsetA6x }; 209 | static const float weight[6] = { 0.13298, 0.23227575, 0.1353261595, 0.0511557427, 0.01253922, 0.0019913644 }; 210 | static const int loopCount = 6; 211 | #else 212 | static const float offset[4] = { 0.0, Offset02x, Offset03x, Offset04x }; 213 | static const float weight[4] = { 0.39894, 0.2959599993, 0.0045656525, 0.00000149278686458842 }; 214 | static const int loopCount = 4; 215 | #endif 216 | blur *= weight[0]; 217 | 218 | [loop] 219 | for (int i = 1; i < loopCount; ++i) { 220 | coordOffset = float2(offset[i], 0.0); 221 | blur += _Temp2Tex.SampleLevel(sampler_Temp2Tex, (texcoord + coordOffset) * weight[i], 0); 222 | blur += _Temp2Tex.SampleLevel(sampler_Temp2Tex, (texcoord - coordOffset) * weight[i], 0); 223 | } 224 | 225 | return blur; 226 | } 227 | 228 | float4 Clarity3(v2f i) : SV_Target 229 | { 230 | float4 orig = _MainTex.Sample(sampler_MainTex, i.texcoord); 231 | float3 blur = _Temp1Tex.Sample(sampler_Temp1Tex, i.texcoord / (float)_Offset).rgb; 232 | 233 | float2 texcoord = i.texcoord; 234 | float3 sharp = 1.0 - blur; 235 | 236 | if (_MaskContrast) { 237 | const float3 vivid = saturate((1 - (1 - orig.rgb) / (2 * sharp) + orig.rgb / (2 * (1 - sharp))) * 0.5); 238 | sharp = (orig.rgb + sharp) * 0.5; 239 | sharp = lerp(sharp, vivid, _MaskContrast); 240 | } 241 | else { 242 | sharp = (orig.rgb + sharp) * 0.5; 243 | } 244 | 245 | if (_DarkIntensity || _LightIntensity) 246 | { 247 | float3 curve = sharp * sharp * sharp * (sharp * (sharp * 6.0 - 15.0) + 10.0); 248 | float3 sharpMin = lerp(sharp, curve, _DarkIntensity); 249 | float3 sharpMax = lerp(sharp, curve, _LightIntensity); 250 | float3 sharpStep = step(0.5, sharp); 251 | sharp = (sharpMin * (1 - sharpStep)) + (sharpMax * sharpStep); 252 | } 253 | 254 | sharp = lerp(sharp, sharp - float3(noiseR, noiseG, noiseB), _DitherStrength); 255 | 256 | #ifdef BLENDMODE_SOFTLIGHT 257 | const float3 A = (2 * orig.rgb * sharp) + (orig.rgb * orig.rgb * (1.0 - 2 * sharp)); 258 | const float3 B = (2 * orig.rgb * (1.0 - sharp)) + (sqrt(orig.rgb) * (2 * sharp - 1.0)); 259 | const float3 C = step(0.49, sharp); 260 | sharp = (A * (1.0 - C)) + (B * C); 261 | #elif BLENDMODE_OVERLAY 262 | const float3 A = (2 * orig.rgb * sharp); 263 | const float3 B = (1.0 - 2 * (1.0 - orig.rgb) * (1.0 - sharp)); 264 | const float3 C = step(0.5, orig.rgb); 265 | sharp = lerp(A, B, C); 266 | #elif BLENDMODE_HARDLIGHT 267 | const float3 A = 2 * orig.rgb * sharp; 268 | const float3 B = 1.0 - 2 * (1.0 - orig.rgb) * (1.0 - sharp); 269 | const float3 C = step(0.5, sharp); 270 | sharp = lerp(A, B, C); 271 | #elif BLENDMODE_MULTIPLY 272 | sharp = saturate(2 * orig.rgb * sharp); 273 | #elif BLENDMODE_VIVIDLIGHT 274 | const float3 A = 2 * orig.rgb * sharp; 275 | const float3 B = orig.rgb / (2 * (1 - sharp)); 276 | const float3 C = step(0.50, sharp); 277 | sharp = lerp(A, B, C); 278 | #elif BLENDMODE_LINEARLIGHT 279 | sharp = orig.rgb + 2.0 * sharp - 1.0; 280 | #else // BLENDMODE_ADDITION 281 | sharp = saturate(orig.rgb + (sharp - 0.5)); 282 | #endif 283 | 284 | if (_BlendIfDark || _BlendIfLight < 255) { 285 | const float blendIfD = ((255 - _BlendIfDark) / 255.0); 286 | const float blendIfL = (_BlendIfLight / 255.0); 287 | float3 mask = 1.0; 288 | float range; 289 | 290 | if (_BlendIfDark) { 291 | range = blendIfD * _BlendIfRange; 292 | float3 cmix = 1 - orig.rgb; 293 | mask -= smoothstep(blendIfD - (range), blendIfD + (range), cmix); 294 | } 295 | 296 | if (_BlendIfLight) { 297 | range = blendIfL * _BlendIfRange; 298 | const float3 cmix = orig.rgb; 299 | mask = lerp(mask, 0.0, smoothstep(blendIfL - range, blendIfL + range, cmix)); 300 | } 301 | 302 | sharp = lerp(orig.rgb, sharp, mask); 303 | } 304 | 305 | orig.rgb = lerp(orig.rgb, sharp, _Strength); 306 | 307 | return orig; 308 | } 309 | 310 | ENDHLSL 311 | 312 | SubShader 313 | { 314 | Cull Off ZWrite Off ZTest Always 315 | 316 | Pass 317 | { 318 | HLSLPROGRAM 319 | #pragma vertex Vert 320 | #pragma fragment Clarity0 321 | ENDHLSL 322 | } 323 | Pass 324 | { 325 | HLSLPROGRAM 326 | #pragma multi_compile RADIUS_ZERO RADIUS_ONE RADIUS_TWO RADIUS_THEREE RADIUS_FOUR 327 | #pragma vertex Vert 328 | #pragma fragment Clarity1 329 | ENDHLSL 330 | } 331 | Pass 332 | { 333 | HLSLPROGRAM 334 | #pragma multi_compile RADIUS_ZERO RADIUS_ONE RADIUS_TWO RADIUS_THEREE RADIUS_FOUR 335 | #pragma vertex Vert 336 | #pragma fragment Clarity2 337 | ENDHLSL 338 | } 339 | Pass 340 | { 341 | HLSLPROGRAM 342 | #pragma multi_compile BLENDMODE_SOFTLIGHT BLENDMODE_OVERLAY BLENDMODE_HARDLIGHT BLENDMODE_MULTIPLY BLENDMODE_VIVIDLIGHT BLENDMODE_LINEARLIGHT BLENDMODE_ADDITION 343 | #pragma vertex Vert 344 | #pragma fragment Clarity3 345 | ENDHLSL 346 | } 347 | } 348 | } -------------------------------------------------------------------------------- /Resources/Shaders/Clarity2.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6c6ee994a3bf17645884470dfc9c019b 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Resources/Shaders/Common.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef POSTPROCESSURP_COMMON_INCLUDED 2 | #define POSTPROCESSURP_COMMON_INCLUDED 3 | 4 | struct appdata 5 | { 6 | float4 vertex : POSITION; 7 | float2 uv : TEXCOORD0; 8 | }; 9 | 10 | struct v2f 11 | { 12 | float2 texcoord : TEXCOORD0; 13 | float4 vertex : SV_POSITION; 14 | }; 15 | 16 | v2f Vert(appdata v) 17 | { 18 | v2f o; 19 | o.vertex = float4((v.vertex.xy - 0.5) * 2, 0.0, 1.0); 20 | o.texcoord = v.vertex.xy; 21 | 22 | return o; 23 | } 24 | 25 | #endif -------------------------------------------------------------------------------- /Resources/Shaders/Common.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a2b61bf0667ea8c44a243cbbd5ab1a06 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Resources/Shaders/Contour.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/PostProcessing/Contour" 2 | { 3 | HLSLINCLUDE 4 | Texture2D _MainTex; 5 | SamplerState sampler_MainTex; 6 | float4 _MainTex_TexelSize; 7 | 8 | float4 _Color; 9 | float4 _Background; 10 | 11 | float _Threshold; 12 | float _InvRange; 13 | 14 | float _ColorSensitivity; 15 | float _DepthSensitivity; 16 | float _NormalSensitivity; 17 | float _InvFallOff; 18 | 19 | #include "Common.hlsl" 20 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" 21 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl" 22 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareNormalsTexture.hlsl" 23 | 24 | float4 Frag(v2f i) : SV_Target 25 | { 26 | // Source color 27 | float4 c0 = _MainTex.Sample(sampler_MainTex, i.texcoord); 28 | 29 | // Four sample points of the roberts cross operator 30 | float2 uv0 = i.texcoord; // TL 31 | float2 uv1 = i.texcoord + _MainTex_TexelSize.xy; // BR 32 | float2 uv2 = i.texcoord + float2(_MainTex_TexelSize.x, 0); // TR 33 | float2 uv3 = i.texcoord + float2(0, _MainTex_TexelSize.y); // BL 34 | 35 | float edge = 0; 36 | 37 | #ifdef _CONTOUR_COLOR 38 | // Color samples 39 | float3 c1 = _MainTex.Sample(sampler_MainTex, uv1).rgb; 40 | float3 c2 = _MainTex.Sample(sampler_MainTex, uv2).rgb; 41 | float3 c3 = _MainTex.Sample(sampler_MainTex, uv3).rgb; 42 | 43 | // Roberts cross operator 44 | float3 cg1 = c1 - c0; 45 | float3 cg2 = c3 - c2; 46 | float cg = sqrt(dot(cg1, cg1) + dot(cg2, cg2)); 47 | 48 | edge = cg * _ColorSensitivity; 49 | #endif 50 | 51 | #ifdef _CONTOUR_DEPTH 52 | // Depth samples 53 | float zs0 = SampleSceneDepth(uv0); 54 | float zs1 = SampleSceneDepth(uv1); 55 | float zs2 = SampleSceneDepth(uv2); 56 | float zs3 = SampleSceneDepth(uv3); 57 | 58 | // Calculate fall-off parameter from the depth of the nearest point 59 | float zm = min(min(min(zs0, zs1), zs2), zs3); 60 | float falloff = 1.0 - saturate(LinearEyeDepth(zm, _ZBufferParams) * _InvFallOff); 61 | 62 | // Convert to linear depth values. 63 | float z0 = Linear01Depth(zs0, _ZBufferParams); 64 | float z1 = Linear01Depth(zs1, _ZBufferParams); 65 | float z2 = Linear01Depth(zs2, _ZBufferParams); 66 | float z3 = Linear01Depth(zs3, _ZBufferParams); 67 | 68 | // Roberts cross operator 69 | float zg1 = z1 - z0; 70 | float zg2 = z3 - z2; 71 | float zg = sqrt(zg1 * zg1 + zg2 * zg2); 72 | 73 | edge = max(edge, zg * falloff * _DepthSensitivity / Linear01Depth(zm, _ZBufferParams)); 74 | #endif 75 | 76 | #ifdef _CONTOUR_NORMAL 77 | // Normal samples from the G-buffer 78 | float3 n0 = SampleSceneNormals(uv0); 79 | float3 n1 = SampleSceneNormals(uv1); 80 | float3 n2 = SampleSceneNormals(uv2); 81 | float3 n3 = SampleSceneNormals(uv3); 82 | 83 | // Roberts cross operator 84 | float3 ng1 = n1 - n0; 85 | float3 ng2 = n3 - n2; 86 | float ng = sqrt(dot(ng1, ng1) + dot(ng2, ng2)); 87 | 88 | edge = max(edge, ng * _NormalSensitivity); 89 | #endif 90 | 91 | // Thresholding 92 | edge = saturate((edge - _Threshold) * _InvRange); 93 | 94 | float3 cb = lerp(c0.rgb, _Background.rgb, _Background.a); 95 | float3 co = lerp(cb, _Color.rgb, edge * _Color.a); 96 | return float4(co, c0.a); 97 | } 98 | 99 | ENDHLSL 100 | 101 | SubShader 102 | { 103 | ZTest Always Cull Off ZWrite Off 104 | 105 | Pass 106 | { 107 | HLSLPROGRAM 108 | #pragma vertex Vert 109 | #pragma fragment Frag 110 | #pragma multi_compile _ _CONTOUR_COLOR 111 | #pragma multi_compile _ _CONTOUR_DEPTH 112 | #pragma multi_compile _ _CONTOUR_NORMAL 113 | ENDHLSL 114 | } 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /Resources/Shaders/Contour.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 55ab7a4b9b1b82b48b009bca54f2aefd 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Resources/Shaders/DigitalGlitch.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/PostProcessing/DigitalGlitch" 2 | { 3 | HLSLINCLUDE 4 | Texture2D _MainTex; 5 | SamplerState sampler_MainTex; 6 | Texture2D _NoiseTex; 7 | SamplerState sampler_NoiseTex; 8 | Texture2D _TrashTex; 9 | SamplerState sampler_TrashTex; 10 | 11 | float _Intensity; 12 | 13 | #include "Common.hlsl" 14 | 15 | float4 Frag(v2f i) : SV_Target 16 | { 17 | float4 glitch = _NoiseTex.Sample(sampler_NoiseTex, i.texcoord); 18 | 19 | float thresh = 1.001 - _Intensity * 1.001; 20 | float w_d = step(thresh, pow(abs(glitch.z), 2.5)); 21 | float w_f = step(thresh, pow(abs(glitch.w), 2.5)); 22 | float w_c = step(thresh, pow(abs(glitch.z), 3.5)); 23 | 24 | float2 uv = frac(i.texcoord + glitch.xy * w_d); 25 | float4 source = _MainTex.Sample(sampler_MainTex, uv); 26 | float4 trash = _TrashTex.Sample(sampler_TrashTex, uv); 27 | float3 color = lerp(source, trash, w_f).rgb; 28 | float3 neg = saturate(color.grb + (1 - dot(color, 1)) * 0.5); 29 | color = lerp(color, neg, w_c); 30 | 31 | return float4(color, source.a); 32 | } 33 | ENDHLSL 34 | 35 | SubShader 36 | { 37 | Cull Off ZWrite Off ZTest Always 38 | 39 | Pass 40 | { 41 | HLSLPROGRAM 42 | #pragma vertex Vert 43 | #pragma fragment Frag 44 | ENDHLSL 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /Resources/Shaders/DigitalGlitch.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4d66081d3e065e742900d9966a1eb27f 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Resources/Shaders/EdgeDetection.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/PostProcessing/EdgeDetection" 2 | { 3 | HLSLINCLUDE 4 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareNormalsTexture.hlsl" 5 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl" 6 | 7 | Texture2D _MainTex; 8 | float4 _MainTex_TexelSize; 9 | 10 | // The blending factor for the edges with the original color 11 | float _Intensity; 12 | // The threshold ranges for edge detection (xy used for normals, zw used for depth) 13 | float4 _Threshold; 14 | // The thickness of the edge (determines how far the neighbour samples spread around the center sample) 15 | float _Thickness; 16 | // The color of the edge 17 | float3 _Color; 18 | 19 | // Curtom Scene normal and depth sampling function to read from a custom texture and sampler 20 | float3 SampleSceneNormals(float2 uv, TEXTURE2D_X_FLOAT(_Texture), SAMPLER(sampler_Texture)) 21 | { 22 | return UnpackNormalOctRectEncode(SAMPLE_TEXTURE2D_X(_Texture, sampler_Texture, UnityStereoTransformScreenSpaceTex(uv)).xy) * float3(1.0, 1.0, -1.0); 23 | } 24 | 25 | float SampleSceneDepth(float2 uv, TEXTURE2D_X_FLOAT(_Texture), SAMPLER(sampler_Texture)) 26 | { 27 | return SAMPLE_TEXTURE2D_X(_Texture, sampler_Texture, UnityStereoTransformScreenSpaceTex(uv)).r; 28 | } 29 | 30 | // A Bilinear sampler to allow for subpixel thickness for the edge 31 | SAMPLER(sampler_linear_clamp); 32 | 33 | // Sample normal & depth and combine them to a single 4D vector (xyz for normal, w for depth) 34 | float4 SampleSceneDepthNormal(float2 uv){ 35 | float depth = SampleSceneDepth(uv, _CameraDepthTexture, sampler_linear_clamp); 36 | float depthEye = LinearEyeDepth(depth, _ZBufferParams); 37 | float3 normal = SampleSceneNormals(uv, _CameraNormalsTexture, sampler_linear_clamp); 38 | return float4(normal, depthEye); 39 | } 40 | 41 | // Read the 8 surrounding samples and average them with perspective correction 42 | // The perspective correction helps when the surface normal is almost orthogonal to the view direction 43 | float4 SampleNeighborhood(float2 uv, float thickness){ 44 | // The surrounding pixel offsets 45 | const float2 offsets[8] = { 46 | float2(-1, -1), 47 | float2(-1, 0), 48 | float2(-1, 1), 49 | float2(0, -1), 50 | float2(0, 1), 51 | float2(1, -1), 52 | float2(1, 0), 53 | float2(1, 1) 54 | }; 55 | 56 | float2 delta = _MainTex_TexelSize.xy * thickness; 57 | float4 sum = 0; 58 | float weight = 0; 59 | for(int i=0; i<8; i++){ 60 | float4 sample = SampleSceneDepthNormal(uv + delta * offsets[i]); 61 | // The sum is weight by 1/depth for perspecive correction 62 | sum += sample / sample.w; 63 | weight += 1/sample.w; 64 | } 65 | sum /= weight; 66 | // Doesn't make a visible difference but it feels more correct 67 | // May remove it for performance benefits 68 | sum.xyz = normalize(sum.xyz); 69 | return sum; 70 | } 71 | 72 | #include "Common.hlsl" 73 | 74 | float4 Frag(v2f input) : SV_Target 75 | { 76 | UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); 77 | 78 | float2 uv = UnityStereoTransformScreenSpaceTex(input.texcoord); 79 | float4 color = LOAD_TEXTURE2D_X(_MainTex, uv * _ScreenSize.xy); 80 | 81 | float4 center = SampleSceneDepthNormal(uv); 82 | float4 neighborhood = SampleNeighborhood(uv, _Thickness); 83 | // Normal similarity is calculated using a dot product 84 | float normalSame = smoothstep(_Threshold.x, _Threshold.y, dot(center.xyz, neighborhood.xyz)); 85 | // Depth similarity is calculated using absolute difference 86 | float depthSame = smoothstep(_Threshold.w * center.w, _Threshold.z * center.w, abs(center.w - neighborhood.w)); 87 | // Combine normal and depth sameness to get edge factor 88 | float edge = 1 - normalSame * depthSame; 89 | 90 | color.rgb = lerp(color.rgb, _Color, edge * _Intensity); 91 | return color; 92 | } 93 | ENDHLSL 94 | 95 | SubShader 96 | { 97 | Cull Off ZWrite Off ZTest Always 98 | Pass 99 | { 100 | HLSLPROGRAM 101 | #pragma vertex Vert 102 | #pragma fragment Frag 103 | ENDHLSL 104 | } 105 | } 106 | Fallback Off 107 | } 108 | -------------------------------------------------------------------------------- /Resources/Shaders/EdgeDetection.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4d9cf4e2f8f7a494d8d8d78e4720d209 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Resources/Shaders/FakeHDR.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/PostProcessing/FakeHDR" 2 | { 3 | HLSLINCLUDE 4 | Texture2D _MainTex; 5 | SamplerState sampler_MainTex; 6 | float4 _MainTex_TexelSize; 7 | float _HDRPower; 8 | float _Radius1; 9 | float _Radius2; 10 | 11 | #include "Common.hlsl" 12 | 13 | float4 Frag(v2f i) : SV_Target 14 | { 15 | float3 color = _MainTex.Sample(sampler_MainTex, i.texcoord).rgb; 16 | 17 | float3 bloom_sum1 = _MainTex.Sample(sampler_MainTex, i.texcoord + float2(1.5, -1.5) * _Radius1 * _MainTex_TexelSize.xy).rgb; 18 | bloom_sum1 += _MainTex.Sample(sampler_MainTex, i.texcoord + float2(-1.5, -1.5) * _Radius1 * _MainTex_TexelSize.xy).rgb; 19 | bloom_sum1 += _MainTex.Sample(sampler_MainTex, i.texcoord + float2(1.5, 1.5) * _Radius1 * _MainTex_TexelSize.xy).rgb; 20 | bloom_sum1 += _MainTex.Sample(sampler_MainTex, i.texcoord + float2(-1.5, 1.5) * _Radius1 * _MainTex_TexelSize.xy).rgb; 21 | bloom_sum1 += _MainTex.Sample(sampler_MainTex, i.texcoord + float2(0.0, -2.5) * _Radius1 * _MainTex_TexelSize.xy).rgb; 22 | bloom_sum1 += _MainTex.Sample(sampler_MainTex, i.texcoord + float2(0.0, 2.5) * _Radius1 * _MainTex_TexelSize.xy).rgb; 23 | bloom_sum1 += _MainTex.Sample(sampler_MainTex, i.texcoord + float2(-2.5, 0.0) * _Radius1 * _MainTex_TexelSize.xy).rgb; 24 | bloom_sum1 += _MainTex.Sample(sampler_MainTex, i.texcoord + float2(2.5, 0.0) * _Radius1 * _MainTex_TexelSize.xy).rgb; 25 | bloom_sum1 *= 0.005; 26 | 27 | float3 bloom_sum2 = _MainTex.Sample(sampler_MainTex, i.texcoord + float2(1.5, -1.5) * _Radius2 * _MainTex_TexelSize.xy).rgb; 28 | bloom_sum2 += _MainTex.Sample(sampler_MainTex, i.texcoord + float2(-1.5, -1.5) * _Radius2 * _MainTex_TexelSize.xy).rgb; 29 | bloom_sum2 += _MainTex.Sample(sampler_MainTex, i.texcoord + float2(1.5, 1.5) * _Radius2 * _MainTex_TexelSize.xy).rgb; 30 | bloom_sum2 += _MainTex.Sample(sampler_MainTex, i.texcoord + float2(-1.5, 1.5) * _Radius2 * _MainTex_TexelSize.xy).rgb; 31 | bloom_sum2 += _MainTex.Sample(sampler_MainTex, i.texcoord + float2(0.0, -2.5) * _Radius2 * _MainTex_TexelSize.xy).rgb; 32 | bloom_sum2 += _MainTex.Sample(sampler_MainTex, i.texcoord + float2(0.0, 2.5) * _Radius2 * _MainTex_TexelSize.xy).rgb; 33 | bloom_sum2 += _MainTex.Sample(sampler_MainTex, i.texcoord + float2(-2.5, 0.0) * _Radius2 * _MainTex_TexelSize.xy).rgb; 34 | bloom_sum2 += _MainTex.Sample(sampler_MainTex, i.texcoord + float2(2.5, 0.0) * _Radius2 * _MainTex_TexelSize.xy).rgb; 35 | bloom_sum2 *= 0.010; 36 | 37 | float dist = _Radius2 - _Radius1; 38 | float3 hdr = (color + (bloom_sum2 - bloom_sum1)) * dist; 39 | float3 blend = hdr + color; 40 | color = pow(abs(blend), abs(_HDRPower)) + hdr; 41 | 42 | return float4(color, 1.0); 43 | } 44 | ENDHLSL 45 | 46 | SubShader 47 | { 48 | Cull Off ZWrite Off ZTest Always 49 | 50 | Pass 51 | { 52 | HLSLPROGRAM 53 | #pragma vertex Vert 54 | #pragma fragment Frag 55 | ENDHLSL 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Resources/Shaders/FakeHDR.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 803f6e3fbb998d64c860be4822981fca 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Resources/Shaders/Grayscale.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/PostProcessing/Grayscale" 2 | { 3 | HLSLINCLUDE 4 | Texture2D _MainTex; 5 | SamplerState sampler_MainTex; 6 | float _Blend; 7 | 8 | #include "Common.hlsl" 9 | 10 | float4 Frag(v2f i) : SV_Target 11 | { 12 | float4 color = _MainTex.Sample(sampler_MainTex, i.texcoord); 13 | float luminance = dot(color.rgb, float3(0.2126729, 0.7151522, 0.0721750)); 14 | color.rgb = lerp(color.rgb, luminance.xxx, _Blend.xxx); 15 | return color; 16 | } 17 | ENDHLSL 18 | 19 | SubShader 20 | { 21 | Cull Off ZWrite Off ZTest Always 22 | 23 | Pass 24 | { 25 | HLSLPROGRAM 26 | #pragma vertex Vert 27 | #pragma fragment Frag 28 | ENDHLSL 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /Resources/Shaders/Grayscale.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1200b110dc7a7cd4aa7f3f8849c30ae2 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Resources/Shaders/GrayscaleCS.compute: -------------------------------------------------------------------------------- 1 | #pragma kernel GrayscaleCS 2 | 3 | Texture2D _SourceTex; 4 | RWTexture2D _ResultTex; 5 | 6 | float _Blend; 7 | 8 | float3 LinearToSRGB(float3 c) 9 | { 10 | float3 sRGBLo = c * 12.92; 11 | float3 sRGBHi = (pow(abs(c), float3(1.0 / 2.4, 1.0 / 2.4, 1.0 / 2.4)) * 1.055) - 0.055; 12 | float3 sRGB = (c <= 0.0031308) ? sRGBLo : sRGBHi; 13 | return sRGB; 14 | } 15 | 16 | [numthreads(8, 8, 1)] 17 | void GrayscaleCS(uint3 id : SV_DispatchThreadID) 18 | { 19 | float4 color = _SourceTex[id.xy]; 20 | float luminance = dot(color.rgb, float3(0.2126729, 0.7151522, 0.0721750)); 21 | color.rgb = LinearToSRGB(lerp(color.rgb, luminance.xxx, _Blend.xxx)); 22 | _ResultTex[id.xy] = color; 23 | } -------------------------------------------------------------------------------- /Resources/Shaders/GrayscaleCS.compute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d3c98846476eaf8449ca516e65d2a746 3 | ComputeShaderImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Resources/Shaders/OilPaint.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/PostProcessing/OilPaint" 2 | { 3 | HLSLINCLUDE 4 | Texture2D _MainTex; 5 | SamplerState sampler_MainTex; 6 | float4 _MainTex_TexelSize; 7 | 8 | float _Radius; 9 | 10 | #include "Common.hlsl" 11 | 12 | float4 Frag(v2f i) : SV_Target 13 | { 14 | float2 texcoord = i.texcoord; 15 | float3 mean[4] = { 16 | { 0, 0, 0 }, 17 | { 0, 0, 0 }, 18 | { 0, 0, 0 }, 19 | { 0, 0, 0 } 20 | }; 21 | 22 | float3 sigma[4] = { 23 | { 0, 0, 0 }, 24 | { 0, 0, 0 }, 25 | { 0, 0, 0 }, 26 | { 0, 0, 0 } 27 | }; 28 | 29 | float2 start[4] = { { -_Radius, -_Radius },{ -_Radius, 0 },{ 0, -_Radius },{ 0, 0 } }; 30 | 31 | [unroll] 32 | for (int k = 0; k < 4; k++) { 33 | for (int i = 0; i <= _Radius; i++) { 34 | for (int j = 0; j <= _Radius; j++) { 35 | float2 pos = float2(i, j) + start[k]; 36 | float3 col = _MainTex.Sample(sampler_MainTex, texcoord + float2(pos.x * _MainTex_TexelSize.x, pos.y * _MainTex_TexelSize.y)).rgb; 37 | mean[k] += col; 38 | sigma[k] += col * col; 39 | } 40 | } 41 | } 42 | 43 | float sigma2; 44 | 45 | float n = pow(_Radius + 1, 2); 46 | float4 color = _MainTex.Sample(sampler_MainTex, i.texcoord); 47 | float min = 1; 48 | 49 | for (int l = 0; l < 4; l++) { 50 | mean[l] /= n; 51 | sigma[l] = abs(sigma[l] / n - mean[l] * mean[l]); 52 | sigma2 = sigma[l].r + sigma[l].g + sigma[l].b; 53 | 54 | if (sigma2 < min) { 55 | min = sigma2; 56 | color.rgb = mean[l].rgb; 57 | } 58 | } 59 | return color; 60 | } 61 | ENDHLSL 62 | 63 | SubShader 64 | { 65 | Cull Off ZWrite Off ZTest Always 66 | 67 | Pass 68 | { 69 | HLSLPROGRAM 70 | #pragma vertex Vert 71 | #pragma fragment Frag 72 | ENDHLSL 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /Resources/Shaders/OilPaint.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7163261b593e77f4298e0fc1c3abeebe 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Resources/Shaders/Pencil.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/PostProcessing/Pencil" 2 | { 3 | HLSLINCLUDE 4 | Texture2D _MainTex; 5 | SamplerState sampler_MainTex; 6 | float4 _MainTex_TexelSize; 7 | 8 | float _GradThreshold; 9 | float _ColorThreshold; 10 | float _Sensivity; 11 | 12 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" 13 | 14 | struct appdata 15 | { 16 | float4 vertex : POSITION; 17 | float2 uv : TEXCOORD0; 18 | }; 19 | 20 | struct v2f { 21 | float4 pos : SV_POSITION; 22 | float4 screenuv : TEXCOORD0; 23 | }; 24 | 25 | v2f Vert(appdata v) 26 | { 27 | v2f o; 28 | o.pos = mul(UNITY_MATRIX_VP, mul(unity_ObjectToWorld, v.vertex)); 29 | o.screenuv = ComputeScreenPos(o.pos); 30 | return o; 31 | } 32 | 33 | #define PI2 6.28318530717959 34 | #define RANGE 16 35 | #define STEP 2 36 | #define ANGLENUM 4 37 | #define GRADTHRESH 0.01 38 | 39 | float4 getCol(float2 pos) 40 | { 41 | return _MainTex.Sample(sampler_MainTex, pos / _ScreenParams.xy); 42 | } 43 | 44 | float getVal(float2 pos) 45 | { 46 | float4 c = getCol(pos); 47 | return dot(c.xyz, float3(0.2126, 0.7152, 0.0722)); 48 | } 49 | 50 | float2 getGrad(float2 pos, float delta) 51 | { 52 | float2 d = float2(delta, 0.0); 53 | return float2(getVal(pos + d.xy) - getVal(pos - d.xy), 54 | getVal(pos + d.yx) - getVal(pos - d.yx)) / delta / 2.0; 55 | } 56 | 57 | void pR(inout float2 p, float a) { 58 | p = cos(a) * p + sin(a) * float2(p.y, -p.x); 59 | } 60 | 61 | float4 Frag(v2f i) : SV_Target 62 | { 63 | float2 screenuv = i.screenuv.xy / i.screenuv.w; 64 | float2 screenPos = float2(i.screenuv.x * _ScreenParams.x, i.screenuv.y * _ScreenParams.y); 65 | float weight = 1.0; 66 | 67 | [unroll] 68 | for (int j = 0; j < ANGLENUM; j++) 69 | { 70 | float2 dir = float2(1.0, 0.0); 71 | pR(dir, j * PI2 / (2.0 * ANGLENUM)); 72 | 73 | float2 grad = float2(-dir.y, dir.x); 74 | 75 | [unroll] 76 | for (int i = -RANGE; i <= RANGE; i += STEP) 77 | { 78 | float2 b = normalize(dir); 79 | float2 pos2 = screenPos + float2(b.x, b.y) * i; 80 | 81 | if (pos2.y < 0.0 || pos2.x < 0.0 || pos2.x > _ScreenParams.x || pos2.y > _ScreenParams.y) 82 | continue; 83 | 84 | float2 g = getGrad(pos2, 1.0); 85 | 86 | if (sqrt(dot(g,g)) < _GradThreshold) 87 | continue; 88 | 89 | weight -= pow(abs(dot(normalize(grad), normalize(g))), _Sensivity) / floor((2.0 * RANGE + 1.0) / STEP) / ANGLENUM; 90 | } 91 | } 92 | 93 | float4 col = getCol(screenPos); 94 | float4 background = lerp(col, float4(1.0, 1.0, 1.0, 1.0), _ColorThreshold); 95 | 96 | return lerp(float4(0.0, 0.0, 0.0, 0.0), background, weight); 97 | } 98 | 99 | ENDHLSL 100 | 101 | SubShader 102 | { 103 | Cull Off ZWrite Off ZTest Always 104 | 105 | Pass 106 | { 107 | HLSLPROGRAM 108 | #pragma vertex Vert 109 | #pragma fragment Frag 110 | ENDHLSL 111 | } 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /Resources/Shaders/Pencil.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a4828e75aaacfac42b4ba57bb2b0614d 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Resources/Shaders/RadialBlur.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/PostProcessing/RadialBlur" 2 | { 3 | HLSLINCLUDE 4 | Texture2D _MainTex; 5 | SamplerState sampler_MainTex; 6 | 7 | float _BlurRadius; 8 | float _Iteration; 9 | float _RadialCenterX; 10 | float _RadialCenterY; 11 | 12 | #include "Common.hlsl" 13 | 14 | float4 Frag(v2f i) : SV_Target 15 | { 16 | float2 center = float2(_RadialCenterX, _RadialCenterY); 17 | float2 blurVector = (center - i.texcoord.xy) * _BlurRadius; 18 | float4 stackedColor = float4(0, 0, 0, 0); 19 | 20 | [unroll(30)] 21 | for (int c = 0; c < _Iteration; c++) 22 | { 23 | stackedColor += _MainTex.Sample(sampler_MainTex, i.texcoord); 24 | i.texcoord.xy += blurVector; 25 | } 26 | 27 | return stackedColor / _Iteration; 28 | } 29 | ENDHLSL 30 | 31 | SubShader 32 | { 33 | Cull Off ZWrite Off ZTest Always 34 | 35 | Pass 36 | { 37 | HLSLPROGRAM 38 | #pragma vertex Vert 39 | #pragma fragment Frag 40 | ENDHLSL 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /Resources/Shaders/RadialBlur.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1676d22a138d08244be7bb0c88a11c60 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Resources/Shaders/Streak.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/PostProcessing/Streak" 2 | { 3 | HLSLINCLUDE 4 | Texture2D _MainTex; 5 | SamplerState sampler_MainTex; 6 | Texture2D _HighTex; 7 | SamplerState sampler_HighTex; 8 | 9 | float4 _MainTex_TexelSize; 10 | float _Threshold; 11 | float _Stretch; 12 | float _Intensity; 13 | half3 _Color; 14 | 15 | #include "Common.hlsl" 16 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" 17 | 18 | // Prefilter: Shrink horizontally and apply threshold. 19 | half4 FragPrefilter(v2f i) : SV_Target 20 | { 21 | // Actually this should be 1, but we assume you need more blur... 22 | const float vscale = 1.5; 23 | const float dy = _MainTex_TexelSize.y * vscale / 2; 24 | 25 | float2 uv = i.texcoord; 26 | half3 c0 = _MainTex.Sample(sampler_MainTex, float2(uv.x, uv.y - dy)).rgb; 27 | half3 c1 = _MainTex.Sample(sampler_MainTex, float2(uv.x, uv.y + dy)).rgb; 28 | half3 c = (c0 + c1) / 2; 29 | 30 | float br = max(c.r, max(c.g, c.b)); 31 | c *= max(0, br - _Threshold) / max(br, 1e-5); 32 | 33 | return half4(c, 1); 34 | } 35 | 36 | // Downsampler 37 | half4 FragDownsample(v2f i) : SV_Target 38 | { 39 | // Actually this should be 1, but we assume you need more blur... 40 | const float hscale = 1.25; 41 | const float dx = _MainTex_TexelSize.x * hscale; 42 | 43 | float2 uv = i.texcoord; 44 | float u0 = uv.x - dx * 5; 45 | float u1 = uv.x - dx * 3; 46 | float u2 = uv.x - dx * 1; 47 | float u3 = uv.x + dx * 1; 48 | float u4 = uv.x + dx * 3; 49 | float u5 = uv.x + dx * 5; 50 | 51 | half3 c0 = _MainTex.Sample(sampler_MainTex, float2(u0, uv.y)).rgb; 52 | half3 c1 = _MainTex.Sample(sampler_MainTex, float2(u1, uv.y)).rgb; 53 | half3 c2 = _MainTex.Sample(sampler_MainTex, float2(u2, uv.y)).rgb; 54 | half3 c3 = _MainTex.Sample(sampler_MainTex, float2(u3, uv.y)).rgb; 55 | half3 c4 = _MainTex.Sample(sampler_MainTex, float2(u4, uv.y)).rgb; 56 | half3 c5 = _MainTex.Sample(sampler_MainTex, float2(u5, uv.y)).rgb; 57 | 58 | // Simple box filter 59 | half3 c = (c0 + c1 + c2 + c3 + c4 + c5) / 6; 60 | 61 | return half4(c, 1); 62 | } 63 | 64 | // Upsampler 65 | half4 FragUpsample(v2f i) : SV_Target 66 | { 67 | half3 c0 = _MainTex.Sample(sampler_MainTex, i.texcoord).rgb / 4; 68 | half3 c1 = _MainTex.Sample(sampler_MainTex, i.texcoord).rgb / 2; 69 | half3 c2 = _MainTex.Sample(sampler_MainTex, i.texcoord).rgb / 4; 70 | half3 c3 = _HighTex.Sample(sampler_HighTex, i.texcoord).rgb; 71 | return half4(lerp(c3, c0 + c1 + c2, _Stretch), 1); 72 | } 73 | 74 | // Final composition 75 | half4 FragComposition(v2f i) : SV_Target 76 | { 77 | half3 c0 = _MainTex.Sample(sampler_MainTex, i.texcoord).rgb / 4; 78 | half3 c1 = _MainTex.Sample(sampler_MainTex, i.texcoord).rgb / 2; 79 | half3 c2 = _MainTex.Sample(sampler_MainTex, i.texcoord).rgb / 4; 80 | half3 c3 = _HighTex.Sample(sampler_HighTex, i.texcoord).rgb; 81 | half3 cf = (c0 + c1 + c2) * _Color * _Intensity * 5; 82 | return half4(cf + c3, 1); 83 | } 84 | 85 | ENDHLSL 86 | 87 | SubShader 88 | { 89 | Cull Off ZWrite Off ZTest Always 90 | Pass 91 | { 92 | HLSLPROGRAM 93 | #pragma vertex Vert 94 | #pragma fragment FragPrefilter 95 | ENDHLSL 96 | } 97 | Pass 98 | { 99 | HLSLPROGRAM 100 | #pragma vertex Vert 101 | #pragma fragment FragDownsample 102 | ENDHLSL 103 | } 104 | Pass 105 | { 106 | HLSLPROGRAM 107 | #pragma vertex Vert 108 | #pragma fragment FragUpsample 109 | ENDHLSL 110 | } 111 | Pass 112 | { 113 | HLSLPROGRAM 114 | #pragma vertex Vert 115 | #pragma fragment FragComposition 116 | ENDHLSL 117 | } 118 | } 119 | } -------------------------------------------------------------------------------- /Resources/Shaders/Streak.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d01cba3928409084d98519e8287946fd 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Resources/Shaders/WaterColor.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/PostProcessing/WaterColor" 2 | { 3 | HLSLINCLUDE 4 | Texture2D _MainTex; 5 | SamplerState sampler_MainTex; 6 | Texture2D _NoiseTex; 7 | SamplerState sampler_NoiseTex; 8 | float4 _EffectParams; 9 | float _Interval; 10 | int _Iteration; 11 | 12 | float4 _EdgeColor; 13 | float4 _FillColor; 14 | 15 | float edgeContrast; 16 | float blurWidth; 17 | float blurFrequency; 18 | float hueShift; 19 | float iterationRcp; 20 | 21 | #include "Common.hlsl" 22 | #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl" 23 | 24 | float2 Rotate90(float2 v) 25 | { 26 | return v.yx * float2(-1, 1); 27 | } 28 | 29 | // Texture sampling functions 30 | float3 SampleColor(float2 p) 31 | { 32 | return _MainTex.Sample(sampler_MainTex, p).rgb; 33 | } 34 | 35 | float SampleLuminance(float2 p) 36 | { 37 | return Luminance(SampleColor(p)); 38 | } 39 | 40 | float3 SampleNoise(float2 p) 41 | { 42 | return _NoiseTex.Sample(sampler_NoiseTex, p).rgb; 43 | } 44 | 45 | float2 GetGradient(float2 p, float freq) 46 | { 47 | const float2 dx = float2(_Interval / 200, 0); 48 | float ldx = SampleLuminance(p + dx.xy) - SampleLuminance(p - dx.xy); 49 | float ldy = SampleLuminance(p + dx.yx) - SampleLuminance(p - dx.yx); 50 | float2 n = SampleNoise(p * 0.4 * freq).gb - 0.5; 51 | return float2(ldx, ldy) + n * 0.05; 52 | } 53 | 54 | // Edge / fill processing functions 55 | float ProcessEdge(inout float2 p, float stride) 56 | { 57 | float2 grad = GetGradient(p, 1); 58 | float edge = saturate(length(grad) * 10); 59 | float pattern = SampleNoise(p * 0.8).r; 60 | p += normalize(Rotate90(grad)) * stride; 61 | return pattern * edge; 62 | } 63 | 64 | float3 ProcessFill(inout float2 p, float stride) 65 | { 66 | float2 grad = GetGradient(p, blurFrequency); 67 | p += normalize(grad) * stride; 68 | float shift = SampleNoise(p * 0.1).r * 2; 69 | return SampleColor(p) * HsvToRgb(float3(shift, hueShift, 1)); 70 | } 71 | 72 | float3 Process(float2 uv) 73 | { 74 | float2 p_e_n = uv; 75 | float2 p_e_p = uv; 76 | float2 p_c_n = uv; 77 | float2 p_c_p = uv; 78 | 79 | const float Stride = 0.04 * iterationRcp; 80 | 81 | float acc_e = 0; 82 | float3 acc_c = 0; 83 | float sum_e = 0; 84 | float sum_c = 0; 85 | 86 | for (int i = 0; i < _Iteration; i++) 87 | { 88 | float w_e = 1.5 - i * iterationRcp; 89 | acc_e += ProcessEdge(p_e_n, -Stride) * w_e; 90 | acc_e += ProcessEdge(p_e_p, +Stride) * w_e; 91 | sum_e += w_e * 2; 92 | 93 | float w_c = 0.2 + i * iterationRcp; 94 | acc_c += ProcessFill(p_c_n, -Stride * blurWidth) * w_c; 95 | acc_c += ProcessFill(p_c_p, +Stride * blurWidth) * w_c * 0.3; 96 | sum_c += w_c * 1.3; 97 | } 98 | 99 | // Normalization and contrast 100 | acc_e /= sum_e; 101 | acc_c /= sum_c; 102 | acc_e = saturate((acc_e - 0.5) * edgeContrast + 0.5); 103 | 104 | // Color blending 105 | float3 rgb_e = lerp(1, _EdgeColor.rgb, _EdgeColor.a * acc_e); 106 | float3 rgb_f = lerp(1, acc_c, _FillColor.a) * _FillColor.rgb; 107 | 108 | return rgb_e * rgb_f; 109 | } 110 | 111 | float4 Frag(v2f i) : SV_Target 112 | { 113 | edgeContrast = _EffectParams.x; 114 | blurWidth = _EffectParams.y; 115 | blurFrequency = _EffectParams.z; 116 | hueShift = _EffectParams.w; 117 | iterationRcp = 1.0 / _Iteration; 118 | 119 | return float4(Process(i.texcoord), 1); 120 | } 121 | ENDHLSL 122 | 123 | SubShader 124 | { 125 | Cull Off ZWrite Off ZTest Always 126 | 127 | Pass 128 | { 129 | HLSLPROGRAM 130 | #pragma vertex Vert 131 | #pragma fragment Frag 132 | ENDHLSL 133 | } 134 | } 135 | } -------------------------------------------------------------------------------- /Resources/Shaders/WaterColor.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 06b9dc87fb15f9e4bb29969f15abe85a 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Resources/Textures.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 57873c3d8e660cb4ba4d51e0141825e0 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Resources/Textures/WaterColorNoise.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/8izips/PostProcessingURP/d1b8f87be7d9e6bddd4c5aabcfe63d646118f75e/Resources/Textures/WaterColorNoise.png -------------------------------------------------------------------------------- /Resources/Textures/WaterColorNoise.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 38433da6fd65d7c45aa018c0d9f3f264 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 11 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | sRGBTexture: 0 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | flipGreenChannel: 0 24 | isReadable: 0 25 | streamingMipmaps: 0 26 | streamingMipmapsPriority: 0 27 | vTOnly: 0 28 | ignoreMasterTextureLimit: 0 29 | grayScaleToAlpha: 0 30 | generateCubemap: 6 31 | cubemapConvolution: 0 32 | seamlessCubemap: 0 33 | textureFormat: 1 34 | maxTextureSize: 2048 35 | textureSettings: 36 | serializedVersion: 2 37 | filterMode: 1 38 | aniso: 1 39 | mipBias: 0 40 | wrapU: 0 41 | wrapV: 0 42 | wrapW: 0 43 | nPOTScale: 1 44 | lightmap: 0 45 | compressionQuality: 50 46 | spriteMode: 0 47 | spriteExtrude: 1 48 | spriteMeshType: 1 49 | alignment: 0 50 | spritePivot: {x: 0.5, y: 0.5} 51 | spritePixelsToUnits: 100 52 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 53 | spriteGenerateFallbackPhysicsShape: 1 54 | alphaUsage: 1 55 | alphaIsTransparency: 0 56 | spriteTessellationDetail: -1 57 | textureType: 0 58 | textureShape: 1 59 | singleChannelComponent: 0 60 | flipbookRows: 1 61 | flipbookColumns: 1 62 | maxTextureSizeSet: 0 63 | compressionQualitySet: 0 64 | textureFormatSet: 0 65 | ignorePngGamma: 0 66 | applyGammaDecoding: 0 67 | swizzle: 50462976 68 | platformSettings: 69 | - serializedVersion: 3 70 | buildTarget: DefaultTexturePlatform 71 | maxTextureSize: 2048 72 | resizeAlgorithm: 0 73 | textureFormat: -1 74 | textureCompression: 1 75 | compressionQuality: 50 76 | crunchedCompression: 0 77 | allowsAlphaSplitting: 0 78 | overridden: 0 79 | androidETC2FallbackOverride: 0 80 | forceMaximumCompressionQuality_BC6H_BC7: 0 81 | - serializedVersion: 3 82 | buildTarget: Standalone 83 | maxTextureSize: 2048 84 | resizeAlgorithm: 0 85 | textureFormat: -1 86 | textureCompression: 1 87 | compressionQuality: 50 88 | crunchedCompression: 0 89 | allowsAlphaSplitting: 0 90 | overridden: 0 91 | androidETC2FallbackOverride: 0 92 | forceMaximumCompressionQuality_BC6H_BC7: 0 93 | - serializedVersion: 3 94 | buildTarget: Server 95 | maxTextureSize: 2048 96 | resizeAlgorithm: 0 97 | textureFormat: -1 98 | textureCompression: 1 99 | compressionQuality: 50 100 | crunchedCompression: 0 101 | allowsAlphaSplitting: 0 102 | overridden: 0 103 | androidETC2FallbackOverride: 0 104 | forceMaximumCompressionQuality_BC6H_BC7: 0 105 | spriteSheet: 106 | serializedVersion: 2 107 | sprites: [] 108 | outline: [] 109 | physicsShape: [] 110 | bones: [] 111 | spriteID: 112 | internalID: 0 113 | vertices: [] 114 | indices: 115 | edges: [] 116 | weights: [] 117 | secondaryTextures: [] 118 | nameFileIdTable: {} 119 | spritePackingTag: 120 | pSDRemoveMatte: 0 121 | userData: 122 | assetBundleName: 123 | assetBundleVariant: 124 | --------------------------------------------------------------------------------