I am trying to make a post processing shader that creates a post processing effect, right now my shader just makes my camera effect display the current screen but slightly brighter when the post processing shader is enabled. What I am trying to do is duplicate the screen, blur that image, then apply as overlay to make the camera have a dreamy like effect, where the edges of objects are slightly glowing. For a good reference if you duplicate a image in photoshop, then apply a slight guassian blur to the top image and use overlay. Below is the script I made but the blur part of the effect is not showing for some reason.
Shader "Hidden/Custom/ScreenOverlayNew"
{
HLSLINCLUDE
#include "Packages/com.unity.postprocessing/PostProcessing/Shaders/StdLib.hlsl"
TEXTURE2D_SAMPLER2D(_MainTex, sampler_MainTex);
float _Opacity;
float _BlurSize = 0.5f;
float4 texelSize = 0.5f;
float4 Frag(VaryingsDefault i) : SV_Target{
float4 base = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoord);
// Add the blur by sampling the texture in a kernel
base += SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoord + texelSize.xy * float2(-_BlurSize, -_BlurSize)) * 0.05;
base += SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoord + texelSize.xy * float2(-_BlurSize, 0)) * 0.09;
base += SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoord + texelSize.xy * float2(-_BlurSize, _BlurSize)) * 0.05;
base += SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoord + texelSize.xy * float2(0, -_BlurSize)) * 0.09;
base += SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoord + texelSize.xy * float2(0, 0)) * 0.16;
base += SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoord + texelSize.xy * float2(0, _BlurSize)) * 0.09;
base += SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoord + texelSize.xy * float2(_BlurSize, -_BlurSize)) * 0.05;
base += SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoord + texelSize.xy * float2(_BlurSize, 0)) * 0.09;
base += SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoord + texelSize.xy * float2(_BlurSize, _BlurSize)) * 0.05;
base /= 1.6;
float4 calculateBase = (1 - (1 - base)*(1 - base));
return lerp(calculateBase, base, 0.75f);
}
ENDHLSL
SubShader {
Cull Off ZWrite Off ZTest Always
Pass
{
HLSLPROGRAM
#pragma vertex VertDefault
#pragma fragment Frag
ENDHLSL
}
}
}