Add beautify post process to project
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
#ifndef BEAUTIFY_AA_FX
|
||||
#define BEAUTIFY_AA_FX
|
||||
|
||||
float4 _AntialiasData;
|
||||
#define ANTIALIAS_STRENGTH _AntialiasData.x
|
||||
#define ANTIALIAS_THRESHOLD _AntialiasData.y
|
||||
#define ANTIALIAS_DEPTH_ATTEN _AntialiasData.z
|
||||
#define ANTIALIAS_CLAMP _AntialiasData.w
|
||||
|
||||
float3 ApplyEdgeAA(float2 uv, float3 rgbM, float dDepth, float depthCenter, float lumaN, float lumaS, float lumaW, float lumaE, float minLuma, float maxLuma, float2 texelSize) {
|
||||
float2 gradient = float2(lumaN - lumaS, lumaW - lumaE);
|
||||
float2 absGradient = abs(gradient);
|
||||
float gradientAmp = max(absGradient.x, absGradient.y) + 1e-5;
|
||||
float2 dir = gradient / gradientAmp;
|
||||
float sampleRadius = min(gradientAmp * ANTIALIAS_STRENGTH, ANTIALIAS_CLAMP);
|
||||
float2 n = dir * sampleRadius;
|
||||
float antialiasDepthAtten = 1.0 - saturate(depthCenter * ANTIALIAS_DEPTH_ATTEN);
|
||||
n *= texelSize * antialiasDepthAtten;
|
||||
|
||||
float3 rgbA = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv - n * 0.166667).rgb + SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv + n * 0.166667).rgb;
|
||||
float3 rgbB = 0.25 * (rgbA + SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv - n * 0.5).rgb + SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv + n * 0.5).rgb);
|
||||
float lumaB = getLuma(rgbB);
|
||||
if (lumaB < minLuma || lumaB > maxLuma) rgbB = rgbA * 0.5;
|
||||
|
||||
return rgbB;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 76a62ec60ec8e4611859a7a93049e981
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,55 @@
|
||||
// This file "BeautifyACESFitted.hlsl" is covered by MIT license as follows:
|
||||
//
|
||||
//=================================================================================================
|
||||
//
|
||||
// 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. :)
|
||||
|
||||
#ifndef BEAUTIFY_ACES_FITTED
|
||||
#define BEAUTIFY_ACES_FITTED
|
||||
|
||||
// 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 val)
|
||||
{
|
||||
val = mul(ACESInputMat, val);
|
||||
|
||||
// Apply RRT and ODT
|
||||
val = RRTAndODTFit(val);
|
||||
|
||||
val = mul(ACESOutputMat, val);
|
||||
|
||||
// Clamp to [0, 1]
|
||||
//val = saturate(val);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
#endif // BEAUTIFY_ACES_FITTED
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2a60bf244efbd4a2cb2d66d73177f740
|
||||
timeCreated: 1517506872
|
||||
licenseType: Pro
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,96 @@
|
||||
// This file (BeautifyAGX.hlsl) is covered by MIT license as follows:
|
||||
//
|
||||
// MIT License
|
||||
//
|
||||
// Copyright (c) 2024 Missing Deadlines (Benjamin Wrensch)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright and this permission shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// All values used to derive this implementation are sourced from Troy’s initial AgX implementation/OCIO config file available here:
|
||||
// https://github.com/sobotka/AgX
|
||||
// Adaptation to HLSL for Unity by Kronnect
|
||||
|
||||
#ifndef BEAUTIFY_AGX
|
||||
#define BEAUTIFY_AGX
|
||||
|
||||
float _TonemapAGXGamma;
|
||||
|
||||
static const float3x3 agx_mat = float3x3(
|
||||
0.842479062253094, 0.0784335999999992, 0.0792237451477643,
|
||||
0.0423282422610123, 0.878468636469772, 0.0791661274605434,
|
||||
0.0423756549057051, 0.0784336, 0.879142973793104);
|
||||
|
||||
static const float3x3 agx_mat_inv = float3x3(
|
||||
1.19687900512017, -0.0980208811401368, -0.0990297440797205,
|
||||
-0.0528968517574562, 1.15190312990417, -0.0989611768448433,
|
||||
-0.0529716355144438, -0.0980434501171241, 1.15107367264116);
|
||||
|
||||
// Mean error^2: 3.6705141e-06
|
||||
float3 agxDefaultContrastApprox(float3 x) {
|
||||
float3 x2 = x * x;
|
||||
float3 x4 = x2 * x2;
|
||||
|
||||
return 15.5 * x4 * x2
|
||||
- 40.14 * x4 * x
|
||||
+ 31.96 * x4
|
||||
- 6.868 * x2 * x
|
||||
+ 0.4298 * x2
|
||||
+ 0.1191 * x
|
||||
- 0.00232;
|
||||
}
|
||||
|
||||
|
||||
float3 agx(float3 val) {
|
||||
|
||||
const float min_ev = -12.47393f;
|
||||
const float max_ev = 4.026069f;
|
||||
|
||||
// Input transform (inset)
|
||||
val = mul(agx_mat, val);
|
||||
|
||||
// Log2 space encoding
|
||||
val = clamp(log2(val), min_ev, max_ev);
|
||||
val = (val - min_ev) / (max_ev - min_ev);
|
||||
|
||||
// Apply sigmoid function approximation
|
||||
val = agxDefaultContrastApprox(val);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
float3 agxEotf(float3 val) {
|
||||
|
||||
// Inverse input transform (outset)
|
||||
val = mul(agx_mat_inv, val);
|
||||
|
||||
// sRGB IEC 61966-2-1 2.2 Exponent Reference EOTF Display
|
||||
// NOTE: We're linearizing the output here. Comment/adjust when
|
||||
// *not* using a sRGB render target
|
||||
val = pow(val, _TonemapAGXGamma);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
float3 AGXFitted(float3 value) {
|
||||
value = agx(value);
|
||||
value = agxEotf(value);
|
||||
return value;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f1496f614c1d5445583417c070512078
|
||||
timeCreated: 1517506872
|
||||
licenseType: Pro
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef BEAUTIFY_CABERRATION_INCLUDE
|
||||
#define BEAUTIFY_CABERRATION_INCLUDE
|
||||
|
||||
// Copyright 2020-2021 Kronnect - All Rights Reserved.
|
||||
#include "BeautifyCommon.hlsl"
|
||||
|
||||
TEXTURE2D_X(_MainTex);
|
||||
SAMPLER(sampler_MainTex);
|
||||
float4 _MainTex_TexelSize;
|
||||
|
||||
#include "BeautifyDistortion.hlsl"
|
||||
|
||||
float4 fragChromaticAberration (VaryingsSimple i) : SV_Target {
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
i.uv = UnityStereoTransformScreenSpaceTex(i.uv);
|
||||
float4 pixel = GetDistortedColor(i.uv);
|
||||
return pixel;
|
||||
}
|
||||
|
||||
|
||||
#endif // BEAUTIFY_CABERRATION_INCLUDE
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1fff09f3f51e64815b1cf93c283fb99a
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,28 @@
|
||||
#ifndef BEAUTIFY_COLOR_TEMP
|
||||
#define BEAUTIFY_COLOR_TEMP
|
||||
|
||||
const float LuminancePreservationFactor = 1.0;
|
||||
|
||||
const float PI2 = 6.2831853071;
|
||||
|
||||
// kelvin = { 1000 - 40000 }
|
||||
float3 KelvinToRGB(float kelvin) {
|
||||
const float3x3 cold = float3x3(float3(0.0, -2902.1955373783176, -8257.7997278925690),
|
||||
float3(0.0, 1669.5803561666639, 2575.2827530017594),
|
||||
float3(1.0, 1.3302673723350029, 1.8993753891711275));
|
||||
const float3x3 hot = float3x3(float3(0.0, -2902.1955373783176, -8257.7997278925690),
|
||||
float3(0.0, 1669.5803561666639, 2575.2827530017594),
|
||||
float3(1.0, 1.3302673723350029, 1.8993753891711275));
|
||||
|
||||
float3x3 m = (kelvin <= 6500.0) ? cold : hot;
|
||||
|
||||
float3 m0 = float3(m[0][0], m[0][1], m[0][2]);
|
||||
float3 m1 = float3(m[1][0], m[1][1], m[1][2]);
|
||||
float3 m2 = float3(m[2][0], m[2][1], m[2][2]);
|
||||
float3 cm = lerp(( m0 / (clamp(kelvin, 1000.0, 40000.0).xxx + m1) + m2),
|
||||
1.0.xxx,
|
||||
smoothstep(1000.0, 0.0, kelvin));
|
||||
return cm;
|
||||
}
|
||||
|
||||
#endif // BEAUTIFY_COLOR_TEMP
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 01837ee01fce64c8db5624c139e32ac5
|
||||
timeCreated: 1517506872
|
||||
licenseType: Pro
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,158 @@
|
||||
#ifndef __BEAUTIFY_COMMON_INCLUDE
|
||||
#define __BEAUTIFY_COMMON_INCLUDE
|
||||
|
||||
// Set to 1 to support orthographic mode
|
||||
#define BEAUTIFY_ORTHO 0
|
||||
|
||||
// Set to 1 to enable Sobel outline
|
||||
#define BEAUTIFY_OUTLINE_SOBEL 0
|
||||
|
||||
// Set to 1 to enable alternate chromatic aberration method
|
||||
#define BEAUTIFY_CABERRATION_ALT 0
|
||||
|
||||
// Set to 1 to use legacy eye adaptation mode
|
||||
#define BEAUTIFY_EA_LEGACY_MODE 0
|
||||
|
||||
TEXTURE2D(_BlueNoise);
|
||||
float4 _BlueNoise_TexelSize;
|
||||
|
||||
TEXTURE2D_X_FLOAT(_CameraDepthTexture);
|
||||
SAMPLER(sampler_CameraDepthTexture);
|
||||
|
||||
float HighPrecisionSampleSceneDepth(float2 uvStereo)
|
||||
{
|
||||
return SAMPLE_TEXTURE2D_X(_CameraDepthTexture, sampler_CameraDepthTexture, uvStereo).r;
|
||||
}
|
||||
|
||||
|
||||
#if BEAUTIFY_ORTHO
|
||||
#if UNITY_REVERSED_Z
|
||||
#define BEAUTIFY_GET_DEPTH_01(x) (1.0-x)
|
||||
#define BEAUTIFY_GET_DEPTH_EYE(x) ((1.0-x) * _ProjectionParams.z)
|
||||
|
||||
#define BEAUTIFY_GET_SCENE_DEPTH_01(x) (1.0 - HighPrecisionSampleSceneDepth(x))
|
||||
#define BEAUTIFY_GET_SCENE_DEPTH_EYE(x) ((1.0 - HighPrecisionSampleSceneDepth(x)) * _ProjectionParams.z)
|
||||
|
||||
#define BEAUTIFY_GET_CUSTOM_DEPTH_01(s, x) (1.0 - SAMPLE_TEXTURE2D_X(s, sampler_PointClamp, x).r)
|
||||
#else
|
||||
#define BEAUTIFY_GET_DEPTH_01(x) (x)
|
||||
#define BEAUTIFY_GET_DEPTH_EYE(x) (x * _ProjectionParams.z)
|
||||
|
||||
#define BEAUTIFY_GET_SCENE_DEPTH_01(x) HighPrecisionSampleSceneDepth(x)
|
||||
#define BEAUTIFY_GET_SCENE_DEPTH_EYE(x) (HighPrecisionSampleSceneDepth(x) * _ProjectionParams.z)
|
||||
|
||||
#define BEAUTIFY_GET_CUSTOM_DEPTH_01(s, x) SAMPLE_TEXTURE2D_X(s, sampler_PointClamp, x).r
|
||||
#endif
|
||||
#else
|
||||
#define BEAUTIFY_GET_DEPTH_01(x) Linear01Depth(x, _ZBufferParams)
|
||||
#define BEAUTIFY_GET_DEPTH_EYE(x) LinearEyeDepth(x, _ZBufferParams)
|
||||
|
||||
#define BEAUTIFY_GET_SCENE_DEPTH_01(x) Linear01Depth(HighPrecisionSampleSceneDepth(x), _ZBufferParams)
|
||||
#define BEAUTIFY_GET_SCENE_DEPTH_EYE(x) LinearEyeDepth(HighPrecisionSampleSceneDepth(x), _ZBufferParams)
|
||||
|
||||
#define BEAUTIFY_GET_CUSTOM_DEPTH_01(s, x) Linear01Depth(SAMPLE_TEXTURE2D_X(s, sampler_PointClamp, x).r, _ZBufferParams)
|
||||
#endif
|
||||
|
||||
|
||||
// Base for COC - required for Android
|
||||
#define COC_BASE 128
|
||||
|
||||
|
||||
// Optimization for SSPR
|
||||
#define uvN uv1
|
||||
#define uvE uv2
|
||||
#define uvW uv3
|
||||
#define uvS uv4
|
||||
|
||||
|
||||
#if defined(UNITY_STEREO_INSTANCING_ENABLED) || defined(UNITY_STEREO_MULTIVIEW_ENABLED) || defined(SINGLE_PASS_STEREO)
|
||||
#define BEAUTIFY_VERTEX_CROSS_UV_DATA
|
||||
#define BEAUTIFY_VERTEX_OUTPUT_CROSS_UV(o)
|
||||
#define BEAUTIFY_VERTEX_OUTPUT_GAUSSIAN_UV(o)
|
||||
|
||||
#define BEAUTIFY_FRAG_SETUP_CROSS_UV(i) float3 uvInc = float3(_MainTex_TexelSize.x, _MainTex_TexelSize.y, 0); float2 uvN = i.uv + uvInc.zy; float2 uvE = i.uv + uvInc.xz; float2 uvW = i.uv - uvInc.xz; float2 uvS = i.uv - uvInc.zy;
|
||||
|
||||
#if defined(BEAUTIFY_BLUR_HORIZ)
|
||||
#define BEAUTIFY_FRAG_SETUP_GAUSSIAN_UV(i) float2 inc = float2(_MainTex_TexelSize.x * 1.3846153846 * _BlurScale, 0); float2 uv1 = i.uv - inc; float2 uv2 = i.uv + inc; float2 inc2 = float2(_MainTex_TexelSize.x * 3.2307692308 * _BlurScale, 0); float2 uv3 = i.uv - inc2; float2 uv4 = i.uv + inc2;
|
||||
#else
|
||||
#define BEAUTIFY_FRAG_SETUP_GAUSSIAN_UV(i) float2 inc = float2(0, _MainTex_TexelSize.y * 1.3846153846 * _BlurScale); float2 uv1 = i.uv - inc; float2 uv2 = i.uv + inc; float2 inc2 = float2(0, _MainTex_TexelSize.y * 3.2307692308 * _BlurScale); float2 uv3 = i.uv - inc2; float2 uv4 = i.uv + inc2;
|
||||
#endif
|
||||
|
||||
#else
|
||||
#define BEAUTIFY_VERTEX_CROSS_UV_DATA float2 uvN : TEXCOORD1; float2 uvW: TEXCOORD2; float2 uvE: TEXCOORD3; float2 uvS: TEXCOORD4;
|
||||
|
||||
#define BEAUTIFY_VERTEX_OUTPUT_CROSS_UV(o) float3 uvInc = float3(_MainTex_TexelSize.x, _MainTex_TexelSize.y, 0); o.uvN = o.uv + uvInc.zy; o.uvE = o.uv + uvInc.xz; o.uvW = o.uv - uvInc.xz; o.uvS = o.uv - uvInc.zy;
|
||||
#define BEAUTIFY_FRAG_SETUP_CROSS_UV(i) float2 uv1 = i.uv1; float2 uv2 = i.uv2; float2 uv3 = i.uv3; float2 uv4 = i.uv4;
|
||||
|
||||
#if defined(BEAUTIFY_BLUR_HORIZ)
|
||||
#define BEAUTIFY_VERTEX_OUTPUT_GAUSSIAN_UV(o) float2 inc = float2(_MainTex_TexelSize.x * 1.3846153846 * _BlurScale, 0); o.uv1 = o.uv - inc; o.uv2 = o.uv + inc; float2 inc2 = float2(_MainTex_TexelSize.x * 3.2307692308 * _BlurScale, 0); o.uv3 = o.uv - inc2; o.uv4 = o.uv + inc2;
|
||||
#else
|
||||
#define BEAUTIFY_VERTEX_OUTPUT_GAUSSIAN_UV(o) float2 inc = float2(0, _MainTex_TexelSize.y * 1.3846153846 * _BlurScale); o.uv1 = o.uv - inc; o.uv2 = o.uv + inc; float2 inc2 = float2(0, _MainTex_TexelSize.y * 3.2307692308 * _BlurScale); o.uv3 = o.uv - inc2; o.uv4 = o.uv + inc2;
|
||||
#endif
|
||||
#define BEAUTIFY_FRAG_SETUP_GAUSSIAN_UV(i) float2 uv1 = i.uv1; float2 uv2 = i.uv2; float2 uv3 = i.uv3; float2 uv4 = i.uv4;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if BEAUTIFY_TURBO
|
||||
#define GAMMA_TO_LINEAR(x) FastSRGBToLinear(x)
|
||||
#define LINEAR_TO_GAMMA(x) FastLinearToSRGB(x)
|
||||
#else
|
||||
#define GAMMA_TO_LINEAR(x) SRGBToLinear(x)
|
||||
#define LINEAR_TO_GAMMA(x) LinearToSRGB(x)
|
||||
#endif
|
||||
|
||||
|
||||
// Common functions
|
||||
|
||||
float _FlipY;
|
||||
|
||||
struct AttributesSimple
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
|
||||
struct VaryingsSimple
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
VaryingsSimple VertOS(AttributesSimple input) {
|
||||
VaryingsSimple output;
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
output.positionCS = input.positionOS;
|
||||
output.positionCS.y *= _ProjectionParams.x * _FlipY;
|
||||
output.uv = input.uv;
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
inline float getLuma(float3 rgb) {
|
||||
//const float3 lum = float3(0.2627, 0.6780, 0.0593); // Rec.2020 (HDR/wide gamut)
|
||||
//const float3 lum = float3(0.2126, 0.7152, 0.0722); // Rec709 (sRGB/HD)
|
||||
const float3 lum = float3(0.299, 0.587, 0.114); // Rec601 (SD/broadcast)
|
||||
return dot(rgb, lum);
|
||||
}
|
||||
|
||||
|
||||
inline 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);
|
||||
}
|
||||
|
||||
inline float getSaturation(float3 rgb) {
|
||||
float maxVal = max(max(rgb.r, rgb.g), rgb.b);
|
||||
float minVal = min(min(rgb.r, rgb.g), rgb.b);
|
||||
float delta = maxVal - minVal;
|
||||
return delta / max(maxVal, 0.0001);
|
||||
}
|
||||
|
||||
#endif // __BEAUTIFY_COMMON_INCLUDE
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 911431f45704646a990da305cf54bd45
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,590 @@
|
||||
#ifndef BEAUTIFY_CORE_FX
|
||||
#define BEAUTIFY_CORE_FX
|
||||
|
||||
#pragma warning (disable : 3571)
|
||||
|
||||
TEXTURE2D_X(_MainTex);
|
||||
SAMPLER(sampler_MainTex);
|
||||
float4 _MainTex_TexelSize;
|
||||
|
||||
#include "BeautifyACESFitted.hlsl"
|
||||
#include "BeautifyAGX.hlsl"
|
||||
#include "BeautifyColorTemp.hlsl"
|
||||
#include "BeautifyDistortion.hlsl"
|
||||
#include "BeautifyCommon.hlsl"
|
||||
#include "BeautifyPPSFilmGrain.hlsl"
|
||||
|
||||
// Copyright 2020-2021 Ramiro Oliva (Kronnect) - All Rights Reserved.
|
||||
float4 _CompareParams;
|
||||
TEXTURE2D_X(_CompareTex);
|
||||
TEXTURE2D_X(_BloomTex);
|
||||
TEXTURE2D_X(_ScreenLum);
|
||||
TEXTURE2D(_OverlayTex);
|
||||
TEXTURE2D(_LUTTex);
|
||||
TEXTURE3D(_LUT3DTex);
|
||||
TEXTURE2D_X(_EAHist);
|
||||
TEXTURE2D_X(_EALumSrc);
|
||||
TEXTURE2D_X(_BlurTex);
|
||||
TEXTURE2D(_BlurMask);
|
||||
float4 _BlurData;
|
||||
float4 _BlurData2;
|
||||
|
||||
#define BLUR_CENTER _BlurData.xy
|
||||
#define BLUR_WIDTH _BlurData.z
|
||||
#define BLUR_FALLOFF _BlurData.w
|
||||
#define BLUR_STYLE (int)_BlurData2.x
|
||||
#define BLUR_SHOW_MASK _BlurData2.y
|
||||
|
||||
TEXTURE2D_X(_MiniViewTex);
|
||||
float4 _MiniViewRect;
|
||||
float4 _MiniViewBlend;
|
||||
|
||||
float4 _Params;
|
||||
float4 _Sharpen;
|
||||
float4 _Bloom;
|
||||
float4 _Dirt; // x = brightness based, y = intensity, z = threshold, w = bloom contribution
|
||||
float4 _FXColor;
|
||||
float4 _ColorBoost;
|
||||
float4 _TintColor;
|
||||
float4 _Purkinje;
|
||||
float4 _EyeAdaptation;
|
||||
float4 _EyeAdaptation2; // x: center weight, y: min camera distance, z: middle gray, w: unused
|
||||
float4 _BokehData;
|
||||
float4 _BokehData2;
|
||||
float3 _BokehData3;
|
||||
|
||||
float4 _Outline;
|
||||
#define OUTLINE_EDGE_THRESHOLD _Outline.a
|
||||
|
||||
float4 _OutlineData;
|
||||
#define OUTLINE_INTENSITY_MULTIPLIER _OutlineData.x
|
||||
#define OUTLINE_DISTANCE_FADE _OutlineData.y
|
||||
#define OUTLINE_MIN_DEPTH_THRESHOLD _OutlineData.z
|
||||
#define OUTLINE_MIN_SATURATION_THRESHOLD _OutlineData.w
|
||||
|
||||
float3 _ColorTemp;
|
||||
float4 _NightVision;
|
||||
float2 _NightVisionDepth;
|
||||
float4 _LUTTex_TexelSize;
|
||||
float2 _LUT3DParams;
|
||||
|
||||
#if BEAUTIFY_VIGNETTING || BEAUTIFY_VIGNET_MASK
|
||||
float4 _Vignetting;
|
||||
float4 _VignettingData;
|
||||
float _VignettingData2;
|
||||
#define VIGNETTE_ASPECT_RATIO_Y _VignettingData.z
|
||||
#define VIGNETTE_CENTER _VignettingData.xy
|
||||
#define VIGNETTE_OUTER_RING _VignettingData.w
|
||||
#define VIGNETTE_FADE_AND_BLINK _Purkinje.z
|
||||
#define VIGNETTE_INNER_RING _Purkinje.w
|
||||
#define VIGNETTE_ASPECT_RATIO_X _VignettingData2
|
||||
TEXTURE2D_X(_VignettingMask);
|
||||
#endif
|
||||
|
||||
#if BEAUTIFY_FRAME
|
||||
TEXTURE2D_X(_FrameMask);
|
||||
float4 _Frame;
|
||||
float4 _FrameData;
|
||||
#endif
|
||||
|
||||
#if BEAUTIFY_DOF_TRANSPARENT || BEAUTIFY_DEPTH_OF_FIELD
|
||||
TEXTURE2D_X(_DoFTex);
|
||||
float4 _DoFTex_TexelSize;
|
||||
#endif
|
||||
#if BEAUTIFY_DOF_TRANSPARENT
|
||||
TEXTURE2D_X(_DoFTransparentDepth);
|
||||
//TEXTURE2D_X(_DofExclusionTexture;
|
||||
#endif
|
||||
|
||||
#if BEAUTIFY_EDGE_AA
|
||||
#include "BeautifyAA.hlsl"
|
||||
#endif
|
||||
|
||||
#if BEAUTIFY_EXCLUSION_MASK_SHARPEN
|
||||
TEXTURE2D_X(_SharpenExclusionMask);
|
||||
#endif
|
||||
|
||||
|
||||
struct VaryingsBeautify {
|
||||
float4 positionCS : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
BEAUTIFY_VERTEX_CROSS_UV_DATA
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
|
||||
VaryingsBeautify VertBeautify(AttributesSimple input) {
|
||||
VaryingsBeautify output;
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
output.positionCS = input.positionOS;
|
||||
output.positionCS.y *= _ProjectionParams.x * _FlipY;
|
||||
output.uv = input.uv.xy;
|
||||
BEAUTIFY_VERTEX_OUTPUT_CROSS_UV(output)
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
float getRandom(float2 uv) {
|
||||
return frac(sin(_Time.y + dot(uv, float2(12.9898, 78.233)))* 43758.5453);
|
||||
}
|
||||
|
||||
|
||||
float getCoc(VaryingsBeautify i) {
|
||||
#if BEAUTIFY_DOF_TRANSPARENT
|
||||
float depthTex = BEAUTIFY_GET_CUSTOM_DEPTH_01(_DoFTransparentDepth, i.uv);
|
||||
//float exclusionDepth = DecodeFloatRGBA(SAMPLE_TEXTURE2D_LOD(_DofExclusionTexture, sampler_DoFExclusionTexture, i.uv, 0));
|
||||
float depth = BEAUTIFY_GET_SCENE_DEPTH_01(i.uv);
|
||||
depth = min(depth, depthTex);
|
||||
//if (exclusionDepth < depth) return 0;
|
||||
depth *= _ProjectionParams.z;
|
||||
#else
|
||||
float depth = BEAUTIFY_GET_SCENE_DEPTH_EYE(i.uv);
|
||||
#endif
|
||||
float xd = abs(depth - _BokehData.x) - _BokehData2.x * (depth < _BokehData.x);
|
||||
return min(_BokehData3.z, 0.5 * _BokehData.y * xd/depth); // radius of CoC
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void beautifyPass(VaryingsBeautify i, inout float3 rgbM) {
|
||||
|
||||
#if BEAUTIFY_ACES_TONEMAP || BEAUTIFY_AGX_TONEMAP || BEAUTIFY_ACES_FITTED_TONEMAP
|
||||
rgbM = clamp(rgbM, 0, _FXColor.z);
|
||||
#endif
|
||||
|
||||
float2 uv = i.uv;
|
||||
BEAUTIFY_FRAG_SETUP_CROSS_UV(i)
|
||||
|
||||
float depthS = BEAUTIFY_GET_SCENE_DEPTH_01(uvS);
|
||||
float depthW = BEAUTIFY_GET_SCENE_DEPTH_01(uvW);
|
||||
float depthE = BEAUTIFY_GET_SCENE_DEPTH_01(uvE);
|
||||
float depthN = BEAUTIFY_GET_SCENE_DEPTH_01(uvN);
|
||||
|
||||
// neighbour depth analysis
|
||||
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;
|
||||
|
||||
// luma analysis
|
||||
float3 rgbS = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uvS).rgb;
|
||||
float3 rgbW = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uvW).rgb;
|
||||
float3 rgbE = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uvE).rgb;
|
||||
float3 rgbN = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uvN).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);
|
||||
#if !BEAUTIFY_TURBO
|
||||
maxLuma = max(maxLuma, lumaE);
|
||||
#endif
|
||||
float minLuma = min(lumaN,lumaS);
|
||||
minLuma = min(minLuma, lumaW);
|
||||
#if !BEAUTIFY_TURBO
|
||||
minLuma = min(minLuma, lumaE);
|
||||
#endif
|
||||
minLuma -= 0.000001;
|
||||
|
||||
#if BEAUTIFY_EDGE_AA
|
||||
if (dDepth > ANTIALIAS_THRESHOLD) {
|
||||
rgbM = ApplyEdgeAA(uv, rgbM, dDepth, depthN, lumaN, lumaS, lumaW, lumaE, minLuma, maxLuma, _MainTex_TexelSize.xy);
|
||||
}
|
||||
#endif
|
||||
|
||||
float lumaM = getLuma(rgbM);
|
||||
|
||||
// daltonize
|
||||
#if BEAUTIFY_COLOR_TWEAKS
|
||||
float3 rgb0 = 1.0.xxx - saturate(rgbM.rgb);
|
||||
rgbM.r *= 1.0 + rgbM.r * rgb0.g * rgb0.b * _Params.y;
|
||||
rgbM.g *= 1.0 + rgbM.g * rgb0.r * rgb0.b * _Params.y;
|
||||
rgbM.b *= 1.0 + rgbM.b * rgb0.r * rgb0.g * _Params.y;
|
||||
rgbM *= lumaM / (getLuma(rgbM) + 0.0001);
|
||||
#endif
|
||||
|
||||
// sharpen
|
||||
#if BEAUTIFY_TURBO
|
||||
const float lumaDepth = 1.0;
|
||||
#else
|
||||
float lumaDepth = saturate( _Sharpen.y / max(dDepth, 0.000001));
|
||||
#endif
|
||||
|
||||
float lumaPower = 2.0 * lumaM - minLuma - maxLuma;
|
||||
float lumaAtten = saturate(_Sharpen.w / (maxLuma - minLuma));
|
||||
#if BEAUTIFY_TURBO
|
||||
const float depthClamp = 1.0;
|
||||
#else
|
||||
float depthClamp = abs(depthW - _Params.z) < _Params.w;
|
||||
#endif
|
||||
|
||||
#if BEAUTIFY_SHARPEN || BEAUTIFY_EXCLUSION_MASK_SHARPEN
|
||||
float sharpenAmount = clamp(lumaPower * lumaAtten * lumaDepth * _Sharpen.x, -_Sharpen.z, _Sharpen.z) * depthClamp;
|
||||
#if BEAUTIFY_EXCLUSION_MASK_SHARPEN
|
||||
float3 sharpenMask = SAMPLE_TEXTURE2D_X(_SharpenExclusionMask, sampler_LinearClamp, i.uv).rgb;
|
||||
if (any(sharpenMask != 0)) sharpenAmount = 0;
|
||||
#endif
|
||||
rgbM *= 1.0 + sharpenAmount;
|
||||
#endif
|
||||
|
||||
#if BEAUTIFY_DEPTH_OF_FIELD || BEAUTIFY_DOF_TRANSPARENT
|
||||
float4 dofPix = SAMPLE_TEXTURE2D_X(_DoFTex, sampler_LinearClamp, i.uv);
|
||||
#if UNITY_COLORSPACE_GAMMA
|
||||
dofPix.rgb = LINEAR_TO_GAMMA(dofPix.rgb);
|
||||
#endif
|
||||
if (_DoFTex_TexelSize.z < _MainTex_TexelSize.z) {
|
||||
float CoC = getCoc(i) / COC_BASE;
|
||||
dofPix.a = lerp(CoC, dofPix.a, _DoFTex_TexelSize.z / _MainTex_TexelSize.z);
|
||||
}
|
||||
rgbM = lerp(rgbM, dofPix.rgb, saturate(dofPix.a * COC_BASE));
|
||||
#endif
|
||||
|
||||
#if BEAUTIFY_NIGHT_VISION || (BEAUTIFY_OUTLINE && !BEAUTIFY_OUTLINE_SOBEL)
|
||||
float3 uvNormalDisp = float3(_MainTex_TexelSize.x, _MainTex_TexelSize.y, 0);
|
||||
float depth = BEAUTIFY_GET_SCENE_DEPTH_01(i.uv);
|
||||
float3 normalNW = getNormal(depth, depthN, depthW, uvNormalDisp.zy, float2(-uvNormalDisp.x, -uvNormalDisp.z));
|
||||
#endif
|
||||
|
||||
#if BEAUTIFY_OUTLINE
|
||||
#if !BEAUTIFY_OUTLINE_SOBEL
|
||||
float3 normalSE = getNormal(depth, depthS, depthE, -uvNormalDisp.zy, uvNormalDisp.xz);
|
||||
float dnorm = dot(normalNW, normalSE);
|
||||
float satN = getSaturation(rgbN);
|
||||
float satS = getSaturation(rgbS);
|
||||
float satW = getSaturation(rgbW);
|
||||
float satE = getSaturation(rgbE);
|
||||
float maxSat = max( max(satN, satS), max(satW, satE) );
|
||||
float minSat = min( min(satN, satS), min(satW, satE) );
|
||||
float dSat = maxSat - minSat;
|
||||
rgbM = lerp(rgbM, _Outline.rgb, (float)(dnorm < OUTLINE_EDGE_THRESHOLD && dDepth > OUTLINE_MIN_DEPTH_THRESHOLD && dSat > OUTLINE_MIN_SATURATION_THRESHOLD));
|
||||
#else
|
||||
float3 uvInc = float3(_MainTex_TexelSize.x, _MainTex_TexelSize.y, 0);
|
||||
float3 rgbSW = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv - uvInc.xy).rgb; // was tex2Dlod
|
||||
float3 rgbNE = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv + uvInc.xy).rgb;
|
||||
float3 rgbSE = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv + float2( uvInc.x, -uvInc.y)).rgb;
|
||||
float3 rgbNW = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv + float2(-uvInc.x, uvInc.y)).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 && (BEAUTIFY_BLOOM || BEAUTIFY_NIGHT_VISION || BEAUTIFY_THERMAL_VISION || BEAUTIFY_DIRT || BEAUTIFY_EYE_ADAPTATION || BEAUTIFY_PURKINJE || BEAUTIFY_ACES_TONEMAP || BEAUTIFY_AGX_TONEMAP || BEAUTIFY_ACES_FITTED_TONEMAP)
|
||||
rgbM = GAMMA_TO_LINEAR(rgbM);
|
||||
#endif
|
||||
|
||||
#if BEAUTIFY_BLOOM
|
||||
rgbM += SAMPLE_TEXTURE2D_X(_BloomTex, sampler_LinearClamp, i.uv).rgb * _Bloom.xxx;
|
||||
#endif
|
||||
|
||||
#if BEAUTIFY_DIRT
|
||||
float3 scrLum = SAMPLE_TEXTURE2D_X(_ScreenLum, sampler_LinearClamp, i.uv).rgb;
|
||||
#if BEAUTIFY_BLOOM
|
||||
scrLum *= _Dirt.www;
|
||||
#endif
|
||||
|
||||
#if defined(UNITY_SINGLE_PASS_STEREO)
|
||||
float2 dirtUV = float2(uv.x * 2.0, uv.y); // TODO: ?? should ignore Single Pass
|
||||
#else
|
||||
float2 dirtUV = uv;
|
||||
#endif
|
||||
float4 dirt = SAMPLE_TEXTURE2D(_OverlayTex, sampler_LinearRepeat, dirtUV);
|
||||
rgbM += saturate(0.5.xxx - _Dirt.zzz + scrLum) * dirt.rgb * _Dirt.y;
|
||||
#endif
|
||||
|
||||
#if BEAUTIFY_NIGHT_VISION
|
||||
rgbM *= saturate( (_NightVisionDepth.x - BEAUTIFY_GET_SCENE_DEPTH_EYE(uv)) * _NightVisionDepth.y );
|
||||
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 * _NightVision.rgb;
|
||||
rgbM *= frac(floor(uv.y * _MainTex_TexelSize.w)*0.25)>0.4; // scan lines
|
||||
rgbM *= 1.0 + getRandom(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(uv.y * _MainTex_TexelSize.w)*0.25)>_NightVision.a; // scan lines
|
||||
rgbM *= 1.0 + getRandom(uv) * 0.2 - 0.1; // noise
|
||||
#endif
|
||||
|
||||
#if BEAUTIFY_EYE_ADAPTATION || BEAUTIFY_PURKINJE
|
||||
float4 avgLum = SAMPLE_TEXTURE2D_X(_EAHist, sampler_LinearClamp, 0.5.xx);
|
||||
#endif
|
||||
|
||||
#if BEAUTIFY_EYE_ADAPTATION
|
||||
float eaFactor;
|
||||
#if BEAUTIFY_EA_LEGACY_MODE
|
||||
float srcLum = SAMPLE_TEXTURE2D_X(_EALumSrc, sampler_LinearClamp, 0.5.xx).r;
|
||||
float eaLuma = getLuma(rgbM);
|
||||
float pixLum = max(0, log(1.0 + eaLuma));
|
||||
static const float epsilon = 1e-4;
|
||||
float avgLumSafe = max(avgLum.r, epsilon);
|
||||
eaFactor = pow(pixLum / avgLumSafe, abs(srcLum / avgLumSafe - 1.0));
|
||||
#else
|
||||
float histLum = exp(avgLum.r) - 1.0 + 0.001;
|
||||
float middleGray = _EyeAdaptation2.z;
|
||||
eaFactor = middleGray / histLum;
|
||||
#endif
|
||||
eaFactor = clamp(eaFactor, _EyeAdaptation.x, _EyeAdaptation.y);
|
||||
rgbM *= eaFactor;
|
||||
#endif
|
||||
|
||||
#if BEAUTIFY_AGX_TONEMAP
|
||||
rgbM *= _FXColor.r;
|
||||
rgbM = AGXFitted(rgbM); // already applies gamma correction
|
||||
rgbM *= _FXColor.g;
|
||||
rgbM = saturate(rgbM);
|
||||
#else
|
||||
#if BEAUTIFY_ACES_FITTED_TONEMAP
|
||||
rgbM *= _FXColor.r;
|
||||
rgbM = ACESFitted(rgbM);
|
||||
rgbM *= _FXColor.g;
|
||||
#endif
|
||||
#if BEAUTIFY_ACES_TONEMAP
|
||||
rgbM *= _FXColor.r;
|
||||
rgbM = tmoFilmicACES(rgbM);
|
||||
rgbM *= _FXColor.g;
|
||||
#endif
|
||||
#if UNITY_COLORSPACE_GAMMA && (BEAUTIFY_BLOOM || BEAUTIFY_NIGHT_VISION || BEAUTIFY_THERMAL_VISION || BEAUTIFY_DIRT || BEAUTIFY_EYE_ADAPTATION || BEAUTIFY_PURKINJE || BEAUTIFY_ACES_FITTED_TONEMAP || BEAUTIFY_ACES_TONEMAP)
|
||||
rgbM = LINEAR_TO_GAMMA(rgbM);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if BEAUTIFY_LUT || BEAUTIFY_3DLUT
|
||||
#if !UNITY_COLORSPACE_GAMMA
|
||||
rgbM = LINEAR_TO_GAMMA(rgbM);
|
||||
#endif
|
||||
#if BEAUTIFY_3DLUT
|
||||
float3 xyz = rgbM * _LUT3DParams.y + _LUT3DParams.x;
|
||||
float3 lut = SAMPLE_TEXTURE3D(_LUT3DTex, sampler_LinearClamp, xyz).rgb;
|
||||
#else
|
||||
float3 lutST = float3(_LUTTex_TexelSize.x, _LUTTex_TexelSize.y, _LUTTex_TexelSize.w - 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(SAMPLE_TEXTURE2D(_LUTTex, sampler_LinearClamp, lookUp.xy).rgb, SAMPLE_TEXTURE2D(_LUTTex, sampler_LinearClamp, lookUpNextSlice).rgb, lookUp.z - slice);
|
||||
#endif
|
||||
rgbM = lerp(rgbM, lut, _FXColor.a);
|
||||
|
||||
#if !UNITY_COLORSPACE_GAMMA
|
||||
rgbM = GAMMA_TO_LINEAR(rgbM);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
// sepia
|
||||
#if BEAUTIFY_COLOR_TWEAKS
|
||||
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, _Params.x);
|
||||
#endif
|
||||
|
||||
// saturate
|
||||
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;
|
||||
|
||||
#if BEAUTIFY_COLOR_TWEAKS
|
||||
lumaM = getLuma(rgbM);
|
||||
float3 kelvin = KelvinToRGB(_ColorTemp.x);
|
||||
rgbM = lerp(rgbM, rgbM * kelvin, _ColorTemp.y);
|
||||
//rgbM *= getLuma(rgbM) / lumaM; // energy preservation (optional)
|
||||
#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
|
||||
|
||||
// Film Grain
|
||||
#if BEAUTIFY_FILM_GRAIN
|
||||
ApplyFilmGrain(rgbM, lumaM, uv);
|
||||
#endif
|
||||
|
||||
#if BEAUTIFY_VIGNETTING
|
||||
float2 vd = float2((uv.x - VIGNETTE_CENTER.x) * VIGNETTE_ASPECT_RATIO_X, (uv.y - VIGNETTE_CENTER.y) * VIGNETTE_ASPECT_RATIO_Y);
|
||||
float3 vcolor = lerp(_Vignetting.rgb, rgbM, saturate( saturate((dot(vd, vd) - VIGNETTE_OUTER_RING) / (VIGNETTE_INNER_RING - VIGNETTE_OUTER_RING) ) - VIGNETTE_FADE_AND_BLINK)) ;
|
||||
rgbM = lerp(rgbM, vcolor, _Vignetting.a);
|
||||
#elif BEAUTIFY_VIGNET_MASK
|
||||
float2 vd = float2((uv.x - VIGNETTE_CENTER.x) * VIGNETTE_ASPECT_RATIO_X, (uv.y - VIGNETTE_CENTER.y) * VIGNETTE_ASPECT_RATIO_Y);
|
||||
float vmask = SAMPLE_TEXTURE2D_X(_VignettingMask, sampler_LinearClamp, uv).a;
|
||||
rgbM = lerp(rgbM, lumaM * _Vignetting.rgb, saturate(VIGNETTE_FADE_AND_BLINK + vmask * _Vignetting.a * saturate(VIGNETTE_OUTER_RING * 4.0 * dot(vd, vd))));
|
||||
#endif
|
||||
|
||||
#if BEAUTIFY_FRAME
|
||||
float aspectRatio = _MainTex_TexelSize.z / _MainTex_TexelSize.w;
|
||||
float2 distToEdge = min(i.uv.xy, 1.0 - i.uv.xy);
|
||||
distToEdge.x *= aspectRatio;
|
||||
float thickness = _FrameData.x;
|
||||
float frameIntensity = saturate( (thickness - min(distToEdge.x, distToEdge.y)) * _FrameData.y );
|
||||
|
||||
float2 bands = saturate( (abs(i.uv.xy - 0.5) - _FrameData.xz) * _FrameData.yw);
|
||||
float bandsIntensity = max(bands.x, bands.y);
|
||||
|
||||
frameIntensity = _FrameData.w > 0 ? bandsIntensity : frameIntensity;
|
||||
|
||||
float4 frameMask = SAMPLE_TEXTURE2D_X(_FrameMask, sampler_LinearClamp, uv);
|
||||
rgbM = lerp(rgbM, _Frame.rgb * frameMask.rgb, frameMask.a * _Frame.a * frameIntensity);
|
||||
#endif
|
||||
|
||||
#if BEAUTIFY_DITHER
|
||||
#if BEAUTIFY_TURBO
|
||||
float3 dither = dot(float2(171.0, 231.0), i.uv * _MainTex_TexelSize.zw).xxx;
|
||||
dither = frac(dither / float3(103.0, 71.0, 97.0)) - 0.5.xxx;
|
||||
rgbM += dither * _ColorBoost.w;
|
||||
#else
|
||||
float2 noiseUV = i.uv * _BlueNoise_TexelSize.xy * _MainTex_TexelSize.zw;
|
||||
float3 blueNoise = SAMPLE_TEXTURE2D(_BlueNoise, sampler_PointRepeat, noiseUV).rgb;
|
||||
rgbM += (blueNoise - 0.5.xxx) * _ColorBoost.w * saturate(1.0 - lumaM);
|
||||
#endif
|
||||
rgbM = max(0.0.xxx, rgbM);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
float4 FragBeautify (VaryingsBeautify i) : SV_Target {
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
i.uv = UnityStereoTransformScreenSpaceTex(i.uv);
|
||||
|
||||
#if BEAUTIFY_THERMAL_VISION
|
||||
i.uv.x += _NightVision.z * 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
|
||||
|
||||
#if BEAUTIFY_CABERRATION
|
||||
float4 pixel = GetDistortedColor(i.uv);
|
||||
#else
|
||||
float4 pixel = SAMPLE_TEXTURE2D_X(_MainTex, sampler_MainTex, i.uv);
|
||||
#endif
|
||||
|
||||
beautifyPass(i, pixel.rgb);
|
||||
|
||||
return pixel;
|
||||
}
|
||||
|
||||
|
||||
float4 FragCompare (VaryingsSimple i) : SV_Target {
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
i.uv = UnityStereoTransformScreenSpaceTex(i.uv);
|
||||
|
||||
// separator line + antialias
|
||||
float2 dd = i.uv;
|
||||
if (_CompareParams.z < -15) {
|
||||
dd.x -= (_CompareParams.z - -20);
|
||||
_CompareParams.z = -10;
|
||||
} else {
|
||||
dd.x -= 0.5;
|
||||
}
|
||||
dd.y -= 0.5;
|
||||
|
||||
float co = dot(_CompareParams.xy, dd);
|
||||
float dist = distance( _CompareParams.xy * co, dd );
|
||||
float4 aa = saturate( (_CompareParams.w - dist) / abs(_MainTex_TexelSize.y) );
|
||||
|
||||
float sameSide = (_CompareParams.z > -5);
|
||||
float2 pixelUV = lerp(i.uv, float2(i.uv.x + _CompareParams.z, i.uv.y), sameSide);
|
||||
float2 pixelNiceUV = lerp(i.uv, float2(i.uv.x - 0.5 + _CompareParams.z, i.uv.y), sameSide);
|
||||
float4 pixel = SAMPLE_TEXTURE2D_X(_MainTex, sampler_MainTex, pixelUV);
|
||||
float4 pixelNice = SAMPLE_TEXTURE2D_X(_CompareTex, sampler_MainTex, pixelNiceUV);
|
||||
|
||||
// are we on the beautified side?
|
||||
float2 cp = float2(_CompareParams.y, -_CompareParams.x);
|
||||
float t = dot(dd, cp) > 0;
|
||||
pixel = lerp(pixel, pixelNice, t);
|
||||
return pixel + aa;
|
||||
}
|
||||
|
||||
|
||||
half4 FragCopy (VaryingsSimple i) : SV_Target {
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
float2 uv = UnityStereoTransformScreenSpaceTex(i.uv);
|
||||
#if defined(USE_BILINEAR)
|
||||
return clamp(SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv), 0, 1e6);
|
||||
#else
|
||||
return SAMPLE_TEXTURE2D_X(_MainTex, sampler_PointClamp, uv);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
half4 FragCopyWithMask (VaryingsSimple i) : SV_Target {
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
float2 uv = UnityStereoTransformScreenSpaceTex(i.uv);
|
||||
|
||||
half maskAlpha;
|
||||
int style = BLUR_STYLE;
|
||||
if (style == 0) {
|
||||
maskAlpha = SAMPLE_TEXTURE2D_LOD(_BlurMask, sampler_LinearClamp, uv, 0).a;
|
||||
} else if (style == 1) { // Tilt Shift
|
||||
float dist = abs(uv.y - BLUR_CENTER.y);
|
||||
float width = BLUR_WIDTH * 0.5;
|
||||
maskAlpha = smoothstep(width, width + max(BLUR_FALLOFF, 0.0001), dist);
|
||||
} else { // Radial Blur
|
||||
float aspect = _MainTex_TexelSize.z * _MainTex_TexelSize.y;
|
||||
float2 dist2 = uv - BLUR_CENTER;
|
||||
dist2.x *= aspect;
|
||||
float dist = length(dist2);
|
||||
maskAlpha = smoothstep(BLUR_WIDTH, BLUR_WIDTH + max(BLUR_FALLOFF, 0.0001), dist);
|
||||
}
|
||||
|
||||
if (BLUR_SHOW_MASK > 0) {
|
||||
return half4(maskAlpha, maskAlpha, maskAlpha, 1);
|
||||
}
|
||||
|
||||
half4 srcPixel = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv);
|
||||
half4 blurPixel = SAMPLE_TEXTURE2D_X(_BlurTex, sampler_LinearClamp, uv);
|
||||
return lerp(srcPixel, blurPixel, maskAlpha);
|
||||
}
|
||||
|
||||
half4 FragCopyWithMiniView (VaryingsSimple i) : SV_Target {
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
float2 uv = UnityStereoTransformScreenSpaceTex(i.uv);
|
||||
float2 uvOrig = (uv - _MiniViewRect.xy) / _MiniViewRect.zw;
|
||||
half4 source = SAMPLE_TEXTURE2D_X_LOD(_MiniViewTex, sampler_LinearClamp, uvOrig, 0);
|
||||
half4 final = SAMPLE_TEXTURE2D_X_LOD(_MainTex, sampler_LinearClamp, uv, 0);
|
||||
if (any(floor(uvOrig) != 0)) source = final;
|
||||
float2 frameIntensity = saturate( (abs(uvOrig - 0.5) - _MiniViewBlend.xz) * _MiniViewBlend.yw);
|
||||
float frameBlend = max(frameIntensity.x, frameIntensity.y);
|
||||
return lerp(source, final, frameBlend);
|
||||
}
|
||||
|
||||
|
||||
#endif // BEAUTIFY_CORE_FX
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 850a3a451a0484244acec510bfdf6867
|
||||
timeCreated: 1517506872
|
||||
licenseType: Pro
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,487 @@
|
||||
Shader "Hidden/Kronnect/Beautify" {
|
||||
Properties {
|
||||
_FlareTex("Flare Texture", 2D) = "white" {}
|
||||
_OverlayTex("Lens Dirt Texture", 2D) = "black" {}
|
||||
_Color("", Color) = (1,1,1)
|
||||
_BlueNoise("Blue Noise", 2D) = "black" {}
|
||||
_BokehData2("", Vector) = (1,1,1,1)
|
||||
_BokehData3("", Vector) = (1,1,1000,1)
|
||||
_BlurMask("Blur Mask", 2D) = "white" {}
|
||||
_FlipY("Flip Y", Float) = 1
|
||||
}
|
||||
|
||||
Subshader {
|
||||
|
||||
Tags { "RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" }
|
||||
LOD 100
|
||||
ZWrite Off ZTest Always Blend Off Cull Off
|
||||
|
||||
HLSLINCLUDE
|
||||
#pragma target 3.0
|
||||
#pragma prefer_hlslcc gles
|
||||
#pragma exclude_renderers d3d11_9x
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Filtering.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/PostProcessing/Common.hlsl"
|
||||
ENDHLSL
|
||||
|
||||
Pass { // 0
|
||||
Name "Raw Copy (Point Filtering)"
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertOS
|
||||
#pragma fragment FragCopy
|
||||
#include "BeautifyCore.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass { // 1
|
||||
Name "Compare View"
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertOS
|
||||
#pragma fragment FragCompare
|
||||
#include "BeautifyCore.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass { // 2
|
||||
Name "Main Beautify Pass (core)"
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertBeautify
|
||||
#pragma fragment FragBeautify
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_ACES_TONEMAP BEAUTIFY_ACES_FITTED_TONEMAP BEAUTIFY_AGX_TONEMAP
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_LUT BEAUTIFY_3DLUT BEAUTIFY_NIGHT_VISION BEAUTIFY_THERMAL_VISION
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_BLOOM
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_DIRT
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_DEPTH_OF_FIELD BEAUTIFY_DOF_TRANSPARENT BEAUTIFY_CABERRATION
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_PURKINJE
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_VIGNETTING BEAUTIFY_VIGNET_MASK
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_EYE_ADAPTATION
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_COLOR_TWEAKS
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_TURBO
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_DITHER BEAUTIFY_FILM_GRAIN
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_SHARPEN BEAUTIFY_EXCLUSION_MASK_SHARPEN
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_FRAME
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_EDGE_AA BEAUTIFY_OUTLINE
|
||||
#include "BeautifyCore.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass { // 3
|
||||
Name "Extract Luminance"
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertLum
|
||||
#pragma fragment FragLum
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_TURBO
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_BLOOM_USE_DEPTH
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_BLOOM_USE_LAYER BEAUTIFY_BLOOM_USE_LAYER_INCLUSION
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_BLOOM_PROP_THRESHOLDING
|
||||
#include "BeautifyPPSLum.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass { // 4
|
||||
Name "Debug bloom"
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertOS
|
||||
#pragma fragment FragDebugBloom
|
||||
#include "BeautifyPPSLum.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass { // 5
|
||||
Name "Blur horizontally"
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertBlur
|
||||
#pragma fragment FragBlur
|
||||
#define BEAUTIFY_BLUR_HORIZ
|
||||
#include "BeautifyPPSLum.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass { // 6
|
||||
Name "Blur vertically"
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertBlur
|
||||
#pragma fragment FragBlur
|
||||
#include "BeautifyPPSLum.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass { // 7
|
||||
Name "Bloom compose"
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertOS
|
||||
#pragma fragment FragBloomCompose
|
||||
#include "BeautifyPPSLum.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass { // 8
|
||||
Name "Resample"
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertCross
|
||||
#pragma fragment FragResample
|
||||
#include "BeautifyPPSLum.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass { // 9
|
||||
Name "Combine resample"
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertCross
|
||||
#pragma fragment FragResample
|
||||
#define COMBINE_BLOOM
|
||||
#include "BeautifyPPSLum.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass { // 10
|
||||
Name "Bloom extract luminance with antiflicker"
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertCrossLum
|
||||
#pragma fragment FragLumAntiflicker
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_TURBO
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_BLOOM_USE_DEPTH
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_BLOOM_USE_LAYER BEAUTIFY_BLOOM_USE_LAYER_INCLUSION
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_BLOOM_PROP_THRESHOLDING
|
||||
#include "BeautifyPPSLum.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass { // 11
|
||||
Name "Resample Anamorphic Flares"
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertCross
|
||||
#pragma fragment FragResampleAF
|
||||
#define COMBINE_BLOOM
|
||||
#include "BeautifyPPSLum.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass { // 12
|
||||
Name "Combine AF"
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertOS
|
||||
#pragma fragment FragCombine
|
||||
#define COMBINE_BLOOM
|
||||
#include "BeautifyPPSLum.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass { // 13
|
||||
Name "Compute Screen Lum"
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertOS
|
||||
#pragma fragment FragScreenLum
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_EA_USE_DEPTH
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_EA_USE_MASK
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_TURBO
|
||||
#include "BeautifyPPSEA.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass { // 14
|
||||
Name "Reduce Screen Lum"
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertCross
|
||||
#pragma fragment FragReduceScreenLum
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_EA_USE_DEPTH
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_EA_USE_MASK
|
||||
#include "BeautifyPPSEA.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass { // 15
|
||||
Name "Blend Screen Lum"
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertOS
|
||||
#pragma fragment FragBlendScreenLum
|
||||
#include "BeautifyPPSEA.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass { // 16
|
||||
Name "Simple Blend"
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertOS
|
||||
#pragma fragment FragBlend
|
||||
#include "BeautifyPPSEA.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass { // 17
|
||||
Name "AF Lum"
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertLum
|
||||
#pragma fragment FragLum
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_TURBO
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_ANAMORPHIC_FLARES_USE_DEPTH
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_ANAMORPHIC_FLARES_USE_LAYER BEAUTIFY_ANAMORPHIC_FLARES_USE_LAYER_INCLUSION
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_ANAMORPHIC_PROP_THRESHOLDING
|
||||
#define USE_AF_THRESHOLD
|
||||
#include "BeautifyPPSLum.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass { // 18
|
||||
Name "AF Lum AntiFlicker"
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertCrossLum
|
||||
#pragma fragment FragLumAntiflicker
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_TURBO
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_ANAMORPHIC_FLARES_USE_DEPTH
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_ANAMORPHIC_FLARES_USE_LAYER BEAUTIFY_ANAMORPHIC_FLARES_USE_LAYER_INCLUSION
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_ANAMORPHIC_PROP_THRESHOLDING
|
||||
#define USE_AF_THRESHOLD
|
||||
#include "BeautifyPPSLum.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass { // 19
|
||||
Name "Sun Flares"
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertSF
|
||||
#pragma fragment FragSF
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_SF_USE_GHOSTS
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_SF_OCCLUSION_SIMPLE BEAUTIFY_SF_OCCLUSION_SMOOTH
|
||||
#include "BeautifyPPSSF.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass { // 20
|
||||
Name "Sun Flares Additive"
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertSF
|
||||
#pragma fragment FragSFAdditive
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_SF_USE_GHOSTS
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_SF_OCCLUSION_SIMPLE BEAUTIFY_SF_OCCLUSION_SMOOTH
|
||||
#include "BeautifyPPSSF.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass { // 21
|
||||
Name "DoF CoC"
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertOS
|
||||
#pragma fragment FragCoC
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_DOF_TRANSPARENT
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_EDGE_AA_DOF
|
||||
#include "BeautifyPPSDoF.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass { // 22
|
||||
Name "DoF CoC Debug"
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertOS
|
||||
#pragma fragment FragCoCDebug
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_DOF_TRANSPARENT
|
||||
#include "BeautifyPPSDoF.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass { // 23
|
||||
Name "DoF Blur"
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertOS
|
||||
#pragma fragment FragBlur
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#include "BeautifyPPSDoF.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass { // 24
|
||||
Name "DoF Blur wo/Bokeh"
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertOS
|
||||
#pragma fragment FragBlurNoBokeh
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#include "BeautifyPPSDoF.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass { // 25
|
||||
Name "DoF Blur Horizontally"
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertBlur
|
||||
#pragma fragment FragBlurCoC
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#define BEAUTIFY_BLUR_HORIZ
|
||||
#include "BeautifyPPSDoF.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass { // 26
|
||||
Name "DoF Blur Vertically"
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertBlur
|
||||
#pragma fragment FragBlurCoC
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#include "BeautifyPPSDoF.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass { // 27
|
||||
Name "Raw Copy (Bilinear Filtering)"
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertOS
|
||||
#pragma fragment FragCopy
|
||||
#define USE_BILINEAR
|
||||
#include "BeautifyCore.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass { // 28
|
||||
Name "Bloom Exclusion Layer Debug"
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertOS
|
||||
#pragma fragment FragDebugBloomExclusionLayer
|
||||
#include "BeautifyPPSLum.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass { // 29
|
||||
Name "DoF Debug Transparent"
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertOS
|
||||
#pragma fragment FragDoFDebugTransparent
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_DOF_TRANSPARENT
|
||||
#include "BeautifyPPSDoF.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass { // 30
|
||||
Name "Chromatic Aberration Custom Pass"
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertOS
|
||||
#pragma fragment fragChromaticAberration
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#pragma multi_compile_local_fragment __ BEAUTIFY_TURBO
|
||||
#define BEAUTIFY_CABERRATION 1
|
||||
#include "BeautifyCAberration.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass { // 31
|
||||
Name "Outline Detection Pass"
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertOutline
|
||||
#pragma fragment fragOutline
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#pragma multi_compile_local_fragment _ BEAUTIFY_DEPTH_FADE
|
||||
#pragma multi_compile_local_fragment _ BEAUTIFY_OUTLINE_CUSTOM_DEPTH BEAUTIFY_OUTLINE_OBJECT_ID
|
||||
#pragma multi_compile_local_fragment _ BEAUTIFY_OUTLINE_MIN_SEPARATION
|
||||
#pragma multi_compile_local_fragment _ BEAUTIFY_OUTLINE_OUTER_ONLY
|
||||
#include "BeautifyPPSOutline.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass { // 32
|
||||
Name "Outline Blur Horizontally (depth aware)"
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertBlur
|
||||
#pragma fragment FragBlur
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#define BEAUTIFY_BLUR_HORIZ
|
||||
#include "BeautifyPPSOutline.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass { // 33
|
||||
Name "Outline Blur Vertically (depth aware)"
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertBlur
|
||||
#pragma fragment FragBlur
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#include "BeautifyPPSOutline.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass { // 34
|
||||
Name "Outline Blend Pass"
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertOutline
|
||||
#pragma fragment FragCopy
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#include "BeautifyPPSOutline.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass { // 35
|
||||
Name "Mask Blur"
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertOS
|
||||
#pragma fragment FragCopyWithMask
|
||||
#include "BeautifyCore.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
|
||||
Pass { // 36
|
||||
Name "DoF Threshold for bokeh"
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertOS
|
||||
#pragma fragment FragThreshold
|
||||
#include "BeautifyPPSDoF.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass { // 37
|
||||
Name "DoF Additive"
|
||||
Blend One One
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertOS
|
||||
#pragma fragment FragCopyBokeh
|
||||
#include "BeautifyPPSDoF.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass { // 38
|
||||
Name "DoF Blur bokeh"
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertOS
|
||||
#pragma fragment FragBlurSeparateBokeh
|
||||
#include "BeautifyPPSDoF.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass { // 39
|
||||
Name "Anamorphic Flares Exclusion Layer Debug"
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertOS
|
||||
#pragma fragment FragDebugAnamorphicFlaresExclusionLayer
|
||||
#include "BeautifyPPSLum.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass { // 40
|
||||
Name "Copy with MiniView"
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertOS
|
||||
#pragma fragment FragCopyWithMiniView
|
||||
#include "BeautifyCore.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass { // 41
|
||||
Name "Sun Flares Occlusion Test"
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertSF
|
||||
#pragma fragment FragSFOcclusion
|
||||
#pragma multi_compile_local_fragment _ BEAUTIFY_SF_OCCLUSION_INIT
|
||||
#include "BeautifyPPSSF.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
FallBack Off
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 55d70ca4ea7504a38b66170bbe587b2f
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures:
|
||||
- _MainTex: {instanceID: 0}
|
||||
- _FlareTex: {fileID: 2800000, guid: 93092410bbc6f4ccba773578db5832d9, type: 3}
|
||||
- _OverlayTex: {fileID: 2800000, guid: 0bd567658bec947d2b4d2877ccb0faa7, type: 3}
|
||||
- _BlueNoise: {fileID: 2800000, guid: e6a467a4c71a24898ac842ed6f9a1d52, type: 3}
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,70 @@
|
||||
#ifndef BEAUTIFY_DISTORTION
|
||||
#define BEAUTIFY_DISTORTION
|
||||
|
||||
#if BEAUTIFY_CABERRATION
|
||||
|
||||
float3 _ChromaticAberrationData;
|
||||
#define CHROMATIC_ABERRATION_INTENSITY _ChromaticAberrationData.x
|
||||
#define CHROMATIC_ABERRATION_SMOOTHING _ChromaticAberrationData.y
|
||||
#define CHROMATIC_ABERRATION_SHIFT _ChromaticAberrationData.z
|
||||
#define CHROMATIC_ABERRATION_MAX_SAMPLES 32
|
||||
|
||||
#if BEAUTIFY_TURBO
|
||||
|
||||
float4 GetDistortedColor(float2 uv) {
|
||||
|
||||
float2 coords = 2.0 * uv - 1.0;
|
||||
float dst = dot(coords, coords);
|
||||
float2 delta = coords * (dst * CHROMATIC_ABERRATION_INTENSITY);
|
||||
float r = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv).r;
|
||||
float g = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv - delta).g;
|
||||
float b = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv - delta * 2.0).b;
|
||||
return float4(r, g, b, 1.0);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
float4 GetDistortedColor(float2 uv) {
|
||||
|
||||
float2 coords = 2.0 * uv - 1.0;
|
||||
float dst = dot(coords, coords);
|
||||
float2 delta = coords * (dst * CHROMATIC_ABERRATION_INTENSITY);
|
||||
float4 abColor = float4(0,0,0,1.0);
|
||||
|
||||
#if BEAUTIFY_CABERRATION_ALT
|
||||
int samples = clamp( (int)(dst * CHROMATIC_ABERRATION_SMOOTHING) + 1, 1, CHROMATIC_ABERRATION_MAX_SAMPLES);
|
||||
UNITY_UNROLL
|
||||
for (int k=0;k<CHROMATIC_ABERRATION_MAX_SAMPLES;k++) {
|
||||
if (k<samples) {
|
||||
float h = (float)(k + 1.0) / samples;
|
||||
float r = SAMPLE_TEXTURE2D_X_LOD(_MainTex, sampler_LinearClamp, uv, 0).r;
|
||||
float g = SAMPLE_TEXTURE2D_X_LOD(_MainTex, sampler_LinearClamp, uv - delta * h, 0).g;
|
||||
float b = SAMPLE_TEXTURE2D_X_LOD(_MainTex, sampler_LinearClamp, uv - delta * 2.0 * h, 0).b;
|
||||
abColor.rgb += float3(r, g, b);
|
||||
}
|
||||
}
|
||||
abColor.xyz /= samples;
|
||||
#else
|
||||
int samples = clamp( (int)(dst * CHROMATIC_ABERRATION_SMOOTHING) + 1, 3, CHROMATIC_ABERRATION_MAX_SAMPLES);
|
||||
float3 weight = 0.0001.xxx;
|
||||
UNITY_UNROLL
|
||||
for (int k=0;k<CHROMATIC_ABERRATION_MAX_SAMPLES;k++) {
|
||||
if (k<samples) {
|
||||
float h = (k+0.5) / samples;
|
||||
float3 spec = saturate( abs( fmod( (h + CHROMATIC_ABERRATION_SHIFT) * 6.0.xxx + float3(0, 4, 2), 6.0) - 3.0) - 1.0 ); // hue to rgb
|
||||
float3 rgb = SAMPLE_TEXTURE2D_X_LOD(_MainTex, sampler_LinearClamp, uv - delta * h, 0).xyz;
|
||||
abColor.xyz += rgb * spec;
|
||||
weight += spec;
|
||||
}
|
||||
}
|
||||
abColor.xyz /= weight;
|
||||
#endif
|
||||
|
||||
return abColor;
|
||||
}
|
||||
|
||||
#endif // BEAUTIFY_TURBO
|
||||
|
||||
#endif // BEAUTIFY_CABERRATION
|
||||
|
||||
#endif // BEAUTIFY_DISTORTION
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cddff75d1d1474a5b93d4bbbc8d07417
|
||||
timeCreated: 1517506872
|
||||
licenseType: Pro
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,307 @@
|
||||
#ifndef BEAUTIFY_PPSDOF_FX
|
||||
#define BEAUTIFY_PPSDOF_FX
|
||||
|
||||
// Copyright 2020-2021 Kronnect - All Rights Reserved.
|
||||
#include "BeautifyCommon.hlsl"
|
||||
|
||||
TEXTURE2D_X(_DoFTransparentDepth);
|
||||
//TEXTURE2D_X(_DofExclusionTexture);
|
||||
TEXTURE2D_X(_MainTex);
|
||||
|
||||
float4 _MainTex_TexelSize;
|
||||
float4 _MainTex_ST;
|
||||
float4 _BokehData;
|
||||
float4 _BokehData2;
|
||||
float3 _BokehData3;
|
||||
float _BlurScale;
|
||||
|
||||
#if BEAUTIFY_EDGE_AA_DOF
|
||||
#include "BeautifyAA.hlsl"
|
||||
#endif
|
||||
|
||||
struct VaryingsDoFCross {
|
||||
float4 positionCS : SV_POSITION;
|
||||
float2 uv: TEXCOORD0;
|
||||
BEAUTIFY_VERTEX_CROSS_UV_DATA
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
|
||||
float getCocFromDepth(float depth) {
|
||||
if (depth > _BokehData3.y) return 0;
|
||||
float xd = abs(depth - _BokehData.x) - _BokehData2.x * (depth < _BokehData.x);
|
||||
return min(_BokehData3.z, 0.5 * _BokehData.y * xd / depth);
|
||||
}
|
||||
|
||||
float getCocFromUV(float2 uv) {
|
||||
#if BEAUTIFY_DOF_TRANSPARENT
|
||||
float depthTex = BEAUTIFY_GET_CUSTOM_DEPTH_01(_DoFTransparentDepth, uv);
|
||||
float depth = BEAUTIFY_GET_SCENE_DEPTH_01(uv);
|
||||
depth = min(depth, depthTex);
|
||||
depth *= _ProjectionParams.z;
|
||||
#else
|
||||
float depth = BEAUTIFY_GET_SCENE_DEPTH_EYE(uv);
|
||||
#endif
|
||||
return getCocFromDepth(depth);
|
||||
}
|
||||
|
||||
float getCoc(VaryingsSimple i) {
|
||||
return getCocFromUV(i.uv);
|
||||
}
|
||||
|
||||
float4 FragCoC (VaryingsSimple i) : SV_Target {
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
i.uv = UnityStereoTransformScreenSpaceTex(i.uv);
|
||||
|
||||
float3 pixelRGB = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, i.uv).rgb;
|
||||
float coc = getCoc(i) / COC_BASE;
|
||||
|
||||
#if BEAUTIFY_EDGE_AA_DOF
|
||||
float2 uv = i.uv;
|
||||
float2 texelSize = _MainTex_TexelSize.xy;
|
||||
float2 uvN = uv + float2(0, texelSize.y);
|
||||
float2 uvS = uv - float2(0, texelSize.y);
|
||||
float2 uvW = uv - float2(texelSize.x, 0);
|
||||
float2 uvE = uv + float2(texelSize.x, 0);
|
||||
|
||||
float depthN = BEAUTIFY_GET_SCENE_DEPTH_01(uvN);
|
||||
float depthS = BEAUTIFY_GET_SCENE_DEPTH_01(uvS);
|
||||
float depthW = BEAUTIFY_GET_SCENE_DEPTH_01(uvW);
|
||||
float depthE = BEAUTIFY_GET_SCENE_DEPTH_01(uvE);
|
||||
float depthCenter = BEAUTIFY_GET_SCENE_DEPTH_01(uv);
|
||||
float dDepth = abs(depthN - depthS) + abs(depthW - depthE);
|
||||
|
||||
if (dDepth > ANTIALIAS_THRESHOLD) {
|
||||
float3 rgbN = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uvN).rgb;
|
||||
float3 rgbS = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uvS).rgb;
|
||||
float3 rgbW = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uvW).rgb;
|
||||
float3 rgbE = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uvE).rgb;
|
||||
|
||||
float lumaN = getLuma(rgbN);
|
||||
float lumaS = getLuma(rgbS);
|
||||
float lumaW = getLuma(rgbW);
|
||||
float lumaE = getLuma(rgbE);
|
||||
float maxLuma = max(max(lumaN, lumaS), max(lumaW, lumaE));
|
||||
float minLuma = min(min(lumaN, lumaS), min(lumaW, lumaE));
|
||||
|
||||
pixelRGB = ApplyEdgeAA(uv, pixelRGB, dDepth, depthCenter, lumaN, lumaS, lumaW, lumaE, minLuma, maxLuma, texelSize);
|
||||
|
||||
float farClip = _ProjectionParams.z;
|
||||
float cocN = getCocFromDepth(depthN * farClip) / COC_BASE;
|
||||
float cocS = getCocFromDepth(depthS * farClip) / COC_BASE;
|
||||
float cocW = getCocFromDepth(depthW * farClip) / COC_BASE;
|
||||
float cocE = getCocFromDepth(depthE * farClip) / COC_BASE;
|
||||
float maxNeighborCoC = max(max(cocN, cocS), max(cocW, cocE));
|
||||
coc = lerp(coc, maxNeighborCoC, 0.5);
|
||||
}
|
||||
#endif
|
||||
|
||||
pixelRGB = clamp(pixelRGB, 0.0.xxx, _BokehData3.xxx);
|
||||
#if UNITY_COLORSPACE_GAMMA
|
||||
pixelRGB = GAMMA_TO_LINEAR(pixelRGB);
|
||||
#endif
|
||||
return float4(pixelRGB, coc);
|
||||
}
|
||||
|
||||
float4 FragCoCDebug (VaryingsSimple i) : SV_Target {
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
i.uv = UnityStereoTransformScreenSpaceTex(i.uv);
|
||||
|
||||
float4 pixel = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, i.uv);
|
||||
float CoC = min(getCoc(i) / 16.0, 1.0);
|
||||
return float4(CoC.xxx, 1.0);
|
||||
}
|
||||
|
||||
float4 FragDoFDebugTransparent (VaryingsSimple i) : SV_Target {
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
i.uv = UnityStereoTransformScreenSpaceTex(i.uv);
|
||||
|
||||
float depthTex = BEAUTIFY_GET_CUSTOM_DEPTH_01(_DoFTransparentDepth, i.uv);
|
||||
return float4(depthTex.xxx, 1.0);
|
||||
}
|
||||
|
||||
float4 FragBlur (VaryingsSimple i): SV_Target {
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
i.uv = UnityStereoTransformScreenSpaceTex(i.uv);
|
||||
|
||||
float4 sum = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, i.uv );
|
||||
float samples = ceil(sum.a * COC_BASE);
|
||||
|
||||
float4 dir = float4(_BokehData.zw * _MainTex_TexelSize.xy, 0, 0);
|
||||
dir *= max(1.0, samples / _BokehData2.y);
|
||||
#if defined(UNITY_STEREO_INSTANCING_ENABLED) || defined(UNITY_STEREO_MULTIVIEW_ENABLED) || defined(SINGLE_PASS_STEREO)
|
||||
dir.x *= 2.0;
|
||||
#endif
|
||||
|
||||
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.uv + disp0, 0, 0);
|
||||
float4 disp2 = float4(i.uv - 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) {
|
||||
|
||||
float4 pixel1 = SAMPLE_TEXTURE2D_X_LOD(_MainTex, sampler_LinearClamp, disp1.xy, 0);
|
||||
float bt1 = saturate(pixel1.a * COC_BASE - k);
|
||||
pixel1.rgb += _BokehData2.www * max(pixel1.rgb - _BokehData2.zzz, 0.0.xxx);
|
||||
sum += pixel1 * bt1;
|
||||
w += bt1;
|
||||
disp1 += dir;
|
||||
|
||||
float4 pixel2 = SAMPLE_TEXTURE2D_X_LOD(_MainTex, sampler_LinearClamp, disp2.xy, 0);
|
||||
float bt2 = saturate(pixel2.a * COC_BASE - 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 (VaryingsSimple i): SV_Target {
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
i.uv = UnityStereoTransformScreenSpaceTex(i.uv);
|
||||
|
||||
float4 sum = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, i.uv );
|
||||
float samples = ceil(sum.a * COC_BASE);
|
||||
float4 dir = float4(_BokehData.zw * _MainTex_TexelSize.xy, 0, 0);
|
||||
dir *= max(1.0, samples / _BokehData2.y);
|
||||
#if defined(UNITY_STEREO_INSTANCING_ENABLED) || defined(UNITY_STEREO_MULTIVIEW_ENABLED) || defined(SINGLE_PASS_STEREO)
|
||||
dir.x *= 2.0;
|
||||
#endif
|
||||
|
||||
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.uv + disp0, 0, 0);
|
||||
float4 disp2 = float4(i.uv - 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) {
|
||||
float4 pixel1 = SAMPLE_TEXTURE2D_X_LOD(_MainTex, sampler_LinearClamp, disp1.xy, 0);
|
||||
float bt1 = saturate(pixel1.a * COC_BASE - k);
|
||||
sum += bt1 * pixel1;
|
||||
w += bt1;
|
||||
disp1 += dir;
|
||||
float4 pixel2 = SAMPLE_TEXTURE2D_X_LOD(_MainTex, sampler_LinearClamp, disp2.xy, 0);
|
||||
float bt2 = saturate(pixel2.a * COC_BASE - k);
|
||||
sum += bt2 * pixel2;
|
||||
w += bt2;
|
||||
disp2 -= dir;
|
||||
}
|
||||
}
|
||||
return sum / w;
|
||||
}
|
||||
|
||||
VaryingsDoFCross VertBlur(AttributesSimple input) {
|
||||
VaryingsDoFCross output;
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
output.positionCS = input.positionOS;
|
||||
output.positionCS.y *= _ProjectionParams.x * _FlipY;
|
||||
output.uv = input.uv;
|
||||
|
||||
BEAUTIFY_VERTEX_OUTPUT_GAUSSIAN_UV(output);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
float4 FragBlurCoC (VaryingsDoFCross i): SV_Target {
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
i.uv = UnityStereoTransformScreenSpaceTex(i.uv);
|
||||
BEAUTIFY_FRAG_SETUP_GAUSSIAN_UV(i)
|
||||
|
||||
float depth = BEAUTIFY_GET_SCENE_DEPTH_EYE(i.uv);
|
||||
float depth1 = BEAUTIFY_GET_SCENE_DEPTH_EYE(uv1);
|
||||
float depth2 = BEAUTIFY_GET_SCENE_DEPTH_EYE(uv2);
|
||||
float depth3 = BEAUTIFY_GET_SCENE_DEPTH_EYE(uv3);
|
||||
float depth4 = BEAUTIFY_GET_SCENE_DEPTH_EYE(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 = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv1).a;
|
||||
float coc2 = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv2).a;
|
||||
float coc3 = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv3).a;
|
||||
float coc4 = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv4).a;
|
||||
|
||||
float w0 = 0.2270270270;
|
||||
|
||||
float4 pixel = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, i.uv);
|
||||
|
||||
float coc = (pixel.a * w0 + coc1 * w1 + coc2 * w2 + coc3 * w3 + coc4 * w4) / (w0 + w1 + w2 + w3 + w4);
|
||||
pixel.a = max(pixel.a, coc);
|
||||
return pixel;
|
||||
}
|
||||
|
||||
|
||||
float4 FragThreshold (VaryingsSimple input) : SV_Target {
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
|
||||
input.uv = UnityStereoTransformScreenSpaceTex(input.uv);
|
||||
float2 uv = input.uv;
|
||||
float4 pixel = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv);
|
||||
pixel = clamp(pixel, 0.0.xxxx, _BokehData3.xxxx);
|
||||
#if UNITY_COLORSPACE_GAMMA
|
||||
pixel.rgb = GAMMA_TO_LINEAR(pixel.rgb);
|
||||
#endif
|
||||
pixel.rgb = _BokehData2.www * max(pixel.rgb - _BokehData2.zzz, 0.0.xxx);
|
||||
float coc = getCoc(input) / COC_BASE;
|
||||
return float4(pixel.rgb, coc);
|
||||
}
|
||||
|
||||
float4 FragCopyBokeh(VaryingsSimple input) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
|
||||
input.uv = UnityStereoTransformScreenSpaceTex(input.uv);
|
||||
float4 bokeh = SAMPLE_TEXTURE2D_X(_MainTex, sampler_PointClamp, input.uv);
|
||||
return bokeh;
|
||||
}
|
||||
|
||||
float4 FragBlurSeparateBokeh (VaryingsSimple input): SV_Target {
|
||||
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
|
||||
input.uv = UnityStereoTransformScreenSpaceTex(input.uv);
|
||||
|
||||
float2 uv = input.uv;
|
||||
|
||||
float4 sum = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv);
|
||||
float samples = ceil(sum.a * COC_BASE);
|
||||
float4 dir = float4(_BokehData.zw * _MainTex_TexelSize.xy, 0, 0);
|
||||
dir *= max(1.0, samples / _BokehData2.y);
|
||||
float jitter = dot(float2(2.4084507, 3.2535211), uv * _MainTex_TexelSize.zw);
|
||||
float2 disp0 = dir.xy * (frac(jitter) + 0.5);
|
||||
float4 disp1 = float4(input.uv + disp0, 0, 0);
|
||||
float4 disp2 = float4(input.uv - disp0, 0, 0);
|
||||
|
||||
const int sampleCount = (int)min(_BokehData2.y, samples);
|
||||
UNITY_UNROLL
|
||||
for (int k=1;k<16;k++) {
|
||||
if (k<sampleCount) {
|
||||
float4 pixel1 = SAMPLE_TEXTURE2D_X_LOD(_MainTex, sampler_LinearClamp, disp1.xy, 0);
|
||||
float bt1 = saturate(pixel1.a * COC_BASE - k);
|
||||
sum = max(sum, bt1 * pixel1);
|
||||
disp1 += dir;
|
||||
float4 pixel2 = SAMPLE_TEXTURE2D_X_LOD(_MainTex, sampler_LinearClamp, disp2.xy, 0);
|
||||
float bt2 = saturate(pixel2.a * COC_BASE - k);
|
||||
sum = max(sum, bt2 * pixel2);
|
||||
disp2 -= dir;
|
||||
}
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
|
||||
#endif // BEAUTIFY_PPSDOF_FX
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1f6d4ab36910a4e2487f3638629e0492
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,126 @@
|
||||
#ifndef BEAUTIFY_PPSEA_FX
|
||||
#define BEAUTIFY_PPSEA_FX
|
||||
|
||||
// Copyright 2020-2021 Kronnect - All Rights Reserved.
|
||||
#include "BeautifyCommon.hlsl"
|
||||
|
||||
TEXTURE2D_X(_MainTex);
|
||||
TEXTURE2D_X(_EALumSrc);
|
||||
TEXTURE2D_X(_EAHist);
|
||||
TEXTURE2D(_EAMask);
|
||||
float4 _MainTex_TexelSize;
|
||||
float4 _MainTex_ST;
|
||||
float4 _EyeAdaptation;
|
||||
float4 _EyeAdaptation2; // x: center weight, y: min camera distance, z: middle gray, w: unused
|
||||
|
||||
struct VaryingsCross {
|
||||
float4 positionCS : SV_POSITION;
|
||||
float2 uv: TEXCOORD0;
|
||||
BEAUTIFY_VERTEX_CROSS_UV_DATA
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
VaryingsCross VertCross(AttributesSimple v) {
|
||||
VaryingsCross o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
o.positionCS = v.positionOS;
|
||||
o.positionCS.y *= _ProjectionParams.x * _FlipY;
|
||||
o.uv = v.uv;
|
||||
|
||||
BEAUTIFY_VERTEX_OUTPUT_CROSS_UV(o)
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 FragScreenLum (VaryingsSimple i) : SV_Target {
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
float2 uv = UnityStereoTransformScreenSpaceTex(i.uv);
|
||||
|
||||
#if BEAUTIFY_EA_USE_DEPTH
|
||||
float eyeDepth = BEAUTIFY_GET_SCENE_DEPTH_EYE(uv);
|
||||
if (eyeDepth < _EyeAdaptation2.y) {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
float4 c = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv);
|
||||
#if UNITY_COLORSPACE_GAMMA
|
||||
c.rgb = GAMMA_TO_LINEAR(c.rgb);
|
||||
#endif
|
||||
|
||||
float weight = 1.0;
|
||||
|
||||
#if !BEAUTIFY_EA_LEGACY_MODE
|
||||
#if BEAUTIFY_EA_USE_MASK
|
||||
float mask = SAMPLE_TEXTURE2D(_EAMask, sampler_LinearClamp, i.uv).a;
|
||||
weight = mask;
|
||||
#endif
|
||||
|
||||
float2 dc = uv - 0.5;
|
||||
float r2 = length(dc) * 2.0;
|
||||
weight *= exp(-r2 * _EyeAdaptation2.x);
|
||||
#endif
|
||||
|
||||
float weightClamped = saturate(weight);
|
||||
float luma = getLuma(c.rgb);
|
||||
float lumaLogRaw = log(1.0 + luma);
|
||||
|
||||
return float4(lumaLogRaw, lumaLogRaw, weightClamped, 0);
|
||||
}
|
||||
|
||||
float4 FragReduceScreenLum (VaryingsCross i) : SV_Target {
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
i.uv = UnityStereoTransformScreenSpaceTex(i.uv);
|
||||
BEAUTIFY_FRAG_SETUP_CROSS_UV(i);
|
||||
|
||||
float4 c1 = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv1);
|
||||
float4 c2 = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv2);
|
||||
float4 c3 = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv3);
|
||||
float4 c4 = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv4);
|
||||
|
||||
float maxLum = max( c1.g, max( c2.g, max( c3.g, c4.g )) ); // used by purkinje
|
||||
|
||||
#if BEAUTIFY_EA_LEGACY_MODE
|
||||
c1.r = (c1.r + c2.r + c3.r + c4.r) * 0.25;
|
||||
c1.g = maxLum;
|
||||
#else
|
||||
float w1 = c1.b;
|
||||
float w2 = c2.b;
|
||||
float w3 = c3.b;
|
||||
float w4 = c4.b;
|
||||
float weightSum = w1 + w2 + w3 + w4;
|
||||
|
||||
float weightedSum = c1.r * w1 + c2.r * w2 + c3.r * w3 + c4.r * w4;
|
||||
if (weightSum > 0) {
|
||||
weightedSum /= weightSum;
|
||||
}
|
||||
c1.r = weightedSum;
|
||||
c1.g = maxLum;
|
||||
c1.b = weightSum * 0.25;
|
||||
#endif
|
||||
|
||||
return c1;
|
||||
}
|
||||
|
||||
float4 FragBlendScreenLum (VaryingsSimple i) : SV_Target {
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
float2 uv = UnityStereoTransformScreenSpaceTex(float2(0.5, 0.5));
|
||||
|
||||
float4 c = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv);
|
||||
float4 p = SAMPLE_TEXTURE2D_X(_EAHist, sampler_LinearClamp, uv);
|
||||
float speed = c.r < p.r ? _EyeAdaptation.z: _EyeAdaptation.w;
|
||||
c.a = speed * unity_DeltaTime.x;
|
||||
return c;
|
||||
}
|
||||
|
||||
float4 FragBlend (VaryingsSimple i) : SV_Target {
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
i.uv = UnityStereoTransformScreenSpaceTex(i.uv);
|
||||
|
||||
float4 c = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, 0.5.xx);
|
||||
c.a = 1.0;
|
||||
return c;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 136698a3df19b478e98ecc73a7f68a1b
|
||||
timeCreated: 1518001072
|
||||
licenseType: Pro
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,106 @@
|
||||
#ifndef BEAUTIFY_PPS_FILM_GRAIN
|
||||
#define BEAUTIFY_PPS_FILM_GRAIN
|
||||
|
||||
float4 _FilmGrainData; // x: intensity, y: luma attenuation, z: resolution, w: unused
|
||||
float4 _FilmArtifactsData; // x: dirt spots amount, y: dirt spots intensity, z: scratches amount, w: scratches intensity
|
||||
|
||||
#define FILM_GRAIN_INTENSITY _FilmGrainData.x
|
||||
#define FILM_GRAIN_LUMA_ATTENUATION _FilmGrainData.y
|
||||
#define FILM_GRAIN_RESOLUTION _FilmGrainData.z
|
||||
|
||||
#define DIRT_SPOTS_AMOUNT _FilmArtifactsData.x
|
||||
#define DIRT_SPOTS_INTENSITY _FilmArtifactsData.y
|
||||
#define SCRATCHES_AMOUNT _FilmArtifactsData.z
|
||||
#define SCRATCHES_INTENSITY _FilmArtifactsData.w
|
||||
|
||||
float3 r3(float2 uv) {
|
||||
static const float2 magic1 = float2(321.8942, 1225.6548);
|
||||
static const float magic2 = 4251.4865;
|
||||
float d1 = dot(uv, magic1);
|
||||
float d2 = dot(uv + 0.1, magic1);
|
||||
float d3 = dot(uv + 0.2, magic1);
|
||||
return frac(sin(float3(d1, d2, d3)) * magic2 + _Time.y);
|
||||
}
|
||||
|
||||
inline float r1(float x) {
|
||||
static const float magic = 4251.4865;
|
||||
return frac(sin(x * 321.8942) * magic + _Time.y);
|
||||
}
|
||||
|
||||
|
||||
// Generate film artifacts like dirt spots and scratches
|
||||
float getFilmArtifacts(float2 uv) {
|
||||
float artifacts = 0.0;
|
||||
|
||||
// Dirt spots - small circular spots that appear randomly
|
||||
UNITY_BRANCH
|
||||
if (DIRT_SPOTS_AMOUNT > 0) {
|
||||
float2 dirtUV = uv * 20.0;
|
||||
float2 dirtCell = floor(dirtUV);
|
||||
float2 dirtFrac = dirtUV - dirtCell;
|
||||
float3 dirtRandom = r3(dirtCell + floor(_Time.y * 0.5));
|
||||
if (dirtRandom.x > DIRT_SPOTS_AMOUNT) {
|
||||
float2 dirtOffset = dirtFrac - 0.5;
|
||||
float dirtDistanceSqr = dot(dirtOffset, dirtOffset);
|
||||
float dirtSize = dirtRandom.y * 0.3 + 0.1;
|
||||
float dirtSpot = 1.0 - smoothstep(0.0, dirtSize * dirtSize, dirtDistanceSqr);
|
||||
artifacts += dirtSpot * (dirtRandom.z - 0.5) * DIRT_SPOTS_INTENSITY;
|
||||
}
|
||||
}
|
||||
|
||||
// Vertical scratches - appear occasionally and persist for a few frames
|
||||
UNITY_BRANCH
|
||||
if (SCRATCHES_AMOUNT > 0) {
|
||||
float scratchTime = floor(dot(_Time.xyzw, 1.0));
|
||||
float scratchRandom = r1(scratchTime);
|
||||
if (scratchRandom > SCRATCHES_AMOUNT) {
|
||||
float scratchX = r1(scratchTime + 0.1);
|
||||
float scratchWidth = 0.001 + r1(scratchTime + 0.2) * 0.003;
|
||||
float scratchDistance = abs(uv.x - scratchX);
|
||||
float scratch = 1.0 - smoothstep(0.0, scratchWidth, scratchDistance);
|
||||
artifacts += scratch * SCRATCHES_INTENSITY;
|
||||
}
|
||||
}
|
||||
|
||||
return artifacts;
|
||||
}
|
||||
|
||||
void ApplyFilmGrain(inout float3 rgb, float luma, float2 uv) {
|
||||
|
||||
float2 noiseSize = _MainTex_TexelSize.zw * FILM_GRAIN_RESOLUTION;
|
||||
float2 scaledUV = uv * noiseSize;
|
||||
float2 cell = floor(scaledUV);
|
||||
|
||||
#if BEAUTIFY_TURBO
|
||||
static const float c0 = 1.0f;
|
||||
static const float c1 = -1.828427f;
|
||||
static const float c2 = 0.828427f;
|
||||
float luminanceFactor = c0 + luma * (c1 + luma * c2);
|
||||
float3 grain = r3(cell / noiseSize);
|
||||
float artifacts = 0.0;
|
||||
#else
|
||||
float luminanceFactor = 1.0 - sqrt(luma);
|
||||
// Bilinear interpolation
|
||||
float2 fracUV = scaledUV - cell;
|
||||
float2 invNoiseSize = rcp(noiseSize);
|
||||
float3 rand00 = r3(cell * invNoiseSize);
|
||||
float3 rand10 = r3((cell + float2(1, 0)) * invNoiseSize);
|
||||
float3 rand01 = r3((cell + float2(0, 1)) * invNoiseSize);
|
||||
float3 rand11 = r3((cell + float2(1, 1)) * invNoiseSize);
|
||||
float3 randX0 = lerp(rand00, rand10, fracUV.x);
|
||||
float3 randX1 = lerp(rand01, rand11, fracUV.x);
|
||||
float3 grain = lerp(randX0, randX1, fracUV.y);
|
||||
float artifacts = getFilmArtifacts(uv);
|
||||
#endif
|
||||
|
||||
static const float3 channelSensibility = float3(1, 0.95, 1.05);
|
||||
grain = (grain - 0.5) * channelSensibility;
|
||||
|
||||
float grainAmount = lerp(1.0, luminanceFactor, FILM_GRAIN_LUMA_ATTENUATION);
|
||||
|
||||
rgb *= 1.0 + grain * grainAmount * FILM_GRAIN_INTENSITY + artifacts;
|
||||
|
||||
rgb = saturate(rgb);
|
||||
}
|
||||
|
||||
#endif // BEAUTIFY_PPS_FILM_GRAIN
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a2f62a5fa4eb746948cde9ffbfa3fa3f
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,411 @@
|
||||
#ifndef BEAUTIFY_PPSLUM_FX
|
||||
#define BEAUTIFY_PPSLUM_FX
|
||||
|
||||
// Copyright 2020-2021 Kronnect - All Rights Reserved.
|
||||
#include "BeautifyCommon.hlsl"
|
||||
|
||||
TEXTURE2D_X(_MainTex);
|
||||
TEXTURE2D_X(_BloomTex);
|
||||
float4 _BloomTex_TexelSize;
|
||||
TEXTURE2D_X(_CombineTex);
|
||||
TEXTURE2D_X(_BloomTex1);
|
||||
TEXTURE2D_X(_BloomTex2);
|
||||
TEXTURE2D_X(_BloomTex3);
|
||||
TEXTURE2D_X(_BloomTex4);
|
||||
float4 _MainTex_TexelSize;
|
||||
float4 _MainTex_ST;
|
||||
float4 _Bloom;
|
||||
float4 _BloomWeights;
|
||||
float4 _BloomWeights2;
|
||||
float4 _BloomTint;
|
||||
float3 _BloomTint0, _BloomTint1, _BloomTint2, _BloomTint3, _BloomTint4, _BloomTint5;
|
||||
float _BloomSpread;
|
||||
float4 _AFTint;
|
||||
float _BlurScale;
|
||||
float4 _AFData;
|
||||
|
||||
#if defined(USE_AF_THRESHOLD)
|
||||
#define MAX_BRIGHTNESS _AFData.w
|
||||
#else
|
||||
#define MAX_BRIGHTNESS _BloomWeights2.z
|
||||
|
||||
#endif
|
||||
#if BEAUTIFY_BLOOM_USE_DEPTH || BEAUTIFY_ANAMORPHIC_FLARES_USE_DEPTH
|
||||
float _BloomDepthThreshold;
|
||||
float _BloomNearThreshold;
|
||||
float _AFDepthThreshold;
|
||||
float _AFNearThreshold;
|
||||
#endif
|
||||
|
||||
TEXTURE2D_X(_BloomSourceDepth);
|
||||
TEXTURE2D_X(_AFSourceDepth);
|
||||
|
||||
struct VaryingsCross {
|
||||
float4 positionCS : SV_POSITION;
|
||||
float2 uv: TEXCOORD0;
|
||||
BEAUTIFY_VERTEX_CROSS_UV_DATA
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
struct VaryingsLum {
|
||||
float4 positionCS : SV_POSITION;
|
||||
float2 uv: TEXCOORD0;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
struct VaryingsCrossLum {
|
||||
float4 positionCS : SV_POSITION;
|
||||
float2 uv: TEXCOORD0;
|
||||
BEAUTIFY_VERTEX_CROSS_UV_DATA
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
|
||||
VaryingsLum VertLum(AttributesSimple input) {
|
||||
|
||||
VaryingsLum output;
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
output.positionCS = input.positionOS;
|
||||
output.positionCS.y *= _ProjectionParams.x * _FlipY;
|
||||
output.uv = input.uv;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
half Brightness(half3 c) {
|
||||
return max(c.r, max(c.g, c.b));
|
||||
}
|
||||
|
||||
half Included(half4 c) {
|
||||
#if BEAUTIFY_BLOOM_USE_LAYER_INCLUSION || BEAUTIFY_ANAMORPHIC_FLARES_USE_LAYER_INCLUSION
|
||||
return Brightness(c.rgb) >= 0.01;
|
||||
#else
|
||||
return Brightness(c.rgb) < 0.01;
|
||||
#endif
|
||||
}
|
||||
|
||||
half3 ColorAboveThreshold(half3 c, half brightness) {
|
||||
#if defined(USE_AF_THRESHOLD)
|
||||
half threshold = _AFData.y;
|
||||
#else
|
||||
half threshold = _Bloom.w;
|
||||
#endif
|
||||
|
||||
#if BEAUTIFY_ANAMORPHIC_PROP_THRESHOLDING || BEAUTIFY_BLOOM_PROP_THRESHOLDING
|
||||
half cs = clamp(brightness - 0.5 * threshold, 0.0, threshold);
|
||||
cs = 0.5 * cs * cs / (threshold + 0.0001);
|
||||
c *= max(brightness - threshold, cs) / max(brightness, 0.0001);
|
||||
#else
|
||||
c = max(c - threshold, 0);
|
||||
#endif
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
half4 FragLum (VaryingsLum i) : SV_Target {
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
i.uv = UnityStereoTransformScreenSpaceTex(i.uv);
|
||||
|
||||
half4 c = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, i.uv);
|
||||
c = clamp(c, 0.0.xxxx, MAX_BRIGHTNESS.xxxx);
|
||||
|
||||
#if UNITY_COLORSPACE_GAMMA
|
||||
c.rgb = GAMMA_TO_LINEAR(c.rgb);
|
||||
#endif
|
||||
|
||||
#if BEAUTIFY_BLOOM_USE_DEPTH || BEAUTIFY_ANAMORPHIC_FLARES_USE_DEPTH
|
||||
float depth01 = BEAUTIFY_GET_SCENE_DEPTH_01(i.uv);
|
||||
#endif
|
||||
|
||||
#if BEAUTIFY_BLOOM_USE_DEPTH
|
||||
c.rgb *= max(0, 1.0 - depth01 * _BloomDepthThreshold);
|
||||
c.rgb *= min(1.0, depth01 / _BloomNearThreshold);
|
||||
#endif
|
||||
|
||||
#if BEAUTIFY_ANAMORPHIC_FLARES_USE_DEPTH
|
||||
c.rgb *= max(0, 1.0 - depth01 * _AFDepthThreshold);
|
||||
c.rgb *= min(1.0, depth01 / _AFNearThreshold);
|
||||
#endif
|
||||
|
||||
#if BEAUTIFY_BLOOM_USE_LAYER || BEAUTIFY_BLOOM_USE_LAYER_INCLUSION
|
||||
half included = Included(SAMPLE_TEXTURE2D_X(_BloomSourceDepth, sampler_LinearClamp, i.uv));
|
||||
c.rgb *= included;
|
||||
#endif
|
||||
|
||||
#if BEAUTIFY_ANAMORPHIC_FLARES_USE_LAYER || BEAUTIFY_ANAMORPHIC_FLARES_USE_LAYER_INCLUSION
|
||||
half included = Included(SAMPLE_TEXTURE2D_X(_AFSourceDepth, sampler_LinearClamp, i.uv));
|
||||
c.rgb *= included;
|
||||
#endif
|
||||
|
||||
c.a = Brightness(c.rgb);
|
||||
#if !defined(USE_AF_THRESHOLD)
|
||||
c.rgb = lerp(c.rgb, c.a * _BloomTint.rgb, _BloomTint.a);
|
||||
#endif
|
||||
c.rgb = ColorAboveThreshold(c.rgb, c.a);
|
||||
return c;
|
||||
}
|
||||
|
||||
VaryingsCross VertCross(AttributesSimple v) {
|
||||
VaryingsCross o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
o.positionCS = v.positionOS;
|
||||
o.positionCS.y *= _ProjectionParams.x * _FlipY;
|
||||
o.uv = v.uv;
|
||||
BEAUTIFY_VERTEX_OUTPUT_CROSS_UV(o)
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
VaryingsCrossLum VertCrossLum(AttributesSimple v) {
|
||||
VaryingsCrossLum o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
o.positionCS = v.positionOS;
|
||||
o.positionCS.y *= _ProjectionParams.x * _FlipY;
|
||||
o.uv = v.uv;
|
||||
BEAUTIFY_VERTEX_OUTPUT_CROSS_UV(o)
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 FragLumAntiflicker(VaryingsCrossLum i) : SV_Target {
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
i.uv = UnityStereoTransformScreenSpaceTex(i.uv);
|
||||
BEAUTIFY_FRAG_SETUP_CROSS_UV(i)
|
||||
|
||||
half4 c1 = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv1);
|
||||
half4 c2 = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv2);
|
||||
half4 c3 = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv3);
|
||||
half4 c4 = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv4);
|
||||
|
||||
c1 = clamp(c1, 0.0.xxxx, MAX_BRIGHTNESS.xxxx);
|
||||
c2 = clamp(c2, 0.0.xxxx, MAX_BRIGHTNESS.xxxx);
|
||||
c3 = clamp(c3, 0.0.xxxx, MAX_BRIGHTNESS.xxxx);
|
||||
c4 = clamp(c4, 0.0.xxxx, MAX_BRIGHTNESS.xxxx);
|
||||
|
||||
#if BEAUTIFY_BLOOM_USE_DEPTH || BEAUTIFY_ANAMORPHIC_FLARES_USE_DEPTH
|
||||
float depth01 = BEAUTIFY_GET_SCENE_DEPTH_01(i.uv);
|
||||
#endif
|
||||
|
||||
#if BEAUTIFY_BLOOM_USE_DEPTH
|
||||
float depthAtten = max(0, 1.0 - depth01 * _BloomDepthThreshold);
|
||||
c1.rgb *= depthAtten;
|
||||
c2.rgb *= depthAtten;
|
||||
c3.rgb *= depthAtten;
|
||||
c4.rgb *= depthAtten;
|
||||
float nearAtten = min(1.0, depth01 / _BloomNearThreshold);
|
||||
c1.rgb *= nearAtten;
|
||||
c2.rgb *= nearAtten;
|
||||
c3.rgb *= nearAtten;
|
||||
c4.rgb *= nearAtten;
|
||||
#endif
|
||||
|
||||
#if BEAUTIFY_ANAMORPHIC_FLARES_USE_DEPTH
|
||||
float depthAtten = max(0, 1.0 - depth01 * _AFDepthThreshold);
|
||||
c1.rgb *= depthAtten;
|
||||
c2.rgb *= depthAtten;
|
||||
c3.rgb *= depthAtten;
|
||||
c4.rgb *= depthAtten;
|
||||
float nearAtten = min(1.0, depth01 / _AFNearThreshold);
|
||||
c1.rgb *= nearAtten;
|
||||
c2.rgb *= nearAtten;
|
||||
c3.rgb *= nearAtten;
|
||||
c4.rgb *= nearAtten;
|
||||
#endif
|
||||
|
||||
#if BEAUTIFY_BLOOM_USE_LAYER || BEAUTIFY_BLOOM_USE_LAYER_INCLUSION
|
||||
half included = Included(SAMPLE_TEXTURE2D_X(_BloomSourceDepth, sampler_LinearClamp, i.uv));
|
||||
c1.rgb *= included;
|
||||
c2.rgb *= included;
|
||||
c3.rgb *= included;
|
||||
c4.rgb *= included;
|
||||
#endif
|
||||
|
||||
#if BEAUTIFY_ANAMORPHIC_FLARES_USE_LAYER || BEAUTIFY_ANAMORPHIC_FLARES_USE_LAYER_INCLUSION
|
||||
half included = Included(SAMPLE_TEXTURE2D_X(_AFSourceDepth, sampler_LinearClamp, i.uv));
|
||||
c1.rgb *= included;
|
||||
c2.rgb *= included;
|
||||
c3.rgb *= included;
|
||||
c4.rgb *= included;
|
||||
#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 = GAMMA_TO_LINEAR(c1.rgb);
|
||||
#endif
|
||||
|
||||
#if !defined(USE_AF_THRESHOLD)
|
||||
c1.rgb = lerp(c1.rgb, c1.a * _BloomTint.rgb, _BloomTint.a);
|
||||
#endif
|
||||
c1.rgb = ColorAboveThreshold(c1.rgb, c1.a);
|
||||
|
||||
return c1;
|
||||
}
|
||||
|
||||
float4 FragBloomCompose (VaryingsSimple i) : SV_Target {
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
i.uv = UnityStereoTransformScreenSpaceTex(i.uv);
|
||||
|
||||
float4 b0 = SAMPLE_TEXTURE2D_X( _BloomTex , sampler_LinearClamp, i.uv );
|
||||
float4 b1 = SAMPLE_TEXTURE2D_X( _BloomTex1 , sampler_LinearClamp, i.uv );
|
||||
float4 b2 = SAMPLE_TEXTURE2D_X( _BloomTex2 , sampler_LinearClamp, i.uv );
|
||||
float4 b3 = SAMPLE_TEXTURE2D_X( _BloomTex3 , sampler_LinearClamp, i.uv );
|
||||
float4 b4 = SAMPLE_TEXTURE2D_X( _BloomTex4 , sampler_LinearClamp, i.uv );
|
||||
float4 b5 = SAMPLE_TEXTURE2D_X( _MainTex , sampler_LinearClamp, i.uv );
|
||||
b0.rgb *= _BloomTint0;
|
||||
b1.rgb *= _BloomTint1;
|
||||
b2.rgb *= _BloomTint2;
|
||||
b3.rgb *= _BloomTint3;
|
||||
b4.rgb *= _BloomTint4;
|
||||
b5.rgb *= _BloomTint5;
|
||||
float4 pixel = b0 * _BloomWeights.x + b1 * _BloomWeights.y + b2 * _BloomWeights.z + b3 * _BloomWeights.w + b4 * _BloomWeights2.x + b5 * _BloomWeights2.y;
|
||||
//pixel.rgb = lerp(pixel.rgb, Brightness(pixel.rgb) * _BloomTint.rgb, _BloomTint.a);
|
||||
return pixel;
|
||||
}
|
||||
|
||||
inline float4 Lerp3(float4 a, float4 b, float4 c, float t) {
|
||||
if (t <= 0.5) {
|
||||
return lerp(a, b, t * 2.0);
|
||||
} else {
|
||||
return lerp(b, c, t * 2.0 - 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
float4 FragResample(VaryingsCross i) : SV_Target {
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
i.uv = UnityStereoTransformScreenSpaceTex(i.uv);
|
||||
BEAUTIFY_FRAG_SETUP_CROSS_UV(i)
|
||||
|
||||
float4 c1 = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv1);
|
||||
float4 c2 = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv2);
|
||||
float4 c3 = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv3);
|
||||
float4 c4 = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv4);
|
||||
|
||||
float w1 = 1.0 / (c1.a + 1.0);
|
||||
float w2 = 1.0 / (c2.a + 1.0);
|
||||
float w3 = 1.0 / (c3.a + 1.0);
|
||||
float w4 = 1.0 / (c4.a + 1.0);
|
||||
|
||||
float dd = 1.0 / (w1 + w2 + w3 + w4);
|
||||
float4 v = (c1 * w1 + c2 * w2 + c3 * w3 + c4 * w4) * dd;
|
||||
#if defined(COMBINE_BLOOM)
|
||||
float4 o = SAMPLE_TEXTURE2D_X(_BloomTex, sampler_LinearClamp, i.uv);
|
||||
v = Lerp3(o, o+v, v, _BloomSpread);
|
||||
#endif
|
||||
return v;
|
||||
}
|
||||
|
||||
float4 FragResampleAF(VaryingsCross i) : SV_Target {
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
i.uv = UnityStereoTransformScreenSpaceTex(i.uv);
|
||||
BEAUTIFY_FRAG_SETUP_CROSS_UV(i)
|
||||
|
||||
float4 c1 = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv1);
|
||||
float4 c2 = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv2);
|
||||
float4 c3 = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv3);
|
||||
float4 c4 = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv4);
|
||||
|
||||
float w1 = 1.0 / (c1.a + 1.0);
|
||||
float w2 = 1.0 / (c2.a + 1.0);
|
||||
float w3 = 1.0 / (c3.a + 1.0);
|
||||
float w4 = 1.0 / (c4.a + 1.0);
|
||||
|
||||
float dd = 1.0 / (w1 + w2 + w3 + w4);
|
||||
float4 v = (c1 * w1 + c2 * w2 + c3 * w3 + c4 * w4) * dd;
|
||||
v.rgb = lerp(v.rgb, Brightness(c1.rgb) * _AFTint.rgb, _AFTint.a);
|
||||
v.rgb *= _AFData.xxx;
|
||||
|
||||
#if defined(COMBINE_BLOOM)
|
||||
float4 o = SAMPLE_TEXTURE2D_X(_BloomTex, sampler_LinearClamp, i.uv);
|
||||
v += o;
|
||||
#endif
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
float4 FragCombine(VaryingsSimple i) : SV_Target {
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
i.uv = UnityStereoTransformScreenSpaceTex(i.uv);
|
||||
|
||||
float4 c1 = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, i.uv);
|
||||
float4 c2 = SAMPLE_TEXTURE2D_X(_CombineTex, sampler_LinearClamp, i.uv);
|
||||
return c1 + c2;
|
||||
}
|
||||
|
||||
|
||||
float4 FragDebugBloom (VaryingsSimple i) : SV_Target {
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
i.uv = UnityStereoTransformScreenSpaceTex(i.uv);
|
||||
|
||||
return SAMPLE_TEXTURE2D_X(_BloomTex, sampler_LinearClamp, i.uv) * _Bloom.xxxx;
|
||||
}
|
||||
|
||||
|
||||
float4 FragDebugBloomExclusionLayer (VaryingsSimple i) : SV_Target {
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
i.uv = UnityStereoTransformScreenSpaceTex(i.uv);
|
||||
|
||||
float depth = BEAUTIFY_GET_CUSTOM_DEPTH_01(_BloomSourceDepth, i.uv);
|
||||
return float4(depth.xxx, 1.0);
|
||||
}
|
||||
|
||||
float4 FragDebugAnamorphicFlaresExclusionLayer (VaryingsSimple i) : SV_Target {
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
i.uv = UnityStereoTransformScreenSpaceTex(i.uv);
|
||||
|
||||
float depth = BEAUTIFY_GET_CUSTOM_DEPTH_01(_AFSourceDepth, i.uv);
|
||||
return float4(depth.xxx, 1.0);
|
||||
}
|
||||
|
||||
float4 FragResampleFastAF(VaryingsSimple i) : SV_Target {
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
i.uv = UnityStereoTransformScreenSpaceTex(i.uv);
|
||||
|
||||
float4 c = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, i.uv);
|
||||
c.rgb = lerp(c.rgb, Brightness(c.rgb) * _AFTint.rgb, _AFTint.a);
|
||||
c.rgb *= _AFData.xxx;
|
||||
return c;
|
||||
}
|
||||
|
||||
VaryingsCross VertBlur(AttributesSimple v) {
|
||||
VaryingsCross o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
o.positionCS = v.positionOS;
|
||||
o.positionCS.y *= _ProjectionParams.x * _FlipY;
|
||||
o.uv = v.uv;
|
||||
BEAUTIFY_VERTEX_OUTPUT_GAUSSIAN_UV(o)
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 FragBlur (VaryingsCross i): SV_Target {
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
i.uv = UnityStereoTransformScreenSpaceTex(i.uv);
|
||||
BEAUTIFY_FRAG_SETUP_GAUSSIAN_UV(i)
|
||||
|
||||
float4 pixel = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, i.uv) * 0.2270270270
|
||||
+ (SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv1) + SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv2)) * 0.3162162162
|
||||
+ (SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv3) + SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv4)) * 0.0702702703;
|
||||
return pixel;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5dc8cdd18d3c6470e91404ae4fab3163
|
||||
timeCreated: 1518001072
|
||||
licenseType: Pro
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,205 @@
|
||||
#ifndef BEAUTIFY_PPSOUTLINE
|
||||
#define BEAUTIFY_PPSOUTLINE
|
||||
// Copyright 2016-2021 Ramiro Oliva (Kronnect) - All Rights Reserved.
|
||||
|
||||
#include "BeautifyCommon.hlsl"
|
||||
|
||||
TEXTURE2D_X(_MainTex);
|
||||
float4 _MainTex_TexelSize;
|
||||
float4 _MainTex_ST;
|
||||
|
||||
TEXTURE2D_X_FLOAT(_OutlineDepth);
|
||||
TEXTURE2D_X_FLOAT(_OutlineObjectId);
|
||||
|
||||
float4 _Outline;
|
||||
#define OUTLINE_EDGE_THRESHOLD _Outline.a
|
||||
|
||||
float4 _OutlineData;
|
||||
#define OUTLINE_INTENSITY_MULTIPLIER _OutlineData.x
|
||||
#define OUTLINE_DISTANCE_FADE _OutlineData.y
|
||||
#define OUTLINE_MIN_DEPTH_THRESHOLD _OutlineData.z
|
||||
#define OUTLINE_MIN_SATURATION_THRESHOLD _OutlineData.w
|
||||
|
||||
half _BlurScale;
|
||||
#define OUTLINE_MIN_SEPARATION _OutlineData.z
|
||||
|
||||
struct VaryingsOutline {
|
||||
float4 positionCS : SV_POSITION;
|
||||
float2 uv: TEXCOORD0;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
struct VaryingsCross {
|
||||
float4 positionCS : SV_POSITION;
|
||||
float2 uv: TEXCOORD0;
|
||||
BEAUTIFY_VERTEX_CROSS_UV_DATA
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
|
||||
VaryingsOutline VertOutline(AttributesSimple input) {
|
||||
VaryingsOutline output;
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
output.positionCS = input.positionOS;
|
||||
output.positionCS.y *= _ProjectionParams.x * _FlipY;
|
||||
output.uv = input.uv;
|
||||
return output;
|
||||
}
|
||||
|
||||
float OutlinePass(VaryingsOutline i) {
|
||||
|
||||
float3 uvInc = float3(_MainTex_TexelSize.x, _MainTex_TexelSize.y, 0);
|
||||
|
||||
#if BEAUTIFY_DEPTH_FADE || !BEAUTIFY_OUTLINE_SOBEL
|
||||
#if BEAUTIFY_OUTLINE_CUSTOM_DEPTH || BEAUTIFY_OUTLINE_OBJECT_ID
|
||||
float depth = BEAUTIFY_GET_CUSTOM_DEPTH_01(_OutlineDepth, i.uv);
|
||||
float sceneDepth = BEAUTIFY_GET_SCENE_DEPTH_01(i.uv);
|
||||
if (sceneDepth < depth * 0.999) return 0;
|
||||
#else
|
||||
float depth = BEAUTIFY_GET_SCENE_DEPTH_01(i.uv);
|
||||
if (depth >= 1.0) return 0;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
float outline = 0;
|
||||
|
||||
#if BEAUTIFY_OUTLINE_OBJECT_ID && !BEAUTIFY_OUTLINE_SOBEL
|
||||
float objS = SAMPLE_TEXTURE2D_X(_OutlineObjectId, sampler_PointClamp, i.uv - uvInc.zy).x;
|
||||
float objN = SAMPLE_TEXTURE2D_X(_OutlineObjectId, sampler_PointClamp, i.uv + uvInc.zy).x;
|
||||
float objW = SAMPLE_TEXTURE2D_X(_OutlineObjectId, sampler_PointClamp, i.uv - uvInc.xz).x;
|
||||
float objE = SAMPLE_TEXTURE2D_X(_OutlineObjectId, sampler_PointClamp, i.uv + uvInc.xz).x;
|
||||
float maxObj = max( max(objS, objN), max(objW, objE) );
|
||||
float minObj = min( min(objS, objN), min(objW, objE) );
|
||||
float objDiff = maxObj - minObj;
|
||||
outline = objDiff > 0.01;
|
||||
|
||||
#if BEAUTIFY_OUTLINE_OUTER_ONLY
|
||||
float depthN = BEAUTIFY_GET_CUSTOM_DEPTH_01(_OutlineDepth, i.uv + uvInc.zy);
|
||||
float depthS = BEAUTIFY_GET_CUSTOM_DEPTH_01(_OutlineDepth, i.uv - uvInc.zy);
|
||||
float depthW = BEAUTIFY_GET_CUSTOM_DEPTH_01(_OutlineDepth, i.uv - uvInc.xz);
|
||||
float depthE = BEAUTIFY_GET_CUSTOM_DEPTH_01(_OutlineDepth, i.uv + uvInc.xz);
|
||||
|
||||
float objM = SAMPLE_TEXTURE2D_X(_OutlineObjectId, sampler_PointClamp, i.uv).x;
|
||||
if ( (depth < depthN && abs(objN - objM) > 0.01) ||
|
||||
(depth < depthS && abs(objS - objM) > 0.01) ||
|
||||
(depth < depthW && abs(objW - objM) > 0.01) ||
|
||||
(depth < depthE && abs(objE - objM) > 0.01))
|
||||
outline = 0;
|
||||
#endif
|
||||
|
||||
// check object is big enough
|
||||
#if BEAUTIFY_OUTLINE_MIN_SEPARATION
|
||||
uvInc *= OUTLINE_MIN_SEPARATION;
|
||||
float objS2 = SAMPLE_TEXTURE2D_X(_OutlineObjectId, sampler_PointClamp, i.uv - uvInc.zy).x;
|
||||
float objN2 = SAMPLE_TEXTURE2D_X(_OutlineObjectId, sampler_PointClamp, i.uv + uvInc.zy).x;
|
||||
if (abs(objN2 - objN) > 0.01 && abs(objS2 - objS) > 0.01) outline *= 0.25 / OUTLINE_INTENSITY_MULTIPLIER;
|
||||
float objW2 = SAMPLE_TEXTURE2D_X(_OutlineObjectId, sampler_PointClamp, i.uv - uvInc.xz).x;
|
||||
float objE2 = SAMPLE_TEXTURE2D_X(_OutlineObjectId, sampler_PointClamp, i.uv + uvInc.xz).x;
|
||||
if (abs(objE2 - objE) > 0.01 && abs(objW2 - objW) > 0.01) outline *= 0.25 / OUTLINE_INTENSITY_MULTIPLIER;
|
||||
#endif
|
||||
|
||||
#else
|
||||
float3 rgbS = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, i.uv - uvInc.zy).rgb;
|
||||
float3 rgbN = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, i.uv + uvInc.zy).rgb;
|
||||
float3 rgbW = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, i.uv - uvInc.xz).rgb;
|
||||
float3 rgbE = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, i.uv + uvInc.xz).rgb;
|
||||
|
||||
#if BEAUTIFY_OUTLINE_CUSTOM_DEPTH || !BEAUTIFY_OUTLINE_SOBEL
|
||||
#if BEAUTIFY_OUTLINE_CUSTOM_DEPTH
|
||||
float depthS = BEAUTIFY_GET_CUSTOM_DEPTH_01(_OutlineDepth, i.uv - uvInc.zy);
|
||||
float depthW = BEAUTIFY_GET_CUSTOM_DEPTH_01(_OutlineDepth, i.uv - uvInc.xz);
|
||||
float depthE = BEAUTIFY_GET_CUSTOM_DEPTH_01(_OutlineDepth, i.uv + uvInc.xz);
|
||||
float depthN = BEAUTIFY_GET_CUSTOM_DEPTH_01(_OutlineDepth, i.uv + uvInc.zy);
|
||||
#else
|
||||
float depthS = BEAUTIFY_GET_SCENE_DEPTH_01(i.uv - uvInc.zy);
|
||||
float depthW = BEAUTIFY_GET_SCENE_DEPTH_01(i.uv - uvInc.xz);
|
||||
float depthE = BEAUTIFY_GET_SCENE_DEPTH_01(i.uv + uvInc.xz);
|
||||
float depthN = BEAUTIFY_GET_SCENE_DEPTH_01(i.uv + uvInc.zy);
|
||||
#endif
|
||||
float maxDepth = max(depth, max(max(depthS, depthN), max(depthW, depthE)));
|
||||
float minDepth = min(depth, min(min(depthS, depthN), min(depthW, depthE)));
|
||||
float depthDiff = maxDepth - minDepth;
|
||||
float3 normalNW = getNormal(depth, depthN, depthW, uvInc.zy, float2(-uvInc.x, -uvInc.z));
|
||||
float3 normalSE = getNormal(depth, depthS, depthE, -uvInc.zy, uvInc.xz);
|
||||
float dnorm = dot(normalNW, normalSE);
|
||||
float satN = getSaturation(rgbN);
|
||||
float satS = getSaturation(rgbS);
|
||||
float satW = getSaturation(rgbW);
|
||||
float satE = getSaturation(rgbE);
|
||||
float maxSat = max( max(satN, satS), max(satW, satE) );
|
||||
float minSat = min( min(satN, satS), min(satW, satE) );
|
||||
float dSat = maxSat - minSat;
|
||||
outline = dSat > OUTLINE_MIN_SATURATION_THRESHOLD && dnorm < OUTLINE_EDGE_THRESHOLD && depthDiff > OUTLINE_MIN_DEPTH_THRESHOLD;
|
||||
#else
|
||||
float3 rgbSW = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, i.uv - uvInc.xy).rgb;
|
||||
float3 rgbNE = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, i.uv + uvInc.xy).rgb;
|
||||
float3 rgbSE = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, i.uv + float2( uvInc.x, -uvInc.y)).rgb;
|
||||
float3 rgbNW = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, i.uv + float2(-uvInc.x, uvInc.y)).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;
|
||||
outline = (length(gx * gx + gy * gy) - _Outline.a) > 0.0;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if BEAUTIFY_DEPTH_FADE
|
||||
float factor = max(0, (OUTLINE_DISTANCE_FADE - depth) / OUTLINE_DISTANCE_FADE);
|
||||
outline *= factor;
|
||||
#endif
|
||||
|
||||
return outline;
|
||||
}
|
||||
|
||||
float4 fragOutline (VaryingsOutline i) : SV_Target {
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
i.uv = UnityStereoTransformScreenSpaceTex(i.uv);
|
||||
float outline = OutlinePass(i);
|
||||
return outline;
|
||||
}
|
||||
|
||||
|
||||
VaryingsCross VertBlur(AttributesSimple v) {
|
||||
VaryingsCross o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
o.positionCS = v.positionOS;
|
||||
o.positionCS.y *= _ProjectionParams.x * _FlipY;
|
||||
o.uv = v.uv;
|
||||
BEAUTIFY_VERTEX_OUTPUT_GAUSSIAN_UV(o)
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 FragBlur (VaryingsCross i): SV_Target {
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
i.uv = UnityStereoTransformScreenSpaceTex(i.uv);
|
||||
BEAUTIFY_FRAG_SETUP_GAUSSIAN_UV(i)
|
||||
|
||||
half4 pixel = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, i.uv) * 0.2270270270
|
||||
+ (SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv1) + SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv2)) * 0.3162162162
|
||||
+ (SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv3) + SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, uv4)) * 0.0702702703;
|
||||
return pixel;
|
||||
}
|
||||
|
||||
half4 FragCopy (VaryingsSimple i): SV_Target {
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
i.uv = UnityStereoTransformScreenSpaceTex(i.uv);
|
||||
half outline = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, i.uv).r;
|
||||
half4 color = half4(_Outline.rgb, _Outline.a * outline);
|
||||
color *= OUTLINE_INTENSITY_MULTIPLIER;
|
||||
color.a = saturate(color.a);
|
||||
return color;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c704640fa1801475a870ff4fc5e06b86
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,196 @@
|
||||
#ifndef BEAUTIFY_PPSSF_FX
|
||||
#define BEAUTIFY_PPSSF_FX
|
||||
|
||||
// Copyright 2020-2021 Kronnect - All Rights Reserved.
|
||||
#include "BeautifyCommon.hlsl"
|
||||
|
||||
TEXTURE2D_X(_MainTex);
|
||||
TEXTURE2D(_FlareTex);
|
||||
TEXTURE2D(_OcclusionTex);
|
||||
|
||||
float4 _MainTex_ST;
|
||||
float4 _MainTex_TexelSize;
|
||||
float4 _SunPos;
|
||||
float3 _SunDir;
|
||||
float4 _SunData; // x = sunIntensity, y = disk size, z = ray difraction, w = ray difraction amount
|
||||
float4 _SunCoronaRays1; // x = length, y = streaks, z = spread, w = angle offset
|
||||
float4 _SunCoronaRays2; // x = length, y = streaks, z = spread, w = angle offset
|
||||
float4 _SunGhosts1; // x = reserved, y = size, 2 = pos offset, 3 = brightness
|
||||
float4 _SunGhosts2; // x = reserved, y = size, 2 = pos offset, 3 = brightness
|
||||
float4 _SunGhosts3; // x = reserved, y = size, 2 = pos offset, 3 = brightness
|
||||
float4 _SunGhosts4; // x = reserved, y = size, 2 = pos offset, 3 = brightness
|
||||
float3 _SunHalo; // x = offset, y = amplitude, z = intensity
|
||||
float4 _SunTint;
|
||||
float _SunFlaresAspectRatio;
|
||||
float _SunOcclusionThreshold;
|
||||
#define SUN_TINT_COLOR _SunTint.rgb
|
||||
#define OCCLUSION_SPEED _SunTint.a
|
||||
#define OCCLUSION_THRESHOLD _SunOcclusionThreshold
|
||||
|
||||
struct VaryingsSF {
|
||||
float4 positionCS : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float2 sunPos : TEXCOORD1;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
VaryingsSF VertSF(AttributesSimple input) {
|
||||
VaryingsSF output;
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
output.positionCS = input.positionOS;
|
||||
output.positionCS.y *= _ProjectionParams.x * _FlipY;
|
||||
output.uv = input.uv.xy;
|
||||
|
||||
float4 clipPos = TransformWorldToHClip(_WorldSpaceCameraPos.xyz - _SunDir.xyz * 1000.0);
|
||||
float2 sunPos = float2(clipPos.x, clipPos.y * _ProjectionParams.x) * 0.5 / clipPos.w + 0.5;
|
||||
output.sunPos = sunPos;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
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(VaryingsSF input) {
|
||||
|
||||
// general params
|
||||
float2 uv = input.uv;
|
||||
float2 sunPos = input.sunPos;
|
||||
|
||||
#if BEAUTIFY_SF_OCCLUSION_SIMPLE
|
||||
float depth = BEAUTIFY_GET_SCENE_DEPTH_01(sunPos);
|
||||
if (depth < 1.0) return 0;
|
||||
const float occlusion = 1.0;
|
||||
#elif BEAUTIFY_SF_OCCLUSION_SMOOTH
|
||||
float occlusion = SAMPLE_TEXTURE2D(_OcclusionTex, sampler_LinearRepeat, float2(0,0)).r;
|
||||
if (occlusion <= 0.02) return 0.0.xxx;
|
||||
#else
|
||||
const float occlusion = 1.0;
|
||||
#endif
|
||||
|
||||
float2 grd = uv - sunPos;
|
||||
float aspectRatio = _SunFlaresAspectRatio;
|
||||
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;
|
||||
|
||||
float3 flare = s0.xxx;
|
||||
|
||||
#if BEAUTIFY_SF_USE_GHOSTS // defined(UNITY_SINGLE_PASS_STEREO) && !defined(UNITY_STEREO_INSTANCING_ENABLED) && !defined(UNITY_STEREO_MULTIVIEW_ENABLED)
|
||||
// ghosts circular (not compatible with XR due to how projection works)
|
||||
|
||||
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;
|
||||
|
||||
#endif
|
||||
|
||||
// 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(SAMPLE_TEXTURE2D(_FlareTex, sampler_LinearRepeat, 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 max(0, flare * SUN_TINT_COLOR * occlusion);
|
||||
}
|
||||
|
||||
float4 FragSF (VaryingsSF i) : SV_Target {
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
//i.uv = UnityStereoTransformScreenSpaceTex(i.uv);
|
||||
|
||||
return float4(sunflare(i), 1.0);
|
||||
}
|
||||
|
||||
float4 FragSFAdditive (VaryingsSF i) : SV_Target {
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
float2 stereoUV = UnityStereoTransformScreenSpaceTex(i.uv);
|
||||
|
||||
float4 p = SAMPLE_TEXTURE2D_X(_MainTex, sampler_LinearClamp, stereoUV);
|
||||
return p + float4(sunflare(i), 1.0);
|
||||
}
|
||||
|
||||
float GetDepth(float2 sunPos, float2 offset) {
|
||||
float2 pos = saturate(sunPos + offset * _MainTex_TexelSize.xy);
|
||||
return BEAUTIFY_GET_SCENE_DEPTH_01(pos);
|
||||
}
|
||||
|
||||
float OcclusionTest(float2 sunPos) {
|
||||
|
||||
float depth1 = GetDepth(sunPos, float2(-1, -1));
|
||||
float depth2 = GetDepth(sunPos, float2( 1, 1));
|
||||
float depth3 = GetDepth(sunPos, float2( 3, 3));
|
||||
float depth4 = GetDepth(sunPos, float2(-3, -3));
|
||||
float occlusion = (depth1 + depth2 + depth3 + depth4) * 0.25;
|
||||
occlusion *= step(OCCLUSION_THRESHOLD, occlusion);
|
||||
return occlusion;
|
||||
}
|
||||
|
||||
float4 FragSFOcclusion (VaryingsSF input) : SV_Target {
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
|
||||
float occlusion = OcclusionTest(input.sunPos);
|
||||
#if BEAUTIFY_SF_OCCLUSION_INIT
|
||||
return float4(occlusion, occlusion, occlusion, 1.0);
|
||||
#else
|
||||
return float4(occlusion, occlusion, occlusion, unity_DeltaTime.x * OCCLUSION_SPEED);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d16ac644481a94c35a79383d0def48aa
|
||||
timeCreated: 1518007506
|
||||
licenseType: Pro
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,81 @@
|
||||
Shader "Hidden/Beautify2/DepthOnly"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[MainTexture] _BaseMap ("Texture", 2D) = "white" {}
|
||||
[MainColor] _BaseColor("Color", Color) = (1, 1, 1, 1)
|
||||
_Cutoff("AlphaCutout", Range(0.0, 1.0)) = 0.5
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
ColorMask 0
|
||||
ZWrite On
|
||||
Cull [_Cull]
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Beautify DepthOnly Pass"
|
||||
HLSLPROGRAM
|
||||
#pragma target 4.5
|
||||
#pragma vertex UnlitPassVertex
|
||||
#pragma fragment UnlitPassFragment
|
||||
#pragma multi_compile_local _ DEPTH_PREPASS_ALPHA_TEST
|
||||
#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
#pragma multi_compile_instancing
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
|
||||
TEXTURE2D(_BaseMap);
|
||||
SAMPLER(sampler_BaseMap);
|
||||
|
||||
#if DEPTH_PREPASS_ALPHA_TEST
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
half _Cutoff;
|
||||
float4 _BaseMap_ST;
|
||||
CBUFFER_END
|
||||
|
||||
#ifdef UNITY_DOTS_INSTANCING_ENABLED
|
||||
UNITY_DOTS_INSTANCING_START(MaterialPropertyMetadata)
|
||||
UNITY_DOTS_INSTANCED_PROP(float, _Cutoff)
|
||||
UNITY_DOTS_INSTANCED_PROP(float4, _BaseMap_ST)
|
||||
UNITY_DOTS_INSTANCING_END(MaterialPropertyMetadata)
|
||||
#define _Cutoff UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float, _Cutoff)
|
||||
#define _BaseMap_ST UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float4, _BaseMap_ST)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "DepthOnly_Include.hlsl"
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Beautify DepthOnly Pass" // for older GPUs with no DOTs instancing
|
||||
HLSLPROGRAM
|
||||
#pragma target 2.0
|
||||
#pragma vertex UnlitPassVertex
|
||||
#pragma fragment UnlitPassFragment
|
||||
#pragma multi_compile_local _ DEPTH_PREPASS_ALPHA_TEST
|
||||
#pragma multi_compile_instancing
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
|
||||
TEXTURE2D(_BaseMap);
|
||||
SAMPLER(sampler_BaseMap);
|
||||
|
||||
#if DEPTH_PREPASS_ALPHA_TEST
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
half _Cutoff;
|
||||
float4 _BaseMap_ST;
|
||||
CBUFFER_END
|
||||
#endif
|
||||
|
||||
#include "DepthOnly_Include.hlsl"
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 13944f5ed1ab543b29d359ce4fedcb7c
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,74 @@
|
||||
Shader "Hidden/Beautify2/DepthOnlyAlphaTest"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[MainTexture] _BaseMap ("Texture", 2D) = "white" {}
|
||||
[MainColor] _BaseColor("Color", Color) = (1, 1, 1, 1)
|
||||
_Cutoff("AlphaCutout", Range(0.0, 1.0)) = 0.5
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
ColorMask 0
|
||||
ZWrite On
|
||||
Cull Back
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Beautify DepthOnly Alpha Test Pass"
|
||||
HLSLPROGRAM
|
||||
#pragma target 4.5
|
||||
#pragma vertex UnlitPassVertex
|
||||
#pragma fragment UnlitPassFragment
|
||||
#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
#pragma multi_compile_instancing
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
|
||||
half _OutlineCutOff;
|
||||
|
||||
TEXTURE2D(_BaseMap);
|
||||
SAMPLER(sampler_BaseMap);
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float4 _BaseMap_ST;
|
||||
CBUFFER_END
|
||||
|
||||
#ifdef UNITY_DOTS_INSTANCING_ENABLED
|
||||
UNITY_DOTS_INSTANCING_START(MaterialPropertyMetadata)
|
||||
UNITY_DOTS_INSTANCED_PROP(float4, _BaseMap_ST)
|
||||
UNITY_DOTS_INSTANCING_END(MaterialPropertyMetadata)
|
||||
#define _BaseMap_ST UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float4, _BaseMap_ST)
|
||||
#endif
|
||||
|
||||
#include "DepthOnlyAlphaTest_Include.hlsl"
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Beautify DepthOnly Alpha Test Pass" // for older GPUs with no DOTs instancing
|
||||
HLSLPROGRAM
|
||||
#pragma target 2.0
|
||||
#pragma vertex UnlitPassVertex
|
||||
#pragma fragment UnlitPassFragment
|
||||
#pragma multi_compile_instancing
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
|
||||
half _OutlineCutOff;
|
||||
|
||||
TEXTURE2D(_BaseMap);
|
||||
SAMPLER(sampler_BaseMap);
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float4 _BaseMap_ST;
|
||||
CBUFFER_END
|
||||
|
||||
#include "DepthOnlyAlphaTest_Include.hlsl"
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d04252e5ea700488f9d1adcccbda3af3
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,45 @@
|
||||
struct Attributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
Varyings UnlitPassVertex(Attributes input)
|
||||
{
|
||||
Varyings output = (Varyings)0;
|
||||
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_TRANSFER_INSTANCE_ID(input, output);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
VertexPositionInputs vertexInput = GetVertexPositionInputs(input.positionOS.xyz);
|
||||
|
||||
output.positionCS = vertexInput.positionCS;
|
||||
output.uv = TRANSFORM_TEX(input.uv, _BaseMap);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
void UnlitPassFragment(
|
||||
Varyings input
|
||||
, out half4 outColor : SV_Target0
|
||||
)
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
|
||||
|
||||
half4 color = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, input.uv);
|
||||
clip(color.a - _OutlineCutOff);
|
||||
|
||||
outColor = 0;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 727d7e57de2fc475b9665ec321327224
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,79 @@
|
||||
Shader "Hidden/Beautify2/DepthOnlyWithObjectId"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[MainTexture] _BaseMap ("Texture", 2D) = "white" {}
|
||||
[MainColor] _BaseColor("Color", Color) = (1, 1, 1, 1)
|
||||
_Cutoff("AlphaCutout", Range(0.0, 1.0)) = 0.5
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
ZWrite On
|
||||
Cull [_Cull]
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Beautify DepthOnly With ObjectId Pass"
|
||||
HLSLPROGRAM
|
||||
#pragma target 4.5
|
||||
#pragma vertex UnlitPassVertex
|
||||
#pragma fragment UnlitPassFragment
|
||||
#pragma multi_compile_local _ DEPTH_PREPASS_ALPHA_TEST
|
||||
#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
#pragma multi_compile_instancing
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
|
||||
TEXTURE2D(_BaseMap);
|
||||
SAMPLER(sampler_BaseMap);
|
||||
|
||||
#if DEPTH_PREPASS_ALPHA_TEST
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
half _Cutoff;
|
||||
float4 _BaseMap_ST;
|
||||
CBUFFER_END
|
||||
|
||||
#ifdef UNITY_DOTS_INSTANCING_ENABLED
|
||||
UNITY_DOTS_INSTANCING_START(MaterialPropertyMetadata)
|
||||
UNITY_DOTS_INSTANCED_PROP(float, _Cutoff)
|
||||
UNITY_DOTS_INSTANCED_PROP(float4, _BaseMap_ST)
|
||||
UNITY_DOTS_INSTANCING_END(MaterialPropertyMetadata)
|
||||
#define _Cutoff UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float, _Cutoff)
|
||||
#define _BaseMap_ST UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float4, _BaseMap_ST)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#include "DepthOnlyWithObjectId_Include.hlsl"
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Beautify DepthOnly With ObjectId Pass"
|
||||
HLSLPROGRAM
|
||||
#pragma target 2.0
|
||||
#pragma vertex UnlitPassVertex
|
||||
#pragma fragment UnlitPassFragment
|
||||
#pragma multi_compile_local _ DEPTH_PREPASS_ALPHA_TEST
|
||||
#pragma multi_compile_instancing
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
|
||||
TEXTURE2D(_BaseMap);
|
||||
SAMPLER(sampler_BaseMap);
|
||||
|
||||
#if DEPTH_PREPASS_ALPHA_TEST
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
half _Cutoff;
|
||||
float4 _BaseMap_ST;
|
||||
CBUFFER_END
|
||||
#endif
|
||||
|
||||
#include "DepthOnlyWithObjectId_Include.hlsl"
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9d0c093c7389d4312af43ddc63c2fa3f
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,71 @@
|
||||
Shader "Hidden/Beautify2/DepthOnlyWithObjectIdAlphaTest"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[MainTexture] _BaseMap ("Texture", 2D) = "white" {}
|
||||
[MainColor] _BaseColor("Color", Color) = (1, 1, 1, 1)
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
ZWrite On
|
||||
Cull Back
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Beautify DepthOnly With ObjectId Alpha Test Pass"
|
||||
HLSLPROGRAM
|
||||
#pragma target 4.5
|
||||
#pragma vertex UnlitPassVertex
|
||||
#pragma fragment UnlitPassFragment
|
||||
#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
#pragma multi_compile_instancing
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
|
||||
half _OutlineCutOff;
|
||||
|
||||
TEXTURE2D(_BaseMap);
|
||||
SAMPLER(sampler_BaseMap);
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float4 _BaseMap_ST;
|
||||
CBUFFER_END
|
||||
|
||||
#ifdef UNITY_DOTS_INSTANCING_ENABLED
|
||||
UNITY_DOTS_INSTANCING_START(MaterialPropertyMetadata)
|
||||
UNITY_DOTS_INSTANCED_PROP(float4, _BaseMap_ST)
|
||||
UNITY_DOTS_INSTANCING_END(MaterialPropertyMetadata)
|
||||
#define _BaseMap_ST UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float4, _BaseMap_ST)
|
||||
#endif
|
||||
|
||||
#include "DepthOnlyWithObjectIdAlphaTest_Include.hlsl"
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Beautify DepthOnly With ObjectId Alpha Test Pass" // for older GPUs with no DOTs instancing
|
||||
HLSLPROGRAM
|
||||
#pragma target 2.0
|
||||
#pragma vertex UnlitPassVertex
|
||||
#pragma fragment UnlitPassFragment
|
||||
#pragma multi_compile_instancing
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
|
||||
half _OutlineCutOff;
|
||||
|
||||
TEXTURE2D(_BaseMap);
|
||||
SAMPLER(sampler_BaseMap);
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float4 _BaseMap_ST;
|
||||
CBUFFER_END
|
||||
|
||||
#include "DepthOnlyWithObjectIdAlphaTest_Include.hlsl"
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1801c4e234eee4d99a8226b9cab3c01b
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float objectId : TEXCOORD1;
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
Varyings UnlitPassVertex(Attributes input)
|
||||
{
|
||||
Varyings output = (Varyings)0;
|
||||
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_TRANSFER_INSTANCE_ID(input, output);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
VertexPositionInputs vertexInput = GetVertexPositionInputs(input.positionOS.xyz);
|
||||
|
||||
output.positionCS = vertexInput.positionCS;
|
||||
output.uv = TRANSFORM_TEX(input.uv, _BaseMap);
|
||||
|
||||
VertexPositionInputs vertexInput0 = GetVertexPositionInputs(float3(1,1,1));
|
||||
|
||||
float3 posWS0 = TransformObjectToWorld(float3(0,0,0));
|
||||
float objectId = dot(vertexInput0.positionWS, 1);
|
||||
output.objectId = objectId;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
void UnlitPassFragment(
|
||||
Varyings input
|
||||
, out half4 outColor : SV_Target0
|
||||
)
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
|
||||
|
||||
half4 color = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, input.uv);
|
||||
clip(color.a - _OutlineCutOff);
|
||||
|
||||
outColor = input.objectId;
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 437cd803475ec42389edc2d7ba7b85e1
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,61 @@
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
#if DEPTH_PREPASS_ALPHA_TEST
|
||||
float2 uv : TEXCOORD0;
|
||||
#endif
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
|
||||
#if DEPTH_PREPASS_ALPHA_TEST
|
||||
float2 uv : TEXCOORD0;
|
||||
#endif
|
||||
|
||||
float objectId : TEXCOORD1;
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
Varyings UnlitPassVertex(Attributes input)
|
||||
{
|
||||
Varyings output = (Varyings)0;
|
||||
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_TRANSFER_INSTANCE_ID(input, output);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
VertexPositionInputs vertexInput = GetVertexPositionInputs(input.positionOS.xyz);
|
||||
|
||||
output.positionCS = vertexInput.positionCS;
|
||||
#if DEPTH_PREPASS_ALPHA_TEST
|
||||
output.uv = TRANSFORM_TEX(input.uv, _BaseMap);
|
||||
#endif
|
||||
|
||||
VertexPositionInputs vertexInput0 = GetVertexPositionInputs(float3(1,1,1));
|
||||
float objectId = dot(vertexInput0.positionWS, 1);
|
||||
output.objectId = objectId;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
void UnlitPassFragment(
|
||||
Varyings input
|
||||
, out half4 outColor : SV_Target0
|
||||
)
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
|
||||
|
||||
#if DEPTH_PREPASS_ALPHA_TEST
|
||||
half4 color = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, input.uv);
|
||||
clip(color.a - _Cutoff);
|
||||
#endif
|
||||
|
||||
outColor = input.objectId;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 348330f64a84643f889321b73f3bb033
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,58 @@
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
#if DEPTH_PREPASS_ALPHA_TEST
|
||||
float2 uv : TEXCOORD0;
|
||||
#endif
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
|
||||
#if DEPTH_PREPASS_ALPHA_TEST
|
||||
float2 uv : TEXCOORD0;
|
||||
#endif
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
Varyings UnlitPassVertex(Attributes input)
|
||||
{
|
||||
Varyings output = (Varyings)0;
|
||||
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_TRANSFER_INSTANCE_ID(input, output);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
VertexPositionInputs vertexInput = GetVertexPositionInputs(input.positionOS.xyz);
|
||||
|
||||
output.positionCS = vertexInput.positionCS;
|
||||
#if DEPTH_PREPASS_ALPHA_TEST
|
||||
output.uv = TRANSFORM_TEX(input.uv, _BaseMap);
|
||||
#endif
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
void UnlitPassFragment(
|
||||
Varyings input
|
||||
, out half4 outColor : SV_Target0
|
||||
)
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
|
||||
|
||||
#if DEPTH_PREPASS_ALPHA_TEST
|
||||
half4 color = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, input.uv);
|
||||
clip(color.a - _Cutoff);
|
||||
#endif
|
||||
|
||||
outColor = 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 92428f66f0cce4f1e8d7d818ace6bd0a
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user