initial commit

This commit is contained in:
2026-05-29 18:21:53 +03:00
commit 66ddf0ead0
2184 changed files with 1384338 additions and 0 deletions

View File

@@ -0,0 +1,136 @@
Shader "Hidden/BlendModesOverlay" {
Properties {
_MainTex ("Screen Blended", 2D) = "" {}
_Overlay ("Color", 2D) = "grey" {}
}
CGINCLUDE
#include "UnityCG.cginc"
struct v2f {
float4 pos : SV_POSITION;
float2 uv[2] : TEXCOORD0;
};
sampler2D _Overlay;
half4 _Overlay_ST;
sampler2D _MainTex;
half4 _MainTex_ST;
half _Intensity;
half4 _MainTex_TexelSize;
half4 _UV_Transform = half4(1, 0, 0, 1);
v2f vert( appdata_img v ) {
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv[0] = UnityStereoScreenSpaceUVAdjust(float2(
dot(v.texcoord.xy, _UV_Transform.xy),
dot(v.texcoord.xy, _UV_Transform.zw)
), _Overlay_ST);
#if UNITY_UV_STARTS_AT_TOP
if(_MainTex_TexelSize.y<0.0)
o.uv[0].y = 1.0-o.uv[0].y;
#endif
o.uv[1] = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy, _MainTex_ST);
return o;
}
half4 fragAddSub (v2f i) : SV_Target {
half4 toAdd = tex2D(_Overlay, i.uv[0]) * _Intensity;
return tex2D(_MainTex, i.uv[1]) + toAdd;
}
half4 fragMultiply (v2f i) : SV_Target {
half4 toBlend = tex2D(_Overlay, i.uv[0]) * _Intensity;
return tex2D(_MainTex, i.uv[1]) * toBlend;
}
half4 fragScreen (v2f i) : SV_Target {
half4 toBlend = (tex2D(_Overlay, i.uv[0]) * _Intensity);
return 1-(1-toBlend)*(1-(tex2D(_MainTex, i.uv[1])));
}
half4 fragOverlay (v2f i) : SV_Target {
half4 m = (tex2D(_Overlay, i.uv[0]));// * 255.0;
half4 color = (tex2D(_MainTex, i.uv[1]));//* 255.0;
// overlay blend mode
//color.rgb = (color.rgb/255.0) * (color.rgb + ((2*m.rgb)/( 255.0 )) * (255.0-color.rgb));
//color.rgb /= 255.0;
/*
if (Target > ½) R = 1 - (1-2x(Target-½)) x (1-Blend)
if (Target <= ½) R = (2xTarget) x Blend
*/
float3 check = step(half3(0.5,0.5,0.5), color.rgb);
float3 result = 0;
result = check * (half3(1,1,1) - ( (half3(1,1,1) - 2*(color.rgb-0.5)) * (1-m.rgb)));
result += (1-check) * (2*color.rgb) * m.rgb;
return half4(lerp(color.rgb, result.rgb, (_Intensity)), color.a);
}
half4 fragAlphaBlend (v2f i) : SV_Target {
half4 toAdd = tex2D(_Overlay, i.uv[0]) ;
return lerp(tex2D(_MainTex, i.uv[1]), toAdd, toAdd.a * _Intensity);
}
ENDCG
Subshader {
ZTest Always Cull Off ZWrite Off
ColorMask RGB
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment fragAddSub
ENDCG
}
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment fragScreen
ENDCG
}
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment fragMultiply
ENDCG
}
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment fragOverlay
ENDCG
}
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment fragAlphaBlend
ENDCG
}
}
Fallback off
} // shader

View File

@@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: 8c81db0e527d24acc9bcec04e87781bd
ShaderImporter:
userData:

View File

@@ -0,0 +1,52 @@
Shader "Hidden/BlurEffectConeTap" {
Properties { _MainTex ("", any) = "" {} }
CGINCLUDE
#include "UnityCG.cginc"
struct v2f {
float4 pos : SV_POSITION;
half2 uv : TEXCOORD0;
half2 taps[4] : TEXCOORD1;
};
sampler2D _MainTex;
half4 _MainTex_TexelSize;
half4 _MainTex_ST;
half4 _BlurOffsets;
v2f vert( appdata_img v ) {
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = v.texcoord - _BlurOffsets.xy * _MainTex_TexelSize.xy; // hack, see BlurEffect.cs for the reason for this. let's make a new blur effect soon
#ifdef UNITY_SINGLE_PASS_STEREO
// we need to keep texel size correct after the uv adjustment.
o.taps[0] = UnityStereoScreenSpaceUVAdjust(o.uv + _MainTex_TexelSize * _BlurOffsets.xy * (1.0f / _MainTex_ST.xy), _MainTex_ST);
o.taps[1] = UnityStereoScreenSpaceUVAdjust(o.uv - _MainTex_TexelSize * _BlurOffsets.xy * (1.0f / _MainTex_ST.xy), _MainTex_ST);
o.taps[2] = UnityStereoScreenSpaceUVAdjust(o.uv + _MainTex_TexelSize * _BlurOffsets.xy * half2(1, -1) * (1.0f / _MainTex_ST.xy), _MainTex_ST);
o.taps[3] = UnityStereoScreenSpaceUVAdjust(o.uv - _MainTex_TexelSize * _BlurOffsets.xy * half2(1, -1) * (1.0f / _MainTex_ST.xy), _MainTex_ST);
#else
o.taps[0] = o.uv + _MainTex_TexelSize * _BlurOffsets.xy;
o.taps[1] = o.uv - _MainTex_TexelSize * _BlurOffsets.xy;
o.taps[2] = o.uv + _MainTex_TexelSize * _BlurOffsets.xy * half2(1,-1);
o.taps[3] = o.uv - _MainTex_TexelSize * _BlurOffsets.xy * half2(1,-1);
#endif
return o;
}
half4 frag(v2f i) : SV_Target {
half4 color = tex2D(_MainTex, i.taps[0]);
color += tex2D(_MainTex, i.taps[1]);
color += tex2D(_MainTex, i.taps[2]);
color += tex2D(_MainTex, i.taps[3]);
return color * 0.25;
}
ENDCG
SubShader {
Pass {
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
ENDCG
}
}
Fallback off
}

View File

@@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: 57e6deea7c2924e22a5138e2b70bb4dc
ShaderImporter:
userData:

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: a40c1b84cf7fe418bae97a29041b85a4

View File

@@ -0,0 +1,70 @@
// Calculates adaptation to minimum/maximum luminance values,
// based on "currently adapted" and "new values to adapt to"
// textures (both 1x1).
Shader "Hidden/Contrast Stretch Adaptation" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_CurTex ("Base (RGB)", 2D) = "white" {}
}
Category {
SubShader {
Pass {
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#pragma vertex vert_img
#pragma fragment frag
#include "UnityCG.cginc"
uniform sampler2D _MainTex; // currently adapted to
uniform sampler2D _CurTex; // new value to adapt to
uniform float4 _AdaptParams; // x=adaptLerp, y=limitMinimum, z=limitMaximum
half4 _MainTex_ST;
half4 _CurTex_ST;
float4 frag (v2f_img i) : SV_Target {
// value is: max, min
float2 valAdapted = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv, _MainTex_ST)).xy;
float2 valCur = tex2D(_CurTex, UnityStereoScreenSpaceUVAdjust(i.uv, _MainTex_ST)).xy;
// Calculate new adapted values: interpolate
// from valAdapted to valCur by script-supplied amount.
//
// Because we store adaptation levels in a simple 8 bit/channel
// texture, we might not have enough precision - the interpolation
// amount might be too small to change anything, and we'll never
// arrive at the needed values.
//
// So we make sure the change we do is at least 1/255th of the
// color range - this way we'll always change the value.
const float kMinChange = 1.0/255.0;
float2 delta = (valCur-valAdapted) * _AdaptParams.x;
delta.x = sign(delta.x) * max( kMinChange, abs(delta.x) );
delta.y = sign(delta.y) * max( kMinChange, abs(delta.y) );
float4 valNew;
valNew.xy = valAdapted + delta;
// Impose user limits on maximum/minimum values
valNew.x = max( valNew.x, _AdaptParams.z );
valNew.y = min( valNew.y, _AdaptParams.y );
// Optimization so that our final apply pass is faster:
// z = max-min (plus a small amount to prevent division by zero)
valNew.z = valNew.x - valNew.y + 0.01;
// w = min/(max-min)
valNew.w = valNew.y / valNew.z;
return valNew;
}
ENDCG
}
}
}
Fallback off
}

View File

@@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: 257bc83cbeb544540bd0e558aa9b1383
ShaderImporter:
userData:

View File

@@ -0,0 +1,56 @@
// Final pass in the contrast stretch effect: apply
// color stretch to the original image, based on currently
// adapted to minimum/maximum luminances.
Shader "Hidden/Contrast Stretch Apply" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_AdaptTex ("Base (RGB)", 2D) = "white" {}
}
Category {
SubShader {
Pass {
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct v2f {
float4 pos : SV_POSITION;
float2 uv[2] : TEXCOORD0;
};
uniform sampler2D _MainTex;
uniform sampler2D _AdaptTex;
half4 _MainTex_ST;
v2f vert (appdata_img v)
{
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv[0] = MultiplyUV (UNITY_MATRIX_TEXTURE0, UnityStereoScreenSpaceUVAdjust(v.texcoord, _MainTex_ST));
o.uv[1] = float2(0.5,0.5);
return o;
}
float4 frag (v2f i) : SV_Target
{
float4 col = tex2D(_MainTex, i.uv[0]);
float4 adapted = tex2D(_AdaptTex, i.uv[1]);
float vmul = 1.0 / adapted.z;
float vadd = -adapted.w;
col.rgb = col.rgb * vmul + vadd;
return col;
}
ENDCG
}
}
}
Fallback off
}

View File

@@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: f4901f25d4e1542589348bbb89563d8e
ShaderImporter:
userData:

View File

@@ -0,0 +1,36 @@
// Outputs luminance (grayscale) of the input image _MainTex
Shader "Hidden/Contrast Stretch Luminance" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
}
Category {
SubShader {
Pass {
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#pragma vertex vert_img
#pragma fragment frag
#include "UnityCG.cginc"
uniform sampler2D _MainTex;
half4 _MainTex_ST;
float4 frag (v2f_img i) : SV_Target
{
float4 col = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv, _MainTex_ST));
col.rgb = Luminance(col.rgb) * (1+col.a*2);
return col;
}
ENDCG
}
}
}
Fallback off
}

View File

@@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: befbb4b9c320b4b18a08ef7afb93b6c9
ShaderImporter:
userData:

View File

@@ -0,0 +1,66 @@
// Reduces input image (_MainTex) by 2x2.
// Outputs maximum value in R, minimum in G.
Shader "Hidden/Contrast Stretch Reduction" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
}
Category {
SubShader {
Pass {
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct v2f {
float4 position : SV_POSITION;
float2 uv[4] : TEXCOORD0;
};
uniform sampler2D _MainTex;
half4 _MainTex_ST;
v2f vert (appdata_img v) {
v2f o;
o.position = UnityObjectToClipPos(v.vertex);
float2 uv = MultiplyUV (UNITY_MATRIX_TEXTURE0, v.texcoord);
// Compute UVs to sample 2x2 pixel block.
o.uv[0] = UnityStereoScreenSpaceUVAdjust(uv + float2(0,0), _MainTex_ST);
o.uv[1] = UnityStereoScreenSpaceUVAdjust(uv + float2(0,1), _MainTex_ST);
o.uv[2] = UnityStereoScreenSpaceUVAdjust(uv + float2(1,0), _MainTex_ST);
o.uv[3] = UnityStereoScreenSpaceUVAdjust(uv + float2(1,1), _MainTex_ST);
return o;
}
float4 frag (v2f i) : SV_Target
{
// Sample pixel block
float4 v00 = tex2D(_MainTex, i.uv[0]);
float2 v01 = tex2D(_MainTex, i.uv[1]).xy;
float2 v10 = tex2D(_MainTex, i.uv[2]).xy;
float2 v11 = tex2D(_MainTex, i.uv[3]).xy;
float4 res;
// output x: maximum of the four values
res.x = max( max(v00.x,v01.x), max(v10.x,v11.x) );
// output y: minimum of the four values
res.y = min( min(v00.y,v01.y), min(v10.y,v11.y) );
// output zw unchanged from the first pixel
res.zw = v00.zw;
return res;
}
ENDCG
}
}
}
Fallback off
}

View File

@@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: 57b33a14b6d5347c5a85c36f6cb3b280
ShaderImporter:
userData:

View File

@@ -0,0 +1,70 @@
Shader "Hidden/ContrastComposite" {
Properties {
_MainTex ("Base (RGB)", 2D) = "" {}
_MainTexBlurred ("Base Blurred (RGB)", 2D) = "" {}
}
// Shader code pasted into all further CGPROGRAM blocks
CGINCLUDE
#include "UnityCG.cginc"
struct v2f {
float4 pos : SV_POSITION;
float2 uv[2] : TEXCOORD0;
};
sampler2D _MainTex;
sampler2D _MainTexBlurred;
float4 _MainTex_TexelSize;
half4 _MainTex_ST;
half4 _MainTexBlurred_ST;
float intensity;
float threshold;
v2f vert( appdata_img v ) {
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv[0] = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy, _MainTexBlurred_ST);
o.uv[1] = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy, _MainTex_ST);
#if UNITY_UV_STARTS_AT_TOP
if (_MainTex_TexelSize.y < 0)
o.uv[0].y = 1-o.uv[0].y;
#endif
return o;
}
half4 frag(v2f i) : SV_Target
{
half4 color = tex2D (_MainTex, i.uv[1]);
half4 blurred = tex2D (_MainTexBlurred, (i.uv[0]));
half4 difference = color - blurred;
half4 signs = sign (difference);
half4 enhancement = saturate (abs(difference) - threshold) * signs * 1.0/(1.0-threshold);
color += enhancement * intensity;
return color;
}
ENDCG
Subshader {
Pass {
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
ENDCG
}
}
Fallback off
} // shader

View File

@@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: 273404942eede4ea1883ca1fb2942507
ShaderImporter:
userData:

View File

@@ -0,0 +1,56 @@
Shader "Hidden/ConvertDepth" {
Properties {
_MainTex ("Base (RGB)", 2D) = "" {}
}
// Shader code pasted into all further CGPROGRAM blocks
CGINCLUDE
#include "UnityCG.cginc"
struct v2f {
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
};
sampler2D _MainTex;
sampler2D_float _CameraDepthTexture;
half4 _CameraDepthTexture_ST;
v2f vert( appdata_img v )
{
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy, _CameraDepthTexture_ST);
return o;
}
half4 frag(v2f i) : SV_Target
{
float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, i.uv.xy);
d = Linear01Depth(d);
if(d>0.99999)
return half4(1,1,1,1);
else
return EncodeFloatRGBA(d);
}
ENDCG
Subshader {
Pass {
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
ENDCG
}
}
Fallback off
} // shader

View File

@@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: 14768d3865b1342e3a861fbe19ba2db2
ShaderImporter:
userData:

View File

@@ -0,0 +1,97 @@
Shader "Hidden/PrepareSunShaftsBlur" {
Properties {
_MainTex ("Base", 2D) = "" {}
_Skybox ("Skybox", 2D) = "" {}
}
CGINCLUDE
#include "UnityCG.cginc"
struct v2f {
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
};
sampler2D _MainTex;
sampler2D _Skybox;
sampler2D_float _CameraDepthTexture;
uniform half _NoSkyBoxMask;
uniform half4 _SunPosition;
v2f vert (appdata_img v) {
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = v.texcoord.xy;
return o;
}
half TransformColor (half4 skyboxValue) {
return max (skyboxValue.a, _NoSkyBoxMask * dot (skyboxValue.rgb, float3 (0.59,0.3,0.11)));
}
half4 frag (v2f i) : SV_Target {
float depthSample = SAMPLE_DEPTH_TEXTURE( _CameraDepthTexture, i.uv.xy);
half4 tex = tex2D (_MainTex, i.uv.xy);
depthSample = Linear01Depth (depthSample);
// consider maximum radius
half2 vec = _SunPosition.xy - i.uv.xy;
half dist = saturate (_SunPosition.w - length (vec.xy));
half4 outColor = 0;
// consider shafts blockers
if (depthSample > 0.99)
outColor = TransformColor (tex) * dist;
return outColor;
}
half4 fragNoDepthNeeded (v2f i) : SV_Target {
float4 sky = (tex2D (_Skybox, i.uv.xy));
float4 tex = (tex2D (_MainTex, i.uv.xy));
// consider maximum radius
half2 vec = _SunPosition.xy - i.uv.xy;
half dist = saturate (_SunPosition.w - length (vec));
half4 outColor = 0;
if (Luminance ( abs(sky.rgb - tex.rgb)) < 0.2)
outColor = TransformColor (sky) * dist;
return outColor;
}
ENDCG
Subshader {
Pass {
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
ENDCG
}
Pass {
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#pragma vertex vert
#pragma fragment fragNoDepthNeeded
ENDCG
}
}
Fallback off
} // shader

View File

@@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: 9ad381ed8492840ab9f165df743e4826
ShaderImporter:
userData:

View File

@@ -0,0 +1,261 @@
/**
\author Michael Mara and Morgan McGuire, Casual Effects. 2015.
*/
#ifndef SCREEN_SPACE_RAYTRACE_INCLUDED
#define SCREEN_SPACE_RAYTRACE_INCLUDED
sampler2D_float _CameraDepthTexture;
float distanceSquared(float2 A, float2 B) {
A -= B;
return dot(A, A);
}
float distanceSquared(float3 A, float3 B) {
A -= B;
return dot(A, A);
}
void swap(inout float v0, inout float v1) {
float temp = v0;
v0 = v1;
v1 = temp;
}
bool isIntersecting(float rayZMin, float rayZMax, float sceneZ, float layerThickness) {
return (rayZMax >= sceneZ - layerThickness) && (rayZMin <= sceneZ);
}
void rayIterations(inout float2 P, inout float stepDirection, inout float end, inout int stepCount, inout int maxSteps, inout bool intersecting,
inout float sceneZ, inout float2 dP, inout float3 Q, inout float3 dQ, inout float k, inout float dk,
inout float rayZMin, inout float rayZMax, inout float prevZMaxEstimate, inout bool permute, inout float2 hitPixel,
inout float2 invSize, inout float layerThickness) {
UNITY_LOOP
for (;
( (P.x * stepDirection) <= end) &&
(stepCount < maxSteps) &&
(!intersecting);
P += dP, Q.z += dQ.z, k += dk, stepCount += 1) {
// The depth range that the ray covers within this loop iteration.
// Assume that the ray is moving in increasing z and swap if backwards.
rayZMin = prevZMaxEstimate;
//rayZMin = (dQ.z * -0.5 + Q.z) / (dk * -0.5 + k);
// Compute the value at 1/2 pixel into the future
rayZMax = (dQ.z * 0.5 + Q.z) / (dk * 0.5 + k);
prevZMaxEstimate = rayZMax;
if (rayZMin > rayZMax) { swap(rayZMin, rayZMax); }
// Undo the homogeneous operation to obtain the camera-space
// Q at each point
hitPixel = permute ? P.yx : P;
sceneZ = tex2Dlod(_CameraDepthTexture, float4(hitPixel * invSize,0,0)).r;
sceneZ = -LinearEyeDepth(sceneZ);
intersecting = isIntersecting(rayZMin, rayZMax, sceneZ, layerThickness);
} // pixel on ray
P -= dP, Q.z -= dQ.z, k -= dk;
}
/**
\param csOrigin must have z < -0.01, and project within the valid screen rectangle
\param stepRate Set to 1.0 by default, higher to step faster
*/
bool castDenseScreenSpaceRay
(float3 csOrigin,
float3 csDirection,
float4x4 projectToPixelMatrix,
float2 csZBufferSize,
float3 clipInfo,
float jitterFraction,
int maxSteps,
float layerThickness,
float maxRayTraceDistance,
out float2 hitPixel,
int stepRate,
bool refine,
out float3 csHitPoint,
out float stepCount) {
float2 invSize = float2(1.0 / csZBufferSize.x, 1.0 / csZBufferSize.y);
// Initialize to off screen
hitPixel = float2(-1, -1);
float nearPlaneZ = -0.01;
// Clip ray to a near plane in 3D (doesn't have to be *the* near plane, although that would be a good idea)
float rayLength = ((csOrigin.z + csDirection.z * maxRayTraceDistance) > nearPlaneZ) ?
((nearPlaneZ - csOrigin.z) / csDirection.z) :
maxRayTraceDistance;
float3 csEndPoint = csDirection * rayLength + csOrigin;
// Project into screen space
// This matrix has a lot of zeroes in it. We could expand
// out these multiplies to avoid multiplying by zero
// ...but 16 MADDs are not a big deal compared to what's ahead
float4 H0 = mul(projectToPixelMatrix, float4(csOrigin, 1.0));
float4 H1 = mul(projectToPixelMatrix, float4(csEndPoint, 1.0));
// There are a lot of divisions by w that can be turned into multiplications
// at some minor precision loss...and we need to interpolate these 1/w values
// anyway.
//
// Because the caller was required to clip to the near plane,
// this homogeneous division (projecting from 4D to 2D) is guaranteed
// to succeed.
float k0 = 1.0 / H0.w;
float k1 = 1.0 / H1.w;
// Screen-space endpoints
float2 P0 = H0.xy * k0;
float2 P1 = H1.xy * k1;
// Switch the original points to values that interpolate linearly in 2D:
float3 Q0 = csOrigin * k0;
float3 Q1 = csEndPoint * k1;
#if 1 // Clipping to the screen coordinates. We could simply modify maxSteps instead
float yMax = csZBufferSize.y - 0.5;
float yMin = 0.5;
float xMax = csZBufferSize.x - 0.5;
float xMin = 0.5;
// 2D interpolation parameter
float alpha = 0.0;
// P0 must be in bounds
if (P1.y > yMax || P1.y < yMin) {
float yClip = (P1.y > yMax) ? yMax : yMin;
float yAlpha = (P1.y - yClip) / (P1.y - P0.y); // Denominator is not zero, since P0 != P1 (or P0 would have been clipped!)
alpha = yAlpha;
}
// P0 must be in bounds
if (P1.x > xMax || P1.x < xMin) {
float xClip = (P1.x > xMax) ? xMax : xMin;
float xAlpha = (P1.x - xClip) / (P1.x - P0.x); // Denominator is not zero, since P0 != P1 (or P0 would have been clipped!)
alpha = max(alpha, xAlpha);
}
// These are all in homogeneous space, so they interpolate linearly
P1 = lerp(P1, P0, alpha);
k1 = lerp(k1, k0, alpha);
Q1 = lerp(Q1, Q0, alpha);
#endif
// We're doing this to avoid divide by zero (rays exactly parallel to an eye ray)
P1 = (distanceSquared(P0, P1) < 0.0001) ? P0 + float2(0.01, 0.01) : P1;
float2 delta = P1 - P0;
// Assume horizontal
bool permute = false;
if (abs(delta.x) < abs(delta.y)) {
// More-vertical line. Create a permutation that swaps x and y in the output
permute = true;
// Directly swizzle the inputs
delta = delta.yx;
P1 = P1.yx;
P0 = P0.yx;
}
// From now on, "x" is the primary iteration direction and "y" is the secondary one
float stepDirection = sign(delta.x);
float invdx = stepDirection / delta.x;
float2 dP = float2(stepDirection, invdx * delta.y);
// Track the derivatives of Q and k
float3 dQ = (Q1 - Q0) * invdx;
float dk = (k1 - k0) * invdx;
dP *= stepRate;
dQ *= stepRate;
dk *= stepRate;
P0 += dP * jitterFraction;
Q0 += dQ * jitterFraction;
k0 += dk * jitterFraction;
// Slide P from P0 to P1, (now-homogeneous) Q from Q0 to Q1, and k from k0 to k1
float3 Q = Q0;
float k = k0;
// We track the ray depth at +/- 1/2 pixel to treat pixels as clip-space solid
// voxels. Because the depth at -1/2 for a given pixel will be the same as at
// +1/2 for the previous iteration, we actually only have to compute one value
// per iteration.
float prevZMaxEstimate = csOrigin.z;
stepCount = 0.0;
float rayZMax = prevZMaxEstimate, rayZMin = prevZMaxEstimate;
float sceneZ = 100000;
// P1.x is never modified after this point, so pre-scale it by
// the step direction for a signed comparison
float end = P1.x * stepDirection;
bool intersecting = isIntersecting(rayZMin, rayZMax, sceneZ, layerThickness);
// We only advance the z field of Q in the inner loop, since
// Q.xy is never used until after the loop terminates
//int rayIterations = min(maxSteps, stepsToGetOffscreen);
float2 P = P0;
int originalStepCount = 0;
rayIterations(P, stepDirection, end, originalStepCount, maxSteps, intersecting,
sceneZ, dP, Q, dQ, k, dk,
rayZMin, rayZMax, prevZMaxEstimate, permute, hitPixel,
invSize, layerThickness);
stepCount = originalStepCount;
if (refine && intersecting && stepRate > 1) {
// We're going back a step.
P -= dP, Q.z -= dQ.z, k -= dk;
prevZMaxEstimate = Q.z / k;
rayZMin = prevZMaxEstimate;
rayZMax = prevZMaxEstimate;
intersecting = false;
int refinementStepCount = 0;
int refinementMaxSteps = stepRate;
float refinementConstant = 1.0 / stepRate;
dQ.z *= refinementConstant;
dP *= refinementConstant;
dk *= refinementConstant;
// Refinement
rayIterations(P, stepDirection, end, refinementStepCount, refinementMaxSteps, intersecting,
sceneZ, dP, Q, dQ, k, dk,
rayZMin, rayZMax, prevZMaxEstimate, permute, hitPixel,
invSize, layerThickness);
stepCount += refinementStepCount * refinementConstant - 1.0;
//stepCount = refinementStepCount;
intersecting = true;
}
// Loop only advanced the Z component. Now that we know where we are going
// update xy
Q.xy += dQ.xy * stepCount;
// Q is a vector, so we are trying to get by with 1 division instead of 3.
csHitPoint = Q * (1.0 / k);
return intersecting;
}
#endif // SCREEN_SPACE_RAYTRACE_INCLUDED

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 26c67b7245085cf438e3d42d50d94f55
timeCreated: 1425661779
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,54 @@
Shader "Hidden/ShowAlphaChannel" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_EdgeTex ("_EdgeTex", 2D) = "white" {}
}
SubShader {
Pass {
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
uniform sampler2D _MainTex;
uniform sampler2D _EdgeTex;
uniform float4 _MainTex_TexelSize;
float filterRadius;
struct v2f {
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
};
v2f vert( appdata_img v )
{
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = v.texcoord.xy;
return o;
}
half4 frag (v2f i) : SV_Target
{
half4 color = tex2D(_MainTex, i.uv.xy);
half edges = color.a;
return edges;
}
ENDCG
}
}
Fallback off
}

View File

@@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: da310021e2a4142429d95c537846dc38
ShaderImporter:
userData:

View File

@@ -0,0 +1,41 @@
Shader "Hidden/SimpleClear" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Pass {
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
uniform sampler2D _MainTex;
uniform float4 _MainTex_TexelSize;
struct v2f {
float4 pos : SV_POSITION;
};
v2f vert( appdata_img v )
{
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
return o;
}
half4 frag (v2f i) : SV_Target
{
return half4(0,0,0,0);
}
ENDCG
}
}
Fallback off
}

View File

@@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: f688f89ed5eb847c5b19c934a0f1e772
ShaderImporter:
userData:

View File

@@ -0,0 +1,227 @@
Shader "Hidden/SunShaftsComposite" {
Properties {
_MainTex ("Base", 2D) = "" {}
_ColorBuffer ("Color", 2D) = "" {}
_Skybox ("Skybox", 2D) = "" {}
}
CGINCLUDE
#include "UnityCG.cginc"
struct v2f {
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
#if UNITY_UV_STARTS_AT_TOP
float2 uv1 : TEXCOORD1;
#endif
};
struct v2f_radial {
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
float2 blurVector : TEXCOORD1;
};
sampler2D _MainTex;
sampler2D _ColorBuffer;
sampler2D _Skybox;
sampler2D_float _CameraDepthTexture;
uniform half4 _SunThreshold;
uniform half4 _SunColor;
uniform half4 _BlurRadius4;
uniform half4 _SunPosition;
uniform half4 _MainTex_TexelSize;
half4 _MainTex_ST;
half4 _ColorBuffer_ST;
half4 _Skybox_ST;
half4 _CameraDepthTexture_ST;
#define SAMPLES_FLOAT 6.0f
#define SAMPLES_INT 6
v2f vert( appdata_img v ) {
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = v.texcoord.xy;
#if UNITY_UV_STARTS_AT_TOP
o.uv1 = v.texcoord.xy;
if (_MainTex_TexelSize.y < 0)
o.uv1.y = 1-o.uv1.y;
#endif
return o;
}
half4 fragScreen(v2f i) : SV_Target {
half4 colorA = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _MainTex_ST));
#if UNITY_UV_STARTS_AT_TOP
half4 colorB = tex2D (_ColorBuffer, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _ColorBuffer_ST));
#else
half4 colorB = tex2D (_ColorBuffer, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _ColorBuffer_ST));
#endif
half4 depthMask = saturate (colorB * _SunColor);
return 1.0f - (1.0f-colorA) * (1.0f-depthMask);
}
half4 fragAdd(v2f i) : SV_Target {
half4 colorA = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _MainTex_ST));
#if UNITY_UV_STARTS_AT_TOP
half4 colorB = tex2D (_ColorBuffer, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _ColorBuffer_ST));
#else
half4 colorB = tex2D (_ColorBuffer, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _ColorBuffer_ST));
#endif
half4 depthMask = saturate (colorB * _SunColor);
return colorA + depthMask;
}
v2f_radial vert_radial( appdata_img v ) {
v2f_radial o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv.xy = v.texcoord.xy;
o.blurVector = (_SunPosition.xy - v.texcoord.xy) * _BlurRadius4.xy;
return o;
}
half4 frag_radial(v2f_radial i) : SV_Target
{
half4 color = half4(0,0,0,0);
for(int j = 0; j < SAMPLES_INT; j++)
{
half4 tmpColor = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _MainTex_ST));
color += tmpColor;
i.uv.xy += i.blurVector;
}
return color / SAMPLES_FLOAT;
}
half TransformColor (half4 skyboxValue) {
return dot(max(skyboxValue.rgb - _SunThreshold.rgb, half3(0,0,0)), half3(1,1,1)); // threshold and convert to greyscale
}
half4 frag_depth (v2f i) : SV_Target {
#if UNITY_UV_STARTS_AT_TOP
float depthSample = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST));
#else
float depthSample = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _CameraDepthTexture_ST));
#endif
half4 tex = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _MainTex_ST));
depthSample = Linear01Depth (depthSample);
// consider maximum radius
#if UNITY_UV_STARTS_AT_TOP
half2 vec = _SunPosition.xy - i.uv1.xy;
#else
half2 vec = _SunPosition.xy - i.uv.xy;
#endif
half dist = saturate (_SunPosition.w - length (vec.xy));
half4 outColor = 0;
// consider shafts blockers
if (depthSample > 0.99)
outColor = TransformColor (tex) * dist;
return outColor;
}
half4 frag_nodepth (v2f i) : SV_Target {
#if UNITY_UV_STARTS_AT_TOP
float4 sky = (tex2D (_Skybox, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _Skybox_ST)));
#else
float4 sky = (tex2D (_Skybox, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _Skybox_ST)));
#endif
float4 tex = (tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _MainTex_ST)));
// consider maximum radius
#if UNITY_UV_STARTS_AT_TOP
half2 vec = _SunPosition.xy - i.uv1.xy;
#else
half2 vec = _SunPosition.xy - i.uv.xy;
#endif
half dist = saturate (_SunPosition.w - length (vec));
half4 outColor = 0;
// find unoccluded sky pixels
// consider pixel values that differ significantly between framebuffer and sky-only buffer as occluded
if (Luminance ( abs(sky.rgb - tex.rgb)) < 0.2)
outColor = TransformColor (sky) * dist;
return outColor;
}
ENDCG
Subshader {
Pass {
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#pragma vertex vert
#pragma fragment fragScreen
ENDCG
}
Pass {
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#pragma vertex vert_radial
#pragma fragment frag_radial
ENDCG
}
Pass {
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag_depth
ENDCG
}
Pass {
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag_nodepth
ENDCG
}
Pass {
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#pragma vertex vert
#pragma fragment fragAdd
ENDCG
}
}
Fallback off
} // shader

View File

@@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: d3b1c8c1036784176946f5cfbfb7fe4c
ShaderImporter:
userData:

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: d6ef58fc6f637406bbe6814a19c377f8

View File

@@ -0,0 +1,116 @@
Shader "Hidden/Blend" {
Properties {
_MainTex ("Screen Blended", 2D) = "" {}
_ColorBuffer ("Color", 2D) = "" {}
}
CGINCLUDE
#include "UnityCG.cginc"
struct v2f {
float4 pos : SV_POSITION;
float2 uv[2] : TEXCOORD0;
};
struct v2f_mt {
float4 pos : SV_POSITION;
float2 uv[4] : TEXCOORD0;
};
sampler2D _ColorBuffer;
sampler2D _MainTex;
half _Intensity;
half4 _ColorBuffer_TexelSize;
half4 _ColorBuffer_ST;
half4 _MainTex_TexelSize;
half4 _MainTex_ST;
v2f vert( appdata_img v ) {
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv[0] = v.texcoord.xy;
o.uv[1] = v.texcoord.xy;
#if UNITY_UV_STARTS_AT_TOP
if (_ColorBuffer_TexelSize.y < 0)
o.uv[1].y = 1-o.uv[1].y;
#endif
return o;
}
v2f_mt vertMultiTap( appdata_img v ) {
v2f_mt o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv[0] = v.texcoord.xy + _MainTex_TexelSize.xy * 0.5;
o.uv[1] = v.texcoord.xy - _MainTex_TexelSize.xy * 0.5;
o.uv[2] = v.texcoord.xy - _MainTex_TexelSize.xy * half2(1,-1) * 0.5;
o.uv[3] = v.texcoord.xy + _MainTex_TexelSize.xy * half2(1,-1) * 0.5;
return o;
}
half4 fragScreen (v2f i) : SV_Target {
half4 toBlend = saturate (tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv[0], _MainTex_ST)) * _Intensity);
return 1-(1-toBlend)*(1-tex2D(_ColorBuffer, UnityStereoScreenSpaceUVAdjust(i.uv[1], _ColorBuffer_ST)));
}
half4 fragAdd (v2f i) : SV_Target {
return tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv[0].xy, _MainTex_ST)) * _Intensity + tex2D(_ColorBuffer, UnityStereoScreenSpaceUVAdjust(i.uv[1], _ColorBuffer_ST));
}
half4 fragVignetteBlend (v2f i) : SV_Target {
return tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv[0].xy, _MainTex_ST)) * tex2D(_ColorBuffer, UnityStereoScreenSpaceUVAdjust(i.uv[0], _ColorBuffer_ST));
}
half4 fragMultiTap (v2f_mt i) : SV_Target {
half4 outColor = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv[0].xy, _MainTex_ST));
outColor += tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv[1].xy, _MainTex_ST));
outColor += tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv[2].xy, _MainTex_ST));
outColor += tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv[3].xy, _MainTex_ST));
return outColor * 0.25;
}
ENDCG
Subshader {
ZTest Always Cull Off ZWrite Off
// 0: nicer & softer "screen" blend mode
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment fragScreen
ENDCG
}
// 1: simple "add" blend mode
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment fragAdd
ENDCG
}
// 2: used for "stable" downsampling
Pass {
CGPROGRAM
#pragma vertex vertMultiTap
#pragma fragment fragMultiTap
ENDCG
}
// 3: vignette blending
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment fragVignetteBlend
ENDCG
}
}
Fallback off
} // shader

View File

@@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: 53b3960ee3d3d4a5caa8d5473d120187
ShaderImporter:
userData:

View File

@@ -0,0 +1,222 @@
Shader "Hidden/BlendForBloom" {
Properties {
_MainTex ("Screen Blended", 2D) = "" {}
_ColorBuffer ("Color", 2D) = "" {}
}
CGINCLUDE
#include "UnityCG.cginc"
struct v2f {
float4 pos : SV_POSITION;
float2 uv[2] : TEXCOORD0;
};
struct v2f_mt {
float4 pos : SV_POSITION;
float2 uv[5] : TEXCOORD0;
};
sampler2D _ColorBuffer;
sampler2D _MainTex;
half _Intensity;
half4 _ColorBuffer_TexelSize;
half4 _ColorBuffer_ST;
half4 _MainTex_TexelSize;
half4 _MainTex_ST;
v2f vert( appdata_img v ) {
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv[0] = v.texcoord.xy;
o.uv[1] = v.texcoord.xy;
#if UNITY_UV_STARTS_AT_TOP
if (_ColorBuffer_TexelSize.y < 0)
o.uv[1].y = 1-o.uv[1].y;
#endif
return o;
}
v2f_mt vertMultiTap( appdata_img v ) {
v2f_mt o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv[4] = v.texcoord.xy;
o.uv[0] = v.texcoord.xy + _MainTex_TexelSize.xy * 0.5;
o.uv[1] = v.texcoord.xy - _MainTex_TexelSize.xy * 0.5;
o.uv[2] = v.texcoord.xy - _MainTex_TexelSize.xy * half2(1,-1) * 0.5;
o.uv[3] = v.texcoord.xy + _MainTex_TexelSize.xy * half2(1,-1) * 0.5;
return o;
}
half4 fragScreen (v2f i) : SV_Target {
half4 addedbloom = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv[0].xy, _MainTex_ST)) * _Intensity;
half4 screencolor = tex2D(_ColorBuffer, UnityStereoScreenSpaceUVAdjust(i.uv[1], _ColorBuffer_ST));
return 1-(1-addedbloom)*(1-screencolor);
}
half4 fragScreenCheap(v2f i) : SV_Target {
half4 addedbloom = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv[0].xy, _MainTex_ST)) * _Intensity;
half4 screencolor = tex2D(_ColorBuffer, UnityStereoScreenSpaceUVAdjust(i.uv[1], _ColorBuffer_ST));
return 1-(1-addedbloom)*(1-screencolor);
}
half4 fragAdd (v2f i) : SV_Target {
half4 addedbloom = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv[0].xy, _MainTex_ST));
half4 screencolor = tex2D(_ColorBuffer, UnityStereoScreenSpaceUVAdjust(i.uv[1], _ColorBuffer_ST));
return _Intensity * addedbloom + screencolor;
}
half4 fragAddCheap (v2f i) : SV_Target {
half4 addedbloom = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv[0].xy, _MainTex_ST));
half4 screencolor = tex2D(_ColorBuffer, UnityStereoScreenSpaceUVAdjust(i.uv[1], _ColorBuffer_ST));
return _Intensity * addedbloom + screencolor;
}
half4 fragVignetteMul (v2f i) : SV_Target {
return tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv[0].xy, _MainTex_ST)) * tex2D(_ColorBuffer, UnityStereoScreenSpaceUVAdjust(i.uv[0], _ColorBuffer_ST));
}
half4 fragVignetteBlend (v2f i) : SV_Target {
return half4(1,1,1, tex2D(_ColorBuffer, UnityStereoScreenSpaceUVAdjust(i.uv[0], _ColorBuffer_ST)).r);
}
half4 fragClear (v2f i) : SV_Target {
return 0;
}
half4 fragAddOneOne (v2f i) : SV_Target {
half4 addedColors = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv[0].xy, _MainTex_ST));
return addedColors * _Intensity;
}
half4 frag1Tap (v2f i) : SV_Target {
return tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv[0].xy, _MainTex_ST));
}
half4 fragMultiTapMax (v2f_mt i) : SV_Target {
half4 outColor = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv[4].xy, _MainTex_ST));
outColor = max(outColor, tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv[0].xy, _MainTex_ST)));
outColor = max(outColor, tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv[1].xy, _MainTex_ST)));
outColor = max(outColor, tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv[2].xy, _MainTex_ST)));
outColor = max(outColor, tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv[3].xy, _MainTex_ST)));
return outColor;
}
half4 fragMultiTapBlur (v2f_mt i) : SV_Target {
half4 outColor = 0;
outColor += tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv[0].xy, _MainTex_ST));
outColor += tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv[1].xy, _MainTex_ST));
outColor += tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv[2].xy, _MainTex_ST));
outColor += tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv[3].xy, _MainTex_ST));
return outColor/4;
}
ENDCG
Subshader {
ZTest Always Cull Off ZWrite Off
// 0: nicer & softer "screen" blend mode
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment fragScreen
ENDCG
}
// 1: "add" blend mode
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment fragAdd
ENDCG
}
// 2: several taps, maxxed
Pass {
CGPROGRAM
#pragma vertex vertMultiTap
#pragma fragment fragMultiTapMax
ENDCG
}
// 3: vignette blending
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment fragVignetteMul
ENDCG
}
// 4: nicer & softer "screen" blend mode(cheapest)
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment fragScreenCheap
ENDCG
}
// 5: "add" blend mode (cheapest)
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment fragAddCheap
ENDCG
}
// 6: used for "stable" downsampling (blur)
Pass {
CGPROGRAM
#pragma vertex vertMultiTap
#pragma fragment fragMultiTapBlur
ENDCG
}
// 7: vignette blending (blend to dest)
Pass {
Blend Zero SrcAlpha
CGPROGRAM
#pragma vertex vert
#pragma fragment fragVignetteBlend
ENDCG
}
// 8: clear
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment fragClear
ENDCG
}
// 9: fragAddOneOne
Pass {
Blend One One
CGPROGRAM
#pragma vertex vert
#pragma fragment fragAddOneOne
ENDCG
}
// 10: max blend
Pass {
BlendOp Max
Blend One One
CGPROGRAM
#pragma vertex vert
#pragma fragment frag1Tap
ENDCG
}
}
Fallback off
} // shader

View File

@@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: 7856cbff0a0ca45c787d5431eb805bb0
ShaderImporter:
userData:

View File

@@ -0,0 +1,49 @@
Shader "Hidden/BlendOneOne" {
Properties {
_MainTex ("-", 2D) = "" {}
}
CGINCLUDE
#include "UnityCG.cginc"
struct v2f {
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
};
sampler2D _MainTex;
half4 _MainTex_ST;
half _Intensity;
v2f vert( appdata_img v ) {
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy, _MainTex_ST);
return o;
}
half4 frag(v2f i) : SV_Target {
return tex2D(_MainTex, i.uv) * _Intensity;
}
ENDCG
Subshader {
Pass {
BlendOp Add
Blend One One
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
ENDCG
}
}
Fallback off
}

View File

@@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: f7898d203e9b94c0dbe2bf9dd5cb32c0
ShaderImporter:
userData:

View File

@@ -0,0 +1,203 @@
Shader "Hidden/BlurAndFlares" {
Properties {
_MainTex ("Base (RGB)", 2D) = "" {}
_NonBlurredTex ("Base (RGB)", 2D) = "" {}
}
CGINCLUDE
#include "UnityCG.cginc"
struct v2f {
half4 pos : SV_POSITION;
half2 uv : TEXCOORD0;
};
struct v2f_opts {
half4 pos : SV_POSITION;
half2 uv[7] : TEXCOORD0;
};
struct v2f_blur {
half4 pos : SV_POSITION;
half2 uv : TEXCOORD0;
half4 uv01 : TEXCOORD1;
half4 uv23 : TEXCOORD2;
half4 uv45 : TEXCOORD3;
half4 uv67 : TEXCOORD4;
};
half4 _Offsets;
half4 _TintColor;
half _StretchWidth;
half2 _Threshhold;
half _Saturation;
half4 _MainTex_TexelSize;
half4 _MainTex_ST;
sampler2D _MainTex;
sampler2D _NonBlurredTex;
v2f vert (appdata_img v) {
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = v.texcoord.xy;
return o;
}
v2f_blur vertWithMultiCoords2 (appdata_img v) {
v2f_blur o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv.xy = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy, _MainTex_ST);
o.uv01 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * half4(1,1, -1,-1), _MainTex_ST);
o.uv23 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * half4(1,1, -1,-1) * 2.0, _MainTex_ST);
o.uv45 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * half4(1,1, -1,-1) * 3.0, _MainTex_ST);
o.uv67 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * half4(1,1, -1,-1) * 4.0, _MainTex_ST);
o.uv67 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * half4(1,1, -1,-1) * 5.0, _MainTex_ST);
return o;
}
v2f_opts vertStretch (appdata_img v) {
v2f_opts o;
o.pos = UnityObjectToClipPos(v.vertex);
half b = _StretchWidth;
o.uv[0] = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy, _MainTex_ST);
o.uv[1] = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy + b * 2.0 * _Offsets.xy, _MainTex_ST);
o.uv[2] = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy - b * 2.0 * _Offsets.xy, _MainTex_ST);
o.uv[3] = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy + b * 4.0 * _Offsets.xy, _MainTex_ST);
o.uv[4] = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy - b * 4.0 * _Offsets.xy, _MainTex_ST);
o.uv[5] = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy + b * 6.0 * _Offsets.xy, _MainTex_ST);
o.uv[6] = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy - b * 6.0 * _Offsets.xy, _MainTex_ST);
return o;
}
v2f_opts vertWithMultiCoords (appdata_img v) {
v2f_opts o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv[0] = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy, _MainTex_ST);
o.uv[1] = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy + 0.5 * _MainTex_TexelSize.xy * _Offsets.xy, _MainTex_ST);
o.uv[2] = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy - 0.5 * _MainTex_TexelSize.xy * _Offsets.xy, _MainTex_ST);
o.uv[3] = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy + 1.5 * _MainTex_TexelSize.xy * _Offsets.xy, _MainTex_ST);
o.uv[4] = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy - 1.5 * _MainTex_TexelSize.xy * _Offsets.xy, _MainTex_ST);
o.uv[5] = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy + 2.5 * _MainTex_TexelSize.xy * _Offsets.xy, _MainTex_ST);
o.uv[6] = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy - 2.5 * _MainTex_TexelSize.xy * _Offsets.xy, _MainTex_ST);
return o;
}
half4 fragPostNoBlur (v2f i) : SV_Target {
half4 color = tex2D (_MainTex, i.uv);
return color * 1.0/(1.0 + Luminance(color.rgb) + 0.5); // this also makes it a little noisy
}
half4 fragGaussBlur (v2f_blur i) : SV_Target {
half4 color = half4 (0,0,0,0);
color += 0.225 * tex2D (_MainTex, i.uv);
color += 0.150 * tex2D (_MainTex, i.uv01.xy);
color += 0.150 * tex2D (_MainTex, i.uv01.zw);
color += 0.110 * tex2D (_MainTex, i.uv23.xy);
color += 0.110 * tex2D (_MainTex, i.uv23.zw);
color += 0.075 * tex2D (_MainTex, i.uv45.xy);
color += 0.075 * tex2D (_MainTex, i.uv45.zw);
color += 0.0525 * tex2D (_MainTex, i.uv67.xy);
color += 0.0525 * tex2D (_MainTex, i.uv67.zw);
return color;
}
half4 fragPreAndCut (v2f_opts i) : SV_Target {
half4 color = tex2D (_MainTex, i.uv[0]);
color += tex2D (_MainTex, i.uv[1]);
color += tex2D (_MainTex, i.uv[2]);
color += tex2D (_MainTex, i.uv[3]);
color += tex2D (_MainTex, i.uv[4]);
color += tex2D (_MainTex, i.uv[5]);
color += tex2D (_MainTex, i.uv[6]);
color = max(color / 7.0 - _Threshhold.xxxx, float4(0,0,0,0));
half lum = Luminance(color.rgb);
color.rgb = lerp(half3(lum,lum,lum), color.rgb, _Saturation) * _TintColor.rgb;
return color;
}
half4 fragStretch (v2f_opts i) : SV_Target {
half4 color = tex2D (_MainTex, i.uv[0]);
color = max (color, tex2D (_MainTex, i.uv[1]));
color = max (color, tex2D (_MainTex, i.uv[2]));
color = max (color, tex2D (_MainTex, i.uv[3]));
color = max (color, tex2D (_MainTex, i.uv[4]));
color = max (color, tex2D (_MainTex, i.uv[5]));
color = max (color, tex2D (_MainTex, i.uv[6]));
return color;
}
half4 fragPost (v2f_opts i) : SV_Target {
half4 color = tex2D (_MainTex, i.uv[0]);
color += tex2D (_MainTex, i.uv[1]);
color += tex2D (_MainTex, i.uv[2]);
color += tex2D (_MainTex, i.uv[3]);
color += tex2D (_MainTex, i.uv[4]);
color += tex2D (_MainTex, i.uv[5]);
color += tex2D (_MainTex, i.uv[6]);
return color * 1.0/(7.0 + Luminance(color.rgb) + 0.5); // this also makes it a little noisy
}
ENDCG
Subshader {
ZTest Always Cull Off ZWrite Off
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment fragPostNoBlur
ENDCG
}
Pass {
CGPROGRAM
#pragma vertex vertStretch
#pragma fragment fragStretch
ENDCG
}
// 2
Pass {
CGPROGRAM
#pragma vertex vertWithMultiCoords
#pragma fragment fragPreAndCut
ENDCG
}
// 3
Pass {
CGPROGRAM
#pragma vertex vertWithMultiCoords
#pragma fragment fragPost
ENDCG
}
// 4
Pass {
CGPROGRAM
#pragma vertex vertWithMultiCoords2
#pragma fragment fragGaussBlur
ENDCG
}
}
Fallback off
}

View File

@@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: be6e39cf196f146d5be72fbefb18ed75
ShaderImporter:
userData:

View File

@@ -0,0 +1,58 @@
Shader "Hidden/BrightPassFilterForBloom"
{
Properties
{
_MainTex ("Base (RGB)", 2D) = "" {}
}
CGINCLUDE
#include "UnityCG.cginc"
struct v2f
{
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
};
sampler2D _MainTex;
half4 _MainTex_ST;
half4 threshold;
half useSrcAlphaAsMask;
v2f vert( appdata_img v )
{
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy, _MainTex_ST);
return o;
}
half4 frag(v2f i) : SV_Target
{
half4 color = tex2D(_MainTex, i.uv);
//color = color * saturate((color-threshhold.x) * 75.0); // didn't go well with HDR and din't make sense
color = color * lerp(1.0, color.a, useSrcAlphaAsMask);
color = max(half4(0,0,0,0), color-threshold.x);
return color;
}
ENDCG
Subshader
{
Pass
{
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
ENDCG
}
}
Fallback off
}

View File

@@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: 186c4c0d31e314f049595dcbaf4ca129
ShaderImporter:
userData:

View File

@@ -0,0 +1,75 @@
Shader "Hidden/BrightPassFilter2"
{
Properties
{
_MainTex ("Base (RGB)", 2D) = "" {}
}
CGINCLUDE
#include "UnityCG.cginc"
struct v2f
{
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
};
sampler2D _MainTex;
half4 _MainTex_ST;
half4 _Threshhold;
v2f vert( appdata_img v )
{
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy, _MainTex_ST);
return o;
}
half4 fragScalarThresh(v2f i) : SV_Target
{
half4 color = tex2D(_MainTex, i.uv);
color.rgb = color.rgb;
color.rgb = max(half3(0,0,0), color.rgb-_Threshhold.xxx);
return color;
}
half4 fragColorThresh(v2f i) : SV_Target
{
half4 color = tex2D(_MainTex, i.uv);
color.rgb = max(half3(0,0,0), color.rgb-_Threshhold.rgb);
return color;
}
ENDCG
Subshader
{
Pass
{
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#pragma vertex vert
#pragma fragment fragScalarThresh
ENDCG
}
Pass
{
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#pragma vertex vert
#pragma fragment fragColorThresh
ENDCG
}
}
Fallback off
}

View File

@@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: 0aeaa4cb29f5d4e9c8455f04c8575c8c
ShaderImporter:
userData:

View File

@@ -0,0 +1,61 @@
Shader "Hidden/LensFlareCreate" {
Properties {
_MainTex ("Base (RGB)", 2D) = "" {}
}
CGINCLUDE
#include "UnityCG.cginc"
struct v2f {
float4 pos : SV_POSITION;
float2 uv[4] : TEXCOORD0;
};
fixed4 colorA;
fixed4 colorB;
fixed4 colorC;
fixed4 colorD;
sampler2D _MainTex;
half4 _MainTex_ST;
v2f vert( appdata_img v ) {
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv[0] = UnityStereoScreenSpaceUVAdjust(( ( v.texcoord.xy - 0.5 ) * -0.85 ) + 0.5, _MainTex_ST);
o.uv[1] = UnityStereoScreenSpaceUVAdjust(( ( v.texcoord.xy - 0.5 ) * -1.45 ) + 0.5, _MainTex_ST);
o.uv[2] = UnityStereoScreenSpaceUVAdjust(( ( v.texcoord.xy - 0.5 ) * -2.55 ) + 0.5, _MainTex_ST);
o.uv[3] = UnityStereoScreenSpaceUVAdjust(( ( v.texcoord.xy - 0.5 ) * -4.15 ) + 0.5, _MainTex_ST);
return o;
}
fixed4 frag(v2f i) : SV_Target {
fixed4 color = float4 (0,0,0,0);
color += tex2D(_MainTex, i.uv[0] ) * colorA;
color += tex2D(_MainTex, i.uv[1] ) * colorB;
color += tex2D(_MainTex, i.uv[2] ) * colorC;
color += tex2D(_MainTex, i.uv[3] ) * colorD;
return color;
}
ENDCG
Subshader {
Blend One One
Pass {
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
ENDCG
}
}
Fallback off
} // shader

View File

@@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: 459fe69d2f6d74ddb92f04dbf45a866b
ShaderImporter:
userData:

View File

@@ -0,0 +1,287 @@
Shader "Hidden/FastBloom" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_Bloom ("Bloom (RGB)", 2D) = "black" {}
}
CGINCLUDE
#include "UnityCG.cginc"
sampler2D _MainTex;
sampler2D _Bloom;
uniform half4 _MainTex_TexelSize;
half4 _MainTex_ST;
uniform half4 _Parameter;
uniform half4 _OffsetsA;
uniform half4 _OffsetsB;
#define ONE_MINUS_THRESHHOLD_TIMES_INTENSITY _Parameter.w
#define THRESHHOLD _Parameter.z
struct v2f_simple
{
float4 pos : SV_POSITION;
half2 uv : TEXCOORD0;
#if UNITY_UV_STARTS_AT_TOP
half2 uv2 : TEXCOORD1;
#endif
};
v2f_simple vertBloom ( appdata_img v )
{
v2f_simple o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = UnityStereoScreenSpaceUVAdjust(v.texcoord, _MainTex_ST);
#if UNITY_UV_STARTS_AT_TOP
o.uv2 = o.uv;
if (_MainTex_TexelSize.y < 0.0)
o.uv.y = 1.0 - o.uv.y;
#endif
return o;
}
struct v2f_tap
{
float4 pos : SV_POSITION;
half2 uv20 : TEXCOORD0;
half2 uv21 : TEXCOORD1;
half2 uv22 : TEXCOORD2;
half2 uv23 : TEXCOORD3;
};
v2f_tap vert4Tap ( appdata_img v )
{
v2f_tap o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv20 = UnityStereoScreenSpaceUVAdjust(v.texcoord + _MainTex_TexelSize.xy, _MainTex_ST);
o.uv21 = UnityStereoScreenSpaceUVAdjust(v.texcoord + _MainTex_TexelSize.xy * half2(-0.5h,-0.5h), _MainTex_ST);
o.uv22 = UnityStereoScreenSpaceUVAdjust(v.texcoord + _MainTex_TexelSize.xy * half2(0.5h,-0.5h), _MainTex_ST);
o.uv23 = UnityStereoScreenSpaceUVAdjust(v.texcoord + _MainTex_TexelSize.xy * half2(-0.5h,0.5h), _MainTex_ST);
return o;
}
fixed4 fragBloom ( v2f_simple i ) : SV_Target
{
#if UNITY_UV_STARTS_AT_TOP
fixed4 color = tex2D(_MainTex, i.uv2);
return color + tex2D(_Bloom, i.uv);
#else
fixed4 color = tex2D(_MainTex, i.uv);
return color + tex2D(_Bloom, i.uv);
#endif
}
fixed4 fragDownsample ( v2f_tap i ) : SV_Target
{
fixed4 color = tex2D (_MainTex, i.uv20);
color += tex2D (_MainTex, i.uv21);
color += tex2D (_MainTex, i.uv22);
color += tex2D (_MainTex, i.uv23);
return max(color/4 - THRESHHOLD, 0) * ONE_MINUS_THRESHHOLD_TIMES_INTENSITY;
}
// weight curves
static const half curve[7] = { 0.0205, 0.0855, 0.232, 0.324, 0.232, 0.0855, 0.0205 }; // gauss'ish blur weights
static const half4 curve4[7] = { half4(0.0205,0.0205,0.0205,0), half4(0.0855,0.0855,0.0855,0), half4(0.232,0.232,0.232,0),
half4(0.324,0.324,0.324,1), half4(0.232,0.232,0.232,0), half4(0.0855,0.0855,0.0855,0), half4(0.0205,0.0205,0.0205,0) };
struct v2f_withBlurCoords8
{
float4 pos : SV_POSITION;
half4 uv : TEXCOORD0;
half2 offs : TEXCOORD1;
};
struct v2f_withBlurCoordsSGX
{
float4 pos : SV_POSITION;
half2 uv : TEXCOORD0;
half4 offs[3] : TEXCOORD1;
};
v2f_withBlurCoords8 vertBlurHorizontal (appdata_img v)
{
v2f_withBlurCoords8 o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = half4(v.texcoord.xy,1,1);
o.offs = _MainTex_TexelSize.xy * half2(1.0, 0.0) * _Parameter.x;
return o;
}
v2f_withBlurCoords8 vertBlurVertical (appdata_img v)
{
v2f_withBlurCoords8 o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = half4(v.texcoord.xy,1,1);
o.offs = _MainTex_TexelSize.xy * half2(0.0, 1.0) * _Parameter.x;
return o;
}
half4 fragBlur8 ( v2f_withBlurCoords8 i ) : SV_Target
{
half2 uv = i.uv.xy;
half2 netFilterWidth = i.offs;
half2 coords = uv - netFilterWidth * 3.0;
half4 color = 0;
for( int l = 0; l < 7; l++ )
{
half4 tap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(coords, _MainTex_ST));
color += tap * curve4[l];
coords += netFilterWidth;
}
return color;
}
v2f_withBlurCoordsSGX vertBlurHorizontalSGX (appdata_img v)
{
v2f_withBlurCoordsSGX o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = v.texcoord.xy;
half offsetMagnitude = _MainTex_TexelSize.x * _Parameter.x;
o.offs[0] = v.texcoord.xyxy + offsetMagnitude * half4(-3.0h, 0.0h, 3.0h, 0.0h);
o.offs[1] = v.texcoord.xyxy + offsetMagnitude * half4(-2.0h, 0.0h, 2.0h, 0.0h);
o.offs[2] = v.texcoord.xyxy + offsetMagnitude * half4(-1.0h, 0.0h, 1.0h, 0.0h);
return o;
}
v2f_withBlurCoordsSGX vertBlurVerticalSGX (appdata_img v)
{
v2f_withBlurCoordsSGX o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = half4(v.texcoord.xy,1,1);
half offsetMagnitude = _MainTex_TexelSize.y * _Parameter.x;
o.offs[0] = v.texcoord.xyxy + offsetMagnitude * half4(0.0h, -3.0h, 0.0h, 3.0h);
o.offs[1] = v.texcoord.xyxy + offsetMagnitude * half4(0.0h, -2.0h, 0.0h, 2.0h);
o.offs[2] = v.texcoord.xyxy + offsetMagnitude * half4(0.0h, -1.0h, 0.0h, 1.0h);
return o;
}
half4 fragBlurSGX ( v2f_withBlurCoordsSGX i ) : SV_Target
{
half2 uv = i.uv.xy;
half4 color = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv, _MainTex_ST)) * curve4[3];
for( int l = 0; l < 3; l++ )
{
half4 tapA = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.offs[l].xy, _MainTex_ST));
half4 tapB = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.offs[l].zw, _MainTex_ST));
color += (tapA + tapB) * curve4[l];
}
return color;
}
ENDCG
SubShader {
ZTest Off Cull Off ZWrite Off Blend Off
// 0
Pass {
CGPROGRAM
#pragma vertex vertBloom
#pragma fragment fragBloom
ENDCG
}
// 1
Pass {
CGPROGRAM
#pragma vertex vert4Tap
#pragma fragment fragDownsample
ENDCG
}
// 2
Pass {
ZTest Always
Cull Off
CGPROGRAM
#pragma vertex vertBlurVertical
#pragma fragment fragBlur8
ENDCG
}
// 3
Pass {
ZTest Always
Cull Off
CGPROGRAM
#pragma vertex vertBlurHorizontal
#pragma fragment fragBlur8
ENDCG
}
// alternate blur
// 4
Pass {
ZTest Always
Cull Off
CGPROGRAM
#pragma vertex vertBlurVerticalSGX
#pragma fragment fragBlurSGX
ENDCG
}
// 5
Pass {
ZTest Always
Cull Off
CGPROGRAM
#pragma vertex vertBlurHorizontalSGX
#pragma fragment fragBlurSGX
ENDCG
}
}
FallBack Off
}

View File

@@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: 68a00c837b82e4c6d92e7da765dc5f1d
ShaderImporter:
userData:

View File

@@ -0,0 +1,234 @@
Shader "Hidden/FastBlur" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_Bloom ("Bloom (RGB)", 2D) = "black" {}
}
CGINCLUDE
#include "UnityCG.cginc"
sampler2D _MainTex;
sampler2D _Bloom;
uniform half4 _MainTex_TexelSize;
half4 _MainTex_ST;
half4 _Bloom_ST;
uniform half4 _Parameter;
struct v2f_tap
{
float4 pos : SV_POSITION;
half2 uv20 : TEXCOORD0;
half2 uv21 : TEXCOORD1;
half2 uv22 : TEXCOORD2;
half2 uv23 : TEXCOORD3;
};
v2f_tap vert4Tap ( appdata_img v )
{
v2f_tap o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv20 = UnityStereoScreenSpaceUVAdjust(v.texcoord + _MainTex_TexelSize.xy, _MainTex_ST);
o.uv21 = UnityStereoScreenSpaceUVAdjust(v.texcoord + _MainTex_TexelSize.xy * half2(-0.5h,-0.5h), _MainTex_ST);
o.uv22 = UnityStereoScreenSpaceUVAdjust(v.texcoord + _MainTex_TexelSize.xy * half2(0.5h,-0.5h), _MainTex_ST);
o.uv23 = UnityStereoScreenSpaceUVAdjust(v.texcoord + _MainTex_TexelSize.xy * half2(-0.5h,0.5h), _MainTex_ST);
return o;
}
fixed4 fragDownsample ( v2f_tap i ) : SV_Target
{
fixed4 color = tex2D (_MainTex, i.uv20);
color += tex2D (_MainTex, i.uv21);
color += tex2D (_MainTex, i.uv22);
color += tex2D (_MainTex, i.uv23);
return color / 4;
}
// weight curves
static const half curve[7] = { 0.0205, 0.0855, 0.232, 0.324, 0.232, 0.0855, 0.0205 }; // gauss'ish blur weights
static const half4 curve4[7] = { half4(0.0205,0.0205,0.0205,0), half4(0.0855,0.0855,0.0855,0), half4(0.232,0.232,0.232,0),
half4(0.324,0.324,0.324,1), half4(0.232,0.232,0.232,0), half4(0.0855,0.0855,0.0855,0), half4(0.0205,0.0205,0.0205,0) };
struct v2f_withBlurCoords8
{
float4 pos : SV_POSITION;
half4 uv : TEXCOORD0;
half2 offs : TEXCOORD1;
};
struct v2f_withBlurCoordsSGX
{
float4 pos : SV_POSITION;
half2 uv : TEXCOORD0;
half4 offs[3] : TEXCOORD1;
};
v2f_withBlurCoords8 vertBlurHorizontal (appdata_img v)
{
v2f_withBlurCoords8 o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = half4(v.texcoord.xy,1,1);
o.offs = _MainTex_TexelSize.xy * half2(1.0, 0.0) * _Parameter.x;
return o;
}
v2f_withBlurCoords8 vertBlurVertical (appdata_img v)
{
v2f_withBlurCoords8 o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = half4(v.texcoord.xy,1,1);
o.offs = _MainTex_TexelSize.xy * half2(0.0, 1.0) * _Parameter.x;
return o;
}
half4 fragBlur8 ( v2f_withBlurCoords8 i ) : SV_Target
{
half2 uv = i.uv.xy;
half2 netFilterWidth = i.offs;
half2 coords = uv - netFilterWidth * 3.0;
half4 color = 0;
for( int l = 0; l < 7; l++ )
{
half4 tap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(coords, _MainTex_ST));
color += tap * curve4[l];
coords += netFilterWidth;
}
return color;
}
v2f_withBlurCoordsSGX vertBlurHorizontalSGX (appdata_img v)
{
v2f_withBlurCoordsSGX o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy, _MainTex_ST);
half offsetMagnitude = _MainTex_TexelSize.x * _Parameter.x;
o.offs[0] = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + offsetMagnitude * half4(-3.0h, 0.0h, 3.0h, 0.0h), _MainTex_ST);
o.offs[1] = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + offsetMagnitude * half4(-2.0h, 0.0h, 2.0h, 0.0h), _MainTex_ST);
o.offs[2] = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + offsetMagnitude * half4(-1.0h, 0.0h, 1.0h, 0.0h), _MainTex_ST);
return o;
}
v2f_withBlurCoordsSGX vertBlurVerticalSGX (appdata_img v)
{
v2f_withBlurCoordsSGX o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = half4(UnityStereoScreenSpaceUVAdjust(v.texcoord.xy, _MainTex_ST),1,1);
half offsetMagnitude = _MainTex_TexelSize.y * _Parameter.x;
o.offs[0] = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + offsetMagnitude * half4(0.0h, -3.0h, 0.0h, 3.0h), _MainTex_ST);
o.offs[1] = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + offsetMagnitude * half4(0.0h, -2.0h, 0.0h, 2.0h), _MainTex_ST);
o.offs[2] = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + offsetMagnitude * half4(0.0h, -1.0h, 0.0h, 1.0h), _MainTex_ST);
return o;
}
half4 fragBlurSGX ( v2f_withBlurCoordsSGX i ) : SV_Target
{
half2 uv = i.uv.xy;
half4 color = tex2D(_MainTex, i.uv) * curve4[3];
for( int l = 0; l < 3; l++ )
{
half4 tapA = tex2D(_MainTex, i.offs[l].xy);
half4 tapB = tex2D(_MainTex, i.offs[l].zw);
color += (tapA + tapB) * curve4[l];
}
return color;
}
ENDCG
SubShader {
ZTest Off Cull Off ZWrite Off Blend Off
// 0
Pass {
CGPROGRAM
#pragma vertex vert4Tap
#pragma fragment fragDownsample
ENDCG
}
// 1
Pass {
ZTest Always
Cull Off
CGPROGRAM
#pragma vertex vertBlurVertical
#pragma fragment fragBlur8
ENDCG
}
// 2
Pass {
ZTest Always
Cull Off
CGPROGRAM
#pragma vertex vertBlurHorizontal
#pragma fragment fragBlur8
ENDCG
}
// alternate blur
// 3
Pass {
ZTest Always
Cull Off
CGPROGRAM
#pragma vertex vertBlurVerticalSGX
#pragma fragment fragBlurSGX
ENDCG
}
// 4
Pass {
ZTest Always
Cull Off
CGPROGRAM
#pragma vertex vertBlurHorizontalSGX
#pragma fragment fragBlurSGX
ENDCG
}
}
FallBack Off
}

View File

@@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: f9d5fa183cd6b45eeb1491f74863cd91
ShaderImporter:
userData:

View File

@@ -0,0 +1,155 @@
Shader "Hidden/MultipassHollywoodFlares" {
Properties {
_MainTex ("Base (RGB)", 2D) = "" {}
_NonBlurredTex ("Base (RGB)", 2D) = "" {}
}
CGINCLUDE
#include "UnityCG.cginc"
struct v2f {
half4 pos : SV_POSITION;
half2 uv : TEXCOORD0;
};
struct v2f_opts {
half4 pos : SV_POSITION;
half2 uv[7] : TEXCOORD0;
};
half4 offsets;
half4 tintColor;
half stretchWidth;
half2 _Threshhold;
half4 _MainTex_TexelSize;
half4 _MainTex_ST;
sampler2D _MainTex;
sampler2D _NonBlurredTex;
v2f vert (appdata_img v) {
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = v.texcoord.xy;
return o;
}
v2f_opts vertStretch (appdata_img v) {
v2f_opts o;
o.pos = UnityObjectToClipPos(v.vertex);
half b = stretchWidth;
o.uv[0] = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy, _MainTex_ST);
o.uv[1] = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy + b * 2.0 * offsets.xy, _MainTex_ST);
o.uv[2] = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy - b * 2.0 * offsets.xy, _MainTex_ST);
o.uv[3] = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy + b * 4.0 * offsets.xy, _MainTex_ST);
o.uv[4] = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy - b * 4.0 * offsets.xy, _MainTex_ST);
o.uv[5] = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy + b * 6.0 * offsets.xy, _MainTex_ST);
o.uv[6] = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy - b * 6.0 * offsets.xy, _MainTex_ST);
return o;
}
v2f_opts vertVerticalCoords (appdata_img v) {
v2f_opts o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv[0] = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy, _MainTex_ST);
o.uv[1] = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy + 0.5 * _MainTex_TexelSize.xy * half2(0,1), _MainTex_ST);
o.uv[2] = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy - 0.5 * _MainTex_TexelSize.xy * half2(0,1), _MainTex_ST);
o.uv[3] = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy + 1.5 * _MainTex_TexelSize.xy * half2(0,1), _MainTex_ST);
o.uv[4] = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy - 1.5 * _MainTex_TexelSize.xy * half2(0,1), _MainTex_ST);
o.uv[5] = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy + 2.5 * _MainTex_TexelSize.xy * half2(0,1), _MainTex_ST);
o.uv[6] = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy - 2.5 * _MainTex_TexelSize.xy * half2(0,1), _MainTex_ST);
return o;
}
// deprecated
half4 fragPrepare (v2f i) : SV_Target {
half4 color = tex2D (_MainTex, i.uv);
half4 colorNb = tex2D (_NonBlurredTex, i.uv);
return color * tintColor * 0.5 + colorNb * normalize (tintColor) * 0.5;
}
half4 fragPreAndCut (v2f_opts i) : SV_Target {
half4 color = tex2D (_MainTex, i.uv[0]);
color += tex2D (_MainTex, i.uv[1]);
color += tex2D (_MainTex, i.uv[2]);
color += tex2D (_MainTex, i.uv[3]);
color += tex2D (_MainTex, i.uv[4]);
color += tex2D (_MainTex, i.uv[5]);
color += tex2D (_MainTex, i.uv[6]);
return max(color / 7.0 - _Threshhold.x, 0.0) * _Threshhold.y * tintColor;
}
half4 fragStretch (v2f_opts i) : SV_Target {
half4 color = tex2D (_MainTex, i.uv[0]);
color = max (color, tex2D (_MainTex, i.uv[1]));
color = max (color, tex2D (_MainTex, i.uv[2]));
color = max (color, tex2D (_MainTex, i.uv[3]));
color = max (color, tex2D (_MainTex, i.uv[4]));
color = max (color, tex2D (_MainTex, i.uv[5]));
color = max (color, tex2D (_MainTex, i.uv[6]));
return color;
}
half4 fragPost (v2f_opts i) : SV_Target {
half4 color = tex2D (_MainTex, i.uv[0]);
color += tex2D (_MainTex, i.uv[1]);
color += tex2D (_MainTex, i.uv[2]);
color += tex2D (_MainTex, i.uv[3]);
color += tex2D (_MainTex, i.uv[4]);
color += tex2D (_MainTex, i.uv[5]);
color += tex2D (_MainTex, i.uv[6]);
return color * 1.0/(7.0 + Luminance(color.rgb) + 0.5); // this also makes it a little noisy
}
ENDCG
Subshader {
ZTest Always Cull Off ZWrite Off
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment fragPrepare
ENDCG
}
Pass {
CGPROGRAM
#pragma vertex vertStretch
#pragma fragment fragStretch
ENDCG
}
Pass {
CGPROGRAM
#pragma vertex vertVerticalCoords
#pragma fragment fragPreAndCut
ENDCG
}
Pass {
CGPROGRAM
#pragma vertex vertVerticalCoords
#pragma fragment fragPost
ENDCG
}
}
Fallback off
}

View File

@@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: e2baf3cae8edc4daf94c9adc2154be00
ShaderImporter:
userData:

View File

@@ -0,0 +1,70 @@
Shader "Hidden/SeparableBlurPlus" {
Properties {
_MainTex ("Base (RGB)", 2D) = "" {}
}
CGINCLUDE
#include "UnityCG.cginc"
struct v2f {
half4 pos : SV_POSITION;
half2 uv : TEXCOORD0;
half4 uv01 : TEXCOORD1;
half4 uv23 : TEXCOORD2;
half4 uv45 : TEXCOORD3;
half4 uv67 : TEXCOORD4;
};
half4 offsets;
sampler2D _MainTex;
half4 _MainTex_ST;
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;
o.uv67 = v.texcoord.xyxy + offsets.xyxy * half4(1,1, -1,-1) * 4.5;
o.uv67 = v.texcoord.xyxy + offsets.xyxy * half4(1,1, -1,-1) * 6.5;
return o;
}
half4 frag (v2f i) : SV_Target {
half4 color = half4 (0,0,0,0);
color += 0.225 * tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv, _MainTex_ST));
color += 0.150 * tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv01.xy, _MainTex_ST));
color += 0.150 * tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv01.zw, _MainTex_ST));
color += 0.110 * tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv23.xy, _MainTex_ST));
color += 0.110 * tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv23.zw, _MainTex_ST));
color += 0.075 * tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv45.xy, _MainTex_ST));
color += 0.075 * tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv45.zw, _MainTex_ST));
color += 0.0525 * tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv67.xy, _MainTex_ST));
color += 0.0525 * tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv67.zw, _MainTex_ST));
return color;
}
ENDCG
Subshader {
Pass {
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
ENDCG
}
}
Fallback off
} // shader

View File

@@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: a9df009a214e24a5ebbf271595f8d5b6
ShaderImporter:
userData:

View File

@@ -0,0 +1,57 @@
Shader "Hidden/VignetteShader" {
Properties {
_MainTex ("Base (RGB)", 2D) = "" {}
}
CGINCLUDE
#include "UnityCG.cginc"
struct v2f {
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
};
sampler2D _MainTex;
float4 _MainTex_TexelSize;
float vignetteIntensity;
v2f vert( appdata_img v ) {
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = v.texcoord.xy;
return o;
}
half4 frag(v2f i) : SV_Target {
half2 coords = i.uv;
half2 uv = i.uv;
coords = (coords - 0.5) * 2.0;
half coordDot = dot (coords,coords);
half4 color = tex2D (_MainTex, uv);
float mask = 1.0 - coordDot * vignetteIntensity;
return color * mask;
}
ENDCG
Subshader {
Pass {
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
ENDCG
}
}
Fallback off
} // shader

View File

@@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: 562f620336e024ac99992ff05725a89a
ShaderImporter:
userData: