New Version 1.6

New 125 balls & powerups.
Improved graphics.
This commit is contained in:
SkunkStudios 2025-05-07 06:18:40 +07:00
parent b35433ae45
commit 71779ef7ac
9413 changed files with 193360 additions and 264803 deletions

View file

@ -0,0 +1,83 @@
Shader "Hidden/Dof/Bokeh34" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_Source ("Base (RGB)", 2D) = "black" {}
}
SubShader {
CGINCLUDE
#include "UnityCG.cginc"
sampler2D _MainTex;
sampler2D _Source;
uniform half4 _ArScale;
uniform half _Intensity;
uniform half4 _Source_TexelSize;
struct v2f {
half4 pos : POSITION;
half2 uv2 : TEXCOORD0;
half4 source : TEXCOORD1;
};
#define COC bokeh.a
v2f vert (appdata_full v)
{
v2f o;
o.pos = v.vertex;
o.uv2.xy = v.texcoord.xy;// * 2.0; <- needed when using Triangles.js and not Quads.js
#if UNITY_UV_STARTS_AT_TOP
float4 bokeh = tex2Dlod (_Source, half4 (v.texcoord1.xy * half2(1,-1) + half2(0,1), 0, 0));
#else
float4 bokeh = tex2Dlod (_Source, half4 (v.texcoord1.xy, 0, 0));
#endif
o.source = bokeh;
o.pos.xy += (v.texcoord.xy * 2.0 - 1.0) * _ArScale.xy * COC;// + _ArScale.zw * coc;
o.source.rgb *= _Intensity;
return o;
}
half4 frag (v2f i) : COLOR
{
half4 color = tex2D (_MainTex, i.uv2.xy);
color.rgb *= i.source.rgb;
color.a *= Luminance(i.source.rgb*0.25);
return color;
}
ENDCG
Pass {
Blend OneMinusDstColor One
ZTest Always Cull Off ZWrite Off
Fog { Mode off }
CGPROGRAM
#pragma glsl
#pragma target 3.0
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vert
#pragma fragment frag
ENDCG
}
}
Fallback off
}

View file

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: e1810bb8510eabd4da3dc3a0bf2bcf7d
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,524 @@
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
Shader "Hidden/Dof/DepthOfField34" {
Properties {
_MainTex ("Base", 2D) = "" {}
_TapLowBackground ("TapLowBackground", 2D) = "" {}
_TapLowForeground ("TapLowForeground", 2D) = "" {}
_TapMedium ("TapMedium", 2D) = "" {}
}
CGINCLUDE
#include "UnityCG.cginc"
struct v2f {
half4 pos : POSITION;
half2 uv1 : TEXCOORD0;
};
struct v2fDofApply {
half4 pos : POSITION;
half2 uv : TEXCOORD0;
};
struct v2fRadius {
half4 pos : POSITION;
half2 uv : TEXCOORD0;
half4 uv1[4] : TEXCOORD1;
};
struct v2fDown {
half4 pos : POSITION;
half2 uv0 : TEXCOORD0;
half2 uv[2] : TEXCOORD1;
};
sampler2D _MainTex;
sampler2D _CameraDepthTexture;
sampler2D _TapLowBackground;
sampler2D _TapLowForeground;
sampler2D _TapMedium;
half4 _CurveParams;
half _ForegroundBlurExtrude;
uniform half3 _Threshhold;
uniform float4 _MainTex_TexelSize;
uniform float2 _InvRenderTargetSize;
v2f vert( appdata_img v ) {
v2f o;
o.pos = UnityObjectToClipPos (v.vertex);
o.uv1.xy = v.texcoord.xy;
return o;
}
v2fRadius vertWithRadius( appdata_img v ) {
v2fRadius o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv.xy = v.texcoord.xy;
const half2 blurOffsets[4] = {
half2(-0.5, +1.5),
half2(+0.5, -1.5),
half2(+1.5, +0.5),
half2(-1.5, -0.5)
};
o.uv1[0].xy = v.texcoord.xy + 5.0 * _MainTex_TexelSize.xy * blurOffsets[0];
o.uv1[1].xy = v.texcoord.xy + 5.0 * _MainTex_TexelSize.xy * blurOffsets[1];
o.uv1[2].xy = v.texcoord.xy + 5.0 * _MainTex_TexelSize.xy * blurOffsets[2];
o.uv1[3].xy = v.texcoord.xy + 5.0 * _MainTex_TexelSize.xy * blurOffsets[3];
o.uv1[0].zw = v.texcoord.xy + 3.0 * _MainTex_TexelSize.xy * blurOffsets[0];
o.uv1[1].zw = v.texcoord.xy + 3.0 * _MainTex_TexelSize.xy * blurOffsets[1];
o.uv1[2].zw = v.texcoord.xy + 3.0 * _MainTex_TexelSize.xy * blurOffsets[2];
o.uv1[3].zw = v.texcoord.xy + 3.0 * _MainTex_TexelSize.xy * blurOffsets[3];
return o;
}
v2fDofApply vertDofApply( appdata_img v ) {
v2fDofApply o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv.xy = v.texcoord.xy;
return o;
}
v2fDown vertDownsampleWithCocConserve(appdata_img v) {
v2fDown o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv0.xy = v.texcoord.xy;
o.uv[0].xy = v.texcoord.xy + half2(-1.0,-1.0) * _InvRenderTargetSize;
o.uv[1].xy = v.texcoord.xy + half2(1.0,-1.0) * _InvRenderTargetSize;
return o;
}
half4 BokehPrereqs (sampler2D tex, half4 uv1[4], half4 center, half considerCoc) {
// @NOTE 1:
// we are checking for 3 things in order to create a bokeh.
// goal is to get the highest bang for the buck.
// 1.) contrast/frequency should be very high (otherwise bokeh mostly unvisible)
// 2.) luminance should be high
// 3.) no occluder nearby (stored in alpha channel)
// @NOTE 2: about the alpha channel in littleBlur:
// the alpha channel stores an heuristic on how likely it is
// that there is no bokeh occluder nearby.
// if we didn't' check for that, we'd get very noise bokeh
// popping because of the sudden contrast changes
half4 sampleA = tex2D(tex, uv1[0].zw);
half4 sampleB = tex2D(tex, uv1[1].zw);
half4 sampleC = tex2D(tex, uv1[2].zw);
half4 sampleD = tex2D(tex, uv1[3].zw);
half4 littleBlur = 0.125 * (sampleA + sampleB + sampleC + sampleD);
sampleA = tex2D(tex, uv1[0].xy);
sampleB = tex2D(tex, uv1[1].xy);
sampleC = tex2D(tex, uv1[2].xy);
sampleD = tex2D(tex, uv1[3].xy);
littleBlur += 0.125 * (sampleA + sampleB + sampleC + sampleD);
littleBlur = lerp (littleBlur, center, saturate(100.0 * considerCoc * abs(littleBlur.a - center.a)));
return littleBlur;
}
half4 fragDownsampleWithCocConserve(v2fDown i) : COLOR {
half2 rowOfs[4];
rowOfs[0] = half2(0.0, 0.0);
rowOfs[1] = half2(0.0, _InvRenderTargetSize.y);
rowOfs[2] = half2(0.0, _InvRenderTargetSize.y) * 2.0;
rowOfs[3] = half2(0.0, _InvRenderTargetSize.y) * 3.0;
half4 color = tex2D(_MainTex, i.uv0.xy);
half4 sampleA = tex2D(_MainTex, i.uv[0].xy + rowOfs[0]);
half4 sampleB = tex2D(_MainTex, i.uv[1].xy + rowOfs[0]);
half4 sampleC = tex2D(_MainTex, i.uv[0].xy + rowOfs[2]);
half4 sampleD = tex2D(_MainTex, i.uv[1].xy + rowOfs[2]);
color += sampleA + sampleB + sampleC + sampleD;
color *= 0.2;
// @NOTE we are doing max on the alpha channel for 2 reasons:
// 1) foreground blur likes a slightly bigger radius
// 2) otherwise we get an ugly outline between high blur- and medium blur-areas
// drawback: we get a little bit of color bleeding
color.a = max(max(sampleA.a, sampleB.a), max(sampleC.a, sampleD.a));
return color;
}
half4 fragDofApplyBg (v2fDofApply i) : COLOR {
half4 tapHigh = tex2D (_MainTex, i.uv.xy);
#if SHADER_API_D3D9 || SHADER_API_D3D11 || SHADER_API_XBOX360
if (_MainTex_TexelSize.y < 0)
i.uv.xy = i.uv.xy * half2(1,-1)+half2(0,1);
#endif
half4 tapLow = tex2D (_TapLowBackground, i.uv.xy); // already mixed with medium blur
tapHigh = lerp (tapHigh, tapLow, tapHigh.a);
return tapHigh;
}
half4 fragDofApplyBgDebug (v2fDofApply i) : COLOR {
half4 tapHigh = tex2D (_MainTex, i.uv.xy);
half4 tapLow = tex2D (_TapLowBackground, i.uv.xy);
half4 tapMedium = tex2D (_TapMedium, i.uv.xy);
tapMedium.rgb = (tapMedium.rgb + half3 (1, 1, 0)) * 0.5;
tapLow.rgb = (tapLow.rgb + half3 (0, 1, 0)) * 0.5;
tapLow = lerp (tapMedium, tapLow, saturate (tapLow.a * tapLow.a));
tapLow = tapLow * 0.5 + tex2D (_TapLowBackground, i.uv.xy) * 0.5;
return lerp (tapHigh, tapLow, tapHigh.a);
}
half4 fragDofApplyFg (v2fDofApply i) : COLOR {
half4 fgBlur = tex2D(_TapLowForeground, i.uv.xy);
#if SHADER_API_D3D9 || SHADER_API_D3D11 || SHADER_API_XBOX360
if (_MainTex_TexelSize.y < 0)
i.uv.xy = i.uv.xy * half2(1,-1)+half2(0,1);
#endif
half4 fgColor = tex2D(_MainTex,i.uv.xy);
//fgBlur.a = saturate(fgBlur.a*_ForegroundBlurWeight+saturate(fgColor.a-fgBlur.a));
//fgBlur.a = max (fgColor.a, (2.0 * fgBlur.a - fgColor.a)) * _ForegroundBlurExtrude;
fgBlur.a = max(fgColor.a, fgBlur.a * _ForegroundBlurExtrude); //max (fgColor.a, (2.0*fgBlur.a-fgColor.a)) * _ForegroundBlurExtrude;
return lerp (fgColor, fgBlur, saturate(fgBlur.a));
}
half4 fragDofApplyFgDebug (v2fDofApply i) : COLOR {
half4 fgBlur = tex2D(_TapLowForeground, i.uv.xy);
half4 fgColor = tex2D(_MainTex,i.uv.xy);
fgBlur.a = max(fgColor.a, fgBlur.a * _ForegroundBlurExtrude); //max (fgColor.a, (2.0*fgBlur.a-fgColor.a)) * _ForegroundBlurExtrude;
half4 tapMedium = half4 (1, 1, 0, fgBlur.a);
tapMedium.rgb = 0.5 * (tapMedium.rgb + fgColor.rgb);
fgBlur.rgb = 0.5 * (fgBlur.rgb + half3(0,1,0));
fgBlur.rgb = lerp (tapMedium.rgb, fgBlur.rgb, saturate (fgBlur.a * fgBlur.a));
return lerp ( fgColor, fgBlur, saturate(fgBlur.a));
}
half4 fragCocBg (v2f i) : COLOR {
float d = UNITY_SAMPLE_DEPTH ( tex2D (_CameraDepthTexture, i.uv1.xy) );
d = Linear01Depth (d);
half coc = 0.0;
half focalDistance01 = _CurveParams.w + _CurveParams.z;
if (d > focalDistance01)
coc = (d - focalDistance01);
coc = saturate (coc * _CurveParams.y);
return coc;
}
half4 fragCocFg (v2f i) : COLOR {
half4 color = tex2D (_MainTex, i.uv1.xy);
color.a = 0.0;
#if SHADER_API_D3D9 || SHADER_API_D3D11 || SHADER_API_XBOX360
if (_MainTex_TexelSize.y < 0)
i.uv1.xy = i.uv1.xy * half2(1,-1)+half2(0,1);
#endif
float d = UNITY_SAMPLE_DEPTH (tex2D (_CameraDepthTexture, i.uv1.xy) );
d = Linear01Depth (d);
half focalDistance01 = (_CurveParams.w - _CurveParams.z);
if (d < focalDistance01)
color.a = (focalDistance01 - d);
color.a = saturate (color.a * _CurveParams.x);
return color;
}
// not being used atm
half4 fragMask (v2f i) : COLOR {
return half4(0,0,0,0);
}
// used for simple one one blend
half4 fragAddBokeh (v2f i) : COLOR {
half4 from = tex2D( _MainTex, i.uv1.xy );
return from;
}
half4 fragAddFgBokeh (v2f i) : COLOR {
half4 from = tex2D( _MainTex, i.uv1.xy );
return from;
}
half4 fragDarkenForBokeh(v2fRadius i) : COLOR {
half4 fromOriginal = tex2D(_MainTex, i.uv.xy);
half4 lowRez = BokehPrereqs (_MainTex, i.uv1, fromOriginal, _Threshhold.z);
half4 outColor = half4(0,0,0, fromOriginal.a);
half modulate = fromOriginal.a;
// this code imitates the if-then-else conditions below
half2 conditionCheck = half2( dot(abs(fromOriginal.rgb-lowRez.rgb), half3(0.3,0.5,0.2)), Luminance(fromOriginal.rgb));
conditionCheck *= fromOriginal.a;
conditionCheck = saturate(_Threshhold.xy - conditionCheck);
outColor = lerp (outColor, fromOriginal, saturate (dot(conditionCheck, half2(1000.0,1000.0))));
/*
if ( abs(dot(fromOriginal.rgb - lowRez.rgb, half3 (0.3,0.5,0.2))) * modulate < _Threshhold.x)
outColor = fromOriginal; // no darkening
if (Luminance(fromOriginal.rgb) * modulate < _Threshhold.y)
outColor = fromOriginal; // no darkening
if (lowRez.a < _Threshhold.z) // need to make foreground not cast false bokeh's
outColor = fromOriginal; // no darkenin
*/
return outColor;
}
half4 fragExtractAndAddToBokeh (v2fRadius i) : COLOR {
half4 from = tex2D(_MainTex, i.uv.xy);
half4 lowRez = BokehPrereqs(_MainTex, i.uv1, from, _Threshhold.z);
half4 outColor = from;
// this code imitates the if-then-else conditions below
half2 conditionCheck = half2( dot(abs(from.rgb-lowRez.rgb), half3(0.3,0.5,0.2)), Luminance(from.rgb));
conditionCheck *= from.a;
conditionCheck = saturate(_Threshhold.xy - conditionCheck);
outColor = lerp (outColor, half4(0,0,0,0), saturate (dot(conditionCheck, half2(1000.0,1000.0))));
/*
if ( abs(dot(from.rgb - lowRez.rgb, half3 (0.3,0.5,0.2))) * modulate < _Threshhold.x)
outColor = half4(0,0,0,0); // don't add
if (Luminance(from.rgb) * modulate < _Threshhold.y)
outColor = half4(0,0,0,0); // don't add
if (lowRez.a < _Threshhold.z) // need to make foreground not cast false bokeh's
outColor = half4(0,0,0,0); // don't add
*/
return outColor;
}
ENDCG
Subshader {
// pass 0
Pass {
ZTest Always Cull Off ZWrite Off
Fog { Mode off }
CGPROGRAM
#pragma exclude_renderers flash
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vertDofApply
#pragma fragment fragDofApplyBg
ENDCG
}
// pass 1
Pass {
ZTest Always Cull Off ZWrite Off
ColorMask RGB
Fog { Mode off }
CGPROGRAM
#pragma exclude_renderers flash
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vertDofApply
#pragma fragment fragDofApplyFgDebug
ENDCG
}
// pass 2
Pass {
ZTest Always Cull Off ZWrite Off
ColorMask RGB
Fog { Mode off }
CGPROGRAM
#pragma exclude_renderers flash
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vertDofApply
#pragma fragment fragDofApplyBgDebug
ENDCG
}
// pass 3
Pass {
ZTest Always Cull Off ZWrite Off
ColorMask A
Fog { Mode off }
CGPROGRAM
#pragma exclude_renderers flash
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vert
#pragma fragment fragCocBg
ENDCG
}
// pass 4
Pass {
ZTest Always Cull Off ZWrite Off
ColorMask RGB
//Blend One One
Fog { Mode off }
CGPROGRAM
#pragma exclude_renderers flash
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vertDofApply
#pragma fragment fragDofApplyFg
ENDCG
}
// pass 5
Pass {
ZTest Always Cull Off ZWrite Off
ColorMask ARGB
Fog { Mode off }
CGPROGRAM
#pragma exclude_renderers flash
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vert
#pragma fragment fragCocFg
ENDCG
}
// pass 6
Pass {
ZTest Always Cull Off ZWrite Off
Fog { Mode off }
CGPROGRAM
#pragma exclude_renderers flash
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vertDownsampleWithCocConserve
#pragma fragment fragDownsampleWithCocConserve
ENDCG
}
// pass 7
// not being used atm
Pass {
ZTest Always Cull Off ZWrite Off
ColorMask RGBA
Fog { Mode off }
CGPROGRAM
#pragma exclude_renderers flash
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vert
#pragma fragment fragMask
ENDCG
}
// pass 8
Pass {
ZTest Always Cull Off ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
ColorMask RGB
Fog { Mode off }
CGPROGRAM
#pragma exclude_renderers flash
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vert
#pragma fragment fragAddBokeh
ENDCG
}
// pass 9
Pass {
ZTest Always Cull Off ZWrite Off
Blend One One
ColorMask RGB
Fog { Mode off }
CGPROGRAM
#pragma exclude_renderers flash
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vertWithRadius
#pragma fragment fragExtractAndAddToBokeh
ENDCG
}
// pass 10
Pass {
ZTest Always Cull Off ZWrite Off
Fog { Mode off }
CGPROGRAM
#pragma exclude_renderers flash
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vertWithRadius
#pragma fragment fragDarkenForBokeh
ENDCG
}
// pass 11
Pass {
ZTest Always Cull Off ZWrite Off
Fog { Mode off }
CGPROGRAM
#pragma exclude_renderers flash
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vertWithRadius
#pragma fragment fragExtractAndAddToBokeh
ENDCG
}
}
Fallback off
}

View file

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: b8ae1eeb817251f4984be5ff8cc6fb7c
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,909 @@
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
Shader "Hidden/Dof/DepthOfFieldHdr" {
Properties {
_MainTex ("-", 2D) = "black" {}
_FgOverlap ("-", 2D) = "black" {}
_LowRez ("-", 2D) = "black" {}
}
CGINCLUDE
#include "UnityCG.cginc"
struct v2f {
half4 pos : POSITION;
half2 uv : TEXCOORD0;
half2 uv1 : TEXCOORD1;
};
struct v2fRadius {
half4 pos : POSITION;
half2 uv : TEXCOORD0;
half4 uv1[4] : TEXCOORD1;
};
struct v2fBlur {
half4 pos : POSITION;
half2 uv : TEXCOORD0;
half4 uv01 : TEXCOORD1;
half4 uv23 : TEXCOORD2;
half4 uv45 : TEXCOORD3;
half4 uv67 : TEXCOORD4;
half4 uv89 : TEXCOORD5;
};
uniform sampler2D _MainTex;
uniform sampler2D _CameraDepthTexture;
uniform sampler2D _FgOverlap;
uniform sampler2D _LowRez;
uniform half4 _CurveParams;
uniform float4 _MainTex_TexelSize;
uniform half4 _Offsets;
v2f vert( appdata_img v ) {
v2f o;
o.pos = UnityObjectToClipPos (v.vertex);
o.uv1.xy = v.texcoord.xy;
o.uv.xy = v.texcoord.xy;
#if SHADER_API_D3D9 || SHADER_API_XBOX360 || SHADER_API_D3D11
if (_MainTex_TexelSize.y < 0)
o.uv.y = 1-o.uv.y;
#endif
return o;
}
v2fBlur vertBlurPlusMinus (appdata_img v) {
v2fBlur o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv.xy = v.texcoord.xy;
o.uv01 = v.texcoord.xyxy + _Offsets.xyxy * half4(1,1, -1,-1) * _MainTex_TexelSize.xyxy;
o.uv23 = v.texcoord.xyxy + _Offsets.xyxy * half4(2,2, -2,-2) * _MainTex_TexelSize.xyxy;// * 3.0;
o.uv45 = v.texcoord.xyxy + _Offsets.xyxy * half4(3,3, -3,-3) * _MainTex_TexelSize.xyxy;// * 3.0;
o.uv67 = v.texcoord.xyxy + _Offsets.xyxy * half4(4,4, -4,-4) * _MainTex_TexelSize.xyxy;// * 4.0;
o.uv89 = v.texcoord.xyxy + _Offsets.xyxy * half4(5,5, -5,-5) * _MainTex_TexelSize.xyxy;// * 5.0;
return o;
}
inline half3 Axis(half2 coords, half minRange)
{
half coc = tex2D(_MainTex, coords).a;
coc *= coc;
return half3( max(coc, minRange) * (_Offsets.xy), coc);
}
inline half3 AxisFromSample(half4 sample, half minRange)
{
return half3( max(sample.a, minRange) * (_Offsets.xy), sample.a);
}
inline half2 AxisFromSamplePoisson(half4 sample, half minRange)
{
return half2( max(sample.a, minRange), sample.a);
}
inline float4 AdjustForLowRezBuffers(half2 coords, half4 returnValue)
{
half4 highRezColor = tex2D(_MainTex, coords);
return lerp(highRezColor, returnValue, smoothstep(0.135, 0.5, highRezColor.a)); // lerp value is important as blending HR <-> LR is pretty PRETTY REALLY ugly :/
}
inline float ForegroundOverlap(float2 coords)
{
return saturate(tex2D(_FgOverlap,coords).a);
}
inline float BokehWeightForDisc(float4 sample, float4 center, float blurWidth, float2 tapOffset)
{
return smoothstep(-1,0, sample.a * blurWidth - length(tapOffset * blurWidth * center.a));
}
inline float BokehWeightForDiscFg(float4 sample, float4 center, float blurWidth, float2 tapOffset)
{
return smoothstep(-1,0, length(tapOffset * blurWidth * center.a)- sample.a * blurWidth);
}
static const float2 poisson[13] =
{
float2(0,0),
float2(-0.326212,-0.40581),
float2(-0.840144,-0.07358),
float2(-0.695914,0.457137),
float2(-0.203345,0.620716),
float2(0.96234,-0.194983),
float2(0.473434,-0.480026),
float2(0.519456,0.767022),
float2(0.185461,-0.893124),
float2(0.507431,0.064425),
float2(0.89642,0.412458),
float2(-0.32194,-0.932615),
float2(-0.791559,-0.59771)
};
half4 fragBlurPoisson (v2f i) : COLOR
{
const int TAPS = 13; // X1
half4 centerTap = tex2D(_MainTex, i.uv1.xy);
half4 sum = centerTap;
half4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w;
half sampleCount = centerTap.a;
sum *= sampleCount;
for(int l=1; l < TAPS; l++)
{
half2 sampleUV = i.uv1.xy + poisson[l].xy * poissonScale;
half4 sample0 = tex2D(_MainTex, sampleUV.xy);
half weight0 = BokehWeightForDisc(sample0, centerTap, _Offsets.w, poisson[l].xy);
sum += sample0 * weight0;
sampleCount += weight0 ;
}
half4 returnValue = sum / (0.00001 + sampleCount);
returnValue.a = centerTap.a;
return returnValue;
}
half4 fragBlurPoissonLowRez (v2f i) : COLOR
{
const int TAPS = 13; // X1
half4 centerTap = tex2D(_LowRez, i.uv1.xy);
half4 sum = centerTap;
half4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w;
half sampleCount = centerTap.a;
sum *= sampleCount;
for(int l=1; l < TAPS; l++)
{
half2 sampleUV = i.uv1.xy + poisson[l].xy * poissonScale;
half4 sample0 = tex2D(_LowRez, sampleUV.xy);
half weight0 = BokehWeightForDisc(sample0, centerTap, _Offsets.w, poisson[l].xy);
sum += sample0 * weight0;
sampleCount += weight0 ;
}
half4 returnValue = sum / (0.00001 + sampleCount);
returnValue.a = centerTap.a;
return AdjustForLowRezBuffers(i.uv1.xy, returnValue);
}
half4 fragBlurProduction (v2f i) : COLOR
{
const int TAPS = 13; // X2
half4 centerTap = tex2D(_MainTex, i.uv1.xy);
half4 sum = centerTap;
half4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w;
half sampleCount = centerTap.a;
sum *= sampleCount;
for(int l=1; l < TAPS; l++)
{
half4 sampleUV = i.uv1.xyxy + half4(poisson[l].xy,-poisson[l].xy) * poissonScale;
half4 sample0 = tex2D(_MainTex, sampleUV.xy);
half4 sample1 = tex2D(_MainTex, sampleUV.zw);
half weight0 = BokehWeightForDisc(sample0, centerTap, _Offsets.w, poisson[l].xy);
half weight1 = BokehWeightForDisc(sample1, centerTap, _Offsets.w, -poisson[l].xy);
sum += sample0 * weight0;
sum += sample1 * weight1;
sampleCount += weight0 + weight1;
}
half4 returnValue = sum / (0.00001 + sampleCount);
returnValue.a = centerTap.a;
return returnValue;
}
half4 fragBlurProductionLowRez (v2f i) : COLOR
{
const int TAPS = 13; // X2
half4 centerTap = tex2D(_LowRez, i.uv1.xy);
half4 sum = centerTap;
half4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w;
half sampleCount = centerTap.a;
sum *= sampleCount;
for(int l=1; l < TAPS; l++)
{
half4 sampleUV = i.uv1.xyxy + half4(poisson[l].xy,-poisson[l].xy) * poissonScale;
half4 sample0 = tex2D(_LowRez, sampleUV.xy);
half4 sample1 = tex2D(_LowRez, sampleUV.zw);
half weight0 = BokehWeightForDisc(sample0, centerTap, _Offsets.w, poisson[l].xy);
half weight1 = BokehWeightForDisc(sample1, centerTap, _Offsets.w, -poisson[l].xy);
sum += sample0 * weight0;
sum += sample1 * weight1;
sampleCount += weight0 + weight1;
}
half4 returnValue = sum / (0.00001 + sampleCount);
returnValue.a = centerTap.a;
return AdjustForLowRezBuffers(i.uv1.xy, returnValue);
}
static const float3 movieTaps[60] =
{
float3( 0.2165, 0.1250, 1.0000 ),
float3( 0.0000, 0.2500, 1.0000 ),
float3( -0.2165, 0.1250, 1.0000 ),
float3( -0.2165, -0.1250, 1.0000 ),
float3( -0.0000, -0.2500, 1.0000 ),
float3( 0.2165, -0.1250, 1.0000 ),
float3( 0.4330, 0.2500, 1.0000 ),
float3( 0.0000, 0.5000, 1.0000 ),
float3( -0.4330, 0.2500, 1.0000 ),
float3( -0.4330, -0.2500, 1.0000 ),
float3( -0.0000, -0.5000, 1.0000 ),
float3( 0.4330, -0.2500, 1.0000 ),
float3( 0.6495, 0.3750, 1.0000 ),
float3( 0.0000, 0.7500, 1.0000 ),
float3( -0.6495, 0.3750, 1.0000 ),
float3( -0.6495, -0.3750, 1.0000 ),
float3( -0.0000, -0.7500, 1.0000 ),
float3( 0.6495, -0.3750, 1.0000 ),
float3( 0.8660, 0.5000, 1.0000 ),
float3( 0.0000, 1.0000, 1.0000 ),
float3( -0.8660, 0.5000, 1.0000 ),
float3( -0.8660, -0.5000, 1.0000 ),
float3( -0.0000, -1.0000, 1.0000 ),
float3( 0.8660, -0.5000, 1.0000 ),
float3( 0.2163, 0.3754, 0.8670 ),
float3( -0.2170, 0.3750, 0.8670 ),
float3( -0.4333, -0.0004, 0.8670 ),
float3( -0.2163, -0.3754, 0.8670 ),
float3( 0.2170, -0.3750, 0.8670 ),
float3( 0.4333, 0.0004, 0.8670 ),
float3( 0.4328, 0.5004, 0.8847 ),
float3( -0.2170, 0.6250, 0.8847 ),
float3( -0.6498, 0.1246, 0.8847 ),
float3( -0.4328, -0.5004, 0.8847 ),
float3( 0.2170, -0.6250, 0.8847 ),
float3( 0.6498, -0.1246, 0.8847 ),
float3( 0.6493, 0.6254, 0.9065 ),
float3( -0.2170, 0.8750, 0.9065 ),
float3( -0.8663, 0.2496, 0.9065 ),
float3( -0.6493, -0.6254, 0.9065 ),
float3( 0.2170, -0.8750, 0.9065 ),
float3( 0.8663, -0.2496, 0.9065 ),
float3( 0.2160, 0.6259, 0.8851 ),
float3( -0.4340, 0.5000, 0.8851 ),
float3( -0.6500, -0.1259, 0.8851 ),
float3( -0.2160, -0.6259, 0.8851 ),
float3( 0.4340, -0.5000, 0.8851 ),
float3( 0.6500, 0.1259, 0.8851 ),
float3( 0.4325, 0.7509, 0.8670 ),
float3( -0.4340, 0.7500, 0.8670 ),
float3( -0.8665, -0.0009, 0.8670 ),
float3( -0.4325, -0.7509, 0.8670 ),
float3( 0.4340, -0.7500, 0.8670 ),
float3( 0.8665, 0.0009, 0.8670 ),
float3( 0.2158, 0.8763, 0.9070 ),
float3( -0.6510, 0.6250, 0.9070 ),
float3( -0.8668, -0.2513, 0.9070 ),
float3( -0.2158, -0.8763, 0.9070 ),
float3( 0.6510, -0.6250, 0.9070 ),
float3( 0.8668, 0.2513, 0.9070 )
};
// insane movie quality
half4 fragBlurMovie (v2f i) : COLOR
{
const int TAPS = 60;
half4 centerTap = tex2D(_MainTex, i.uv1.xy);
half4 sum = centerTap;
half4 poissonScale = _MainTex_TexelSize.xyxy * (centerTap.a) * _Offsets.w;
half sampleCount = centerTap.a;
sum *= sampleCount;
for(int l=0; l < TAPS; l++)
{
half2 sampleUV = i.uv1.xy + movieTaps[l].xy * poissonScale;
half4 sample0 = tex2D(_MainTex, sampleUV.xy);
half weight0 = saturate( BokehWeightForDisc(sample0, centerTap, _Offsets.w, movieTaps[l].xy) * movieTaps[l].z);
sum += sample0 * weight0;
sampleCount += weight0;
}
half4 returnValue = sum / (0.00001 + sampleCount);
returnValue.a = centerTap.a;
return returnValue;
}
// insane movie quality in low resolution
half4 fragBlurMovieLowRez (v2f i) : COLOR
{
const int TAPS = 60;
half4 centerTap = tex2D(_LowRez, i.uv1.xy);
half4 sum = centerTap;
half4 poissonScale = _MainTex_TexelSize.xyxy * (centerTap.a) * _Offsets.w;
half sampleCount = centerTap.a;
sum *= sampleCount;
for(int l=1; l < TAPS; l++)
{
half2 sampleUV = i.uv1.xy + movieTaps[l].xy * poissonScale;
half4 sample0 = tex2D(_LowRez, sampleUV.xy);
half weight0 = BokehWeightForDisc(sample0, centerTap, _Offsets.w, movieTaps[l].xy) * movieTaps[l].z;
sum += sample0 * weight0;
sampleCount += weight0;
}
half4 returnValue = sum / (0.00001 + sampleCount);
returnValue.a = centerTap.a;
return AdjustForLowRezBuffers(i.uv1.xy, returnValue);
}
half4 fragBlurHighSampleCount (v2f i) : COLOR
{
const int TAPS = 12;
const half FILTER_KERNEL_WEIGHTS[12] = {1.0, 0.8, 0.65, 0.5, 0.4, 0.2, 0.1, 0.05, 0.025, 0.0125, 0.005, 0.00175};
//const half FILTER_KERNEL_WEIGHTS[10] = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0};
half fgOverlap = saturate(tex2D(_FgOverlap, i.uv1.xy).a*3); // CheckForegroundOverlap(i.uv.xy);
half4 centerTap = tex2D(_MainTex, i.uv1.xy);
half4 sum = centerTap;// * FILTER_KERNEL_WEIGHTS[0];
half2 offset = AxisFromSample(sum, fgOverlap); //GetFirstAxis(TexCoord);
half amount = length(offset.xy);
// half centerDepth = Linear01Depth(tex2D(_CameraDepthTexture, i.uv.xy).x);
half sampleCount = FILTER_KERNEL_WEIGHTS[0];
half4 steps = (offset.xy * _MainTex_TexelSize.xy).xyxy;
steps.zw *= -1;
for(int l=1; l < TAPS; l++)
{
//djhkjsdhkjashdkjashdkj kashd as iiiiii
half4 sampleUV = i.uv1.xyxy + steps * l;
// Color samples
half4 sample0 = tex2D(_MainTex, sampleUV.xy);
half4 sample1 = tex2D(_MainTex, sampleUV.zw);
// Maximum extent of the blur at these samples
half maxLengthAt0;
half maxLengthAt1;
maxLengthAt0 = length(AxisFromSample(sample0, fgOverlap).xy) * (TAPS+1);//length(GetFirstAxis(sampleUV.xy)) * (NUM_STEPS+1);
maxLengthAt1 = length(AxisFromSample(sample1, fgOverlap).xy) * (TAPS+1);//length(GetFirstAxis(sampleUV.zw)) * (NUM_STEPS+1);
// half depth0 = Linear01Depth(tex2D(_CameraDepthTexture, sampleUV.xy).x);
//half depth1 = Linear01Depth(tex2D(_CameraDepthTexture, sampleUV.zw).x);
//depth0 = saturate(1-(centerDepth-depth0)*(centerDepth-depth0)*10.5);
//depth1 = saturate(1-(centerDepth-depth1)*(centerDepth-depth1)*10.5);
// Y U NO WORKY ?
half currentLength = amount * ((half)l);
half weight0 = max(0, saturate((maxLengthAt0 - currentLength))) * FILTER_KERNEL_WEIGHTS[l];//* depth0;
sum += sample0 * weight0;
sampleCount += weight0;
half weight1 = max(0, saturate((maxLengthAt1 - currentLength))) * FILTER_KERNEL_WEIGHTS[l];//* depth1;
sum += sample1 * weight1;
sampleCount += weight1;
}
half4 returnValue = sum / sampleCount;
returnValue.a = centerTap.a;
return returnValue;
}
half4 fragBlurLowSampleCount (v2f i) : COLOR
{
const int TAPS = 6;
const half FILTER_KERNEL_WEIGHTS[6] = {1.0, 0.8, 0.6, 0.375, 0.135, 0.075};
half fgOverlap = saturate(tex2D(_FgOverlap, i.uv1.xy).a*3); // CheckForegroundOverlap(i.uv.xy);
half4 centerTap = tex2D(_MainTex, i.uv1.xy);
half4 sum = centerTap;// * FILTER_KERNEL_WEIGHTS[0];
half2 offset = AxisFromSample(sum, fgOverlap); //GetFirstAxis(TexCoord);
half amount = length(offset.xy);
// half centerDepth = Linear01Depth(tex2D(_CameraDepthTexture, i.uv.xy).x);
half sampleCount = FILTER_KERNEL_WEIGHTS[0];
half4 steps = (offset.xy * _MainTex_TexelSize.xy).xyxy;
steps.zw *= -1;
for(int l=1; l < TAPS; l++)
{
//djhkjsdhkjashdkjashdkj kashd as iiiiii
half4 sampleUV = i.uv1.xyxy + steps * l;
// Color samples
half4 sample0 = tex2D(_MainTex, sampleUV.xy);
half4 sample1 = tex2D(_MainTex, sampleUV.zw);
// Maximum extent of the blur at these samples
half maxLengthAt0;
half maxLengthAt1;
maxLengthAt0 = length(AxisFromSample(sample0, fgOverlap).xy) * (TAPS+1);//length(GetFirstAxis(sampleUV.xy)) * (NUM_STEPS+1);
maxLengthAt1 = length(AxisFromSample(sample1, fgOverlap).xy) * (TAPS+1);//length(GetFirstAxis(sampleUV.zw)) * (NUM_STEPS+1);
// half depth0 = Linear01Depth(tex2D(_CameraDepthTexture, sampleUV.xy).x);
//half depth1 = Linear01Depth(tex2D(_CameraDepthTexture, sampleUV.zw).x);
//depth0 = saturate(1-(centerDepth-depth0)*(centerDepth-depth0)*10.5);
//depth1 = saturate(1-(centerDepth-depth1)*(centerDepth-depth1)*10.5);
// Y U NO WORKY ?
half currentLength = amount * ((half)l);
half weight0 = max(0, saturate((maxLengthAt0 - currentLength))) * FILTER_KERNEL_WEIGHTS[l];//* depth0;
sum += sample0 * weight0;
sampleCount += weight0;
half weight1 = max(0, saturate((maxLengthAt1 - currentLength))) * FILTER_KERNEL_WEIGHTS[l];//* depth1;
sum += sample1 * weight1;
sampleCount += weight1;
}
half4 returnValue = sum / sampleCount;
returnValue.a = centerTap.a;
return returnValue;
}
half4 fragBlurForFgCoc (v2fBlur i) : COLOR
{
half4 blurredColor = half4 (0,0,0,0);
half4 sampleA = tex2D(_MainTex, i.uv.xy)*4;
half4 sampleB = tex2D(_MainTex, i.uv01.xy)*2;
half4 sampleC = tex2D(_MainTex, i.uv01.zw)*2;
half4 sampleD = tex2D(_MainTex, i.uv23.xy);
half4 sampleE = tex2D(_MainTex, i.uv23.zw);
half4 sampleF = tex2D(_MainTex, i.uv45.xy)*0.55;
half4 sampleG = tex2D(_MainTex, i.uv45.zw)*0.55;
half4 sampleH = tex2D(_MainTex, i.uv67.xy)*0.2;
half4 sampleI = tex2D(_MainTex, i.uv67.zw)*0.2;
blurredColor += sampleA;
blurredColor += sampleB;
blurredColor += sampleC;
blurredColor += sampleD;
blurredColor += sampleE;
blurredColor += sampleF;
blurredColor += sampleG;
blurredColor += sampleH;
blurredColor += sampleI;
blurredColor /= 11.5;
//half4 alphas = half4(sampleD.a, sampleE.a, sampleH.a*5, sampleI.a*5);
//half4 alphas2 = half4(sampleE.a, sampleF.a, sampleG.a, 1.0);
//half overlapFactor = saturate(length(alphas-sampleA.aaaa/4)-0.5);
//half4 maxedColor = max(sampleA, sampleB);
//maxedColor = max(maxedColor, sampleC);
//blurredColor.a = saturate(blurredColor.a * 4.0f);
// to do ot not to do
//blurredColor.a += overlapFactor ; // max(maxedColor.a, blurredColor.a);
float4 originalCoc = tex2D(_FgOverlap,i.uv.xy).aaaa;
originalCoc.a = saturate(originalCoc.a + 1.8*saturate(blurredColor.a-originalCoc.a));
return max(blurredColor.aaaa, originalCoc.aaaa);
}
half4 frag4TapBlurForLRSpawn (v2f i) : COLOR
{
half4 tapA = tex2D(_MainTex, i.uv.xy + _MainTex_TexelSize.xy);
half4 tapB = tex2D(_MainTex, i.uv.xy - _MainTex_TexelSize.xy);
half4 tapC = tex2D(_MainTex, i.uv.xy + _MainTex_TexelSize.xy * half2(1,-1));
half4 tapD = tex2D(_MainTex, i.uv.xy - _MainTex_TexelSize.xy * half2(1,-1));
half4 color = (tapA + tapB * tapB.a + tapC * tapC.a + tapD * tapD.a) / (1.0 + tapB.a + tapC.a + tapD.a);
color.a = tapA.a;
return color;
}
half4 fragApplyDebug (v2f i) : COLOR
{
float4 tapHigh = tex2D (_MainTex, i.uv1.xy);
float4 outColor = lerp(tapHigh, half4(0,1,0,1), tapHigh.a);
return outColor;
}
float4 fragCaptureCoc (v2f i) : COLOR
{
float4 color = half4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy);
float d = UNITY_SAMPLE_DEPTH(tex2D(_CameraDepthTexture, i.uv1.xy));
d = Linear01Depth (d);
color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 0.0001);
color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, 1.0);
return color;
/*
float4 color = half4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy);
//float4 lowTap = tex2D(_TapLowA, i.uv1.xy);
float d = UNITY_SAMPLE_DEPTH(tex2D(_CameraDepthTexture, i.uv1.xy));
d = Linear01Depth (d);
float focalDistance01 = _CurveParams.w + _CurveParams.z;
//if (d > focalDistance01)
color.a = (d - focalDistance01);
half coc = saturate(color.a * _CurveParams.y);
coc += saturate(-color.a * _CurveParams.x);
// we are mixing the newly calculated BG COC with the foreground COC
// also, for foreground COC, let's scale the COC a bit to get nicer overlaps
//color.a = max(lowTap.a, color.a);
//color.a = saturate(color.a);// + COC_SMALL_VALUE);
//color.rgb *= color.a;
color.a = coc;
return saturate(color);
*/
}
half4 fragCaptureForegroundCoc (v2f i) : COLOR
{
float4 color = half4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy);
float d = UNITY_SAMPLE_DEPTH(tex2D(_CameraDepthTexture, i.uv1.xy));
d = Linear01Depth (d);
color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 0.0001);
color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, 1.0);
return color;
/*
half4 color = tex2D (_MainTex, i.uv.xy);
color.a = 0.0;
//#if SHADER_API_D3D9
//if (_MainTex_TexelSize.y < 0)
// i.uv1.xy = i.uv1.xy * half2(1,-1)+half2(0,1);
//#endif
float d = UNITY_SAMPLE_DEPTH(tex2D(_CameraDepthTexture, i.uv1.xy));
d = Linear01Depth (d);
float focalDistance01 = (_CurveParams.w - _CurveParams.z);
if (d < focalDistance01)
color.a = (focalDistance01 - d);
color.a = saturate(color.a * _CurveParams.x);
return color;
*/
}
half4 fragCopyAlpha4Tap (v2f i) : COLOR {
half4 tapA = tex2D(_MainTex, i.uv.xy + 0.5*_MainTex_TexelSize.xy);
half4 tapB = tex2D(_MainTex, i.uv.xy - 0.5*_MainTex_TexelSize.xy);
half4 tapC = tex2D(_MainTex, i.uv.xy + 0.5*_MainTex_TexelSize.xy * half2(1,-1));
half4 tapD = tex2D(_MainTex, i.uv.xy - 0.5*_MainTex_TexelSize.xy * half2(1,-1));
return (tapA+tapB+tapC+tapD)/4;
}
half4 fragPrepare (v2f i) : COLOR {
half4 from = tex2D(_MainTex, i.uv1.xy);
half square = from.a * from.a;
square*=square;
from.a = saturate(square*square);
//from.rgb = 0;//half3(0,0,1); // debug
return from;
}
ENDCG
Subshader {
// pass 0
Pass {
ZTest Always Cull Off ZWrite Off
ColorMask A
Fog { Mode off }
CGPROGRAM
#pragma glsl
#pragma target 3.0
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vert
#pragma fragment fragCaptureCoc
ENDCG
}
// pass 1
Pass
{
ZTest Always Cull Off ZWrite Off
ColorMask RGB
Fog { Mode off }
CGPROGRAM
#pragma glsl
#pragma target 3.0
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vert
#pragma fragment fragApplyDebug
ENDCG
}
// pass 2
Pass {
ZTest Always Cull Off ZWrite Off
Fog { Mode off }
CGPROGRAM
#pragma glsl
#pragma target 3.0
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vertBlurPlusMinus
#pragma fragment fragBlurForFgCoc
ENDCG
}
// pass 3
Pass
{
ZTest Always Cull Off ZWrite Off
Fog { Mode off }
ColorMask A
BlendOp Max, Max
Blend One One, One One
CGPROGRAM
#pragma glsl
#pragma target 3.0
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vert
#pragma fragment fragCaptureCoc
ENDCG
}
// pass 4
Pass
{
ZTest Always Cull Off ZWrite Off
Fog { Mode off }
ColorMask A
CGPROGRAM
#pragma glsl
#pragma target 3.0
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vert
#pragma fragment fragCaptureForegroundCoc
ENDCG
}
// pass 5
Pass {
ZTest Always Cull Off ZWrite Off
Fog { Mode off }
CGPROGRAM
#pragma glsl
#pragma target 3.0
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vert
#pragma fragment fragBlurHighSampleCount
ENDCG
}
// pass 6
Pass {
ZTest Always Cull Off ZWrite Off
Fog { Mode off }
CGPROGRAM
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vert
#pragma fragment frag4TapBlurForLRSpawn
ENDCG
}
// pass 7
Pass {
ZTest Always Cull Off ZWrite Off
ColorMask A
Fog { Mode off }
CGPROGRAM
#pragma glsl
#pragma target 3.0
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vert
#pragma fragment fragCopyAlpha4Tap
ENDCG
}
// pass 8
Pass
{
ZTest Always Cull Off ZWrite Off
ColorMask RGB
Blend SrcAlpha OneMinusSrcAlpha
Fog { Mode off }
CGPROGRAM
#pragma glsl
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vert
#pragma fragment fragPrepare
ENDCG
}
// pass 9
Pass {
ZTest Always Cull Off ZWrite Off
Fog { Mode off }
CGPROGRAM
#pragma glsl
#pragma target 3.0
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vert
#pragma fragment fragBlurLowSampleCount
ENDCG
}
// pass 10
Pass {
ZTest Always Cull Off ZWrite Off
Fog { Mode off }
CGPROGRAM
#pragma glsl
#pragma target 3.0
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vert
#pragma fragment fragBlurPoisson
ENDCG
}
// pass 11
Pass {
ZTest Always Cull Off ZWrite Off
Fog { Mode off }
CGPROGRAM
#pragma glsl
#pragma target 3.0
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vert
#pragma fragment fragBlurProduction
ENDCG
}
// pass 12
Pass {
ZTest Always Cull Off ZWrite Off
Fog { Mode off }
CGPROGRAM
#pragma glsl
#pragma target 3.0
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vert
#pragma fragment fragBlurProductionLowRez
ENDCG
}
// pass 13
Pass {
ZTest Always Cull Off ZWrite Off
Fog { Mode off }
CGPROGRAM
#pragma glsl
#pragma target 3.0
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vert
#pragma fragment fragBlurPoissonLowRez
ENDCG
}
// pass 14
Pass {
ZTest Always Cull Off ZWrite Off
Fog { Mode off }
CGPROGRAM
#pragma glsl
#pragma target 3.0
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vert
#pragma fragment fragBlurMovie
ENDCG
}
// pass 15
Pass {
ZTest Always Cull Off ZWrite Off
Fog { Mode off }
CGPROGRAM
#pragma glsl
#pragma target 3.0
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vert
#pragma fragment fragBlurMovieLowRez
ENDCG
}
}
Fallback off
}

View file

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: f365e6b60236cbc48ae333817437397b
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,70 @@
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
Shader "Hidden/SeparableBlur" {
Properties {
_MainTex ("Base (RGB)", 2D) = "" {}
}
CGINCLUDE
#include "UnityCG.cginc"
struct v2f {
float4 pos : POSITION;
float2 uv : TEXCOORD0;
float4 uv01 : TEXCOORD1;
float4 uv23 : TEXCOORD2;
float4 uv45 : TEXCOORD3;
};
float4 offsets;
sampler2D _MainTex;
v2f vert (appdata_img v) {
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv.xy = v.texcoord.xy;
o.uv01 = v.texcoord.xyxy + offsets.xyxy * float4(1,1, -1,-1);
o.uv23 = v.texcoord.xyxy + offsets.xyxy * float4(1,1, -1,-1) * 2.0;
o.uv45 = v.texcoord.xyxy + offsets.xyxy * float4(1,1, -1,-1) * 3.0;
return o;
}
half4 frag (v2f i) : COLOR {
half4 color = float4 (0,0,0,0);
color += 0.40 * tex2D (_MainTex, i.uv);
color += 0.15 * tex2D (_MainTex, i.uv01.xy);
color += 0.15 * tex2D (_MainTex, i.uv01.zw);
color += 0.10 * tex2D (_MainTex, i.uv23.xy);
color += 0.10 * tex2D (_MainTex, i.uv23.zw);
color += 0.05 * tex2D (_MainTex, i.uv45.xy);
color += 0.05 * tex2D (_MainTex, i.uv45.zw);
return color;
}
ENDCG
Subshader {
Pass {
ZTest Always Cull Off ZWrite Off
Fog { Mode off }
CGPROGRAM
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vert
#pragma fragment frag
ENDCG
}
}
Fallback off
} // shader

View file

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 4d4f2bc1484617f469d2d9b0276c8282
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,250 @@
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
Shader "Hidden/SeparableWeightedBlurDof34" {
Properties {
_MainTex ("Base (RGB)", 2D) = "" {}
_TapMedium ("TapMedium (RGB)", 2D) = "" {}
_TapLow ("TapLow (RGB)", 2D) = "" {}
_TapHigh ("TapHigh (RGB)", 2D) = "" {}
}
CGINCLUDE
#include "UnityCG.cginc"
half4 offsets;
half4 _Threshhold;
sampler2D _MainTex;
sampler2D _TapHigh;
struct v2f {
half4 pos : POSITION;
half2 uv : TEXCOORD0;
half4 uv01 : TEXCOORD1;
half4 uv23 : TEXCOORD2;
half4 uv45 : TEXCOORD3;
};
struct v2fSingle {
half4 pos : POSITION;
half2 uv : TEXCOORD0;
};
//
// VERT PROGRAMS
//
v2f vert (appdata_img v) {
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv.xy = v.texcoord.xy;
o.uv01 = v.texcoord.xyxy + offsets.xyxy * half4(1,1, -1,-1);
o.uv23 = v.texcoord.xyxy + offsets.xyxy * half4(1,1, -1,-1) * 2.0;
o.uv45 = v.texcoord.xyxy + offsets.xyxy * half4(1,1, -1,-1) * 3.0;
return o;
}
v2fSingle vertSingleTex (appdata_img v) {
v2fSingle o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv.xy = v.texcoord.xy;
return o;
}
//
// FRAG PROGRAMS
//
// mostly used for foreground, so more gaussian-like
half4 fragBlurUnweighted (v2f i) : COLOR {
half4 blurredColor = half4 (0,0,0,0);
half4 sampleA = tex2D(_MainTex, i.uv.xy);
half4 sampleB = tex2D(_MainTex, i.uv01.xy);
half4 sampleC = tex2D(_MainTex, i.uv01.zw);
half4 sampleD = tex2D(_MainTex, i.uv23.xy);
half4 sampleE = tex2D(_MainTex, i.uv23.zw);
blurredColor += sampleA;
blurredColor += sampleB;
blurredColor += sampleC;
blurredColor += sampleD;
blurredColor += sampleE;
blurredColor *= 0.2;
blurredColor.a = max(tex2D(_TapHigh, i.uv.xy).a, blurredColor.a);
return blurredColor;
}
// used for background, so more bone curve-like
half4 fragBlurWeighted (v2f i) : COLOR {
half4 blurredColor = half4 (0,0,0,0);
half4 sampleA = tex2D(_MainTex, i.uv.xy);
half4 sampleB = tex2D(_MainTex, i.uv01.xy);
half4 sampleC = tex2D(_MainTex, i.uv01.zw);
half4 sampleD = tex2D(_MainTex, i.uv23.xy);
half4 sampleE = tex2D(_MainTex, i.uv23.zw);
half sum = sampleA.a + dot (half4 (1.25, 1.25, 1.5, 1.5), half4 (sampleB.a,sampleC.a,sampleD.a,sampleE.a));
sampleA.rgb = sampleA.rgb * sampleA.a;
sampleB.rgb = sampleB.rgb * sampleB.a * 1.25;
sampleC.rgb = sampleC.rgb * sampleC.a * 1.25;
sampleD.rgb = sampleD.rgb * sampleD.a * 1.5;
sampleE.rgb = sampleE.rgb * sampleE.a * 1.5;
blurredColor += sampleA;
blurredColor += sampleB;
blurredColor += sampleC;
blurredColor += sampleD;
blurredColor += sampleE;
blurredColor /= sum;
half4 color = blurredColor;
color.a = sampleA.a;
return color;
}
half4 fragBlurDark (v2f i) : COLOR {
half4 blurredColor = half4 (0,0,0,0);
half4 sampleA = tex2D(_MainTex, i.uv.xy);
half4 sampleB = tex2D(_MainTex, i.uv01.xy);
half4 sampleC = tex2D(_MainTex, i.uv01.zw);
half4 sampleD = tex2D(_MainTex, i.uv23.xy);
half4 sampleE = tex2D(_MainTex, i.uv23.zw);
half sum = sampleA.a + dot (half4 (0.75, 0.75, 0.5, 0.5), half4 (sampleB.a,sampleC.a,sampleD.a,sampleE.a));
sampleA.rgb = sampleA.rgb * sampleA.a;
sampleB.rgb = sampleB.rgb * sampleB.a * 0.75;
sampleC.rgb = sampleC.rgb * sampleC.a * 0.75;
sampleD.rgb = sampleD.rgb * sampleD.a * 0.5;
sampleE.rgb = sampleE.rgb * sampleE.a * 0.5;
blurredColor += sampleA;
blurredColor += sampleB;
blurredColor += sampleC;
blurredColor += sampleD;
blurredColor += sampleE;
blurredColor /= sum;
half4 color = blurredColor;
color.a = sampleA.a;
return color;
}
// not used atm
half4 fragBlurUnweightedDark (v2f i) : COLOR {
half4 blurredColor = half4 (0,0,0,0);
half4 sampleA = tex2D(_MainTex, i.uv.xy);
half4 sampleB = tex2D(_MainTex, i.uv01.xy);
half4 sampleC = tex2D(_MainTex, i.uv01.zw);
half4 sampleD = tex2D(_MainTex, i.uv23.xy);
half4 sampleE = tex2D(_MainTex, i.uv23.zw);
blurredColor += sampleA;
blurredColor += sampleB * 0.75;
blurredColor += sampleC * 0.75;
blurredColor += sampleD * 0.5;
blurredColor += sampleE * 0.5;
blurredColor /= 3.5;
blurredColor.a = max(tex2D(_TapHigh, i.uv.xy).a, blurredColor.a);
return blurredColor;
}
// fragMixMediumAndLowTap
// happens before applying final coc/blur result to screen,
// mixes defocus buffers of different resolutions / bluriness
sampler2D _TapMedium;
sampler2D _TapLow;
half4 fragMixMediumAndLowTap (v2fSingle i) : COLOR
{
half4 tapMedium = tex2D (_TapMedium, i.uv.xy);
half4 tapLow = tex2D (_TapLow, i.uv.xy);
tapMedium.a *= tapMedium.a;
tapLow.rgb = lerp (tapMedium.rgb, tapLow.rgb, (tapMedium.a * tapMedium.a));
return tapLow;
}
ENDCG
Subshader {
ZTest Always Cull Off ZWrite Off
Fog { Mode off }
Pass {
CGPROGRAM
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vert
#pragma fragment fragBlurWeighted
ENDCG
}
Pass {
CGPROGRAM
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vert
#pragma fragment fragBlurUnweighted
ENDCG
}
// 2
Pass {
CGPROGRAM
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vert
#pragma fragment fragBlurUnweightedDark
ENDCG
}
Pass {
CGPROGRAM
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vertSingleTex
#pragma fragment fragMixMediumAndLowTap
ENDCG
}
// 4
Pass {
CGPROGRAM
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vert
#pragma fragment fragBlurDark
ENDCG
}
}
Fallback off
} // shader

View file

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: fb5fe6aa0c3a3cf4e8334c417bc431c6
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,342 @@
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
Shader "Hidden/tiltShift" {
Properties {
_MainTex ("Base", 2D) = "" {}
_Blurred ("Blurred", 2D) = "" {}
_Coc ("Coc", 2D) = "" {}
}
CGINCLUDE
#include "UnityCG.cginc"
struct v2f {
float4 pos : POSITION;
float2 uv : TEXCOORD0;
#if SHADER_API_D3D9
float2 uv1 : TEXCOORD1;
#endif
};
struct v2f_blur {
float4 pos : POSITION;
float2 uv : TEXCOORD0;
float4 uv01 : TEXCOORD1;
float4 uv23 : TEXCOORD2;
float4 uv45 : TEXCOORD3;
};
half4 offsets;
sampler2D _MainTex;
sampler2D _CameraDepthTexture;
sampler2D _Blurred;
sampler2D _Coc;
half4 _MainTex_TexelSize;
half4 _SimpleDofParams;
half2 _FgOrBgCoc;
#define focalStart01 _SimpleDofParams.x
#define focalDistance01 _SimpleDofParams.y
#define focalEnd01 _SimpleDofParams.z
#define curve _SimpleDofParams.w
v2f vert (appdata_img v) {
v2f o;
o.pos = UnityObjectToClipPos (v.vertex);
o.uv.xy = v.texcoord;
#if SHADER_API_D3D9
o.uv1.xy = v.texcoord;
if (_MainTex_TexelSize.y < 0)
o.uv1.y = 1-o.uv1.y;
#else
#endif
return o;
}
half4 fragCocFg (v2f i) : COLOR {
#if SHADER_API_D3D9
float d = UNITY_SAMPLE_DEPTH(tex2D (_CameraDepthTexture, i.uv1.xy));
#else
float d = UNITY_SAMPLE_DEPTH(tex2D (_CameraDepthTexture, i.uv.xy));
#endif
d = Linear01Depth(d);
half coc;
if (d > focalDistance01)
coc = (d - focalDistance01 - 0.0025) * 0.0f;
else
coc = (focalDistance01 - d - 0.0025) * 2.0f;
coc = clamp ( ( (coc / (curve))), 0.0, 0.999);
return EncodeFloatRGBA (coc);
}
half4 fragCocBgAfterFg (v2f i) : COLOR
{
#if SHADER_API_D3D9
float d = UNITY_SAMPLE_DEPTH(tex2D (_CameraDepthTexture, i.uv1.xy));
#else
float d = UNITY_SAMPLE_DEPTH(tex2D (_CameraDepthTexture, i.uv.xy));
#endif
d = Linear01Depth(d);
half coc;
if (d > focalDistance01)
coc = (d - focalDistance01 - 0.0025) * 2.0f;
else
coc = (focalDistance01 - d - 0.0025) * 0.0f;
coc = clamp ( ( (coc / (curve))), 0.0, 0.999);
#if SHADER_API_D3D9
half4 cocTex = tex2D (_Coc, i.uv1.xy);
#else
half4 cocTex = tex2D (_Coc, i.uv.xy);
#endif
return max( EncodeFloatRGBA (coc), cocTex);
}
half4 fragDofApply (v2f i) : COLOR
{
half4 color = tex2D (_MainTex, i.uv.xy);
#if SHADER_API_D3D9
half4 blurred = tex2D (_Blurred, i.uv1.xy);
#else
half4 blurred = tex2D (_Blurred, i.uv.xy);
#endif
#if SHADER_API_D3D9
half coc = DecodeFloatRGBA (tex2D (_Coc, i.uv1.xy));
#else
half coc = DecodeFloatRGBA (tex2D (_Coc, i.uv.xy));
#endif
return lerp (color, blurred, coc);
}
half4 fragDofDebug (v2f i) : COLOR
{
half4 color = tex2D (_MainTex, i.uv.xy);
#if SHADER_API_D3D9
half4 blurred = tex2D (_Blurred, i.uv1.xy);
#else
half4 blurred = tex2D (_Blurred, i.uv.xy);
#endif
blurred = (half4(0,1,0,1) + blurred) * 0.5;
#if SHADER_API_D3D9
half coc = DecodeFloatRGBA (tex2D (_Coc, i.uv1.xy));
#else
half coc = DecodeFloatRGBA (tex2D (_Coc, i.uv.xy));
#endif
return lerp (color, blurred, coc);
}
half4 fragUp (v2f i) : COLOR
{
half4 color = tex2D (_MainTex, i.uv.xy);
half4 cocTex = tex2D (_Coc, i.uv.xy);
return max (color, cocTex);
}
v2f_blur vertBlur (appdata_img v) {
v2f_blur o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv.xy = v.texcoord.xy;
o.uv01 = v.texcoord.xyxy + offsets.xyxy * float4(1,1, -1,-1);
o.uv23 = v.texcoord.xyxy + offsets.xyxy * float4(1,1, -1,-1) * 2.0;
o.uv45 = v.texcoord.xyxy + offsets.xyxy * float4(1,1, -1,-1) * 3.0;
return o;
}
half4 fragDependentBlur (v2f_blur i) : COLOR
{
half4 color = float4 (0,0,0,0);
// texture dependent texture read ... a little slow
half coc = DecodeFloatRGBA (tex2D (_Coc, i.uv));
i.uv01 = lerp (i.uv.xyxy, i.uv01, coc);
i.uv23 = lerp (i.uv.xyxy, i.uv23, coc);
i.uv45 = lerp (i.uv.xyxy, i.uv45, coc);
color += 0.30 * tex2D (_MainTex, i.uv);
color += 0.15 * tex2D (_MainTex, i.uv01.xy);
color += 0.15 * tex2D (_MainTex, i.uv01.zw);
color += 0.125 * tex2D (_MainTex, i.uv23.xy);
color += 0.125 * tex2D (_MainTex, i.uv23.zw);
color += 0.075 * tex2D (_MainTex, i.uv45.xy);
color += 0.075 * tex2D (_MainTex, i.uv45.zw);
return color;
}
half4 fragBlurMax (v2f_blur i) : COLOR
{
half4 color = float4 (0,0,0,0);
color += 0.30 * tex2D (_MainTex, i.uv);
color += 0.15 * tex2D (_MainTex, i.uv01.xy);
color += 0.15 * tex2D (_MainTex, i.uv01.zw);
color += 0.125 * tex2D (_MainTex, i.uv23.xy);
color += 0.125 * tex2D (_MainTex, i.uv23.zw);
color += 0.075 * tex2D (_MainTex, i.uv45.xy);
color += 0.075 * tex2D (_MainTex, i.uv45.zw);
return max (color, tex2D (_Coc, i.uv));
}
half4 fragBlurWeighted (v2f_blur i) : COLOR {
half4 blurredColor = float4 (0,0,0,0);
half4 sampleA = tex2D (_MainTex, i.uv.xy);
half4 sampleB = tex2D (_MainTex, i.uv01.xy);
half4 sampleC = tex2D (_MainTex, i.uv01.zw);
half4 sampleD = tex2D (_MainTex, i.uv23.xy);
half4 sampleE = tex2D (_MainTex, i.uv23.zw);
sampleA.a = DecodeFloatRGBA (tex2D (_Coc, i.uv));
sampleB.a = DecodeFloatRGBA (tex2D (_Coc, i.uv01.xy));
sampleC.a = DecodeFloatRGBA (tex2D (_Coc, i.uv01.zw));
sampleD.a = DecodeFloatRGBA (tex2D (_Coc, i.uv23.xy));
sampleE.a = DecodeFloatRGBA (tex2D (_Coc, i.uv23.zw));
half sum = sampleA.a + dot( half4(1,1,1,1), half4 (sampleB.a,sampleC.a,sampleD.a,sampleE.a));
sampleA.rgb = sampleA.rgb * sampleA.a;
sampleB.rgb = sampleB.rgb * sampleB.a;
sampleC.rgb = sampleC.rgb * sampleC.a;
sampleD.rgb = sampleD.rgb * sampleD.a;
sampleE.rgb = sampleE.rgb * sampleE.a;
blurredColor += sampleA;
blurredColor += sampleB;
blurredColor += sampleC;
blurredColor += sampleD;
blurredColor += sampleE;
blurredColor /= sum;
half4 color = blurredColor;
color.a = sampleA.a;
return color;
}
ENDCG
Subshader {
ZTest Always Cull Off ZWrite Off
Fog { Mode off }
Pass { // 0
CGPROGRAM
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vert
#pragma fragment fragCocFg
ENDCG
}
Pass { // 1
CGPROGRAM
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vert
#pragma fragment fragDofApply
ENDCG
}
Pass { // 2
CGPROGRAM
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vertBlur
#pragma fragment fragDependentBlur
ENDCG
}
Pass { // 3
CGPROGRAM
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vertBlur
#pragma fragment fragBlurMax
ENDCG
}
Pass { // 4
CGPROGRAM
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vert
#pragma fragment fragDofDebug
ENDCG
}
Pass { // 5
CGPROGRAM
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vert
#pragma fragment fragCocBgAfterFg
ENDCG
}
Pass { // 6
CGPROGRAM
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vertBlur
#pragma fragment fragBlurWeighted
ENDCG
}
Pass { // 7
CGPROGRAM
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vert
#pragma fragment fragUp
ENDCG
}
}
Fallback off
}

View file

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: d72e1d2b61cb2c247a2c795243df76a0
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant: