Add beautify post process to project

This commit is contained in:
Lucien
2026-08-03 16:52:25 +02:00
parent 3cd1ca53fd
commit 98a9c89de6
248 changed files with 23693 additions and 3085 deletions
-491
View File
@@ -1,491 +0,0 @@
// Copyright 2016-2020 Ramiro Oliva (Kronnect) - All Rights Reserved.
#include "UnityCG.cginc"
#include "BeautifyAdvancedParams.cginc"
#include "BeautifyOrtho.cginc"
#if defined(BEAUTIFY_ACES_FITTED)
#include "BeautifyACESFitted.cginc"
#define tmoFilmicACES ACESFitted
#endif
UNITY_DECLARE_SCREENSPACE_TEXTURE(_MainTex);
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
uniform sampler2D _OverlayTex;
UNITY_DECLARE_SCREENSPACE_TEXTURE(_ScreenLum);
UNITY_DECLARE_SCREENSPACE_TEXTURE(_BloomTex);
UNITY_DECLARE_SCREENSPACE_TEXTURE(_EALumSrc);
UNITY_DECLARE_SCREENSPACE_TEXTURE(_EAHist);
UNITY_DECLARE_SCREENSPACE_TEXTURE(_CompareTex);
uniform sampler2D _LUTTex;
uniform float4 _MainTex_TexelSize;
uniform float4 _MainTex_ST;
uniform float4 _BloomTex_TexelSize;
uniform float4 _ColorBoost; // x = Brightness, y = Contrast, z = Saturate, w = Daltonize;
uniform float4 _Sharpen;
uniform float4 _Dither;
uniform float4 _FXColor;
uniform float4 _TintColor;
uniform float4 _Outline;
uniform float4 _Dirt; // x = brightness based, y = intensity, z = threshold, w = bloom contribution
uniform float4 _Bloom;
uniform float4 _CompareParams;
uniform float _SharpenDepthFallOff;
#if BEAUTIFY_VIGNETTING || BEAUTIFY_VIGNETTING_MASK
uniform float4 _Vignetting;
uniform float _VignettingAspectRatio;
uniform sampler2D _VignettingMask;
#endif
#if BEAUTIFY_FRAME || BEAUTIFY_FRAME_MASK
uniform float4 _Frame;
uniform sampler2D _FrameMask;
#endif
uniform float4 _BokehData;
uniform float4 _BokehData2;
uniform float4 _EyeAdaptation;
uniform float3 _Purkinje;
#if BEAUTIFY_DEPTH_OF_FIELD_TRANSPARENT || BEAUTIFY_DEPTH_OF_FIELD
UNITY_DECLARE_SCREENSPACE_TEXTURE(_DoFTex);
uniform float4 _DoFTex_TexelSize;
#endif
#if BEAUTIFY_DEPTH_OF_FIELD_TRANSPARENT
uniform sampler2D _DepthTexture;
uniform sampler2D _DofExclusionTexture;
#endif
#if defined(BEAUTIFY_EDGE_AA)
uniform float2 _AntialiasData;
#endif
struct appdata {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f {
float4 pos : SV_POSITION;
float2 uv: TEXCOORD0;
float4 depthUV : TEXCOORD1;
#if BEAUTIFY_DIRT || BEAUTIFY_DEPTH_OF_FIELD_TRANSPARENT || BEAUTIFY_VIGNETTING || BEAUTIFY_VIGNETTING_MASK || BEAUTIFY_FRAME || BEAUTIFY_FRAME_MASK
float2 uvNonStereo: TEXCOORD2;
#endif
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
struct v2fCompare {
float4 pos : SV_POSITION;
float2 uv: TEXCOORD0;
float2 uvNonStereo: TEXCOORD1;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
struct v2fCross {
float4 pos : SV_POSITION;
float2 uv: TEXCOORD0;
float2 uv1: TEXCOORD1;
float2 uv2: TEXCOORD2;
float2 uv3: TEXCOORD3;
float2 uv4: TEXCOORD4;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
v2fCompare vertCompare(appdata v) {
v2fCompare o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = UnityStereoScreenSpaceUVAdjust(v.texcoord, _MainTex_ST);
o.uvNonStereo = v.texcoord;
return o;
}
v2fCross vertCross(appdata v) {
v2fCross o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = UnityStereoScreenSpaceUVAdjust(v.texcoord, _MainTex_ST);
float3 offsets = _MainTex_TexelSize.xyx * half3(1.75,1.75,0);
#if UNITY_SINGLE_PASS_STEREO
offsets.x *= 2.0;
#endif
o.uv1 = UnityStereoScreenSpaceUVAdjust(v.texcoord - offsets.zy, _MainTex_ST);
o.uv2 = UnityStereoScreenSpaceUVAdjust(v.texcoord - offsets.xz, _MainTex_ST);
o.uv3 = UnityStereoScreenSpaceUVAdjust(v.texcoord + offsets.xz, _MainTex_ST);
o.uv4 = UnityStereoScreenSpaceUVAdjust(v.texcoord + offsets.zy, _MainTex_ST);
return o;
}
v2f vert(appdata v) {
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = UnityStereoScreenSpaceUVAdjust(v.texcoord, _MainTex_ST);
o.depthUV = float4(o.uv, 0, 0);
#if BEAUTIFY_DIRT || BEAUTIFY_DEPTH_OF_FIELD_TRANSPARENT || BEAUTIFY_VIGNETTING || BEAUTIFY_VIGNETTING_MASK || BEAUTIFY_FRAME || BEAUTIFY_FRAME_MASK
o.uvNonStereo = v.texcoord;
#endif
#if UNITY_UV_STARTS_AT_TOP
if (_MainTex_TexelSize.y < 0) {
// Depth texture is inverted WRT the main texture
o.depthUV.y = 1.0 - o.depthUV.y;
#if BEAUTIFY_DIRT || BEAUTIFY_DEPTH_OF_FIELD_TRANSPARENT || BEAUTIFY_VIGNETTING || BEAUTIFY_VIGNETTING_MASK || BEAUTIFY_FRAME || BEAUTIFY_FRAME_MASK
o.uvNonStereo.y = 1.0 - o.uvNonStereo.y;
#endif
}
#endif
return o;
}
inline float getLuma(float3 rgb) {
const float3 lum = float3(0.299, 0.587, 0.114);
return dot(rgb, lum);
}
float3 getNormal(float depth, float depth1, float depth2, float2 offset1, float2 offset2) {
float3 p1 = float3(offset1, depth1 - depth);
float3 p2 = float3(offset2, depth2 - depth);
float3 normal = cross(p1, p2);
return normalize(normal);
}
float getRandom(float2 uv) {
return frac(sin(_Time.y + dot(uv, float2(12.9898, 78.233)))* 43758.5453);
}
float getCoc(v2f i) {
#if BEAUTIFY_DEPTH_OF_FIELD_TRANSPARENT
float depthTex = DecodeFloatRGBA(tex2Dlod(_DepthTexture, float4(i.uvNonStereo, 0, 0)));
float exclusionDepth = DecodeFloatRGBA(tex2Dlod(_DofExclusionTexture, float4(i.uvNonStereo, 0, 0)));
//float depth = BEAUTIFY_GET_DEPTH_01(UNITY_SAMPLE_DEPTH(SAMPLE_RAW_DEPTH_TEXTURE_LOD(_CameraDepthTexture, i.depthUV)));
float depth = Linear01Depth(BEAUTIFY_DEPTH_LOD(_CameraDepthTexture, i.depthUV));
depth = min(depth, depthTex);
if (exclusionDepth < depth) return 0;
depth *= _ProjectionParams.z;
#else
//float depth = BEAUTIFY_GET_DEPTH_EYE(UNITY_SAMPLE_DEPTH(SAMPLE_RAW_DEPTH_TEXTURE_LOD(_CameraDepthTexture, i.depthUV)));
float depth = LinearEyeDepth(BEAUTIFY_DEPTH_LOD(_CameraDepthTexture, i.depthUV));
#endif
float xd = abs(depth - _BokehData.x) - _BokehData2.x * (depth < _BokehData.x);
return 0.5 * _BokehData.y * xd/depth; // radius of CoC
}
#if !defined(BEAUTIFY_ACES_FITTED)
inline float3 tmoFilmicACES(float3 x) {
const float A = 2.51;
const float B = 0.03;
const float C = 2.43;
const float D = 0.59;
const float E = 0.14;
return (x * (A * x + B) ) / (x * (C * x + D) + E);
}
#endif
void beautifyPass(v2f i, inout float3 rgbM) {
float3 uvInc = float3(_MainTex_TexelSize.x, _MainTex_TexelSize.y, 0);
float depthS = Linear01Depth(BEAUTIFY_DEPTH_LOD(_CameraDepthTexture, i.depthUV - uvInc.zyzz));
float depthW = Linear01Depth(BEAUTIFY_DEPTH_LOD(_CameraDepthTexture, i.depthUV - uvInc.xzzz));
float depthE = Linear01Depth(BEAUTIFY_DEPTH_LOD(_CameraDepthTexture, i.depthUV + uvInc.xzzz));
float depthN = Linear01Depth(BEAUTIFY_DEPTH_LOD(_CameraDepthTexture, i.depthUV + uvInc.zyzz));
float lumaM = getLuma(rgbM);
#if !BEAUTIFY_NIGHT_VISION && !BEAUTIFY_THERMAL_VISION
#if !defined(BEAUTIFY_DITHER_FINAL) && defined(BEAUTIFY_ENABLE_DITHER)
float3 dither = dot(float2(171.0, 231.0), i.uv * _ScreenParams.xy).xxx;
dither = frac(dither / float3(103.0, 71.0, 97.0)) - 0.5.xxx;
rgbM *= 1.0 + step(_Dither.y, depthW) * _Dither.x * dither;
#endif
#if BEAUTIFY_DALTONIZE
float3 rgb0 = 1.0.xxx - saturate(rgbM.rgb);
rgbM.r *= 1.0 + rgbM.r * rgb0.g * rgb0.b * _ColorBoost.w;
rgbM.g *= 1.0 + rgbM.g * rgb0.r * rgb0.b * _ColorBoost.w;
rgbM.b *= 1.0 + rgbM.b * rgb0.r * rgb0.g * _ColorBoost.w;
rgbM *= lumaM / (getLuma(rgbM) + 0.0001);
#endif
float maxDepth = max(depthN, depthS);
maxDepth = max(maxDepth, depthW);
maxDepth = max(maxDepth, depthE);
float minDepth = min(depthN, depthS);
minDepth = min(minDepth, depthW);
minDepth = min(minDepth, depthE);
float dDepth = maxDepth - minDepth + 0.00001;
float lumaDepth = saturate(_Sharpen.y / dDepth);
float3 rgbS = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv - uvInc.zy).rgb;
float3 rgbW = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv - uvInc.xz).rgb;
float3 rgbE = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv + uvInc.xz).rgb;
float3 rgbN = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv + uvInc.zy).rgb;
float lumaN = getLuma(rgbN);
float lumaE = getLuma(rgbE);
float lumaW = getLuma(rgbW);
float lumaS = getLuma(rgbS);
float maxLuma = max(lumaN,lumaS);
maxLuma = max(maxLuma, lumaW);
maxLuma = max(maxLuma, lumaE);
float minLuma = min(lumaN,lumaS);
minLuma = min(minLuma, lumaW);
minLuma = min(minLuma, lumaE) - 0.000001;
float lumaPower = 2.0 * lumaM - minLuma - maxLuma;
float lumaAtten = saturate(_Sharpen.w / (maxLuma - minLuma));
#if defined(BEAUTIFY_EDGE_AA)
if (dDepth > _AntialiasData.y) {
float2 n = float2(lumaS - lumaN, lumaW - lumaE);
n *= _MainTex_TexelSize.xy * _AntialiasData.x;
float3 rgbA = 0.5 * (UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv + n * (1.0 / 3.0 - 0.5)).rgb + UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv + n * (2.0 / 3.0 - 0.5)).rgb);
float3 rgbB = rgbA * 0.5 + 0.25 * (UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv + n * (0.0 / 3.0 - 0.5)).rgb + UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv + n * (3.0 / 3.0 - 0.5)).rgb);
float lumaB = getLuma(rgbB);
if (lumaB < minLuma || lumaB > maxLuma) rgbM = rgbA; else rgbM = rgbB;
}
#endif
#if defined(BEAUTIFY_DEPTH_BASED_SHARPEN)
float depthDist = _Dither.w / abs(depthW - _Dither.z);
float depthClamp = depthDist > 1.0;
depthClamp = max(depthClamp, saturate(_SharpenDepthFallOff * depthDist));
#else
float depthClamp = 1.0;
#endif
#if defined(BEAUTIFY_ENABLE_CORE_EFFECT)
rgbM *= 1.0 + clamp(lumaPower * lumaAtten * lumaDepth * _Sharpen.x, -_Sharpen.z, _Sharpen.z) * depthClamp;
#endif
#if BEAUTIFY_DEPTH_OF_FIELD || BEAUTIFY_DEPTH_OF_FIELD_TRANSPARENT
float4 dofPix = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_DoFTex, i.uv);
#if UNITY_COLORSPACE_GAMMA
dofPix.rgb = LinearToGammaSpace(dofPix.rgb);
#endif
if (_DoFTex_TexelSize.z < _MainTex_TexelSize.z) {
float CoC = getCoc(i);
dofPix.a = lerp(CoC, dofPix.a, _DoFTex_TexelSize.z / _MainTex_TexelSize.z);
}
rgbM = lerp(rgbM, dofPix.rgb, saturate(dofPix.a));
#endif
#endif // night & thermal vision exclusion
#if BEAUTIFY_NIGHT_VISION
//float depth = BEAUTIFY_GET_DEPTH_01(UNITY_SAMPLE_DEPTH(SAMPLE_RAW_DEPTH_TEXTURE_LOD(_CameraDepthTexture, i.depthUV)));
float depth = Linear01Depth(BEAUTIFY_DEPTH_LOD(_CameraDepthTexture, i.depthUV));
// float3 normalNW = getNormal(depth, depthN, depthW, uvInc.zy, -uvInc.xz); // According to Unity QA this causes issues in Mali G71 GPU due to a hardware problem
float3 normalNW = getNormal(depth, depthN, depthW, uvInc.zy, float2(-uvInc.x, -uvInc.z));
#endif
#if BEAUTIFY_OUTLINE
#if !defined(BEAUTIFY_OUTLINE_SOBEL)
#if !BEAUTIFY_NIGHT_VISION
//float depth = BEAUTIFY_GET_DEPTH_01(UNITY_SAMPLE_DEPTH(SAMPLE_RAW_DEPTH_TEXTURE_LOD(_CameraDepthTexture, i.depthUV)));
float depth = Linear01Depth(BEAUTIFY_DEPTH_LOD(_CameraDepthTexture, i.depthUV));
// float3 normalNW = getNormal(depth, depthN, depthW, uvInc.zy, -uvInc.xz); // According to Unity QA this causes issues in Mali G71 GPU due to a hardware problem
float3 normalNW = getNormal(depth, depthN, depthW, uvInc.zy, float2(-uvInc.x, -uvInc.z));
#endif
float3 normalSE = getNormal(depth, depthS, depthE, -uvInc.zy, uvInc.xz);
float dnorm = dot(normalNW, normalSE);
rgbM = lerp(rgbM, _Outline.rgb, (float)(dnorm < _Outline.a));
#else
float4 uv4 = float4(i.uv, 0, 0);
#if BEAUTIFY_NIGHT_VISION || BEAUTIFY_THERMAL_VISION
float3 rgbS = SAMPLE_RAW_DEPTH_TEXTURE_LOD(_MainTex, uv4 - uvInc.zyzz).rgb;
float3 rgbN = SAMPLE_RAW_DEPTH_TEXTURE_LOD(_MainTex, uv4 + uvInc.zyzz).rgb;
float3 rgbW = SAMPLE_RAW_DEPTH_TEXTURE_LOD(_MainTex, uv4 - uvInc.xzzz).rgb;
float3 rgbE = SAMPLE_RAW_DEPTH_TEXTURE_LOD(_MainTex, uv4 + uvInc.xzzz).rgb;
#endif
float3 rgbSW = SAMPLE_RAW_DEPTH_TEXTURE_LOD(_MainTex, uv4 - uvInc.xyzz).rgb; // was tex2Dlod
float3 rgbNE = SAMPLE_RAW_DEPTH_TEXTURE_LOD(_MainTex, uv4 + uvInc.xyzz).rgb;
float3 rgbSE = SAMPLE_RAW_DEPTH_TEXTURE_LOD(_MainTex, uv4 + float4( uvInc.x, -uvInc.y, 0, 0)).rgb;
float3 rgbNW = SAMPLE_RAW_DEPTH_TEXTURE_LOD(_MainTex, uv4 + float4(-uvInc.x, uvInc.y, 0, 0)).rgb;
float3 gx = rgbSW * -1.0;
gx += rgbSE * 1.0;
gx += rgbW * -2.0;
gx += rgbE * 2.0;
gx += rgbNW * -1.0;
gx += rgbNE * 1.0;
float3 gy = rgbSW * -1.0;
gy += rgbS * -2.0;
gy += rgbSE * -1.0;
gy += rgbNW * 1.0;
gy += rgbN * 2.0;
gy += rgbNE * 1.0;
float olColor = (length(gx * gx + gy * gy) - _Outline.a) > 0.0;
rgbM = lerp(rgbM, _Outline.rgb, olColor);
#endif
#endif
#if UNITY_COLORSPACE_GAMMA
rgbM = GammaToLinearSpace(rgbM);
#endif
#if BEAUTIFY_BLOOM
rgbM += UNITY_SAMPLE_SCREENSPACE_TEXTURE(_BloomTex, i.uv).rgb * _Bloom.xxx;
#endif
#if BEAUTIFY_DIRT
float3 scrLum = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_ScreenLum, i.uv).rgb;
#if BEAUTIFY_BLOOM
scrLum *= _Dirt.www;
#endif
float4 dirt = tex2D(_OverlayTex, i.uvNonStereo);
rgbM += saturate(0.5.xxx - _Dirt.zzz + scrLum) * dirt.rgb * _Dirt.y;
#endif
#if BEAUTIFY_NIGHT_VISION
lumaM = getLuma(rgbM); // updates luma
float nvbase = saturate(normalNW.z - 0.8); // minimum ambient self radiance (useful for pitch black)
nvbase += lumaM; // adds current lighting
nvbase *= nvbase * (0.5 + nvbase); // increase contrast
rgbM = nvbase * _FXColor.rgb;
rgbM *= frac(floor(i.uv.y*_ScreenParams.y)*0.25)>0.4; // scan lines
rgbM *= 1.0 + getRandom(i.uv) * 0.3 - 0.15; // noise
#endif
#if BEAUTIFY_THERMAL_VISION
lumaM = getLuma(rgbM); // updates luma
float3 tv0 = lerp(float3(0.0,0.0,1.0), float3(1.0,1.0,0.0), lumaM * 2.0);
float3 tv1 = lerp(float3(1.0,1.0,0.0), float3(1.0,0.0,0.0), lumaM * 2.0 - 1.0);
rgbM = lerp(tv0, tv1, (float)(lumaM >= 0.5));
rgbM *= 0.2 + frac(floor(i.uv.y*_ScreenParams.y)*0.25)>0.4; // scan lines
rgbM *= 1.0 + getRandom(i.uv) * 0.2 - 0.1; // noise
#endif
#if BEAUTIFY_EYE_ADAPTATION || BEAUTIFY_PURKINJE
float4 avgLum = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_EAHist, 0.5.xx);
#endif
#if BEAUTIFY_EYE_ADAPTATION
float srcLum = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_EALumSrc, 0.5.xx).r;
float diff = srcLum / (avgLum.r + 0.0001);
#if defined(BEAUTIFY_EYE_ADAPTATION_DYNAMIC_RANGE)
float pixLum = log(1.0 + getLuma(rgbM));
diff = pow(pixLum / (avgLum.r + 0.0001), abs(diff-1.0));
#endif
diff = clamp(diff, _EyeAdaptation.x, _EyeAdaptation.y);
rgbM = rgbM * diff;
#endif
#if BEAUTIFY_TONEMAP_ACES
rgbM *= _ColorBoost.x;
rgbM = tmoFilmicACES(rgbM);
#endif
#if UNITY_COLORSPACE_GAMMA
rgbM = LinearToGammaSpace(rgbM);
#endif
#if defined(BEAUTIFY_USE_PROCEDURAL_SEPIA)
float3 sepia = float3(
dot(rgbM, float3(0.393, 0.769, 0.189)),
dot(rgbM, float3(0.349, 0.686, 0.168)),
dot(rgbM, float3(0.272, 0.534, 0.131))
);
rgbM = lerp(rgbM, sepia, _FXColor.a);
#elif BEAUTIFY_LUT
#if !UNITY_COLORSPACE_GAMMA
rgbM = LinearToGammaSpace(rgbM);
#endif
const float3 lutST = float3(1.0/1024, 1.0/32, 32-1);
float3 lookUp = saturate(rgbM) * lutST.zzz;
lookUp.xy = lutST.xy * (lookUp.xy + 0.5);
float slice = floor(lookUp.z);
lookUp.x += slice * lutST.y;
float2 lookUpNextSlice = float2(lookUp.x + lutST.y, lookUp.y);
float3 lut = lerp(tex2D(_LUTTex, lookUp.xy).rgb, tex2D(_LUTTex, lookUpNextSlice).rgb, lookUp.z - slice);
rgbM = lerp(rgbM, lut, _FXColor.a);
#if !UNITY_COLORSPACE_GAMMA
rgbM = GammaToLinearSpace(rgbM);
#endif
#endif
#if defined(BEAUTIFY_ENABLE_COLOR_TWEAKS)
float maxComponent = max(rgbM.r, max(rgbM.g, rgbM.b));
float minComponent = min(rgbM.r, min(rgbM.g, rgbM.b));
float sat = saturate(maxComponent - minComponent);
rgbM *= 1.0 + _ColorBoost.z * (1.0 - sat) * (rgbM - getLuma(rgbM));
rgbM = lerp(rgbM, rgbM * _TintColor.rgb, _TintColor.a);
rgbM = (rgbM - 0.5.xxx) * _ColorBoost.y + 0.5.xxx;
#if !BEAUTIFY_TONEMAP_ACES
rgbM *= _ColorBoost.x;
#endif
#endif
#if BEAUTIFY_PURKINJE
lumaM = getLuma(rgbM);
float3 shifted = saturate(float3(lumaM / (1.0 + _Purkinje.x * 1.14), lumaM, lumaM * (1.0 + _Purkinje.x * 2.99)));
rgbM = lerp(shifted, rgbM, saturate(exp(avgLum.g) - _Purkinje.y));
#endif
#if BEAUTIFY_VIGNETTING
float2 vd = float2(i.uvNonStereo.x - 0.5, (i.uvNonStereo.y - 0.5) * _VignettingAspectRatio);
rgbM = lerp(rgbM, lumaM * _Vignetting.rgb, saturate(_Purkinje.z + _Vignetting.a * dot(vd, vd)));
#elif BEAUTIFY_VIGNETTING_MASK
float2 vd = float2(i.uvNonStereo.x - 0.5, (i.uvNonStereo.y - 0.5) * _VignettingAspectRatio);
float vmask = tex2D(_VignettingMask, i.uvNonStereo).a;
rgbM = lerp(rgbM, lumaM * _Vignetting.rgb, saturate(_Purkinje.z + vmask * _Vignetting.a * dot(vd, vd)));
#endif
#if BEAUTIFY_FRAME
rgbM = lerp(rgbM, _Frame.rgb, saturate( (max(abs(i.uvNonStereo.x - 0.5), abs(i.uvNonStereo.y - 0.5)) - _Frame.a) * 50.0));
#elif BEAUTIFY_FRAME_MASK
float4 frameMask = tex2D(_FrameMask, i.uvNonStereo);
float3 frameColor = lerp(_Frame.rgb, frameMask.rgb * _Frame.rgb, frameMask.a);
rgbM = lerp(rgbM, frameColor, saturate( (max(abs(i.uvNonStereo.x - 0.5), abs(i.uvNonStereo.y - 0.5)) - _Frame.a) * 50.0));
#endif
#if !BEAUTIFY_NIGHT_VISION && !BEAUTIFY_THERMAL_VISION && defined(BEAUTIFY_DITHER_FINAL) && defined(BEAUTIFY_ENABLE_DITHER)
float3 dither = dot(float2(171.0, 231.0), i.uv * _ScreenParams.xy).xxx;
dither = frac(dither / float3(103.0, 71.0, 97.0)) - 0.5.xxx;
rgbM *= 1.0 + step(_Dither.y, depthW) * _Dither.x * dither;
#endif
}
float4 fragBeautify (v2f i) : SV_Target {
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
#if BEAUTIFY_THERMAL_VISION
i.uv.x += 0.0009 * sin(_Time.z + i.uv.y * 20.0) / (1.0 + 10.0 * dot(i.uv - 0.5.xx, i.uv.xy - 0.5.xx)); // wave animation
#endif
float4 pixel = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv);
beautifyPass(i, pixel.rgb);
return pixel;
}
float4 fragCompare (v2fCompare i) : SV_Target {
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
// separator line + antialias
float2 dd = i.uvNonStereo - 0.5.xx;
float co = dot(_CompareParams.xy, dd);
float dist = distance( _CompareParams.xy * co, dd );
float4 aa = saturate( (_CompareParams.w - dist) / abs(_MainTex_TexelSize.y) );
float4 pixel = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv);
float4 pixelNice = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_CompareTex, i.uv);
// are we on the beautified side?
float t = dot(dd, _CompareParams.yz) > 0;
pixel = lerp(pixel, pixelNice, t);
return pixel + aa;
}
-9
View File
@@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: 83c7f2de0e89d4c59ba8b1bf830d8504
timeCreated: 1463645543
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
-417
View File
@@ -1,417 +0,0 @@
Shader "Beautify/Beautify" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_OverlayTex ("Overlay (RGB)", 2D) = "black" {}
//_DoFTex("DoF (RGBA)", 2D) = "black" {}
_DoFTex("DoF (RGBA)", any) = "black" {}
_Sharpen ("Sharpen Data", Vector) = (2.5, 0.035, 0.5)
_SharpenDepthFallOff("Sharpen Depth FallOff", Float) = 0
_ColorBoost ("Color Boost Data", Vector) = (1.1, 1.1, 0.08, 0)
_Dither ("Dither Data", Vector) = (5, 0, 0, 1.0)
_FXColor ("FXColor Color", Color) = (1,1,1,0)
_TintColor ("Tint Color Color", Color) = (1,1,1,0)
_Vignetting ("Vignetting", Color) = (0.3,0.3,0.3,0.05)
_VignettingAspectRatio ("Vignetting Aspect Ratio", Float) = 1.0
_VignettingMask ("Mask Texture (A)", 2D) = "white" {}
_Frame("Frame Data", Vector) = (50,50,50,0)
_FrameMask ("Mask Texture (A)", 2D) = "white" {}
_Outline("Outline", Color) = (0,0,0,0.8)
_Dirt("Dirt Data", Vector) = (0.5,0.5,0.5,0.5)
_Bloom("Bloom Data", Vector) = (0.5,0,0)
_BloomTex("BloomTex (RGBA)", any) = "black" {}
//_BloomTex("BloomTex (RGBA)", 2D) = "black" {}
_BloomWeights("Bloom Weights", Vector) = (0.35,0.55,0.7,0.8)
_BloomWeights2("Bloom Weights 2", Vector) = (0.35,0.55,0.7,0.8)
_ScreenLum("Luminance Tex (RGBA)", any) = "black" {}
//_ScreenLum("Luminance Tex (RGBA)", 2D) = "black" {}
_CompareParams("Compare Params", Vector) = (0.785398175, 0.001, 0, 0)
_AFTint ("Anamorphic Flares Tint", Color) = (1,1,1,0.5)
_BokehData("Bokeh Data", Vector) = (10,1,0,1)
_DepthTexture("Depth (RGBA)", 2D) = "black" {}
_DofExclusionTexture("DoF Exclusion (R)", 2D) = "white" {}
_BokehData2("Bokeh Data 2", Vector) = (1000.0, 4, 0, 0)
_BokehData3("Bokeh Data 3", Vector) = (1000.0, 100000.0, 0)
_EyeAdaptation("Eye Adaptation Data", Vector) = (0.1, 2, 0.7, 1)
_Purkinje ("Purkinje Data", Vector) = (1.0, 0.15, 0)
_BloomDepthTreshold("Bloom Depth Threshold", Float) = 1.0
_FlareTex("Sun Flare texture", 2D) = "black" {}
_SunPos("SF Screen Position", Vector) = (0.5, 0.5, 0, 0)
_SunPosRightEye("SF Screen Position Right Eye", Vector) = (0.5, 0.5, 0, 0)
_SunData("SunFlares Sun Data", Vector) = (0.1, 0.05, 3.5, 0.13)
_SunCoronaRays1("SunFlares Corona Rays 1 Data", Vector) = (0.02, 12, 0.001, 0)
_SunCoronaRays2("SunFlares Corona Rays 2 Data", Vector) = (0.05, 12, 0.1, 0)
_SunGhosts1("SunFlares Ghosts 1 Data", Vector) = (0, 0.03, 0.6, 0.06)
_SunGhosts2("SunFlares Ghosts 2 Data", Vector) = (0, 0.1, 0.2, 0.03)
_SunGhosts3("SunFlares Ghosts 3 Data", Vector) = (0, 0.25, 0.4, 0.025)
_SunGhosts4("SunFlares Ghosts 4 Data", Vector) = (0, 0.5, 0.3, 0.04)
_SunTint("Sun Flare Tint Color", Color) = (1,1,1)
_SunHalo("SunFlares Halo Data", Vector) = (0.22, 15.1415, 1.0)
_CompareTex ("Compare Image (RGB)", any) = "black" {}
// _CompareTex ("Compare Image (RGB)", 2D) = "black" {}
_BlurScale ("Blur Scale", Float) = 1.0
_LUTTex ("Lut Texture (RGB)", 2D) = "white" {}
_AntialiasData("Antialias Data", Vector) = (5, 0.001, 0)
}
Subshader {
Pass { // 0
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vertCompare
#pragma fragment fragCompare
#pragma target 3.0
#include "Beautify.cginc"
ENDCG
}
Pass { // 1
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vert
#pragma fragment fragBeautify
#pragma target 3.0
// Edited by Shader Control: #pragma multi_compile __ BEAUTIFY_DALTONIZE BEAUTIFY_LUT BEAUTIFY_NIGHT_VISION BEAUTIFY_THERMAL_VISION
#pragma multi_compile __ BEAUTIFY_LUT
// Edited by Shader Control: #pragma multi_compile __ BEAUTIFY_DEPTH_OF_FIELD BEAUTIFY_DEPTH_OF_FIELD_TRANSPARENT
#pragma multi_compile __ BEAUTIFY_DEPTH_OF_FIELD
// Disabled by Shader Control: #pragma multi_compile __ BEAUTIFY_OUTLINE
// Disabled by Shader Control: #pragma multi_compile __ BEAUTIFY_DIRT
#pragma multi_compile __ BEAUTIFY_BLOOM
#pragma multi_compile __ BEAUTIFY_EYE_ADAPTATION
#pragma multi_compile __ BEAUTIFY_TONEMAP_ACES
// Disabled by Shader Control: #pragma multi_compile __ BEAUTIFY_PURKINJE
// Edited by Shader Control: #pragma multi_compile __ BEAUTIFY_VIGNETTING BEAUTIFY_VIGNETTING_MASK
#pragma multi_compile __ BEAUTIFY_VIGNETTING
// Disabled by Shader Control: #pragma multi_compile __ BEAUTIFY_FRAME BEAUTIFY_FRAME_MASK
#pragma multi_compile __ UNITY_COLORSPACE_GAMMA
#include "Beautify.cginc"
ENDCG
}
Pass { // 2
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vertLum
#pragma fragment fragLum
#pragma fragmentoption ARB_precision_hint_fastest
#pragma multi_compile __ BEAUTIFY_BLOOM_USE_DEPTH
#pragma multi_compile __ BEAUTIFY_BLOOM_USE_LAYER
#pragma multi_compile __ UNITY_COLORSPACE_GAMMA
#include "BeautifyLum.cginc"
ENDCG
}
Pass { // 3
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vert
#pragma fragment fragDebugBloom
#pragma fragmentoption ARB_precision_hint_fastest
#include "BeautifyLum.cginc"
ENDCG
}
Pass { // 4
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vertBlurH
#pragma fragment fragBlur
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
#include "BeautifyLum.cginc"
ENDCG
}
Pass { // 5
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vertBlurV
#pragma fragment fragBlur
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
#include "BeautifyLum.cginc"
ENDCG
}
Pass { // 6
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vert
#pragma fragment fragBloomCompose
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
#include "BeautifyLum.cginc"
ENDCG
}
Pass { // 7
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vertCross
#pragma fragment fragResample
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
#include "BeautifyLum.cginc"
ENDCG
}
Pass { // 8
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
Blend One One
CGPROGRAM
#pragma vertex vertCross
#pragma fragment fragResample
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
#include "BeautifyLum.cginc"
ENDCG
}
Pass { // 9
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vertCrossLum
#pragma fragment fragLumAntiflicker
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
#pragma multi_compile __ BEAUTIFY_BLOOM_USE_DEPTH
#pragma multi_compile __ BEAUTIFY_BLOOM_USE_LAYER
#pragma multi_compile __ UNITY_COLORSPACE_GAMMA
#include "BeautifyLum.cginc"
ENDCG
}
Pass { // 10
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
Blend One One
CGPROGRAM
#pragma vertex vertCross
#pragma fragment fragResampleAF
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
#include "BeautifyLum.cginc"
ENDCG
}
Pass { // 11
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
Blend One One
CGPROGRAM
#pragma vertex vert
#pragma fragment fragCopy
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
#include "BeautifyLum.cginc"
ENDCG
}
Pass { // 12 DoF CoC
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vert
#pragma fragment fragCoC
#pragma target 3.0
#pragma fragmentoption ARB_precision_hint_fastest
// Disabled by Shader Control: #pragma multi_compile __ BEAUTIFY_DEPTH_OF_FIELD_TRANSPARENT
#pragma multi_compile __ UNITY_COLORSPACE_GAMMA
#include "BeautifyDoF.cginc"
ENDCG
}
Pass { // 13 DoF CoC Debug
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vert
#pragma fragment fragCoCDebug
#pragma target 3.0
#pragma fragmentoption ARB_precision_hint_fastest
// Disabled by Shader Control: #pragma multi_compile __ BEAUTIFY_DEPTH_OF_FIELD_TRANSPARENT
#include "BeautifyDoF.cginc"
ENDCG
}
Pass { // 14 DoF Blur
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vert
#pragma fragment fragBlur
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
#include "BeautifyDoF.cginc"
ENDCG
}
Pass { // 15 Compute Screen Lum
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vert
#pragma fragment fragScreenLum
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
#pragma multi_compile __ UNITY_COLORSPACE_GAMMA
#include "BeautifyEA.cginc"
ENDCG
}
Pass { // 16 Reduce Screen Lum
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vertCross
#pragma fragment fragReduceScreenLum
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
#include "BeautifyEA.cginc"
ENDCG
}
Pass { // 17 Blend Screen Lum
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma vertex vert
#pragma fragment fragBlendScreenLum
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
#include "BeautifyEA.cginc"
ENDCG
}
Pass { // 18 Simple Blend
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
// Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma vertex vert
#pragma fragment fragBlend
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
#include "BeautifyEA.cginc"
ENDCG
}
Pass { // 19 DoF Blur wo/Bokeh
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vert
#pragma fragment fragBlurNoBokeh
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
#include "BeautifyDoF.cginc"
ENDCG
}
Pass { // 20 Sun Flares
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vert
#pragma fragment fragSF
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
#include "BeautifySF.cginc"
ENDCG
}
Pass { // 21 Sun Flares Additive
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vert
#pragma fragment fragSFAdditive
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
#include "BeautifySF.cginc"
ENDCG
}
Pass { // 22 Raw copy used in single blits with Single Pass Instanced
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vert
#pragma fragment fragCopy
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
#include "BeautifyLum.cginc"
ENDCG
}
Pass { // 23 DoF Blur CoC
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vertBlurH
#pragma fragment fragBlurCoC
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
#include "BeautifyDoF.cginc"
ENDCG
}
Pass { // 24 DoF Blur CoC
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vertBlurV
#pragma fragment fragBlurCoC
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
#include "BeautifyDoF.cginc"
ENDCG
}
}
FallBack Off
}
-9
View File
@@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: 1cb716be5dc9d4230ada327d9468ff41
timeCreated: 1462519614
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
-49
View File
@@ -1,49 +0,0 @@
//=================================================================================================
//
// ACES Fitted, an alternate ACES tonemap operator by MJP and David Neubelt
// http://mynameismjp.wordpress.com/
//
// Licensed under the MIT license
//
//=================================================================================================
// The code in this file was originally written by Stephen Hill (@self_shadow), who deserves all
// credit for coming up with this fit and implementing it. Buy him a beer next time you see him. :)
// sRGB => XYZ => D65_2_D60 => AP1 => RRT_SAT
static const float3x3 ACESInputMat =
{
{0.59719, 0.35458, 0.04823},
{0.07600, 0.90834, 0.01566},
{0.02840, 0.13383, 0.83777}
};
// ODT_SAT => XYZ => D60_2_D65 => sRGB
static const float3x3 ACESOutputMat =
{
{ 1.60475, -0.53108, -0.07367},
{-0.10208, 1.10813, -0.00605},
{-0.00327, -0.07276, 1.07602}
};
float3 RRTAndODTFit(float3 v)
{
float3 a = v * (v + 0.0245786f) - 0.000090537f;
float3 b = v * (0.983729f * v + 0.4329510f) + 0.238081f;
return a / b;
}
float3 ACESFitted(float3 color)
{
color = mul(ACESInputMat, color);
// Apply RRT and ODT
color = RRTAndODTFit(color);
color = mul(ACESOutputMat, color);
// Clamp to [0, 1]
color = saturate(color);
return color;
}
@@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: 6f4f77b7f9ffd4486910b55411e3e072
timeCreated: 1488661131
licenseType: Free
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -1,42 +0,0 @@
// Advanced customization parameters
// To prevent overusing multi_compile keywords, these options are exposed here as they're one-time toggles (meaning you won't be toggling them at runtime)
// Note that changes to this file will be lost when you update Beautify! Remember to revert this file to your preferences after updating.
// Uncomment this one to support Orthographic Camera
//#define BEAUTIFY_ORTHO
// Comment out this one to disable sharpen
#define BEAUTIFY_ENABLE_CORE_EFFECT
// Comment out this one to apply sharpen regardless of depth
#define BEAUTIFY_DEPTH_BASED_SHARPEN
// Comment out this one to disable brightness, contrast and vibrance effects
#define BEAUTIFY_ENABLE_COLOR_TWEAKS
// Comment out this one to disable dithering. Can improve performance on old mobile devices.
#define BEAUTIFY_ENABLE_DITHER
// Dither is applied at the end of stack. Comment out this line to apply dither at the start.
#define BEAUTIFY_DITHER_FINAL
// Comment out this line to simplify eye adaptation to brightness increase/reduction (old method)
#define BEAUTIFY_EYE_ADAPTATION_DYNAMIC_RANGE
// Uncomment this to enable occlusion on objects that do not have colliders
#define BEAUTIFY_SUN_FLARES_OCCLUSION_DEPTH
// Uncomment this line to use an alternate ACES tonemap operator
//#define BEAUTIFY_ACES_FITTED
// Uncomment this line to use a color-based edge detection algorithm instead of a depth based method. Useful for 2D projects.
//#define BEAUTIFY_OUTLINE_SOBEL
// Uncomment this line to use a formula instead of Look-Up texture to produce Sepia effect
//#define BEAUTIFY_USE_PROCEDURAL_SEPIA
// Uncomment this line to improve LUT transform in Best Performance mode
//#define BEAUTIFY_BETTER_FASTER_LUT
// Uncomment this line to enable AntiAliasing
#define BEAUTIFY_EDGE_AA
@@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: 187d6b6c578eb41029a2bf2d15920773
timeCreated: 1488661131
licenseType: Free
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
-118
View File
@@ -1,118 +0,0 @@
// Copyright 2016-2019 Kronnect - All Rights Reserved.
#include "UnityCG.cginc"
UNITY_DECLARE_SCREENSPACE_TEXTURE(_MainTex);
UNITY_DECLARE_SCREENSPACE_TEXTURE(_CompareTex);
uniform float4 _MainTex_TexelSize;
uniform float4 _MainTex_ST;
uniform fixed4 _ColorBoost; // x = Brightness, y = Contrast, z = Saturate, w = Daltonize;
uniform fixed4 _Sharpen;
uniform float4 _CompareParams;
struct appdata {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f {
float4 pos : SV_POSITION;
float2 uv: TEXCOORD0;
float2 uvN: TEXCOORD1;
float2 uvS: TEXCOORD2;
float2 uvW: TEXCOORD3;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
struct v2fCompare {
float4 pos : SV_POSITION;
float2 uv: TEXCOORD0;
float2 uvNonStereo: TEXCOORD1;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
v2fCompare vertCompare(appdata v) {
v2fCompare o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = UnityStereoScreenSpaceUVAdjust(v.texcoord, _MainTex_ST);
o.uvNonStereo = v.texcoord;
return o;
}
v2f vert(appdata v) {
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = UnityStereoScreenSpaceUVAdjust(v.texcoord, _MainTex_ST);
float3 uvInc = float3(_MainTex_TexelSize.x, _MainTex_TexelSize.y, 0);
o.uvN = o.uv + uvInc.zy;
o.uvS = o.uv - uvInc.zy;
o.uvW = o.uv - uvInc.xz;
return o;
}
inline fixed getLuma(fixed3 rgb) {
const fixed3 lum = fixed3(0.299, 0.587, 0.114);
return dot(rgb, lum);
}
void beautifyPassFast(v2f i, inout fixed3 rgbM) {
fixed3 rgbN = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uvN).rgb;
fixed3 rgbS = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uvS).rgb;
fixed3 rgbW = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uvW).rgb;
fixed lumaM = getLuma(rgbM);
fixed lumaN = getLuma(rgbN);
fixed lumaW = getLuma(rgbW);
fixed lumaS = getLuma(rgbS);
fixed maxLuma = max(lumaN,lumaS);
maxLuma = max(maxLuma, lumaW);
fixed minLuma = min(lumaN,lumaS);
minLuma = min(minLuma, lumaW) - 0.000001;
fixed lumaPower = 2 * lumaM - minLuma - maxLuma;
fixed lumaAtten = saturate(_Sharpen.w / (maxLuma - minLuma));
rgbM *= 1.0 + clamp(lumaPower * lumaAtten * _Sharpen.x, -_Sharpen.z, _Sharpen.z);
fixed3 maxComponent = max(rgbM.r, max(rgbM.g, rgbM.b));
fixed3 minComponent = min(rgbM.r, min(rgbM.g, rgbM.b));
fixed sat = saturate(maxComponent - minComponent);
rgbM *= 1.0 + _ColorBoost.z * (1.0 - sat) * (rgbM - getLuma(rgbM));
rgbM = (rgbM - 0.5.xxx) * _ColorBoost.y + 0.5.xxx;
rgbM *= _ColorBoost.x;
}
fixed4 fragBeautifyFast (v2f i) : SV_Target {
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
fixed4 pixel = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv);
beautifyPassFast(i, pixel.rgb);
return pixel;
}
fixed4 fragCompareFast (v2fCompare i) : SV_Target {
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
// separator line + antialias
float2 dd = i.uvNonStereo - 0.5.xx;
float co = dot(_CompareParams.xy, dd);
float dist = distance( _CompareParams.xy * co, dd );
float4 aa = saturate( (_CompareParams.w - dist) / abs(_MainTex_TexelSize.y) );
fixed4 pixel = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv);
fixed4 pixelNice = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_CompareTex, i.uv);
// are we on the beautified side?
fixed t = dot(dd, _CompareParams.yz) > 0;
pixel = lerp(pixel, pixelNice, t);
return pixel + aa;
}
-9
View File
@@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: 0bc032bf4e7db40538b1f62e5ed2f7a4
timeCreated: 1488292291
licenseType: Free
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
-38
View File
@@ -1,38 +0,0 @@
Shader "Beautify/BeautifyBasic" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_Sharpen ("Sharpen Data", Vector) = (2.5, 0.035, 0.5)
_ColorBoost ("Color Boost Data", Vector) = (1.1, 1.1, 0.08, 0)
_CompareTex ("Compare Image (RGB)", 2D) = "black" {}
}
Subshader {
Pass { // 0
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vertCompare
#pragma fragment fragCompareFast
#pragma fragmentoption ARB_precision_hint_fastest
#include "BeautifyBasic.cginc"
ENDCG
}
Pass { // 1
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vert
#pragma fragment fragBeautifyFast
#pragma fragmentoption ARB_precision_hint_fastest
#pragma multi_compile __ UNITY_COLORSPACE_GAMMA
#include "BeautifyBasic.cginc"
ENDCG
}
}
FallBack Off
}
@@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: 3f400c48e7682407493d7fa6766cf631
timeCreated: 1465126706
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
-292
View File
@@ -1,292 +0,0 @@
// Copyright 2016-2019 Kronnect - All Rights Reserved.
#include "UnityCG.cginc"
#include "BeautifyAdvancedParams.cginc"
#include "BeautifyOrtho.cginc"
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
uniform sampler2D _DepthTexture;
uniform sampler2D _DofExclusionTexture;
UNITY_DECLARE_SCREENSPACE_TEXTURE(_MainTex);
uniform float4 _MainTex_TexelSize;
uniform float4 _MainTex_ST;
uniform float4 _BokehData;
uniform float4 _BokehData2;
uniform float3 _BokehData3;
uniform float _BlurScale;
struct appdata {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f {
float4 pos : SV_POSITION;
float2 uv: TEXCOORD0;
float2 depthUV : TEXCOORD1;
float2 uvNonStereo: TEXCOORD2;
float2 uvNonStereoInv: TEXCOORD3;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
struct v2fCross {
float4 pos : SV_POSITION;
float2 uv: TEXCOORD0;
float2 uv1: TEXCOORD1;
float2 uv2: TEXCOORD2;
float2 uv3: TEXCOORD3;
float2 uv4: TEXCOORD4;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert(appdata v) {
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = UnityObjectToClipPos(v.vertex);
o.uvNonStereo = v.texcoord;
o.uvNonStereoInv = v.texcoord;
o.uv = UnityStereoScreenSpaceUVAdjust(v.texcoord, _MainTex_ST);
o.depthUV = o.uv;
#if UNITY_UV_STARTS_AT_TOP
if (_MainTex_TexelSize.y < 0) {
o.uv.y = 1.0 - o.uv.y;
o.uvNonStereoInv.y = 1.0 - o.uvNonStereoInv.y;
}
#endif
return o;
}
float getCoc(v2f i) {
#if BEAUTIFY_DEPTH_OF_FIELD_TRANSPARENT
float depthTex = DecodeFloatRGBA(tex2Dlod(_DepthTexture, float4(i.uvNonStereo, 0, 0)));
float exclusionDepth = DecodeFloatRGBA(tex2Dlod(_DofExclusionTexture, float4(i.uvNonStereo, 0, 0)));
//float depth = BEAUTIFY_GET_DEPTH_01(UNITY_SAMPLE_DEPTH(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_CameraDepthTexture, i.depthUV)));
float depth = Linear01Depth(BEAUTIFY_DEPTH(_CameraDepthTexture, i.depthUV));
depth = min(depth, depthTex);
if (exclusionDepth < depth) return 0;
depth *= _ProjectionParams.z;
#else
//float depth = BEAUTIFY_GET_DEPTH_EYE(UNITY_SAMPLE_DEPTH(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_CameraDepthTexture, i.depthUV)));
float depth = LinearEyeDepth(BEAUTIFY_DEPTH(_CameraDepthTexture, i.depthUV));
#endif
if (depth>_BokehData3.y) return 0;
float xd = abs(depth - _BokehData.x) - _BokehData2.x * (depth < _BokehData.x);
return 0.5 * _BokehData.y * xd/depth; // radius of CoC
}
float4 fragCoC (v2f i) : SV_Target {
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
float4 pixel = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv);
pixel = clamp(pixel, 0.0.xxxx, _BokehData3.xxxx);
#if UNITY_COLORSPACE_GAMMA
pixel.rgb = GammaToLinearSpace(pixel.rgb);
#endif
return float4(pixel.rgb, getCoc(i));
}
float4 fragCoCDebug (v2f i) : SV_Target {
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
float4 pixel = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv);
pixel = clamp(pixel, 0.0.xxxx, _BokehData3.xxxx);
float CoC = getCoc(i);
pixel.a = min(CoC, pixel.a);
return pixel.aaaa;
}
float4 fragBlur (v2f i): SV_Target {
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
float4 sum = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv );
float samples = ceil(sum.a);
float4 dir = float4(_BokehData.zw * _MainTex_TexelSize.xy, 0, 0);
#if UNITY_SINGLE_PASS_STEREO
dir.x *= 2.0;
#endif
dir *= max(1.0, samples / _BokehData2.y);
float jitter = dot(float2(2.4084507, 3.2535211), i.uv * _MainTex_TexelSize.zw);
float2 disp0 = dir.xy * (frac(jitter) + 0.5);
float4 disp1 = float4(i.uvNonStereoInv + disp0, 0, 0);
float4 disp2 = float4(i.uvNonStereoInv - disp0, 0, 0);
float w = 1.0;
const int sampleCount = (int)min(_BokehData2.y, samples);
UNITY_UNROLL
for (int k=1;k<16;k++) {
if (k<sampleCount) {
#if UNITY_SINGLE_PASS_STEREO
disp1.xy = saturate(disp1.xy);
float4 pixel1 = SAMPLE_RAW_DEPTH_TEXTURE_LOD(_MainTex, float4(UnityStereoScreenSpaceUVAdjust(disp1.xy, _MainTex_ST), 0, 0)); // was tex2Dlod
#else
float4 pixel1 = SAMPLE_RAW_DEPTH_TEXTURE_LOD(_MainTex, disp1);
#endif
// float bt1 = pixel1.a > k;
float bt1 = saturate(pixel1.a - k);
pixel1.rgb += _BokehData2.www * max(pixel1.rgb - _BokehData2.zzz, 0.0.xxx);
sum += pixel1 * bt1;
w += bt1;
disp1 += dir;
#if UNITY_SINGLE_PASS_STEREO
disp2.xy = saturate(disp2.xy);
float4 pixel2 = SAMPLE_RAW_DEPTH_TEXTURE_LOD(_MainTex, float4(UnityStereoScreenSpaceUVAdjust(disp2.xy, _MainTex_ST), 0, 0));
#else
float4 pixel2 = SAMPLE_RAW_DEPTH_TEXTURE_LOD(_MainTex, disp2);
#endif
// float bt2 = pixel2.a > k;
float bt2 = saturate(pixel2.a - k);
pixel2.rgb += _BokehData2.www * max(pixel2.rgb - _BokehData2.zzz, 0.0.xxx);
sum += pixel2 * bt2;
w += bt2;
disp2 -= dir;
}
}
return sum / w;
}
float4 fragBlurNoBokeh (v2f i): SV_Target {
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
float4 sum = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv );
float samples = ceil(sum.a);
float4 dir = float4(_BokehData.zw * _MainTex_TexelSize.xy, 0, 0);
#if UNITY_SINGLE_PASS_STEREO
dir.x *= 0.5;
#endif
dir *= max(1.0, samples / _BokehData2.y);
float jitter = dot(float2(2.4084507, 3.2535211), i.uv * _MainTex_TexelSize.zw);
float2 disp0 = dir.xy * (frac(jitter) + 0.5);
float4 disp1 = float4(i.uvNonStereoInv + disp0, 0, 0);
float4 disp2 = float4(i.uvNonStereoInv - disp0, 0, 0);
float w = 1.0;
const int sampleCount = (int)min(_BokehData2.y, samples);
UNITY_UNROLL
for (int k=1;k<16;k++) {
if (k<sampleCount) {
#if UNITY_SINGLE_PASS_STEREO
float4 pixel1 = SAMPLE_RAW_DEPTH_TEXTURE_LOD(_MainTex, float4(UnityStereoScreenSpaceUVAdjust(disp1.xy, _MainTex_ST), 0, 0));
#else
float4 pixel1 = SAMPLE_RAW_DEPTH_TEXTURE_LOD(_MainTex, disp1);
#endif
// float bt1 = pixel1.a > k;
float bt1 = saturate(pixel1.a - k);
sum += bt1 * pixel1;
w += bt1;
disp1 += dir;
#if UNITY_SINGLE_PASS_STEREO
float4 pixel2 = SAMPLE_RAW_DEPTH_TEXTURE_LOD(_MainTex, float4(UnityStereoScreenSpaceUVAdjust(disp2.xy, _MainTex_ST), 0, 0));
#else
float4 pixel2 = SAMPLE_RAW_DEPTH_TEXTURE_LOD(_MainTex, disp2);
#endif
// float bt2 = pixel2.a > k;
float bt2 = saturate(pixel2.a - k);
sum += bt2 * pixel2;
w += bt2;
disp2 -= dir;
}
}
return sum / w;
}
v2fCross vertBlurH(appdata v) {
v2fCross o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = UnityStereoScreenSpaceUVAdjust(v.texcoord, _MainTex_ST);
#if UNITY_UV_STARTS_AT_TOP
if (_MainTex_TexelSize.y < 0) {
o.uv.y = 1.0 - o.uv.y;
}
#endif
float2 inc = float2(_MainTex_TexelSize.x * 1.3846153846 * _BlurScale, 0);
#if UNITY_SINGLE_PASS_STEREO
inc.x *= 2.0;
#endif
o.uv1 = UnityStereoScreenSpaceUVAdjust(v.texcoord - inc, _MainTex_ST);
o.uv2 = UnityStereoScreenSpaceUVAdjust(v.texcoord + inc, _MainTex_ST);
float2 inc2 = float2(_MainTex_TexelSize.x * 3.2307692308 * _BlurScale, 0);
#if UNITY_SINGLE_PASS_STEREO
inc2.x *= 2.0;
#endif
o.uv3 = UnityStereoScreenSpaceUVAdjust(v.texcoord - inc2, _MainTex_ST);
o.uv4 = UnityStereoScreenSpaceUVAdjust(v.texcoord + inc2, _MainTex_ST);
return o;
}
v2fCross vertBlurV(appdata v) {
v2fCross o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = UnityStereoScreenSpaceUVAdjust(v.texcoord, _MainTex_ST);
#if UNITY_UV_STARTS_AT_TOP
if (_MainTex_TexelSize.y < 0) {
o.uv.y = 1.0 - o.uv.y;
}
#endif
float2 inc = float2(0, _MainTex_TexelSize.y * 1.3846153846 * _BlurScale);
o.uv1 = UnityStereoScreenSpaceUVAdjust(v.texcoord - inc, _MainTex_ST);
o.uv2 = UnityStereoScreenSpaceUVAdjust(v.texcoord + inc, _MainTex_ST);
float2 inc2 = float2(0, _MainTex_TexelSize.y * 3.2307692308 * _BlurScale);
o.uv3 = UnityStereoScreenSpaceUVAdjust(v.texcoord - inc2, _MainTex_ST);
o.uv4 = UnityStereoScreenSpaceUVAdjust(v.texcoord + inc2, _MainTex_ST);
return o;
}
float4 fragBlurCoC (v2fCross i): SV_Target {
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
//float depth = LinearEyeDepth(UNITY_SAMPLE_DEPTH(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_CameraDepthTexture, i.uv)));
//float depth1 = LinearEyeDepth(UNITY_SAMPLE_DEPTH(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_CameraDepthTexture, i.uv1)));
//float depth2 = LinearEyeDepth(UNITY_SAMPLE_DEPTH(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_CameraDepthTexture, i.uv2)));
//float depth3 = LinearEyeDepth(UNITY_SAMPLE_DEPTH(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_CameraDepthTexture, i.uv3)));
//float depth4 = LinearEyeDepth(UNITY_SAMPLE_DEPTH(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_CameraDepthTexture, i.uv4)));
float depth = LinearEyeDepth(BEAUTIFY_DEPTH(_CameraDepthTexture, i.uv));
float depth1 = LinearEyeDepth(BEAUTIFY_DEPTH(_CameraDepthTexture, i.uv1));
float depth2 = LinearEyeDepth(BEAUTIFY_DEPTH(_CameraDepthTexture, i.uv2));
float depth3 = LinearEyeDepth(BEAUTIFY_DEPTH(_CameraDepthTexture, i.uv3));
float depth4 = LinearEyeDepth(BEAUTIFY_DEPTH(_CameraDepthTexture, i.uv4));
const float f = 10;
float w1 = saturate((depth - depth1)/f) * 0.3162162162;
float w2 = saturate((depth - depth2)/f) * 0.3162162162;
float w3 = saturate((depth - depth3)/f) * 0.0702702703;
float w4 = saturate((depth - depth4)/f) * 0.0702702703;
float coc1 = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv1).a;
float coc2 = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv2).a;
float coc3 = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv3).a;
float coc4 = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv4).a;
float w0 = 0.2270270270;
half4 pixel = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv);
float coc = (pixel.a * w0 + coc1 * w1 + coc2 * w2 + coc3 * w3 + coc4 * w4) / (w0 + w1 + w2 + w3 + w4);
pixel.a = coc;
return pixel;
}
-9
View File
@@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: 7e05eb685611f4798a1257f353e5f366
timeCreated: 1476036848
licenseType: Free
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
-104
View File
@@ -1,104 +0,0 @@
#include "UnityCG.cginc"
UNITY_DECLARE_SCREENSPACE_TEXTURE(_MainTex);
UNITY_DECLARE_SCREENSPACE_TEXTURE(_EALumSrc);
UNITY_DECLARE_SCREENSPACE_TEXTURE(_EAHist);
uniform half4 _MainTex_TexelSize;
uniform half4 _MainTex_ST;
uniform half4 _EyeAdaptation;
struct appdata {
float4 vertex : POSITION;
half2 texcoord : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f {
float4 pos : SV_POSITION;
half2 uv: TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
struct v2fCross {
float4 pos : SV_POSITION;
half2 uv1: TEXCOORD0;
half2 uv2: TEXCOORD1;
half2 uv3: TEXCOORD2;
half2 uv4: TEXCOORD3;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert(appdata v) {
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = UnityStereoScreenSpaceUVAdjust(v.texcoord, _MainTex_ST);
return o;
}
v2fCross vertCross(appdata v) {
v2fCross o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = UnityObjectToClipPos(v.vertex);
half3 offsets = _MainTex_TexelSize.xyy * half3(0.5, 0.5, 0);
#if UNITY_SINGLE_PASS_STEREO
offsets.xz *= 2.0;
#endif
o.uv1 = UnityStereoScreenSpaceUVAdjust(v.texcoord - offsets.xz, _MainTex_ST);
o.uv2 = UnityStereoScreenSpaceUVAdjust(v.texcoord - offsets.zy, _MainTex_ST);
o.uv3 = UnityStereoScreenSpaceUVAdjust(v.texcoord + offsets.xz, _MainTex_ST);
o.uv4 = UnityStereoScreenSpaceUVAdjust(v.texcoord + offsets.zy, _MainTex_ST);
return o;
}
inline half getLuma(half3 rgb) {
const half3 lum = half3(0.299, 0.587, 0.114);
return dot(rgb, lum);
}
half4 fragScreenLum (v2f i) : SV_Target {
UNITY_SETUP_INSTANCE_ID(i);
half4 c = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv);
#if UNITY_COLORSPACE_GAMMA
c.rgb = GammaToLinearSpace(c.rgb);
#endif
c.r = log(1.0 + getLuma(c.rgb));
return c.rrrr;
}
half4 fragReduceScreenLum (v2fCross i) : SV_Target {
UNITY_SETUP_INSTANCE_ID(i);
half4 c1 = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv1);
half4 c2 = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv2);
half4 c3 = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv3);
half4 c4 = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv4);
c1.g = max( c1.g, max( c2.g, max( c3.g, c4.g )));
c1.r = (c1.r + c2.r + c3.r + c4.r) * 0.25;
return c1;
}
half4 fragBlendScreenLum (v2f i) : SV_Target {
UNITY_SETUP_INSTANCE_ID(i);
half4 c = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, 0.5.xx);
half4 p = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_EAHist , 0.5.xx);
float speed = c.r < p.r ? _EyeAdaptation.z: _EyeAdaptation.w;
c.a = speed * unity_DeltaTime.x;
return c;
}
half4 fragBlend (v2f i) : SV_Target {
UNITY_SETUP_INSTANCE_ID(i);
half4 c = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, 0.5.xx);
c.a = 1.0;
return c;
}
-9
View File
@@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: 871f58622181443c6abbcf766217c40d
timeCreated: 1478037772
licenseType: Free
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
-462
View File
@@ -1,462 +0,0 @@
// Copyright 2016-2019 Kronnect - All Rights Reserved.
#include "UnityCG.cginc"
#include "BeautifyAdvancedParams.cginc"
#include "BeautifyOrtho.cginc"
UNITY_DECLARE_SCREENSPACE_TEXTURE(_MainTex);
UNITY_DECLARE_SCREENSPACE_TEXTURE(_BloomTex);
half4 _BloomTex_TexelSize;
UNITY_DECLARE_SCREENSPACE_TEXTURE(_BloomTex1);
UNITY_DECLARE_SCREENSPACE_TEXTURE(_BloomTex2);
UNITY_DECLARE_SCREENSPACE_TEXTURE(_BloomTex3);
UNITY_DECLARE_SCREENSPACE_TEXTURE(_BloomTex4);
half4 _MainTex_TexelSize;
half4 _MainTex_ST;
half4 _Bloom;
half4 _BloomWeights;
half4 _BloomWeights2;
half4 _AFTint;
half _BlurScale;
#if BEAUTIFY_BLOOM_USE_DEPTH || BEAUTIFY_BLOOM_USE_LAYER
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
uniform half _BloomDepthTreshold;
#endif
#if BEAUTIFY_BLOOM_USE_LAYER
uniform sampler2D _BloomSourceTex;
uniform sampler2D_float _BloomSourceDepth;
uniform sampler2D _BloomSourceTexRightEye;
uniform sampler2D_float _BloomSourceDepthRightEye;
uniform half _BloomLayerZBias;
#endif
struct appdata {
float4 vertex : POSITION;
half2 texcoord : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f {
float4 pos : SV_POSITION;
half2 uv: TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
struct v2fCross {
float4 pos : SV_POSITION;
half2 uv: TEXCOORD0;
half2 uv1: TEXCOORD1;
half2 uv2: TEXCOORD2;
half2 uv3: TEXCOORD3;
half2 uv4: TEXCOORD4;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
struct v2fLum {
float4 pos : SV_POSITION;
half2 uv: TEXCOORD0;
#if BEAUTIFY_BLOOM_USE_DEPTH || BEAUTIFY_BLOOM_USE_LAYER
half2 depthUV: TEXCOORD1;
#endif
#if BEAUTIFY_BLOOM_USE_LAYER && UNITY_SINGLE_PASS_STEREO
half2 depthUVNonStereo: TEXCOORD2;
#endif
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
struct v2fCrossLum {
float4 pos : SV_POSITION;
half2 uv: TEXCOORD0;
half2 uv1: TEXCOORD1;
half2 uv2: TEXCOORD2;
half2 uv3: TEXCOORD3;
half2 uv4: TEXCOORD4;
#if BEAUTIFY_BLOOM_USE_DEPTH || BEAUTIFY_BLOOM_USE_LAYER
half2 depthUV: TEXCOORD5;
#endif
#if BEAUTIFY_BLOOM_USE_LAYER && UNITY_SINGLE_PASS_STEREO
half2 depthUVNonStereo: TEXCOORD6;
#endif
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert(appdata v) {
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = UnityStereoScreenSpaceUVAdjust(v.texcoord, _MainTex_ST);
#if UNITY_UV_STARTS_AT_TOP
if (_MainTex_TexelSize.y < 0) {
// Depth texture is inverted WRT the main texture
o.uv.y = 1.0 - o.uv.y;
}
#endif
return o;
}
v2fLum vertLum(appdata v) {
v2fLum o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = UnityObjectToClipPos(v.vertex);
#if BEAUTIFY_BLOOM_USE_LAYER && UNITY_SINGLE_PASS_STEREO
o.uv = v.texcoord;
o.depthUVNonStereo = v.texcoord;
o.depthUV = UnityStereoScreenSpaceUVAdjust(v.texcoord, _MainTex_ST);
#else
o.uv = UnityStereoScreenSpaceUVAdjust(v.texcoord, _MainTex_ST);
#if BEAUTIFY_BLOOM_USE_DEPTH || BEAUTIFY_BLOOM_USE_LAYER
o.depthUV = o.uv;
#endif
#endif
#if UNITY_UV_STARTS_AT_TOP
if (_MainTex_TexelSize.y < 0) {
// Depth texture is inverted WRT the main texture
o.uv.y = 1.0 - o.uv.y;
}
#endif
return o;
}
inline half Brightness(half3 c) {
return max(c.r, max(c.g, c.b));
}
half4 fragLum (v2fLum i) : SV_Target {
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
#if BEAUTIFY_BLOOM_USE_LAYER
half4 c;
if (unity_StereoEyeIndex == 0) {
c = tex2D(_BloomSourceTex, i.uv);
} else {
c = tex2D(_BloomSourceTexRightEye, i.uv);
}
#else
half4 c = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv);
#endif
c = clamp(c, 0.0.xxxx, _BloomWeights2.zzzz);
#if UNITY_COLORSPACE_GAMMA
c.rgb = GammaToLinearSpace(c.rgb);
#endif
#if BEAUTIFY_BLOOM_USE_DEPTH || BEAUTIFY_BLOOM_USE_LAYER
//half depth01 = BEAUTIFY_GET_DEPTH_01(UNITY_SAMPLE_DEPTH(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_CameraDepthTexture, i.depthUV)));
half depth01 = Linear01Depth(BEAUTIFY_DEPTH(_CameraDepthTexture, i.depthUV));
#endif
#if BEAUTIFY_BLOOM_USE_DEPTH
c.rgb *= (1.0 - depth01 * _BloomDepthTreshold);
#endif
#if BEAUTIFY_BLOOM_USE_LAYER
half depth02;
#if UNITY_SINGLE_PASS_STEREO
if (unity_StereoEyeIndex == 0) {
depth02 = Linear01Depth(UNITY_SAMPLE_DEPTH(tex2D(_BloomSourceDepth, i.depthUVNonStereo)));
} else {
depth02 = Linear01Depth(UNITY_SAMPLE_DEPTH(tex2D(_BloomSourceDepthRightEye, i.depthUVNonStereo)));
}
#else
if (unity_StereoEyeIndex == 0) {
depth02 = Linear01Depth(UNITY_SAMPLE_DEPTH(tex2D(_BloomSourceDepth, i.depthUV)));
} else {
depth02 = Linear01Depth(UNITY_SAMPLE_DEPTH(tex2D(_BloomSourceDepthRightEye, i.depthUV)));
}
#endif
half isTransparent = (depth02 >= 1) && any(c.rgb>0);
half nonEclipsed = isTransparent || (depth01 > depth02 - _BloomLayerZBias);
c.rgb *= nonEclipsed;
#endif
c.a = Brightness(c.rgb);
c.rgb = max(c.rgb - _Bloom.www, 0);
return c;
}
v2fCross vertCross(appdata v) {
v2fCross o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = UnityObjectToClipPos(v.vertex);
#if UNITY_UV_STARTS_AT_TOP
if (_MainTex_TexelSize.y < 0) {
// Texture is inverted WRT the main texture
v.texcoord.y = 1.0 - v.texcoord.y;
}
#endif
o.uv = UnityStereoScreenSpaceUVAdjust(v.texcoord, _MainTex_ST);
half3 offsets = _MainTex_TexelSize.xyx * half3(1,1,-1);
#if UNITY_SINGLE_PASS_STEREO
offsets.xz *= 2.0;
#endif
o.uv1 = UnityStereoScreenSpaceUVAdjust(v.texcoord - offsets.xy, _MainTex_ST);
o.uv2 = UnityStereoScreenSpaceUVAdjust(v.texcoord - offsets.zy, _MainTex_ST);
o.uv3 = UnityStereoScreenSpaceUVAdjust(v.texcoord + offsets.zy, _MainTex_ST);
o.uv4 = UnityStereoScreenSpaceUVAdjust(v.texcoord + offsets.xy, _MainTex_ST);
return o;
}
v2fCrossLum vertCrossLum(appdata v) {
v2fCrossLum o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = UnityObjectToClipPos(v.vertex);
#if BEAUTIFY_BLOOM_USE_LAYER && UNITY_SINGLE_PASS_STEREO
o.depthUVNonStereo = v.texcoord;
o.depthUV = UnityStereoScreenSpaceUVAdjust(v.texcoord, _MainTex_ST);
#if UNITY_UV_STARTS_AT_TOP
if (_MainTex_TexelSize.y < 0) {
// Texture is inverted WRT the main texture
v.texcoord.y = 1.0 - v.texcoord.y;
}
#endif
o.uv = v.texcoord;
half3 offsets = _MainTex_TexelSize.xyx * half3(1, 1, -1);
o.uv1 = v.texcoord - offsets.xy;
o.uv2 = v.texcoord - offsets.zy;
o.uv3 = v.texcoord + offsets.zy;
o.uv4 = v.texcoord + offsets.xy;
#else
#if BEAUTIFY_BLOOM_USE_DEPTH || BEAUTIFY_BLOOM_USE_LAYER
o.depthUV = UnityStereoScreenSpaceUVAdjust(v.texcoord, _MainTex_ST);
#endif
#if UNITY_UV_STARTS_AT_TOP
if (_MainTex_TexelSize.y < 0) {
// Texture is inverted WRT the main texture
v.texcoord.y = 1.0 - v.texcoord.y;
}
#endif
o.uv = UnityStereoScreenSpaceUVAdjust(v.texcoord, _MainTex_ST);
half3 offsets = _MainTex_TexelSize.xyx * half3(1, 1, -1);
#if UNITY_SINGLE_PASS_STEREO
offsets.xz *= 2.0;
#endif
o.uv1 = UnityStereoScreenSpaceUVAdjust(v.texcoord - offsets.xy, _MainTex_ST);
o.uv2 = UnityStereoScreenSpaceUVAdjust(v.texcoord - offsets.zy, _MainTex_ST);
o.uv3 = UnityStereoScreenSpaceUVAdjust(v.texcoord + offsets.zy, _MainTex_ST);
o.uv4 = UnityStereoScreenSpaceUVAdjust(v.texcoord + offsets.xy, _MainTex_ST);
#endif
return o;
}
half4 fragLumAntiflicker(v2fCrossLum i) : SV_Target {
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
#if BEAUTIFY_BLOOM_USE_LAYER
half4 c1, c2, c3, c4;
if (unity_StereoEyeIndex == 0) {
c1 = tex2D(_BloomSourceTex, i.uv1);
c2 = tex2D(_BloomSourceTex, i.uv2);
c3 = tex2D(_BloomSourceTex, i.uv3);
c4 = tex2D(_BloomSourceTex, i.uv4);
} else {
c1 = tex2D(_BloomSourceTexRightEye, i.uv1);
c2 = tex2D(_BloomSourceTexRightEye, i.uv2);
c3 = tex2D(_BloomSourceTexRightEye, i.uv3);
c4 = tex2D(_BloomSourceTexRightEye, i.uv4);
}
#else
half4 c1 = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv1);
half4 c2 = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv2);
half4 c3 = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv3);
half4 c4 = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv4);
#endif
c1 = clamp(c1, 0.0.xxxx, _BloomWeights2.zzzz);
c2 = clamp(c2, 0.0.xxxx, _BloomWeights2.zzzz);
c3 = clamp(c3, 0.0.xxxx, _BloomWeights2.zzzz);
c4 = clamp(c4, 0.0.xxxx, _BloomWeights2.zzzz);
#if BEAUTIFY_BLOOM_USE_DEPTH || BEAUTIFY_BLOOM_USE_LAYER
//half depth01 = BEAUTIFY_GET_DEPTH_01(UNITY_SAMPLE_DEPTH(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_CameraDepthTexture, i.depthUV)));
half depth01 = Linear01Depth(BEAUTIFY_DEPTH(_CameraDepthTexture, i.depthUV));
half depthAtten = 1.0 - depth01 * _BloomDepthTreshold;
#endif
#if BEAUTIFY_BLOOM_USE_DEPTH
c1.rgb *= depthAtten;
c2.rgb *= depthAtten;
c3.rgb *= depthAtten;
c4.rgb *= depthAtten;
#endif
#if BEAUTIFY_BLOOM_USE_LAYER
#if UNITY_SINGLE_PASS_STEREO
//half depth02 = BEAUTIFY_GET_DEPTH_01(UNITY_SAMPLE_DEPTH(tex2D(_BloomSourceDepth, i.depthUVNonStereo)));
half depth02 = Linear01Depth(UNITY_SAMPLE_DEPTH(tex2D(_BloomSourceDepth, i.depthUVNonStereo)));
#else
//half depth02 = BEAUTIFY_GET_DEPTH_01(UNITY_SAMPLE_DEPTH(tex2D(_BloomSourceDepth, i.depthUV)));
half depth02 = Linear01Depth(UNITY_SAMPLE_DEPTH(tex2D(_BloomSourceDepth, i.depthUV)));
#endif
half isTransparent = (depth02 >= 1) && any(c1.rgb>0);
half nonEclipsed = isTransparent || (depth01 > depth02 - _BloomLayerZBias );
c1.rgb *= nonEclipsed;
c2.rgb *= nonEclipsed;
c3.rgb *= nonEclipsed;
c4.rgb *= nonEclipsed;
#endif
c1.a = Brightness(c1.rgb);
c2.a = Brightness(c2.rgb);
c3.a = Brightness(c3.rgb);
c4.a = Brightness(c4.rgb);
half w1 = 1.0 / (c1.a + 1.0);
half w2 = 1.0 / (c2.a + 1.0);
half w3 = 1.0 / (c3.a + 1.0);
half w4 = 1.0 / (c4.a + 1.0);
half dd = 1.0 / (w1 + w2 + w3 + w4);
c1 = (c1 * w1 + c2 * w2 + c3 * w3 + c4 * w4) * dd;
#if UNITY_COLORSPACE_GAMMA
c1.rgb = GammaToLinearSpace(c1.rgb);
#endif
c1.rgb = max(c1.rgb - _Bloom.www, 0);
return c1;
}
half4 fragBloomCompose (v2f i) : SV_Target {
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
half4 b0 = UNITY_SAMPLE_SCREENSPACE_TEXTURE( _BloomTex , i.uv );
half4 b1 = UNITY_SAMPLE_SCREENSPACE_TEXTURE( _BloomTex1 , i.uv );
half4 b2 = UNITY_SAMPLE_SCREENSPACE_TEXTURE( _BloomTex2 , i.uv );
half4 b3 = UNITY_SAMPLE_SCREENSPACE_TEXTURE( _BloomTex3 , i.uv );
half4 b4 = UNITY_SAMPLE_SCREENSPACE_TEXTURE( _BloomTex4 , i.uv );
half4 b5 = UNITY_SAMPLE_SCREENSPACE_TEXTURE( _MainTex , i.uv );
half4 pixel = b0 * _BloomWeights.x + b1 * _BloomWeights.y + b2 * _BloomWeights.z + b3 * _BloomWeights.w + b4 * _BloomWeights2.x + b5 * _BloomWeights2.y;
return pixel;
}
half4 fragResample(v2fCross i) : SV_Target {
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
half4 c1 = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv1);
half4 c2 = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv2);
half4 c3 = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv3);
half4 c4 = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv4);
half w1 = 1.0 / (c1.a + 1.0);
half w2 = 1.0 / (c2.a + 1.0);
half w3 = 1.0 / (c3.a + 1.0);
half w4 = 1.0 / (c4.a + 1.0);
half dd = 1.0 / (w1 + w2 + w3 + w4);
return (c1 * w1 + c2 * w2 + c3 * w3 + c4 * w4) * dd;
}
half4 fragResampleAF(v2fCross i) : SV_Target {
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
half4 c1 = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv1);
half4 c2 = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv2);
half4 c3 = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv3);
half4 c4 = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv4);
half w1 = 1.0 / (c1.a + 1.0);
half w2 = 1.0 / (c2.a + 1.0);
half w3 = 1.0 / (c3.a + 1.0);
half w4 = 1.0 / (c4.a + 1.0);
half dd = 1.0 / (w1 + w2 + w3 + w4);
c1 = (c1 * w1 + c2 * w2 + c3 * w3 + c4 * w4) * dd;
c1.rgb = lerp(c1.rgb, Brightness(c1.rgb) * _AFTint.rgb, _AFTint.a);
c1.rgb *= _Bloom.xxx;
return c1;
}
half4 fragCopy(v2f i) : SV_Target {
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
return UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv);
}
half4 fragDebugBloom (v2f i) : SV_Target {
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
return UNITY_SAMPLE_SCREENSPACE_TEXTURE(_BloomTex, i.uv) * _Bloom.xxxx;
}
half4 fragResampleFastAF(v2f i) : SV_Target {
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
half4 c = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv);
c.rgb = lerp(c.rgb, Brightness(c.rgb) * _AFTint.rgb, _AFTint.a);
c.rgb *= _Bloom.xxx;
return c;
}
v2fCross vertBlurH(appdata v) {
v2fCross o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = UnityObjectToClipPos(v.vertex);
#if UNITY_UV_STARTS_AT_TOP
if (_MainTex_TexelSize.y < 0) {
// Texture is inverted WRT the main texture
v.texcoord.y = 1.0 - v.texcoord.y;
}
#endif
o.uv = UnityStereoScreenSpaceUVAdjust(v.texcoord, _MainTex_ST);
half2 inc = half2(_MainTex_TexelSize.x * 1.3846153846 * _BlurScale, 0);
#if UNITY_SINGLE_PASS_STEREO
inc.x *= 2.0;
#endif
o.uv1 = UnityStereoScreenSpaceUVAdjust(v.texcoord - inc, _MainTex_ST);
o.uv2 = UnityStereoScreenSpaceUVAdjust(v.texcoord + inc, _MainTex_ST);
half2 inc2 = half2(_MainTex_TexelSize.x * 3.2307692308 * _BlurScale, 0);
#if UNITY_SINGLE_PASS_STEREO
inc2.x *= 2.0;
#endif
o.uv3 = UnityStereoScreenSpaceUVAdjust(v.texcoord - inc2, _MainTex_ST);
o.uv4 = UnityStereoScreenSpaceUVAdjust(v.texcoord + inc2, _MainTex_ST);
return o;
}
v2fCross vertBlurV(appdata v) {
v2fCross o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = UnityObjectToClipPos(v.vertex);
#if UNITY_UV_STARTS_AT_TOP
if (_MainTex_TexelSize.y < 0) {
// Texture is inverted WRT the main texture
v.texcoord.y = 1.0 - v.texcoord.y;
}
#endif
o.uv = UnityStereoScreenSpaceUVAdjust(v.texcoord, _MainTex_ST);
half2 inc = half2(0, _MainTex_TexelSize.y * 1.3846153846 * _BlurScale);
o.uv1 = UnityStereoScreenSpaceUVAdjust(v.texcoord - inc, _MainTex_ST);
o.uv2 = UnityStereoScreenSpaceUVAdjust(v.texcoord + inc, _MainTex_ST);
half2 inc2 = half2(0, _MainTex_TexelSize.y * 3.2307692308 * _BlurScale);
o.uv3 = UnityStereoScreenSpaceUVAdjust(v.texcoord - inc2, _MainTex_ST);
o.uv4 = UnityStereoScreenSpaceUVAdjust(v.texcoord + inc2, _MainTex_ST);
return o;
}
half4 fragBlur (v2fCross i): SV_Target {
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
half4 pixel = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv) * 0.2270270270
+ (UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv1) + UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv2)) * 0.3162162162
+ (UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv3) + UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv4)) * 0.0702702703;
return pixel;
}
-9
View File
@@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: 6708800698de942e2a85c62acbfa8693
timeCreated: 1466064953
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
-426
View File
@@ -1,426 +0,0 @@
// Copyright 2016-2019 Ramiro Oliva (Kronnect) - All Rights Reserved.
#include "UnityCG.cginc"
#include "BeautifyAdvancedParams.cginc"
#include "BeautifyOrtho.cginc"
UNITY_DECLARE_SCREENSPACE_TEXTURE(_MainTex);
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
uniform sampler2D _OverlayTex;
UNITY_DECLARE_SCREENSPACE_TEXTURE(_ScreenLum);
UNITY_DECLARE_SCREENSPACE_TEXTURE(_BloomTex);
UNITY_DECLARE_SCREENSPACE_TEXTURE(_EALumSrc);
UNITY_DECLARE_SCREENSPACE_TEXTURE(_EAHist);
UNITY_DECLARE_SCREENSPACE_TEXTURE(_CompareTex);
uniform sampler2D _LUTTex;
uniform float4 _MainTex_TexelSize;
uniform float4 _MainTex_ST;
uniform float4 _ColorBoost; // x = Brightness, y = Contrast, z = Saturate, w = Daltonize;
uniform float4 _Sharpen;
uniform float4 _Dither;
uniform float4 _FXColor;
uniform float4 _TintColor;
uniform float4 _Outline;
uniform float4 _Dirt;
uniform float3 _Bloom;
uniform float4 _CompareParams;
uniform float4 _BokehData;
uniform float4 _BokehData2;
uniform float4 _EyeAdaptation;
uniform float3 _Purkinje;
#if BEAUTIFY_VIGNETTING || BEAUTIFY_VIGNETTING_MASK
uniform float4 _Vignetting;
uniform float _VignettingAspectRatio;
uniform sampler2D _VignettingMask;
#endif
#if BEAUTIFY_FRAME || BEAUTIFY_FRAME_MASK
uniform float4 _Frame;
uniform sampler2D _FrameMask;
#endif
#if BEAUTIFY_DEPTH_OF_FIELD_TRANSPARENT || BEAUTIFY_DEPTH_OF_FIELD
UNITY_DECLARE_SCREENSPACE_TEXTURE(_DoFTex);
uniform float4 _DoFTex_TexelSize;
#endif
#if BEAUTIFY_DEPTH_OF_FIELD_TRANSPARENT
uniform sampler2D _DepthTexture;
uniform sampler2D _DofExclusionTexture;
#endif
struct appdata {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f {
float4 pos : SV_POSITION;
float2 uv: TEXCOORD0;
float2 depthUV : TEXCOORD1;
float2 uvN: TEXCOORD2;
float2 uvS: TEXCOORD3;
float2 uvW: TEXCOORD4;
#if BEAUTIFY_DIRT || BEAUTIFY_DEPTH_OF_FIELD_TRANSPARENT || BEAUTIFY_VIGNETTING || BEAUTIFY_VIGNETTING_MASK || BEAUTIFY_FRAME || BEAUTIFY_FRAME_MASK
float2 uvNonStereo: TEXCOORD5;
#endif
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
struct v2fCompare {
float4 pos : SV_POSITION;
float2 uv: TEXCOORD0;
float2 uvNonStereo: TEXCOORD1;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
v2fCompare vertCompare(appdata v) {
v2fCompare o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = UnityStereoScreenSpaceUVAdjust(v.texcoord, _MainTex_ST);
o.uvNonStereo = v.texcoord;
return o;
}
v2f vert(appdata v) {
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = UnityStereoScreenSpaceUVAdjust(v.texcoord, _MainTex_ST);
o.depthUV = o.uv;
float3 uvInc = float3(_MainTex_TexelSize.x, _MainTex_TexelSize.y, 0);
o.uvN = o.uv + uvInc.zy;
o.uvS = o.uv - uvInc.zy;
o.uvW = o.uv - uvInc.xz;
#if BEAUTIFY_DIRT || BEAUTIFY_DEPTH_OF_FIELD_TRANSPARENT || BEAUTIFY_VIGNETTING || BEAUTIFY_VIGNETTING_MASK || BEAUTIFY_FRAME || BEAUTIFY_FRAME_MASK
o.uvNonStereo = v.texcoord;
#endif
#if UNITY_UV_STARTS_AT_TOP
if (_MainTex_TexelSize.y < 0) {
// Depth texture is inverted WRT the main texture
o.depthUV.y = 1.0 - o.depthUV.y;
#if BEAUTIFY_DIRT || BEAUTIFY_DEPTH_OF_FIELD_TRANSPARENT || BEAUTIFY_VIGNETTING || BEAUTIFY_VIGNETTING_MASK || BEAUTIFY_FRAME || BEAUTIFY_FRAME_MASK
o.uvNonStereo.y = 1.0 - o.uvNonStereo.y;
#endif
}
#endif
return o;
}
inline float getLuma(float3 rgb) {
const float3 lum = float3(0.299, 0.587, 0.114);
return dot(rgb, lum);
}
float3 getNormal(float depth, float depth1, float depth2, float2 offset1, float2 offset2) {
float3 p1 = float3(offset1, depth1 - depth);
float3 p2 = float3(offset2, depth2 - depth);
float3 normal = cross(p1, p2);
return normalize(normal);
}
float getRandomFast(float2 uv) {
float2 p = uv + _Time.yy;
p -= floor(p * 0.01408450704) * 71.0;
p += float2( 26.0, 161.0 );
p *= p;
return frac(p.x * p.y * 0.001051374728);
}
float getCoc(v2f i) {
#if BEAUTIFY_DEPTH_OF_FIELD_TRANSPARENT
float depthTex = DecodeFloatRGBA(tex2Dlod(_DepthTexture, float4(i.uvNonStereo, 0, 0)));
float exclusionDepth = DecodeFloatRGBA(tex2Dlod(_DofExclusionTexture, float4(i.uvNonStereo, 0, 0)));
//float depth = BEAUTIFY_GET_DEPTH_01(UNITY_SAMPLE_DEPTH(SAMPLE_RAW_DEPTH_TEXTURE_LOD(_CameraDepthTexture, float4(i.depthUV, 0, 0))));
float depth = Linear01Depth(BEAUTIFY_DEPTH_LOD(_CameraDepthTexture, float4(i.depthUV, 0, 0)));
depth = min(depth, depthTex);
if (exclusionDepth < depth) return 0;
depth *= _ProjectionParams.z;
#else
//float depth = BEAUTIFY_GET_DEPTH_EYE(UNITY_SAMPLE_DEPTH(SAMPLE_RAW_DEPTH_TEXTURE_LOD(_CameraDepthTexture, float4(i.depthUV, 0, 0))));
float depth = LinearEyeDepth(BEAUTIFY_DEPTH_LOD(_CameraDepthTexture, float4(i.depthUV, 0, 0)));
#endif
float xd = abs(depth - _BokehData.x) - _BokehData2.x * (depth < _BokehData.x);
return 0.5 * _BokehData.y * xd/depth; // radius of CoC
}
void beautifyPassFast(v2f i, inout float3 rgbM) {
float3 uvInc = float3(_MainTex_TexelSize.x, _MainTex_TexelSize.y, 0);
#if BEAUTIFY_NIGHT_VISION || BEAUTIFY_OUTLINE
//float depthN = BEAUTIFY_GET_DEPTH_01(UNITY_SAMPLE_DEPTH(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_CameraDepthTexture, i.depthUV + uvInc.zy)));
float depthN = Linear01Depth(BEAUTIFY_DEPTH(_CameraDepthTexture, i.depthUV + uvInc.zy));
#endif
//float depthW = BEAUTIFY_GET_DEPTH_01(UNITY_SAMPLE_DEPTH(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_CameraDepthTexture, i.depthUV - uvInc.xz)));
float depthW = Linear01Depth(BEAUTIFY_DEPTH(_CameraDepthTexture, i.depthUV - uvInc.xz));
float lumaM = getLuma(rgbM);
#if !BEAUTIFY_NIGHT_VISION && !BEAUTIFY_THERMAL_VISION
#if !defined(BEAUTIFY_DITHER_FINAL) && defined(BEAUTIFY_ENABLE_DITHER)
float3 dither = dot(float2(171.0, 231.0), i.uv * _ScreenParams.xy).xxx;
dither = frac(dither / float3(103.0, 71.0, 97.0)) - 0.5.xxx;
rgbM *= 1.0 + step(_Dither.y, depthW) * _Dither.x * dither;
#endif
#if BEAUTIFY_DALTONIZE
float3 rgb0 = 1.0.xxx - saturate(rgbM.rgb);
rgbM.r *= 1.0 + rgbM.r * rgb0.g * rgb0.b * _ColorBoost.w;
rgbM.g *= 1.0 + rgbM.g * rgb0.r * rgb0.b * _ColorBoost.w;
rgbM.b *= 1.0 + rgbM.b * rgb0.r * rgb0.g * _ColorBoost.w;
rgbM *= lumaM / (getLuma(rgbM) + 0.0001);
#endif
#if defined(BEAUTIFY_DEPTH_BASED_SHARPEN)
float depthClamp = abs(depthW - _Dither.z) < _Dither.w;
#else
float depthClamp = 1.0;
#endif
float3 rgbN = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uvN).rgb;
float3 rgbS = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uvS).rgb;
float3 rgbW = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uvW).rgb;
float lumaN = getLuma(rgbN);
float lumaW = getLuma(rgbW);
float lumaS = getLuma(rgbS);
float maxLuma = max(lumaN,lumaS);
maxLuma = max(maxLuma, lumaW);
float minLuma = min(lumaN,lumaS);
minLuma = min(minLuma, lumaW) - 0.000001;
float lumaPower = 2 * lumaM - minLuma - maxLuma;
float lumaAtten = saturate(_Sharpen.w / (maxLuma - minLuma));
#if defined(BEAUTIFY_ENABLE_CORE_EFFECT)
rgbM *= 1.0 + clamp(lumaPower * lumaAtten * _Sharpen.x, -_Sharpen.z, _Sharpen.z) * depthClamp;
#endif
#if BEAUTIFY_DEPTH_OF_FIELD || BEAUTIFY_DEPTH_OF_FIELD_TRANSPARENT
float4 dofPix = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_DoFTex, i.uv);
#if UNITY_COLORSPACE_GAMMA
dofPix.rgb = LinearToGammaSpace(dofPix.rgb);
#endif
if (_DoFTex_TexelSize.z < _MainTex_TexelSize.z) {
float CoC = getCoc(i);
dofPix.a = lerp(CoC, dofPix.a, _DoFTex_TexelSize.z / _MainTex_TexelSize.z);
}
rgbM = lerp(rgbM, dofPix.rgb, saturate(dofPix.a));
#endif
#endif // night & thermal vision exclusion
#if BEAUTIFY_NIGHT_VISION
float depth = Linear01Depth(BEAUTIFY_DEPTH(_CameraDepthTexture, i.depthUV)); // was tex2D
// float3 normalNW = getNormal(depth, depthN, depthW, uvInc.zy, -uvInc.xz); // According to Unity QA this causes issues in Mali G71 GPU due to a hardware problem
float3 normalNW = getNormal(depth, depthN, depthW, uvInc.zy, float2(-uvInc.x, -uvInc.z));
#endif
#if BEAUTIFY_OUTLINE
#if !defined(BEAUTIFY_OUTLINE_SOBEL)
#if !BEAUTIFY_NIGHT_VISION
//float depth = BEAUTIFY_GET_DEPTH_01(UNITY_SAMPLE_DEPTH(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_CameraDepthTexture, i.depthUV)));
float depth = Linear01Depth(BEAUTIFY_DEPTH(_CameraDepthTexture, i.depthUV));
// float3 normalNW = getNormal(depth, depthN, depthW, uvInc.zy, -uvInc.xz); // According to Unity QA this causes issues in Mali G71 GPU due to a hardware problem
float3 normalNW = getNormal(depth, depthN, depthW, uvInc.zy, float2(-uvInc.x, -uvInc.z));
#endif
//float depthE = BEAUTIFY_GET_DEPTH_01(UNITY_SAMPLE_DEPTH(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_CameraDepthTexture, i.depthUV + uvInc.xz)));
//float depthS = BEAUTIFY_GET_DEPTH_01(UNITY_SAMPLE_DEPTH(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_CameraDepthTexture, i.depthUV - uvInc.zy)));
float depthE = Linear01Depth(BEAUTIFY_DEPTH(_CameraDepthTexture, i.depthUV + uvInc.xz));
float depthS = Linear01Depth(BEAUTIFY_DEPTH(_CameraDepthTexture, i.depthUV - uvInc.zy));
float3 normalSE = getNormal(depth, depthS, depthE, -uvInc.zy, uvInc.xz);
float dnorm = dot(normalNW, normalSE);
rgbM = lerp(rgbM, _Outline.rgb, dnorm < _Outline.a);
#else
float4 uv4 = float4(i.uv, 0, 0);
#if BEAUTIFY_NIGHT_VISION || BEAUTIFY_THERMAL_VISION
float3 rgbS = SAMPLE_RAW_DEPTH_TEXTURE_LOD(_MainTex, uv4 - uvInc.zyzz).rgb;
float3 rgbN = SAMPLE_RAW_DEPTH_TEXTURE_LOD(_MainTex, uv4 + uvInc.zyzz).rgb;
float3 rgbW = SAMPLE_RAW_DEPTH_TEXTURE_LOD(_MainTex, uv4 - uvInc.xzzz).rgb;
#endif
float3 rgbSW = SAMPLE_RAW_DEPTH_TEXTURE_LOD(_MainTex, uv4 - uvInc.xyzz).rgb;
float3 rgbNE = SAMPLE_RAW_DEPTH_TEXTURE_LOD(_MainTex, uv4 + uvInc.xyzz).rgb;
float3 rgbSE = SAMPLE_RAW_DEPTH_TEXTURE_LOD(_MainTex, uv4 + float4( uvInc.x, -uvInc.y, 0, 0)).rgb;
float3 rgbNW = SAMPLE_RAW_DEPTH_TEXTURE_LOD(_MainTex, uv4 + float4(-uvInc.x, uvInc.y, 0, 0)).rgb;
float3 gx = rgbSW * -1.0;
gx += rgbSE * 3.0;
gx += rgbW * -2.0;
gx += rgbNW * -1.0;
gx += rgbN * 1.0;
float3 gy = rgbSW * -1.0;
gy += rgbS * -2.0;
gy += rgbSE * -1.0;
gy += rgbNW * 1.0;
gy += rgbN * 3.0;
float olColor = (length(gx * gx + gy * gy) - _Outline.a) > 0.0;
rgbM = lerp(rgbM, _Outline.rgb, olColor);
#endif
#endif
#if BEAUTIFY_BLOOM || BEAUTIFY_DIRT
#if UNITY_COLORSPACE_GAMMA
rgbM = GammaToLinearSpace(rgbM);
#endif
#endif
#if BEAUTIFY_BLOOM
rgbM += UNITY_SAMPLE_SCREENSPACE_TEXTURE(_BloomTex, i.uv).rgb * _Bloom.xxx;
#endif
#if BEAUTIFY_DIRT
float3 scrLum = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_ScreenLum, i.uv).rgb;
#if BEAUTIFY_BLOOM
scrLum *= _Dirt.www;
#endif
float4 dirt = tex2D(_OverlayTex, i.uvNonStereo);
rgbM += saturate(0.5.xxx - _Dirt.zzz + scrLum) * dirt.rgb * _Dirt.y;
#endif
#if BEAUTIFY_EYE_ADAPTATION || BEAUTIFY_PURKINJE
float4 avgLum = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_EAHist, 0.5.xx);
#endif
#if BEAUTIFY_EYE_ADAPTATION
float srcLum = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_EALumSrc, 0.5.xx).r;
float diff = srcLum / (avgLum.r + 0.0001);
diff = clamp(diff, _EyeAdaptation.x, _EyeAdaptation.y);
rgbM = rgbM * diff;
#endif
#if BEAUTIFY_BLOOM || BEAUTIFY_DIRT
#if UNITY_COLORSPACE_GAMMA
rgbM = LinearToGammaSpace(rgbM);
#endif
#endif
#if BEAUTIFY_NIGHT_VISION
lumaM = getLuma(rgbM); // updates luma
float nvbase = saturate(normalNW.z - 0.8); // minimum ambient self radiance (useful for pitch black)
nvbase += lumaM; // adds current lighting
nvbase *= nvbase * (0.5 + nvbase); // increase contrast
rgbM = nvbase * _FXColor.rgb;
float2 uvs = floor(i.uv.xy * _ScreenParams.xy);
rgbM *= frac(uvs.y*0.25)>0.4; // scan lines
rgbM *= 1.0 + getRandomFast(uvs) * 0.3 - 0.15; // noise
#endif
#if BEAUTIFY_THERMAL_VISION
lumaM = getLuma(rgbM); // updates luma
float3 tv0 = lerp(float3(0.0,0.0,1.0), float3(1.0,1.0,0.0), lumaM * 2.0);
float3 tv1 = lerp(float3(1.0,1.0,0.0), float3(1.0,0.0,0.0), lumaM * 2.0 - 1.0);
rgbM = lerp(tv0, tv1, lumaM >= 0.5);
float2 uvs = floor(i.uv.xy * _ScreenParams.xy);
rgbM *= 0.2 + frac(uvs.y*0.25)>0.4; // scan lines
rgbM *= 1.0 + getRandomFast(uvs) * 0.2 - 0.1; // noise
#endif
#if defined(BEAUTIFY_USE_PROCEDURAL_SEPIA)
float3 sepia = float3(
dot(rgbM, float3(0.393, 0.769, 0.189)),
dot(rgbM, float3(0.349, 0.686, 0.168)),
dot(rgbM, float3(0.272, 0.534, 0.131))
);
rgbM = lerp(rgbM, sepia, _FXColor.a);
#elif BEAUTIFY_LUT
#if !UNITY_COLORSPACE_GAMMA
rgbM = LinearToGammaSpace(rgbM);
#endif
const float3 lutST = float3(1.0/1024, 1.0/32, 32-1);
float3 lookUp = saturate(rgbM) * lutST.zzz;
lookUp.xy = lutST.xy * (lookUp.xy + 0.5);
float slice = floor(lookUp.z);
lookUp.x += slice * lutST.y;
#if defined(BEAUTIFY_BETTER_FASTER_LUT)
float2 lookUpNextSlice = float2(lookUp.x + lutST.y, lookUp.y);
float3 lut = lerp(tex2D(_LUTTex, lookUp.xy).rgb, tex2D(_LUTTex, lookUpNextSlice).rgb, lookUp.z - slice);
#else
float3 lut = tex2D(_LUTTex, lookUp.xy).rgb;
#endif
rgbM = lerp(rgbM, lut, _FXColor.a);
#if !UNITY_COLORSPACE_GAMMA
rgbM = GammaToLinearSpace(rgbM);
#endif
#endif
#if defined(BEAUTIFY_ENABLE_COLOR_TWEAKS)
float maxComponent = max(rgbM.r, max(rgbM.g, rgbM.b));
float minComponent = min(rgbM.r, min(rgbM.g, rgbM.b));
float sat = saturate(maxComponent - minComponent);
rgbM *= 1.0 + _ColorBoost.z * (1.0 - sat) * (rgbM - getLuma(rgbM));
rgbM = lerp(rgbM, rgbM * _TintColor.rgb, _TintColor.a);
rgbM = (rgbM - 0.5.xxx) * _ColorBoost.y + 0.5.xxx;
rgbM *= _ColorBoost.x;
#endif
#if BEAUTIFY_PURKINJE
lumaM = getLuma(rgbM);
float3 shifted = saturate(float3(lumaM / (1.0 + _Purkinje.x * 1.14), lumaM, lumaM * (1.0 + _Purkinje.x * 2.99)));
rgbM = lerp(shifted, rgbM, saturate(exp(avgLum.g) - _Purkinje.y));
#endif
#if BEAUTIFY_VIGNETTING
float2 vd = float2(i.uvNonStereo.x - 0.5, (i.uvNonStereo.y - 0.5) * _VignettingAspectRatio);
rgbM = lerp(rgbM, lumaM * _Vignetting.rgb, saturate(_Purkinje.z + _Vignetting.a * dot(vd,vd)));
#elif BEAUTIFY_VIGNETTING_MASK
float2 vd = float2(i.uvNonStereo.x - 0.5, (i.uvNonStereo.y - 0.5) * _VignettingAspectRatio);
float vmask = tex2D(_VignettingMask, i.uvNonStereo).a;
rgbM = lerp(rgbM, lumaM * _Vignetting.rgb, saturate(_Purkinje.z + vmask * _Vignetting.a * dot(vd, vd)));
#endif
#if BEAUTIFY_FRAME
rgbM = lerp(rgbM, _Frame.rgb, saturate( (max(abs(i.uvNonStereo.x - 0.5), abs(i.uvNonStereo.y - 0.5)) - _Frame.a) * 50.0));
#elif BEAUTIFY_FRAME_MASK
float4 frameMask = tex2D(_FrameMask, i.uvNonStereo);
float3 frameColor = lerp(_Frame.rgb, frameMask.rgb * _Frame.rgb, frameMask.a);
rgbM = lerp(rgbM, frameColor, saturate( (max(abs(i.uvNonStereo.x - 0.5), abs(i.uvNonStereo.y - 0.5)) - _Frame.a) * 50.0));
#endif
#if !BEAUTIFY_NIGHT_VISION && !BEAUTIFY_THERMAL_VISION && defined(BEAUTIFY_DITHER_FINAL) && defined(BEAUTIFY_ENABLE_DITHER)
float3 dither = dot(float2(171.0, 231.0), i.uv * _ScreenParams.xy).xxx;
dither = frac(dither / float3(103.0, 71.0, 97.0)) - 0.5.xxx;
rgbM *= 1.0 + step(_Dither.y, depthW) * _Dither.x * dither;
#endif
}
float4 fragBeautifyFast (v2f i) : SV_Target {
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
float4 pixel = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv);
beautifyPassFast(i, pixel.rgb);
return pixel;
}
float4 fragCompareFast (v2fCompare i) : SV_Target {
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
// separator line + antialias
float2 dd = i.uvNonStereo - 0.5.xx;
float co = dot(_CompareParams.xy, dd);
float dist = distance( _CompareParams.xy * co, dd );
float4 aa = saturate( (_CompareParams.w - dist) / abs(_MainTex_TexelSize.y) );
float4 pixel = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv);
float4 pixelNice = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_CompareTex, i.uv);
// are we on the beautified side?
float t = dot(dd, _CompareParams.yz) > 0;
pixel = lerp(pixel, pixelNice, t);
return pixel + aa;
}
@@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: 1d84252c1f1ab4413b72b835c3c271f4
timeCreated: 1465123627
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
-328
View File
@@ -1,328 +0,0 @@
Shader "Beautify/BeautifyMobile" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_OverlayTex ("Overlay (RGB)", 2D) = "black" {}
_DoFTex("DoF (RGBA)", any) = "black" {}
//_DoFTex("DoF (RGBA)", 2D) = "black" {}
_Sharpen ("Sharpen Data", Vector) = (2.5, 0.035, 0.5)
_ColorBoost ("Color Boost Data", Vector) = (1.1, 1.1, 0.08, 0)
_Dither ("Dither Data", Vector) = (5, 0, 0, 1.0)
_FXColor ("FXColor Color", Color) = (1,1,1,0)
_TintColor ("Tint Color Color", Color) = (1,1,1,0)
_Vignetting ("Vignetting", Color) = (0.3,0.3,0.3,0.05)
_VignettingAspectRatio ("Vignetting Aspect Ratio", Float) = 1.0
_VignettingMask ("Mask Texture (A)", 2D) = "white" {}
_Frame("Frame Data", Vector) = (50,50,50,0)
_FrameMask ("Mask Texture (A)", 2D) = "white" {}
_Outline("Outline", Color) = (0,0,0,0.8)
_Dirt("Dirt Data", Vector) = (0.5,0.5,0.5,0.5)
_Bloom("Bloom Data", Vector) = (0.5,0,0)
//_BloomTex("BloomTex (RGBA)", any) = "black" {}
_BloomTex("BloomTex (RGBA)", any) = "black" {}
_BloomWeights("Bloom Weights", Vector) = (0.35,0.55,0.7,0.8)
_BloomWeights2("Bloom Weights 2", Vector) = (0.35,0.55,0.7,0.8)
//_ScreenLum("Luminance Tex (RGBA)", 2D) = "black" {}
_ScreenLum("Luminance Tex (RGBA)", any) = "black" {}
_CompareParams("Compare Params", Vector) = (0.785398175, 0.001, 0, 0)
_AFTint ("Anamorphic Flares Tint", Color) = (1,1,1,0.5)
_BokehData("Bokeh Data", Vector) = (10,1,0,1)
_DepthTexture("Depth (RGBA)", 2D) = "black" {}
_DofExclusionTexture("DoF Exclusion (R)", 2D) = "white" {}
_BokehData2("Bokeh Data 2", Vector) = (1000.0, 4, 0, 0)
_BokehData3("Bokeh Data 3", Vector) = (1000.0, 100000.0, 0)
_EyeAdaptation("Eye Adaptation Data", Vector) = (0.1, 2, 0.7, 1)
_Purkinje ("Purkinje Data", Vector) = (1.0, 0.15, 0)
_BloomDepthTreshold("Bloom Depth Threshold", Float) = 1.0
_SunPos("SunFlares Sun Screen Position", Vector) = (0.5, 0.5, 0, 0)
_SunPosRightEye("SF Screen Position Right Eye", Vector) = (0.5, 0.5, 0, 0)
_SunData("SunFlares Sun Data", Vector) = (0.1, 0.05, 3.5, 0.13)
_SunCoronaRays1("SunFlares Corona Rays 1 Data", Vector) = (0.02, 12, 0.001, 0)
_SunCoronaRays2("SunFlares Corona Rays 2 Data", Vector) = (0.05, 12, 0.1, 0)
_SunGhosts1("SunFlares Ghosts 1 Data", Vector) = (0, 0.03, 0.6, 0.06)
_SunGhosts2("SunFlares Ghosts 2 Data", Vector) = (0, 0.1, 0.2, 0.03)
_SunHalo("SunFlares Halo Data", Vector) = (0.22, 15.1415, 1.0)
_SunTint("Sun Flare Tint Color", Color) = (1,1,1)
// _CompareTex ("Compare Image (RGB)", 2D) = "black" {}
_CompareTex ("Compare Image (RGB)", any) = "black" {}
_BlurScale ("Blur Scale", Float) = 1.0
_LUTTex ("Lut Texture (RGB)", 2D) = "white" {}
}
Subshader {
Pass { // 0
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vertCompare
#pragma fragment fragCompareFast
#pragma target 3.0
#pragma fragmentoption ARB_precision_hint_fastest
#include "BeautifyMobile.cginc"
ENDCG
}
Pass { // 1
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vert
#pragma fragment fragBeautifyFast
#pragma target 3.0
#pragma fragmentoption ARB_precision_hint_fastest
// Edited by Shader Control: #pragma multi_compile __ BEAUTIFY_DALTONIZE BEAUTIFY_LUT BEAUTIFY_NIGHT_VISION BEAUTIFY_THERMAL_VISION
#pragma multi_compile __ BEAUTIFY_LUT
// Edited by Shader Control: #pragma multi_compile __ BEAUTIFY_DEPTH_OF_FIELD BEAUTIFY_DEPTH_OF_FIELD_TRANSPARENT
#pragma multi_compile __ BEAUTIFY_DEPTH_OF_FIELD
// Disabled by Shader Control: #pragma multi_compile __ BEAUTIFY_OUTLINE
// Disabled by Shader Control: #pragma multi_compile __ BEAUTIFY_DIRT
#pragma multi_compile __ BEAUTIFY_BLOOM
#pragma multi_compile __ BEAUTIFY_EYE_ADAPTATION
// Disabled by Shader Control: #pragma multi_compile __ BEAUTIFY_PURKINJE
// Edited by Shader Control: #pragma multi_compile __ BEAUTIFY_VIGNETTING BEAUTIFY_VIGNETTING_MASK
#pragma multi_compile __ BEAUTIFY_VIGNETTING
// Disabled by Shader Control: #pragma multi_compile __ BEAUTIFY_FRAME BEAUTIFY_FRAME_MASK
#pragma multi_compile __ UNITY_COLORSPACE_GAMMA
#include "BeautifyMobile.cginc"
ENDCG
}
Pass { // 2
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vertLum
#pragma fragment fragLum
#pragma fragmentoption ARB_precision_hint_fastest
#pragma multi_compile __ BEAUTIFY_BLOOM_USE_DEPTH
#pragma multi_compile __ BEAUTIFY_BLOOM_USE_LAYER
#pragma multi_compile __ UNITY_COLORSPACE_GAMMA
#include "BeautifyLum.cginc"
ENDCG
}
Pass { // 3
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vert
#pragma fragment fragDebugBloom
#pragma fragmentoption ARB_precision_hint_fastest
#include "BeautifyLum.cginc"
ENDCG
}
Pass { // 4
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vertBlurH
#pragma fragment fragBlur
#pragma target 3.0
#pragma fragmentoption ARB_precision_hint_fastest
#include "BeautifyLum.cginc"
ENDCG
}
Pass { // 5
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vertBlurV
#pragma fragment fragBlur
#pragma target 3.0
#pragma fragmentoption ARB_precision_hint_fastest
#include "BeautifyLum.cginc"
ENDCG
}
Pass { // 6 DoF CoC
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vert
#pragma fragment fragCoC
#pragma target 3.0
#pragma fragmentoption ARB_precision_hint_fastest
// Disabled by Shader Control: #pragma multi_compile __ BEAUTIFY_DEPTH_OF_FIELD_TRANSPARENT
#pragma multi_compile __ UNITY_COLORSPACE_GAMMA
#include "BeautifyDoF.cginc"
ENDCG
}
Pass { // 7 DoF CoC Debug
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vert
#pragma fragment fragCoCDebug
#pragma target 3.0
#pragma fragmentoption ARB_precision_hint_fastest
// Disabled by Shader Control: #pragma multi_compile __ BEAUTIFY_DEPTH_OF_FIELD_TRANSPARENT
#include "BeautifyDoF.cginc"
ENDCG
}
Pass { // 8 DoF Blur
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vert
#pragma fragment fragBlur
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
#include "BeautifyDoF.cginc"
ENDCG
}
Pass { // 9 Compute Screen Lum
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vert
#pragma fragment fragScreenLum
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
#pragma multi_compile __ UNITY_COLORSPACE_GAMMA
#include "BeautifyEA.cginc"
ENDCG
}
Pass { // 10 Reduce Screen Lum
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vertCross
#pragma fragment fragReduceScreenLum
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
#include "BeautifyEA.cginc"
ENDCG
}
Pass { // 11 Blend Screen Lum
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma vertex vert
#pragma fragment fragBlendScreenLum
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
#include "BeautifyEA.cginc"
ENDCG
}
Pass { // 12 Simple copy
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
// Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma vertex vert
#pragma fragment fragBlend
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
#include "BeautifyEA.cginc"
ENDCG
}
Pass { // 13 Bloom premul compose
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
Blend One One
CGPROGRAM
#pragma vertex vert
#pragma fragment fragCopy
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
#include "BeautifyLum.cginc"
ENDCG
}
Pass { // 14
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
Blend One One
CGPROGRAM
#pragma vertex vert
#pragma fragment fragResampleFastAF
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
#include "BeautifyLum.cginc"
ENDCG
}
Pass { // 15 DoF Blur wo/Bokeh
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vert
#pragma fragment fragBlurNoBokeh
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
#include "BeautifyDoF.cginc"
ENDCG
}
Pass { // 16 Sun Flares
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vert
#pragma fragment fragSFFast
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
#include "BeautifySF.cginc"
ENDCG
}
Pass { // 17 Sun Flares Additive
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vert
#pragma fragment fragSFFastAdditive
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
#include "BeautifySF.cginc"
ENDCG
}
Pass { // 18 Raw copy used in single blits with Single Pass Instanced
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vert
#pragma fragment fragCopy
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
#include "BeautifyLum.cginc"
ENDCG
}
}
FallBack Off
}
@@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: 7f163b29981e24a17b9cc00713070e43
timeCreated: 1465126706
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
-29
View File
@@ -1,29 +0,0 @@
#ifndef __BEAUTIFY_ORTHO
#define __BEAUTIFY_ORTHO
// Fix for Oculus GO & Stereo Rendering
#if SHADER_API_MOBILE && (defined(UNITY_STEREO_INSTANCING_ENABLED) || defined(UNITY_STEREO_MULTIVIEW_ENABLED))
//#define BEAUTIFY_GET_DEPTH_01(x) saturate(Linear01Depth(x))
//#define BEAUTIFY_GET_DEPTH_EYE(x) clamp(LinearEyeDepth(x), 0, _ProjectionParams.z)
#define BEAUTIFY_DEPTH_LOD(tex,uv) UNITY_SAMPLE_TEX2DARRAY_LOD(tex, float3((uv).xy, 0), (uv).w).r
#define BEAUTIFY_DEPTH(tex,uv) UNITY_SAMPLE_TEX2DARRAY(tex, float3((uv).x, (uv).y, 0)).r
#else
#define BEAUTIFY_DEPTH_LOD(tex,uv) SAMPLE_DEPTH_TEXTURE_LOD(tex, uv)
#define BEAUTIFY_DEPTH(tex,uv) SAMPLE_DEPTH_TEXTURE(tex, uv)
//#define BEAUTIFY_GET_DEPTH_01(x) Linear01Depth(x)
//#define BEAUTIFY_GET_DEPTH_EYE(x) LinearEyeDepth(x)
#endif
#if defined(BEAUTIFY_ORTHO)
#if UNITY_REVERSED_Z
#define Linear01Depth(x) (1.0-(x))
#define LinearEyeDepth(x) ((1.0-(x)) * _ProjectionParams.z)
#else
#define Linear01Depth(x) (x)
#define LinearEyeDepth(x) ((x) * _ProjectionParams.z)
#endif
#endif
#endif // __BEAUTIFY_ORTHO
-9
View File
@@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: 5ad73c29f6c734ba5a0916b50c13b146
timeCreated: 1488661131
licenseType: Free
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
-235
View File
@@ -1,235 +0,0 @@
#include "UnityCG.cginc"
#include "BeautifyAdvancedParams.cginc"
#include "BeautifyOrtho.cginc"
UNITY_DECLARE_SCREENSPACE_TEXTURE(_MainTex);
#if defined(BEAUTIFY_SUN_FLARES_OCCLUSION_DEPTH)
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
#endif
uniform sampler2D _FlareTex;
uniform float4 _MainTex_ST;
uniform float4 _MainTex_TexelSize;
uniform float4 _SunPos;
uniform float4 _SunData; // x = sunIntensity, y = disk size, z = ray difraction, w = ray difraction amount
uniform float4 _SunCoronaRays1; // x = length, y = streaks, z = spread, w = angle offset
uniform float4 _SunCoronaRays2; // x = length, y = streaks, z = spread, w = angle offset
uniform float4 _SunGhosts1; // x = reserved, y = size, 2 = pos offset, 3 = brightness
uniform float4 _SunGhosts2; // x = reserved, y = size, 2 = pos offset, 3 = brightness
uniform float4 _SunGhosts3; // x = reserved, y = size, 2 = pos offset, 3 = brightness
uniform float4 _SunGhosts4; // x = reserved, y = size, 2 = pos offset, 3 = brightness
uniform float3 _SunHalo; // x = offset, y = amplitude, z = intensity
uniform float3 _SunTint;
uniform float3 _SunPosRightEye;
struct appdata {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f {
float4 pos : SV_POSITION;
float2 uv: TEXCOORD0;
float2 uvNonStereo: TEXCOORD1;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert(appdata v) {
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = UnityObjectToClipPos(v.vertex);
o.uvNonStereo = v.texcoord;
o.uv = UnityStereoScreenSpaceUVAdjust(v.texcoord, _MainTex_ST);
return o;
}
void rotate(inout float2 uv, float ang) {
float2 sico;
sincos(ang, sico.x, sico.y);
float2 cosi = float2(sico.y, -sico.x);
uv = float2(dot(cosi, uv), dot(sico, uv));
}
float3 sunflare(float2 uv) {
// general params
float2 sunPos = unity_StereoEyeIndex == 0 ? _SunPos.xy : _SunPosRightEye.xy;
#if defined(BEAUTIFY_SUN_FLARES_OCCLUSION_DEPTH)
float4 depthSunPos = float4(sunPos, 0, 0);
#if UNITY_UV_STARTS_AT_TOP
if (_MainTex_TexelSize.y < 0) {
// Depth texture is inverted WRT the main texture
depthSunPos.y = 1.0 - depthSunPos.y;
}
#endif
//float depth = BEAUTIFY_GET_DEPTH_01(UNITY_SAMPLE_DEPTH(SAMPLE_RAW_DEPTH_TEXTURE_LOD(_CameraDepthTexture, depthSunPos)));
float depth = Linear01Depth(BEAUTIFY_DEPTH_LOD(_CameraDepthTexture, depthSunPos));
if (depth<1) return 0;
#endif
float2 grd = uv - sunPos;
float aspectRatio = _ScreenParams.y / _ScreenParams.x;
grd.y *= aspectRatio;
float len = length(grd);
// sun disk
float s0 = pow( 1.0 + saturate(_SunData.y - len), 75) - 1.0;
// corona rays
float gang = _SunPos.w; //atan2(0.5 - sunPos.y, sunPos.x - 0.5);
float ang = atan2(grd.y, grd.x) + gang;
float ray1 = _SunCoronaRays1.z + abs(_SunCoronaRays1.x * cos(_SunCoronaRays1.w + ang * _SunCoronaRays1.y)); // design
ray1 *= pow( 1.0 + len, 1.0/_SunCoronaRays1.x);
s0 += 1.0 / ray1;
float ray2 = _SunCoronaRays2.z + abs(_SunCoronaRays2.x * sin(_SunCoronaRays2.w + ang * _SunCoronaRays2.y)); // design
ray2 *= pow( 1.0 + len, 1.0/_SunCoronaRays2.x);
s0 += 1.0 / ray2;
s0 *= _SunData.x;
// ghosts hexagonal
// float gang = atan2( (sunPos.y * _ScreenParams.y / _ScreenParams.x) - 0.5, sunPos.x - 0.5); // this angle should be passed by uniform
// grd = uv - ghost1Pos + (ghost1Pos - 0.5) * ghost1PosOffset;
// grd.y *= _ScreenParams.y / _ScreenParams.x;
// rotate(grd, gang);
// grd *= ghost1Size;
// s0 += tex2D(_FlareTex, grd + 0.5.xx).r * ghost1Brighness;
//
// grd = uv - ghost2Pos + (ghost2Pos - 0.5) * ghost2PosOffset;
// grd.y *= _ScreenParams.y / _ScreenParams.x;
// rotate(grd, gang);
// grd *= ghost2Size;
// s0 += tex2D(_FlareTex, grd + 0.5.xx).r * ghost2Brighness;
float3 flare = s0.xxx;
// ghosts circular
float2 ghost1Pos = 1.0 - sunPos;
grd = uv - ghost1Pos + (ghost1Pos - 0.5) * _SunGhosts1.z;
grd.y *= aspectRatio;
float g0 = saturate(_SunGhosts1.y / length(grd));
g0 = pow(g0, 12);
flare += g0 * _SunGhosts1.w / len;
float2 ghost2Pos = 1.0 - sunPos;
grd = uv - ghost2Pos + (ghost2Pos - 0.5) * _SunGhosts2.z;
grd.y *= aspectRatio;
g0 = saturate(_SunGhosts2.y / length(grd));
g0 = pow(g0, 12);
flare += g0 * _SunGhosts2.w / len;
float2 ghost3Pos = 1.0 - sunPos;
grd = uv - ghost3Pos + (ghost3Pos - 0.5) * _SunGhosts3.z;
grd.y *= aspectRatio;
g0 = saturate(_SunGhosts3.y / length(grd));
g0 = pow(g0, 12);
flare += g0 * _SunGhosts3.w / len;
float2 ghost4Pos = 1.0 - sunPos;
grd = uv - ghost4Pos + (ghost4Pos - 0.5) * _SunGhosts4.z;
grd.y *= aspectRatio;
g0 = saturate(_SunGhosts4.y / length(grd));
g0 = pow(g0, 12);
flare += g0 * _SunGhosts4.w / len;
// light rays
float2 uv2 = uv - sunPos;
float clen = length(uv2);
rotate(uv2, gang);
uv2.x *= aspectRatio;
uv2.x *= 0.1;
uv2 /= len;
float lr = saturate(tex2D(_FlareTex, uv2 + _SunPos.zz).r - _SunData.w);
float3 rays = lr * sin(float3(len, len + 0.1, len + 0.2) * 3.1415927);
float atten = pow(1.0 + clen, 13.0);
rays *= _SunData.z / atten;
flare += rays;
// halo
float hlen = clamp( (len - _SunHalo.x) * _SunHalo.y, 0, 3.1415927);
float3 halo = pow(sin(float3(hlen, hlen + 0.1, hlen + 0.2)), 12.0.xxx);
halo *= _SunHalo.z / atten;
flare += halo;
return flare * _SunTint;
}
float3 sunflareFast(float2 uv) {
// general params
float2 sunPos = unity_StereoEyeIndex == 0 ? _SunPos.xy : _SunPosRightEye.xy;
float2 grd = uv - sunPos;
float aspectRatio = _ScreenParams.y / _ScreenParams.x;
grd.y *= aspectRatio;
float len = length(grd);
// corona rays
float ang = atan2(grd.y, grd.x);
float ray1 = _SunCoronaRays1.z + abs(_SunCoronaRays1.x * cos(_SunCoronaRays1.w + ang * _SunCoronaRays1.y)); // design
ray1 *= pow( 1.0 + len, 1.0/_SunCoronaRays1.x);
float s0 = 1.0 / ray1;
s0 *= _SunData.x;
float3 flare = s0.xxx;
// ghosts circular
float2 ghost1Pos = 1.0 - sunPos;
grd = uv - ghost1Pos + (ghost1Pos - 0.5) * _SunGhosts1.z;
grd.y *= aspectRatio;
float g0 = saturate(_SunGhosts1.y / length(grd));
g0 = pow(g0, 12);
flare += g0 * _SunGhosts1.w / len;
float2 ghost2Pos = 1.0 - sunPos;
grd = uv - ghost2Pos + (ghost2Pos - 0.5) * _SunGhosts2.z;
grd.y *= aspectRatio;
g0 = saturate(_SunGhosts2.y / length(grd));
g0 = pow(g0, 12);
flare += g0 * _SunGhosts2.w / len;
// halo
float hlen = clamp( (len - _SunHalo.x) * _SunHalo.y, 0, 3.1415927);
float3 halo = pow(sin(float3(hlen, hlen + 0.1, hlen + 0.2)), 12.0.xxx);
float clen = length(uv - 0.5.xx);
float atten = pow(1.0 + clen, 13.0);
halo *= _SunHalo.z / atten;
flare += halo;
return flare * _SunTint;
}
float4 fragSF (v2f i) : SV_Target {
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
return float4(sunflare(i.uvNonStereo), 1.0);
}
float4 fragSFAdditive (v2f i) : SV_Target {
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
float4 p = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv);
return p + float4(sunflare(i.uvNonStereo), 1.0);
}
float4 fragSFFast (v2f i) : SV_Target {
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
return float4(sunflareFast(i.uvNonStereo), 1.0);
}
float4 fragSFFastAdditive (v2f i) : SV_Target {
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
float4 p = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv);
return p + float4(sunflareFast(i.uvNonStereo), 1.0);
}
-9
View File
@@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: 4dd4f0cb023a74ec0afce3ad10c6a013
timeCreated: 1488661131
licenseType: Free
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant: