├── .gitattributes ├── .github └── FUNDING.yml ├── .gitignore ├── Assets ├── ASCI │ ├── ASCII.compute │ ├── ASCII.compute.meta │ ├── ASCII.shader │ ├── ASCII.shader.meta │ ├── ASCIIPass.cs │ ├── ASCIIPass.cs.meta │ ├── ASCIIRenderFeature.cs │ ├── ASCIIRenderFeature.cs.meta │ ├── ASCIIVolume.cs │ ├── ASCIIVolume.cs.meta │ ├── LUTs.meta │ └── LUTs │ │ ├── 1x0 8x8 2.png │ │ ├── 1x0 8x8 2.png.meta │ │ ├── 1x0 8x8 3.png │ │ ├── 1x0 8x8 3.png.meta │ │ ├── 1x0 8x8.png │ │ ├── 1x0 8x8.png.meta │ │ ├── 1x10 2.png │ │ ├── 1x10 2.png.meta │ │ ├── 1x10.png │ │ ├── 1x10.png.meta │ │ ├── edges 8x40.png │ │ └── edges 8x40.png.meta ├── BlendModes │ ├── BlendMode.shader │ ├── BlendMode.shader.meta │ ├── BlendModePass.cs │ ├── BlendModePass.cs.meta │ ├── BlendModeRenderFeature.cs │ ├── BlendModeRenderFeature.cs.meta │ ├── BlendModeVolume.cs │ └── BlendModeVolume.cs.meta ├── Bloom │ ├── BloomAcerolaPass.cs │ ├── BloomAcerolaPass.cs.meta │ ├── BloomAcerolaRenderFeature.cs │ ├── BloomAcerolaRenderFeature.cs.meta │ ├── BloomAcerolaVolume.cs │ ├── BloomAcerolaVolume.cs.meta │ ├── Bloom_AceRola.shader │ └── Bloom_AceRola.shader.meta ├── Blur │ ├── Blur.shader │ ├── Blur.shader.meta │ ├── BlurPass.cs │ ├── BlurPass.cs.meta │ ├── BlurRenderFeature.cs │ ├── BlurRenderFeature.cs.meta │ ├── BlurVolume.cs │ └── BlurVolume.cs.meta ├── ChromaticAboration │ ├── ChromaticAberration.shader │ ├── ChromaticAberration.shader.meta │ ├── ChromaticAboPass.cs │ ├── ChromaticAboPass.cs.meta │ ├── ChromaticAboRendererFeature.cs │ ├── ChromaticAboRendererFeature.cs.meta │ ├── ChromaticAboVolume.cs │ └── ChromaticAboVolume.cs.meta ├── Color Blindness │ ├── Color Blindness.shader │ ├── Color Blindness.shader.meta │ ├── ColorBlindnessPass.cs │ ├── ColorBlindnessPass.cs.meta │ ├── ColorBlindnessRenderFeature.cs │ ├── ColorBlindnessRenderFeature.cs.meta │ ├── ColorBlindnessVolume.cs │ ├── ColorBlindnessVolume.cs.meta │ ├── Deuteranomaly.cginc │ ├── Deuteranomaly.cginc.meta │ ├── Protanomaly.cginc │ ├── Protanomaly.cginc.meta │ ├── Tritanomaly.cginc │ └── Tritanomaly.cginc.meta ├── Color Correct │ ├── Color Correct.shader │ ├── Color Correct.shader.meta │ ├── ColorCorrectPass.cs │ ├── ColorCorrectPass.cs.meta │ ├── ColorCorrectRenderFeature.cs │ ├── ColorCorrectRenderFeature.cs.meta │ ├── ColorCorrectVolume.cs │ ├── ColorCorrectVolume.cs.meta │ ├── Gamma.shader │ ├── Gamma.shader.meta │ ├── GammaPass.cs │ ├── GammaPass.cs.meta │ ├── GammaRenderFeature.cs │ ├── GammaRenderFeature.cs.meta │ ├── GammaVolume.cs │ ├── GammaVolume.cs.meta │ ├── Hue Shift.shader │ ├── Hue Shift.shader.meta │ ├── HueShiftPass.cs │ ├── HueShiftPass.cs.meta │ ├── HueShiftRenderFeature.cs │ ├── HueShiftRenderFeature.cs.meta │ ├── HueShiftVolume.cs │ └── HueShiftVolume.cs.meta ├── Difference Of Gaussian │ ├── DifferenceOfGaussians.shader │ ├── DifferenceOfGaussians.shader.meta │ ├── DifferenceOfGaussiansPass.cs │ ├── DifferenceOfGaussiansPass.cs.meta │ ├── DifferenceOfGaussiansRenderFeature.cs │ ├── DifferenceOfGaussiansRenderFeature.cs.meta │ ├── DifferenceOfGaussiansVolume.cs │ ├── DifferenceOfGaussiansVolume.cs.meta │ ├── ExtendedDOG.shader │ ├── ExtendedDOG.shader.meta │ ├── ExtendedDOGPass.cs │ ├── ExtendedDOGPass.cs.meta │ ├── ExtendedDOGRenderFeature.cs │ ├── ExtendedDOGRenderFeature.cs.meta │ ├── ExtendedDOGVolume.cs │ └── ExtendedDOGVolume.cs.meta ├── Dithering │ ├── Dithering.shader │ ├── Dithering.shader.meta │ ├── DitheringPass.cs │ ├── DitheringPass.cs.meta │ ├── DitheringRendererFeature.cs │ ├── DitheringRendererFeature.cs.meta │ ├── DitheringVolume.cs │ └── DitheringVolume.cs.meta ├── Fog │ ├── Fog.shader │ ├── Fog.shader.meta │ ├── FogPass.cs │ ├── FogPass.cs.meta │ ├── FogRenderFeature.cs │ ├── FogRenderFeature.cs.meta │ ├── FogVolume.cs │ ├── FogVolume.cs.meta │ └── GradientFog.meta ├── Halftone │ ├── Halftone.shader │ ├── Halftone.shader.meta │ ├── HalftonePass.cs │ ├── HalftonePass.cs.meta │ ├── HalftoneRenderFeature.cs │ ├── HalftoneRenderFeature.cs.meta │ ├── HalftoneVolume.cs │ └── HalftoneVolume.cs.meta ├── Kuwahara │ ├── AnisotropicKuwahara.shader │ ├── AnisotropicKuwahara.shader.meta │ ├── AnisotropicKuwaharaPass.cs │ ├── AnisotropicKuwaharaPass.cs.meta │ ├── AnisotropicKuwaharaRendererFeature.cs │ ├── AnisotropicKuwaharaRendererFeature.cs.meta │ ├── AnisotropicKuwaharaVolume.cs │ ├── AnisotropicKuwaharaVolume.cs.meta │ ├── GeneralizedKuwahara.shader │ ├── GeneralizedKuwahara.shader.meta │ ├── GeneralizedKuwaharaPass.cs │ ├── GeneralizedKuwaharaPass.cs.meta │ ├── GeneralizedKuwaharaRenderFeature.cs │ ├── GeneralizedKuwaharaRenderFeature.cs.meta │ ├── GeneralizedKuwaharaVolume.cs │ ├── GeneralizedKuwaharaVolume.cs.meta │ ├── HybridKuwa.meta │ ├── Kuwahara.shader │ ├── Kuwahara.shader.meta │ ├── KuwaharaPass.cs │ ├── KuwaharaPass.cs.meta │ ├── KuwaharaRenderFeature.cs │ ├── KuwaharaRenderFeature.cs.meta │ ├── KuwaharaVolume.cs │ └── KuwaharaVolume.cs.meta ├── Lens Flare │ ├── Acerola.meta │ └── Acerola │ │ ├── Lens Flare.shader │ │ ├── Lens Flare.shader.meta │ │ ├── LensFlarePass.cs │ │ ├── LensFlarePass.cs.meta │ │ ├── LensFlareRenderFeature.cs │ │ ├── LensFlareRenderFeature.cs.meta │ │ ├── LensFlareVolume.cs │ │ ├── LensFlareVolume.cs.meta │ │ ├── Note.txt │ │ └── Note.txt.meta ├── Outlines │ ├── EdgeDetect.shader │ ├── EdgeDetect.shader.meta │ ├── EdgeDetectPass.cs │ ├── EdgeDetectPass.cs.meta │ ├── EdgeDetectRenderFeature.cs │ ├── EdgeDetectRenderFeature.cs.meta │ ├── EdgeDetectVolume.cs │ └── EdgeDetectVolume.cs.meta ├── Pixel Art │ ├── PaletteSwapper.shader │ ├── PaletteSwapper.shader.meta │ ├── PaletteSwapperPass.cs │ ├── PaletteSwapperPass.cs.meta │ ├── PaletteSwapperRenderFeature.cs │ ├── PaletteSwapperRenderFeature.cs.meta │ ├── PaletteSwapperVolume.cs │ ├── PaletteSwapperVolume.cs.meta │ ├── PixelArtFilter.shader │ ├── PixelArtFilter.shader.meta │ ├── PixelArtPass.cs │ ├── PixelArtPass.cs.meta │ ├── PixelArtRenderFeature.cs │ ├── PixelArtRenderFeature.cs.meta │ ├── PixelArtVolume.cs │ └── PixelArtVolume.cs.meta ├── Sharpness │ ├── ContrastAdaptiveSharpness.shader │ ├── ContrastAdaptiveSharpness.shader.meta │ ├── Sharpness.shader │ ├── Sharpness.shader.meta │ ├── SharpnessPass.cs │ ├── SharpnessPass.cs.meta │ ├── SharpnessRenderFeature.cs │ ├── SharpnessRenderFeature.cs.meta │ ├── SharpnessVolume.cs │ └── SharpnessVolume.cs.meta ├── ToneMap │ ├── TonemapPass.cs │ ├── TonemapPass.cs.meta │ ├── TonemapRenderFeature.cs │ ├── TonemapRenderFeature.cs.meta │ ├── TonemapVolume.cs │ ├── TonemapVolume.cs.meta │ ├── Tonemapping.shader │ └── Tonemapping.shader.meta ├── Vignette │ ├── Vignette.shader │ ├── Vignette.shader.meta │ ├── VignettePass.cs │ ├── VignettePass.cs.meta │ ├── VignetteRenderFeature.cs │ ├── VignetteRenderFeature.cs.meta │ ├── VignetteVolume.cs │ └── VignetteVolume.cs.meta └── Zoom │ ├── Zoom.shader │ ├── Zoom.shader.meta │ ├── ZoomPass.cs │ ├── ZoomPass.cs.meta │ ├── ZoomRenderFeature.cs │ ├── ZoomRenderFeature.cs.meta │ ├── ZoomVolume.cs │ └── ZoomVolume.cs.meta ├── LICENSE └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: Josephy5 # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 12 | polar: # Replace with a single Polar username 13 | buy_me_a_coffee: # Replace with a single Buy Me a Coffee username 14 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # This .gitignore file should be placed at the root of your Unity project directory 2 | # 3 | # Get latest from https://github.com/github/gitignore/blob/main/Unity.gitignore 4 | # 5 | /[Ll]ibrary/ 6 | /[Tt]emp/ 7 | /[Oo]bj/ 8 | /[Bb]uild/ 9 | /[Bb]uilds/ 10 | /[Ll]ogs/ 11 | /[Uu]ser[Ss]ettings/ 12 | 13 | # MemoryCaptures can get excessive in size. 14 | # They also could contain extremely sensitive data 15 | /[Mm]emoryCaptures/ 16 | 17 | # Recordings can get excessive in size 18 | /[Rr]ecordings/ 19 | 20 | # Uncomment this line if you wish to ignore the asset store tools plugin 21 | # /[Aa]ssets/AssetStoreTools* 22 | 23 | # Autogenerated Jetbrains Rider plugin 24 | /[Aa]ssets/Plugins/Editor/JetBrains* 25 | 26 | # Visual Studio cache directory 27 | .vs/ 28 | 29 | # Gradle cache directory 30 | .gradle/ 31 | 32 | # Autogenerated VS/MD/Consulo solution and project files 33 | ExportedObj/ 34 | .consulo/ 35 | *.csproj 36 | *.unityproj 37 | *.sln 38 | *.suo 39 | *.tmp 40 | *.user 41 | *.userprefs 42 | *.pidb 43 | *.booproj 44 | *.svd 45 | *.pdb 46 | *.mdb 47 | *.opendb 48 | *.VC.db 49 | 50 | # Unity3D generated meta files 51 | *.pidb.meta 52 | *.pdb.meta 53 | *.mdb.meta 54 | 55 | # Unity3D generated file on crash reports 56 | sysinfo.txt 57 | 58 | # Builds 59 | *.apk 60 | *.aab 61 | *.unitypackage 62 | *.app 63 | 64 | # Crashlytics generated file 65 | crashlytics-build.properties 66 | 67 | # Packed Addressables 68 | /[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin* 69 | 70 | # Temporary auto-generated Android Assets 71 | /[Aa]ssets/[Ss]treamingAssets/aa.meta 72 | /[Aa]ssets/[Ss]treamingAssets/aa/* 73 | -------------------------------------------------------------------------------- /Assets/ASCI/ASCII.compute: -------------------------------------------------------------------------------- 1 | #pragma kernel CS_DrawEdges 2 | 3 | #define PI 3.14159265358979323846f 4 | 5 | Texture2D _SobelTex, _EdgeAsciiTex, _AsciiTex, _LuminanceTex; 6 | RWTexture2D _Result; 7 | SamplerState point_clamp_sampler; 8 | 9 | uint _ViewUncompressed, _DebugEdges, _Grid, _EdgeThreshold, _NoEdges, _NoFill; 10 | float _Exposure, _Attenuation; 11 | 12 | 13 | groupshared int edgeCount[64]; 14 | 15 | [numthreads(8,8,1)] 16 | void CS_DrawEdges(uint3 id : SV_DISPATCHTHREADID, uint3 gid : SV_GROUPTHREADID) { 17 | // Initialize groupshared memory 18 | edgeCount[gid.x + gid.y * 8] = 0; 19 | 20 | float3 sobel = _SobelTex[id.xy].xyz; 21 | 22 | float theta = sobel.y; 23 | 24 | float absTheta = abs(theta) / PI; 25 | 26 | int direction = -1; 27 | 28 | // Check nan mask first 29 | if (any(sobel.z)) { 30 | // Quantize angle to edge direction 31 | if ((0.0f <= absTheta) && (absTheta < 0.05f)) direction = 0; // VERTICAL 32 | else if ((0.9f < absTheta) && (absTheta <= 1.0f)) direction = 0; 33 | else if ((0.45f < absTheta) && (absTheta < 0.55f)) direction = 1; // HORIZONTAL 34 | else if (0.05f < absTheta && absTheta < 0.45f) direction = sign(theta) > 0 ? 2 : 3; // DIAGONAL 1 35 | else if (0.55f < absTheta && absTheta < 0.9f) direction = sign(theta) > 0 ? 3 : 2; // DIAGONAL 2 36 | } 37 | 38 | // Set group thread bucket to direction 39 | edgeCount[gid.x + gid.y * 8] = direction; 40 | 41 | GroupMemoryBarrierWithGroupSync(); 42 | 43 | int commonEdgeIndex = -1; 44 | if ((gid.x == 0) && (gid.y == 0)) { 45 | uint buckets[4] = {0, 0, 0, 0}; 46 | 47 | // Count up directions in tile 48 | for (int i = 0; i < 64; ++i) { 49 | buckets[edgeCount[i]] += 1; 50 | } 51 | 52 | uint maxValue = 0; 53 | 54 | // Scan for most common edge direction (max) 55 | for (int j = 0; j < 4; ++j) { 56 | if (buckets[j] > maxValue) { 57 | commonEdgeIndex = j; 58 | maxValue = buckets[j]; 59 | } 60 | } 61 | 62 | // Discard edge info if not enough edge pixels in tile 63 | if (maxValue < _EdgeThreshold) commonEdgeIndex = -1; 64 | 65 | edgeCount[0] = commonEdgeIndex; 66 | } 67 | 68 | GroupMemoryBarrierWithGroupSync(); 69 | 70 | commonEdgeIndex = _ViewUncompressed ? direction : edgeCount[0]; 71 | 72 | float3 debugEdge = 0; 73 | if (commonEdgeIndex == 0) debugEdge = float3(1, 0, 0); 74 | if (commonEdgeIndex == 1) debugEdge = float3(0, 1, 0); 75 | if (commonEdgeIndex == 2) debugEdge = float3(0, 1, 1); 76 | if (commonEdgeIndex == 3) debugEdge = float3(1, 1, 0); 77 | 78 | float4 quantizedEdge = (commonEdgeIndex + 1) * 8; 79 | 80 | float4 ascii = 0; 81 | 82 | if (saturate(commonEdgeIndex + 1) && !_NoEdges) { 83 | float2 localUV; 84 | localUV.x = ((id.x % 8)) + quantizedEdge.x; 85 | localUV.y = 8 - (id.y % 8); 86 | 87 | ascii = _EdgeAsciiTex[localUV].r; 88 | } else if (!_NoFill) { 89 | // No edge here, blend luminance based ASCII 90 | 91 | uint2 luminanceID = id.xy / 8; 92 | 93 | float luminance = saturate(pow(abs((_LuminanceTex[luminanceID].w) * _Exposure), _Attenuation)); 94 | 95 | luminance = max(0, (floor(luminance * 10) - 1)) / 10.0f; 96 | 97 | float2 localUV; 98 | localUV.x = ((id.x % 8)) + luminance * 80; 99 | localUV.y = (id.y % 8); 100 | 101 | ascii = _AsciiTex[localUV].r; 102 | } 103 | 104 | float3 col = _LuminanceTex[id.xy / 8].rgb; 105 | // ascii.rgb *= col; 106 | 107 | if (_ViewUncompressed) ascii = (commonEdgeIndex + 1) / 5.0f; 108 | if (_DebugEdges) ascii = float4(debugEdge, 1.0f); 109 | 110 | int grid = (gid.y == 0) + (gid.x == 0); 111 | if (_Grid) ascii += grid * 0.5f; 112 | 113 | _Result[id.xy] = ascii; 114 | } -------------------------------------------------------------------------------- /Assets/ASCI/ASCII.compute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b8436936e86cb5043b58c380855b5b16 3 | ComputeShaderImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/ASCI/ASCII.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 05e2dc4309431674788ac723824b4394 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/ASCI/ASCIIPass.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2363ae7025bbee04fb1dd8a55c31a7be 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/ASCI/ASCIIRenderFeature.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class ASCIIRenderFeature : ScriptableRendererFeature 8 | { 9 | [System.Serializable] 10 | public class Settings 11 | { 12 | public RenderPassEvent renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing; 13 | public Shader shader; 14 | public ComputeShader computeShader; 15 | } 16 | public Settings settings = new Settings(); 17 | 18 | ASCIIPass m_ASCIIPass; 19 | private void OnEnable() 20 | { 21 | settings.shader = Shader.Find("Joseph&Acerola/ASCII"); 22 | } 23 | public override void Create() 24 | { 25 | this.name = "ASCII Pass"; 26 | if (settings.shader == null) 27 | { 28 | Debug.LogWarning("No Shader"); 29 | return; 30 | } 31 | m_ASCIIPass = new ASCIIPass(settings.renderPassEvent, settings.shader, settings.computeShader); 32 | } 33 | 34 | public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) 35 | { 36 | renderer.EnqueuePass(m_ASCIIPass); 37 | } 38 | } -------------------------------------------------------------------------------- /Assets/ASCI/ASCIIRenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fee4d55d265ec26429b874a60d90d35d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/ASCI/ASCIIVolume.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | using UnityEngine.Rendering; 6 | using UnityEngine.Rendering.Universal; 7 | 8 | [Serializable, VolumeComponentMenu("Joseph_Acerola/Custom ASCII")] 9 | public class ASCIIVolume : VolumeComponent, IPostProcessComponent 10 | { 11 | [Header("Textures")] 12 | public TextureParameter _asciiTex = new TextureParameter(null, true); 13 | public TextureParameter _edgeTex = new TextureParameter(null, true); 14 | 15 | [Header("Parameters")] 16 | public ClampedIntParameter _gaussianKernelSize = new ClampedIntParameter(2, 1, 10, true); 17 | public ClampedFloatParameter _stdev = new ClampedFloatParameter(2.0f, 0.1f, 5f, true); 18 | public ClampedFloatParameter _stdevScale = new ClampedFloatParameter(1.6f,0.1f,5f, true); 19 | public ClampedFloatParameter _tau = new ClampedFloatParameter(1.0f,0.01f,5f, true); 20 | public ClampedFloatParameter _threshold = new ClampedFloatParameter(0.005f,0.001f, 0.1f, true); 21 | public ClampedIntParameter _edgeThreshold = new ClampedIntParameter(8, 0, 64, true); 22 | public ClampedFloatParameter _exposure = new ClampedFloatParameter(1.0f, 0f, 10f, true); 23 | public ClampedFloatParameter _attenuation = new ClampedFloatParameter(1.0f, 0f, 10f, true); 24 | 25 | [Header("Extras")] 26 | public BoolParameter _invert = new BoolParameter(false, true); 27 | public BoolParameter _viewDog = new BoolParameter(false, true); 28 | public BoolParameter _viewSobel = new BoolParameter(false, true); 29 | public BoolParameter _viewGrid = new BoolParameter(false, true); 30 | public BoolParameter _debugEdges = new BoolParameter(false, true); 31 | public BoolParameter _viewUncompressedEdges = new BoolParameter(false, true); 32 | public BoolParameter _viewQuantizedSobel = new BoolParameter(false, true); 33 | public BoolParameter _noEdges = new BoolParameter(false, true); 34 | public BoolParameter _noFill = new BoolParameter(false, true); 35 | 36 | public void load(Material material, ref RenderingData renderingData) 37 | { 38 | material.SetTexture("_AsciiTex", _asciiTex.value); 39 | material.SetFloat("_K", _stdevScale.value); 40 | material.SetFloat("_Sigma", _stdev.value); 41 | material.SetFloat("_Tau", _tau.value); 42 | material.SetInt("_GaussianKernelSize", _gaussianKernelSize.value); 43 | material.SetFloat("_Threshold", _threshold.value); 44 | material.SetInt("_Invert", _invert.value ? 1 : 0); 45 | } 46 | 47 | public bool IsActive() => true; 48 | public bool IsTileCompatible() => false; 49 | } -------------------------------------------------------------------------------- /Assets/ASCI/ASCIIVolume.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ea9c8c715a5f6cc4e9f3a027afa712d8 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/ASCI/LUTs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 861972e217a46694e8a91415bd951ae5 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/ASCI/LUTs/1x0 8x8 2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Josephy5/PostProcessing-URP/4ab7140ef631b709b8538062d2ae6366da085465/Assets/ASCI/LUTs/1x0 8x8 2.png -------------------------------------------------------------------------------- /Assets/ASCI/LUTs/1x0 8x8 3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Josephy5/PostProcessing-URP/4ab7140ef631b709b8538062d2ae6366da085465/Assets/ASCI/LUTs/1x0 8x8 3.png -------------------------------------------------------------------------------- /Assets/ASCI/LUTs/1x0 8x8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Josephy5/PostProcessing-URP/4ab7140ef631b709b8538062d2ae6366da085465/Assets/ASCI/LUTs/1x0 8x8.png -------------------------------------------------------------------------------- /Assets/ASCI/LUTs/1x0 8x8.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b1e893ff78100ce428453d134d6584f2 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 12 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | sRGBTexture: 1 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 | ignoreMipmapLimit: 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 | cookieLightType: 0 69 | platformSettings: 70 | - serializedVersion: 3 71 | buildTarget: DefaultTexturePlatform 72 | maxTextureSize: 2048 73 | resizeAlgorithm: 0 74 | textureFormat: -1 75 | textureCompression: 1 76 | compressionQuality: 50 77 | crunchedCompression: 0 78 | allowsAlphaSplitting: 0 79 | overridden: 0 80 | ignorePlatformSupport: 0 81 | androidETC2FallbackOverride: 0 82 | forceMaximumCompressionQuality_BC6H_BC7: 0 83 | - serializedVersion: 3 84 | buildTarget: WebGL 85 | maxTextureSize: 2048 86 | resizeAlgorithm: 0 87 | textureFormat: -1 88 | textureCompression: 1 89 | compressionQuality: 50 90 | crunchedCompression: 0 91 | allowsAlphaSplitting: 0 92 | overridden: 0 93 | ignorePlatformSupport: 0 94 | androidETC2FallbackOverride: 0 95 | forceMaximumCompressionQuality_BC6H_BC7: 0 96 | - serializedVersion: 3 97 | buildTarget: Standalone 98 | maxTextureSize: 2048 99 | resizeAlgorithm: 0 100 | textureFormat: -1 101 | textureCompression: 1 102 | compressionQuality: 50 103 | crunchedCompression: 0 104 | allowsAlphaSplitting: 0 105 | overridden: 0 106 | ignorePlatformSupport: 0 107 | androidETC2FallbackOverride: 0 108 | forceMaximumCompressionQuality_BC6H_BC7: 0 109 | - serializedVersion: 3 110 | buildTarget: iPhone 111 | maxTextureSize: 2048 112 | resizeAlgorithm: 0 113 | textureFormat: -1 114 | textureCompression: 1 115 | compressionQuality: 50 116 | crunchedCompression: 0 117 | allowsAlphaSplitting: 0 118 | overridden: 0 119 | ignorePlatformSupport: 0 120 | androidETC2FallbackOverride: 0 121 | forceMaximumCompressionQuality_BC6H_BC7: 0 122 | spriteSheet: 123 | serializedVersion: 2 124 | sprites: [] 125 | outline: [] 126 | physicsShape: [] 127 | bones: [] 128 | spriteID: 129 | internalID: 0 130 | vertices: [] 131 | indices: 132 | edges: [] 133 | weights: [] 134 | secondaryTextures: [] 135 | nameFileIdTable: {} 136 | mipmapLimitGroupName: 137 | pSDRemoveMatte: 0 138 | userData: 139 | assetBundleName: 140 | assetBundleVariant: 141 | -------------------------------------------------------------------------------- /Assets/ASCI/LUTs/1x10 2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Josephy5/PostProcessing-URP/4ab7140ef631b709b8538062d2ae6366da085465/Assets/ASCI/LUTs/1x10 2.png -------------------------------------------------------------------------------- /Assets/ASCI/LUTs/1x10 2.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b921c353cc8ce24449a18739323d02a3 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 12 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | sRGBTexture: 1 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 | ignoreMipmapLimit: 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 | cookieLightType: 0 69 | platformSettings: 70 | - serializedVersion: 3 71 | buildTarget: DefaultTexturePlatform 72 | maxTextureSize: 2048 73 | resizeAlgorithm: 0 74 | textureFormat: -1 75 | textureCompression: 1 76 | compressionQuality: 50 77 | crunchedCompression: 0 78 | allowsAlphaSplitting: 0 79 | overridden: 0 80 | ignorePlatformSupport: 0 81 | androidETC2FallbackOverride: 0 82 | forceMaximumCompressionQuality_BC6H_BC7: 0 83 | - serializedVersion: 3 84 | buildTarget: WebGL 85 | maxTextureSize: 2048 86 | resizeAlgorithm: 0 87 | textureFormat: -1 88 | textureCompression: 1 89 | compressionQuality: 50 90 | crunchedCompression: 0 91 | allowsAlphaSplitting: 0 92 | overridden: 0 93 | ignorePlatformSupport: 0 94 | androidETC2FallbackOverride: 0 95 | forceMaximumCompressionQuality_BC6H_BC7: 0 96 | - serializedVersion: 3 97 | buildTarget: Standalone 98 | maxTextureSize: 2048 99 | resizeAlgorithm: 0 100 | textureFormat: -1 101 | textureCompression: 1 102 | compressionQuality: 50 103 | crunchedCompression: 0 104 | allowsAlphaSplitting: 0 105 | overridden: 0 106 | ignorePlatformSupport: 0 107 | androidETC2FallbackOverride: 0 108 | forceMaximumCompressionQuality_BC6H_BC7: 0 109 | - serializedVersion: 3 110 | buildTarget: iPhone 111 | maxTextureSize: 2048 112 | resizeAlgorithm: 0 113 | textureFormat: -1 114 | textureCompression: 1 115 | compressionQuality: 50 116 | crunchedCompression: 0 117 | allowsAlphaSplitting: 0 118 | overridden: 0 119 | ignorePlatformSupport: 0 120 | androidETC2FallbackOverride: 0 121 | forceMaximumCompressionQuality_BC6H_BC7: 0 122 | spriteSheet: 123 | serializedVersion: 2 124 | sprites: [] 125 | outline: [] 126 | physicsShape: [] 127 | bones: [] 128 | spriteID: 129 | internalID: 0 130 | vertices: [] 131 | indices: 132 | edges: [] 133 | weights: [] 134 | secondaryTextures: [] 135 | nameFileIdTable: {} 136 | mipmapLimitGroupName: 137 | pSDRemoveMatte: 0 138 | userData: 139 | assetBundleName: 140 | assetBundleVariant: 141 | -------------------------------------------------------------------------------- /Assets/ASCI/LUTs/1x10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Josephy5/PostProcessing-URP/4ab7140ef631b709b8538062d2ae6366da085465/Assets/ASCI/LUTs/1x10.png -------------------------------------------------------------------------------- /Assets/ASCI/LUTs/1x10.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bb8ff8757356cec46a4a1ff784664f76 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 12 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | sRGBTexture: 1 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 | ignoreMipmapLimit: 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 | cookieLightType: 0 69 | platformSettings: 70 | - serializedVersion: 3 71 | buildTarget: DefaultTexturePlatform 72 | maxTextureSize: 2048 73 | resizeAlgorithm: 0 74 | textureFormat: -1 75 | textureCompression: 1 76 | compressionQuality: 50 77 | crunchedCompression: 0 78 | allowsAlphaSplitting: 0 79 | overridden: 0 80 | ignorePlatformSupport: 0 81 | androidETC2FallbackOverride: 0 82 | forceMaximumCompressionQuality_BC6H_BC7: 0 83 | - serializedVersion: 3 84 | buildTarget: WebGL 85 | maxTextureSize: 2048 86 | resizeAlgorithm: 0 87 | textureFormat: -1 88 | textureCompression: 1 89 | compressionQuality: 50 90 | crunchedCompression: 0 91 | allowsAlphaSplitting: 0 92 | overridden: 0 93 | ignorePlatformSupport: 0 94 | androidETC2FallbackOverride: 0 95 | forceMaximumCompressionQuality_BC6H_BC7: 0 96 | - serializedVersion: 3 97 | buildTarget: Standalone 98 | maxTextureSize: 2048 99 | resizeAlgorithm: 0 100 | textureFormat: -1 101 | textureCompression: 1 102 | compressionQuality: 50 103 | crunchedCompression: 0 104 | allowsAlphaSplitting: 0 105 | overridden: 0 106 | ignorePlatformSupport: 0 107 | androidETC2FallbackOverride: 0 108 | forceMaximumCompressionQuality_BC6H_BC7: 0 109 | - serializedVersion: 3 110 | buildTarget: iPhone 111 | maxTextureSize: 2048 112 | resizeAlgorithm: 0 113 | textureFormat: -1 114 | textureCompression: 1 115 | compressionQuality: 50 116 | crunchedCompression: 0 117 | allowsAlphaSplitting: 0 118 | overridden: 0 119 | ignorePlatformSupport: 0 120 | androidETC2FallbackOverride: 0 121 | forceMaximumCompressionQuality_BC6H_BC7: 0 122 | spriteSheet: 123 | serializedVersion: 2 124 | sprites: [] 125 | outline: [] 126 | physicsShape: [] 127 | bones: [] 128 | spriteID: 129 | internalID: 0 130 | vertices: [] 131 | indices: 132 | edges: [] 133 | weights: [] 134 | secondaryTextures: [] 135 | nameFileIdTable: {} 136 | mipmapLimitGroupName: 137 | pSDRemoveMatte: 0 138 | userData: 139 | assetBundleName: 140 | assetBundleVariant: 141 | -------------------------------------------------------------------------------- /Assets/ASCI/LUTs/edges 8x40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Josephy5/PostProcessing-URP/4ab7140ef631b709b8538062d2ae6366da085465/Assets/ASCI/LUTs/edges 8x40.png -------------------------------------------------------------------------------- /Assets/BlendModes/BlendMode.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0bad4ad59c9b8994e8af5e550490cc7a 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/BlendModes/BlendModePass.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class BlendModePass : ScriptableRenderPass 8 | { 9 | static readonly string renderPassTag = "Blend Mode"; 10 | 11 | private BlendModeVolume blendModeVolume; 12 | private Material blendModeMaterial; 13 | 14 | public BlendModePass(RenderPassEvent evt, Shader blendModeshader) 15 | { 16 | renderPassEvent = evt; 17 | var shader = blendModeshader; 18 | if (shader == null) 19 | { 20 | Debug.LogError("No Shader"); 21 | return; 22 | } 23 | blendModeMaterial = CoreUtils.CreateEngineMaterial(blendModeshader); 24 | } 25 | 26 | 27 | public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) 28 | { 29 | if (blendModeMaterial == null) 30 | { 31 | Debug.LogError("No Blend Mode Material"); 32 | return; 33 | } 34 | 35 | if (!renderingData.cameraData.postProcessEnabled) 36 | { 37 | //Debug.LogError("Post Processing in Camera not enabled"); 38 | return; 39 | } 40 | 41 | VolumeStack stack = VolumeManager.instance.stack; 42 | blendModeVolume = stack.GetComponent(); 43 | 44 | var cmd = CommandBufferPool.Get(renderPassTag); 45 | Render(cmd, ref renderingData); 46 | context.ExecuteCommandBuffer(cmd); 47 | 48 | CommandBufferPool.Release(cmd); 49 | } 50 | 51 | void Render(CommandBuffer cmd, ref RenderingData renderingData) 52 | { 53 | if (blendModeVolume.IsActive() == false) return; 54 | blendModeVolume.load(blendModeMaterial, ref renderingData); 55 | 56 | int blendMode = (int)blendModeVolume._blendMode.value; 57 | 58 | var source = renderingData.cameraData.renderer.cameraColorTarget; 59 | 60 | var descriptor = renderingData.cameraData.cameraTargetDescriptor; 61 | descriptor.depthBufferBits = 0; 62 | 63 | var temporaryRT = Shader.PropertyToID("_TemporaryRT"); 64 | cmd.GetTemporaryRT(temporaryRT, descriptor, FilterMode.Point); 65 | 66 | cmd.Blit(source, temporaryRT); 67 | cmd.Blit(temporaryRT, source, blendModeMaterial, blendMode) ; 68 | 69 | cmd.ReleaseTemporaryRT(temporaryRT); 70 | } 71 | 72 | } -------------------------------------------------------------------------------- /Assets/BlendModes/BlendModePass.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a0e4e61da01bb4b45897d4aca5256542 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/BlendModes/BlendModeRenderFeature.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class BlendModeRenderFeature : ScriptableRendererFeature 8 | { 9 | [System.Serializable] 10 | public class Settings 11 | { 12 | public RenderPassEvent renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing; 13 | public Shader shader; 14 | //[Range(2, 10)] public int sampleTimes = 2; 15 | } 16 | public Settings settings = new Settings(); 17 | 18 | BlendModePass m_BlendModePass; 19 | private void OnEnable() 20 | { 21 | settings.shader = Shader.Find("Joseph&Acerola/BlendModes"); 22 | } 23 | public override void Create() 24 | { 25 | this.name = "Blend Mode Pass"; 26 | if (settings.shader == null) 27 | { 28 | Debug.LogWarning("No Shader"); 29 | return; 30 | } 31 | m_BlendModePass = new BlendModePass(settings.renderPassEvent, settings.shader); 32 | } 33 | 34 | public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) 35 | { 36 | renderer.EnqueuePass(m_BlendModePass); 37 | } 38 | } -------------------------------------------------------------------------------- /Assets/BlendModes/BlendModeRenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a7e134946e0a58b449f6c9715b57ef64 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/BlendModes/BlendModeVolume.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | using UnityEngine.Rendering; 6 | using UnityEngine.Rendering.Universal; 7 | 8 | [Serializable, VolumeComponentMenu("Joseph_Acerola/Custom Blend Modes")] 9 | public class BlendModeVolume : VolumeComponent, IPostProcessComponent 10 | { 11 | public BlendModeParameter _blendMode = new BlendModeParameter(BlendMode.NoBlend, true); 12 | public BlendTypeParameter _blendType = new BlendTypeParameter(BlendType.BlendOnItself, true); 13 | public ClampedFloatParameter _strength = new ClampedFloatParameter(1.0f, 0.0f, 1.0f, true); 14 | public TextureParameter _blendTexture = new TextureParameter(null, true); 15 | public ColorParameter _blendColor = new ColorParameter(Color.white, true); 16 | 17 | public void load(Material material, ref RenderingData renderingData) 18 | { 19 | //material.SetInt("_BlendMode", (int) _blendMode.value); 20 | material.SetInt("_BlendType", (int) _blendType.value); 21 | material.SetTexture("_BlendTex", _blendTexture.value); 22 | material.SetColor("_BlendColor", _blendColor.value); 23 | material.SetFloat("_Strength", _strength.value); 24 | } 25 | 26 | public bool IsActive() => true; 27 | public bool IsTileCompatible() => false; 28 | } 29 | public enum BlendMode 30 | { 31 | NoBlend = 0, 32 | Add, 33 | Subtract, 34 | Multiply, 35 | Screen, 36 | Overlay, 37 | SoftLight, 38 | ColorDodge, 39 | ColorBurn, 40 | VividLight 41 | } 42 | 43 | [Serializable] 44 | public sealed class BlendModeParameter : VolumeParameter 45 | { 46 | public BlendModeParameter(BlendMode value, bool overrideState = false) : base(value, overrideState) { } 47 | } 48 | public enum BlendType 49 | { 50 | BlendOnItself, 51 | PickedTexture, 52 | PickedColor 53 | } 54 | [Serializable] 55 | public sealed class BlendTypeParameter : VolumeParameter 56 | { 57 | public BlendTypeParameter(BlendType value, bool overrideState = false) : base(value, overrideState) { } 58 | } -------------------------------------------------------------------------------- /Assets/BlendModes/BlendModeVolume.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 274ff4288c451ff48a7e17ef572e3a29 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Bloom/BloomAcerolaPass.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class BloomAcerolaPass : ScriptableRenderPass 8 | { 9 | static readonly string renderPassTag = "Acerola Bloom"; 10 | 11 | private BloomAcerolaVolume BloomAcerolaVolume; 12 | private Material BloomAcerolaMaterial; 13 | 14 | public BloomAcerolaPass(RenderPassEvent evt, Shader BloomAcerolashader) 15 | { 16 | renderPassEvent = evt; 17 | var shader = BloomAcerolashader; 18 | if (shader == null) 19 | { 20 | Debug.LogError("No Shader"); 21 | return; 22 | } 23 | BloomAcerolaMaterial = CoreUtils.CreateEngineMaterial(BloomAcerolashader); 24 | } 25 | 26 | 27 | public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) 28 | { 29 | if (BloomAcerolaMaterial == null) 30 | { 31 | Debug.LogError("No Acerola Bloom Material"); 32 | return; 33 | } 34 | 35 | if (!renderingData.cameraData.postProcessEnabled) 36 | { 37 | //Debug.LogError("Post Processing in Camera not enabled"); 38 | return; 39 | } 40 | 41 | VolumeStack stack = VolumeManager.instance.stack; 42 | BloomAcerolaVolume = stack.GetComponent(); 43 | 44 | var cmd = CommandBufferPool.Get(renderPassTag); 45 | Render(cmd, ref renderingData); 46 | context.ExecuteCommandBuffer(cmd); 47 | 48 | CommandBufferPool.Release(cmd); 49 | } 50 | 51 | void Render(CommandBuffer cmd, ref RenderingData renderingData) 52 | { 53 | if (BloomAcerolaVolume.IsActive() == false) return; 54 | BloomAcerolaVolume.load(BloomAcerolaMaterial, ref renderingData); 55 | 56 | int width = renderingData.cameraData.cameraTargetDescriptor.width; 57 | int height = renderingData.cameraData.cameraTargetDescriptor.height; 58 | var source = renderingData.cameraData.renderer.cameraColorTarget; 59 | 60 | width /= 2; 61 | height /= 2; 62 | 63 | RenderTexture[] textures = new RenderTexture[16]; 64 | RenderTexture currentDestination = textures[0] = RenderTexture.GetTemporary(width, height, 0, renderingData.cameraData.cameraTargetDescriptor.colorFormat); 65 | 66 | cmd.Blit(source, currentDestination, BloomAcerolaMaterial, 0); 67 | RenderTexture currentSource = currentDestination; 68 | 69 | int downSamples = (int)BloomAcerolaVolume._downSamples.value; 70 | 71 | int i = 1; 72 | for (; i < downSamples; ++i) 73 | { 74 | width /= 2; 75 | height /= 2; 76 | 77 | if (height < 2) 78 | break; 79 | 80 | currentDestination = textures[i] = RenderTexture.GetTemporary(width, height, 0, renderingData.cameraData.cameraTargetDescriptor.colorFormat); 81 | Graphics.Blit(currentSource, currentDestination, BloomAcerolaMaterial, 1); 82 | currentSource = currentDestination; 83 | } 84 | 85 | for (i -= 2; i >= 0; --i) 86 | { 87 | currentDestination = textures[i]; 88 | textures[i] = null; 89 | Graphics.Blit(currentSource, currentDestination, BloomAcerolaMaterial, 2); 90 | RenderTexture.ReleaseTemporary(currentSource); 91 | currentSource = currentDestination; 92 | } 93 | 94 | cmd.Blit(currentSource, source, BloomAcerolaMaterial, 3); 95 | RenderTexture.ReleaseTemporary(currentSource); 96 | } 97 | 98 | } -------------------------------------------------------------------------------- /Assets/Bloom/BloomAcerolaPass.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0ca022d6822a9504a91a6dba9220b9f6 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Bloom/BloomAcerolaRenderFeature.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class BloomAcerolaRenderFeature : ScriptableRendererFeature 8 | { 9 | [System.Serializable] 10 | public class Settings 11 | { 12 | public RenderPassEvent renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing; 13 | public Shader shader; 14 | } 15 | public Settings settings = new Settings(); 16 | 17 | BloomAcerolaPass m_BloomAcerolaPass; 18 | private void OnEnable() 19 | { 20 | settings.shader = Shader.Find("Joseph&Acerola/Bloom"); 21 | } 22 | public override void Create() 23 | { 24 | this.name = "Acerola Bloom Pass"; 25 | if (settings.shader == null) 26 | { 27 | Debug.LogWarning("No Shader"); 28 | return; 29 | } 30 | m_BloomAcerolaPass = new BloomAcerolaPass(settings.renderPassEvent, settings.shader); 31 | } 32 | 33 | public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) 34 | { 35 | renderer.EnqueuePass(m_BloomAcerolaPass); 36 | } 37 | } -------------------------------------------------------------------------------- /Assets/Bloom/BloomAcerolaRenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 291d1021e19a17a4eb5fe09cb901d0d6 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Bloom/BloomAcerolaVolume.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | using UnityEngine.Rendering; 6 | using UnityEngine.Rendering.Universal; 7 | 8 | [Serializable, VolumeComponentMenu("Joseph_Acerola/Custom Acerola Bloom")] 9 | public class BloomAcerolaVolume : VolumeComponent, IPostProcessComponent 10 | { 11 | public ClampedFloatParameter _threshold = new ClampedFloatParameter(1.0f, 0f, 10f, true); 12 | public ClampedFloatParameter _softThreshold = new ClampedFloatParameter(1f, 0f, 1f, true); 13 | public ClampedIntParameter _downSamples = new ClampedIntParameter(1, 1, 16, true); 14 | public ClampedFloatParameter _downSampleDelta = new ClampedFloatParameter(1.0f, 0.01f, 2.0f, true); 15 | public ClampedFloatParameter _upSampleDelta = new ClampedFloatParameter(0.5f, 0.01f, 2f, true); 16 | public ClampedFloatParameter _bloomIntensity = new ClampedFloatParameter(1f, 0f, 10f, true); 17 | 18 | public void load(Material material, ref RenderingData renderingData) 19 | { 20 | material.SetFloat("_Threshold", _threshold.value); 21 | material.SetFloat("_SoftThreshold", _softThreshold.value); 22 | material.SetFloat("_DownDelta", _downSampleDelta.value); 23 | material.SetFloat("_UpDelta", _upSampleDelta.value); 24 | //material.SetTexture("_OriginalTex", _source.value); 25 | material.SetFloat("_Intensity", _bloomIntensity.value); 26 | } 27 | 28 | public bool IsActive() => true; 29 | public bool IsTileCompatible() => false; 30 | } -------------------------------------------------------------------------------- /Assets/Bloom/BloomAcerolaVolume.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3b3b7cd1efc6bf343b1252dd0b0eecbc 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Bloom/Bloom_AceRola.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a36ce3d9aea6a4d43a671389b9f98f9a 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Blur/Blur.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 486df6190f697d249a0871e7a0bef07b 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Blur/BlurPass.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class BlurPass : ScriptableRenderPass 8 | { 9 | static readonly string renderPassTag = "Blur"; 10 | 11 | private BlurVolume blurVolume; 12 | private Material blurMaterial; 13 | 14 | //private int testRTID; 15 | private int sampleTimes; 16 | 17 | public BlurPass(RenderPassEvent evt, Shader blurshader) 18 | { 19 | renderPassEvent = evt; 20 | var shader = blurshader; 21 | if (shader == null) 22 | { 23 | Debug.LogError("No Shader"); 24 | return; 25 | } 26 | blurMaterial = CoreUtils.CreateEngineMaterial(blurshader); 27 | //this.sampleTimes = sampleTimes; 28 | } 29 | 30 | 31 | public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) 32 | { 33 | if (blurMaterial == null) 34 | { 35 | Debug.LogError("No Blur Material"); 36 | return; 37 | } 38 | 39 | if (!renderingData.cameraData.postProcessEnabled) 40 | { 41 | //Debug.LogError("Post Processing in Camera not enabled"); 42 | return; 43 | } 44 | 45 | VolumeStack stack = VolumeManager.instance.stack; 46 | blurVolume = stack.GetComponent(); 47 | 48 | var cmd = CommandBufferPool.Get(renderPassTag); 49 | Render(cmd, ref renderingData); 50 | context.ExecuteCommandBuffer(cmd); 51 | 52 | CommandBufferPool.Release(cmd); 53 | 54 | } 55 | 56 | void Render(CommandBuffer cmd, ref RenderingData renderingData) 57 | { 58 | if (blurVolume.IsActive() == false) return; 59 | blurVolume.load(blurMaterial, ref renderingData); 60 | int blurPasses = blurVolume._blurPasses.value; 61 | int blurOperator = (int) blurVolume._blurOperator.value; 62 | 63 | var cameraColorTarget = renderingData.cameraData.renderer.cameraColorTarget; 64 | 65 | var descriptor = renderingData.cameraData.cameraTargetDescriptor; 66 | var temp1 = Shader.PropertyToID("_Temp1"); 67 | var temp2 = Shader.PropertyToID("_Temp2"); 68 | 69 | cmd.GetTemporaryRT(temp1, descriptor); 70 | cmd.GetTemporaryRT(temp2, descriptor); 71 | 72 | cmd.Blit(cameraColorTarget, temp1, blurMaterial, blurOperator * 2); 73 | cmd.Blit(temp1, temp2, blurMaterial, blurOperator * 2 + 1); 74 | 75 | for (int i = 1; i < blurPasses; ++i) 76 | { 77 | cmd.Blit(temp2, temp1, blurMaterial, blurOperator * 2); 78 | cmd.Blit(temp1, temp2, blurMaterial, blurOperator * 2 + 1); 79 | } 80 | 81 | cmd.Blit(temp2, cameraColorTarget); 82 | 83 | cmd.ReleaseTemporaryRT(temp1); 84 | cmd.ReleaseTemporaryRT(temp2); 85 | } 86 | 87 | } -------------------------------------------------------------------------------- /Assets/Blur/BlurPass.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 92325038ec1567c4a949e8677fb9435d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Blur/BlurRenderFeature.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class BlurRenderFeature : ScriptableRendererFeature 8 | { 9 | [System.Serializable] 10 | public class Settings 11 | { 12 | public RenderPassEvent renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing; 13 | public Shader shader; 14 | //[Range(2, 10)] public int sampleTimes = 2; 15 | } 16 | public Settings settings = new Settings(); 17 | 18 | BlurPass m_blurPass; 19 | private void OnEnable() 20 | { 21 | settings.shader = Shader.Find("Joseph&Acerola/Blur"); 22 | } 23 | public override void Create() 24 | { 25 | this.name = "Blur Pass"; 26 | if (settings.shader == null) 27 | { 28 | Debug.LogWarning("No Shader"); 29 | return; 30 | } 31 | m_blurPass = new BlurPass(settings.renderPassEvent, settings.shader); 32 | } 33 | 34 | public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) 35 | { 36 | renderer.EnqueuePass(m_blurPass); 37 | } 38 | } -------------------------------------------------------------------------------- /Assets/Blur/BlurRenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 74292e73c25acc247a76881e66f5ec23 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Blur/BlurVolume.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | using UnityEngine.Rendering; 6 | using UnityEngine.Rendering.Universal; 7 | 8 | [Serializable, VolumeComponentMenu("Joseph_Acerola/Custom Blur")] 9 | public class BlurVolume : VolumeComponent, IPostProcessComponent 10 | { 11 | public BlurOperatorsParameter _blurOperator = new BlurOperatorsParameter(BlurOperators.Box, true); 12 | public IntParameter _kernelSize = new IntParameter(3, true); 13 | public ClampedFloatParameter _sigma = new ClampedFloatParameter(2.0f, 0.1f, 10.0f,true); 14 | public ClampedIntParameter _blurPasses = new ClampedIntParameter(1, 1, 10,true); 15 | 16 | public void load(Material material, ref RenderingData renderingData) 17 | { 18 | material.SetFloat("_KernelSize", _kernelSize.value); 19 | material.SetFloat("_Sigma", _sigma.value); 20 | } 21 | 22 | public bool IsActive() => true; 23 | public bool IsTileCompatible() => false; 24 | } 25 | public enum BlurOperators 26 | { 27 | Box, 28 | Gaussian 29 | } 30 | [Serializable] 31 | public sealed class BlurOperatorsParameter : VolumeParameter 32 | { 33 | public BlurOperatorsParameter(BlurOperators value, bool overrideState = false) : base(value, overrideState) { } 34 | } -------------------------------------------------------------------------------- /Assets/Blur/BlurVolume.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5c3ce7c217c894a4cb9277171437791f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/ChromaticAboration/ChromaticAberration.shader: -------------------------------------------------------------------------------- 1 | Shader "Joseph&Acerola/ChromaticAberration" { 2 | Properties { 3 | _MainTex("Texture", 2D) = "white" {} 4 | } 5 | SubShader { 6 | Pass { 7 | CGPROGRAM 8 | #pragma vertex vp 9 | #pragma fragment fp 10 | 11 | #include "UnityCG.cginc" 12 | 13 | struct VertexData { 14 | float4 vertex : POSITION; 15 | float2 uv : TEXCOORD0; 16 | }; 17 | 18 | struct v2f { 19 | float2 uv : TEXCOORD0; 20 | float4 vertex : SV_POSITION; 21 | }; 22 | 23 | v2f vp(VertexData v) { 24 | v2f o; 25 | o.vertex = UnityObjectToClipPos(v.vertex); 26 | o.uv = v.uv; 27 | return o; 28 | } 29 | 30 | sampler2D _MainTex; 31 | float4 _MainTex_TexelSize; 32 | bool _DebugMask; 33 | float2 _FocalOffset, _Radius; 34 | float _Hardness, _Intensity; 35 | float3 _ColorOffsets; 36 | 37 | float4 fp(v2f i) : SV_Target { 38 | float2 pos = i.uv - 0.5f; 39 | pos -= _FocalOffset; 40 | pos *= _Radius; 41 | pos += 0.5f; 42 | 43 | float2 d = pos - 0.5f; 44 | float intensity = saturate(pow(abs(length(pos - 0.5f)), _Hardness)) * _Intensity; 45 | 46 | if (_DebugMask) 47 | return intensity; 48 | 49 | float4 col = 1.0f; 50 | float2 redUV = i.uv + (d * _ColorOffsets.r * _MainTex_TexelSize.xy) * intensity; 51 | float2 blueUV = i.uv + (d * _ColorOffsets.b * _MainTex_TexelSize.xy) * intensity; 52 | float2 greenUV = i.uv + (d * _ColorOffsets.g * _MainTex_TexelSize.xy) * intensity; 53 | 54 | col.r = tex2D(_MainTex, redUV).r; 55 | col.g = tex2D(_MainTex, blueUV).g; 56 | col.b = tex2D(_MainTex, greenUV).b; 57 | 58 | return col; 59 | } 60 | ENDCG 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Assets/ChromaticAboration/ChromaticAberration.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f40c0c8c768162248a4463c3ac5c5661 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/ChromaticAboration/ChromaticAboPass.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class ChromaticAboPass : ScriptableRenderPass 8 | { 9 | static readonly string renderPassTag = "Chromatic Aberration"; 10 | 11 | private ChromaticAboVolume ChromaticVolume; 12 | private Material ChromaticMaterial; 13 | 14 | public ChromaticAboPass(RenderPassEvent evt, Shader chromaticshader) 15 | { 16 | renderPassEvent = evt; 17 | var shader = chromaticshader; 18 | if (shader == null) 19 | { 20 | Debug.LogError("No Shader"); 21 | return; 22 | } 23 | ChromaticMaterial = CoreUtils.CreateEngineMaterial(chromaticshader); 24 | } 25 | 26 | public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) 27 | { 28 | if (ChromaticMaterial == null) 29 | { 30 | Debug.LogError("No Chromatic Aboration Material"); 31 | return; 32 | } 33 | 34 | if (!renderingData.cameraData.postProcessEnabled) 35 | { 36 | //Debug.LogError("Post Processing in Camera not enabled"); 37 | return; 38 | } 39 | 40 | VolumeStack stack = VolumeManager.instance.stack; 41 | ChromaticVolume = stack.GetComponent(); 42 | 43 | var cmd = CommandBufferPool.Get(renderPassTag); 44 | Render(cmd, ref renderingData); 45 | context.ExecuteCommandBuffer(cmd); 46 | CommandBufferPool.Release(cmd); 47 | } 48 | void Render(CommandBuffer cmd, ref RenderingData renderingData) 49 | { 50 | ChromaticVolume.load(ChromaticMaterial, ref renderingData); 51 | 52 | var cameraColorTarget = renderingData.cameraData.renderer.cameraColorTarget; 53 | 54 | // Apply chromatic aberration effect 55 | cmd.GetTemporaryRT(Shader.PropertyToID("_ChromaticRT"), renderingData.cameraData.cameraTargetDescriptor, FilterMode.Point); 56 | RenderTargetIdentifier chromatic = new RenderTargetIdentifier("_ChromaticRT"); 57 | cmd.Blit(cameraColorTarget, chromatic, ChromaticMaterial, 0); // Use pass 0 58 | 59 | // Final blit to the destination 60 | cmd.Blit(chromatic, cameraColorTarget); // Use the default pass 61 | 62 | // Release temporary render texture 63 | cmd.ReleaseTemporaryRT(Shader.PropertyToID("_ChromaticRT")); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Assets/ChromaticAboration/ChromaticAboPass.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 27479b34acbb8804fa41a888517b5f27 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/ChromaticAboration/ChromaticAboRendererFeature.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering.Universal; 5 | 6 | public class ChromaticAboRendererFeature : ScriptableRendererFeature 7 | { 8 | [System.Serializable] 9 | public class Settings 10 | { 11 | public RenderPassEvent renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing; 12 | public Shader shader; 13 | } 14 | 15 | public Settings settings = new Settings(); 16 | 17 | ChromaticAboPass m_ChromaticPass; 18 | 19 | private void OnEnable() 20 | { 21 | settings.shader = Shader.Find("Joseph&Acerola/ChromaticAberration"); 22 | } 23 | public override void Create() 24 | { 25 | this.name = "Chromatic Aboration Pass"; 26 | if(settings.shader == null) 27 | { 28 | Debug.LogWarning("No Shader"); 29 | return; 30 | } 31 | m_ChromaticPass = new ChromaticAboPass(settings.renderPassEvent, settings.shader); 32 | } 33 | 34 | public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) 35 | { 36 | renderer.EnqueuePass(m_ChromaticPass); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Assets/ChromaticAboration/ChromaticAboRendererFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0784d89b48159cf4c8131c77c4867697 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/ChromaticAboration/ChromaticAboVolume.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | [VolumeComponentMenu("Joseph_Acerola/Custom Chromatic Aboration")] 8 | public class ChromaticAboVolume : VolumeComponent, IPostProcessComponent 9 | { 10 | public Vector2Parameter _focalOffset = new Vector2Parameter(new Vector2(0.0f, 0.0f),true); 11 | public Vector2Parameter _radius = new Vector2Parameter(new Vector2(1.0f, 1.0f), true); 12 | 13 | public ClampedFloatParameter _hardness = new ClampedFloatParameter(1f, 0.01f, 5.0f, true); 14 | public ClampedFloatParameter _intensity = new ClampedFloatParameter(1f, 0.01f, 5.0f, true); 15 | 16 | public Vector3Parameter _channelOffsets = new Vector3Parameter(new Vector3(0.0f, 0.0f, 0.0f), true); 17 | 18 | public void load(Material material, ref RenderingData renderingData) 19 | { 20 | material.SetVector("_FocalOffset", _focalOffset.value); 21 | material.SetVector("_Radius", _radius.value); 22 | material.SetVector("_ColorOffsets", _channelOffsets.value); 23 | material.SetFloat("_Hardness", _hardness.value); 24 | material.SetFloat("_Intensity", _intensity.value); 25 | } 26 | public bool IsActive() => true; 27 | public bool IsTileCompatible() => false; 28 | } 29 | -------------------------------------------------------------------------------- /Assets/ChromaticAboration/ChromaticAboVolume.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ab67133ca6a55164fb9c9bb02ce356d7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Color Blindness/Color Blindness.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1a3ca4584bf347041b41f16bf621f43e 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Color Blindness/ColorBlindnessPass.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class ColorBlindnessPass : ScriptableRenderPass 8 | { 9 | static readonly string renderPassTag = "Color Blindness"; 10 | 11 | private ColorBlindnessVolume ColorBlindnessVolume; 12 | private Material ColorBlindnessMaterial; 13 | 14 | public ColorBlindnessPass(RenderPassEvent evt, Shader ColorBlindnessshader) 15 | { 16 | renderPassEvent = evt; 17 | var shader = ColorBlindnessshader; 18 | if (shader == null) 19 | { 20 | Debug.LogError("No Shader"); 21 | return; 22 | } 23 | ColorBlindnessMaterial = CoreUtils.CreateEngineMaterial(ColorBlindnessshader); 24 | } 25 | 26 | 27 | public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) 28 | { 29 | if (ColorBlindnessMaterial == null) 30 | { 31 | Debug.LogError("No Color Blindness Material"); 32 | return; 33 | } 34 | 35 | if (!renderingData.cameraData.postProcessEnabled || renderingData.cameraData.cameraType == CameraType.SceneView) 36 | { 37 | //Debug.LogError("Post Processing in Camera not enabled"); 38 | return; 39 | } 40 | 41 | VolumeStack stack = VolumeManager.instance.stack; 42 | ColorBlindnessVolume = stack.GetComponent(); 43 | 44 | var cmd = CommandBufferPool.Get(renderPassTag); 45 | Render(cmd, ref renderingData); 46 | context.ExecuteCommandBuffer(cmd); 47 | 48 | CommandBufferPool.Release(cmd); 49 | } 50 | 51 | void Render(CommandBuffer cmd, ref RenderingData renderingData) 52 | { 53 | if (ColorBlindnessVolume.IsActive() == false) return; 54 | ColorBlindnessVolume.load(ColorBlindnessMaterial, ref renderingData); 55 | 56 | int blindType = (int)ColorBlindnessVolume._blindType.value; 57 | 58 | var source = renderingData.cameraData.renderer.cameraColorTarget; 59 | 60 | cmd.Blit(source, source, ColorBlindnessMaterial, blindType); 61 | } 62 | 63 | } -------------------------------------------------------------------------------- /Assets/Color Blindness/ColorBlindnessPass.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a8b10f802d2936a4697f09c361c7a042 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Color Blindness/ColorBlindnessRenderFeature.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class ColorBlindnessRenderFeature : ScriptableRendererFeature 8 | { 9 | [System.Serializable] 10 | public class Settings 11 | { 12 | public RenderPassEvent renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing; 13 | public Shader shader; 14 | //[Range(2, 10)] public int sampleTimes = 2; 15 | } 16 | public Settings settings = new Settings(); 17 | 18 | ColorBlindnessPass m_ColorBlindnessPass; 19 | private void OnEnable() 20 | { 21 | settings.shader = Shader.Find("Joseph&Acerola/ColorBlindess"); 22 | } 23 | public override void Create() 24 | { 25 | this.name = "Color Blindness Pass"; 26 | if (settings.shader == null) 27 | { 28 | Debug.LogWarning("No Shader"); 29 | return; 30 | } 31 | m_ColorBlindnessPass = new ColorBlindnessPass(settings.renderPassEvent, settings.shader); 32 | } 33 | 34 | public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) 35 | { 36 | renderer.EnqueuePass(m_ColorBlindnessPass); 37 | } 38 | } -------------------------------------------------------------------------------- /Assets/Color Blindness/ColorBlindnessRenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1a86372d563ba5244a59e560115261d8 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Color Blindness/ColorBlindnessVolume.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | using UnityEngine.Rendering; 6 | using UnityEngine.Rendering.Universal; 7 | 8 | [Serializable, VolumeComponentMenu("Joseph_Acerola/Custom Color Blindness")] 9 | public class ColorBlindnessVolume : VolumeComponent, IPostProcessComponent 10 | { 11 | public BlindTypeParameter _blindType = new BlindTypeParameter(BlindTypes.Protanomaly, true); 12 | public FloatParameter _severity = new ClampedFloatParameter(0f, 0f, 1f, true); 13 | public BoolParameter _difference = new BoolParameter(false, true); 14 | 15 | public void load(Material material, ref RenderingData renderingData) 16 | { 17 | material.SetFloat("_Severity", _severity.value); 18 | material.SetInt("_Difference", _difference.value ? 1 : 0); 19 | } 20 | 21 | public bool IsActive() => true; 22 | public bool IsTileCompatible() => false; 23 | } 24 | public enum BlindTypes 25 | { 26 | Protanomaly = 0, 27 | Deuteranomaly, 28 | Tritanomaly 29 | } 30 | [Serializable] 31 | public sealed class BlindTypeParameter : VolumeParameter 32 | { 33 | public BlindTypeParameter(BlindTypes value, bool overrideState = false) : base(value, overrideState) { } 34 | } -------------------------------------------------------------------------------- /Assets/Color Blindness/ColorBlindnessVolume.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aec580994b1c5f94f9d764226418a3a4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Color Blindness/Deuteranomaly.cginc: -------------------------------------------------------------------------------- 1 | static const float3x3 deuteranomaly0 = { 2 | 1.0f, 0.0f, 0.0f, 3 | 0.0f, 1.0f, 0.0f, 4 | 0.0f, 0.0f, 1.0f 5 | }; 6 | 7 | static const float3x3 deuteranomaly01 = { 8 | 0.866435, 0.177704, -0.044139, 9 | 0.049567, 0.939063, 0.011370, 10 | -0.003453, 0.007233, 0.996220 11 | }; 12 | 13 | static const float3x3 deuteranomaly02 = { 14 | 0.760729, 0.319078, -0.079807, 15 | 0.090568, 0.889315, 0.020117, 16 | -0.006027, 0.013325, 0.992702 17 | }; 18 | 19 | static const float3x3 deuteranomaly03 = { 20 | 0.675425, 0.433850, -0.109275, 21 | 0.125303, 0.847755, 0.026942, 22 | -0.007950, 0.018572, 0.989378 23 | }; 24 | 25 | static const float3x3 deuteranomaly04 = { 26 | 0.605511, 0.528560, -0.134071, 27 | 0.155318, 0.812366, 0.032316, 28 | -0.009376, 0.023176, 0.986200 29 | }; 30 | 31 | static const float3x3 deuteranomaly05 = { 32 | 0.547494, 0.607765, -0.155259, 33 | 0.181692, 0.781742, 0.036566, 34 | -0.010410, 0.027275, 0.983136 35 | }; 36 | 37 | static const float3x3 deuteranomaly06 = { 38 | 0.498864, 0.674741, -0.173604, 39 | 0.205199, 0.754872, 0.039929, 40 | -0.011131, 0.030969, 0.980162 41 | }; 42 | 43 | static const float3x3 deuteranomaly07 = { 44 | 0.457771, 0.731899, -0.189670, 45 | 0.226409, 0.731012, 0.042579, 46 | -0.011595, 0.034333, 0.977261 47 | }; 48 | 49 | static const float3x3 deuteranomaly08 = { 50 | 0.422823, 0.781057, -0.203881, 51 | 0.245752, 0.709602, 0.044646, 52 | -0.011843, 0.037423, 0.974421 53 | }; 54 | 55 | static const float3x3 deuteranomaly09 = { 56 | 0.392952, 0.823610, -0.216562, 57 | 0.263559, 0.690210, 0.046232, 58 | -0.011910, 0.040281, 0.971630 59 | }; 60 | 61 | static const float3x3 deuteranomaly10 = { 62 | 0.367322, 0.860646, -0.227968, 63 | 0.280085, 0.672501, 0.047413, 64 | -0.011820, 0.042940, 0.968881 65 | }; 66 | 67 | static const float3x3 deuteranomalySeverities[11] = { 68 | deuteranomaly0, 69 | deuteranomaly01, 70 | deuteranomaly02, 71 | deuteranomaly03, 72 | deuteranomaly04, 73 | deuteranomaly05, 74 | deuteranomaly06, 75 | deuteranomaly07, 76 | deuteranomaly08, 77 | deuteranomaly09, 78 | deuteranomaly10 79 | }; -------------------------------------------------------------------------------- /Assets/Color Blindness/Deuteranomaly.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aaa7fa00279cafe459425b4c4936ba89 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Color Blindness/Protanomaly.cginc: -------------------------------------------------------------------------------- 1 | static const float3x3 protanomaly0 = { 2 | 1.0f, 0.0f, 0.0f, 3 | 0.0f, 1.0f, 0.0f, 4 | 0.0f, 0.0f, 1.0f 5 | }; 6 | 7 | static const float3x3 protanomaly01 = { 8 | 0.856167, 0.182038, -0.038205, 9 | 0.029342, 0.955115, 0.015544, 10 | -0.002880, -0.001563, 1.004443 11 | }; 12 | 13 | static const float3x3 protanomaly02 = { 14 | 0.734766, 0.334872, -0.069637, 15 | 0.051840, 0.919198, 0.028963, 16 | -0.004928, -0.004209, 1.009137 17 | }; 18 | 19 | static const float3x3 protanomaly03 = { 20 | 0.630323, 0.465641, -0.095964, 21 | 0.069181, 0.890046, 0.040773, 22 | -0.006308, -0.007724, 1.014032 23 | }; 24 | 25 | static const float3x3 protanomaly04 = { 26 | 0.539009, 0.579343, -0.118352, 27 | 0.082546, 0.866121, 0.051332, 28 | -0.007136, -0.011959, 1.019095 29 | }; 30 | 31 | static const float3x3 protanomaly05 = { 32 | 0.458064, 0.679578, -0.137642, 33 | 0.092785, 0.846313, 0.060902, 34 | -0.007494, -0.016807, 1.024301 35 | }; 36 | 37 | static const float3x3 protanomaly06 = { 38 | 0.385450, 0.769005, -0.154455, 39 | 0.100526, 0.829802, 0.069673, 40 | -0.007442, -0.022190, 1.029632 41 | }; 42 | 43 | static const float3x3 protanomaly07 = { 44 | 0.319627, 0.849633, -0.169261, 45 | 0.106241, 0.815969, 0.077790, 46 | -0.007025, -0.028051, 1.035076 47 | }; 48 | 49 | static const float3x3 protanomaly08 = { 50 | 0.259411, 0.923008, -0.182420, 51 | 0.110296, 0.804340, 0.085364, 52 | -0.006276, -0.034346, 1.040622 53 | }; 54 | 55 | static const float3x3 protanomaly09 = { 56 | 0.203876, 0.990338, -0.194214, 57 | 0.112975, 0.794542, 0.092483, 58 | -0.005222, -0.041043, 1.046265 59 | }; 60 | 61 | static const float3x3 protanomaly10 = { 62 | 0.152286, 1.052583, -0.204868, 63 | 0.114503, 0.786281, 0.099216, 64 | -0.003882, -0.048116, 1.051998 65 | }; 66 | 67 | static const float3x3 protanomalySeverities[11] = { 68 | protanomaly0, 69 | protanomaly01, 70 | protanomaly02, 71 | protanomaly03, 72 | protanomaly04, 73 | protanomaly05, 74 | protanomaly06, 75 | protanomaly07, 76 | protanomaly08, 77 | protanomaly09, 78 | protanomaly10 79 | }; -------------------------------------------------------------------------------- /Assets/Color Blindness/Protanomaly.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 51807775ef5e7904e834ae28d0614417 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Color Blindness/Tritanomaly.cginc: -------------------------------------------------------------------------------- 1 | static const float3x3 tritanomaly0 = { 2 | 1.0f, 0.0f, 0.0f, 3 | 0.0f, 1.0f, 0.0f, 4 | 0.0f, 0.0f, 1.0f 5 | }; 6 | 7 | static const float3x3 tritanomaly01 = { 8 | 0.926670, 0.092514, -0.019184, 9 | 0.021191, 0.964503, 0.014306, 10 | 0.008437, 0.054813, 0.936750 11 | }; 12 | 13 | static const float3x3 tritanomaly02 = { 14 | 0.895720, 0.133330, -0.029050, 15 | 0.029997, 0.945400, 0.024603, 16 | 0.013027, 0.104707, 0.882266 17 | }; 18 | 19 | static const float3x3 tritanomaly03 = { 20 | 0.905871, 0.127791, -0.033662, 21 | 0.026856, 0.941251, 0.031893, 22 | 0.013410, 0.148296, 0.838294 23 | }; 24 | 25 | static const float3x3 tritanomaly04 = { 26 | 0.948035, 0.089490, -0.037526, 27 | 0.014364, 0.946792, 0.038844, 28 | 0.010853, 0.193991, 0.795156 29 | }; 30 | 31 | static const float3x3 tritanomaly05 = { 32 | 1.017277, 0.027029, -0.044306, 33 | -0.006113, 0.958479, 0.047634, 34 | 0.006379, 0.248708, 0.744913 35 | }; 36 | 37 | static const float3x3 tritanomaly06 = { 38 | 1.104996, -0.046633, -0.058363, 39 | -0.032137, 0.971635, 0.060503, 40 | 0.001336, 0.317922, 0.680742 41 | }; 42 | 43 | static const float3x3 tritanomaly07 = { 44 | 1.193214, -0.109812, -0.083402, 45 | -0.058496, 0.979410, 0.079086, 46 | -0.002346, 0.403492, 0.598854 47 | }; 48 | 49 | static const float3x3 tritanomaly08 = { 50 | 1.257728, -0.139648, -0.118081, 51 | -0.078003, 0.975409, 0.102594, 52 | -0.003316, 0.501214, 0.502102 53 | }; 54 | 55 | static const float3x3 tritanomaly09 = { 56 | 1.278864, -0.125333, -0.153531, 57 | -0.084748, 0.957674, 0.127074, 58 | -0.000989, 0.601151, 0.399838 59 | }; 60 | 61 | static const float3x3 tritanomaly10 = { 62 | 1.255528, -0.076749, -0.178779, 63 | -0.078411, 0.930809, 0.147602, 64 | 0.004733, 0.691367, 0.303900 65 | }; 66 | 67 | static const float3x3 tritanomalySeverities[11] = { 68 | tritanomaly0, 69 | tritanomaly01, 70 | tritanomaly02, 71 | tritanomaly03, 72 | tritanomaly04, 73 | tritanomaly05, 74 | tritanomaly06, 75 | tritanomaly07, 76 | tritanomaly08, 77 | tritanomaly09, 78 | tritanomaly10 79 | }; -------------------------------------------------------------------------------- /Assets/Color Blindness/Tritanomaly.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 22bc532e261c8154a831e8c524510be0 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Color Correct/Color Correct.shader: -------------------------------------------------------------------------------- 1 | Shader "Joseph&Acerola/ColorCorrection" { 2 | Properties{ 3 | _MainTex("Texture", 2D) = "white" {} 4 | } 5 | 6 | SubShader{ 7 | 8 | Pass { 9 | CGPROGRAM 10 | #pragma vertex vp 11 | #pragma fragment fp 12 | 13 | #include "UnityCG.cginc" 14 | 15 | struct VertexData { 16 | float4 vertex : POSITION; 17 | float2 uv : TEXCOORD0; 18 | }; 19 | 20 | struct v2f { 21 | float2 uv : TEXCOORD0; 22 | float4 vertex : SV_POSITION; 23 | }; 24 | 25 | v2f vp(VertexData v) { 26 | v2f o; 27 | o.vertex = UnityObjectToClipPos(v.vertex); 28 | o.uv = v.uv; 29 | return o; 30 | } 31 | 32 | sampler2D _MainTex; 33 | float4 _ColorFilter; 34 | float3 _Exposure, _Contrast, _Brightness, _Saturation, _MidPoint; 35 | float _Temperature, _Tint; 36 | 37 | float luminance(float3 color) { 38 | return dot(color, float3(0.299f, 0.587f, 0.114f)); 39 | } 40 | 41 | //https://docs.unity3d.com/Packages/com.unity.shadergraph@6.9/manual/White-Balance-Node.html 42 | float3 WhiteBalance(float3 col, float temp, float tint) { 43 | float t1 = temp * 10.0f / 6.0f; 44 | float t2 = tint * 10.0f / 6.0f; 45 | 46 | float x = 0.31271 - t1 * (t1 < 0 ? 0.1 : 0.05); 47 | float standardIlluminantY = 2.87 * x - 3 * x * x - 0.27509507; 48 | float y = standardIlluminantY + t2 * 0.05; 49 | 50 | float3 w1 = float3(0.949237, 1.03542, 1.08728); 51 | 52 | float Y = 1; 53 | float X = Y * x / y; 54 | float Z = Y * (1 - x - y) / y; 55 | float L = 0.7328 * X + 0.4296 * Y - 0.1624 * Z; 56 | float M = -0.7036 * X + 1.6975 * Y + 0.0061 * Z; 57 | float S = 0.0030 * X + 0.0136 * Y + 0.9834 * Z; 58 | float3 w2 = float3(L, M, S); 59 | 60 | float3 balance = float3(w1.x / w2.x, w1.y / w2.y, w1.z / w2.z); 61 | 62 | float3x3 LIN_2_LMS_MAT = { 63 | 3.90405e-1, 5.49941e-1, 8.92632e-3, 64 | 7.08416e-2, 9.63172e-1, 1.35775e-3, 65 | 2.31082e-2, 1.28021e-1, 9.36245e-1 66 | }; 67 | 68 | float3x3 LMS_2_LIN_MAT = { 69 | 2.85847e+0, -1.62879e+0, -2.48910e-2, 70 | -2.10182e-1, 1.15820e+0, 3.24281e-4, 71 | -4.18120e-2, -1.18169e-1, 1.06867e+0 72 | }; 73 | 74 | float3 lms = mul(LIN_2_LMS_MAT, col); 75 | lms *= balance; 76 | return mul(LMS_2_LIN_MAT, lms); 77 | } 78 | 79 | float4 fp(v2f i) : SV_Target { 80 | float4 sample = tex2D(_MainTex, i.uv); 81 | float3 col = sample.rgb; 82 | 83 | col = max(0.0f, col * _Exposure); 84 | col = max(0.0f, WhiteBalance(col, _Temperature, _Tint)); 85 | col = max(0.0f, _Contrast * (col - _MidPoint) + _MidPoint + _Brightness); 86 | col = max(0.0f, col * _ColorFilter); 87 | col = max(0.0f, lerp(luminance(col), col, _Saturation)); 88 | 89 | return float4(col, sample.a); 90 | } 91 | ENDCG 92 | } 93 | } 94 | } -------------------------------------------------------------------------------- /Assets/Color Correct/Color Correct.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bc6b2afc6ae16084fb0d294835a729c0 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Color Correct/ColorCorrectPass.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class ColorCorrectPass : ScriptableRenderPass 8 | { 9 | static readonly string renderPassTag = "Color Correct"; 10 | 11 | private ColorCorrectVolume colorCorrectVolume; 12 | private Material colorCorrectMaterial; 13 | 14 | //private int testRTID; 15 | //private int sampleTimes; 16 | 17 | public ColorCorrectPass(RenderPassEvent evt, Shader blendModeshader) 18 | { 19 | renderPassEvent = evt; 20 | var shader = blendModeshader; 21 | if (shader == null) 22 | { 23 | Debug.LogError("No Shader"); 24 | return; 25 | } 26 | colorCorrectMaterial = CoreUtils.CreateEngineMaterial(blendModeshader); 27 | //this.sampleTimes = sampleTimes; 28 | } 29 | 30 | 31 | public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) 32 | { 33 | if (colorCorrectMaterial == null) 34 | { 35 | Debug.LogError("No Color Correct Material"); 36 | return; 37 | } 38 | 39 | if (!renderingData.cameraData.postProcessEnabled || renderingData.cameraData.cameraType == CameraType.SceneView) 40 | { 41 | //Debug.LogError("Post Processing in Camera not enabled"); 42 | return; 43 | } 44 | 45 | VolumeStack stack = VolumeManager.instance.stack; 46 | colorCorrectVolume = stack.GetComponent(); 47 | 48 | var cmd = CommandBufferPool.Get(renderPassTag); 49 | Render(cmd, ref renderingData); 50 | context.ExecuteCommandBuffer(cmd); 51 | 52 | CommandBufferPool.Release(cmd); 53 | } 54 | 55 | void Render(CommandBuffer cmd, ref RenderingData renderingData) 56 | { 57 | if (colorCorrectVolume.IsActive() == false) return; 58 | colorCorrectVolume.load(colorCorrectMaterial, ref renderingData); 59 | 60 | var source = renderingData.cameraData.renderer.cameraColorTarget; 61 | 62 | cmd.Blit(source, source, colorCorrectMaterial); 63 | } 64 | 65 | } -------------------------------------------------------------------------------- /Assets/Color Correct/ColorCorrectPass.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 06a2b59d0bf0ca749b6bde0aeac7f182 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Color Correct/ColorCorrectRenderFeature.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class ColorCorrectRenderFeature : ScriptableRendererFeature 8 | { 9 | [System.Serializable] 10 | public class Settings 11 | { 12 | public RenderPassEvent renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing; 13 | public Shader shader; 14 | } 15 | public Settings settings = new Settings(); 16 | 17 | ColorCorrectPass m_ColorCorrectPass; 18 | private void OnEnable() 19 | { 20 | settings.shader = Shader.Find("Joseph&Acerola/ColorCorrection"); 21 | } 22 | public override void Create() 23 | { 24 | this.name = "Color Correct Pass"; 25 | if (settings.shader == null) 26 | { 27 | Debug.LogWarning("No Shader"); 28 | return; 29 | } 30 | m_ColorCorrectPass = new ColorCorrectPass(settings.renderPassEvent, settings.shader); 31 | } 32 | 33 | public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) 34 | { 35 | renderer.EnqueuePass(m_ColorCorrectPass); 36 | } 37 | } -------------------------------------------------------------------------------- /Assets/Color Correct/ColorCorrectRenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 347153b313fdc3f45939bf572f0567be 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Color Correct/ColorCorrectVolume.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | using UnityEngine.Rendering; 6 | using UnityEngine.Rendering.Universal; 7 | 8 | [Serializable, VolumeComponentMenu("Joseph_Acerola/Custom Color Correct")] 9 | public class ColorCorrectVolume : VolumeComponent, IPostProcessComponent 10 | { 11 | public ColorParameter _colorFilter = new ColorParameter(Color.white, true, true, true, true); 12 | public Vector3Parameter _exposure = new Vector3Parameter(Vector3.one, true); 13 | public FloatParameter _temperature = new ClampedFloatParameter(0f, -100f, 100f, true); 14 | public FloatParameter _tint = new ClampedFloatParameter(0f, -100f, 100f, true); 15 | public Vector3Parameter _contrast = new Vector3Parameter(Vector3.one, true); 16 | public Vector3Parameter _brightness = new Vector3Parameter(Vector3.zero, true); 17 | public Vector3Parameter _saturation = new Vector3Parameter(Vector3.one, true); 18 | public Vector3Parameter _linearMidPoint = new Vector3Parameter(new Vector3(0.5f, 0.5f, 0.5f), true); 19 | 20 | public void load(Material material, ref RenderingData renderingData) 21 | { 22 | material.SetVector("_Exposure", _exposure.value); 23 | material.SetVector("_Contrast", _contrast.value); 24 | material.SetVector("_MidPoint", _linearMidPoint.value); 25 | material.SetVector("_Brightness", _brightness.value); 26 | material.SetVector("_ColorFilter", _colorFilter.value); 27 | material.SetVector("_Saturation", _saturation.value); 28 | material.SetFloat("_Temperature", _temperature.value / 100.0f); 29 | material.SetFloat("_Tint", _tint.value / 100.0f); 30 | } 31 | 32 | public bool IsActive() => true; 33 | public bool IsTileCompatible() => false; 34 | } -------------------------------------------------------------------------------- /Assets/Color Correct/ColorCorrectVolume.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ca077b8947f162c47a08353ab081bf6e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Color Correct/Gamma.shader: -------------------------------------------------------------------------------- 1 | Shader "Joseph&Acerola/Gamma" { 2 | Properties{ 3 | _MainTex("Texture", 2D) = "white" {} 4 | } 5 | 6 | SubShader{ 7 | 8 | Pass { 9 | CGPROGRAM 10 | #pragma vertex vp 11 | #pragma fragment fp 12 | 13 | #include "UnityCG.cginc" 14 | 15 | struct VertexData { 16 | float4 vertex : POSITION; 17 | float2 uv : TEXCOORD0; 18 | }; 19 | 20 | struct v2f { 21 | float2 uv : TEXCOORD0; 22 | float4 vertex : SV_POSITION; 23 | }; 24 | 25 | v2f vp(VertexData v) { 26 | v2f o; 27 | o.vertex = UnityObjectToClipPos(v.vertex); 28 | o.uv = v.uv; 29 | return o; 30 | } 31 | 32 | sampler2D _MainTex; 33 | float _Gamma; 34 | 35 | fixed4 fp(v2f i) : SV_Target { 36 | return float4(pow(tex2D(_MainTex, i.uv).rgb, _Gamma), 1.0f); 37 | } 38 | ENDCG 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /Assets/Color Correct/Gamma.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b796a0e1ab8487b43a41ca0af7592b9f 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Color Correct/GammaPass.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class GammaPass : ScriptableRenderPass 8 | { 9 | static readonly string renderPassTag = "Gamma Correct"; 10 | 11 | private GammaVolume GammaVolume; 12 | private Material GammaMaterial; 13 | 14 | public GammaPass(RenderPassEvent evt, Shader Gammashader) 15 | { 16 | renderPassEvent = evt; 17 | var shader = Gammashader; 18 | if (shader == null) 19 | { 20 | Debug.LogError("No Shader"); 21 | return; 22 | } 23 | GammaMaterial = CoreUtils.CreateEngineMaterial(Gammashader); 24 | } 25 | 26 | 27 | public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) 28 | { 29 | if (GammaMaterial == null) 30 | { 31 | Debug.LogError("No Gamma Material"); 32 | return; 33 | } 34 | 35 | if (!renderingData.cameraData.postProcessEnabled || renderingData.cameraData.cameraType == CameraType.SceneView) 36 | { 37 | //Debug.LogError("Post Processing in Camera not enabled"); 38 | return; 39 | } 40 | 41 | VolumeStack stack = VolumeManager.instance.stack; 42 | GammaVolume = stack.GetComponent(); 43 | 44 | var cmd = CommandBufferPool.Get(renderPassTag); 45 | Render(cmd, ref renderingData); 46 | context.ExecuteCommandBuffer(cmd); 47 | 48 | CommandBufferPool.Release(cmd); 49 | } 50 | 51 | void Render(CommandBuffer cmd, ref RenderingData renderingData) 52 | { 53 | if (GammaVolume.IsActive() == false) return; 54 | GammaVolume.load(GammaMaterial, ref renderingData); 55 | 56 | var source = renderingData.cameraData.renderer.cameraColorTarget; 57 | 58 | cmd.Blit(source, source, GammaMaterial); 59 | } 60 | 61 | } -------------------------------------------------------------------------------- /Assets/Color Correct/GammaPass.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ef68db863d5128b4194b4a098fe11a02 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Color Correct/GammaRenderFeature.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class GammaRenderFeature : ScriptableRendererFeature 8 | { 9 | [System.Serializable] 10 | public class Settings 11 | { 12 | public RenderPassEvent renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing; 13 | public Shader shader; 14 | } 15 | public Settings settings = new Settings(); 16 | 17 | GammaPass m_GammaPass; 18 | private void OnEnable() 19 | { 20 | settings.shader = Shader.Find("Joseph&Acerola/Gamma"); 21 | } 22 | public override void Create() 23 | { 24 | this.name = "Gamma Correct Pass"; 25 | if (settings.shader == null) 26 | { 27 | Debug.LogWarning("No Shader"); 28 | return; 29 | } 30 | m_GammaPass = new GammaPass(settings.renderPassEvent, settings.shader); 31 | } 32 | 33 | public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) 34 | { 35 | renderer.EnqueuePass(m_GammaPass); 36 | } 37 | } -------------------------------------------------------------------------------- /Assets/Color Correct/GammaRenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ea23de4e8bd704a489dc837871b2d03a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Color Correct/GammaVolume.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | using UnityEngine.Rendering; 6 | using UnityEngine.Rendering.Universal; 7 | 8 | [Serializable, VolumeComponentMenu("Joseph_Acerola/Custom Gamma Correct")] 9 | public class GammaVolume : VolumeComponent, IPostProcessComponent 10 | { 11 | public FloatParameter _gamma = new ClampedFloatParameter(1f, 0f, 10f, true); 12 | 13 | public void load(Material material, ref RenderingData renderingData) 14 | { 15 | material.SetFloat("_Gamma", _gamma.value); 16 | } 17 | 18 | public bool IsActive() => true; 19 | public bool IsTileCompatible() => false; 20 | } -------------------------------------------------------------------------------- /Assets/Color Correct/GammaVolume.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0e1db7207265d594f88f758ecda9a9c9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Color Correct/Hue Shift.shader: -------------------------------------------------------------------------------- 1 | Shader "Joseph&Acerola/HueShift" { 2 | Properties{ 3 | _MainTex("Texture", 2D) = "white" {} 4 | } 5 | 6 | SubShader{ 7 | 8 | Pass { 9 | CGPROGRAM 10 | #pragma vertex vp 11 | #pragma fragment fp 12 | 13 | #include "UnityCG.cginc" 14 | 15 | struct VertexData { 16 | float4 vertex : POSITION; 17 | float2 uv : TEXCOORD0; 18 | }; 19 | 20 | struct v2f { 21 | float2 uv : TEXCOORD0; 22 | float4 vertex : SV_POSITION; 23 | }; 24 | 25 | v2f vp(VertexData v) { 26 | v2f o; 27 | o.vertex = UnityObjectToClipPos(v.vertex); 28 | o.uv = v.uv; 29 | return o; 30 | } 31 | 32 | sampler2D _MainTex; 33 | float _HueShift; 34 | 35 | 36 | // https://www.shadertoy.com/view/MsjXRt 37 | float4 HueShift(float3 col, float shift) { 38 | float3 P = 0.55735f * dot(0.55735, col); 39 | float3 U = col - P; 40 | float3 V = cross(0.55735, U); 41 | col = U * cos(shift * 6.2832) + V * sin(shift * 6.2832) + P; 42 | 43 | return float4(col, 1.0f); 44 | } 45 | 46 | float4 fp(v2f i) : SV_Target { 47 | float4 col = tex2D(_MainTex, i.uv); 48 | 49 | return HueShift(col, _HueShift); 50 | } 51 | ENDCG 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /Assets/Color Correct/Hue Shift.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b4be4bf86abb2d24aa0fc5962943bd44 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Color Correct/HueShiftPass.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class HueShiftPass : ScriptableRenderPass 8 | { 9 | static readonly string renderPassTag = "Hue Shift Correct"; 10 | 11 | private HueShiftVolume HueShiftVolume; 12 | private Material HueShiftMaterial; 13 | 14 | //private int testRTID; 15 | //private int sampleTimes; 16 | 17 | public HueShiftPass(RenderPassEvent evt, Shader Gammashader) 18 | { 19 | renderPassEvent = evt; 20 | var shader = Gammashader; 21 | if (shader == null) 22 | { 23 | Debug.LogError("No Shader"); 24 | return; 25 | } 26 | HueShiftMaterial = CoreUtils.CreateEngineMaterial(Gammashader); 27 | //this.sampleTimes = sampleTimes; 28 | } 29 | 30 | 31 | public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) 32 | { 33 | if (HueShiftMaterial == null) 34 | { 35 | Debug.LogError("No Hue Shift Material"); 36 | return; 37 | } 38 | 39 | if (!renderingData.cameraData.postProcessEnabled || renderingData.cameraData.cameraType == CameraType.SceneView) 40 | { 41 | //Debug.LogError("Post Processing in Camera not enabled"); 42 | return; 43 | } 44 | 45 | VolumeStack stack = VolumeManager.instance.stack; 46 | HueShiftVolume = stack.GetComponent(); 47 | 48 | var cmd = CommandBufferPool.Get(renderPassTag); 49 | Render(cmd, ref renderingData); 50 | context.ExecuteCommandBuffer(cmd); 51 | 52 | CommandBufferPool.Release(cmd); 53 | } 54 | 55 | void Render(CommandBuffer cmd, ref RenderingData renderingData) 56 | { 57 | if (HueShiftVolume.IsActive() == false) return; 58 | HueShiftVolume.load(HueShiftMaterial, ref renderingData); 59 | 60 | var source = renderingData.cameraData.renderer.cameraColorTarget; 61 | 62 | cmd.Blit(source, source, HueShiftMaterial); 63 | } 64 | 65 | } -------------------------------------------------------------------------------- /Assets/Color Correct/HueShiftPass.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: afc19b0f0c23a8a4d8903ad979451989 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Color Correct/HueShiftRenderFeature.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class HueShiftRenderFeature : ScriptableRendererFeature 8 | { 9 | [System.Serializable] 10 | public class Settings 11 | { 12 | public RenderPassEvent renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing; 13 | public Shader shader; 14 | } 15 | public Settings settings = new Settings(); 16 | 17 | HueShiftPass m_HueShiftPass; 18 | private void OnEnable() 19 | { 20 | settings.shader = Shader.Find("Joseph&Acerola/HueShift"); 21 | } 22 | public override void Create() 23 | { 24 | this.name = "Hue Shift Pass"; 25 | if (settings.shader == null) 26 | { 27 | Debug.LogWarning("No Shader"); 28 | return; 29 | } 30 | m_HueShiftPass = new HueShiftPass(settings.renderPassEvent, settings.shader); 31 | } 32 | 33 | public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) 34 | { 35 | renderer.EnqueuePass(m_HueShiftPass); 36 | } 37 | } -------------------------------------------------------------------------------- /Assets/Color Correct/HueShiftRenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a4e4aa8b00a39264ca6d002dbe6a60d2 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Color Correct/HueShiftVolume.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | using UnityEngine.Rendering; 6 | using UnityEngine.Rendering.Universal; 7 | 8 | [Serializable, VolumeComponentMenu("Joseph_Acerola/Custom Hue Shift Correct")] 9 | public class HueShiftVolume : VolumeComponent, IPostProcessComponent 10 | { 11 | public FloatParameter _shift = new ClampedFloatParameter(0f, 0f, 1f, true); 12 | 13 | public void load(Material material, ref RenderingData renderingData) 14 | { 15 | material.SetFloat("_HueShift", _shift.value); 16 | } 17 | 18 | public bool IsActive() => true; 19 | public bool IsTileCompatible() => false; 20 | } -------------------------------------------------------------------------------- /Assets/Color Correct/HueShiftVolume.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d1c7c01a689d60143aab251588fb023f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Difference Of Gaussian/DifferenceOfGaussians.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e97e3b8e8e4166e4a84bc344a37ac2c2 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Difference Of Gaussian/DifferenceOfGaussiansPass.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class DifferenceOfGaussiansPass : ScriptableRenderPass 8 | { 9 | static readonly string renderPassTag = "DoG"; 10 | 11 | private DifferenceOfGaussiansVolume DifferenceOfGaussiansVolume; 12 | private Material DifferenceOfGaussiansMaterial; 13 | 14 | public DifferenceOfGaussiansPass(RenderPassEvent evt, Shader DifferenceOfGaussiansshader) 15 | { 16 | renderPassEvent = evt; 17 | var shader = DifferenceOfGaussiansshader; 18 | if (shader == null) 19 | { 20 | Debug.LogError("No Shader"); 21 | return; 22 | } 23 | DifferenceOfGaussiansMaterial = CoreUtils.CreateEngineMaterial(DifferenceOfGaussiansshader); 24 | } 25 | 26 | 27 | public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) 28 | { 29 | if (DifferenceOfGaussiansMaterial == null) 30 | { 31 | Debug.LogError("No Difference Of Gaussians Material"); 32 | return; 33 | } 34 | 35 | if (!renderingData.cameraData.postProcessEnabled) 36 | { 37 | //Debug.LogError("Post Processing in Camera not enabled"); 38 | return; 39 | } 40 | 41 | VolumeStack stack = VolumeManager.instance.stack; 42 | DifferenceOfGaussiansVolume = stack.GetComponent(); 43 | 44 | var cmd = CommandBufferPool.Get(renderPassTag); 45 | Render(cmd, ref renderingData); 46 | context.ExecuteCommandBuffer(cmd); 47 | 48 | CommandBufferPool.Release(cmd); 49 | } 50 | 51 | void Render(CommandBuffer cmd, ref RenderingData renderingData) 52 | { 53 | if (DifferenceOfGaussiansVolume.IsActive() == false) return; 54 | DifferenceOfGaussiansVolume.load(DifferenceOfGaussiansMaterial, ref renderingData); 55 | 56 | var source = renderingData.cameraData.renderer.cameraColorTarget; 57 | int width = renderingData.cameraData.cameraTargetDescriptor.width; 58 | int height = renderingData.cameraData.cameraTargetDescriptor.height; 59 | 60 | var gaussian1 = RenderTexture.GetTemporary(width, height, 0, RenderTextureFormat.RG32); 61 | cmd.Blit(source, gaussian1, DifferenceOfGaussiansMaterial, 0); 62 | var gaussian2 = RenderTexture.GetTemporary(width, height, 0, RenderTextureFormat.RG32); 63 | cmd.Blit(gaussian1, gaussian2, DifferenceOfGaussiansMaterial, 1); 64 | 65 | DifferenceOfGaussiansMaterial.SetTexture("_GaussianTex", gaussian2); 66 | 67 | cmd.Blit(source, source, DifferenceOfGaussiansMaterial, 2); 68 | RenderTexture.ReleaseTemporary(gaussian1); 69 | RenderTexture.ReleaseTemporary(gaussian2); 70 | } 71 | 72 | } -------------------------------------------------------------------------------- /Assets/Difference Of Gaussian/DifferenceOfGaussiansPass.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: db07a2ed2b1e1f240b1b570ef51d84df 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Difference Of Gaussian/DifferenceOfGaussiansRenderFeature.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class DifferenceOfGaussiansRenderFeature : ScriptableRendererFeature 8 | { 9 | [System.Serializable] 10 | public class Settings 11 | { 12 | public RenderPassEvent renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing; 13 | public Shader shader; 14 | } 15 | public Settings settings = new Settings(); 16 | 17 | DifferenceOfGaussiansPass m_DifferenceOfGaussiansPass; 18 | private void OnEnable() 19 | { 20 | settings.shader = Shader.Find("Joseph&Acerola/DifferenceOfGaussians"); 21 | } 22 | public override void Create() 23 | { 24 | this.name = "DoG Pass"; 25 | if (settings.shader == null) 26 | { 27 | Debug.LogWarning("No Shader"); 28 | return; 29 | } 30 | m_DifferenceOfGaussiansPass = new DifferenceOfGaussiansPass(settings.renderPassEvent, settings.shader); 31 | } 32 | 33 | public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) 34 | { 35 | renderer.EnqueuePass(m_DifferenceOfGaussiansPass); 36 | } 37 | } -------------------------------------------------------------------------------- /Assets/Difference Of Gaussian/DifferenceOfGaussiansRenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b9e7c22379db53d498e4db4097b3775e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Difference Of Gaussian/DifferenceOfGaussiansVolume.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | using UnityEngine.Rendering; 6 | using UnityEngine.Rendering.Universal; 7 | 8 | [Serializable, VolumeComponentMenu("Joseph_Acerola/Custom Difference Of Gaussian")] 9 | public class DifferenceOfGaussiansVolume : VolumeComponent, IPostProcessComponent 10 | { 11 | public ClampedIntParameter _gaussianKernelSize = new ClampedIntParameter(5,1,10, true); 12 | 13 | public ClampedFloatParameter _stdev = new ClampedFloatParameter(2.0f,0.1f,5f,true); 14 | 15 | public ClampedFloatParameter _stdevScale = new ClampedFloatParameter(1.6f,0.1f,5f,true); 16 | 17 | public ClampedFloatParameter _tau = new ClampedFloatParameter(1.0f,0.01f,5.0f,true); 18 | 19 | public BoolParameter _thresholding = new BoolParameter(true,true); 20 | 21 | public BoolParameter _tanh = new BoolParameter(false,true); 22 | 23 | public ClampedFloatParameter _phi = new ClampedFloatParameter(1.0f,0.01f, 100f,true); 24 | 25 | public ClampedFloatParameter _threshold = new ClampedFloatParameter(0.005f,-1f,1f,true); 26 | 27 | public BoolParameter _invert = new BoolParameter(false, true); 28 | 29 | public void load(Material material, ref RenderingData renderingData) 30 | { 31 | material.SetInt("_GaussianKernelSize", _gaussianKernelSize.value); 32 | material.SetFloat("_Sigma", _stdev.value); 33 | material.SetFloat("_K", _stdevScale.value); 34 | material.SetFloat("_Tau", _tau.value); 35 | material.SetFloat("_Phi", _phi.value); 36 | material.SetFloat("_Threshold", _threshold.value); 37 | material.SetInt("_Thresholding", _thresholding.value ? 1 : 0); 38 | material.SetInt("_Invert", _invert.value ? 1 : 0); 39 | material.SetInt("_Tanh", _tanh.value ? 1 : 0); 40 | } 41 | 42 | public bool IsActive() => true; 43 | public bool IsTileCompatible() => false; 44 | } -------------------------------------------------------------------------------- /Assets/Difference Of Gaussian/DifferenceOfGaussiansVolume.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 014c36de9c0665e439e043007e93e396 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Difference Of Gaussian/ExtendedDOG.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: af7e94d688cd47148955789e6b96c404 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Difference Of Gaussian/ExtendedDOGPass.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 05b47c499e2d8c944af0aa223ca3fb20 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Difference Of Gaussian/ExtendedDOGRenderFeature.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class ExtendedDOGFeature : ScriptableRendererFeature 8 | { 9 | [System.Serializable] 10 | public class Settings 11 | { 12 | public RenderPassEvent renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing; 13 | public Shader shader; 14 | } 15 | public Settings settings = new Settings(); 16 | 17 | ExtendedDoGPass m_ExtendedDoGPass; 18 | private void OnEnable() 19 | { 20 | settings.shader = Shader.Find("Joseph&Acerola/ExtendedDoG"); 21 | } 22 | public override void Create() 23 | { 24 | this.name = "Extended DoG Pass"; 25 | if (settings.shader == null) 26 | { 27 | Debug.LogWarning("No Shader"); 28 | return; 29 | } 30 | m_ExtendedDoGPass = new ExtendedDoGPass(settings.renderPassEvent, settings.shader); 31 | } 32 | 33 | public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) 34 | { 35 | renderer.EnqueuePass(m_ExtendedDoGPass); 36 | } 37 | } -------------------------------------------------------------------------------- /Assets/Difference Of Gaussian/ExtendedDOGRenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a9ad59076ac96994984b23de6b80eb3f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Difference Of Gaussian/ExtendedDOGVolume.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 53e99cc6c1fec264abd948df9c11756d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Dithering/Dithering.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6757b42a776877743a62f41d9f8b99a2 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Dithering/DitheringPass.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9e9ec9a24b5cb6641af1534a4b67fd87 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Dithering/DitheringRendererFeature.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering.Universal; 5 | 6 | public class DitheringRendererFeature : ScriptableRendererFeature 7 | { 8 | [System.Serializable] 9 | public class Settings 10 | { 11 | public RenderPassEvent RenderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing; 12 | public Shader shader; 13 | } 14 | 15 | public Settings settings = new Settings(); 16 | 17 | DitheringPass DitheringPass; 18 | private void OnEnable() 19 | { 20 | settings.shader = Shader.Find("Joseph&Acerola/Dither"); 21 | } 22 | public override void Create() 23 | { 24 | this.name = "Dithering Pass"; 25 | if(settings.shader == null) 26 | { 27 | Debug.LogWarning("No Shader"); 28 | return; 29 | } 30 | DitheringPass = new DitheringPass(settings.RenderPassEvent, settings.shader); 31 | } 32 | 33 | public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) 34 | { 35 | renderer.EnqueuePass(DitheringPass); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Assets/Dithering/DitheringRendererFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2eb7af3b8b40c7340a42e8aa896a03ea 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Dithering/DitheringVolume.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | [VolumeComponentMenu("Joseph_Acerola/Custom Dithering")] 8 | public class DitheringVolume : VolumeComponent, IPostProcessComponent 9 | { 10 | public ClampedFloatParameter _spread = new ClampedFloatParameter(0.5f, 0.0f, 1.0f, true); 11 | 12 | public ClampedIntParameter _redColorCount = new ClampedIntParameter(2, 2, 16, true); 13 | public ClampedIntParameter _greenColorCount = new ClampedIntParameter(2, 2, 16, true); 14 | public ClampedIntParameter _blueColorCount = new ClampedIntParameter(2, 2, 16, true); 15 | 16 | public ClampedIntParameter _bayerLevel = new ClampedIntParameter(0, 0, 2, true); 17 | public ClampedIntParameter _downSamples = new ClampedIntParameter(0, 0, 8, true); 18 | 19 | public void load(Material material, ref RenderingData renderingData) 20 | { 21 | material.SetFloat("_Spread", _spread.value); 22 | material.SetInt("_RedColorCount", _redColorCount.value); 23 | material.SetInt("_GreenColorCount", _greenColorCount.value); 24 | material.SetInt("_BlueColorCount", _blueColorCount.value); 25 | material.SetInt("_BayerLevel", _bayerLevel.value); 26 | } 27 | public bool IsActive() => true; 28 | public bool IsTileCompatible() => false; 29 | } 30 | -------------------------------------------------------------------------------- /Assets/Dithering/DitheringVolume.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6b7baaabdc0cb99459834632167eefc3 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Fog/Fog.shader: -------------------------------------------------------------------------------- 1 | Shader "Joseph&Acerola/SSFog" { 2 | Properties{ 3 | _MainTex("Texture", 2D) = "white" {} 4 | } 5 | 6 | SubShader{ 7 | 8 | Pass { 9 | CGPROGRAM 10 | #pragma vertex vp 11 | #pragma fragment fp 12 | 13 | #include "UnityCG.cginc" 14 | 15 | struct VertexData { 16 | float4 vertex : POSITION; 17 | float2 uv : TEXCOORD0; 18 | }; 19 | 20 | struct v2f { 21 | float2 uv : TEXCOORD0; 22 | float4 vertex : SV_POSITION; 23 | }; 24 | 25 | v2f vp(VertexData v) { 26 | v2f o; 27 | o.vertex = UnityObjectToClipPos(v.vertex); 28 | o.uv = v.uv; 29 | return o; 30 | } 31 | 32 | sampler2D _MainTex, _CameraDepthTexture; 33 | float4 _FogColor; 34 | float _FogDensity, _FogOffset; 35 | 36 | float4 fp(v2f i) : SV_Target { 37 | int x, y; 38 | float4 col = tex2D(_MainTex, i.uv); 39 | float depth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, i.uv); 40 | depth = Linear01Depth(depth); 41 | 42 | float viewDistance = depth * _ProjectionParams.z; 43 | 44 | float fogFactor = (_FogDensity / sqrt(log(2))) * max(0.0f, viewDistance - _FogOffset); 45 | fogFactor = exp2(-fogFactor * fogFactor); 46 | 47 | float4 fogOutput = lerp(_FogColor, col, saturate(fogFactor)); 48 | 49 | return fogOutput; 50 | } 51 | ENDCG 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /Assets/Fog/Fog.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1691bcb7ada8dbe4ea314fb578ff5468 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Fog/FogPass.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class FogPass : ScriptableRenderPass 8 | { 9 | static readonly string renderPassTag = "Fog"; 10 | 11 | private FogVolume fogVolume; 12 | private Material fogMaterial; 13 | 14 | public FogPass(RenderPassEvent evt, Shader blendModeshader) 15 | { 16 | renderPassEvent = evt; 17 | var shader = blendModeshader; 18 | if (shader == null) 19 | { 20 | Debug.LogError("No Shader"); 21 | return; 22 | } 23 | fogMaterial = CoreUtils.CreateEngineMaterial(blendModeshader); 24 | } 25 | 26 | 27 | public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) 28 | { 29 | if (fogMaterial == null) 30 | { 31 | Debug.LogError("No Fog Material"); 32 | return; 33 | } 34 | 35 | if (!renderingData.cameraData.postProcessEnabled || renderingData.cameraData.cameraType == CameraType.SceneView) 36 | { 37 | //Debug.LogError("Post Processing in Camera not enabled"); 38 | return; 39 | } 40 | 41 | VolumeStack stack = VolumeManager.instance.stack; 42 | fogVolume = stack.GetComponent(); 43 | 44 | var cmd = CommandBufferPool.Get(renderPassTag); 45 | Render(cmd, ref renderingData); 46 | context.ExecuteCommandBuffer(cmd); 47 | 48 | CommandBufferPool.Release(cmd); 49 | } 50 | 51 | void Render(CommandBuffer cmd, ref RenderingData renderingData) 52 | { 53 | if (fogVolume.IsActive() == false) return; 54 | fogVolume.load(fogMaterial, ref renderingData); 55 | 56 | var source = renderingData.cameraData.renderer.cameraColorTarget; 57 | 58 | cmd.Blit(source, source, fogMaterial); 59 | } 60 | 61 | } -------------------------------------------------------------------------------- /Assets/Fog/FogPass.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ff9a01b16b82959429ca20019f67fb6c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Fog/FogRenderFeature.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class FogRenderFeature : ScriptableRendererFeature 8 | { 9 | [System.Serializable] 10 | public class Settings 11 | { 12 | public RenderPassEvent renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing; 13 | public Shader shader; 14 | } 15 | public Settings settings = new Settings(); 16 | 17 | FogPass m_FogPass; 18 | private void OnEnable() 19 | { 20 | settings.shader = Shader.Find("Joseph&Acerola/SSFog"); 21 | } 22 | public override void Create() 23 | { 24 | this.name = "Fog Pass"; 25 | if (settings.shader == null) 26 | { 27 | Debug.LogWarning("No Shader"); 28 | return; 29 | } 30 | m_FogPass = new FogPass(settings.renderPassEvent, settings.shader); 31 | } 32 | 33 | public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) 34 | { 35 | renderer.EnqueuePass(m_FogPass); 36 | } 37 | } -------------------------------------------------------------------------------- /Assets/Fog/FogRenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 472cb1b3dd330d64793b79f063400e96 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Fog/FogVolume.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | using UnityEngine.Rendering; 6 | using UnityEngine.Rendering.Universal; 7 | 8 | [Serializable, VolumeComponentMenu("Joseph_Acerola/Custom Fog")] 9 | public class FogVolume : VolumeComponent, IPostProcessComponent 10 | { 11 | public ColorParameter _fogColor = new ColorParameter(Color.white, true, true, true, true); 12 | public FloatParameter _fogDensity = new ClampedFloatParameter(0f, 0f, 1f, true); 13 | public FloatParameter _fogOffset = new ClampedFloatParameter(0f, 0f, 100f, true); 14 | 15 | public void load(Material material, ref RenderingData renderingData) 16 | { 17 | material.SetVector("_FogColor", _fogColor.value); 18 | material.SetFloat("_FogDensity", _fogDensity.value); 19 | material.SetFloat("_FogOffset", _fogOffset.value); 20 | } 21 | 22 | public bool IsActive() => true; 23 | public bool IsTileCompatible() => false; 24 | } -------------------------------------------------------------------------------- /Assets/Fog/FogVolume.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f8943a1254475bd43ba652227e9a00c5 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Fog/GradientFog.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c26b55e3c258a6b44b14a36b63e4e2a2 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Halftone/Halftone.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 55a32cb25d8ec804f9d7400129ce1ee6 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Halftone/HalftonePass.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class HalftonePass : ScriptableRenderPass 8 | { 9 | static readonly string renderPassTag = "Half Tone"; 10 | 11 | private HalftoneVolume HalftoneVolume; 12 | private Material HalftoneMaterial; 13 | 14 | public HalftonePass(RenderPassEvent evt, Shader halfToneshader) 15 | { 16 | renderPassEvent = evt; 17 | var shader = halfToneshader; 18 | if (shader == null) 19 | { 20 | Debug.LogError("No Shader"); 21 | return; 22 | } 23 | HalftoneMaterial = CoreUtils.CreateEngineMaterial(halfToneshader); 24 | } 25 | 26 | 27 | public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) 28 | { 29 | if (HalftoneMaterial == null) 30 | { 31 | Debug.LogError("No Half Tone Material"); 32 | return; 33 | } 34 | 35 | if (!renderingData.cameraData.postProcessEnabled || renderingData.cameraData.cameraType == CameraType.SceneView) 36 | { 37 | //Debug.LogError("Post Processing in Camera not enabled"); 38 | return; 39 | } 40 | 41 | VolumeStack stack = VolumeManager.instance.stack; 42 | HalftoneVolume = stack.GetComponent(); 43 | 44 | var cmd = CommandBufferPool.Get(renderPassTag); 45 | Render(cmd, ref renderingData); 46 | context.ExecuteCommandBuffer(cmd); 47 | 48 | CommandBufferPool.Release(cmd); 49 | } 50 | 51 | void Render(CommandBuffer cmd, ref RenderingData renderingData) 52 | { 53 | if (HalftoneVolume.IsActive() == false) return; 54 | HalftoneVolume.load(HalftoneMaterial, ref renderingData); 55 | 56 | int width = renderingData.cameraData.cameraTargetDescriptor.width; 57 | int height = renderingData.cameraData.cameraTargetDescriptor.height; 58 | 59 | var source = renderingData.cameraData.renderer.cameraColorTarget; 60 | var cmyk = RenderTexture.GetTemporary(width, height, 0, renderingData.cameraData.cameraTargetDescriptor.colorFormat); 61 | 62 | cmd.Blit(source, cmyk, HalftoneMaterial, 0); 63 | cmd.Blit(cmyk, source, HalftoneMaterial, 1); 64 | RenderTexture.ReleaseTemporary(cmyk); 65 | } 66 | 67 | } -------------------------------------------------------------------------------- /Assets/Halftone/HalftonePass.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: be380f59acd48764bb4eeb83634a543a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Halftone/HalftoneRenderFeature.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class HalftoneRenderFeature : ScriptableRendererFeature 8 | { 9 | [System.Serializable] 10 | public class Settings 11 | { 12 | public RenderPassEvent renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing; 13 | public Shader shader; 14 | } 15 | public Settings settings = new Settings(); 16 | 17 | HalftonePass m_HalftonePass; 18 | private void OnEnable() 19 | { 20 | settings.shader = Shader.Find("Joseph&Acerola/Halftone"); 21 | } 22 | public override void Create() 23 | { 24 | this.name = "Half Tone Pass"; 25 | if (settings.shader == null) 26 | { 27 | Debug.LogWarning("No Shader"); 28 | return; 29 | } 30 | m_HalftonePass = new HalftonePass(settings.renderPassEvent, settings.shader); 31 | } 32 | 33 | public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) 34 | { 35 | renderer.EnqueuePass(m_HalftonePass); 36 | } 37 | } -------------------------------------------------------------------------------- /Assets/Halftone/HalftoneRenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a4e009efb061b43448ea9b85e22af3ae 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Halftone/HalftoneVolume.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | using UnityEngine.Rendering; 6 | using UnityEngine.Rendering.Universal; 7 | 8 | [Serializable, VolumeComponentMenu("Joseph_Acerola/Custom Half Tone")] 9 | public class HalftoneVolume : VolumeComponent, IPostProcessComponent 10 | { 11 | [Header("Cyan")] 12 | public BoolParameter _printCyan = new BoolParameter(true, true); 13 | public ClampedFloatParameter _cyanDotSize = new ClampedFloatParameter(1.0f,0f,3f,true); 14 | public ClampedFloatParameter _cyanBias = new ClampedFloatParameter(0.0f,-1f,1f,true); 15 | public Vector2Parameter _cyanOffset = new Vector2Parameter(Vector2.zero, true); 16 | 17 | [Header("Magenta")] 18 | public BoolParameter _printMagenta = new BoolParameter(true,true); 19 | public ClampedFloatParameter _magentaDotSize = new ClampedFloatParameter(1.0f, 0f, 3f, true); 20 | public ClampedFloatParameter _magentaBias = new ClampedFloatParameter(0.0f, -1f, 1f, true); 21 | public Vector2Parameter _magentaOffset = new Vector2Parameter(Vector2.zero, true); 22 | 23 | [Header("Yellow")] 24 | public BoolParameter _printYellow = new BoolParameter(true, true); 25 | public ClampedFloatParameter _yellowDotSize = new ClampedFloatParameter(1.0f,0f,3f, true); 26 | public ClampedFloatParameter _yellowBias = new ClampedFloatParameter(0.0f,-1f,1f,true); 27 | public Vector2Parameter _yellowOffset = new Vector2Parameter(Vector2.zero,true); 28 | 29 | [Header("Black")] 30 | public BoolParameter _printBlack = new BoolParameter(false,true); 31 | public ClampedFloatParameter _blackDotSize = new ClampedFloatParameter(1.0f,0f,3f, true); 32 | public ClampedFloatParameter _blackBias = new ClampedFloatParameter(0.0f,-1f,1f, true); 33 | public Vector2Parameter _blackOffset = new Vector2Parameter(Vector2.zero,true); 34 | 35 | public void load(Material material, ref RenderingData renderingData) 36 | { 37 | material.SetFloat("_CyanDotSize", _cyanDotSize.value); 38 | material.SetFloat("_MagentaDotSize", _magentaDotSize.value); 39 | material.SetFloat("_YellowDotSize", _yellowDotSize.value); 40 | material.SetFloat("_BlackDotSize", _blackDotSize.value); 41 | material.SetInt("_PrintCyan", _printCyan.value ? 1 : 0); 42 | material.SetFloat("_CyanBias", _cyanBias.value); 43 | material.SetVector("_CyanOffset", _cyanOffset.value); 44 | material.SetInt("_PrintMagenta", _printMagenta.value ? 1 : 0); 45 | material.SetFloat("_MagentaBias", _magentaBias.value); 46 | material.SetVector("_MagentaOffset", _magentaOffset.value); 47 | material.SetInt("_PrintYellow", _printYellow.value ? 1 : 0); 48 | material.SetFloat("_YellowBias", _yellowBias.value); 49 | material.SetVector("_YellowOffset", _yellowOffset.value); 50 | material.SetInt("_PrintBlack", _printBlack.value ? 1 : 0); 51 | material.SetFloat("_BlackBias", _blackBias.value); 52 | material.SetVector("_BlackOffset", _blackOffset.value); 53 | } 54 | 55 | public bool IsActive() => true; 56 | public bool IsTileCompatible() => false; 57 | } -------------------------------------------------------------------------------- /Assets/Halftone/HalftoneVolume.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 463dc7bc0a4332b4e8e5084f29309062 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Kuwahara/AnisotropicKuwahara.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ebfa7fb6957ec5147baa4b81bc0a532e 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Kuwahara/AnisotropicKuwaharaPass.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7899f1db0e452e24382f99f0d74f7459 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Kuwahara/AnisotropicKuwaharaRendererFeature.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering.Universal; 5 | 6 | public class AnisotropicKuwaharaRendererFeature : ScriptableRendererFeature 7 | { 8 | [System.Serializable] 9 | public class Settings 10 | { 11 | public RenderPassEvent RenderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing; 12 | public Shader shader; 13 | } 14 | 15 | public Settings settings = new Settings(); 16 | 17 | AnisotropicKuwaharaPass KuwaharaPass; 18 | private void OnEnable() 19 | { 20 | settings.shader = Shader.Find("Joseph&Acerola/AnisotropicKuwahara"); 21 | } 22 | public override void Create() 23 | { 24 | this.name = "Anisotropic Kuwahara Pass"; 25 | if(settings.shader == null) 26 | { 27 | Debug.LogWarning("No Shader"); 28 | return; 29 | } 30 | KuwaharaPass = new AnisotropicKuwaharaPass(settings.RenderPassEvent, settings.shader); 31 | } 32 | 33 | public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) 34 | { 35 | renderer.EnqueuePass(KuwaharaPass); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Assets/Kuwahara/AnisotropicKuwaharaRendererFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: adaf8125d69da764b9677b003dec2f3b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Kuwahara/AnisotropicKuwaharaVolume.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | [VolumeComponentMenu("Joseph_Acerola/Custom Anisotropic Kuwahara")] 8 | public class AnisotropicKuwaharaVolume : VolumeComponent, IPostProcessComponent 9 | { 10 | public ClampedIntParameter _kernelSize = new ClampedIntParameter(2, 2, 20, true); 11 | public ClampedFloatParameter _sharpness = new ClampedFloatParameter(8.0f, 1.0f, 18.0f, true); 12 | public ClampedFloatParameter _hardness = new ClampedFloatParameter(8.0f, 1.0f, 100.0f, true); 13 | public ClampedFloatParameter _alpha = new ClampedFloatParameter(1.0f, 0.01f, 2.0f, true); 14 | public ClampedFloatParameter _zeroCrossing = new ClampedFloatParameter(0.58f, 0.01f, 2.0f, true); 15 | public BoolParameter _useZeta = new BoolParameter(false, true); 16 | public ClampedFloatParameter _zeta = new ClampedFloatParameter(1.0f, 0.01f, 3.0f, true); 17 | public ClampedIntParameter _passes = new ClampedIntParameter(1, 1, 4, true); 18 | 19 | public void load(Material material, ref RenderingData renderingData) 20 | { 21 | material.SetFloat("_KernelSize", _kernelSize.value); 22 | material.SetInt("_N", 8); 23 | material.SetFloat("_Q", _sharpness.value); 24 | material.SetFloat("_Hardness", _hardness.value); 25 | material.SetFloat("_Alpha", _alpha.value); 26 | material.SetFloat("_ZeroCrossing", _zeroCrossing.value); 27 | material.SetFloat("_Zeta", _useZeta.value ? _zeta.value : 2.0f / 2.0f / (_kernelSize.value / 2.0f)); 28 | } 29 | public bool IsActive() => true; 30 | public bool IsTileCompatible() => false; 31 | } 32 | -------------------------------------------------------------------------------- /Assets/Kuwahara/AnisotropicKuwaharaVolume.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 06d842ed5385d274c9184c91a1a73dbb 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Kuwahara/GeneralizedKuwahara.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c2fc6d8f977a11c479460dea9153fda2 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Kuwahara/GeneralizedKuwaharaPass.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class GeneralizedKuwaharaPass : ScriptableRenderPass 8 | { 9 | static readonly string renderPassTag = "Generalized Kuwahara"; 10 | 11 | private GeneralizedKuwaharaVolume GeneralizedKuwaharaVolume; 12 | private Material GeneralizedKuwaharaMaterial; 13 | 14 | public GeneralizedKuwaharaPass(RenderPassEvent evt, Shader GeneralizedKuwaharashader) 15 | { 16 | renderPassEvent = evt; 17 | var shader = GeneralizedKuwaharashader; 18 | if (shader == null) 19 | { 20 | Debug.LogError("No Shader"); 21 | return; 22 | } 23 | GeneralizedKuwaharaMaterial = CoreUtils.CreateEngineMaterial(GeneralizedKuwaharashader); 24 | } 25 | 26 | public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) 27 | { 28 | if (GeneralizedKuwaharaMaterial == null) 29 | { 30 | Debug.LogError("No Generalized Kuwahara Material"); 31 | return; 32 | } 33 | 34 | if (!renderingData.cameraData.postProcessEnabled) 35 | { 36 | //Debug.LogError("Post Processing in Camera not enabled"); 37 | return; 38 | } 39 | 40 | VolumeStack stack = VolumeManager.instance.stack; 41 | GeneralizedKuwaharaVolume = stack.GetComponent(); 42 | 43 | var cmd = CommandBufferPool.Get(renderPassTag); 44 | Render(cmd, ref renderingData); 45 | context.ExecuteCommandBuffer(cmd); 46 | 47 | CommandBufferPool.Release(cmd); 48 | } 49 | 50 | void Render(CommandBuffer cmd, ref RenderingData renderingData) 51 | { 52 | if (GeneralizedKuwaharaVolume.IsActive() == false) return; 53 | GeneralizedKuwaharaVolume.load(GeneralizedKuwaharaMaterial, ref renderingData); 54 | 55 | var source = renderingData.cameraData.renderer.cameraColorTarget; 56 | int width = renderingData.cameraData.cameraTargetDescriptor.width; 57 | int height = renderingData.cameraData.cameraTargetDescriptor.height; 58 | 59 | int passes = (int)GeneralizedKuwaharaVolume._passes.value; 60 | RenderTexture[] kuwaharaPasses = new RenderTexture[passes]; 61 | 62 | for (int i = 0; i < passes; ++i) 63 | { 64 | kuwaharaPasses[i] = RenderTexture.GetTemporary(width, height, 0, renderingData.cameraData.cameraTargetDescriptor.colorFormat); 65 | } 66 | 67 | cmd.Blit(source, kuwaharaPasses[0], GeneralizedKuwaharaMaterial); 68 | 69 | for (int i = 1; i < passes; ++i) 70 | { 71 | cmd.Blit(kuwaharaPasses[i - 1], kuwaharaPasses[i], GeneralizedKuwaharaMaterial); 72 | } 73 | 74 | cmd.Blit(kuwaharaPasses[passes - 1], source); 75 | 76 | for (int i = 0; i < passes; ++i) 77 | { 78 | RenderTexture.ReleaseTemporary(kuwaharaPasses[i]); 79 | } 80 | } 81 | 82 | } -------------------------------------------------------------------------------- /Assets/Kuwahara/GeneralizedKuwaharaPass.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3e8a30bdf4ad8a84f8db03a2c5a3f309 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Kuwahara/GeneralizedKuwaharaRenderFeature.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class GeneralizedKuwaharaRenderFeature : ScriptableRendererFeature 8 | { 9 | [System.Serializable] 10 | public class Settings 11 | { 12 | public RenderPassEvent renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing; 13 | public Shader shader; 14 | } 15 | public Settings settings = new Settings(); 16 | 17 | GeneralizedKuwaharaPass m_GeneralizedKuwaharaPass; 18 | private void OnEnable() 19 | { 20 | settings.shader = Shader.Find("Joseph&Acerola/GeneralizedKuwahara"); 21 | } 22 | public override void Create() 23 | { 24 | this.name = "Generalized Kuwahara Pass"; 25 | if (settings.shader == null) 26 | { 27 | Debug.LogWarning("No Shader"); 28 | return; 29 | } 30 | m_GeneralizedKuwaharaPass = new GeneralizedKuwaharaPass(settings.renderPassEvent, settings.shader); 31 | } 32 | 33 | public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) 34 | { 35 | renderer.EnqueuePass(m_GeneralizedKuwaharaPass); 36 | } 37 | } -------------------------------------------------------------------------------- /Assets/Kuwahara/GeneralizedKuwaharaRenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dedb290c17131e94d87bcacea8d1ac7f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Kuwahara/GeneralizedKuwaharaVolume.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | using UnityEngine.Rendering; 6 | using UnityEngine.Rendering.Universal; 7 | 8 | [Serializable, VolumeComponentMenu("Joseph_Acerola/Custom Generalized Kuwahara")] 9 | public class GeneralizedKuwaharaVolume : VolumeComponent, IPostProcessComponent 10 | { 11 | public ClampedIntParameter _kernelSize = new ClampedIntParameter(2,2,20,true); 12 | public ClampedFloatParameter _sharpness = new ClampedFloatParameter(8f,1f,18f,true); 13 | public ClampedFloatParameter _hardness = new ClampedFloatParameter(8f,1f,100f,true); 14 | public ClampedFloatParameter _zeroCrossing = new ClampedFloatParameter(0.58f,0.01f,2f,true); 15 | public BoolParameter _useZeta = new BoolParameter(false,true); 16 | public ClampedFloatParameter _zeta = new ClampedFloatParameter(1.0f,0.01f,3f,true); 17 | public ClampedIntParameter _passes = new ClampedIntParameter(1,1,4,true); 18 | 19 | public void load(Material material, ref RenderingData renderingData) 20 | { 21 | material.SetInt("_KernelSize", _kernelSize.value); 22 | material.SetInt("_N", 8); 23 | material.SetFloat("_Q", _sharpness.value); 24 | material.SetFloat("_Hardness", _hardness.value); 25 | material.SetFloat("_ZeroCrossing", _zeroCrossing.value); 26 | material.SetFloat("_Zeta", _useZeta.value ? _zeta.value : 2.0f / (_kernelSize.value / 2.0f)); 27 | } 28 | 29 | public bool IsActive() => true; 30 | public bool IsTileCompatible() => false; 31 | } -------------------------------------------------------------------------------- /Assets/Kuwahara/GeneralizedKuwaharaVolume.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b3f98ad8d8037a14092ba255b32baf1a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Kuwahara/HybridKuwa.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2d191951b5782e94db22955ea6ca81a1 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Kuwahara/Kuwahara.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8f12a26f4fc308f4caaf678a77c55042 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Kuwahara/KuwaharaPass.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class KuwaharaPass : ScriptableRenderPass 8 | { 9 | static readonly string renderPassTag = "Kuwahara"; 10 | 11 | private KuwaharaVolume KuwaharaVolume; 12 | private Material KuwaharaMaterial; 13 | 14 | public KuwaharaPass(RenderPassEvent evt, Shader Kuwaharashader) 15 | { 16 | renderPassEvent = evt; 17 | var shader = Kuwaharashader; 18 | if (shader == null) 19 | { 20 | Debug.LogError("No Shader"); 21 | return; 22 | } 23 | KuwaharaMaterial = CoreUtils.CreateEngineMaterial(Kuwaharashader); 24 | } 25 | 26 | 27 | public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) 28 | { 29 | if (KuwaharaMaterial == null) 30 | { 31 | Debug.LogError("No Kuwahara Material"); 32 | return; 33 | } 34 | 35 | if (!renderingData.cameraData.postProcessEnabled) 36 | { 37 | //Debug.LogError("Post Processing in Camera not enabled"); 38 | return; 39 | } 40 | 41 | VolumeStack stack = VolumeManager.instance.stack; 42 | KuwaharaVolume = stack.GetComponent(); 43 | 44 | var cmd = CommandBufferPool.Get(renderPassTag); 45 | Render(cmd, ref renderingData); 46 | context.ExecuteCommandBuffer(cmd); 47 | 48 | CommandBufferPool.Release(cmd); 49 | } 50 | 51 | void Render(CommandBuffer cmd, ref RenderingData renderingData) 52 | { 53 | if (KuwaharaVolume.IsActive() == false) return; 54 | KuwaharaVolume.load(KuwaharaMaterial, ref renderingData); 55 | 56 | var source = renderingData.cameraData.renderer.cameraColorTarget; 57 | int width = renderingData.cameraData.cameraTargetDescriptor.width; 58 | int height = renderingData.cameraData.cameraTargetDescriptor.height; 59 | 60 | int passes = (int)KuwaharaVolume._passes.value; 61 | RenderTexture[] kuwaharaPasses = new RenderTexture[passes]; 62 | 63 | for (int i = 0; i < passes; ++i) 64 | { 65 | kuwaharaPasses[i] = RenderTexture.GetTemporary(width, height, 0, renderingData.cameraData.cameraTargetDescriptor.colorFormat); 66 | } 67 | 68 | cmd.Blit(source, kuwaharaPasses[0], KuwaharaMaterial); 69 | 70 | for (int i = 1; i < passes; ++i) 71 | { 72 | cmd.Blit(kuwaharaPasses[i - 1], kuwaharaPasses[i], KuwaharaMaterial); 73 | } 74 | 75 | cmd.Blit(kuwaharaPasses[passes - 1], source); 76 | 77 | for (int i = 0; i < passes; ++i) 78 | { 79 | RenderTexture.ReleaseTemporary(kuwaharaPasses[i]); 80 | } 81 | } 82 | 83 | } -------------------------------------------------------------------------------- /Assets/Kuwahara/KuwaharaPass.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7676d5f375993824d8ce5890dfc21e5f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Kuwahara/KuwaharaRenderFeature.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class KuwaharaRenderFeature : ScriptableRendererFeature 8 | { 9 | [System.Serializable] 10 | public class Settings 11 | { 12 | public RenderPassEvent renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing; 13 | public Shader shader; 14 | } 15 | public Settings settings = new Settings(); 16 | 17 | KuwaharaPass m_KuwaharaPass; 18 | private void OnEnable() 19 | { 20 | settings.shader = Shader.Find("Joseph&Acerola/Kuwahara"); 21 | } 22 | public override void Create() 23 | { 24 | this.name = "Kuwahara Pass"; 25 | if (settings.shader == null) 26 | { 27 | Debug.LogWarning("No Shader"); 28 | return; 29 | } 30 | m_KuwaharaPass = new KuwaharaPass(settings.renderPassEvent, settings.shader); 31 | } 32 | 33 | public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) 34 | { 35 | renderer.EnqueuePass(m_KuwaharaPass); 36 | } 37 | } -------------------------------------------------------------------------------- /Assets/Kuwahara/KuwaharaRenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 95d066119ef52b847ba2cada4e9d62dd 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Kuwahara/KuwaharaVolume.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | using UnityEngine.Rendering; 6 | using UnityEngine.Rendering.Universal; 7 | 8 | [Serializable, VolumeComponentMenu("Joseph_Acerola/Custom Kuwahara")] 9 | public class KuwaharaVolume : VolumeComponent, IPostProcessComponent 10 | { 11 | public ClampedIntParameter _kernelSize = new ClampedIntParameter(1, 1, 20, true); 12 | public BoolParameter _animateKernelSize = new BoolParameter(false, true); 13 | public ClampedIntParameter _minKernelSize = new ClampedIntParameter(1, 1, 20, true); 14 | public ClampedFloatParameter _sizeAnimationSpeed = new ClampedFloatParameter(1f, 0.1f, 5f, true); 15 | public ClampedFloatParameter _noiseFrequency = new ClampedFloatParameter(10f, 0f, 30f, true); 16 | public BoolParameter _animateKernelOrigin = new BoolParameter(false, true); 17 | public ClampedIntParameter _passes = new ClampedIntParameter(1, 1, 4, true); 18 | 19 | public void load(Material material, ref RenderingData renderingData) 20 | { 21 | material.SetInt("_KernelSize", _kernelSize.value); 22 | material.SetInt("_MinKernelSize", _minKernelSize.value); 23 | material.SetInt("_AnimateSize", _animateKernelSize.value ? 1 : 0); 24 | material.SetFloat("_SizeAnimationSpeed", _sizeAnimationSpeed.value); 25 | material.SetFloat("_NoiseFrequency", _noiseFrequency.value); 26 | material.SetInt("_AnimateOrigin", _animateKernelOrigin.value ? 1 : 0); 27 | } 28 | 29 | public bool IsActive() => true; 30 | public bool IsTileCompatible() => false; 31 | } -------------------------------------------------------------------------------- /Assets/Kuwahara/KuwaharaVolume.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4777b298c54fde44f8f99eadfb3b48d9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Lens Flare/Acerola.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 40d72569edb9c1249bdef4e33fb7c001 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Lens Flare/Acerola/Lens Flare.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f5b12e8d8104e7a4786c6ea677a0cb23 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Lens Flare/Acerola/LensFlarePass.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fa993e7a75b366b429594c0f30c5f204 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Lens Flare/Acerola/LensFlareRenderFeature.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class LensFlareRenderFeature : ScriptableRendererFeature 8 | { 9 | [System.Serializable] 10 | public class Settings 11 | { 12 | public RenderPassEvent renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing; 13 | public Shader shader; 14 | } 15 | public Settings settings = new Settings(); 16 | 17 | LensFlarePass m_LensFlarePass; 18 | private void OnEnable() 19 | { 20 | settings.shader = Shader.Find("Joseph&Acerola/LensFlare"); 21 | } 22 | public override void Create() 23 | { 24 | this.name = "Lens Flare Pass"; 25 | if (settings.shader == null) 26 | { 27 | Debug.LogWarning("No Shader"); 28 | return; 29 | } 30 | m_LensFlarePass = new LensFlarePass(settings.renderPassEvent, settings.shader); 31 | } 32 | 33 | public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) 34 | { 35 | renderer.EnqueuePass(m_LensFlarePass); 36 | } 37 | } -------------------------------------------------------------------------------- /Assets/Lens Flare/Acerola/LensFlareRenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1138e9147c2cbc044b17081588997465 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Lens Flare/Acerola/LensFlareVolume.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | using UnityEngine.Rendering; 6 | using UnityEngine.Rendering.Universal; 7 | 8 | [Serializable, VolumeComponentMenu("Joseph_Acerola/Custom Lens Flare")] 9 | public class LensFlareVolume : VolumeComponent, IPostProcessComponent 10 | { 11 | public FloatParameter _threshold = new ClampedFloatParameter(0.5f, 0f, 1f, true); 12 | public IntParameter _sampleCount = new ClampedIntParameter(16, 1, 32, true); 13 | public FloatParameter _sampleDistance = new ClampedFloatParameter(0.01f, 0f, 0.1f, true); 14 | public FloatParameter _haloRadius = new ClampedFloatParameter(1f, 0f, 1f, true); 15 | public FloatParameter _haloThickness = new ClampedFloatParameter(0.5f, 0f, 1f, true); 16 | public Vector3Parameter _channelOffsets = new Vector3Parameter(Vector3.zero, true); 17 | public IntParameter _kernelSize = new ClampedIntParameter(2, 1, 20, true); 18 | public FloatParameter _sigma = new ClampedFloatParameter(1f, 0f, 10f, true); 19 | 20 | public void load(Material material, ref RenderingData renderingData) 21 | { 22 | material.SetFloat("_Threshold", _threshold.value); 23 | material.SetVector("_ColorOffsets", _channelOffsets.value); 24 | material.SetInt("_KernelSize", _kernelSize.value); 25 | material.SetFloat("_Sigma", _sigma.value); 26 | material.SetInt("_SampleCount", _sampleCount.value); 27 | material.SetFloat("_SampleDistance", _sampleDistance.value); 28 | material.SetFloat("_HaloRadius", _haloRadius.value); 29 | material.SetFloat("_HaloThickness", _haloThickness.value); 30 | } 31 | 32 | public bool IsActive() => true; 33 | public bool IsTileCompatible() => false; 34 | } -------------------------------------------------------------------------------- /Assets/Lens Flare/Acerola/LensFlareVolume.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b5b9ba3caaa0e794d897d522ef7e8d5f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Lens Flare/Acerola/Note.txt: -------------------------------------------------------------------------------- 1 | Note from Dev, this lens flare effect from Acerola looks pretty bad/doesn't seem to function well (even when tested on AceRola's Grassmain/post processing project), 2 | will probs make my own or something. -------------------------------------------------------------------------------- /Assets/Lens Flare/Acerola/Note.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4e0f81bef788c9847ad93a3946b11295 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Outlines/EdgeDetect.shader: -------------------------------------------------------------------------------- 1 | Shader "Joseph&Acerola/EdgeDetect" { 2 | Properties{ 3 | _MainTex("Texture", 2D) = "white" {} 4 | } 5 | 6 | SubShader{ 7 | 8 | Pass { 9 | CGPROGRAM 10 | #pragma vertex vp 11 | #pragma fragment fp 12 | 13 | #include "UnityCG.cginc" 14 | 15 | struct VertexData { 16 | float4 vertex : POSITION; 17 | float2 uv : TEXCOORD0; 18 | }; 19 | 20 | struct v2f { 21 | float2 uv : TEXCOORD0; 22 | float4 vertex : SV_POSITION; 23 | }; 24 | 25 | v2f vp(VertexData v) { 26 | v2f o; 27 | o.vertex = UnityObjectToClipPos(v.vertex); 28 | o.uv = v.uv; 29 | return o; 30 | } 31 | 32 | sampler2D _MainTex, _CameraDepthTexture; 33 | float4 _CameraDepthTexture_TexelSize; 34 | float4 _BorderColor; 35 | 36 | fixed4 fp(v2f i) : SV_Target { 37 | int x, y; 38 | fixed4 col = tex2D(_MainTex, i.uv); 39 | float depth = tex2D(_CameraDepthTexture, i.uv); 40 | depth = Linear01Depth(depth); 41 | 42 | float depths; 43 | 44 | 45 | float n = Linear01Depth(tex2D(_CameraDepthTexture, i.uv + _CameraDepthTexture_TexelSize * float2(0, 1)).r); 46 | float e = Linear01Depth(tex2D(_CameraDepthTexture, i.uv + _CameraDepthTexture_TexelSize * float2(1, 0)).r); 47 | float s = Linear01Depth(tex2D(_CameraDepthTexture, i.uv + _CameraDepthTexture_TexelSize * float2(0, -1)).r); 48 | float w = Linear01Depth(tex2D(_CameraDepthTexture, i.uv + _CameraDepthTexture_TexelSize * float2(-1, 0)).r); 49 | 50 | 51 | if (n - s > 0.1 || w - e > 0.1 || e - w > 0.1 || s - n > 0.1) 52 | col = _BorderColor; 53 | 54 | 55 | return col; 56 | } 57 | ENDCG 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /Assets/Outlines/EdgeDetect.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d8c11919c8100d946b6a858ebbb0f8ef 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Outlines/EdgeDetectPass.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class EdgeDetectPass : ScriptableRenderPass 8 | { 9 | static readonly string renderPassTag = "Edge Detect"; 10 | 11 | private EdgeDetectVolume EdgeDetectVolume; 12 | private Material EdgeDetectMaterial; 13 | 14 | public EdgeDetectPass(RenderPassEvent evt, Shader EdgeDetectshader) 15 | { 16 | renderPassEvent = evt; 17 | var shader = EdgeDetectshader; 18 | if (shader == null) 19 | { 20 | Debug.LogError("No Shader"); 21 | return; 22 | } 23 | EdgeDetectMaterial = CoreUtils.CreateEngineMaterial(EdgeDetectshader); 24 | } 25 | 26 | 27 | public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) 28 | { 29 | if (EdgeDetectMaterial == null) 30 | { 31 | Debug.LogError("No Edge Detect Material"); 32 | return; 33 | } 34 | 35 | if (!renderingData.cameraData.postProcessEnabled) 36 | { 37 | //Debug.LogError("Post Processing in Camera not enabled"); 38 | return; 39 | } 40 | 41 | VolumeStack stack = VolumeManager.instance.stack; 42 | EdgeDetectVolume = stack.GetComponent(); 43 | 44 | var cmd = CommandBufferPool.Get(renderPassTag); 45 | Render(cmd, ref renderingData); 46 | context.ExecuteCommandBuffer(cmd); 47 | 48 | CommandBufferPool.Release(cmd); 49 | } 50 | 51 | void Render(CommandBuffer cmd, ref RenderingData renderingData) 52 | { 53 | if (EdgeDetectVolume.IsActive() == false) return; 54 | EdgeDetectVolume.load(EdgeDetectMaterial, ref renderingData); 55 | 56 | var source = renderingData.cameraData.renderer.cameraColorTarget; 57 | 58 | cmd.Blit(source, source, EdgeDetectMaterial); 59 | } 60 | 61 | } -------------------------------------------------------------------------------- /Assets/Outlines/EdgeDetectPass.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ec04c376302b4894e90b8ad608b26a40 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Outlines/EdgeDetectRenderFeature.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class EdgeDetectRenderFeature : ScriptableRendererFeature 8 | { 9 | [System.Serializable] 10 | public class Settings 11 | { 12 | public RenderPassEvent renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing; 13 | public Shader shader; 14 | } 15 | public Settings settings = new Settings(); 16 | 17 | EdgeDetectPass m_EdgeDetectPass; 18 | private void OnEnable() 19 | { 20 | settings.shader = Shader.Find("Joseph&Acerola/EdgeDetect"); 21 | } 22 | public override void Create() 23 | { 24 | this.name = "Edge Detect Pass"; 25 | if (settings.shader == null) 26 | { 27 | Debug.LogWarning("No Shader"); 28 | return; 29 | } 30 | m_EdgeDetectPass = new EdgeDetectPass(settings.renderPassEvent, settings.shader); 31 | } 32 | 33 | public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) 34 | { 35 | renderer.EnqueuePass(m_EdgeDetectPass); 36 | } 37 | } -------------------------------------------------------------------------------- /Assets/Outlines/EdgeDetectRenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e7326052b738b4c4ea709816e7f7c10c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Outlines/EdgeDetectVolume.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | using UnityEngine.Rendering; 6 | using UnityEngine.Rendering.Universal; 7 | 8 | [Serializable, VolumeComponentMenu("Joseph_Acerola/Custom Edge Detect")] 9 | public class EdgeDetectVolume : VolumeComponent, IPostProcessComponent 10 | { 11 | public ColorParameter _borderColor = new ColorParameter(Color.black, true, true, true, true); 12 | 13 | public void load(Material material, ref RenderingData renderingData) 14 | { 15 | material.SetColor("_BorderColor", _borderColor.value); 16 | } 17 | 18 | public bool IsActive() => true; 19 | public bool IsTileCompatible() => false; 20 | } -------------------------------------------------------------------------------- /Assets/Outlines/EdgeDetectVolume.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dac663bd3381dca4aaa849998a70e185 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Pixel Art/PaletteSwapper.shader: -------------------------------------------------------------------------------- 1 | Shader "Joseph&Acerola/PaletteSwapper" { 2 | Properties{ 3 | _MainTex("Texture", 2D) = "white" {} 4 | } 5 | 6 | SubShader{ 7 | 8 | Pass { 9 | CGPROGRAM 10 | #pragma vertex vp 11 | #pragma fragment fp 12 | 13 | #include "UnityCG.cginc" 14 | 15 | struct VertexData { 16 | float4 vertex : POSITION; 17 | float2 uv : TEXCOORD0; 18 | }; 19 | 20 | struct v2f { 21 | float2 uv : TEXCOORD0; 22 | float4 vertex : SV_POSITION; 23 | }; 24 | 25 | v2f vp(VertexData v) { 26 | v2f o; 27 | o.vertex = UnityObjectToClipPos(v.vertex); 28 | o.uv = v.uv; 29 | return o; 30 | } 31 | 32 | sampler2D _MainTex; 33 | Texture2D _ColorPalette; 34 | float4 _ColorPalette_TexelSize; 35 | SamplerState point_clamp_sampler; 36 | int _Invert; 37 | 38 | fixed4 fp(v2f i) : SV_Target { 39 | /* Assumes _MainTex is grayscale and quantized */ 40 | float2 uv = float2(tex2D(_MainTex, i.uv).r, 0.5f); 41 | 42 | uv.x = _Invert == 1 ? 1 - uv.x : uv.x; 43 | 44 | float4 firstColor = _ColorPalette.Sample(point_clamp_sampler, float2(floor(_ColorPalette_TexelSize.z * uv.x) / _ColorPalette_TexelSize.z, 0.5f)); 45 | float4 secondColor = _ColorPalette.Sample(point_clamp_sampler, float2(ceil(_ColorPalette_TexelSize.z * uv.x) / _ColorPalette_TexelSize.z, 0.5f)); 46 | 47 | return lerp(firstColor, secondColor, frac(_ColorPalette_TexelSize.z * uv.x)); 48 | } 49 | ENDCG 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /Assets/Pixel Art/PaletteSwapper.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dcc9a14e24651c146a247607dadae0a3 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Pixel Art/PaletteSwapperPass.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class PaletteSwapperPass : ScriptableRenderPass 8 | { 9 | static readonly string renderPassTag = "Palette Swapper"; 10 | 11 | private PaletteSwapperVolume PaletteSwapperVolume; 12 | private Material PaletteSwapperMaterial; 13 | 14 | public PaletteSwapperPass(RenderPassEvent evt, Shader halfToneshader) 15 | { 16 | renderPassEvent = evt; 17 | var shader = halfToneshader; 18 | if (shader == null) 19 | { 20 | Debug.LogError("No Shader"); 21 | return; 22 | } 23 | PaletteSwapperMaterial = CoreUtils.CreateEngineMaterial(halfToneshader); 24 | } 25 | 26 | 27 | public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) 28 | { 29 | if (PaletteSwapperMaterial == null) 30 | { 31 | Debug.LogError("No Palette Swapper Material"); 32 | return; 33 | } 34 | 35 | if (!renderingData.cameraData.postProcessEnabled || renderingData.cameraData.cameraType == CameraType.SceneView) 36 | { 37 | //Debug.LogError("Post Processing in Camera not enabled"); 38 | return; 39 | } 40 | 41 | VolumeStack stack = VolumeManager.instance.stack; 42 | PaletteSwapperVolume = stack.GetComponent(); 43 | 44 | var cmd = CommandBufferPool.Get(renderPassTag); 45 | Render(cmd, ref renderingData); 46 | context.ExecuteCommandBuffer(cmd); 47 | 48 | CommandBufferPool.Release(cmd); 49 | } 50 | 51 | void Render(CommandBuffer cmd, ref RenderingData renderingData) 52 | { 53 | if (PaletteSwapperVolume.IsActive() == false) return; 54 | PaletteSwapperVolume.load(PaletteSwapperMaterial, ref renderingData); 55 | 56 | var source = renderingData.cameraData.renderer.cameraColorTarget; 57 | 58 | cmd.Blit(source, source, PaletteSwapperMaterial); 59 | } 60 | 61 | } -------------------------------------------------------------------------------- /Assets/Pixel Art/PaletteSwapperPass.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d868837493afc0d4994e81a140d12f7b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Pixel Art/PaletteSwapperRenderFeature.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class PaletteSwapperRenderFeature : ScriptableRendererFeature 8 | { 9 | [System.Serializable] 10 | public class Settings 11 | { 12 | public RenderPassEvent renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing; 13 | public Shader shader; 14 | } 15 | public Settings settings = new Settings(); 16 | 17 | PaletteSwapperPass m_PaletteSwapperPass; 18 | private void OnEnable() 19 | { 20 | settings.shader = Shader.Find("Joseph&Acerola/PaletteSwapper"); 21 | } 22 | public override void Create() 23 | { 24 | this.name = "Palette Swapper Pass"; 25 | if (settings.shader == null) 26 | { 27 | Debug.LogWarning("No Shader"); 28 | return; 29 | } 30 | m_PaletteSwapperPass = new PaletteSwapperPass(settings.renderPassEvent, settings.shader); 31 | } 32 | 33 | public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) 34 | { 35 | renderer.EnqueuePass(m_PaletteSwapperPass); 36 | } 37 | } -------------------------------------------------------------------------------- /Assets/Pixel Art/PaletteSwapperRenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e4c3d606d56e13f4ba5f89cdb50f599d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Pixel Art/PaletteSwapperVolume.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | using UnityEngine.Rendering; 6 | using UnityEngine.Rendering.Universal; 7 | 8 | [Serializable, VolumeComponentMenu("Joseph_Acerola/Custom Palette Swap")] 9 | public class PaletteSwapperVolume : VolumeComponent, IPostProcessComponent 10 | { 11 | public TextureParameter _colorPalette = new TextureParameter(null, true); 12 | public BoolParameter _invert = new BoolParameter(true, true); 13 | 14 | public void load(Material material, ref RenderingData renderingData) 15 | { 16 | material.SetTexture("_ColorPalette", _colorPalette.value); 17 | material.SetInt("_Invert", _invert.value ? 1 : 0); 18 | } 19 | 20 | public bool IsActive() => true; 21 | public bool IsTileCompatible() => false; 22 | } -------------------------------------------------------------------------------- /Assets/Pixel Art/PaletteSwapperVolume.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3e2dd15903a3e2449aceddcfe5050a5b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Pixel Art/PixelArtFilter.shader: -------------------------------------------------------------------------------- 1 | Shader "Joseph&Acerola/PixelArtFilter" { 2 | Properties{ 3 | _MainTex("Texture", 2D) = "white" {} 4 | } 5 | 6 | SubShader{ 7 | 8 | Pass { 9 | CGPROGRAM 10 | #pragma vertex vp 11 | #pragma fragment fp 12 | 13 | #include "UnityCG.cginc" 14 | 15 | struct VertexData { 16 | float4 vertex : POSITION; 17 | float2 uv : TEXCOORD0; 18 | }; 19 | 20 | struct v2f { 21 | float2 uv : TEXCOORD0; 22 | float4 vertex : SV_POSITION; 23 | }; 24 | 25 | v2f vp(VertexData v) { 26 | v2f o; 27 | o.vertex = UnityObjectToClipPos(v.vertex); 28 | o.uv = v.uv; 29 | return o; 30 | } 31 | 32 | Texture2D _MainTex; 33 | SamplerState point_clamp_sampler; 34 | 35 | fixed4 fp(v2f i) : SV_Target { 36 | float4 col = _MainTex.Sample(point_clamp_sampler, i.uv); 37 | 38 | return col; 39 | } 40 | ENDCG 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /Assets/Pixel Art/PixelArtFilter.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 530de4e1cd346c54bbd467246f59e214 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Pixel Art/PixelArtPass.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class PixelArtPass : ScriptableRenderPass 8 | { 9 | static readonly string renderPassTag = "Pixel Art"; 10 | 11 | private PixelArtVolume PixelArtVolume; 12 | private Material PixelArtMaterial; 13 | 14 | public PixelArtPass(RenderPassEvent evt, Shader halfToneshader) 15 | { 16 | renderPassEvent = evt; 17 | var shader = halfToneshader; 18 | if (shader == null) 19 | { 20 | Debug.LogError("No Shader"); 21 | return; 22 | } 23 | PixelArtMaterial = CoreUtils.CreateEngineMaterial(halfToneshader); 24 | } 25 | 26 | 27 | public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) 28 | { 29 | if (PixelArtMaterial == null) 30 | { 31 | Debug.LogError("No Pixel Art Material"); 32 | return; 33 | } 34 | 35 | if (!renderingData.cameraData.postProcessEnabled || renderingData.cameraData.cameraType == CameraType.SceneView) 36 | { 37 | //Debug.LogError("Post Processing in Camera not enabled"); 38 | return; 39 | } 40 | 41 | VolumeStack stack = VolumeManager.instance.stack; 42 | PixelArtVolume = stack.GetComponent(); 43 | 44 | var cmd = CommandBufferPool.Get(renderPassTag); 45 | Render(cmd, ref renderingData); 46 | context.ExecuteCommandBuffer(cmd); 47 | 48 | CommandBufferPool.Release(cmd); 49 | } 50 | 51 | void Render(CommandBuffer cmd, ref RenderingData renderingData) 52 | { 53 | if (PixelArtVolume.IsActive() == false) return; 54 | //PixelArtVolume.load(HalftoneMaterial, ref renderingData); 55 | 56 | int width = renderingData.cameraData.cameraTargetDescriptor.width; 57 | int height = renderingData.cameraData.cameraTargetDescriptor.height; 58 | int downSample = (int) PixelArtVolume._downSample.value; 59 | 60 | var source = renderingData.cameraData.renderer.cameraColorTarget; 61 | RenderTexture[] textures = new RenderTexture[8]; 62 | var currentSource = source; 63 | 64 | for (int i = 0; i < downSample; ++i) 65 | { 66 | width /= 2; 67 | height /= 2; 68 | 69 | if (height < 2) 70 | break; 71 | 72 | RenderTexture currentDestination = textures[i] = RenderTexture.GetTemporary(width, height, 0, renderingData.cameraData.cameraTargetDescriptor.colorFormat); 73 | cmd.Blit(source, currentDestination, PixelArtMaterial); 74 | currentSource = currentDestination; 75 | } 76 | 77 | cmd.Blit(currentSource, source, PixelArtMaterial); 78 | 79 | for (int i = 0; i < downSample; ++i) 80 | { 81 | RenderTexture.ReleaseTemporary(textures[i]); 82 | } 83 | } 84 | 85 | } -------------------------------------------------------------------------------- /Assets/Pixel Art/PixelArtPass.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 02a32c2e55450d648acf363f9815651a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Pixel Art/PixelArtRenderFeature.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class PixelArtRenderFeature : ScriptableRendererFeature 8 | { 9 | [System.Serializable] 10 | public class Settings 11 | { 12 | public RenderPassEvent renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing; 13 | public Shader shader; 14 | } 15 | public Settings settings = new Settings(); 16 | 17 | PixelArtPass m_PixelArtPass; 18 | private void OnEnable() 19 | { 20 | settings.shader = Shader.Find("Joseph&Acerola/PixelArtFilter"); 21 | } 22 | public override void Create() 23 | { 24 | this.name = "Pixel Art Pass"; 25 | if (settings.shader == null) 26 | { 27 | Debug.LogWarning("No Shader"); 28 | return; 29 | } 30 | m_PixelArtPass = new PixelArtPass(settings.renderPassEvent, settings.shader); 31 | } 32 | 33 | public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) 34 | { 35 | renderer.EnqueuePass(m_PixelArtPass); 36 | } 37 | } -------------------------------------------------------------------------------- /Assets/Pixel Art/PixelArtRenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: afcca5e1e751d304b912523c635ffec1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Pixel Art/PixelArtVolume.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | using UnityEngine.Rendering; 6 | using UnityEngine.Rendering.Universal; 7 | 8 | [Serializable, VolumeComponentMenu("Joseph_Acerola/Custom Pixel Art")] 9 | public class PixelArtVolume : VolumeComponent, IPostProcessComponent 10 | { 11 | public ClampedIntParameter _downSample = new ClampedIntParameter(0, 0, 8, true); 12 | 13 | /* 14 | public void load(Material material, ref RenderingData renderingData) 15 | { 16 | 17 | } 18 | */ 19 | 20 | public bool IsActive() => true; 21 | public bool IsTileCompatible() => false; 22 | } -------------------------------------------------------------------------------- /Assets/Pixel Art/PixelArtVolume.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2ef159355ff21b445bc07ad94cce6434 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Sharpness/ContrastAdaptiveSharpness.shader: -------------------------------------------------------------------------------- 1 | Shader "Joseph&Acerola/ContrastAdaptiveSharpness" { 2 | Properties{ 3 | _MainTex("Texture", 2D) = "white" {} 4 | } 5 | 6 | SubShader{ 7 | 8 | Pass { 9 | CGPROGRAM 10 | #pragma vertex vp 11 | #pragma fragment fp 12 | 13 | #include "UnityCG.cginc" 14 | 15 | struct VertexData { 16 | float4 vertex : POSITION; 17 | float2 uv : TEXCOORD0; 18 | }; 19 | 20 | struct v2f { 21 | float2 uv : TEXCOORD0; 22 | float4 vertex : SV_POSITION; 23 | }; 24 | 25 | v2f vp(VertexData v) { 26 | v2f o; 27 | o.vertex = UnityObjectToClipPos(v.vertex); 28 | o.uv = v.uv; 29 | return o; 30 | } 31 | 32 | sampler2D _MainTex; 33 | float4 _MainTex_TexelSize; 34 | float _Amount; 35 | 36 | float3 Sample(float2 uv, float deltaX, float deltaY) { 37 | return saturate(tex2D(_MainTex, uv + float2(deltaX, deltaY) * _MainTex_TexelSize.xy).rgb); 38 | } 39 | 40 | float3 GetMin(float3 x, float3 y, float3 z) { 41 | return min(x, min(y, z)); 42 | } 43 | 44 | float3 GetMax(float3 x, float3 y, float3 z) { 45 | return max(x, max(y, z)); 46 | } 47 | 48 | float4 fp(v2f i) : SV_Target { 49 | float sharpness = -(1.0f / lerp(10.0f, 7.0f, saturate(_Amount))); 50 | 51 | float3 a = Sample(i.uv, -1, -1); 52 | float3 b = Sample(i.uv, 0, -1); 53 | float3 c = Sample(i.uv, 1, -1); 54 | float3 d = Sample(i.uv, -1, 0); 55 | float3 e = Sample(i.uv, 0, 0); 56 | float3 f = Sample(i.uv, 1, 0); 57 | float3 g = Sample(i.uv, -1, 1); 58 | float3 h = Sample(i.uv, 0, 1); 59 | float3 j = Sample(i.uv, 1, 1); 60 | 61 | float3 minRGB = GetMin(GetMin(d, e, f), b, h); 62 | float3 minRGB2 = GetMin(GetMin(minRGB, a, c), g, j); 63 | 64 | minRGB += minRGB2; 65 | 66 | float3 maxRGB = GetMax(GetMax(d, e, f), b, h); 67 | float3 maxRGB2 = GetMax(GetMax(maxRGB, a, c), g, j); 68 | 69 | maxRGB += maxRGB2; 70 | 71 | float3 rcpM = 1.0f / maxRGB; 72 | float3 amp = saturate(min(minRGB, 2.0f - maxRGB) * rcpM); 73 | amp = sqrt(amp); 74 | 75 | float3 w = amp * sharpness; 76 | float3 rcpW = 1.0f / (1.0f + 4.0f * w); 77 | 78 | float3 output = saturate((b * w + d * w + f * w + h * w + e) * rcpW); 79 | 80 | return float4(output, 1.0f); 81 | } 82 | ENDCG 83 | } 84 | } 85 | } -------------------------------------------------------------------------------- /Assets/Sharpness/ContrastAdaptiveSharpness.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4d21a441afeb8ca4796bfca1ce0c6443 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Sharpness/Sharpness.shader: -------------------------------------------------------------------------------- 1 | Shader "Joseph&Acerola/Sharpness" { 2 | Properties{ 3 | _MainTex("Texture", 2D) = "white" {} 4 | } 5 | 6 | SubShader{ 7 | 8 | Pass { 9 | CGPROGRAM 10 | #pragma vertex vp 11 | #pragma fragment fp 12 | 13 | #include "UnityCG.cginc" 14 | 15 | struct VertexData { 16 | float4 vertex : POSITION; 17 | float2 uv : TEXCOORD0; 18 | }; 19 | 20 | struct v2f { 21 | float2 uv : TEXCOORD0; 22 | float4 vertex : SV_POSITION; 23 | }; 24 | 25 | v2f vp(VertexData v) { 26 | v2f o; 27 | o.vertex = UnityObjectToClipPos(v.vertex); 28 | o.uv = v.uv; 29 | return o; 30 | } 31 | 32 | sampler2D _MainTex; 33 | float4 _MainTex_TexelSize; 34 | float _Amount; 35 | 36 | float4 fp(v2f i) : SV_Target { 37 | float4 col = saturate(tex2D(_MainTex, i.uv)); 38 | 39 | float neighbor = _Amount * -1; 40 | float center = _Amount * 4 + 1; 41 | 42 | float4 n = tex2D(_MainTex, i.uv + _MainTex_TexelSize * float2(0, 1)); 43 | float4 e = tex2D(_MainTex, i.uv + _MainTex_TexelSize * float2(1, 0)); 44 | float4 s = tex2D(_MainTex, i.uv + _MainTex_TexelSize * float2(0, -1)); 45 | float4 w = tex2D(_MainTex, i.uv + _MainTex_TexelSize * float2(-1, 0)); 46 | 47 | float4 output = n * neighbor + e * neighbor + col * center + s * neighbor + w * neighbor; 48 | 49 | return saturate(output); 50 | } 51 | ENDCG 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /Assets/Sharpness/Sharpness.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 96aaba7dd19b3db47900eba0bd64cf59 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Sharpness/SharpnessPass.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class SharpnessPass : ScriptableRenderPass 8 | { 9 | static readonly string renderPassTag = "Sharpness"; 10 | 11 | private SharpnessVolume sharpnessVolume; 12 | private Material sharpnessMaterial; 13 | private Shader SharpnessShader; 14 | 15 | public SharpnessPass(RenderPassEvent evt) 16 | { 17 | renderPassEvent = evt; 18 | 19 | VolumeStack stack = VolumeManager.instance.stack; 20 | sharpnessVolume = stack.GetComponent(); 21 | 22 | switch (sharpnessVolume._sharpnessMode.value) 23 | { 24 | case SharpnessMode.Normal: SharpnessShader = Shader.Find("Joseph&Acerola/Sharpness"); break; 25 | case SharpnessMode.Contrast: SharpnessShader = Shader.Find("Joseph&Acerola/ContrastAdaptiveSharpness"); break; 26 | } 27 | 28 | if (SharpnessShader == null) 29 | { 30 | Debug.LogError("No Shader"); 31 | return; 32 | } 33 | 34 | sharpnessMaterial = CoreUtils.CreateEngineMaterial(SharpnessShader); 35 | } 36 | 37 | public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) 38 | { 39 | if (sharpnessMaterial == null) 40 | { 41 | Debug.LogError("No Sharpness Material"); 42 | return; 43 | } 44 | 45 | if (!renderingData.cameraData.postProcessEnabled) 46 | { 47 | //Debug.LogError("Post Processing in Camera not enabled"); 48 | return; 49 | } 50 | 51 | VolumeStack stack = VolumeManager.instance.stack; 52 | sharpnessVolume = stack.GetComponent(); 53 | 54 | var cmd = CommandBufferPool.Get(renderPassTag); 55 | Render(cmd, ref renderingData); 56 | context.ExecuteCommandBuffer(cmd); 57 | CommandBufferPool.Release(cmd); 58 | } 59 | void Render(CommandBuffer cmd, ref RenderingData renderingData) 60 | { 61 | sharpnessVolume.load(sharpnessMaterial, ref renderingData); 62 | 63 | var cameraColorTarget = renderingData.cameraData.renderer.cameraColorTarget; 64 | 65 | // Apply sharpness effect 66 | cmd.GetTemporaryRT(Shader.PropertyToID("_SharpnessRT"), renderingData.cameraData.cameraTargetDescriptor, FilterMode.Point); 67 | RenderTargetIdentifier sharpness = new RenderTargetIdentifier("_SharpnessRT"); 68 | cmd.Blit(cameraColorTarget, sharpness, sharpnessMaterial, 0); // Use pass 0 69 | 70 | // Final blit to the destination 71 | cmd.Blit(sharpness, cameraColorTarget); // Use the default pass 72 | 73 | // Release temporary render texture 74 | cmd.ReleaseTemporaryRT(Shader.PropertyToID("_SharpnessRT")); 75 | } 76 | 77 | } -------------------------------------------------------------------------------- /Assets/Sharpness/SharpnessPass.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 621a6807c49ed364f9d34ba875d31138 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Sharpness/SharpnessRenderFeature.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class SharpnessRenderFeature : ScriptableRendererFeature 8 | { 9 | [System.Serializable] 10 | public class Settings 11 | { 12 | public RenderPassEvent renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing; 13 | //public Shader shader; 14 | } 15 | public Settings settings = new Settings(); 16 | 17 | SharpnessPass m_sharpnessPass; 18 | 19 | public override void Create() 20 | { 21 | this.name = "Sharpness Pass"; 22 | //if (settings.shader == null) 23 | //{ 24 | //Debug.LogWarning("No Shader"); 25 | //return; 26 | //} 27 | m_sharpnessPass = new SharpnessPass(settings.renderPassEvent); 28 | } 29 | 30 | public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) 31 | { 32 | renderer.EnqueuePass(m_sharpnessPass); 33 | } 34 | } -------------------------------------------------------------------------------- /Assets/Sharpness/SharpnessRenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 538c7c5b8b2738b4d9f76ad8fb639033 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Sharpness/SharpnessVolume.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using System; 4 | using UnityEngine; 5 | using UnityEngine.Rendering; 6 | using UnityEngine.Rendering.Universal; 7 | 8 | [VolumeComponentMenu("Joseph_Acerola/Custom Sharpness")] 9 | public class SharpnessVolume : VolumeComponent, IPostProcessComponent 10 | { 11 | public ClampedFloatParameter _amount = new ClampedFloatParameter(0.0f, -10.0f, 10.0f, true); 12 | public SharpnessModeParameter _sharpnessMode = new SharpnessModeParameter(SharpnessMode.Normal, true); 13 | 14 | public void load(Material material, ref RenderingData renderingData) 15 | { 16 | material.SetFloat("_Amount", _amount.value); 17 | } 18 | 19 | public bool IsActive() => true; 20 | public bool IsTileCompatible() => false; 21 | } 22 | public enum SharpnessMode 23 | { 24 | Normal, 25 | Contrast 26 | } 27 | 28 | [Serializable] 29 | public sealed class SharpnessModeParameter : VolumeParameter 30 | { 31 | public SharpnessModeParameter(SharpnessMode value, bool overrideState = false) : base(value, overrideState) { } 32 | } -------------------------------------------------------------------------------- /Assets/Sharpness/SharpnessVolume.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9d4cf5f783e02fb48888df7acd094e0c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/ToneMap/TonemapPass.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class TonemapPass : ScriptableRenderPass 8 | { 9 | static readonly string renderPassTag = "Tonemapper"; 10 | 11 | private TonemapVolume tonemapVolume; 12 | private Material tonemapMaterial; 13 | 14 | private RenderTexture grayscale; 15 | 16 | public TonemapPass(RenderPassEvent evt, Shader tonemapshader) 17 | { 18 | renderPassEvent = evt; 19 | var shader = tonemapshader; 20 | if (shader == null) 21 | { 22 | Debug.LogError("No Shader"); 23 | return; 24 | } 25 | tonemapMaterial = CoreUtils.CreateEngineMaterial(tonemapshader); 26 | 27 | /* 28 | if(grayscale == null) 29 | { 30 | grayscale = new RenderTexture(Screen.width, Screen.height, 0, RenderTextureFormat.RHalf, RenderTextureReadWrite.Linear); 31 | grayscale.useMipMap = true; 32 | grayscale.Create(); 33 | } 34 | */ 35 | } 36 | 37 | 38 | public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) 39 | { 40 | if (tonemapMaterial == null) 41 | { 42 | Debug.LogError("No Tonemap Material"); 43 | return; 44 | } 45 | 46 | if (!renderingData.cameraData.postProcessEnabled || renderingData.cameraData.cameraType == CameraType.SceneView) 47 | { 48 | //Debug.LogError("Post Processing in Camera not enabled"); 49 | return; 50 | } 51 | 52 | VolumeStack stack = VolumeManager.instance.stack; 53 | tonemapVolume = stack.GetComponent(); 54 | 55 | var cmd = CommandBufferPool.Get(renderPassTag); 56 | Render(cmd, ref renderingData); 57 | context.ExecuteCommandBuffer(cmd); 58 | 59 | CommandBufferPool.Release(cmd); 60 | } 61 | 62 | void Render(CommandBuffer cmd, ref RenderingData renderingData) 63 | { 64 | if (tonemapVolume.IsActive() == false) return; 65 | tonemapVolume.load(tonemapMaterial, ref renderingData); 66 | 67 | if (grayscale == null) 68 | { 69 | grayscale = RenderTexture.GetTemporary(Screen.width, Screen.height, 0, RenderTextureFormat.RHalf, RenderTextureReadWrite.Linear); 70 | grayscale.useMipMap = true; 71 | grayscale.Create(); 72 | } 73 | 74 | var source = renderingData.cameraData.renderer.cameraColorTarget; 75 | 76 | cmd.Blit(source, grayscale, tonemapMaterial, 0); 77 | 78 | tonemapMaterial.SetTexture("_LuminanceTex", grayscale); 79 | 80 | cmd.Blit(source, source, tonemapMaterial, (int)tonemapVolume._toneMapper.value); 81 | 82 | RenderTexture.ReleaseTemporary(grayscale); 83 | } 84 | 85 | } -------------------------------------------------------------------------------- /Assets/ToneMap/TonemapPass.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 872eae40432c56145b93bb9becfe079b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/ToneMap/TonemapRenderFeature.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class TonemapRenderFeature : ScriptableRendererFeature 8 | { 9 | [System.Serializable] 10 | public class Settings 11 | { 12 | public RenderPassEvent renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing; 13 | public Shader shader; 14 | //[Range(2, 10)] public int sampleTimes = 2; 15 | } 16 | public Settings settings = new Settings(); 17 | 18 | TonemapPass m_tonemapPass; 19 | private void OnEnable() 20 | { 21 | settings.shader = Shader.Find("Joseph&Acerola/Tonemapping"); 22 | } 23 | public override void Create() 24 | { 25 | this.name = "Tonemap Pass"; 26 | if (settings.shader == null) 27 | { 28 | Debug.LogWarning("No Shader"); 29 | return; 30 | } 31 | m_tonemapPass = new TonemapPass(settings.renderPassEvent, settings.shader); 32 | } 33 | 34 | public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) 35 | { 36 | renderer.EnqueuePass(m_tonemapPass); 37 | } 38 | } -------------------------------------------------------------------------------- /Assets/ToneMap/TonemapRenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0c3493bbea5ffc840bc6f71f7eaa0719 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/ToneMap/TonemapVolume.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aec6e248b5556e04d96f58a1777824bc 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/ToneMap/Tonemapping.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 00b74ee3e6ac300478d1a4dd94315f0c 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Vignette/Vignette.shader: -------------------------------------------------------------------------------- 1 | Shader "Joseph&Acerola/Vignette" { 2 | Properties{ 3 | _MainTex("Texture", 2D) = "white" {} 4 | } 5 | 6 | SubShader{ 7 | Pass { 8 | CGPROGRAM 9 | #pragma vertex vp 10 | #pragma fragment fp 11 | 12 | #include "UnityCG.cginc" 13 | 14 | struct VertexData { 15 | float4 vertex : POSITION; 16 | float2 uv : TEXCOORD0; 17 | }; 18 | 19 | struct v2f { 20 | float2 uv : TEXCOORD0; 21 | float4 vertex : SV_POSITION; 22 | }; 23 | 24 | v2f vp(VertexData v) { 25 | v2f o; 26 | o.vertex = UnityObjectToClipPos(v.vertex); 27 | o.uv = v.uv; 28 | return o; 29 | } 30 | 31 | sampler2D _MainTex; 32 | float2 _VignetteOffset, _VignetteSize; 33 | float _Intensity, _Roundness, _Smoothness; 34 | float3 _VignetteColor; 35 | 36 | float4 fp(v2f i) : SV_Target { 37 | float4 col = tex2D(_MainTex, i.uv); 38 | 39 | float2 pos = i.uv - 0.5f; 40 | pos *= _VignetteSize; 41 | pos += 0.5f; 42 | 43 | float2 d = abs(pos - (float2(0.5f, 0.5f) + _VignetteOffset)) * _Intensity; 44 | d = pow(saturate(d), _Roundness); 45 | float vfactor = pow(saturate(1.0f - dot(d, d)), _Smoothness); 46 | 47 | return float4(lerp(_VignetteColor, col.rgb, vfactor), 1.0f); 48 | } 49 | ENDCG 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /Assets/Vignette/Vignette.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0ce2682057ecb944297f9485d12e591c 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Vignette/VignettePass.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class VignettePass : ScriptableRenderPass 8 | { 9 | static readonly string renderPassTag = "Vignette"; 10 | 11 | private VignetteVolume VignetteVolume; 12 | private Material VignetteMaterial; 13 | 14 | public VignettePass(RenderPassEvent evt, Shader blendModeshader) 15 | { 16 | renderPassEvent = evt; 17 | var shader = blendModeshader; 18 | if (shader == null) 19 | { 20 | Debug.LogError("No Shader"); 21 | return; 22 | } 23 | VignetteMaterial = CoreUtils.CreateEngineMaterial(blendModeshader); 24 | } 25 | 26 | 27 | public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) 28 | { 29 | if (VignetteMaterial == null) 30 | { 31 | Debug.LogError("No Vignette Material"); 32 | return; 33 | } 34 | 35 | if (!renderingData.cameraData.postProcessEnabled || renderingData.cameraData.cameraType == CameraType.SceneView) 36 | { 37 | //Debug.LogError("Post Processing in Camera not enabled"); 38 | return; 39 | } 40 | 41 | VolumeStack stack = VolumeManager.instance.stack; 42 | VignetteVolume = stack.GetComponent(); 43 | 44 | var cmd = CommandBufferPool.Get(renderPassTag); 45 | Render(cmd, ref renderingData); 46 | context.ExecuteCommandBuffer(cmd); 47 | 48 | CommandBufferPool.Release(cmd); 49 | } 50 | 51 | void Render(CommandBuffer cmd, ref RenderingData renderingData) 52 | { 53 | if (VignetteVolume.IsActive() == false) return; 54 | VignetteVolume.load(VignetteMaterial, ref renderingData); 55 | 56 | var source = renderingData.cameraData.renderer.cameraColorTarget; 57 | 58 | cmd.Blit(source, source, VignetteMaterial); 59 | } 60 | 61 | } -------------------------------------------------------------------------------- /Assets/Vignette/VignettePass.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 069338aadb367aa41a9264f1dfaf20e9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Vignette/VignetteRenderFeature.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class VignetteRenderFeature : ScriptableRendererFeature 8 | { 9 | [System.Serializable] 10 | public class Settings 11 | { 12 | public RenderPassEvent renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing; 13 | public Shader shader; 14 | } 15 | public Settings settings = new Settings(); 16 | 17 | VignettePass m_VignettePass; 18 | private void OnEnable() 19 | { 20 | settings.shader = Shader.Find("Joseph&Acerola/Vignette"); 21 | } 22 | public override void Create() 23 | { 24 | this.name = "Vignette Pass"; 25 | if (settings.shader == null) 26 | { 27 | Debug.LogWarning("No Shader"); 28 | return; 29 | } 30 | m_VignettePass = new VignettePass(settings.renderPassEvent, settings.shader); 31 | } 32 | 33 | public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) 34 | { 35 | renderer.EnqueuePass(m_VignettePass); 36 | } 37 | } -------------------------------------------------------------------------------- /Assets/Vignette/VignetteRenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ad73a1ee3bccb1c43a3a9f72cd263073 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Vignette/VignetteVolume.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | using UnityEngine.Rendering; 6 | using UnityEngine.Rendering.Universal; 7 | 8 | [Serializable, VolumeComponentMenu("Joseph_Acerola/Custom Vignette")] 9 | public class VignetteVolume : VolumeComponent, IPostProcessComponent 10 | { 11 | public ColorParameter _vignetteColor = new ColorParameter(Color.black, true, true, true, true); 12 | public Vector2Parameter _vignetteOffset = new Vector2Parameter(Vector2.zero, true); 13 | public Vector2Parameter _vignetteSize = new Vector2Parameter(Vector2.one, true); 14 | public ClampedFloatParameter _intensity = new ClampedFloatParameter(1.0f, 0.0f, 5.0f, true); 15 | public ClampedFloatParameter _roundness = new ClampedFloatParameter(1.0f, 0.0f, 10.0f, true); 16 | public ClampedFloatParameter _smoothness = new ClampedFloatParameter(1.0f, 0.0f, 10.0f, true); 17 | 18 | public void load(Material material, ref RenderingData renderingData) 19 | { 20 | material.SetColor("_VignetteColor", _vignetteColor.value); 21 | material.SetVector("_VignetteOffset", _vignetteOffset.value); 22 | material.SetVector("_VignetteSize", _vignetteSize.value); 23 | material.SetFloat("_Intensity", _intensity.value); 24 | material.SetFloat("_Roundness", _roundness.value); 25 | material.SetFloat("_Smoothness", _smoothness.value); 26 | } 27 | 28 | public bool IsActive() => true; 29 | public bool IsTileCompatible() => false; 30 | } -------------------------------------------------------------------------------- /Assets/Vignette/VignetteVolume.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6c5750ff4653c934a962320f10978767 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Zoom/Zoom.shader: -------------------------------------------------------------------------------- 1 | Shader "Joseph&Acerola/Zoom" { 2 | Properties{ 3 | _MainTex("Texture", 2D) = "white" {} 4 | } 5 | 6 | SubShader{ 7 | 8 | Pass { 9 | CGPROGRAM 10 | #pragma vertex vp 11 | #pragma fragment fp 12 | 13 | #include "UnityCG.cginc" 14 | 15 | struct VertexData { 16 | float4 vertex : POSITION; 17 | float2 uv : TEXCOORD0; 18 | }; 19 | 20 | struct v2f { 21 | float2 uv : TEXCOORD0; 22 | float4 vertex : SV_POSITION; 23 | }; 24 | 25 | v2f vp(VertexData v) { 26 | v2f o; 27 | o.vertex = UnityObjectToClipPos(v.vertex); 28 | o.uv = v.uv; 29 | return o; 30 | } 31 | 32 | Texture2D _MainTex; 33 | SamplerState point_clamp_sampler, linear_clamp_sampler; 34 | float4 _MainTex_TexelSize; 35 | float4 _Offset; 36 | float _Zoom, _Rotation; 37 | int _ZoomMode; 38 | 39 | #define PI 3.14159265358979323846f 40 | 41 | float4 texture2DAA(float2 uv) { 42 | float2 uv_texspace = uv * _MainTex_TexelSize.zw; 43 | float2 seam = floor(uv_texspace + 0.5f); 44 | uv_texspace = (uv_texspace - seam) / fwidth(uv_texspace) + seam; 45 | uv_texspace = clamp(uv_texspace, seam - 0.5f, seam + 0.5f); 46 | return _MainTex.Sample(linear_clamp_sampler, uv_texspace / _MainTex_TexelSize.zw); 47 | } 48 | 49 | float4 fp(v2f i) : SV_Target { 50 | float2 zoomUV = i.uv * 2 - 1; 51 | zoomUV += float2(_Offset.x, _Offset.y); 52 | zoomUV *= _Zoom; 53 | 54 | float radians = _Rotation * PI / 180.0f; 55 | float2x2 R = { 56 | cos(radians), -sin(radians), 57 | sin(radians), cos(radians) 58 | }; 59 | zoomUV = mul(R, zoomUV); 60 | zoomUV = zoomUV * 0.5f + 0.5f; 61 | 62 | if (_ZoomMode == 0) 63 | return _MainTex.Sample(point_clamp_sampler, zoomUV); 64 | else if (_ZoomMode == 1) 65 | return texture2DAA(zoomUV); 66 | else 67 | return _MainTex.Sample(linear_clamp_sampler, zoomUV); 68 | } 69 | ENDCG 70 | } 71 | } 72 | } -------------------------------------------------------------------------------- /Assets/Zoom/Zoom.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 432ebb288551b6f49a329dd70a982cdf 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Zoom/ZoomPass.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class ZoomPass : ScriptableRenderPass 8 | { 9 | static readonly string renderPassTag = "Zoom"; 10 | 11 | private ZoomVolume ZoomVolume; 12 | private Material ZoomMaterial; 13 | 14 | public ZoomPass(RenderPassEvent evt, Shader blendModeshader) 15 | { 16 | renderPassEvent = evt; 17 | var shader = blendModeshader; 18 | if (shader == null) 19 | { 20 | Debug.LogError("No Shader"); 21 | return; 22 | } 23 | ZoomMaterial = CoreUtils.CreateEngineMaterial(blendModeshader); 24 | } 25 | 26 | 27 | public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) 28 | { 29 | if (ZoomMaterial == null) 30 | { 31 | Debug.LogError("No Color Correct Material"); 32 | return; 33 | } 34 | 35 | if (!renderingData.cameraData.postProcessEnabled || renderingData.cameraData.cameraType == CameraType.SceneView) 36 | { 37 | //Debug.LogError("Post Processing in Camera not enabled"); 38 | return; 39 | } 40 | 41 | VolumeStack stack = VolumeManager.instance.stack; 42 | ZoomVolume = stack.GetComponent(); 43 | 44 | var cmd = CommandBufferPool.Get(renderPassTag); 45 | Render(cmd, ref renderingData); 46 | context.ExecuteCommandBuffer(cmd); 47 | 48 | CommandBufferPool.Release(cmd); 49 | } 50 | 51 | void Render(CommandBuffer cmd, ref RenderingData renderingData) 52 | { 53 | if (ZoomVolume.IsActive() == false) return; 54 | ZoomVolume.load(ZoomMaterial, ref renderingData); 55 | 56 | var source = renderingData.cameraData.renderer.cameraColorTarget; 57 | 58 | cmd.Blit(source, source, ZoomMaterial); 59 | } 60 | 61 | } -------------------------------------------------------------------------------- /Assets/Zoom/ZoomPass.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 48189508e7d762541a420f2bbcaa331c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Zoom/ZoomRenderFeature.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using UnityEngine.Rendering.Universal; 6 | 7 | public class ZoomRenderFeature : ScriptableRendererFeature 8 | { 9 | [System.Serializable] 10 | public class Settings 11 | { 12 | public RenderPassEvent renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing; 13 | public Shader shader; 14 | //[Range(2, 10)] public int sampleTimes = 2; 15 | } 16 | public Settings settings = new Settings(); 17 | 18 | ZoomPass m_ZoomPass; 19 | private void OnEnable() 20 | { 21 | settings.shader = Shader.Find("Joseph&Acerola/Zoom"); 22 | } 23 | public override void Create() 24 | { 25 | this.name = "Zoom Pass"; 26 | if (settings.shader == null) 27 | { 28 | Debug.LogWarning("No Shader"); 29 | return; 30 | } 31 | m_ZoomPass = new ZoomPass(settings.renderPassEvent, settings.shader); 32 | } 33 | 34 | public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) 35 | { 36 | renderer.EnqueuePass(m_ZoomPass); 37 | } 38 | } -------------------------------------------------------------------------------- /Assets/Zoom/ZoomRenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1cf139920179abd45ac0e5321a9c16fa 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Zoom/ZoomVolume.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | using UnityEngine.Rendering; 6 | using UnityEngine.Rendering.Universal; 7 | 8 | [Serializable, VolumeComponentMenu("Joseph_Acerola/Custom Zoom")] 9 | public class ZoomVolume : VolumeComponent, IPostProcessComponent 10 | { 11 | public ZoomModeParameter _zoomMode = new ZoomModeParameter(ZoomMode.Point, true); 12 | public FloatParameter _zoom = new ClampedFloatParameter(1f, 0f, 2f, true); 13 | public Vector2Parameter _offset = new Vector2Parameter(Vector2.zero, true); 14 | public FloatParameter _rotation = new ClampedFloatParameter(0f, -180f, 180f, true); 15 | 16 | public void load(Material material, ref RenderingData renderingData) 17 | { 18 | material.SetFloat("_Zoom", _zoom.value); 19 | material.SetFloat("_Rotation", _rotation.value); 20 | material.SetInt("_ZoomMode", (int)_zoomMode.value); 21 | material.SetVector("_Offset", _offset.value); 22 | } 23 | 24 | public bool IsActive() => true; 25 | public bool IsTileCompatible() => false; 26 | } 27 | public enum ZoomMode 28 | { 29 | Point = 0, 30 | PixelArtAntiAlias, 31 | Linear 32 | } 33 | [Serializable] 34 | public sealed class ZoomModeParameter : VolumeParameter 35 | { 36 | public ZoomModeParameter(ZoomMode value, bool overrideState = false) : base(value, overrideState) { } 37 | } -------------------------------------------------------------------------------- /Assets/Zoom/ZoomVolume.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3c178b3b9bc615041b853dfcd02398a9 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) 2024 Josephy5 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 | --------------------------------------------------------------------------------