Add shaders
This commit is contained in:
@@ -1,255 +0,0 @@
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
uniform float4 _HeightParams;
|
||||
uniform float4 _DistanceParams;
|
||||
uniform int4 _SceneFogMode;
|
||||
uniform float4 _SceneFogParams;
|
||||
uniform sampler2D _EnviroVolumeLightingTex;
|
||||
uniform float4 _FogNoiseData;// x: scale, y: intensity, z: intensity offset
|
||||
uniform float4 _FogNoiseVelocity; // x: x velocity, y: z velocity
|
||||
uniform float4 _EnviroParams; //gametime,distance,height,_tonemapping
|
||||
uniform float _EnviroVolumeDensity;
|
||||
uniform float3 _Br;
|
||||
uniform float3 _Bm;
|
||||
uniform float3 _BmScene;
|
||||
uniform float3 _mieG;
|
||||
uniform float3 _mieGScene;
|
||||
uniform float _FogExposure;
|
||||
uniform float _SkyLuminance;
|
||||
uniform float _scatteringPower;
|
||||
uniform float4 _SunParameters; //x = _SunIntensity, y = _SunDiskSize, z = _SunDiskIntensity, w = SkyFog Height Lerp;
|
||||
uniform float4 _scatteringColor;
|
||||
uniform float _SkyColorPower;
|
||||
uniform float3 _SunDir;
|
||||
uniform float _scatteringStrenght;
|
||||
uniform half _distanceFogIntensity;
|
||||
uniform float4 _EnviroSkyFog; // x = _SkyFogHeight, y = _SkyFogIntensity, z = _SkyFogStart, w = _HeightFogIntensity
|
||||
uniform float _maximumFogDensity;
|
||||
uniform float4 _weatherSkyMod;
|
||||
uniform float4 _weatherFogMod;
|
||||
uniform float _lightning;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
half3 tonemapACES(half3 color, float Exposure)
|
||||
{
|
||||
color *= Exposure;
|
||||
|
||||
// See https://knarkowicz.wordpress.com/2016/01/06/aces-filmic-tone-mapping-curve/
|
||||
const half a = 2.51;
|
||||
const half b = 0.03;
|
||||
const half c = 2.43;
|
||||
const half d = 0.59;
|
||||
const half e = 0.14;
|
||||
return saturate((color * (a * color + b)) / (color * (c * color + d) + e));
|
||||
}
|
||||
|
||||
|
||||
half ComputeFogFactor (float coord)
|
||||
{
|
||||
float fogFac = 0.0;
|
||||
|
||||
if (_SceneFogMode.x == 1) // linear
|
||||
{
|
||||
fogFac = coord * _SceneFogParams.z + _SceneFogParams.w;
|
||||
}
|
||||
if (_SceneFogMode.x == 2) // exp
|
||||
{
|
||||
fogFac = _SceneFogParams.y * coord; fogFac = exp2(-fogFac);
|
||||
}
|
||||
if (_SceneFogMode.x == 3) // exp2
|
||||
{
|
||||
fogFac = _SceneFogParams.x * coord; fogFac = exp2(-fogFac*fogFac);
|
||||
}
|
||||
|
||||
return saturate(fogFac);
|
||||
}
|
||||
|
||||
// Distance fog
|
||||
float ComputeDistance (float3 camDir, float zdepth)
|
||||
{
|
||||
float dist;
|
||||
dist = length(camDir);
|
||||
// Built-in fog starts at near plane, so match that by
|
||||
// subtracting the near value. Not a perfect approximation
|
||||
// if near plane is very large, but good enough.
|
||||
dist -= _ProjectionParams.y;
|
||||
return dist;
|
||||
}
|
||||
|
||||
// Linear height fog,
|
||||
float ComputeHalfSpace (float3 wsDir)
|
||||
{
|
||||
float3 wpos = _WorldSpaceCameraPos + wsDir;
|
||||
float FH = _HeightParams.x;
|
||||
float3 C = _WorldSpaceCameraPos;
|
||||
float3 V = wsDir;
|
||||
float3 P = wpos;
|
||||
float3 aV = (_HeightParams.w * _EnviroSkyFog.w) * V;
|
||||
float FdotC = _HeightParams.y;
|
||||
float k = _HeightParams.z;
|
||||
float FdotP = P.y-FH;
|
||||
float FdotV = wsDir.y;
|
||||
float c1 = k * (FdotP + FdotC);
|
||||
float c2 = (1-2*k) * FdotP;
|
||||
float g = min(c2, 0.0);
|
||||
g = -length(aV) * (c1 - g * g / abs(FdotV+1.0e-5f));
|
||||
return g;
|
||||
}
|
||||
|
||||
|
||||
float4 ComputeScattering (float3 viewDir, float2 sunPos)
|
||||
{
|
||||
float cosTheta = dot(viewDir, _SunDir);
|
||||
viewDir = viewDir + float3(0.0, 0.1 ,0.0);
|
||||
|
||||
float zen = acos(saturate(viewDir.y));
|
||||
float alb = (cos(zen) + 0.5 * pow(93.885 - ((zen * 180.0) / 3.141592), - 0.253)); // pi
|
||||
float3 fex = exp(-(_Br * (4 / alb) + _Bm * (1.25 / alb)));
|
||||
float rayPhase = 2.5 + pow(cosTheta,1);
|
||||
float miePhase = _mieG.x / pow(_mieG.y - _mieG.z * cosTheta, 1);
|
||||
float3 BrTheta = 0.059683 * _Br * rayPhase;
|
||||
float3 BmTheta = 0.079577 * _Bm * miePhase;
|
||||
float3 BrmTheta = (BrTheta + BmTheta * 2.0) / ((_Bm + _Br) * 0.75);
|
||||
float3 scattering = BrmTheta * _SunParameters.x * (1.0 - fex);
|
||||
float3 skyFinalize = saturate((pow( 1.0 - fex, 2.0) * 0.234) * (1 - sunPos.x)) * _SkyLuminance;
|
||||
skyFinalize = saturate(lerp(float3(0.1,0.1,0.1), skyFinalize, saturate(dot(viewDir.y + 0.3, float3(0,1,0)))) * (1-fex));
|
||||
scattering *= saturate((lerp(float3(_scatteringPower, _scatteringPower, _scatteringPower), pow(2000.0f * BrmTheta * fex, 0.7), sunPos.y) * 0.05));
|
||||
scattering *= (_SkyLuminance * _scatteringColor.rgb * _scatteringStrenght) * pow((1.0 - fex), 1.0) * sunPos.x;
|
||||
|
||||
//skyFinalize = lerp(skyFinalize,lerp(skyFinalize,_weatherFogMod, clamp(cosTheta,0,1)), _weatherFogMod.a);
|
||||
float4 fogScattering = float4((scattering + skyFinalize), 1);
|
||||
|
||||
//Tonemapping
|
||||
if (_EnviroParams.w == 1)
|
||||
{
|
||||
fogScattering.rgb = tonemapACES(fogScattering.rgb, _FogExposure);
|
||||
}
|
||||
|
||||
fogScattering = pow(fogScattering,_SkyColorPower);
|
||||
fogScattering = lerp(fogScattering,lerp(fogScattering,_weatherSkyMod, clamp(cosTheta,0,1)), _weatherSkyMod.a);
|
||||
fogScattering = lerp(fogScattering, lerp(fogScattering, _weatherFogMod, _weatherFogMod.a), _weatherFogMod.a);
|
||||
|
||||
if(_lightning > 1)
|
||||
fogScattering = fogScattering + (_lightning * 0.06);
|
||||
|
||||
return fogScattering;
|
||||
}
|
||||
|
||||
|
||||
float4 ComputeScatteringClouds(float3 viewDir, float2 sunPos, float time)
|
||||
{
|
||||
float cosTheta = dot(viewDir, _SunDir);
|
||||
viewDir = viewDir + float3(0.0, 0.1, 0.0);
|
||||
|
||||
float zen = acos(saturate(viewDir.y));
|
||||
float alb = (cos(zen) + 0.5 * pow(93.885 - ((zen * 180.0) / 3.141592), -0.253)); // pi
|
||||
float3 fex = exp(-(_Br * (4 / alb) + _Bm * (1.25 / alb)));
|
||||
float rayPhase = 2.5 + pow(cosTheta, 1);
|
||||
float miePhase = _mieGScene.x / pow(_mieGScene.y - _mieGScene.z * cosTheta, 1);
|
||||
float3 BrTheta = 0.059683 * _Br * rayPhase;
|
||||
float3 BmTheta = 0.079577 * _BmScene * miePhase;
|
||||
float3 BrmTheta = (BrTheta + BmTheta * 2.0) / ((_BmScene + _Br) * 0.75);
|
||||
float3 scattering = BrmTheta * _SunParameters.x * (1.0 - fex);
|
||||
float3 skyFinalize = saturate((pow(1.0 - fex, 2.0) * 0.234) * (1 - sunPos.x)) * _SkyLuminance;
|
||||
skyFinalize = saturate(lerp(float3(0.1, 0.1, 0.1), skyFinalize, saturate(dot(viewDir.y + 0.3, float3(0, 1, 0)))) * (1 - fex));
|
||||
scattering *= saturate((lerp(float3(_scatteringPower, _scatteringPower, _scatteringPower), pow(2000.0f * BrmTheta * fex, 0.7), sunPos.y) * 0.05));
|
||||
scattering *= (_SkyLuminance * _scatteringColor.rgb * _scatteringStrenght) * pow((1.0 - fex), 1.0) * sunPos.x;
|
||||
//skyFinalize = lerp(skyFinalize, lerp(skyFinalize, _weatherFogMod, clamp(cosTheta, 0, 1)), _weatherFogMod.a);
|
||||
float4 fogScattering = float4((scattering + skyFinalize), 1);
|
||||
|
||||
//Tonemapping
|
||||
if (_EnviroParams.w == 1)
|
||||
{
|
||||
fogScattering.rgb = tonemapACES(fogScattering.rgb, _FogExposure);
|
||||
}
|
||||
|
||||
fogScattering = pow(fogScattering, _SkyColorPower);
|
||||
fogScattering = lerp(fogScattering, lerp(fogScattering, _weatherSkyMod, clamp(cosTheta, 0, 1)), _weatherSkyMod.a);
|
||||
fogScattering = lerp(fogScattering, lerp(fogScattering, _weatherFogMod, _weatherFogMod.a), _weatherFogMod.a);
|
||||
|
||||
return fogScattering * time;
|
||||
}
|
||||
|
||||
float4 ComputeScatteringScene (float3 viewDir, float2 sunPos)
|
||||
{
|
||||
float cosTheta = dot(viewDir, _SunDir);
|
||||
viewDir = viewDir + float3(0.0, 0.1 ,0.0);
|
||||
float zen = acos(saturate(viewDir.y));
|
||||
float alb = (cos(zen) + 0.5 * pow(93.885 - ((zen * 180.0) / 3.141592), - 0.253)); // pi
|
||||
float3 fex = exp(-(_Br * (4 / alb) + _BmScene * (1.25 / alb)));
|
||||
float rayPhase = 2.5 + pow(cosTheta,1);
|
||||
float miePhase = _mieGScene.x / pow(_mieGScene.y - _mieGScene.z * cosTheta, 1);
|
||||
float3 BrTheta = 0.059683 * _Br * rayPhase;
|
||||
float3 BmTheta = 0.079577 * _BmScene * miePhase;
|
||||
float3 BrmTheta = (BrTheta + BmTheta * 2.0) / ((_BmScene + _Br) * 0.75);
|
||||
float3 scattering = BrmTheta * _SunParameters.x * (1.0 - fex);
|
||||
float3 skyFinalize = saturate((pow( 1.0 - fex, 2.0) * 0.234) * (1 - sunPos.x)) * _SkyLuminance;
|
||||
skyFinalize = saturate(lerp(float3(0.1,0.1,0.1), skyFinalize, saturate(dot(viewDir.y + 0.3, float3(0,1,0)))) * (1-fex));
|
||||
scattering *= saturate((lerp(float3(_scatteringPower, _scatteringPower, _scatteringPower), pow(2000.0f * BrmTheta * fex, 0.7), sunPos.y) * 0.05));
|
||||
scattering *= (_SkyLuminance * _scatteringColor.rgb * _scatteringStrenght) * pow((1.0 - fex), 1.0) * sunPos.x;
|
||||
|
||||
float4 fogScattering = float4((scattering + skyFinalize), 1);
|
||||
|
||||
//Tonemapping
|
||||
if (_EnviroParams.w == 1)
|
||||
{
|
||||
fogScattering.rgb = tonemapACES(fogScattering.rgb, _FogExposure);
|
||||
}
|
||||
|
||||
fogScattering = pow(fogScattering,_SkyColorPower);
|
||||
fogScattering = lerp(fogScattering, lerp(fogScattering, _weatherSkyMod, clamp(cosTheta, 0, 1)), _weatherSkyMod.a);
|
||||
fogScattering = lerp(fogScattering, lerp(fogScattering, _weatherFogMod, _weatherFogMod.a), _weatherFogMod.a);
|
||||
|
||||
if(_lightning > 1)
|
||||
fogScattering = fogScattering + (_lightning * 0.06);
|
||||
|
||||
return fogScattering;
|
||||
}
|
||||
|
||||
float4 TransparentFog(float4 clr, float3 wPos,float2 uv, half depth)
|
||||
{
|
||||
float3 wsDir = wPos - _WorldSpaceCameraPos;
|
||||
float g = _DistanceParams.x;
|
||||
if (_EnviroParams.y > 0)
|
||||
{
|
||||
g += ComputeDistance (wsDir, depth);
|
||||
g *= _distanceFogIntensity ;
|
||||
}
|
||||
|
||||
if (_EnviroParams.z > 0)
|
||||
{
|
||||
//g += ComputeHalfSpaceWithNoise (wsDir);
|
||||
g += ComputeHalfSpace(wsDir);
|
||||
}
|
||||
|
||||
float fogFac = ComputeFogFactor (max(0.0,g));
|
||||
fogFac = lerp(_maximumFogDensity,1.0f,fogFac);
|
||||
float4 fogClr = float4(0, 0, 0, 0);
|
||||
|
||||
#ifdef UNITY_PASS_FORWARDADD
|
||||
float4 volumeLighting = float4(0, 0, 0, 0);
|
||||
#else
|
||||
|
||||
#if ENVIRO_SIMPLE_FOG
|
||||
fogClr = unity_FogColor;
|
||||
#else
|
||||
float2 sunDir;
|
||||
sunDir.x = saturate(_SunDir.y + 0.25);
|
||||
sunDir.y = saturate(clamp(1.0 - _SunDir.y, 0.0, 0.5));
|
||||
fogClr = ComputeScatteringScene(normalize(wsDir), sunDir);
|
||||
#endif
|
||||
|
||||
#if UNITY_SINGLE_PASS_STEREO
|
||||
float4 scaleOffset = unity_StereoScaleOffset[unity_StereoEyeIndex];
|
||||
uv = (uv - scaleOffset.zw) / scaleOffset.xy;
|
||||
#endif
|
||||
|
||||
float4 volumeLighting = tex2D(_EnviroVolumeLightingTex, UnityStereoTransformScreenSpaceTex(uv)) * _EnviroParams.x;
|
||||
#endif
|
||||
float4 final = lerp (lerp(fogClr, fogClr + volumeLighting, _EnviroVolumeDensity), lerp(clr, clr + volumeLighting, _EnviroVolumeDensity), fogFac);
|
||||
|
||||
return final;
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 557ec7efae03e3d4c8c4a050ae0f6ef7
|
||||
timeCreated: 1505167667
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,254 +0,0 @@
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
||||
|
||||
uniform float4 _HeightParams;
|
||||
uniform float4 _DistanceParams;
|
||||
uniform int4 _SceneFogMode;
|
||||
uniform float4 _SceneFogParams;
|
||||
uniform sampler2D _EnviroVolumeLightingTex;
|
||||
uniform float4 _FogNoiseData;// x: scale, y: intensity, z: intensity offset
|
||||
uniform float4 _FogNoiseVelocity; // x: x velocity, y: z velocity
|
||||
uniform float4 _EnviroParams; //gametime,distance,height,_hdr
|
||||
uniform float _EnviroVolumeDensity;
|
||||
uniform float3 _Br;
|
||||
uniform float3 _Bm;
|
||||
uniform float3 _BmScene;
|
||||
uniform float3 _mieG;
|
||||
uniform float3 _mieGScene;
|
||||
uniform float _FogExposure;
|
||||
uniform float _SkyLuminance;
|
||||
uniform float _scatteringPower;
|
||||
uniform float4 _SunParameters; //x = _SunIntensity, y = _SunDiskSize, z = _SunDiskIntensity;
|
||||
uniform float4 _scatteringColor;
|
||||
uniform float _SkyColorPower;
|
||||
uniform float3 _SunDir;
|
||||
uniform float _scatteringStrenght;
|
||||
uniform half _distanceFogIntensity;
|
||||
uniform float4 _EnviroSkyFog; // x = _SkyFogHeight, y = _SkyFogIntensity, z = _SkyFogStart, w = _HeightFogIntensity
|
||||
uniform float _maximumFogDensity;
|
||||
uniform float4 _weatherSkyMod;
|
||||
uniform float4 _weatherFogMod;
|
||||
uniform float _lightning;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
half3 tonemapACES(half3 color, float Exposure)
|
||||
{
|
||||
color *= Exposure;
|
||||
|
||||
// See https://knarkowicz.wordpress.com/2016/01/06/aces-filmic-tone-mapping-curve/
|
||||
const half a = 2.51;
|
||||
const half b = 0.03;
|
||||
const half c = 2.43;
|
||||
const half d = 0.59;
|
||||
const half e = 0.14;
|
||||
return saturate((color * (a * color + b)) / (color * (c * color + d) + e));
|
||||
}
|
||||
|
||||
half ComputeFogFactorEnviro (float coord)
|
||||
{
|
||||
float fogFac = 0.0;
|
||||
|
||||
if (_SceneFogMode.x == 1) // linear
|
||||
{
|
||||
fogFac = coord * _SceneFogParams.z + _SceneFogParams.w;
|
||||
}
|
||||
if (_SceneFogMode.x == 2) // exp
|
||||
{
|
||||
fogFac = _SceneFogParams.y * coord; fogFac = exp2(-fogFac);
|
||||
}
|
||||
if (_SceneFogMode.x == 3) // exp2
|
||||
{
|
||||
fogFac = _SceneFogParams.x * coord; fogFac = exp2(-fogFac*fogFac);
|
||||
}
|
||||
|
||||
return saturate(fogFac);
|
||||
}
|
||||
|
||||
// Distance fog
|
||||
float ComputeDistance (float3 camDir, float zdepth)
|
||||
{
|
||||
float dist;
|
||||
dist = length(camDir);
|
||||
// Built-in fog starts at near plane, so match that by
|
||||
// subtracting the near value. Not a perfect approximation
|
||||
// if near plane is very large, but good enough.
|
||||
dist -= _ProjectionParams.y;
|
||||
return dist;
|
||||
}
|
||||
|
||||
// Linear height fog,
|
||||
float ComputeHalfSpace (float3 wsDir)
|
||||
{
|
||||
float3 wpos = _WorldSpaceCameraPos + wsDir;
|
||||
float FH = _HeightParams.x;
|
||||
float3 C = _WorldSpaceCameraPos;
|
||||
float3 V = wsDir;
|
||||
float3 P = wpos;
|
||||
float3 aV = (_HeightParams.w * _EnviroSkyFog.w) * V;
|
||||
float FdotC = _HeightParams.y;
|
||||
float k = _HeightParams.z;
|
||||
float FdotP = P.y-FH;
|
||||
float FdotV = wsDir.y;
|
||||
float c1 = k * (FdotP + FdotC);
|
||||
float c2 = (1-2*k) * FdotP;
|
||||
float g = min(c2, 0.0);
|
||||
g = -length(aV) * (c1 - g * g / abs(FdotV+1.0e-5f));
|
||||
return g;
|
||||
}
|
||||
|
||||
|
||||
float4 ComputeScattering (float3 viewDir, float2 sunPos)
|
||||
{
|
||||
float cosTheta = dot(viewDir, _SunDir);
|
||||
viewDir = viewDir + float3(0.0, 0.1 ,0.0);
|
||||
|
||||
float zen = acos(saturate(viewDir.y));
|
||||
float alb = (cos(zen) + 0.5 * pow(93.885 - ((zen * 180.0) / 3.141592), - 0.253)); // pi
|
||||
float3 fex = exp(-(_Br * (4 / alb) + _Bm * (1.25 / alb)));
|
||||
float rayPhase = 2.5 + pow(cosTheta,1);
|
||||
float miePhase = _mieG.x / pow(_mieG.y - _mieG.z * cosTheta, 1);
|
||||
float3 BrTheta = 0.059683 * _Br * rayPhase;
|
||||
float3 BmTheta = 0.079577 * _Bm * miePhase;
|
||||
float3 BrmTheta = (BrTheta + BmTheta * 2.0) / ((_Bm + _Br) * 0.75);
|
||||
float3 scattering = BrmTheta * _SunParameters.x * (1.0 - fex);
|
||||
float3 skyFinalize = saturate((pow( 1.0 - fex, 2.0) * 0.234) * (1 - sunPos.x)) * _SkyLuminance;
|
||||
skyFinalize = saturate(lerp(float3(0.1,0.1,0.1), skyFinalize, saturate(dot(viewDir.y + 0.3, float3(0,1,0)))) * (1-fex));
|
||||
scattering *= saturate((lerp(float3(_scatteringPower, _scatteringPower, _scatteringPower), pow(2000.0f * BrmTheta * fex, 0.7), sunPos.y) * 0.05));
|
||||
scattering *= (_SkyLuminance * _scatteringColor.rgb * _scatteringStrenght) * pow((1.0 - fex), 1.0) * sunPos.x;
|
||||
|
||||
//skyFinalize = lerp(skyFinalize,lerp(skyFinalize,_weatherFogMod, clamp(cosTheta,0,1)), _weatherFogMod.a);
|
||||
float4 fogScattering = float4((scattering + skyFinalize), 1);
|
||||
|
||||
//Tonemapping
|
||||
if (_EnviroParams.w == 1)
|
||||
{
|
||||
fogScattering.rgb = tonemapACES(fogScattering.rgb, _FogExposure);
|
||||
}
|
||||
|
||||
fogScattering = pow(fogScattering,_SkyColorPower);
|
||||
fogScattering = lerp(fogScattering,lerp(fogScattering,_weatherSkyMod, clamp(cosTheta,0,1)), _weatherSkyMod.a);
|
||||
fogScattering = lerp(fogScattering, lerp(fogScattering, _weatherFogMod, _weatherFogMod.a), _weatherFogMod.a);
|
||||
|
||||
if(_lightning > 1)
|
||||
fogScattering = fogScattering + (_lightning * 0.06);
|
||||
|
||||
return fogScattering;
|
||||
}
|
||||
|
||||
|
||||
float4 ComputeScatteringClouds(float3 viewDir, float2 sunPos, float time)
|
||||
{
|
||||
float cosTheta = dot(viewDir, _SunDir);
|
||||
viewDir = viewDir + float3(0.0, 0.1, 0.0);
|
||||
|
||||
float zen = acos(saturate(viewDir.y));
|
||||
float alb = (cos(zen) + 0.5 * pow(93.885 - ((zen * 180.0) / 3.141592), -0.253)); // pi
|
||||
float3 fex = exp(-(_Br * (4 / alb) + _Bm * (1.25 / alb)));
|
||||
float rayPhase = 2.5 + pow(cosTheta, 1);
|
||||
float miePhase = _mieG.x / pow(_mieG.y - _mieG.z * cosTheta, 1);
|
||||
float3 BrTheta = 0.059683 * _Br * rayPhase;
|
||||
float3 BmTheta = 0.079577 * _Bm * miePhase;
|
||||
float3 BrmTheta = (BrTheta + BmTheta * 2.0) / ((_Bm + _Br) * 0.75);
|
||||
float3 scattering = BrmTheta * _SunParameters.x * (1.0 - fex);
|
||||
float3 skyFinalize = saturate((pow(1.0 - fex, 2.0) * 0.234) * (1 - sunPos.x)) * _SkyLuminance;
|
||||
skyFinalize = saturate(lerp(float3(0.1, 0.1, 0.1), skyFinalize, saturate(dot(viewDir.y + 0.3, float3(0, 1, 0)))) * (1 - fex));
|
||||
scattering *= saturate((lerp(float3(_scatteringPower, _scatteringPower, _scatteringPower), pow(2000.0f * BrmTheta * fex, 0.7), sunPos.y) * 0.05));
|
||||
scattering *= (_SkyLuminance * _scatteringColor.rgb * _scatteringStrenght) * pow((1.0 - fex), 1.0) * sunPos.x;
|
||||
//skyFinalize = lerp(skyFinalize, lerp(skyFinalize, _weatherFogMod, clamp(cosTheta, 0, 1)), _weatherFogMod.a);
|
||||
float4 fogScattering = float4((scattering + skyFinalize), 1);
|
||||
|
||||
//Tonemapping
|
||||
if (_EnviroParams.w == 1)
|
||||
{
|
||||
fogScattering.rgb = tonemapACES(fogScattering.rgb, _FogExposure);
|
||||
}
|
||||
|
||||
fogScattering = pow(fogScattering, _SkyColorPower);
|
||||
fogScattering = lerp(fogScattering, lerp(fogScattering, _weatherSkyMod, clamp(cosTheta, 0, 1)), _weatherSkyMod.a);
|
||||
fogScattering = lerp(fogScattering, lerp(fogScattering, _weatherFogMod, _weatherFogMod.a), _weatherFogMod.a);
|
||||
|
||||
return fogScattering * time;
|
||||
}
|
||||
|
||||
float4 ComputeScatteringScene (float3 viewDir, float2 sunPos)
|
||||
{
|
||||
float cosTheta = dot(viewDir, _SunDir);
|
||||
viewDir = viewDir + float3(0.0, 0.1 ,0.0);
|
||||
float zen = acos(saturate(viewDir.y));
|
||||
float alb = (cos(zen) + 0.5 * pow(93.885 - ((zen * 180.0) / 3.141592), - 0.253)); // pi
|
||||
float3 fex = exp(-(_Br * (4 / alb) + _BmScene * (1.25 / alb)));
|
||||
float rayPhase = 2.5 + pow(cosTheta,1);
|
||||
float miePhase = _mieGScene.x / pow(_mieGScene.y - _mieGScene.z * cosTheta, 1);
|
||||
float3 BrTheta = 0.059683 * _Br * rayPhase;
|
||||
float3 BmTheta = 0.079577 * _BmScene * miePhase;
|
||||
float3 BrmTheta = (BrTheta + BmTheta * 2.0) / ((_BmScene + _Br) * 0.75);
|
||||
float3 scattering = BrmTheta * _SunParameters.x * (1.0 - fex);
|
||||
float3 skyFinalize = saturate((pow( 1.0 - fex, 2.0) * 0.234) * (1 - sunPos.x)) * _SkyLuminance;
|
||||
skyFinalize = saturate(lerp(float3(0.1,0.1,0.1), skyFinalize, saturate(dot(viewDir.y + 0.3, float3(0,1,0)))) * (1-fex));
|
||||
scattering *= saturate((lerp(float3(_scatteringPower, _scatteringPower, _scatteringPower), pow(2000.0f * BrmTheta * fex, 0.7), sunPos.y) * 0.05));
|
||||
scattering *= (_SkyLuminance * _scatteringColor.rgb * _scatteringStrenght) * pow((1.0 - fex), 1.0) * sunPos.x;
|
||||
|
||||
float4 fogScattering = float4((scattering + skyFinalize), 1);
|
||||
|
||||
//Tonemapping
|
||||
if (_EnviroParams.w == 1)
|
||||
{
|
||||
fogScattering.rgb = tonemapACES(fogScattering.rgb, _FogExposure);
|
||||
}
|
||||
|
||||
fogScattering = pow(fogScattering,_SkyColorPower);
|
||||
fogScattering = lerp(fogScattering, lerp(fogScattering, _weatherSkyMod, clamp(cosTheta, 0, 1)), _weatherSkyMod.a);
|
||||
fogScattering = lerp(fogScattering, lerp(fogScattering, _weatherFogMod, _weatherFogMod.a), _weatherFogMod.a);
|
||||
|
||||
if(_lightning > 1)
|
||||
fogScattering = fogScattering + (_lightning * 0.06);
|
||||
|
||||
return fogScattering;
|
||||
}
|
||||
|
||||
float4 TransparentFog(float4 clr, float3 wPos,float2 uv, half depth)
|
||||
{
|
||||
float3 wsDir = wPos - _WorldSpaceCameraPos;
|
||||
float g = _DistanceParams.x;
|
||||
if (_EnviroParams.y > 0)
|
||||
{
|
||||
g += ComputeDistance (wsDir, depth);
|
||||
g *= _distanceFogIntensity ;
|
||||
}
|
||||
|
||||
if (_EnviroParams.z > 0)
|
||||
{
|
||||
//g += ComputeHalfSpaceWithNoise (wsDir);
|
||||
g += ComputeHalfSpace(wsDir);
|
||||
}
|
||||
|
||||
float fogFac = ComputeFogFactorEnviro(max(0.0,g));
|
||||
fogFac = lerp(_maximumFogDensity,1.0f,fogFac);
|
||||
float4 fogClr = float4(0, 0, 0, 0);
|
||||
|
||||
#ifdef UNITY_PASS_FORWARDADD
|
||||
float4 volumeLighting = float4(0, 0, 0, 0);
|
||||
#else
|
||||
|
||||
#if ENVIRO_SIMPLE_FOG
|
||||
fogClr = unity_FogColor;
|
||||
#else
|
||||
float2 sunDir;
|
||||
sunDir.x = saturate(_SunDir.y + 0.25);
|
||||
sunDir.y = saturate(clamp(1.0 - _SunDir.y, 0.0, 0.5));
|
||||
fogClr = ComputeScatteringScene(normalize(wsDir), sunDir);
|
||||
#endif
|
||||
|
||||
#if UNITY_SINGLE_PASS_STEREO
|
||||
float4 scaleOffset = unity_StereoScaleOffset[unity_StereoEyeIndex];
|
||||
uv = (uv - scaleOffset.zw) / scaleOffset.xy;
|
||||
#endif
|
||||
|
||||
float4 volumeLighting = tex2D(_EnviroVolumeLightingTex, uv) * _EnviroParams.x;
|
||||
#endif
|
||||
float4 final = lerp (lerp(fogClr, fogClr + volumeLighting, _EnviroVolumeDensity), lerp(clr, clr + volumeLighting, _EnviroVolumeDensity), fogFac);
|
||||
|
||||
return final;
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 221026906cc779e4b9ab486bbbd30032
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
-46
@@ -1,46 +0,0 @@
|
||||
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
|
||||
|
||||
Shader "Enviro/Effects/ClearLightShafts" {
|
||||
Properties {
|
||||
_MainTex ("Base (RGB)", 2D) = "white" {}
|
||||
}
|
||||
|
||||
SubShader {
|
||||
Pass {
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
UNITY_DECLARE_SCREENSPACE_TEXTURE(_MainTex);
|
||||
uniform float4 _MainTex_TexelSize;
|
||||
|
||||
struct v2f {
|
||||
float4 pos : SV_POSITION;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f vert( appdata_img v )
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v); //Insert
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o); //Insert
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); //Ins
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 frag (v2f i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
return half4(0,0,0,0);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
Fallback off
|
||||
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ca46cc6d87e05cb4993352de483e4370
|
||||
timeCreated: 1472350262
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
-254
@@ -1,254 +0,0 @@
|
||||
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
|
||||
|
||||
Shader "Enviro/Effects/LightShafts" {
|
||||
Properties{
|
||||
_MainTex("Base", Any) = "" {}
|
||||
_ColorBuffer("Color", Any) = "" {}
|
||||
_Skybox("Skybox", Any) = "" {}
|
||||
}
|
||||
|
||||
CGINCLUDE
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct v2f {
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
float2 uv1 : TEXCOORD1;
|
||||
#endif
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
struct v2f_radial {
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float2 blurVector : TEXCOORD1;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
UNITY_DECLARE_SCREENSPACE_TEXTURE(_MainTex);
|
||||
UNITY_DECLARE_SCREENSPACE_TEXTURE(_ColorBuffer);
|
||||
UNITY_DECLARE_SCREENSPACE_TEXTURE(_Skybox);
|
||||
//sampler2D_float _CameraDepthTexture;
|
||||
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
|
||||
|
||||
uniform half4 _SunThreshold;
|
||||
|
||||
uniform half4 _SunColor;
|
||||
uniform half4 _BlurRadius4;
|
||||
uniform half4 _SunPosition;
|
||||
uniform half4 _MainTex_TexelSize;
|
||||
half4 _MainTex_ST;
|
||||
half4 _ColorBuffer_ST;
|
||||
half4 _Skybox_ST;
|
||||
half4 _CameraDepthTexture_ST;
|
||||
|
||||
|
||||
#define SAMPLES_FLOAT 6.0f
|
||||
#define SAMPLES_INT 6
|
||||
|
||||
v2f vert(appdata_img v) {
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v); //Insert
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o); //Insert
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); //Ins
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.texcoord.xy;
|
||||
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
o.uv1 = v.texcoord.xy;
|
||||
if (_MainTex_TexelSize.y < 0)
|
||||
o.uv1.y = 1 - o.uv1.y;
|
||||
#endif
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 fragScreen(v2f i) : SV_Target{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
half4 colorA = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _MainTex_ST));
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
half4 colorB = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_ColorBuffer, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _ColorBuffer_ST));
|
||||
#else
|
||||
half4 colorB = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_ColorBuffer, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _ColorBuffer_ST));
|
||||
#endif
|
||||
half4 depthMask = saturate(colorB * _SunColor);
|
||||
return 1.0f - (1.0f - colorA) * (1.0f - depthMask);
|
||||
}
|
||||
|
||||
half4 fragAdd(v2f i) : SV_Target{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
half4 colorA = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _MainTex_ST));
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
half4 colorB = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_ColorBuffer, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _ColorBuffer_ST));
|
||||
#else
|
||||
half4 colorB = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_ColorBuffer, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _ColorBuffer_ST));
|
||||
#endif
|
||||
half4 depthMask = saturate(colorB * _SunColor);
|
||||
return colorA + depthMask;
|
||||
}
|
||||
|
||||
v2f_radial vert_radial(appdata_img v) {
|
||||
v2f_radial o;
|
||||
UNITY_SETUP_INSTANCE_ID(v); //Insert
|
||||
UNITY_INITIALIZE_OUTPUT(v2f_radial, o); //Insert
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); //Ins
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
|
||||
o.uv.xy = v.texcoord.xy;
|
||||
|
||||
o.blurVector = (_SunPosition.xy - v.texcoord.xy) * _BlurRadius4.xy;
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 frag_radial(v2f_radial i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
half4 color = half4(0,0,0,0);
|
||||
for (int j = 0; j < SAMPLES_INT; j++)
|
||||
{
|
||||
half4 tmpColor = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _MainTex_ST));
|
||||
color += tmpColor;
|
||||
i.uv.xy += i.blurVector;
|
||||
}
|
||||
return color / SAMPLES_FLOAT;
|
||||
}
|
||||
|
||||
|
||||
half TransformColor(half4 skyboxValue)
|
||||
{
|
||||
return dot(max(skyboxValue.rgb - _SunThreshold.rgb, half3(0, 0, 0)), half3(1, 1, 1)); //threshold and convert to greyscale
|
||||
}
|
||||
|
||||
half4 frag_depth(v2f i) : SV_Target{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
float depthSample = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST));
|
||||
#else
|
||||
float depthSample = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _CameraDepthTexture_ST));
|
||||
#endif
|
||||
|
||||
half4 tex = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _MainTex_ST));
|
||||
|
||||
depthSample = Linear01Depth(depthSample);
|
||||
|
||||
// consider maximum radius
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
half2 vec = _SunPosition.xy - UnityStereoScreenSpaceUVAdjust(i.uv.xy, _MainTex_ST);
|
||||
#else
|
||||
half2 vec = _SunPosition.xy - UnityStereoScreenSpaceUVAdjust(i.uv.xy, _MainTex_ST);
|
||||
#endif
|
||||
|
||||
half dist = saturate(_SunPosition.w - length(vec.xy));
|
||||
|
||||
half4 outColor = 0;
|
||||
|
||||
// consider shafts blockers
|
||||
if (depthSample > 0.99)
|
||||
{
|
||||
outColor = TransformColor(tex) * dist;
|
||||
}
|
||||
return outColor;
|
||||
}
|
||||
|
||||
half4 frag_nodepth(v2f i) : SV_Target{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
float4 sky = (UNITY_SAMPLE_SCREENSPACE_TEXTURE(_Skybox, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _Skybox_ST)));
|
||||
#else
|
||||
float4 sky = (UNITY_SAMPLE_SCREENSPACE_TEXTURE(_Skybox, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _Skybox_ST)));
|
||||
#endif
|
||||
|
||||
float4 tex = (UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _MainTex_ST)));
|
||||
|
||||
// consider maximum radius
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
half2 vec = _SunPosition.xy - i.uv1.xy;
|
||||
#else
|
||||
half2 vec = _SunPosition.xy - i.uv.xy;
|
||||
#endif
|
||||
|
||||
half dist = saturate(_SunPosition.w - length(vec));
|
||||
|
||||
half4 outColor = 0;
|
||||
|
||||
// find unoccluded sky pixels
|
||||
// consider pixel values that differ significantly between framebuffer and sky-only buffer as occluded
|
||||
if (Luminance(abs(sky.rgb - tex.rgb)) < 0.2)
|
||||
{
|
||||
outColor = TransformColor(sky) * dist;
|
||||
}
|
||||
return outColor;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ENDCG
|
||||
|
||||
Subshader {
|
||||
|
||||
Pass{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment fragScreen
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
|
||||
|
||||
Pass{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert_radial
|
||||
#pragma fragment frag_radial
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
|
||||
|
||||
Pass{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag_depth
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag_nodepth
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment fragAdd
|
||||
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
Fallback off
|
||||
|
||||
} // shader
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2721eac037fc4544abddca473138e9f1
|
||||
timeCreated: 1472350262
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,56 +0,0 @@
|
||||
Shader "Hidden/Enviro/BakeCubemap"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex("Base (RGB)", 2D) = "white" {}
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Pass
|
||||
{
|
||||
ZTest Always
|
||||
Cull Off
|
||||
ZWrite Off
|
||||
Blend Off
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
uniform sampler2D _MainTex;
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 pos : SV_POSITION;
|
||||
};
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.uv;
|
||||
o.uv.x = 1 - o.uv.x;
|
||||
o.uv.y = 1 - o.uv.y;
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 frag(v2f IN) : COLOR
|
||||
{
|
||||
return tex2D(_MainTex, IN.uv);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 48f6b84faa79d414db8ed9f447b2f771
|
||||
timeCreated: 1543550691
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,130 +0,0 @@
|
||||
Shader "Enviro/Clouds Particles Advanced" {
|
||||
Properties {
|
||||
_CloudsColor("Color", Color) = (0.5,0.5,0.5,0.5)
|
||||
_MainTex ("Particle Texture", 2D) = "white" {}
|
||||
_InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0
|
||||
}
|
||||
|
||||
Category {
|
||||
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" }
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ColorMask RGB
|
||||
Cull Off Lighting Off ZWrite Off
|
||||
|
||||
|
||||
SubShader {
|
||||
Pass {
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#if ENVIRO_SIMPLE_FOG
|
||||
#pragma target 2.0
|
||||
#else
|
||||
#pragma target 3.0
|
||||
#endif
|
||||
#pragma multi_compile_particles
|
||||
#pragma multi_compile_fog
|
||||
#pragma multi_compile __ ENVIRO_SIMPLE_FOG
|
||||
#pragma multi_compile __ ENVIROVOLUMELIGHT
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
#if ENVIRO_SIMPLE_FOG
|
||||
uniform float3 _SunDir;
|
||||
uniform half4 _EnviroSkyFog;
|
||||
#else
|
||||
#include "Core/EnviroFogCore.cginc"
|
||||
#endif
|
||||
|
||||
uniform sampler2D _MainTex;
|
||||
uniform fixed4 _CloudsColor;
|
||||
|
||||
struct appdata_t {
|
||||
float4 vertex : POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f {
|
||||
float4 vertex : SV_POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
UNITY_FOG_COORDS(1)
|
||||
float3 posWorld : TEXCOORD2;
|
||||
float4 uv : TEXCOORD3;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
float4 _MainTex_ST;
|
||||
|
||||
v2f vert (appdata_t v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v); //Insert
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o); //Insert
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); //Ins
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.posWorld = mul(unity_ObjectToWorld, v.vertex);
|
||||
o.color = v.color;
|
||||
o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
|
||||
o.uv = ComputeScreenPos(o.vertex);
|
||||
UNITY_TRANSFER_FOG(o,o.vertex);
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
fixed4 TransparentParticleCloudsFog(fixed4 clr, float3 wPos, float2 uv)
|
||||
{
|
||||
float3 wsDir = wPos - _WorldSpaceCameraPos;
|
||||
|
||||
float f = saturate((_EnviroSkyFog.x * (dot(normalize(wPos - _WorldSpaceCameraPos.xyz), float3(0, 1, 0)))) +_EnviroSkyFog.z);
|
||||
f = pow(f, _EnviroSkyFog.y);
|
||||
half fogFacSky = (clamp(f, 0, 1));
|
||||
|
||||
fixed4 fogClr = fixed4(0, 0, 0, 0);
|
||||
fixed4 final = fixed4(0, 0, 0, 0);
|
||||
|
||||
#if ENVIRO_SIMPLE_FOG
|
||||
fogClr = unity_FogColor * 2;
|
||||
final = lerp(fogClr, clr, fogFacSky);
|
||||
#else
|
||||
float2 sunDir;
|
||||
sunDir.x = saturate(_SunDir.y + 0.25);
|
||||
sunDir.y = saturate(clamp(1.0 - _SunDir.y, 0.0, 0.5));
|
||||
fogClr = ComputeScattering(normalize(wsDir), sunDir);
|
||||
|
||||
#if ENVIROVOLUMELIGHT
|
||||
|
||||
#if UNITY_SINGLE_PASS_STEREO
|
||||
float4 scaleOffset = unity_StereoScaleOffset[unity_StereoEyeIndex];
|
||||
uv = (uv - scaleOffset.zw) / scaleOffset.xy;
|
||||
#endif
|
||||
float4 volumeLighting = tex2D(_EnviroVolumeLightingTex, UnityStereoTransformScreenSpaceTex(uv));
|
||||
volumeLighting *= _EnviroParams.x;
|
||||
final = lerp(lerp(fogClr, fogClr + volumeLighting, _EnviroVolumeDensity), lerp(clr, clr + volumeLighting, _EnviroVolumeDensity), fogFacSky);
|
||||
#else
|
||||
final = lerp(fogClr, clr, fogFacSky);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return final;
|
||||
}
|
||||
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
fixed4 col = 2.0f * i.color * tex2D(_MainTex, i.texcoord) * _CloudsColor;
|
||||
UNITY_APPLY_FOG(i.fogCoord, col);
|
||||
float3 wsDir = normalize(i.posWorld.xyz -_WorldSpaceCameraPos);
|
||||
float4 fog = TransparentParticleCloudsFog(col, i.posWorld,i.uv.xy / i.uv.w);
|
||||
//float alpha = clamp(col.a * clamp(wsDir.y*1.5, 0, 1),0,1);
|
||||
//if(wsDir.y + _WorldSpaceCameraPos.y < _WorldSpaceCameraPos.y)
|
||||
//alpha = col.a;
|
||||
return float4(fog.rgb, clamp(col.a * clamp(wsDir.y*1.5, 0, 1),0,1));
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 33a3df5c42ad8b94399677a41417d650
|
||||
timeCreated: 1528820905
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,55 +0,0 @@
|
||||
Shader "Hidden/Enviro/ReflectionProbe"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex("Base (RGB)", 2D) = "white" {}
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Pass
|
||||
{
|
||||
ZTest Always
|
||||
Cull Off
|
||||
ZWrite Off
|
||||
Blend Off
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
uniform sampler2D _MainTex;
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 pos : SV_POSITION;
|
||||
};
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.uv;
|
||||
o.uv.x = 1 - o.uv.x;
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 frag(v2f IN) : COLOR
|
||||
{
|
||||
return tex2D(_MainTex, IN.uv);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 41ac77e495e78d44789ff533b305c2fd
|
||||
timeCreated: 1543550691
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,383 +0,0 @@
|
||||
Shader "Enviro/Lite/SkyboxSimple"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_SkyColor ("Sky Color", Color) = (0, 0, 0, 0)
|
||||
_HorizonColor ("Horizon Color", Color) = (0, 0, 0, 0)
|
||||
_SunColor ("Sun Color", Color) = (0, 0, 0, 0)
|
||||
_Stars ("StarsMap", Cube) = "black" {}
|
||||
_MoonTex("Moon Tex", 2D) = "black" {}
|
||||
_FlatCloudsBaseTexture("Base Map", 2D) = "black" {}
|
||||
_FlatCloudsDetailTexture("Detail Map", 2D) = "black" {}
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Lod 300
|
||||
Tags { "Queue"="Background" "RenderType"="Background" "PreviewType"="Skybox" "IgnoreProjector"="True" }
|
||||
|
||||
Pass
|
||||
{
|
||||
Cull Back
|
||||
ZWrite Off
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
#pragma target 3.0
|
||||
//#pragma multi_compile_fog
|
||||
|
||||
uniform half4 _SkyColor;
|
||||
uniform half4 _HorizonColor;
|
||||
uniform half4 _SunColor;
|
||||
uniform samplerCUBE _Stars;
|
||||
uniform float4x4 _StarsMatrix;
|
||||
uniform half _StarsIntensity;
|
||||
uniform half _SunDiskSizeSimple;
|
||||
uniform float4 _weatherSkyMod;
|
||||
uniform half _BlackGround;
|
||||
uniform float3 _SunDir;
|
||||
uniform sampler2D _MoonTex;
|
||||
uniform float3 _MoonDir;
|
||||
uniform float4 _MoonColor;
|
||||
uniform float4 _moonParams;
|
||||
|
||||
struct VertexInput
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float3 texcoord : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
|
||||
struct v2f {
|
||||
float4 position : POSITION;
|
||||
float4 WorldPosition : TEXCOORD0;
|
||||
float3 starPos : TEXCOORD1;
|
||||
half3 vertex : TEXCOORD2;
|
||||
float3 moonPos : TEXCOORD3;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f vert(VertexInput v) {
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v); //Insert
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o); //Insert
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); //Ins
|
||||
float3 viewDir = normalize(v.texcoord + float3(0.0, 0.1, 0.0));
|
||||
|
||||
o.position = UnityObjectToClipPos(v.vertex);
|
||||
o.WorldPosition = normalize(mul((float4x4)unity_ObjectToWorld, v.vertex)).xyzw;
|
||||
o.starPos = mul((float3x3)_StarsMatrix,v.vertex.xyz);
|
||||
o.vertex = -v.vertex;
|
||||
float3 r = normalize(cross(_MoonDir.xyz, float3(0, -1, 0)));
|
||||
float3 u = cross(_MoonDir.xyz, r);
|
||||
o.moonPos.xy = float2(dot(r, v.vertex.xyz), dot(u, v.vertex.xyz)) * (21.0 - _moonParams.x) + 0.5;
|
||||
o.moonPos.z = saturate(dot(-_MoonDir.xyz, viewDir));
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
float MoonPhaseFactor(float2 uv, float phase)
|
||||
{
|
||||
float alpha = 1.0;
|
||||
|
||||
|
||||
float srefx = uv.x - 0.5;
|
||||
float refx = abs(uv.x - 0.5);
|
||||
|
||||
if (phase > 0)
|
||||
{
|
||||
srefx = (1 - uv.x) - 0.5;
|
||||
refx = abs((1 - uv.x) - 0.5);
|
||||
}
|
||||
|
||||
phase = abs(_moonParams.w);
|
||||
float refy = abs(uv.y - 0.5);
|
||||
float refxfory = sqrt(0.25 - refy * refy);
|
||||
float xmin = -refxfory;
|
||||
float xmax = refxfory;
|
||||
float xmin1 = (xmax - xmin) * (phase / 2) + xmin;
|
||||
float xmin2 = (xmax - xmin) * phase + xmin;
|
||||
|
||||
if (srefx < xmin1)
|
||||
{
|
||||
alpha = 0;
|
||||
}
|
||||
else if (srefx < xmin2 && xmin1 != xmin2)
|
||||
{
|
||||
alpha = (srefx - xmin1) / (xmin2 - xmin1);
|
||||
}
|
||||
|
||||
return alpha;
|
||||
}
|
||||
|
||||
half getMiePhase(half eyeCos, half eyeCos2, half y)
|
||||
{
|
||||
half temp = 1.0 + 0.9801 - 2.0 * (-0.990) * eyeCos;
|
||||
temp = pow(temp, pow(_SunDiskSizeSimple, 0.65) * 10);
|
||||
temp = max(temp, 1.0e-4); // prevent division by zero, esp. in half precision
|
||||
temp = 1.5 * ((1.0 - 0.9801) / (2.0 + 0.9801)) * (1.0 + eyeCos2) / temp;
|
||||
//#if defined(UNITY_COLORSPACE_GAMMA) && SKYBOX_COLOR_IN_TARGET_COLOR_SPACE
|
||||
// temp = pow(temp, .454545);
|
||||
//#endif
|
||||
return temp;
|
||||
}
|
||||
|
||||
fixed4 frag(v2f i) : COLOR
|
||||
{
|
||||
half3 ray = normalize(mul((float3x3)unity_ObjectToWorld, i.vertex));
|
||||
half y = ray.y / 0.02;
|
||||
float4 skyColor = float4(0, 0, 0, 1);
|
||||
|
||||
if(_BlackGround == 1.0 && y > 5.0)
|
||||
skyColor = float4(0, 0, 0, 1);
|
||||
else
|
||||
{
|
||||
float3 viewDir = normalize(i.WorldPosition + float3(0,0.2,0));
|
||||
|
||||
float4 moonSampler = tex2D(_MoonTex, i.moonPos.xy);
|
||||
float alpha = MoonPhaseFactor(i.moonPos.xy, _moonParams.w);
|
||||
float3 moonArea = clamp(moonSampler * 10, 0, 1) * i.moonPos.z;
|
||||
moonSampler = lerp(float4(0, 0, 0, 0), moonSampler, alpha);
|
||||
moonSampler = (moonSampler * _MoonColor) * 2;
|
||||
float starsBehindMoon = 1 - clamp((moonArea * 5), 0, 1);
|
||||
|
||||
float3 starsMap = texCUBE(_Stars, i.starPos.xyz);
|
||||
float4 nightSky = float4(((_StarsIntensity * 50) * starsMap.rgb),1) * starsBehindMoon;
|
||||
skyColor = lerp(_HorizonColor,_SkyColor,smoothstep(dot(viewDir.y, float3(0,2,0)),0,0.3));
|
||||
|
||||
if (y < 50.0 && y > 5.0)
|
||||
skyColor = _HorizonColor;
|
||||
|
||||
|
||||
skyColor = skyColor + (1 - skyColor.a) * nightSky;
|
||||
|
||||
half eyeCos = dot(_SunDir, ray);
|
||||
half eyeCos2 = eyeCos * eyeCos;
|
||||
half mie = getMiePhase(eyeCos, eyeCos2,y);
|
||||
skyColor += mie * _SunColor;
|
||||
|
||||
skyColor.rgb += (moonSampler.rgb * i.moonPos.z);
|
||||
|
||||
skyColor = lerp(skyColor, (lerp(skyColor, _weatherSkyMod, _weatherSkyMod.a)), _weatherSkyMod.a);
|
||||
}
|
||||
|
||||
return skyColor;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
//Cirrus Clouds
|
||||
Pass
|
||||
{
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
|
||||
CGPROGRAM
|
||||
#pragma target 2.0
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
uniform sampler2D _CloudMap;
|
||||
uniform float _CloudAlpha;
|
||||
uniform float _CloudCoverage;
|
||||
uniform float _CloudAltitude;
|
||||
uniform float4 _CloudColor;
|
||||
uniform float _CloudColorPower;
|
||||
uniform float2 _CloudAnimation;
|
||||
|
||||
struct appdata {
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 Position : SV_POSITION;
|
||||
float4 uv : TEXCOORD0;
|
||||
float3 worldPos : TEXCOORD1;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v); //Insert
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o); //Insert
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); //Ins
|
||||
|
||||
o.Position = UnityObjectToClipPos(v.vertex);
|
||||
o.worldPos = normalize(v.vertex).xyz;
|
||||
float3 viewDir = normalize(o.worldPos + float3(0,1,0));
|
||||
o.worldPos.y *= 1 - dot(viewDir.y + _CloudAltitude, float3(0,-0.15,0));
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 frag(v2f i) : SV_Target
|
||||
{
|
||||
float3 uvs = normalize(i.worldPos);
|
||||
|
||||
float4 uv1;
|
||||
float4 uv2;
|
||||
|
||||
uv1.xy = (uvs.xz * 0.2) + _CloudAnimation;
|
||||
uv2.xy = (uvs.xz * 0.4) + _CloudAnimation;
|
||||
|
||||
float4 clouds1 = tex2D(_CloudMap, uv1.xy);
|
||||
float4 clouds2 = tex2D(_CloudMap, uv2.xy);
|
||||
|
||||
float color1 = pow(clouds1.g + clouds2.g, 0.1);
|
||||
float color2 = pow(clouds2.b * clouds1.r, 0.2);
|
||||
|
||||
float4 finalClouds = lerp(clouds1, clouds2, color1 * color2);
|
||||
float cloudExtinction = pow(uvs.y , 2);
|
||||
|
||||
|
||||
finalClouds.a *= _CloudAlpha;
|
||||
finalClouds.a *= cloudExtinction;
|
||||
|
||||
if (uvs.y < 0)
|
||||
finalClouds.a = 0;
|
||||
|
||||
finalClouds.rgb = finalClouds.a * pow(_CloudColor,_CloudColorPower);
|
||||
finalClouds.rgb = pow(finalClouds.rgb,1 - _CloudCoverage);
|
||||
|
||||
return finalClouds;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Flat Clouds
|
||||
Pass
|
||||
{
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
|
||||
CGPROGRAM
|
||||
#pragma target 3.0
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
uniform sampler2D _FlatCloudsBaseTexture;
|
||||
uniform sampler2D _FlatCloudsDetailTexture;
|
||||
uniform float4 _FlatCloudsAnimation;
|
||||
uniform float3 _FlatCloudsLightDirection;
|
||||
uniform float3 _FlatCloudsLightColor;
|
||||
uniform float3 _FlatCloudsAmbientColor;
|
||||
uniform float4 _FlatCloudsLightingParams; // x = LightIntensity, y = AmbientIntensity, z = Absorbtion, w = HgPhase
|
||||
uniform float4 _FlatCloudsParams; // x = Coverage, y = Density, z = Altitude, w = tonemapping
|
||||
uniform float4 _FlatCloudsTiling; // x = Base, y = Detail
|
||||
uniform float _CloudsExposure;
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 Position : SV_POSITION;
|
||||
float4 uv : TEXCOORD0;
|
||||
float3 worldPos : TEXCOORD1;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f vert(appdata_base v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
o.Position = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = normalize(v.vertex).xyzw;
|
||||
float3 viewDir = normalize(o.uv + float3(0, 1, 0));
|
||||
o.uv.y *= 1 - dot(viewDir.y + _FlatCloudsParams.z, float3(0, -0.2, 0));
|
||||
o.worldPos = mul(unity_ObjectToWorld, v.vertex);
|
||||
return o;
|
||||
}
|
||||
|
||||
float Remap(float org_val, float org_min, float org_max, float new_min, float new_max)
|
||||
{
|
||||
return new_min + saturate(((org_val - org_min) / (org_max - org_min))*(new_max - new_min));
|
||||
}
|
||||
|
||||
float HenryGreenstein(float cosTheta, float g)
|
||||
{
|
||||
float k = 3.0 / (8.0 * 3.1415926f) * (1.0 - g * g) / (2.0 + g * g);
|
||||
return k * (1.0 + cosTheta * cosTheta) / pow(abs(1.0 + g * g - 2.0 * g * cosTheta), 1.5);
|
||||
}
|
||||
half3 tonemapACES(half3 color, float Exposure)
|
||||
{
|
||||
color *= Exposure;
|
||||
|
||||
// See https://knarkowicz.wordpress.com/2016/01/06/aces-filmic-tone-mapping-curve/
|
||||
const half a = 2.51;
|
||||
const half b = 0.03;
|
||||
const half c = 2.43;
|
||||
const half d = 0.59;
|
||||
const half e = 0.14;
|
||||
return saturate((color * (a * color + b)) / (color * (c * color + d) + e));
|
||||
}
|
||||
|
||||
float CalculateCloudDensity(float2 posBase, float2 posDetail, float coverage)
|
||||
{
|
||||
float4 baseNoise = tex2D(_FlatCloudsBaseTexture, posBase);
|
||||
float low_freq_fBm = (baseNoise.g * 0.625) + (baseNoise.b * 0.25) + (baseNoise.a * 0.125);
|
||||
float base_cloud = Remap(baseNoise.r, -(1.0 - low_freq_fBm), 1.0, 0.0, 1.0) * coverage;
|
||||
|
||||
float4 detailNoise = tex2D(_FlatCloudsDetailTexture, posDetail * 2);
|
||||
float high_freq_fBm = (detailNoise.r * 0.625) + (detailNoise.g * 0.25) + (detailNoise.b * 0.125);
|
||||
float density = Remap(base_cloud, 1.0 - high_freq_fBm * 0.5, 1.0, 0.0, 1.0);
|
||||
|
||||
density *= pow(high_freq_fBm, 0.4);
|
||||
density *= _FlatCloudsParams.y;
|
||||
|
||||
return density;
|
||||
}
|
||||
|
||||
half4 frag(v2f i) : SV_Target
|
||||
{
|
||||
half4 col = 0;
|
||||
float3 uvs = normalize(i.uv);
|
||||
|
||||
float4 uv1;
|
||||
uv1.xy = (uvs.xz * _FlatCloudsTiling.x) + _FlatCloudsAnimation.xy;
|
||||
uv1.zw = (uvs.xz * _FlatCloudsTiling.y) + _FlatCloudsAnimation.zw;
|
||||
|
||||
float cloudExtinction = pow(uvs.y, 2);
|
||||
half density = CalculateCloudDensity(uv1.xy, uv1.zw, _FlatCloudsParams.x);
|
||||
|
||||
//Lighting
|
||||
fixed absorbtion = exp2(-1 * (density * _FlatCloudsLightingParams.z));
|
||||
float3 viewDir = normalize(i.worldPos - _WorldSpaceCameraPos);
|
||||
float inscatterAngle = dot(normalize(_FlatCloudsLightDirection), -viewDir);
|
||||
fixed hg = HenryGreenstein(inscatterAngle, _FlatCloudsLightingParams.w) * 2 * absorbtion;
|
||||
fixed lighting = density * (absorbtion + hg);
|
||||
float3 lightColor = pow(_FlatCloudsLightColor, 2) * (_FlatCloudsLightingParams.x);
|
||||
col.rgb = lightColor * lighting;
|
||||
col.rgb = col.rgb + (_FlatCloudsAmbientColor * _FlatCloudsLightingParams.y);
|
||||
|
||||
//Tonemapping
|
||||
if (_FlatCloudsParams.w == 1)
|
||||
col.rgb = tonemapACES(col.rgb, _CloudsExposure);
|
||||
|
||||
col.a = saturate(density * cloudExtinction);
|
||||
|
||||
if (uvs.y < 0)
|
||||
col.a = 0;
|
||||
|
||||
return col;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
}
|
||||
FallBack "None"
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 846f1e8b410d51444866f03712815c1e
|
||||
timeCreated: 1503929340
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,56 +0,0 @@
|
||||
Shader "Enviro/Particles/Lit Weather" {
|
||||
Properties{
|
||||
_TintColor("Tint Color", Color) = (1,1,1,1)
|
||||
_MainTex("Particle Texture", 2D) = "white" {}
|
||||
_Intensity("Intensity", Range(1,100)) = 10
|
||||
|
||||
}
|
||||
SubShader{
|
||||
Tags{ "RenderType" = "Transparent" "Queue" = "Transparent" }
|
||||
LOD 200
|
||||
|
||||
CGPROGRAM
|
||||
#pragma surface surf Standard alpha:fade finalcolor:ApplyFog
|
||||
#pragma target 3.0
|
||||
|
||||
sampler2D _MainTex;
|
||||
#include "../../Resources/Shaders/Core/EnviroFogCore.cginc"
|
||||
struct Input {
|
||||
float2 uv_MainTex;
|
||||
fixed4 color : COLOR;
|
||||
float4 screenPos;
|
||||
float3 worldPos;
|
||||
};
|
||||
|
||||
fixed4 _TintColor;
|
||||
float _Intensity;
|
||||
|
||||
void ApplyFog(Input IN, SurfaceOutputStandard o, inout fixed4 color)
|
||||
{
|
||||
//Get ScreenPosition
|
||||
float3 uvscreen = IN.screenPos.xyz / IN.screenPos.w;
|
||||
// Calculate Linear Depth
|
||||
half linear01Depth = Linear01Depth(uvscreen.z);
|
||||
//get World Position
|
||||
float3 wPos = IN.worldPos.xyz;
|
||||
// Calculate Fog and apply volume lighting tex
|
||||
float4 fogClr = TransparentFog(color, wPos, uvscreen.xy, linear01Depth);
|
||||
|
||||
#if _ALPHAPREMULTIPLY_ON
|
||||
fogClr.rgb *= o.Alpha;
|
||||
#endif
|
||||
|
||||
#ifndef UNITY_PASS_FORWARDADD
|
||||
color.rgb = fogClr.rgb;
|
||||
#endif
|
||||
}
|
||||
|
||||
void surf(Input IN, inout SurfaceOutputStandard o) {
|
||||
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * (IN.color * _TintColor);
|
||||
o.Albedo = c.rgb * _Intensity;
|
||||
o.Alpha = c.a;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
FallBack "Diffuse"
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 12af3ffc6c4bf5242a04cc4d8dea12e1
|
||||
timeCreated: 1541339377
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,90 +0,0 @@
|
||||
Shader "Enviro/Particles/Additive" {
|
||||
Properties {
|
||||
_MainTex ("Particle Texture", 2D) = "white" {}
|
||||
_InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0
|
||||
}
|
||||
|
||||
Category {
|
||||
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" }
|
||||
Blend One OneMinusSrcColor
|
||||
ColorMask RGB
|
||||
Cull Off Lighting Off ZWrite Off
|
||||
|
||||
SubShader {
|
||||
Pass {
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 2.0
|
||||
#pragma exclude_renderers gles
|
||||
#pragma multi_compile_particles
|
||||
#pragma multi_compile_fog
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "../../Resources/Shaders/Core/EnviroFogCore.cginc"
|
||||
|
||||
sampler2D _MainTex;
|
||||
fixed4 _TintColor;
|
||||
|
||||
struct appdata_t {
|
||||
float4 vertex : POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f {
|
||||
float4 vertex : SV_POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
UNITY_FOG_COORDS(1)
|
||||
float4 projPos : TEXCOORD2;
|
||||
float3 posWorld : TEXCOORD3;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
float4 _MainTex_ST;
|
||||
|
||||
v2f vert (appdata_t v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.posWorld = mul(unity_ObjectToWorld, v.vertex);
|
||||
o.projPos = ComputeScreenPos (o.vertex);
|
||||
COMPUTE_EYEDEPTH(o.projPos.z);
|
||||
o.color = v.color;
|
||||
o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
|
||||
UNITY_TRANSFER_FOG(o,o.vertex);
|
||||
return o;
|
||||
}
|
||||
|
||||
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
|
||||
float _InvFade;
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
float sceneZ = LinearEyeDepth (SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)));
|
||||
|
||||
#ifdef SOFTPARTICLES_ON
|
||||
float partZ = i.projPos.z;
|
||||
float fade = saturate (_InvFade * (sceneZ-partZ));
|
||||
i.color.a *= fade;
|
||||
#endif
|
||||
|
||||
half4 col = i.color * tex2D(_MainTex, i.texcoord);
|
||||
col.rgb *= col.a;
|
||||
UNITY_APPLY_FOG_COLOR(i.fogCoord, col, fixed4(0,0,0,0)); // fog towards black due to our blend mode
|
||||
|
||||
//half linear01Depth = LinearEyeDepth(i.projPos.z);
|
||||
float4 fog = TransparentFog(col,i.posWorld,i.projPos.xy,sceneZ);
|
||||
fog.rgb *= col.rgb;
|
||||
return fog;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 83de0fc6fdb60ae4f879ec2a0d1e18fd
|
||||
timeCreated: 1506252156
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
-90
@@ -1,90 +0,0 @@
|
||||
Shader "Enviro/Particles/Alpha Blended" {
|
||||
Properties {
|
||||
_TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5)
|
||||
_MainTex ("Particle Texture", 2D) = "white" {}
|
||||
_InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0
|
||||
}
|
||||
|
||||
Category {
|
||||
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" }
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ColorMask RGB
|
||||
Cull Off Lighting Off ZWrite Off
|
||||
|
||||
SubShader {
|
||||
Pass {
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 2.0
|
||||
#pragma multi_compile_particles
|
||||
#pragma multi_compile_fog
|
||||
#pragma exclude_renderers gles
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "../../Resources/Shaders/Core/EnviroFogCore.cginc"
|
||||
|
||||
sampler2D _MainTex;
|
||||
fixed4 _TintColor;
|
||||
|
||||
struct appdata_t {
|
||||
float4 vertex : POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f {
|
||||
float4 vertex : SV_POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
UNITY_FOG_COORDS(1)
|
||||
float4 projPos : TEXCOORD2;
|
||||
float3 posWorld : TEXCOORD3;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
float4 _MainTex_ST;
|
||||
|
||||
v2f vert (appdata_t v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.posWorld = mul(unity_ObjectToWorld, v.vertex);
|
||||
o.projPos = ComputeScreenPos (o.vertex);
|
||||
COMPUTE_EYEDEPTH(o.projPos.z);
|
||||
o.color = v.color * _TintColor;
|
||||
o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
|
||||
UNITY_TRANSFER_FOG(o,o.vertex);
|
||||
return o;
|
||||
}
|
||||
|
||||
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
|
||||
float _InvFade;
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
|
||||
float sceneZ = LinearEyeDepth (SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)));
|
||||
|
||||
#ifdef SOFTPARTICLES_ON
|
||||
float partZ = i.projPos.z;
|
||||
float fade = saturate (_InvFade * (sceneZ-partZ));
|
||||
i.color.a *= fade;
|
||||
#endif
|
||||
|
||||
fixed4 col = 2.0f * i.color * tex2D(_MainTex, i.texcoord);
|
||||
UNITY_APPLY_FOG(i.fogCoord, col);
|
||||
|
||||
float4 fog = TransparentFog(col,i.posWorld,i.projPos.xy,sceneZ);
|
||||
|
||||
return float4(fog.rgb,col.a);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4b46c5cd78fad2b4bb7e182ea4f565d4
|
||||
timeCreated: 1506436501
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
-95
@@ -1,95 +0,0 @@
|
||||
Shader "Enviro/Particles/Lightning" {
|
||||
Properties {
|
||||
_MainTex ("Particle Texture", 2D) = "white" {}
|
||||
_InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0
|
||||
_Intensity("Brightness", float) = 250
|
||||
|
||||
}
|
||||
|
||||
Category {
|
||||
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" }
|
||||
Blend One OneMinusSrcColor
|
||||
ColorMask RGB
|
||||
Cull Off Lighting Off ZWrite Off
|
||||
|
||||
SubShader {
|
||||
Pass {
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 2.0
|
||||
#pragma multi_compile_particles
|
||||
#pragma multi_compile_fog
|
||||
#pragma exclude_renderers gles
|
||||
#include "UnityCG.cginc"
|
||||
#include "../../Resources/Shaders/Core/EnviroFogCore.cginc"
|
||||
|
||||
sampler2D _MainTex;
|
||||
fixed4 _TintColor;
|
||||
|
||||
struct appdata_t {
|
||||
float4 vertex : POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f {
|
||||
float4 vertex : SV_POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
UNITY_FOG_COORDS(1)
|
||||
float4 projPos : TEXCOORD2;
|
||||
float3 posWorld : TEXCOORD3;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
float4 _MainTex_ST;
|
||||
|
||||
v2f vert (appdata_t v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.posWorld = mul(unity_ObjectToWorld, v.vertex);
|
||||
o.projPos = ComputeScreenPos (o.vertex);
|
||||
COMPUTE_EYEDEPTH(o.projPos.z);
|
||||
o.color = v.color;
|
||||
o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
|
||||
UNITY_TRANSFER_FOG(o,o.vertex);
|
||||
return o;
|
||||
}
|
||||
|
||||
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
|
||||
float _InvFade;
|
||||
float _Intensity;
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
float sceneZ = LinearEyeDepth (SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)));
|
||||
|
||||
#ifdef SOFTPARTICLES_ON
|
||||
float partZ = i.projPos.z;
|
||||
float fade = saturate (_InvFade * (sceneZ-partZ));
|
||||
i.color.a *= fade;
|
||||
#endif
|
||||
|
||||
half4 col = i.color * tex2D(_MainTex, i.texcoord);
|
||||
col.rgb *= _Intensity;
|
||||
col.rgb *= col.a;
|
||||
UNITY_APPLY_FOG_COLOR(i.fogCoord, col, fixed4(0,0,0,0)); // fog towards black due to our blend mode
|
||||
|
||||
//half linear01Depth = LinearEyeDepth(i.projPos.z);
|
||||
float4 fog = TransparentFog(col,i.posWorld, i.projPos.xy,sceneZ);
|
||||
fog.rgb *= col.rgb;
|
||||
return fog;
|
||||
|
||||
//return col;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: db239a9a1eba8f3459e2cb60bd1ec552
|
||||
timeCreated: 1506252156
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,94 +0,0 @@
|
||||
Shader "Enviro/Particles/WeatherParticles" {
|
||||
Properties {
|
||||
_TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5)
|
||||
_MainTex ("Particle Texture", 2D) = "white" {}
|
||||
//_InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0
|
||||
_lightIntensity ("Light Intensity", Range(0.0,1.0)) = 1.0
|
||||
}
|
||||
|
||||
Category {
|
||||
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ColorMask RGBA
|
||||
Cull Off Lighting Off ZWrite Off
|
||||
|
||||
SubShader {
|
||||
Pass {
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 3.0
|
||||
#pragma multi_compile_particles
|
||||
#pragma multi_compile_fog
|
||||
#pragma exclude_renderers gles
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "../../Resources/Shaders/Core/EnviroFogCore.cginc"
|
||||
|
||||
sampler2D _MainTex;
|
||||
fixed4 _TintColor;
|
||||
float4 _EnviroLighting;
|
||||
float _lightIntensity;
|
||||
|
||||
struct appdata_t {
|
||||
float4 vertex : POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f {
|
||||
float4 vertex : SV_POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
UNITY_FOG_COORDS(1)
|
||||
float4 projPos : TEXCOORD2;
|
||||
float3 posWorld : TEXCOORD3;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
float4 _MainTex_ST;
|
||||
|
||||
v2f vert (appdata_t v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.posWorld = mul(unity_ObjectToWorld, v.vertex);
|
||||
o.projPos = ComputeScreenPos (o.vertex);
|
||||
COMPUTE_EYEDEPTH(o.projPos.z);
|
||||
o.color = v.color;
|
||||
o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
|
||||
UNITY_TRANSFER_FOG(o,o.vertex);
|
||||
return o;
|
||||
}
|
||||
|
||||
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
|
||||
//float _InvFade;
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
|
||||
float sceneZ = LinearEyeDepth (SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)));
|
||||
|
||||
#ifdef SOFTPARTICLES_ON
|
||||
float partZ = i.projPos.z;
|
||||
float fade = saturate (0.5 * (sceneZ-partZ));
|
||||
i.color.a *= fade;
|
||||
#endif
|
||||
|
||||
fixed4 col = 2.0f * i.color * _TintColor * tex2D(_MainTex, i.texcoord);
|
||||
col *= _EnviroLighting * _lightIntensity;
|
||||
UNITY_APPLY_FOG(i.fogCoord, col);
|
||||
|
||||
float4 fog = TransparentFog(col,i.posWorld,i.projPos.xy,sceneZ);
|
||||
|
||||
return float4(fog.rgb,col.a);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: acc6584263b225742a2e39740a470be8
|
||||
timeCreated: 1472601408
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
-97
@@ -1,97 +0,0 @@
|
||||
Shader "Enviro/Particles/WeatherParticlesAdditive" {
|
||||
Properties {
|
||||
_TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5)
|
||||
_MainTex ("Particle Texture", 2D) = "white" {}
|
||||
_InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0
|
||||
_lightIntensity ("Light Intensity", Range(0.0,1.0)) = 1.0
|
||||
}
|
||||
|
||||
Category {
|
||||
Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" "PreviewType" = "Plane" }
|
||||
Blend One OneMinusSrcColor
|
||||
ColorMask RGB
|
||||
Cull Off Lighting Off ZWrite Off
|
||||
|
||||
SubShader {
|
||||
Pass {
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 3.0
|
||||
#pragma multi_compile_particles
|
||||
#pragma multi_compile_fog
|
||||
#pragma exclude_renderers gles
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "../../Resources/Shaders/Core/EnviroFogCore.cginc"
|
||||
|
||||
sampler2D _MainTex;
|
||||
fixed4 _TintColor;
|
||||
float4 _EnviroLighting;
|
||||
float _lightIntensity;
|
||||
float _InvFade;
|
||||
|
||||
struct appdata_t {
|
||||
float4 vertex : POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f {
|
||||
float4 vertex : SV_POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
UNITY_FOG_COORDS(1)
|
||||
float4 projPos : TEXCOORD2;
|
||||
float3 posWorld : TEXCOORD3;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
float4 _MainTex_ST;
|
||||
|
||||
v2f vert (appdata_t v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.posWorld = mul(unity_ObjectToWorld, v.vertex);
|
||||
o.projPos = ComputeScreenPos (o.vertex);
|
||||
COMPUTE_EYEDEPTH(o.projPos.z);
|
||||
o.color = v.color;
|
||||
o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
|
||||
UNITY_TRANSFER_FOG(o,o.vertex);
|
||||
return o;
|
||||
}
|
||||
|
||||
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
|
||||
//float _InvFade;
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
float sceneZ = LinearEyeDepth(SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)));
|
||||
|
||||
#ifdef SOFTPARTICLES_ON
|
||||
float partZ = i.projPos.z;
|
||||
float fade = saturate(_InvFade * (sceneZ - partZ));
|
||||
i.color.a *= fade;
|
||||
#endif
|
||||
|
||||
half4 col = i.color * tex2D(_MainTex, i.texcoord);
|
||||
col.rgb *= _EnviroLighting * 1.5;
|
||||
col.rgb *= col.a;
|
||||
|
||||
UNITY_APPLY_FOG_COLOR(i.fogCoord, col, fixed4(0, 0, 0, 0)); // fog towards black due to our blend mode
|
||||
|
||||
//half linear01Depth = LinearEyeDepth(i.projPos.z);
|
||||
float4 fog = TransparentFog(col, i.posWorld, i.projPos.xy, sceneZ);
|
||||
fog.rgb *= col.rgb;
|
||||
return fog;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7887324a897cd4d4b89d3e52af0d1e46
|
||||
timeCreated: 1472601408
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,66 +0,0 @@
|
||||
Shader "Enviro/StandardAlphaBlended"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_Color ("Color", Color) = (1,1,1,1)
|
||||
_MainTex ("Albedo (RGB)", 2D) = "white" {}
|
||||
_Glossiness ("Smoothness", Range(0,1)) = 0.5
|
||||
_Metallic ("Metallic", Range(0,1)) = 0.0
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags {"Queue" = "Transparent" "RenderType"="Transparent" }
|
||||
LOD 200
|
||||
|
||||
CGPROGRAM
|
||||
#include "../../Resources/Shaders/Core/EnviroFogCore.cginc"
|
||||
#pragma surface surf Standard fullforwardshadows alpha finalcolor:ApplyFog
|
||||
#pragma target 3.0
|
||||
|
||||
|
||||
|
||||
sampler2D _MainTex;
|
||||
sampler2D _CameraDepthTexture;
|
||||
|
||||
struct Input {
|
||||
float2 uv_MainTex;
|
||||
float4 screenPos;
|
||||
float3 worldPos;
|
||||
};
|
||||
|
||||
void ApplyFog(Input IN, SurfaceOutputStandard o, inout fixed4 color)
|
||||
{
|
||||
//Get ScreenPosition
|
||||
float3 uvscreen = IN.screenPos.xyz/IN.screenPos.w;
|
||||
// Calculate Linear Depth
|
||||
half linear01Depth = Linear01Depth(uvscreen.z);
|
||||
//get World Position
|
||||
float3 wPos = IN.worldPos.xyz;
|
||||
// Calculate Fog and apply volume lighting tex
|
||||
float4 fogClr = TransparentFog(color,wPos, uvscreen.xy, linear01Depth);
|
||||
|
||||
#if _ALPHAPREMULTIPLY_ON
|
||||
fogClr.rgb *= o.Alpha;
|
||||
#endif
|
||||
|
||||
#ifndef UNITY_PASS_FORWARDADD
|
||||
color.rgb = fogClr.rgb;
|
||||
#endif
|
||||
}
|
||||
|
||||
half _Glossiness;
|
||||
half _Metallic;
|
||||
fixed4 _Color;
|
||||
|
||||
void surf (Input IN, inout SurfaceOutputStandard o)
|
||||
{
|
||||
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
|
||||
o.Albedo = c.rgb;
|
||||
o.Metallic = _Metallic;
|
||||
o.Smoothness = _Glossiness;
|
||||
o.Alpha = c.a;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
FallBack "Standard"
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 58f17004d23396448827417fe395f149
|
||||
timeCreated: 1506388388
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
-181
@@ -1,181 +0,0 @@
|
||||
|
||||
Shader "Enviro/Lite/EnviroFogRendering"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex("Base (RGB)", Any) = "white" {}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Pass
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off Fog { Mode Off }
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 3.0
|
||||
|
||||
// Start: LuxWater
|
||||
#pragma multi_compile __ LUXWATER_DEFERREDFOG
|
||||
|
||||
#if defined(LUXWATER_DEFERREDFOG)
|
||||
sampler2D _UnderWaterMask;
|
||||
float4 _LuxUnderWaterDeferredFogParams; // x: IsInsideWatervolume?, y: BelowWaterSurface shift, z: EdgeBlend
|
||||
#endif
|
||||
// End: LuxWater
|
||||
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "../../../Core/Resources/Shaders/Core/EnviroFogCore.cginc"
|
||||
|
||||
UNITY_DECLARE_SCREENSPACE_TEXTURE(_MainTex);
|
||||
uniform float4 _MainTex_TexelSize;
|
||||
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
|
||||
uniform float4x4 _LeftWorldFromView;
|
||||
uniform float4x4 _RightWorldFromView;
|
||||
uniform float4x4 _LeftViewFromScreen;
|
||||
uniform float4x4 _RightViewFromScreen;
|
||||
|
||||
struct appdata_t
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float3 texcoord : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float3 texcoord : TEXCOORD0;
|
||||
float3 sky : TEXCOORD1;
|
||||
float2 uv : TEXCOORD2;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
|
||||
v2f vert(appdata_img v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v); //Insert
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o); //Insert
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); //Insert
|
||||
o.pos = v.vertex * float4(2, 2, 1, 1) + float4(-1, -1, 0, 0);
|
||||
o.uv.xy = v.texcoord.xy;
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
if (_MainTex_TexelSize.y > 0)
|
||||
o.uv.y = 1 - o.uv.y;
|
||||
#endif
|
||||
o.sky.x = saturate(_SunDir.y + 0.25);
|
||||
o.sky.y = saturate(clamp(1.0 - _SunDir.y, 0.0, 0.5));
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag(v2f i) : SV_Target
|
||||
{
|
||||
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
|
||||
float rawDepth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoTransformScreenSpaceTex(i.uv));
|
||||
float dpth = Linear01Depth(rawDepth);
|
||||
|
||||
float4x4 proj, eyeToWorld;
|
||||
if (unity_StereoEyeIndex == 0)
|
||||
{
|
||||
proj = _LeftViewFromScreen;
|
||||
eyeToWorld = _LeftWorldFromView;
|
||||
}
|
||||
else
|
||||
{
|
||||
proj = _RightViewFromScreen;
|
||||
eyeToWorld = _RightWorldFromView;
|
||||
}
|
||||
|
||||
//bit of matrix math to take the screen space coord (u,v,depth) and transform to world space
|
||||
float2 uvClip = i.uv * 2.0 - 1.0;
|
||||
float clipDepth = rawDepth; // Fix for OpenGl Core thanks to Lars Bertram
|
||||
clipDepth = (UNITY_NEAR_CLIP_VALUE < 0) ? clipDepth * 2 - 1 : clipDepth;
|
||||
float4 clipPos = float4(uvClip, clipDepth, 1.0);
|
||||
float4 viewPos = mul(proj, clipPos); // inverse projection by clip position
|
||||
viewPos /= viewPos.w; // perspective division
|
||||
|
||||
float4 wsPos = float4(mul(eyeToWorld, viewPos).xyz, 1);
|
||||
float4 wsDir = wsPos - float4(_WorldSpaceCameraPos, 0);
|
||||
|
||||
float3 viewDir = normalize(wsDir);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
half fogFac = 0;
|
||||
float4 finalFog = 0;
|
||||
float g = _DistanceParams.x;
|
||||
half gAdd = 0;
|
||||
|
||||
if (_EnviroParams.z > 0)
|
||||
{
|
||||
gAdd = ComputeHalfSpace (wsDir);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//Scene
|
||||
if (dpth < 0.99999)
|
||||
{
|
||||
// Calculate Distance Fog
|
||||
if (_EnviroParams.y > 0)
|
||||
{
|
||||
g += ComputeDistance(wsDir, dpth);
|
||||
g *= _distanceFogIntensity;
|
||||
}
|
||||
|
||||
// AAdd Height Fog
|
||||
g += gAdd;
|
||||
|
||||
// Compute fog amount
|
||||
fogFac = ComputeFogFactor(max(0.0, g));
|
||||
fogFac = lerp(_maximumFogDensity, 1.0f, fogFac);
|
||||
|
||||
finalFog = ComputeScatteringScene(viewDir, i.sky.xy);
|
||||
|
||||
}
|
||||
else //SKY
|
||||
{
|
||||
float f = saturate(_EnviroSkyFog.x * (viewDir.y + _EnviroSkyFog.z));
|
||||
f = pow(f, _EnviroSkyFog.y);
|
||||
fogFac = (clamp(f, 0, 1));
|
||||
finalFog = ComputeScatteringScene(viewDir, i.sky.xy);
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
// Start: LuxWater
|
||||
#if defined(LUXWATER_DEFERREDFOG)
|
||||
half4 fogMask = tex2D(_UnderWaterMask, UnityStereoTransformScreenSpaceTex(i.uv));
|
||||
float watersurfacefrombelow = DecodeFloatRG(fogMask.ba);
|
||||
|
||||
// Get distance and lower it a bit in order to handle edge blending artifacts (edge blended parts would not get ANY fog)
|
||||
float dist = (watersurfacefrombelow - dpth) + _LuxUnderWaterDeferredFogParams.y * _ProjectionParams.w;
|
||||
// Fade fog from above water to below water
|
||||
float fogFactor = saturate(1.0 + _ProjectionParams.z * _LuxUnderWaterDeferredFogParams.z * dist);
|
||||
// Clamp above result to where water is actually rendered
|
||||
fogFactor = (fogMask.r == 1) ? fogFactor : 1.0;
|
||||
// Mask fog on underwarter parts - only if we are inside a volume (bool... :( )
|
||||
if (_LuxUnderWaterDeferredFogParams.x) {
|
||||
fogFactor *= saturate(1.0 - fogMask.g * 8.0);
|
||||
if (dist < -_ProjectionParams.w * 4 && fogMask.r == 0 && fogMask.g < 1.0) {
|
||||
fogFactor = 1.0;
|
||||
}
|
||||
}
|
||||
// Tweak fog factor
|
||||
fogFac = lerp(1.0, fogFac, fogFactor);
|
||||
#endif
|
||||
// End: LuxWater
|
||||
|
||||
float4 source = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, UnityStereoTransformScreenSpaceTex(i.uv));
|
||||
return lerp (finalFog, source, fogFac);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
Fallback Off
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5b0160f40adf130428015ffb5bfdb8a5
|
||||
timeCreated: 1459178236
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
-161
@@ -1,161 +0,0 @@
|
||||
|
||||
Shader "Enviro/Lite/EnviroFogRenderingSimple"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex("Base (RGB)", Any) = "white" {}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Pass
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off Fog { Mode Off }
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 2.0
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
UNITY_DECLARE_SCREENSPACE_TEXTURE(_MainTex);
|
||||
uniform float4 _MainTex_TexelSize;
|
||||
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
|
||||
|
||||
uniform float4x4 _LeftWorldFromView;
|
||||
uniform float4x4 _RightWorldFromView;
|
||||
uniform float4x4 _LeftViewFromScreen;
|
||||
uniform float4x4 _RightViewFromScreen;
|
||||
uniform float4 _EnviroParams;
|
||||
uniform float4 _DistanceParams;
|
||||
uniform int4 _SceneFogMode;
|
||||
uniform float4 _SceneFogParams;
|
||||
uniform half _distanceFogIntensity;
|
||||
uniform float4 _EnviroSkyFog; // x = _SkyFogHeight, y = _SkyFogIntensity, z = _SkyFogStart, w = _HeightFogIntensity
|
||||
uniform float _maximumFogDensity;
|
||||
uniform float _lightning;
|
||||
|
||||
struct appdata_t
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float3 texcoord : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float3 texcoord : TEXCOORD0;
|
||||
float2 uv : TEXCOORD1;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
|
||||
v2f vert(appdata_img v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v); //Insert
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o); //Insert
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); //Insert
|
||||
o.pos = v.vertex * float4(2, 2, 1, 1) + float4(-1, -1, 0, 0);
|
||||
o.uv.xy = v.texcoord.xy;
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
if (_MainTex_TexelSize.y > 0)
|
||||
o.uv.y = 1 - o.uv.y;
|
||||
#endif
|
||||
return o;
|
||||
}
|
||||
|
||||
half ComputeFogFactor(float coord)
|
||||
{
|
||||
float fogFac = 0.0;
|
||||
|
||||
if (_SceneFogMode.x == 1) // linear
|
||||
{
|
||||
fogFac = coord * _SceneFogParams.z + _SceneFogParams.w;
|
||||
}
|
||||
|
||||
if (_SceneFogMode.x >= 2) // exp
|
||||
{
|
||||
fogFac = _SceneFogParams.y * coord; fogFac = exp2(-fogFac);
|
||||
}
|
||||
|
||||
return saturate(fogFac);
|
||||
}
|
||||
|
||||
// Distance fog
|
||||
float ComputeDistance(float3 camDir, float zdepth)
|
||||
{
|
||||
float dist;
|
||||
dist = length(camDir);
|
||||
dist -= _ProjectionParams.y;
|
||||
return dist;
|
||||
}
|
||||
|
||||
fixed4 frag(v2f i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
|
||||
float rawDepth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoTransformScreenSpaceTex(i.uv));
|
||||
float dpth = Linear01Depth(rawDepth);
|
||||
|
||||
float4x4 proj, eyeToWorld;
|
||||
|
||||
if (unity_StereoEyeIndex == 0)
|
||||
{
|
||||
proj = _LeftViewFromScreen;
|
||||
eyeToWorld = _LeftWorldFromView;
|
||||
}
|
||||
else
|
||||
{
|
||||
proj = _RightViewFromScreen;
|
||||
eyeToWorld = _RightWorldFromView;
|
||||
}
|
||||
|
||||
//bit of matrix math to take the screen space coord (u,v,depth) and transform to world space
|
||||
float2 uvClip = i.uv * 2.0 - 1.0;
|
||||
float clipDepth = rawDepth; // Fix for OpenGl Core thanks to Lars Bertram
|
||||
clipDepth = (UNITY_NEAR_CLIP_VALUE < 0) ? clipDepth * 2 - 1 : clipDepth;
|
||||
float4 clipPos = float4(uvClip, clipDepth, 1.0);
|
||||
float4 viewPos = mul(proj, clipPos); // inverse projection by clip position
|
||||
viewPos /= viewPos.w; // perspective division
|
||||
|
||||
float4 wsPos = float4(mul(eyeToWorld, viewPos).xyz, 1);
|
||||
float4 wsDir = wsPos - float4(_WorldSpaceCameraPos, 0);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
half fogFac = 0;
|
||||
float4 finalFog = unity_FogColor;
|
||||
float g = _DistanceParams.x;
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//Scene
|
||||
if (dpth < 0.99999)
|
||||
{
|
||||
// Calculate Distance Fog
|
||||
if (_EnviroParams.y > 0)
|
||||
{
|
||||
g += ComputeDistance(wsDir,dpth);
|
||||
g *= _distanceFogIntensity;
|
||||
}
|
||||
|
||||
// Compute fog amount
|
||||
fogFac = ComputeFogFactor(max(0.0, g));
|
||||
fogFac = lerp(_maximumFogDensity, 1.0f, fogFac);
|
||||
}
|
||||
else //SKY
|
||||
{
|
||||
float3 viewDir = normalize(wsDir);
|
||||
float f = saturate(_EnviroSkyFog.x * (viewDir.y + _EnviroSkyFog.z));
|
||||
f = pow(f, _EnviroSkyFog.y);
|
||||
fogFac = clamp(f, 0, 1);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
float4 source = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, UnityStereoTransformScreenSpaceTex(i.uv));
|
||||
return lerp (finalFog, source, fogFac);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
Fallback Off
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 52f9d6fdd8d48b54d9e1538255a22e9a
|
||||
timeCreated: 1459178236
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
-74
@@ -1,74 +0,0 @@
|
||||
Shader "Enviro/Lite/MoonShader"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex("Texture (RGB)", 2D) = "black" {}
|
||||
_Color("Color", Color) = (0.8, 0.8, 0.8, 1)
|
||||
_Brightness("Brightness", Float) = 5
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"Queue"="Transparent"
|
||||
"RenderType"="Transparent"
|
||||
"IgnoreProjector"="True"
|
||||
}
|
||||
Pass
|
||||
{
|
||||
Cull Back
|
||||
Blend One One
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 2.0
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
uniform float4 _SunPosition;
|
||||
uniform float4 _MoonPosition;
|
||||
uniform sampler2D _MainTex;
|
||||
uniform float4 _MainTex_ST;
|
||||
uniform float4 _Color;
|
||||
uniform float _Brightness;
|
||||
uniform float _moonFogIntensity;
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float3 normal : TEXCOORD0;
|
||||
float3 worldvertpos : TEXCOORD1;
|
||||
float2 texcoord : TEXCOORD2;
|
||||
};
|
||||
|
||||
v2f vert(appdata_base v)
|
||||
{
|
||||
v2f o;
|
||||
o.pos = UnityObjectToClipPos (v.vertex);
|
||||
o.normal = mul((float3x3)unity_ObjectToWorld, v.normal);
|
||||
o.worldvertpos = mul(unity_ObjectToWorld, v.vertex).xyz;
|
||||
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 frag(v2f i) : COLOR
|
||||
{
|
||||
|
||||
float3 sunPos = _SunPosition;
|
||||
float3 moonPos = _MoonPosition;
|
||||
|
||||
float3 lightVector = normalize(_SunPosition - moonPos);
|
||||
|
||||
i.normal = normalize(i.normal);
|
||||
|
||||
float3 clr = tex2D(_MainTex, i.texcoord) * _Color;
|
||||
clr = pow(clr, 0.3);
|
||||
float d = saturate(max(0.0,dot(i.normal,lightVector)) * 2);
|
||||
clr = (clr * d) * _Brightness;
|
||||
|
||||
return float4(clr * _moonFogIntensity,1);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}}
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8a73bcd29e414e34fb7b2b7eb7f75155
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
-109
@@ -1,109 +0,0 @@
|
||||
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
|
||||
|
||||
Shader "Enviro/Lite/MoonShaderPhased"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Moon Texture", 2D) = "white" {}
|
||||
_Phase ("Moon Phase", float) = 0
|
||||
_Brightness ("Moon Brightness", Range(0.1,5)) = 0.5
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{"Queue"="Transparent"
|
||||
"RenderType"="Transparent"
|
||||
"IgnoreProjector"="True"
|
||||
}
|
||||
|
||||
Fog
|
||||
{
|
||||
Mode Off
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Cull Back
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
#pragma target 2.0
|
||||
|
||||
uniform sampler2D _MainTex;
|
||||
uniform float4 _MainTex_ST;
|
||||
uniform float _Phase;
|
||||
uniform float _Brightness;
|
||||
uniform float _moonFogIntensity;
|
||||
|
||||
struct v2f {
|
||||
float4 position : POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 uv_MainTex : TEXCOORD0;
|
||||
float3 normal : TEXCOORD1;
|
||||
float3 viewdir : TEXCOORD2;
|
||||
};
|
||||
|
||||
float MoonPhaseFactor(float2 uv, float phase)
|
||||
{
|
||||
float alpha = 1.0;
|
||||
|
||||
float srefx = uv.x - 0.5;
|
||||
float refx = abs(uv.x - 0.5);
|
||||
float refy = abs(uv.y - 0.5);
|
||||
float refxfory = sqrt(0.25 - refy * refy);
|
||||
float xmin = -refxfory;
|
||||
float xmax = refxfory;
|
||||
float xmin1 = (xmax - xmin) * (phase / 2) + xmin;
|
||||
float xmin2 = (xmax - xmin) * phase + xmin;
|
||||
if (srefx < xmin1) {
|
||||
alpha = 0;
|
||||
} else if (srefx < xmin2 && xmin1 != xmin2) {
|
||||
alpha = (srefx - xmin1) / (xmin2 - xmin1);
|
||||
}
|
||||
return alpha;
|
||||
}
|
||||
|
||||
v2f vert(appdata_base v) {
|
||||
v2f o;
|
||||
|
||||
float phaseabs = abs(_Phase);
|
||||
float3 offset = 10 * float3(_Phase, -phaseabs, -phaseabs);
|
||||
|
||||
float3 normal = v.normal;
|
||||
float3 viewdir = normalize(ObjSpaceViewDir(v.vertex));
|
||||
|
||||
o.position = UnityObjectToClipPos(v.vertex);
|
||||
o.color.rgb = 1 - phaseabs;
|
||||
o.color.a = 1;
|
||||
o.uv_MainTex = TRANSFORM_TEX(v.texcoord, _MainTex);
|
||||
o.normal = v.normal;
|
||||
o.viewdir = normalize(viewdir + offset);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag(v2f i) : COLOR {
|
||||
fixed4 color = i.color;
|
||||
|
||||
float alpha = MoonPhaseFactor(i.uv_MainTex, abs(_Phase));
|
||||
fixed shading = max(0, dot(i.normal, i.viewdir));
|
||||
color.rgb *= pow(shading, 0.5);
|
||||
|
||||
// Moon texture
|
||||
fixed3 moontex = tex2D(_MainTex, i.uv_MainTex);
|
||||
color.rgb *= moontex.rgb * 2.5;
|
||||
|
||||
float lum = dot(color.rgb, float3(0.8, 0.8, 0.8));
|
||||
color.a = min(color.a, lum * alpha);
|
||||
color.rgb = saturate(1.0 - exp(-_Brightness * color.rgb));
|
||||
return float4(color.rgb, color.a * _moonFogIntensity);
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a1b5f57aa0d6ff9438d0e14cc18c4506
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
-334
@@ -1,334 +0,0 @@
|
||||
// MODIFIED FOR ENVIRO POST PROCESSING
|
||||
//
|
||||
// Kino/Bloom v2 - Bloom filter for Unity
|
||||
//
|
||||
// Copyright (C) 2015, 2016 Keijiro Takahashi
|
||||
//
|
||||
// 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 notice and this permission notice 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.
|
||||
//
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
// Mobile: use RGBM instead of float/half RGB
|
||||
#define USE_RGBM defined(SHADER_API_MOBILE)
|
||||
|
||||
UNITY_DECLARE_SCREENSPACE_TEXTURE(_MainTex);
|
||||
UNITY_DECLARE_SCREENSPACE_TEXTURE(_BaseTex);
|
||||
float2 _MainTex_TexelSize;
|
||||
float2 _BaseTex_TexelSize;
|
||||
half4 _MainTex_ST;
|
||||
half4 _BaseTex_ST;
|
||||
|
||||
float _PrefilterOffs;
|
||||
half _Threshold;
|
||||
half3 _Curve;
|
||||
float _SampleScale;
|
||||
half _Intensity;
|
||||
|
||||
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
|
||||
sampler2D _DistTex;
|
||||
float _Distance;
|
||||
float _Radius;
|
||||
float _SkyBlurring;
|
||||
|
||||
float4x4 _LeftWorldFromView;
|
||||
float4x4 _RightWorldFromView;
|
||||
float4x4 _LeftViewFromScreen;
|
||||
float4x4 _RightViewFromScreen;
|
||||
|
||||
// Brightness function
|
||||
half Brightness(half3 c)
|
||||
{
|
||||
return max(max(c.r, c.g), c.b);
|
||||
}
|
||||
|
||||
// 3-tap median filter
|
||||
half3 Median(half3 a, half3 b, half3 c)
|
||||
{
|
||||
return a + b + c - min(min(a, b), c) - max(max(a, b), c);
|
||||
}
|
||||
|
||||
// Clamp HDR value within a safe range
|
||||
half3 SafeHDR(half3 c) { return min(c, 65000); }
|
||||
half4 SafeHDR(half4 c) { return min(c, 65000); }
|
||||
|
||||
// RGBM encoding/decoding
|
||||
half4 EncodeHDR(float3 rgb)
|
||||
{
|
||||
#if USE_RGBM
|
||||
rgb *= 1.0 / 8;
|
||||
float m = max(max(rgb.r, rgb.g), max(rgb.b, 1e-6));
|
||||
m = ceil(m * 255) / 255;
|
||||
return half4(rgb / m, m);
|
||||
#else
|
||||
return half4(rgb, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
float3 DecodeHDR(half4 rgba)
|
||||
{
|
||||
#if USE_RGBM
|
||||
return rgba.rgb * rgba.a * 8;
|
||||
#else
|
||||
return rgba.rgb;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Downsample with a 4x4 box filter
|
||||
half3 DownsampleFilter(float2 uv)
|
||||
{
|
||||
float4 d = _MainTex_TexelSize.xyxy * float4(-1, -1, +1, +1);
|
||||
|
||||
half3 s;
|
||||
s = DecodeHDR(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv + d.xy));
|
||||
s += DecodeHDR(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv + d.zy));
|
||||
s += DecodeHDR(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv + d.xw));
|
||||
s += DecodeHDR(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv + d.zw));
|
||||
|
||||
return s * (1.0 / 4);
|
||||
}
|
||||
|
||||
// Downsample with a 4x4 box filter + anti-flicker filter
|
||||
half3 DownsampleAntiFlickerFilter(float2 uv)
|
||||
{
|
||||
float4 d = _MainTex_TexelSize.xyxy * float4(-1, -1, +1, +1);
|
||||
|
||||
half3 s1 = DecodeHDR(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv + d.xy));
|
||||
half3 s2 = DecodeHDR(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv + d.zy));
|
||||
half3 s3 = DecodeHDR(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv + d.xw));
|
||||
half3 s4 = DecodeHDR(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv + d.zw));
|
||||
|
||||
// Karis's luma weighted average (using brightness instead of luma)
|
||||
half s1w = 1 / (Brightness(s1) + 1);
|
||||
half s2w = 1 / (Brightness(s2) + 1);
|
||||
half s3w = 1 / (Brightness(s3) + 1);
|
||||
half s4w = 1 / (Brightness(s4) + 1);
|
||||
half one_div_wsum = 1 / (s1w + s2w + s3w + s4w);
|
||||
|
||||
return (s1 * s1w + s2 * s2w + s3 * s3w + s4 * s4w) * one_div_wsum;
|
||||
}
|
||||
|
||||
half3 UpsampleFilter(float2 uv)
|
||||
{
|
||||
#if HIGH_QUALITY
|
||||
// 9-tap bilinear upsampler (tent filter)
|
||||
float4 d = _MainTex_TexelSize.xyxy * float4(1, 1, -1, 0) * _SampleScale;
|
||||
|
||||
half3 s;
|
||||
s = DecodeHDR(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv - d.xy));
|
||||
s += DecodeHDR(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv - d.wy)) * 2;
|
||||
s += DecodeHDR(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv - d.zy));
|
||||
|
||||
s += DecodeHDR(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv + d.zw)) * 2;
|
||||
s += DecodeHDR(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv)) * 4;
|
||||
s += DecodeHDR(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv + d.xw)) * 2;
|
||||
|
||||
s += DecodeHDR(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv + d.zy));
|
||||
s += DecodeHDR(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv + d.wy)) * 2;
|
||||
s += DecodeHDR(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv + d.xy));
|
||||
|
||||
return s * (1.0 / 16);
|
||||
#else
|
||||
// 4-tap bilinear upsampler
|
||||
float4 d = _MainTex_TexelSize.xyxy * float4(-1, -1, +1, +1) * (_SampleScale * 0.5);
|
||||
|
||||
half3 s;
|
||||
s = DecodeHDR(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv + d.xy));
|
||||
s += DecodeHDR(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv + d.zy));
|
||||
s += DecodeHDR(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv + d.xw));
|
||||
s += DecodeHDR(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv + d.zw));
|
||||
|
||||
return s * (1.0 / 4);
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
// Vertex shader
|
||||
//
|
||||
|
||||
v2f_img vert(appdata_img v)
|
||||
{
|
||||
v2f_img o;
|
||||
UNITY_SETUP_INSTANCE_ID(v); //Insert
|
||||
UNITY_INITIALIZE_OUTPUT(v2f_img, o); //Insert
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); //Insert
|
||||
//o.pos = UnityObjectToClipPos(v.vertex);
|
||||
o.pos = v.vertex * float4(2, 2, 1, 1) + float4(-1, -1, 0, 0);
|
||||
o.uv = UnityStereoScreenSpaceUVAdjust(v.texcoord, _MainTex_ST);
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
if (_MainTex_TexelSize.y > 0.0)
|
||||
o.uv.y = 1 - o.uv.y;
|
||||
#endif
|
||||
return o;
|
||||
}
|
||||
|
||||
struct v2f_multitex
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uvMain : TEXCOORD0;
|
||||
float2 uvBase : TEXCOORD1;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f_multitex vert_multitex(appdata_img v)
|
||||
{
|
||||
v2f_multitex o;
|
||||
UNITY_SETUP_INSTANCE_ID(v); //Insert
|
||||
UNITY_INITIALIZE_OUTPUT(v2f_multitex, o); //Insert
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); //Insert
|
||||
//o.pos = UnityObjectToClipPos(v.vertex);
|
||||
o.pos = v.vertex * float4(2, 2, 1, 1) + float4(-1, -1, 0, 0);
|
||||
o.uvMain = UnityStereoScreenSpaceUVAdjust(v.texcoord, _MainTex_ST);
|
||||
o.uvBase = UnityStereoScreenSpaceUVAdjust(v.texcoord, _BaseTex_ST);
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
if (_BaseTex_TexelSize.y > 0.0)
|
||||
o.uvBase.y = 1.0 - v.texcoord.y;
|
||||
if (_MainTex_TexelSize.y > 0.0)
|
||||
o.uvMain.y = 1 - o.uvMain.y;
|
||||
#endif
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// fragment shader
|
||||
//
|
||||
|
||||
|
||||
half AdjustDepth(half d, half2 uv)
|
||||
{
|
||||
float4x4 proj, eyeToWorld;
|
||||
|
||||
if (unity_StereoEyeIndex == 0)
|
||||
{
|
||||
proj = _LeftViewFromScreen;
|
||||
eyeToWorld = _LeftWorldFromView;
|
||||
}
|
||||
else
|
||||
{
|
||||
proj = _RightViewFromScreen;
|
||||
eyeToWorld = _RightWorldFromView;
|
||||
}
|
||||
|
||||
float2 uvClip = uv * 2.0 - 1.0;
|
||||
float4 clipPos = float4(uvClip, d, 1.0);
|
||||
float4 viewPos = mul(proj, clipPos); // inverse projection by clip position
|
||||
viewPos /= viewPos.w; // perspective division
|
||||
float4 wsPos = float4(mul(eyeToWorld, viewPos).xyz, 1);
|
||||
float4 wsDir = wsPos - float4(_WorldSpaceCameraPos, 0);
|
||||
float3 viewDir = normalize(wsDir);
|
||||
|
||||
if (d < 0.99999)
|
||||
{
|
||||
d = clamp(d * ((_ProjectionParams.z - _ProjectionParams.y) / _Distance), 0, 1);
|
||||
d = tex2D(_DistTex, half2(d, 0.5));
|
||||
}
|
||||
else
|
||||
{
|
||||
d = 1 - saturate(_SkyBlurring * viewDir.y);
|
||||
d = (clamp(d, 0, 1));
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
half4 frag_prefilter(v2f_img i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
float2 uv = i.uv + _MainTex_TexelSize.xy * _PrefilterOffs;
|
||||
|
||||
#if ANTI_FLICKER
|
||||
float3 d = _MainTex_TexelSize.xyx * float3(1, 1, 0);
|
||||
half4 s0 = SafeHDR(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv));
|
||||
half3 s1 = SafeHDR(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv - d.xz).rgb);
|
||||
half3 s2 = SafeHDR(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv + d.xz).rgb);
|
||||
half3 s3 = SafeHDR(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv - d.zy).rgb);
|
||||
half3 s4 = SafeHDR(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv + d.zy).rgb);
|
||||
half3 m = Median(Median(s0.rgb, s1, s2), s3, s4);
|
||||
#else
|
||||
half4 s0 = SafeHDR(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv));
|
||||
half3 m = s0.rgb;
|
||||
#endif
|
||||
|
||||
#if UNITY_COLORSPACE_GAMMA
|
||||
m = GammaToLinearSpace(m);
|
||||
#endif
|
||||
// Pixel brightness
|
||||
half br = Brightness(m);
|
||||
|
||||
// Under-threshold part: quadratic curve
|
||||
half rq = clamp(br - _Curve.x, 0, _Curve.y);
|
||||
rq = _Curve.z * rq * rq;
|
||||
|
||||
// Combine and apply the brightness response curve.
|
||||
m *= max(rq, br - _Threshold) / max(br, 1e-5);
|
||||
|
||||
// Adjust Depth Texture for fullscreen blurring
|
||||
half depth = Linear01Depth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, i.uv).r);
|
||||
depth = AdjustDepth(depth, i.uv);
|
||||
|
||||
return EncodeHDR(m * depth);
|
||||
}
|
||||
|
||||
half4 frag_downsample1(v2f_img i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
#if ANTI_FLICKER
|
||||
return EncodeHDR(DownsampleAntiFlickerFilter(i.uv));
|
||||
#else
|
||||
return EncodeHDR(DownsampleFilter(i.uv));
|
||||
#endif
|
||||
}
|
||||
|
||||
half4 frag_downsample2(v2f_img i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
return EncodeHDR(DownsampleFilter(i.uv));
|
||||
}
|
||||
|
||||
half4 frag_upsample(v2f_multitex i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
half3 base = DecodeHDR(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_BaseTex, i.uvBase));
|
||||
half3 blur = UpsampleFilter(i.uvMain);
|
||||
|
||||
return EncodeHDR(base + blur);
|
||||
}
|
||||
|
||||
half4 frag_upsample_final(v2f_multitex i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
half4 base = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_BaseTex, i.uvBase);
|
||||
|
||||
half3 blur = UpsampleFilter(UnityStereoTransformScreenSpaceTex(i.uvMain));
|
||||
#if UNITY_COLORSPACE_GAMMA
|
||||
// base.rgb = GammaToLinearSpace(base.rgb);
|
||||
#endif
|
||||
half3 cout = base.rgb + blur * _Intensity;
|
||||
#if UNITY_COLORSPACE_GAMMA
|
||||
cout = LinearToGammaSpace(cout);
|
||||
#endif
|
||||
|
||||
// Adjust Depth Texture for fullscreen blurring
|
||||
//half depth = Linear01Depth(tex2D(_CameraDepthTexture, i.uvBase).r);
|
||||
|
||||
half depth = Linear01Depth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, i.uvBase).r);
|
||||
depth = AdjustDepth(depth, i.uvBase);
|
||||
|
||||
return lerp(base, half4(blur,1) * (1 / _Radius), clamp(depth ,0,_Intensity));
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3747da2d4df0600489ee1a20c7758494
|
||||
timeCreated: 1481683313
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
-362
@@ -1,362 +0,0 @@
|
||||
|
||||
float3 interpolation_c2( float3 x ) { return x * x * x * (x * (x * 6.0 - 15.0) + 10.0); }
|
||||
|
||||
float3 mod(float3 x, float3 y)
|
||||
{
|
||||
return x - y * floor(x / y);
|
||||
}
|
||||
|
||||
float4 mod(float4 x, float4 y)
|
||||
{
|
||||
return x - y * floor(x / y);
|
||||
}
|
||||
|
||||
float3 mod289(float3 x)
|
||||
{
|
||||
return x - floor(x / 289.0) * 289.0;
|
||||
}
|
||||
|
||||
float4 mod289(float4 x)
|
||||
{
|
||||
return x - floor(x * (1.0 / 289.0)) * 289.0;
|
||||
}
|
||||
|
||||
float4 permute(float4 x)
|
||||
{
|
||||
return mod289(((x*34.0) + 1.0)*x);
|
||||
}
|
||||
|
||||
float3 fade(float3 t) {
|
||||
return t*t*t*(t*(t*6.0 - 15.0) + 10.0);
|
||||
}
|
||||
|
||||
float4 taylorInvSqrt(float4 r)
|
||||
{
|
||||
return 1.79284291400159 - 0.85373472095314 * r;
|
||||
}
|
||||
|
||||
float2 fade(float2 t) {
|
||||
return t*t*t*(t*(t*6.0 - 15.0) + 10.0);
|
||||
}
|
||||
|
||||
////
|
||||
|
||||
float Falloff_Xsq_C2(float xsq) { xsq = 1.0 - xsq; return xsq*xsq*xsq; } // ( 1.0 - x*x )^3. NOTE: 2nd derivative is 0.0 at x=1.0, but non-zero at x=0.0
|
||||
float4 Falloff_Xsq_C2(float4 xsq) { xsq = 1.0 - xsq; return xsq*xsq*xsq; }
|
||||
float2 Interpolation_C2(float2 x) { return x * x * x * (x * (x * 6.0 - 15.0) + 10.0); }
|
||||
|
||||
|
||||
void FAST32_hash_2D(float2 gridcell, out float4 hash_0, out float4 hash_1) // generates 2 random numbers for each of the 4 cell corners
|
||||
{
|
||||
// gridcell is assumed to be an integer coordinate
|
||||
const float2 OFFSET = float2(26.0, 161.0);
|
||||
const float DOMAIN = 71.0;
|
||||
const float2 SOMELARGEFLOATS = float2(951.135664, 642.949883);
|
||||
float4 P = float4(gridcell.xy, gridcell.xy + 1.0);
|
||||
P = P - floor(P * (1.0 / DOMAIN)) * DOMAIN;
|
||||
P += OFFSET.xyxy;
|
||||
P *= P;
|
||||
P = P.xzxz * P.yyww;
|
||||
hash_0 = frac(P * (1.0 / SOMELARGEFLOATS.x));
|
||||
hash_1 = frac(P * (1.0 / SOMELARGEFLOATS.y));
|
||||
}
|
||||
|
||||
float4 FAST32_hash_2D(float2 gridcell) // generates a random number for each of the 4 cell corners
|
||||
{
|
||||
// gridcell is assumed to be an integer coordinate
|
||||
const float2 OFFSET = float2(26.0, 161.0);
|
||||
const float DOMAIN = 71.0;
|
||||
const float SOMELARGEFLOAT = 951.135664;
|
||||
float4 P = float4(gridcell.xy, gridcell.xy + 1.0);
|
||||
P = P - floor(P * (1.0 / DOMAIN)) * DOMAIN; // truncate the domain
|
||||
P += OFFSET.xyxy; // offset to interesting part of the noise
|
||||
P *= P; // calculate and return the hash
|
||||
return frac(P.xzxz * P.yyww * (1.0 / SOMELARGEFLOAT));
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Perlin Noise 2D ( gradient noise )
|
||||
// Return value range of -1.0->1.0
|
||||
// http://briansharpe.files.wordpress.com/2011/11/perlinsample.jpg
|
||||
//
|
||||
float Perlin2D(float2 P)
|
||||
{
|
||||
// establish our grid cell and unit position
|
||||
float2 Pi = floor(P);
|
||||
float4 Pf_Pfmin1 = P.xyxy - float4(Pi, Pi + 1.0);
|
||||
|
||||
#if CLASSICPERLIN
|
||||
//
|
||||
// classic noise looks much better than improved noise in 2D, and with an efficent hash function runs at about the same speed.
|
||||
// requires 2 random numbers per point.
|
||||
//
|
||||
|
||||
// calculate the hash.
|
||||
// ( various hashing methods listed in order of speed )
|
||||
float4 hash_x, hash_y;
|
||||
FAST32_hash_2D(Pi, hash_x, hash_y);
|
||||
//SGPP_hash_2D( Pi, hash_x, hash_y );
|
||||
|
||||
// calculate the gradient results
|
||||
float4 grad_x = hash_x - 0.49999;
|
||||
float4 grad_y = hash_y - 0.49999;
|
||||
float4 grad_results = rsqrt(grad_x * grad_x + grad_y * grad_y) * (grad_x * Pf_Pfmin1.xzxz + grad_y * Pf_Pfmin1.yyww);
|
||||
|
||||
#if CLASSICPERLIN
|
||||
// Classic Perlin Interpolation
|
||||
grad_results *= 1.4142135623730950488016887242097; // (optionally) scale things to a strict -1.0->1.0 range *= 1.0/sqrt(0.5)
|
||||
float2 blend = Interpolation_C2(Pf_Pfmin1.xy);
|
||||
float4 blend2 = float4(blend, float2(1.0 - blend));
|
||||
return dot(grad_results, blend2.zxzx * blend2.wwyy);
|
||||
#else
|
||||
// Classic Perlin Surflet
|
||||
// http://briansharpe.wordpress.com/2012/03/09/modifications-to-classic-perlin-noise/
|
||||
grad_results *= 2.3703703703703703703703703703704; // (optionally) scale things to a strict -1.0->1.0 range *= 1.0/cube(0.75)
|
||||
float4 vecs_len_sq = Pf_Pfmin1 * Pf_Pfmin1;
|
||||
vecs_len_sq = vecs_len_sq.xzxz + vecs_len_sq.yyww;
|
||||
return dot(Falloff_Xsq_C2(min(float4(1.0), vecs_len_sq)), grad_results);
|
||||
#endif
|
||||
|
||||
#else
|
||||
//
|
||||
// 2D improved perlin noise.
|
||||
// requires 1 random value per point.
|
||||
// does not look as good as classic in 2D due to only a small number of possible cell types. But can run a lot faster than classic perlin noise if the hash function is slow
|
||||
//
|
||||
|
||||
// calculate the hash.
|
||||
// ( various hashing methods listed in order of speed )
|
||||
float4 hash = FAST32_hash_2D(Pi);
|
||||
//vec4 hash = BBS_hash_2D( Pi );
|
||||
//vec4 hash = SGPP_hash_2D( Pi );
|
||||
//vec4 hash = BBS_hash_hq_2D( Pi );
|
||||
|
||||
//
|
||||
// evaulate the gradients
|
||||
// choose between the 4 diagonal gradients. ( slightly slower than choosing the axis gradients, but shows less grid artifacts )
|
||||
// NOTE: diagonals give us a nice strict -1.0->1.0 range without additional scaling
|
||||
// [1.0,1.0] [-1.0,1.0] [1.0,-1.0] [-1.0,-1.0]
|
||||
//
|
||||
hash -= 0.5;
|
||||
float4 grad_results = Pf_Pfmin1.xzxz * sign(hash) + Pf_Pfmin1.yyww * sign(abs(hash) - 0.25);
|
||||
|
||||
// blend the results and return
|
||||
float2 blend = Interpolation_C2(Pf_Pfmin1.xy);
|
||||
float4 blend2 = float4(blend, float2(1.0 - blend));
|
||||
return dot(grad_results, blend2.zxzx * blend2.wwyy);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
// convert a 0.0->1.0 sample to a -1.0->1.0 sample weighted towards the extremes
|
||||
float4 Cellular_weight_samples(float4 samples)
|
||||
{
|
||||
samples = samples * 2.0 - 1.0;
|
||||
//return (1.0 - samples * samples) * sign(samples); // square
|
||||
return (samples * samples * samples) - sign(samples); // cubic (even more variance)
|
||||
}
|
||||
|
||||
float Cellular2D(float2 P)
|
||||
{
|
||||
// establish our grid cell and unit position
|
||||
float2 Pi = floor(P);
|
||||
float2 Pf = P - Pi;
|
||||
|
||||
// calculate the hash.
|
||||
// ( various hashing methods listed in order of speed )
|
||||
float4 hash_x, hash_y;
|
||||
FAST32_hash_2D(Pi, hash_x, hash_y);
|
||||
//SGPP_hash_2D( Pi, hash_x, hash_y );
|
||||
|
||||
// generate the 4 random points
|
||||
#if WORLEY_1
|
||||
// restrict the random point offset to eliminate artifacts
|
||||
// we'll improve the variance of the noise by pushing the points to the extremes of the jitter window
|
||||
const float JITTER_WINDOW = 0.25; // 0.25 will guarentee no artifacts. 0.25 is the intersection on x of graphs f(x)=( (0.5+(0.5-x))^2 + (0.5-x)^2 ) and f(x)=( (0.5+x)^2 + x^2 )
|
||||
hash_x = Cellular_weight_samples(hash_x) * JITTER_WINDOW + float4(0.0, 1.0, 0.0, 1.0);
|
||||
hash_y = Cellular_weight_samples(hash_y) * JITTER_WINDOW + float4(0.0, 0.0, 1.0, 1.0);
|
||||
#else
|
||||
// non-weighted jitter window. jitter window of 0.4 will give results similar to Stefans original implementation
|
||||
// nicer looking, faster, but has minor artifacts. ( discontinuities in signal )
|
||||
const float JITTER_WINDOW = 0.4;
|
||||
hash_x = hash_x * JITTER_WINDOW * 2.0 + float4(-JITTER_WINDOW, 1.0 - JITTER_WINDOW, -JITTER_WINDOW, 1.0 - JITTER_WINDOW);
|
||||
hash_y = hash_y * JITTER_WINDOW * 2.0 + float4(-JITTER_WINDOW, -JITTER_WINDOW, 1.0 - JITTER_WINDOW, 1.0 - JITTER_WINDOW);
|
||||
#endif
|
||||
|
||||
// return the closest squared distance
|
||||
float4 dx = Pf.xxxx - hash_x;
|
||||
float4 dy = Pf.yyyy - hash_y;
|
||||
float4 d = dx * dx + dy * dy;
|
||||
d.xy = min(d.xy, d.zw);
|
||||
return min(d.x, d.y) * (1.0 / 1.125); // scale return value from 0.0->1.125 to 0.0->1.0 ( 0.75^2 * 2.0 == 1.125 )
|
||||
}
|
||||
|
||||
|
||||
|
||||
float CalculateWorley3oct(float2 p, float p1, float p2, float p3) {
|
||||
float2 xy = p * p1;
|
||||
float2 xy2 = p * p2;
|
||||
float2 xy3 = p * p3;
|
||||
|
||||
float worley_value1 = Cellular2D(xy).r;
|
||||
float worley_value2 = Cellular2D(xy2).r;
|
||||
float worley_value3 = Cellular2D(xy3).r;
|
||||
|
||||
worley_value1 = worley_value1;
|
||||
worley_value2 = worley_value2;
|
||||
worley_value3 = worley_value3;
|
||||
|
||||
float worley_value = worley_value1 * 3;
|
||||
worley_value = worley_value + worley_value2 * 1.5;
|
||||
worley_value = worley_value + worley_value3 * 1.5;
|
||||
|
||||
return saturate(1 - worley_value);
|
||||
}
|
||||
|
||||
float CalculateWorley1(float2 p, float p1) {
|
||||
float2 xy = p * p1;
|
||||
float worley_value1 = Cellular2D(xy).r;
|
||||
worley_value1 = worley_value1;
|
||||
return saturate(1 - worley_value1);
|
||||
}
|
||||
|
||||
|
||||
float CalculatePerlin5(float2 p)
|
||||
{
|
||||
|
||||
float2 xy = p;
|
||||
float amplitude_factor = 0.5;
|
||||
float frequency_factor = 2.0;
|
||||
|
||||
float a = 1.0;
|
||||
float perlin_value = 0.0;
|
||||
perlin_value += a * Perlin2D(xy).r; a *= amplitude_factor; xy *= (frequency_factor + 0.12);
|
||||
perlin_value -= a * Perlin2D(xy).r; a *= amplitude_factor; xy *= (frequency_factor + 0.03);
|
||||
perlin_value -= a * Perlin2D(xy).r; a *= amplitude_factor; xy *= (frequency_factor + 0.01);
|
||||
perlin_value -= a * Perlin2D(xy).r; a *= amplitude_factor; xy *= (frequency_factor + 0.01);
|
||||
perlin_value += a * Perlin2D(xy).r;
|
||||
|
||||
return perlin_value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Classic Perlin noise, periodic variant
|
||||
float penoise(float2 P, float2 rep)
|
||||
{
|
||||
float4 Pi = floor(P.xyxy) + float4(0.0, 0.0, 1.0, 1.0);
|
||||
float4 Pf = frac(P.xyxy) - float4(0.0, 0.0, 1.0, 1.0);
|
||||
Pi = mod(Pi, rep.xyxy); // To create noise with explicit period
|
||||
Pi = mod289(Pi); // To avoid truncation effects in permutation
|
||||
float4 ix = Pi.xzxz;
|
||||
float4 iy = Pi.yyww;
|
||||
float4 fx = Pf.xzxz;
|
||||
float4 fy = Pf.yyww;
|
||||
|
||||
float4 i = permute(permute(ix) + iy);
|
||||
|
||||
float4 gx = frac(i * (1.0 / 41.0)) * 2.0 - 1.0;
|
||||
float4 gy = abs(gx) - 0.5;
|
||||
float4 tx = floor(gx + 0.5);
|
||||
gx = gx - tx;
|
||||
|
||||
float2 g00 = float2(gx.x, gy.x);
|
||||
float2 g10 = float2(gx.y, gy.y);
|
||||
float2 g01 = float2(gx.z, gy.z);
|
||||
float2 g11 = float2(gx.w, gy.w);
|
||||
|
||||
float4 norm = taylorInvSqrt(float4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11)));
|
||||
g00 *= norm.x;
|
||||
g01 *= norm.y;
|
||||
g10 *= norm.z;
|
||||
g11 *= norm.w;
|
||||
|
||||
float n00 = dot(g00, float2(fx.x, fy.x));
|
||||
float n10 = dot(g10, float2(fx.y, fy.y));
|
||||
float n01 = dot(g01, float2(fx.z, fy.z));
|
||||
float n11 = dot(g11, float2(fx.w, fy.w));
|
||||
|
||||
float2 fade_xy = fade(Pf.xy);
|
||||
float2 n_x = lerp(float2(n00, n01), float2(n10, n11), fade_xy.x);
|
||||
float n_xy = lerp(n_x.x, n_x.y, fade_xy.y);
|
||||
return 2.3 * n_xy;
|
||||
}
|
||||
|
||||
float CalculatePerlinTileing5(float2 p, float2 rep)
|
||||
{
|
||||
|
||||
float2 xy = p;
|
||||
float amplitude_factor = 0.5;
|
||||
float frequency_factor = 1.0;
|
||||
|
||||
float a = 1.0;
|
||||
float perlin_value = 0.0;
|
||||
perlin_value += a * penoise(xy, rep).r; a *= amplitude_factor; xy *= (frequency_factor + 1);
|
||||
perlin_value -= a * penoise(xy, rep).r; a *= amplitude_factor; xy *= (frequency_factor + 1);
|
||||
perlin_value -= a * penoise(xy, rep).r; a *= amplitude_factor; xy *= (frequency_factor + 1);
|
||||
perlin_value -= a * penoise(xy, rep).r; a *= amplitude_factor; xy *= (frequency_factor + 1);
|
||||
perlin_value += a * penoise(xy, rep).r;
|
||||
|
||||
return perlin_value;
|
||||
}
|
||||
|
||||
float CalculatePerlinTileing5OLD(float2 p, float2 rep)
|
||||
{
|
||||
|
||||
float2 xy = p;
|
||||
float amplitude_factor = 0.5;
|
||||
float frequency_factor = 2.0;
|
||||
|
||||
float a = 1.0;
|
||||
float perlin_value = 0.0;
|
||||
perlin_value += a * penoise(xy, rep).r; a *= amplitude_factor; xy *= (frequency_factor + 0.12);
|
||||
perlin_value -= a * penoise(xy, rep).r; a *= amplitude_factor; xy *= (frequency_factor + 0.03);
|
||||
perlin_value -= a * penoise(xy, rep).r; a *= amplitude_factor; xy *= (frequency_factor + 0.01);
|
||||
perlin_value -= a * penoise(xy, rep).r; a *= amplitude_factor; xy *= (frequency_factor + 0.01);
|
||||
perlin_value += a * penoise(xy, rep).r;
|
||||
|
||||
return perlin_value;
|
||||
}
|
||||
|
||||
|
||||
/* float CalculatePerlinTileing(float2 p, float2 rep)
|
||||
{
|
||||
float perlin_value = 0.0;
|
||||
//float2 period = rep;
|
||||
float2 xy = p;
|
||||
float w = 1.0;
|
||||
float s = 1.0;
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
float2 coord = p * s;
|
||||
float2 period = s * 2.0;
|
||||
|
||||
perlin_value += penoise(coord, period) * w;
|
||||
|
||||
w *= 0.5;
|
||||
s *= 0.25;
|
||||
period *= s;
|
||||
}
|
||||
|
||||
return perlin_value;
|
||||
}
|
||||
*/
|
||||
|
||||
float CalculatePerlinTileing(float2 p, float2 rep)
|
||||
{
|
||||
|
||||
float2 xy = p;
|
||||
float amplitude_factor = 0.5;
|
||||
float frequency_factor = 1.0;
|
||||
|
||||
float a = 1.0;
|
||||
float perlin_value = 0.0;
|
||||
perlin_value += a * penoise(xy, rep).r; a *= amplitude_factor; xy *= (frequency_factor + 1);
|
||||
perlin_value += a * penoise(xy, rep).r; a *= amplitude_factor; xy *= (frequency_factor + 1);
|
||||
perlin_value += a * penoise(xy, rep).r; a *= amplitude_factor; xy *= (frequency_factor + 2);
|
||||
perlin_value -= a * penoise(xy, rep).r;
|
||||
|
||||
return perlin_value;
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7722318409d51394d9a6aea87de37263
|
||||
timeCreated: 1505167667
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
-350
@@ -1,350 +0,0 @@
|
||||
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
|
||||
uniform float4x4 _InverseProjection;
|
||||
uniform float4x4 _InverseRotation;
|
||||
uniform float4x4 _InverseProjection_SP;
|
||||
uniform float4x4 _InverseRotation_SP;
|
||||
uniform sampler2D _MainTex;
|
||||
uniform float4 _MainTex_TexelSize;
|
||||
uniform sampler3D _Noise;
|
||||
uniform sampler3D _DetailNoise;
|
||||
uniform sampler2D _WeatherMap;
|
||||
uniform sampler2D _CurlNoise;
|
||||
uniform float4 _CloudsParameter;
|
||||
uniform float4 _Steps;
|
||||
uniform float4 _CloudsLighting; //x = ExtinctionCoef, y = HgPhaseFactor, z = Silver_intensity, w = Silver_spread
|
||||
uniform float4 _CloudsLightingExtended; // x = EdgeDarkness, y = AmbientSkyColorIntensity, z = _Tonemapping, w = _CloudsExposure
|
||||
uniform float4 _CloudsErosionIntensity; //x = Base, y = Detail
|
||||
uniform float _BaseNoiseUV;
|
||||
uniform float _DetailNoiseUV;
|
||||
uniform float4 _CloudDensityScale;
|
||||
uniform float _LightIntensity;
|
||||
uniform float _AmbientSkyColorIntensity;
|
||||
uniform float4 _CloudsCoverageSettings; //x = _GlobalCoverage, y = Bottom Coverage Mod, z = Top coverage mod, w = Clouds Up Morph Intensity
|
||||
uniform float _GlobalCoverage;
|
||||
uniform float4 _LightColor;
|
||||
uniform float4 _MoonLightColor;
|
||||
uniform float4 _AmbientLightColor;
|
||||
uniform float4 _CloudsAnimation;
|
||||
uniform float3 _LightDir;
|
||||
uniform float _stepsInDepth;
|
||||
uniform float _LODDistance;
|
||||
uniform float _gameTime;
|
||||
uniform float3 _CameraPosition;
|
||||
////
|
||||
uniform float4 _Randomness;
|
||||
////
|
||||
|
||||
const float env_inf = 1e10;
|
||||
|
||||
uint intersectRaySphere(
|
||||
float3 rayOrigin,
|
||||
float3 rayDir, // must be normalized
|
||||
float3 sphereCenter,
|
||||
float sphereRadius,
|
||||
out float2 t)
|
||||
{
|
||||
float3 l = rayOrigin - sphereCenter;
|
||||
float a = 1.0f; // dot(rayDir, rayDir) where rayDir is normalized
|
||||
float b = 2.0f * dot(rayDir, l);
|
||||
float c = dot(l, l) - sphereRadius * sphereRadius;
|
||||
float discriminate = b * b - 4.0f * a * c;
|
||||
if (discriminate < 0.0f)
|
||||
{
|
||||
t.x = t.y = 0.0f;
|
||||
return 0u;
|
||||
}
|
||||
else if (abs(discriminate) - 0.00005f <= 0.0f)
|
||||
{
|
||||
t.x = t.y = -0.5f * b / a;
|
||||
return 1u;
|
||||
}
|
||||
else
|
||||
{
|
||||
float q = b > 0.0f ? -0.5f * (b + sqrt(discriminate)) : -0.5f * (b - sqrt(discriminate));
|
||||
float h1 = q / a;
|
||||
float h2 = c / q;
|
||||
t.x = min(h1, h2);
|
||||
t.y = max(h1, h2);
|
||||
if (t.x < 0.0f)
|
||||
{
|
||||
t.x = t.y;
|
||||
if (t.x < 0.0f)
|
||||
{
|
||||
return 0u;
|
||||
}
|
||||
return 1u;
|
||||
}
|
||||
return 2u;
|
||||
}
|
||||
}
|
||||
|
||||
float rand(float2 co) {
|
||||
float a = 12.9898;
|
||||
float b = 78.233;
|
||||
float c = 43758.5453;
|
||||
float dt = dot(co.xy, float2(a, b));
|
||||
float sn = fmod(dt, 3.14);
|
||||
|
||||
return 2.0 * frac(sin(sn) * c) - 1.0;
|
||||
}
|
||||
|
||||
float2 ResolveInside(float3 cameraPos, float3 cameraDir, float maxDistance)
|
||||
{
|
||||
const float3 up = float3(0, 1, 0);
|
||||
|
||||
maxDistance = min(_CloudsParameter.w, maxDistance);
|
||||
|
||||
float bottom = (_CloudsParameter.x - cameraPos.y);
|
||||
float top = ((_CloudsParameter.x + _CloudsParameter.y) - cameraPos.y);
|
||||
|
||||
float horizon = dot(cameraDir, up);
|
||||
float bottomDist = max(0, bottom / horizon);
|
||||
float topDist = max(0, top / horizon);
|
||||
|
||||
float startDist = min(bottomDist, topDist);
|
||||
float endDist = max(bottomDist, topDist);
|
||||
|
||||
startDist = min(maxDistance, startDist);
|
||||
endDist = min(maxDistance, endDist);
|
||||
|
||||
return float2(startDist, endDist);
|
||||
}
|
||||
|
||||
// Realtime Volumetric Rendering Course Notes by Patapom (page 15)
|
||||
float exponential_integral(float z) {
|
||||
return 0.5772156649015328606065 + log(1e-4 + abs(z)) + z * (1.0 + z * (0.25 + z * ((1.0 / 18.0) + z * ((1.0 / 96.0) + z * (1.0 / 600.0))))); // For x!=0
|
||||
}
|
||||
|
||||
// Realtime Volumetric Rendering Course Notes by Patapom (page 15)
|
||||
float3 CalculateAmbientLighting(float altitude, float extinction_coeff, float3 skyColor)
|
||||
{
|
||||
float ambient_term = 0.6 * saturate(1.0 - altitude);
|
||||
float3 isotropic_scattering_top = (skyColor.rgb * 0.25) * max(0.0, exp(ambient_term) - ambient_term * exponential_integral(ambient_term));
|
||||
|
||||
ambient_term = -extinction_coeff * altitude;
|
||||
float3 isotropic_scattering_bottom = skyColor.rgb * 1.0 * max(0.0, exp(ambient_term) - ambient_term * exponential_integral(ambient_term)) * 1.5;
|
||||
|
||||
isotropic_scattering_top *= saturate(altitude);
|
||||
|
||||
return (isotropic_scattering_top)+(isotropic_scattering_bottom);
|
||||
}
|
||||
|
||||
float HenryGreenstein(float cosTheta, float g) {
|
||||
|
||||
float k = 3.0 / (8.0 * 3.1415926f) * (1.0 - g * g) / (2.0 + g * g);
|
||||
return k * (1.0 + cosTheta * cosTheta) / pow(abs(1.0 + g * g - 2.0 * g * cosTheta), 1.5);
|
||||
}
|
||||
|
||||
float Remap(float org_val, float org_min, float org_max, float new_min, float new_max)
|
||||
{
|
||||
return new_min + saturate(((org_val - org_min) / (org_max - org_min))*(new_max - new_min));
|
||||
}
|
||||
|
||||
float4 GetHeightGradient(float cloudType)
|
||||
{
|
||||
const float4 CloudGradient1 = float4(0.0, 0.05, 0.1, 0.25);
|
||||
const float4 CloudGradient2 = float4(0.0, 0.05, 0.4, 0.8);
|
||||
const float4 CloudGradient3 = float4(0.0, 0.05, 0.6, 1.0);
|
||||
|
||||
float a = 1.0 - saturate(cloudType * 2.0);
|
||||
float b = 1.0 - abs(cloudType - 0.5) * 2.0;
|
||||
float c = saturate(cloudType - 0.5) * 2.0;
|
||||
|
||||
return CloudGradient1 * a + CloudGradient2 * b + CloudGradient3 * c;
|
||||
}
|
||||
|
||||
float GradientStep(float a, float4 gradient)
|
||||
{
|
||||
return smoothstep(gradient.x, gradient.y, a) - smoothstep(gradient.z, gradient.w, a);
|
||||
}
|
||||
|
||||
float3 GetWeather(float3 pos)
|
||||
{
|
||||
float2 uv = pos.xz * 0.00001 + 0.5;
|
||||
return tex2Dlod(_WeatherMap, float4(uv, 0.0, 0.0));
|
||||
}
|
||||
|
||||
float GetSamplingHeight(float3 pos, float3 center)
|
||||
{
|
||||
return (length(pos - center) - (_CloudsParameter.w + _CloudsParameter.x)) * _CloudsParameter.z;
|
||||
}
|
||||
|
||||
float3 ScreenSpaceDither(float2 vScreenPos, float lum)
|
||||
{
|
||||
float d = dot(float2(131.0, 312.0), vScreenPos.xy + _Time.y);
|
||||
float3 vDither = float3(d, d, d);
|
||||
vDither.rgb = frac(vDither.rgb / float3(103.0, 71.0, 97.0)) - float3(0.5, 0.5, 0.5);
|
||||
return (vDither.rgb / 15.0) * 1.0 * lum;
|
||||
}
|
||||
|
||||
float GetRaymarchEnd(float sceneDepth, float3 dir)
|
||||
{
|
||||
float raymarchEnd = 0.0f;
|
||||
#if ENVIRO_DEPTHBLENDING
|
||||
if (sceneDepth == 1.0f)
|
||||
{
|
||||
raymarchEnd = 1e7;
|
||||
}
|
||||
else
|
||||
{
|
||||
raymarchEnd = length(dir);
|
||||
// raymarchEnd -= _ProjectionParams.y;
|
||||
}
|
||||
#else
|
||||
raymarchEnd = 1e8;
|
||||
#endif
|
||||
return raymarchEnd;
|
||||
}
|
||||
|
||||
float set_range_clamped(float value, float low, float high) {
|
||||
float ranged_value = clamp(value, low, high);
|
||||
ranged_value = (ranged_value - low) / (high - low);
|
||||
return saturate(ranged_value);
|
||||
}
|
||||
|
||||
float get_fade_term(float3 sample_pos) {
|
||||
float distance = length(sample_pos.xy);
|
||||
return saturate((distance - 5000) / 20000.0);
|
||||
}
|
||||
|
||||
float get_altitude_scalar(float cloud_type) {
|
||||
return lerp(8.0, 2.0, cloud_type);
|
||||
}
|
||||
|
||||
float HeightAlter(float percent_height, float weather) {
|
||||
float cloud_anvil_amount = 0.5;
|
||||
float global_coverage = 0.5;
|
||||
// Round bottom a bit
|
||||
float ret_val = saturate(Remap(percent_height, 0.0, 0.07, 0.0, 1.0));
|
||||
// Round top a lot
|
||||
float stop_height = saturate(weather + 0.12);
|
||||
ret_val *= saturate(Remap(percent_height, stop_height * 0.2, stop_height, 1.0, 0.0));
|
||||
// Apply anvil ( cumulonimbus /" giant storm" clouds)
|
||||
ret_val = pow(ret_val, saturate(Remap(percent_height, 0.65, 0.95, 1.0, (1 - cloud_anvil_amount * global_coverage))));
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
float DensityAlter(float percent_height) {
|
||||
float cloud_anvil_amount = 1.0;
|
||||
// Have density be generally increasing over height
|
||||
float ret_val = percent_height;
|
||||
// Reduce density at base
|
||||
ret_val *= saturate(Remap(percent_height, 0.0, 0.2, 0.0, 1.0));
|
||||
ret_val *= 2;
|
||||
// Reduce density for the anvil ( cumulonimbus clouds)
|
||||
ret_val *= lerp(1, saturate(Remap(pow(percent_height, 0.5) , 0.4, 0.95, 1.0, 0.2)), cloud_anvil_amount);
|
||||
// Reduce density at top to make better transition
|
||||
ret_val *= saturate(Remap(percent_height, 0.9, 1.0, 1.0, 0.0));
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
// Sample Cloud Density
|
||||
float CalculateCloudDensity(float3 pos, float3 PlanetCenter, float3 weather, float mip, float dist, bool details)
|
||||
{
|
||||
const float baseFreq = 1e-5;
|
||||
|
||||
// Get Height fraction
|
||||
float height = GetSamplingHeight(pos, PlanetCenter);
|
||||
|
||||
// wind settings
|
||||
float cloud_top_offset = 20.0;
|
||||
float3 wind_direction = float3(_CloudsAnimation.z, 0.0, _CloudsAnimation.w);
|
||||
|
||||
// skew in wind direction
|
||||
pos += height * wind_direction * cloud_top_offset;
|
||||
|
||||
float mip1 = mip + (1-dist) * (3.5 * _LODDistance);
|
||||
|
||||
float4 coord = float4(pos * baseFreq * _BaseNoiseUV, mip1);
|
||||
// Animate Wind
|
||||
coord.xyz += float3(_CloudsAnimation.x, _CloudsErosionIntensity.w, _CloudsAnimation.y);
|
||||
|
||||
float4 baseNoise = 0;
|
||||
|
||||
baseNoise = tex3Dlod(_Noise, coord);
|
||||
|
||||
float low_freq_fBm = (baseNoise.g * 0.625) + (baseNoise.b * 0.25) + (baseNoise.a * 0.125);
|
||||
float base_cloud = Remap(baseNoise.r, -(1.0 - low_freq_fBm) * _CloudsErosionIntensity.x, 1.0, 0.0, 1.0);
|
||||
|
||||
float heightGradient = GradientStep(height, GetHeightGradient(weather.b));
|
||||
|
||||
base_cloud *= heightGradient;
|
||||
|
||||
float cloud_coverage = saturate(1 - weather.r);
|
||||
|
||||
float densAlter = DensityAlter(1-height);
|
||||
cloud_coverage = pow(cloud_coverage, densAlter);
|
||||
|
||||
//cloud_coverage = pow(cloud_coverage, Remap(height, 0.7, 0.8, 1.0, lerp(1.0, 0.5, 1.0)));
|
||||
|
||||
float cloudDensity = Remap(base_cloud, cloud_coverage, 1.0, 0.0, 1.0);
|
||||
|
||||
cloudDensity *= saturate(1-cloud_coverage);
|
||||
|
||||
//DETAIL
|
||||
[branch]
|
||||
if (details)
|
||||
{
|
||||
float mip2 = mip + (1-dist) * (_LODDistance);
|
||||
coord = float4(pos * baseFreq * _DetailNoiseUV, mip2);
|
||||
#ifdef ENVIRO_CURLNOISE
|
||||
float2 curl_noise = tex2Dlod(_CurlNoise, float4 (coord.xy * 1.25, 0.0, 1.0)).rg;
|
||||
coord.xy += curl_noise.rg * (1 - height);
|
||||
#endif
|
||||
coord.xyz += float3(_CloudsAnimation.x, _CloudsErosionIntensity.w, _CloudsAnimation.y);
|
||||
float3 detailNoise = tex3Dlod(_DetailNoise, coord).rgb;
|
||||
float high_freq_fBm = (detailNoise.r * 0.625) + (detailNoise.g * 0.25) + (detailNoise.b * 0.125);
|
||||
float high_freq_noise_modifier = lerp(high_freq_fBm, 1.0f - high_freq_fBm, saturate((height) * 20));
|
||||
cloudDensity = Remap(cloudDensity, high_freq_noise_modifier * _CloudsErosionIntensity.y, 1.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
return cloudDensity;
|
||||
}
|
||||
|
||||
|
||||
// Lighting Energy Function
|
||||
float GetLightEnergy(float3 p, float height_fraction, float dl, float ds_loded, float phase_probability, float cos_angle, float step_size, float brightness, float3 weather)
|
||||
{
|
||||
brightness *= 300 * weather.g;
|
||||
float sc = lerp(dl * 0.25, _CloudsCoverageSettings.y, 0.75);
|
||||
float s1 = lerp(_CloudsErosionIntensity.z * 0.75, _CloudsErosionIntensity.z, cos_angle);
|
||||
float prim_att = exp(-s1 * dl);
|
||||
float sec_att = exp(-s1 * sc) * 0.7;
|
||||
float attenuation_probability = max(Remap(cos_angle, 0.5, 1.0, sec_att, sec_att * 0.25), prim_att) ;
|
||||
float vertical_probability = pow(Remap(height_fraction, 0.07, 0.3, 0.1, 1.0), 0.8);
|
||||
float depth = _CloudsLightingExtended.x * pow(lerp(0.25, ds_loded * 1.5, Remap(height_fraction,0.0,1.0,0.5,1.0)), Remap(height_fraction, 0.1, 1.0, 0.5, 0.75));
|
||||
float in_scatter = depth;
|
||||
in_scatter = 0.05 + saturate(in_scatter);
|
||||
in_scatter = saturate(lerp(in_scatter, 0.45, cos_angle - 0.1));
|
||||
|
||||
float light_energy = attenuation_probability * in_scatter * vertical_probability * phase_probability * brightness;
|
||||
return light_energy;
|
||||
}
|
||||
|
||||
|
||||
static const float shadowSampleDistance[6] = {0.0, 0.5, 1.0, 1.5, 2.0, 6.0};
|
||||
static const float LightingInfluence[6] = { { 1.0f },{ 2.0f },{ 3.0f },{ 4.0f },{ 6.0f },{ 8.0f } };
|
||||
|
||||
// Lighting Sample Function
|
||||
float GetDensityAlongRay(float3 pos, float3 PlanetCenter, float3 LightDirection, float3 weather, float dist)
|
||||
{
|
||||
float opticalDepth = 0.0;
|
||||
|
||||
[loop]
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
|
||||
float3 samplePoint = pos + LightDirection * shadowSampleDistance[i] * (512 * _CloudDensityScale.y);
|
||||
|
||||
float mip_offset = i * 0.5;
|
||||
|
||||
//if (opticalDepth < 0.3)
|
||||
opticalDepth += CalculateCloudDensity(samplePoint, PlanetCenter, weather, mip_offset, dist, true) * LightingInfluence[i];
|
||||
//else
|
||||
// opticalDepth += CalculateCloudDensity(samplePoint, PlanetCenter, weather, mip_offset, dist, false) * LightingInfluence[i];
|
||||
|
||||
}
|
||||
|
||||
return opticalDepth;
|
||||
}
|
||||
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 862b7616dff96e04b9925de1aed57e51
|
||||
timeCreated: 1505167667
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
-342
@@ -1,342 +0,0 @@
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityDeferredLibrary.cginc"
|
||||
|
||||
half4 _MainTex_ST;
|
||||
half4 _CameraDepthTexture_ST;
|
||||
sampler3D _NoiseTexture;
|
||||
sampler2D _DitherTexture;
|
||||
|
||||
float4x4 _WorldViewProj;
|
||||
float4x4 _WorldViewProj_SP;
|
||||
float4x4 _MyLightMatrix0;
|
||||
float4x4 _MyWorld2Shadow;
|
||||
|
||||
float4x4 _LeftWorldFromView;
|
||||
float4x4 _RightWorldFromView;
|
||||
float4x4 _LeftViewFromScreen;
|
||||
float4x4 _RightViewFromScreen;
|
||||
|
||||
float3 _CameraForward;
|
||||
// x: scattering coef, y: extinction coef, z: range w: skybox extinction coef
|
||||
float4 _VolumetricLight;
|
||||
// x: 1 - g^2, y: 1 + g^2, z: 2*g, w: 1/4pi
|
||||
float4 _MieG;
|
||||
float _MaxRayLength;
|
||||
int _SampleCount;
|
||||
// x: scale, y: intensity, z: intensity offset
|
||||
float4 _NoiseData;
|
||||
// x: x velocity, y: z velocity
|
||||
float4 _NoiseVelocity;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
inline fixed4 GetCascadeWeights_SplitSpheres(float3 wpos)
|
||||
{
|
||||
float3 fromCenter0 = wpos.xyz - unity_ShadowSplitSpheres[0].xyz;
|
||||
float3 fromCenter1 = wpos.xyz - unity_ShadowSplitSpheres[1].xyz;
|
||||
float3 fromCenter2 = wpos.xyz - unity_ShadowSplitSpheres[2].xyz;
|
||||
float3 fromCenter3 = wpos.xyz - unity_ShadowSplitSpheres[3].xyz;
|
||||
float4 distances2 = float4(dot(fromCenter0, fromCenter0), dot(fromCenter1, fromCenter1), dot(fromCenter2, fromCenter2), dot(fromCenter3, fromCenter3));
|
||||
|
||||
fixed4 weights = float4(distances2 < unity_ShadowSplitSqRadii);
|
||||
weights.yzw = saturate(weights.yzw - weights.xyz);
|
||||
return weights;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
inline float4 GetCascadeShadowCoord(float4 wpos, fixed4 cascadeWeights)
|
||||
{
|
||||
float3 sc0 = mul(unity_WorldToShadow[0], wpos).xyz;
|
||||
float3 sc1 = mul(unity_WorldToShadow[1], wpos).xyz;
|
||||
float3 sc2 = mul(unity_WorldToShadow[2], wpos).xyz;
|
||||
float3 sc3 = mul(unity_WorldToShadow[3], wpos).xyz;
|
||||
|
||||
float4 shadowMapCoordinate = float4(sc0 * cascadeWeights[0] + sc1 * cascadeWeights[1] + sc2 * cascadeWeights[2] + sc3 * cascadeWeights[3], 1);
|
||||
#if defined(UNITY_REVERSED_Z)
|
||||
float noCascadeWeights = 1 - dot(cascadeWeights, float4(1, 1, 1, 1));
|
||||
shadowMapCoordinate.z += noCascadeWeights;
|
||||
#endif
|
||||
return shadowMapCoordinate;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
UNITY_DECLARE_SHADOWMAP(_CascadeShadowMapTexture);
|
||||
|
||||
float GetLightAttenuation(float3 wpos)
|
||||
{
|
||||
float atten = 0;
|
||||
#if defined (DIRECTIONAL) || defined (DIRECTIONAL_COOKIE)
|
||||
atten = 1;
|
||||
#if defined (SHADOWS_DEPTH)
|
||||
// sample cascade shadow map
|
||||
float4 cascadeWeights = GetCascadeWeights_SplitSpheres(wpos);
|
||||
bool inside = dot(cascadeWeights, float4(1, 1, 1, 1)) < 4;
|
||||
float4 samplePos = GetCascadeShadowCoord(float4(wpos, 1), cascadeWeights);
|
||||
|
||||
atten = inside ? UNITY_SAMPLE_SHADOW(_CascadeShadowMapTexture, samplePos.xyz) : 1.0f;
|
||||
atten = _LightShadowData.r + atten * (1 - _LightShadowData.r);
|
||||
#endif
|
||||
|
||||
#elif defined (SPOT)
|
||||
float3 tolight = _LightPos.xyz - wpos;
|
||||
half3 lightDir = normalize(tolight);
|
||||
|
||||
float4 uvCookie = mul(_MyLightMatrix0, float4(wpos, 1));
|
||||
// negative bias because http://aras-p.info/blog/2010/01/07/screenspace-vs-mip-mapping/
|
||||
atten = tex2Dbias(_LightTexture0, float4(uvCookie.xy / uvCookie.w, 0, -8)).w;
|
||||
atten *= uvCookie.w < 0;
|
||||
float att = dot(tolight, tolight) * _LightPos.w;
|
||||
atten *= tex2D(_LightTextureB0, att.rr).UNITY_ATTEN_CHANNEL;
|
||||
|
||||
#if defined(SHADOWS_DEPTH)
|
||||
float4 shadowCoord = mul(_MyWorld2Shadow, float4(wpos, 1));
|
||||
atten *= saturate(UnitySampleShadowmap(shadowCoord));
|
||||
#endif
|
||||
#elif defined (POINT) || defined (POINT_COOKIE)
|
||||
float3 tolight = wpos - _LightPos.xyz;
|
||||
half3 lightDir = -normalize(tolight);
|
||||
|
||||
float att = dot(tolight, tolight) * _LightPos.w;
|
||||
atten = tex2D(_LightTextureB0, att.rr).UNITY_ATTEN_CHANNEL;
|
||||
|
||||
atten *= UnityDeferredComputeShadow(tolight, 0, float2(0, 0));
|
||||
|
||||
#if defined (POINT_COOKIE)
|
||||
atten *= texCUBEbias(_LightTexture0, float4(mul(_MyLightMatrix0, half4(wpos, 1)).xyz, -8)).w;
|
||||
#endif //POINT_COOKIE
|
||||
#endif
|
||||
return atten;
|
||||
}
|
||||
|
||||
|
||||
float GetLightAttenuationDir(float3 wpos)
|
||||
{
|
||||
float atten = 1;
|
||||
|
||||
// sample cascade shadow map
|
||||
float4 cascadeWeights = GetCascadeWeights_SplitSpheres(wpos);
|
||||
bool inside = dot(cascadeWeights, float4(1, 1, 1, 1)) < 4;
|
||||
float4 samplePos = GetCascadeShadowCoord(float4(wpos, 1), cascadeWeights);
|
||||
|
||||
atten = inside ? UNITY_SAMPLE_SHADOW(_CascadeShadowMapTexture, samplePos.xyz) : 1.0f;
|
||||
atten = _LightShadowData.r + atten * (1 - _LightShadowData.r);
|
||||
return atten;
|
||||
}
|
||||
|
||||
void ApplyHeightFog(float3 wpos, inout float density)
|
||||
{
|
||||
//#ifdef HEIGHT_FOG
|
||||
density *= exp(-(wpos.y + 1) * 0.1);
|
||||
//#endif
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
float GetDensityFog(float3 wpos)
|
||||
{
|
||||
float density = 1;
|
||||
#ifdef NOISE
|
||||
float noise = tex3D(_NoiseTexture, frac(wpos * _NoiseData.x + float3(_Time.y * _NoiseVelocity.x, 0, _Time.y * _NoiseVelocity.y)));
|
||||
noise = saturate(noise - _NoiseData.z) * _NoiseData.y;
|
||||
density *= saturate(noise);
|
||||
#endif
|
||||
ApplyHeightFog(wpos, density);
|
||||
|
||||
return density;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
float MieScattering(float cosAngle, float4 g)
|
||||
{
|
||||
return g.w * (g.x / (pow(g.y - g.z * cosAngle, 1.5)));
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
float4 RayMarch(float2 screenPos, float3 rayStart, float3 rayDir, float rayLength)
|
||||
{
|
||||
#ifdef DITHER_4_4
|
||||
float2 interleavedPos = (fmod(floor(screenPos.xy), 4.0));
|
||||
#if UNITY_SINGLE_PASS_STEREO
|
||||
float4 scaleOffset = unity_StereoScaleOffset[unity_StereoEyeIndex];
|
||||
interleavedPos = (interleavedPos - scaleOffset.zw) / scaleOffset.xy;
|
||||
#endif
|
||||
float offset = tex2D(_DitherTexture, interleavedPos / 4.0 + float2(0.5 / 4.0, 0.5 / 4.0)).w;
|
||||
#else
|
||||
float2 interleavedPos = (fmod(floor(screenPos.xy), 8.0));
|
||||
#if UNITY_SINGLE_PASS_STEREO
|
||||
float4 scaleOffset = unity_StereoScaleOffset[unity_StereoEyeIndex];
|
||||
interleavedPos = (interleavedPos - scaleOffset.zw) / scaleOffset.xy;
|
||||
#endif
|
||||
float offset = tex2D(_DitherTexture, interleavedPos / 8.0 + float2(0.5 / 8.0, 0.5 / 8.0)).w;
|
||||
#endif
|
||||
|
||||
int stepCount = _SampleCount;
|
||||
|
||||
float stepSize = rayLength / stepCount;
|
||||
float3 step = rayDir * stepSize;
|
||||
|
||||
float3 currentPosition = rayStart + step * offset;
|
||||
|
||||
float4 vlight = 0;
|
||||
|
||||
float cosAngle;
|
||||
#if defined (DIRECTIONAL) || defined (DIRECTIONAL_COOKIE)
|
||||
float extinction = 0;
|
||||
cosAngle = dot(_LightDir.xyz, -rayDir);
|
||||
#else
|
||||
// we don't know about density between camera and light's volume, assume 0.5
|
||||
float extinction = length(_WorldSpaceCameraPos - currentPosition) * _VolumetricLight.y * 0.5;
|
||||
#endif
|
||||
|
||||
[loop]
|
||||
for (int i = 0; i < stepCount; ++i)
|
||||
{
|
||||
float density = 0;
|
||||
float atten = GetLightAttenuation(currentPosition);
|
||||
|
||||
density = GetDensityFog(currentPosition);
|
||||
|
||||
float scattering = _VolumetricLight.x * stepSize * density;
|
||||
extinction += _VolumetricLight.y * stepSize * density;// +scattering;
|
||||
|
||||
float4 light = atten * scattering * exp(-extinction);
|
||||
|
||||
#if !defined (DIRECTIONAL) && !defined (DIRECTIONAL_COOKIE)
|
||||
// phase functino for spot and point lights
|
||||
float3 tolight = normalize(currentPosition - _LightPos.xyz);
|
||||
cosAngle = dot(tolight, -rayDir);
|
||||
light *= MieScattering(cosAngle, _MieG);
|
||||
#endif
|
||||
vlight += light;
|
||||
currentPosition += step;
|
||||
}
|
||||
|
||||
#if defined (DIRECTIONAL) || defined (DIRECTIONAL_COOKIE)
|
||||
// apply phase function for dir light
|
||||
vlight *= MieScattering(cosAngle, _MieG);
|
||||
#endif
|
||||
|
||||
// apply light's color
|
||||
vlight *= _LightColor;
|
||||
|
||||
vlight = max(0, vlight);
|
||||
|
||||
#if defined (DIRECTIONAL) || defined (DIRECTIONAL_COOKIE) // use "proper" out-scattering/absorption for dir light
|
||||
vlight.w = exp(-extinction);
|
||||
#else
|
||||
vlight.w = 0;
|
||||
#endif
|
||||
return vlight;
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/* float4 RayMarchDir(float2 screenPos, float3 rayStart, float3 rayDir, float rayLength)
|
||||
{
|
||||
#ifdef DITHER_4_4
|
||||
float2 interleavedPos = (fmod(floor(screenPos.xy), 4.0));
|
||||
#if UNITY_SINGLE_PASS_STEREO
|
||||
float4 scaleOffset = unity_StereoScaleOffset[unity_StereoEyeIndex];
|
||||
interleavedPos = (interleavedPos - scaleOffset.zw) / scaleOffset.xy;
|
||||
#endif
|
||||
float offset = tex2D(_DitherTexture, interleavedPos / 4.0 + float2(0.5 / 4.0, 0.5 / 4.0)).w;
|
||||
#else
|
||||
float2 interleavedPos = (fmod(floor(screenPos.xy), 8.0));
|
||||
#if UNITY_SINGLE_PASS_STEREO
|
||||
float4 scaleOffset = unity_StereoScaleOffset[unity_StereoEyeIndex];
|
||||
interleavedPos = (interleavedPos - scaleOffset.zw) / scaleOffset.xy;
|
||||
#endif
|
||||
float offset = tex2D(_DitherTexture, interleavedPos / 8.0 + float2(0.5 / 8.0, 0.5 / 8.0)).w;
|
||||
#endif
|
||||
|
||||
int stepCount = _SampleCount;
|
||||
|
||||
float stepSize = rayLength / stepCount;
|
||||
float3 step = rayDir * stepSize;
|
||||
|
||||
float3 currentPosition = rayStart + step * offset;
|
||||
|
||||
float4 vlight = 0;
|
||||
|
||||
float cosAngle;
|
||||
float extinction = 0;
|
||||
cosAngle = dot(_LightDir.xyz, -rayDir);
|
||||
|
||||
[loop]
|
||||
for (int i = 0; i < stepCount; ++i)
|
||||
{
|
||||
float atten = GetLightAttenuationDir(currentPosition);
|
||||
float density = GetDensityFog(currentPosition);
|
||||
|
||||
float scattering = _VolumetricLight.x * stepSize * density;
|
||||
extinction += _VolumetricLight.y * stepSize * density;// +scattering;
|
||||
|
||||
float4 light = atten * scattering * exp(-extinction);
|
||||
vlight += light;
|
||||
currentPosition += step;
|
||||
}
|
||||
|
||||
vlight *= MieScattering(cosAngle, _MieG);
|
||||
|
||||
// apply light's color
|
||||
vlight *= _LightColor;
|
||||
vlight = max(0, vlight);
|
||||
vlight.w = exp(-extinction);
|
||||
return vlight;
|
||||
}
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
float2 RayConeIntersect(in float3 f3ConeApex, in float3 f3ConeAxis, in float fCosAngle, in float3 f3RayStart, in float3 f3RayDir)
|
||||
{
|
||||
float inf = 10000;
|
||||
f3RayStart -= f3ConeApex;
|
||||
float a = dot(f3RayDir, f3ConeAxis);
|
||||
float b = dot(f3RayDir, f3RayDir);
|
||||
float c = dot(f3RayStart, f3ConeAxis);
|
||||
float d = dot(f3RayStart, f3RayDir);
|
||||
float e = dot(f3RayStart, f3RayStart);
|
||||
fCosAngle *= fCosAngle;
|
||||
float A = a*a - b*fCosAngle;
|
||||
float B = 2 * (c*a - d*fCosAngle);
|
||||
float C = c*c - e*fCosAngle;
|
||||
float D = B*B - 4 * A*C;
|
||||
|
||||
if (D > 0)
|
||||
{
|
||||
D = sqrt(D);
|
||||
float2 t = (-B + sign(A)*float2(-D, +D)) / (2 * A);
|
||||
bool2 b2IsCorrect = c + a * t > 0 && t > 0;
|
||||
t = t * b2IsCorrect + !b2IsCorrect * (inf);
|
||||
return t;
|
||||
}
|
||||
else // no intersection
|
||||
return inf;
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
float RayPlaneIntersect(in float3 planeNormal, in float planeD, in float3 rayOrigin, in float3 rayDir)
|
||||
{
|
||||
float NdotD = dot(planeNormal, rayDir);
|
||||
float NdotO = dot(planeNormal, rayOrigin);
|
||||
|
||||
float t = -(NdotO + planeD) / NdotD;
|
||||
if (t < 0)
|
||||
t = 100000;
|
||||
return t;
|
||||
}
|
||||
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 99c079f58f92c804197ee5a23e05164a
|
||||
timeCreated: 1505167667
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
-565
@@ -1,565 +0,0 @@
|
||||
// Upgrade NOTE: replaced 'defined UNITY2017_2_SP' with 'defined (UNITY2017_2_SP)'
|
||||
|
||||
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
|
||||
|
||||
// Copyright(c) 2016, Michal Skalsky
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software without
|
||||
// specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
// OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
// TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
|
||||
Shader "Hidden/EnviroBilateralBlur"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex("Texture", any) = "" {}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
// No culling or depth
|
||||
Cull Off ZWrite Off ZTest Always
|
||||
|
||||
CGINCLUDE
|
||||
|
||||
#pragma shader_feature UNITY2017_2_SP
|
||||
//--------------------------------------------------------------------------------------------
|
||||
// Downsample, bilateral blur and upsample config
|
||||
//--------------------------------------------------------------------------------------------
|
||||
// method used to downsample depth buffer: 0 = min; 1 = max; 2 = min/max in chessboard pattern
|
||||
#define DOWNSAMPLE_DEPTH_MODE 2
|
||||
#define UPSAMPLE_DEPTH_THRESHOLD 1.5f
|
||||
#define BLUR_DEPTH_FACTOR 0.5
|
||||
#define GAUSS_BLUR_DEVIATION 1.5
|
||||
#define FULL_RES_BLUR_KERNEL_SIZE 7
|
||||
#define HALF_RES_BLUR_KERNEL_SIZE 5
|
||||
#define QUARTER_RES_BLUR_KERNEL_SIZE 6
|
||||
//--------------------------------------------------------------------------------------------
|
||||
|
||||
#define PI 3.1415927f
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
UNITY_DECLARE_TEX2D(_CameraDepthTexture);
|
||||
UNITY_DECLARE_TEX2D(_HalfResDepthBuffer);
|
||||
UNITY_DECLARE_TEX2D(_QuarterResDepthBuffer);
|
||||
UNITY_DECLARE_TEX2D(_HalfResColor);
|
||||
UNITY_DECLARE_TEX2D(_QuarterResColor);
|
||||
UNITY_DECLARE_TEX2D(_MainTex);
|
||||
|
||||
float4 _CameraDepthTexture_TexelSize;
|
||||
float4 _HalfResDepthBuffer_TexelSize;
|
||||
float4 _QuarterResDepthBuffer_TexelSize;
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
struct v2fDownsample
|
||||
{
|
||||
#if SHADER_TARGET > 40
|
||||
float2 uv : TEXCOORD0;
|
||||
#else
|
||||
float2 uv00 : TEXCOORD0;
|
||||
float2 uv01 : TEXCOORD1;
|
||||
float2 uv10 : TEXCOORD2;
|
||||
float2 uv11 : TEXCOORD3;
|
||||
#endif
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
struct v2fUpsample
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float2 uv00 : TEXCOORD1;
|
||||
float2 uv01 : TEXCOORD2;
|
||||
float2 uv10 : TEXCOORD3;
|
||||
float2 uv11 : TEXCOORD4;
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.uv;
|
||||
return o;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
// vertDownsampleDepth
|
||||
//-----------------------------------------------------------------------------------------
|
||||
v2fDownsample vertDownsampleDepth(appdata v, float2 texelSize)
|
||||
{
|
||||
v2fDownsample o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
#if SHADER_TARGET > 40
|
||||
o.uv = v.uv;
|
||||
#else
|
||||
o.uv00 = v.uv - 0.5 * texelSize.xy;
|
||||
o.uv10 = o.uv00 + float2(texelSize.x, 0);
|
||||
o.uv01 = o.uv00 + float2(0, texelSize.y);
|
||||
o.uv11 = o.uv00 + texelSize.xy;
|
||||
#endif
|
||||
return o;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
// vertUpsample
|
||||
//-----------------------------------------------------------------------------------------
|
||||
v2fUpsample vertUpsample(appdata v, float2 texelSize)
|
||||
{
|
||||
v2fUpsample o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.uv;
|
||||
|
||||
o.uv00 = v.uv - 0.5 * texelSize.xy;
|
||||
o.uv10 = o.uv00 + float2(texelSize.x, 0);
|
||||
o.uv01 = o.uv00 + float2(0, texelSize.y);
|
||||
o.uv11 = o.uv00 + texelSize.xy;
|
||||
return o;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
// BilateralUpsample
|
||||
//-----------------------------------------------------------------------------------------
|
||||
float4 BilateralUpsample(v2fUpsample input, Texture2D hiDepth, Texture2D loDepth, Texture2D loColor, SamplerState linearSampler, SamplerState pointSampler)
|
||||
{
|
||||
const float threshold = UPSAMPLE_DEPTH_THRESHOLD;
|
||||
float4 highResDepth = LinearEyeDepth(hiDepth.Sample(pointSampler, input.uv)).xxxx;
|
||||
float4 lowResDepth;
|
||||
|
||||
lowResDepth[0] = LinearEyeDepth(loDepth.Sample(pointSampler, input.uv00));
|
||||
lowResDepth[1] = LinearEyeDepth(loDepth.Sample(pointSampler, input.uv10));
|
||||
lowResDepth[2] = LinearEyeDepth(loDepth.Sample(pointSampler, input.uv01));
|
||||
lowResDepth[3] = LinearEyeDepth(loDepth.Sample(pointSampler, input.uv11));
|
||||
|
||||
float4 depthDiff = abs(lowResDepth - highResDepth);
|
||||
|
||||
float accumDiff = dot(depthDiff, float4(1, 1, 1, 1));
|
||||
|
||||
[branch]
|
||||
if (accumDiff < threshold) // small error, not an edge -> use bilinear filter
|
||||
{
|
||||
#if defined (UNITY2017_2_SP)
|
||||
return loColor.Sample(linearSampler, UnityStereoTransformScreenSpaceTex(input.uv));
|
||||
#else
|
||||
return loColor.Sample(linearSampler, input.uv);
|
||||
#endif
|
||||
}
|
||||
|
||||
// find nearest sample
|
||||
float minDepthDiff = depthDiff[0];
|
||||
float2 nearestUv = input.uv00;
|
||||
|
||||
if (depthDiff[1] < minDepthDiff)
|
||||
{
|
||||
nearestUv = input.uv10;
|
||||
minDepthDiff = depthDiff[1];
|
||||
}
|
||||
|
||||
if (depthDiff[2] < minDepthDiff)
|
||||
{
|
||||
nearestUv = input.uv01;
|
||||
minDepthDiff = depthDiff[2];
|
||||
}
|
||||
|
||||
if (depthDiff[3] < minDepthDiff)
|
||||
{
|
||||
nearestUv = input.uv11;
|
||||
minDepthDiff = depthDiff[3];
|
||||
}
|
||||
|
||||
#if defined (UNITY2017_2_SP)
|
||||
return loColor.Sample(pointSampler, UnityStereoTransformScreenSpaceTex(nearestUv));
|
||||
#else
|
||||
return loColor.Sample(pointSampler, nearestUv);
|
||||
#endif
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
// DownsampleDepth
|
||||
//-----------------------------------------------------------------------------------------
|
||||
float DownsampleDepth(v2fDownsample input, Texture2D depthTexture, SamplerState depthSampler)
|
||||
{
|
||||
#if SHADER_TARGET > 40
|
||||
float4 depth = depthTexture.Gather(depthSampler, input.uv);
|
||||
#else
|
||||
float4 depth;
|
||||
depth.x = depthTexture.Sample(depthSampler, input.uv00).x;
|
||||
depth.y = depthTexture.Sample(depthSampler, input.uv01).x;
|
||||
depth.z = depthTexture.Sample(depthSampler, input.uv10).x;
|
||||
depth.w = depthTexture.Sample(depthSampler, input.uv11).x;
|
||||
|
||||
#endif
|
||||
|
||||
#if DOWNSAMPLE_DEPTH_MODE == 0 // min depth
|
||||
return min(min(depth.x, depth.y), min(depth.z, depth.w));
|
||||
#elif DOWNSAMPLE_DEPTH_MODE == 1 // max depth
|
||||
return max(max(depth.x, depth.y), max(depth.z, depth.w));
|
||||
#elif DOWNSAMPLE_DEPTH_MODE == 2 // min/max depth in chessboard pattern
|
||||
|
||||
float minDepth = min(min(depth.x, depth.y), min(depth.z, depth.w));
|
||||
float maxDepth = max(max(depth.x, depth.y), max(depth.z, depth.w));
|
||||
|
||||
// chessboard pattern
|
||||
int2 position = input.vertex.xy % 2;
|
||||
int index = position.x + position.y;
|
||||
return index == 1 ? minDepth : maxDepth;
|
||||
#endif
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
// GaussianWeight
|
||||
//-----------------------------------------------------------------------------------------
|
||||
float GaussianWeight(float offset, float deviation)
|
||||
{
|
||||
float weight = 1.0f / sqrt(2.0f * PI * deviation * deviation);
|
||||
weight *= exp(-(offset * offset) / (2.0f * deviation * deviation));
|
||||
return weight;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
// BilateralBlur
|
||||
//-----------------------------------------------------------------------------------------
|
||||
float4 BilateralBlur(v2f input, int2 direction, Texture2D depth, SamplerState depthSampler, const int kernelRadius, float2 pixelSize)
|
||||
{
|
||||
//const float deviation = kernelRadius / 2.5;
|
||||
const float deviation = kernelRadius / GAUSS_BLUR_DEVIATION; // make it really strong
|
||||
|
||||
float2 uv = input.uv;
|
||||
float4 centerColor = _MainTex.Sample(sampler_MainTex, UnityStereoTransformScreenSpaceTex(uv));
|
||||
float3 color = centerColor.xyz;
|
||||
//return float4(color, 1);
|
||||
float centerDepth = (LinearEyeDepth(depth.Sample(depthSampler, UnityStereoTransformScreenSpaceTex(uv))));
|
||||
|
||||
float weightSum = 0;
|
||||
|
||||
// gaussian weight is computed from constants only -> will be computed in compile time
|
||||
float weight = GaussianWeight(0, deviation);
|
||||
color *= weight;
|
||||
weightSum += weight;
|
||||
|
||||
[unroll] for (int i = -kernelRadius; i < 0; i += 1)
|
||||
{
|
||||
float2 offset = (direction * i);
|
||||
float3 sampleColor = _MainTex.Sample(sampler_MainTex, UnityStereoTransformScreenSpaceTex(input.uv), offset);
|
||||
float sampleDepth = (LinearEyeDepth(depth.Sample(depthSampler, UnityStereoTransformScreenSpaceTex(input.uv), offset)));
|
||||
|
||||
float depthDiff = abs(centerDepth - sampleDepth);
|
||||
float dFactor = depthDiff * BLUR_DEPTH_FACTOR;
|
||||
float w = exp(-(dFactor * dFactor));
|
||||
|
||||
// gaussian weight is computed from constants only -> will be computed in compile time
|
||||
weight = GaussianWeight(i, deviation) * w;
|
||||
|
||||
color += weight * sampleColor;
|
||||
weightSum += weight;
|
||||
}
|
||||
|
||||
[unroll] for (int k = 1; k <= kernelRadius; k += 1)
|
||||
{
|
||||
float2 offset = (direction * k);
|
||||
float3 sampleColor = _MainTex.Sample(sampler_MainTex, UnityStereoTransformScreenSpaceTex(input.uv), offset);
|
||||
float sampleDepth = (LinearEyeDepth(depth.Sample(depthSampler, UnityStereoTransformScreenSpaceTex(input.uv), offset)));
|
||||
|
||||
float depthDiff = abs(centerDepth - sampleDepth);
|
||||
float dFactor = depthDiff * BLUR_DEPTH_FACTOR;
|
||||
float w = exp(-(dFactor * dFactor));
|
||||
|
||||
// gaussian weight is computed from constants only -> will be computed in compile time
|
||||
weight = GaussianWeight(k, deviation) * w;
|
||||
|
||||
color += weight * sampleColor;
|
||||
weightSum += weight;
|
||||
}
|
||||
|
||||
color /= weightSum;
|
||||
return float4(color, centerColor.w);
|
||||
}
|
||||
|
||||
ENDCG
|
||||
|
||||
// pass 0 - horizontal blur (hires)
|
||||
Pass
|
||||
{
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment horizontalFrag
|
||||
#pragma target 3.5
|
||||
#pragma exclude_renderers gles
|
||||
|
||||
|
||||
fixed4 horizontalFrag(v2f input) : SV_Target
|
||||
{
|
||||
return BilateralBlur(input, int2(1, 0), _CameraDepthTexture, sampler_CameraDepthTexture, FULL_RES_BLUR_KERNEL_SIZE, _CameraDepthTexture_TexelSize.xy);
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
// pass 1 - vertical blur (hires)
|
||||
Pass
|
||||
{
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment verticalFrag
|
||||
#pragma target 3.5
|
||||
#pragma exclude_renderers gles
|
||||
|
||||
fixed4 verticalFrag(v2f input) : SV_Target
|
||||
{
|
||||
return BilateralBlur(input, int2(0, 1), _CameraDepthTexture, sampler_CameraDepthTexture, FULL_RES_BLUR_KERNEL_SIZE, _CameraDepthTexture_TexelSize);
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
// pass 2 - horizontal blur (lores)
|
||||
Pass
|
||||
{
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment horizontalFrag
|
||||
#pragma target 3.5
|
||||
#pragma exclude_renderers gles
|
||||
|
||||
fixed4 horizontalFrag(v2f input) : SV_Target
|
||||
{
|
||||
return BilateralBlur(input, int2(1, 0), _HalfResDepthBuffer, sampler_HalfResDepthBuffer, HALF_RES_BLUR_KERNEL_SIZE, _HalfResDepthBuffer_TexelSize);
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
// pass 3 - vertical blur (lores)
|
||||
Pass
|
||||
{
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment verticalFrag
|
||||
#pragma target 3.5
|
||||
#pragma exclude_renderers gles
|
||||
|
||||
fixed4 verticalFrag(v2f input) : SV_Target
|
||||
{
|
||||
return BilateralBlur(input, int2(0, 1), _HalfResDepthBuffer, sampler_HalfResDepthBuffer, HALF_RES_BLUR_KERNEL_SIZE, _HalfResDepthBuffer_TexelSize);
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
// pass 4 - downsample depth to half
|
||||
Pass
|
||||
{
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vertHalfDepth
|
||||
#pragma fragment frag
|
||||
// #pragma target gl4.1
|
||||
#pragma target 3.5
|
||||
#pragma exclude_renderers gles
|
||||
|
||||
v2fDownsample vertHalfDepth(appdata v)
|
||||
{
|
||||
return vertDownsampleDepth(v, _CameraDepthTexture_TexelSize);
|
||||
}
|
||||
|
||||
float4 frag(v2fDownsample input) : SV_Target
|
||||
{
|
||||
float depth = DownsampleDepth(input, _CameraDepthTexture, sampler_CameraDepthTexture);
|
||||
return float4(depth,depth,depth,depth);
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
// pass 5 - bilateral upsample
|
||||
Pass
|
||||
{
|
||||
|
||||
Blend One Zero
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vertUpsampleToFull
|
||||
#pragma fragment frag
|
||||
#pragma target 3.5
|
||||
#pragma exclude_renderers gles
|
||||
|
||||
v2fUpsample vertUpsampleToFull(appdata v)
|
||||
{
|
||||
return vertUpsample(v, _HalfResDepthBuffer_TexelSize);
|
||||
}
|
||||
float4 frag(v2fUpsample input) : SV_Target
|
||||
{
|
||||
return BilateralUpsample(input, _CameraDepthTexture, _HalfResDepthBuffer, _HalfResColor, sampler_HalfResColor, sampler_HalfResDepthBuffer);
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
// pass 6 - downsample depth to quarter
|
||||
Pass
|
||||
{
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vertQuarterDepth
|
||||
#pragma fragment frag
|
||||
//#pragma target gl4.1
|
||||
#pragma target 3.5
|
||||
#pragma exclude_renderers gles
|
||||
|
||||
v2fDownsample vertQuarterDepth(appdata v)
|
||||
{
|
||||
return vertDownsampleDepth(v, _HalfResDepthBuffer_TexelSize);
|
||||
}
|
||||
|
||||
float4 frag(v2fDownsample input) : SV_Target
|
||||
{
|
||||
float depth = DownsampleDepth(input, _HalfResDepthBuffer, sampler_HalfResDepthBuffer);
|
||||
return float4(depth,depth,depth,depth);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
// pass 7 - bilateral upsample quarter to full
|
||||
Pass
|
||||
{
|
||||
Blend One Zero
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vertUpsampleToFull
|
||||
#pragma fragment frag
|
||||
#pragma target 3.5
|
||||
#pragma exclude_renderers gles
|
||||
|
||||
v2fUpsample vertUpsampleToFull(appdata v)
|
||||
{
|
||||
return vertUpsample(v, _QuarterResDepthBuffer_TexelSize);
|
||||
}
|
||||
float4 frag(v2fUpsample input) : SV_Target
|
||||
{
|
||||
return BilateralUpsample(input, _CameraDepthTexture, _QuarterResDepthBuffer, _QuarterResColor, sampler_QuarterResColor, sampler_QuarterResDepthBuffer);
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
// pass 8 - horizontal blur (quarter res)
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment horizontalFrag
|
||||
#pragma target 3.5
|
||||
#pragma exclude_renderers gles
|
||||
|
||||
fixed4 horizontalFrag(v2f input) : SV_Target
|
||||
{
|
||||
return BilateralBlur(input, int2(1, 0), _QuarterResDepthBuffer, sampler_QuarterResDepthBuffer, QUARTER_RES_BLUR_KERNEL_SIZE, _QuarterResDepthBuffer_TexelSize.xy);
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
// pass 9 - vertical blur (quarter res)
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment verticalFrag
|
||||
#pragma target 3.5
|
||||
#pragma exclude_renderers gles
|
||||
|
||||
fixed4 verticalFrag(v2f input) : SV_Target
|
||||
{
|
||||
return BilateralBlur(input, int2(0, 1), _QuarterResDepthBuffer, sampler_QuarterResDepthBuffer, QUARTER_RES_BLUR_KERNEL_SIZE, _QuarterResDepthBuffer_TexelSize.xy);
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
// pass 10 - downsample depth to half (fallback for DX10)
|
||||
Pass
|
||||
{
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vertHalfDepth
|
||||
#pragma fragment frag
|
||||
#pragma target 3.5
|
||||
#pragma exclude_renderers gles
|
||||
|
||||
v2fDownsample vertHalfDepth(appdata v)
|
||||
{
|
||||
return vertDownsampleDepth(v, _CameraDepthTexture_TexelSize);
|
||||
}
|
||||
|
||||
float4 frag(v2fDownsample input) : SV_Target
|
||||
{
|
||||
float depth = DownsampleDepth(input, _CameraDepthTexture, sampler_CameraDepthTexture);
|
||||
|
||||
return float4(depth,depth,depth,depth);
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
// pass 11 - downsample depth to quarter (fallback for DX10)
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vertQuarterDepth
|
||||
#pragma fragment frag
|
||||
#pragma target 3.5
|
||||
#pragma exclude_renderers gles
|
||||
|
||||
v2fDownsample vertQuarterDepth(appdata v)
|
||||
{
|
||||
return vertDownsampleDepth(v, _HalfResDepthBuffer_TexelSize);
|
||||
}
|
||||
|
||||
float4 frag(v2fDownsample input) : SV_Target
|
||||
{
|
||||
float depth = DownsampleDepth(input, _HalfResDepthBuffer, sampler_HalfResDepthBuffer);
|
||||
|
||||
return float4(depth,depth,depth,depth);
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 307338a0d8294f440853ba6b3a56cf54
|
||||
timeCreated: 1459178236
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
-142
@@ -1,142 +0,0 @@
|
||||
// MODIFIED FOR ENVIRO POST PROCESSING
|
||||
//
|
||||
// Kino/Bloom v2 - Bloom filter for Unity
|
||||
//
|
||||
// Copyright (C) 2015, 2016 Keijiro Takahashi
|
||||
//
|
||||
// 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 notice and this permission notice 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.
|
||||
//
|
||||
Shader "Hidden/EnviroDistanceBlur"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex("", any) = "" {}
|
||||
_BaseTex("", any) = "" {}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
// 0: Prefilter
|
||||
Pass
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
CGPROGRAM
|
||||
#pragma multi_compile _ UNITY_COLORSPACE_GAMMA
|
||||
#include "../Core/EnviroBlurCore.cginc"
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag_prefilter
|
||||
#pragma target 3.0
|
||||
ENDCG
|
||||
}
|
||||
// 1: Prefilter with anti-flicker
|
||||
Pass
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
CGPROGRAM
|
||||
#define ANTI_FLICKER 1
|
||||
#pragma multi_compile _ UNITY_COLORSPACE_GAMMA
|
||||
#include "../Core/EnviroBlurCore.cginc"
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag_prefilter
|
||||
#pragma target 3.0
|
||||
ENDCG
|
||||
}
|
||||
// 2: First level downsampler
|
||||
Pass
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
CGPROGRAM
|
||||
#include "../Core/EnviroBlurCore.cginc"
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag_downsample1
|
||||
#pragma target 3.0
|
||||
ENDCG
|
||||
}
|
||||
// 3: First level downsampler with anti-flicker
|
||||
Pass
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
CGPROGRAM
|
||||
#define ANTI_FLICKER 1
|
||||
#include "../Core/EnviroBlurCore.cginc"
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag_downsample1
|
||||
#pragma target 3.0
|
||||
ENDCG
|
||||
}
|
||||
// 4: Second level downsampler
|
||||
Pass
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
CGPROGRAM
|
||||
#include "../Core/EnviroBlurCore.cginc"
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag_downsample2
|
||||
#pragma target 3.0
|
||||
ENDCG
|
||||
}
|
||||
// 5: Upsampler
|
||||
Pass
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
CGPROGRAM
|
||||
#include "../Core/EnviroBlurCore.cginc"
|
||||
#pragma vertex vert_multitex
|
||||
#pragma fragment frag_upsample
|
||||
#pragma target 3.0
|
||||
ENDCG
|
||||
}
|
||||
// 6: High quality upsampler
|
||||
Pass
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
CGPROGRAM
|
||||
#define HIGH_QUALITY 1
|
||||
#include "../Core/EnviroBlurCore.cginc"
|
||||
#pragma vertex vert_multitex
|
||||
#pragma fragment frag_upsample
|
||||
#pragma target 3.0
|
||||
ENDCG
|
||||
}
|
||||
// 7: Combiner
|
||||
Pass
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
CGPROGRAM
|
||||
#pragma multi_compile _ UNITY_COLORSPACE_GAMMA
|
||||
#include "../Core/EnviroBlurCore.cginc"
|
||||
#pragma vertex vert_multitex
|
||||
#pragma fragment frag_upsample_final
|
||||
#pragma target 3.0
|
||||
ENDCG
|
||||
}
|
||||
// 8: High quality combiner
|
||||
Pass
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
CGPROGRAM
|
||||
#define HIGH_QUALITY 1
|
||||
#pragma multi_compile _ UNITY_COLORSPACE_GAMMA
|
||||
#include "../Core/EnviroBlurCore.cginc"
|
||||
#pragma vertex vert_multitex
|
||||
#pragma fragment frag_upsample_final
|
||||
#pragma target 3.0
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1e01d888ba8d52d4283fc169b2717e27
|
||||
timeCreated: 1540850786
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
-292
@@ -1,292 +0,0 @@
|
||||
|
||||
Shader "Enviro/Standard/EnviroFogRendering"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_EnviroVolumeLightingTex("Volume Lighting Tex", Any) = ""{}
|
||||
_MainTex("Source", Any) = "black"{}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Pass
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off Fog { Mode Off }
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 3.0
|
||||
#pragma multi_compile __ ENVIROVOLUMELIGHT
|
||||
#pragma multi_compile __ ENVIRO_DEPTHBLENDING
|
||||
#pragma exclude_renderers gles
|
||||
|
||||
// Start: LuxWater
|
||||
#pragma multi_compile __ LUXWATER_DEFERREDFOG
|
||||
|
||||
#if defined(LUXWATER_DEFERREDFOG)
|
||||
sampler2D _UnderWaterMask;
|
||||
float4 _LuxUnderWaterDeferredFogParams; // x: IsInsideWatervolume?, y: BelowWaterSurface shift, z: EdgeBlend
|
||||
#endif
|
||||
// End: LuxWater
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "../Core/EnviroVolumeLightCore.cginc"
|
||||
#include "../../../../Core/Resources/Shaders/Core/EnviroFogCore.cginc"
|
||||
|
||||
//uniform sampler2D _MainTex;
|
||||
UNITY_DECLARE_SCREENSPACE_TEXTURE(_MainTex);
|
||||
uniform float4 _MainTex_TexelSize;
|
||||
uniform sampler3D _FogNoiseTexture;
|
||||
uniform float _DitheringIntensity;
|
||||
|
||||
#ifdef ENVIRO_DEPTHBLENDING
|
||||
uniform sampler2D _EnviroCloudsTex;
|
||||
#endif
|
||||
struct appdata_t
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float3 texcoord : TEXCOORD0;
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float3 texcoord : TEXCOORD0;
|
||||
float3 sky : TEXCOORD1;
|
||||
float4 uv : TEXCOORD2;
|
||||
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f vert(appdata_img v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v); //Insert
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o); //Insert
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); //Insert
|
||||
o.pos = v.vertex * float4(2, 2, 1, 1) + float4(-1, -1, 0, 0);
|
||||
o.uv.xy = v.texcoord.xy;
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
if (_MainTex_TexelSize.y > 0)
|
||||
o.uv.y = 1 - o.uv.y;
|
||||
#endif
|
||||
o.sky.x = saturate(_SunDir.y + 0.25);
|
||||
o.sky.y = saturate(clamp(1.0 - _SunDir.y, 0.0, 0.5));
|
||||
return o;
|
||||
}
|
||||
|
||||
float3 ScreenSpaceDither(float2 vScreenPos, float3 clr)
|
||||
{
|
||||
float d = dot(float2(131.0, 312.0), vScreenPos.xy + _Time.y);
|
||||
float3 vDither = float3(d, d, d);
|
||||
vDither.rgb = frac(vDither.rgb / float3(103.0, 71.0, 97.0)) - float3(0.5, 0.5, 0.5);
|
||||
return (vDither.rgb / 15.0) * _DitheringIntensity;
|
||||
}
|
||||
|
||||
// Linear height fog function
|
||||
float ComputeHalfSpaceWithNoise(float3 wsDir)
|
||||
{
|
||||
float3 wpos = _WorldSpaceCameraPos + wsDir;
|
||||
float FH = _HeightParams.x;
|
||||
float3 C = _WorldSpaceCameraPos;
|
||||
float3 V = wsDir;
|
||||
float3 P = wpos;
|
||||
float3 aV = (_HeightParams.w * _EnviroSkyFog.w) * V;
|
||||
float noise = tex3D(_FogNoiseTexture, frac(wpos * _FogNoiseData.x + float3(_Time.y * _FogNoiseVelocity.x, 0, _Time.y * _FogNoiseVelocity.y)));
|
||||
// float noise = tex3D(_FogNoiseTexture, wpos * 0.01);
|
||||
noise = saturate(noise - _FogNoiseData.z) * _FogNoiseData.y;
|
||||
aV *= noise;
|
||||
float FdotC = _HeightParams.y;
|
||||
float k = _HeightParams.z;
|
||||
float FdotP = P.y - FH;
|
||||
float FdotV = wsDir.y;
|
||||
float c1 = k * (FdotP + FdotC);
|
||||
float c2 = (1 - 2 * k) * FdotP;
|
||||
float g = min(c2, 0.0);
|
||||
g = -length(aV) * (c1 - g * g / abs(FdotV + 1.0e-5f));
|
||||
return g;
|
||||
}
|
||||
|
||||
float Remap(float org_val, float org_min, float org_max, float new_min, float new_max)
|
||||
{
|
||||
return new_min + saturate(((org_val - org_min) / (org_max - org_min))*(new_max - new_min));
|
||||
}
|
||||
|
||||
/// Main Fragment Shader
|
||||
fixed4 frag(v2f i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
|
||||
float rawDepth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoTransformScreenSpaceTex(i.uv));
|
||||
float dpth = Linear01Depth(rawDepth);
|
||||
|
||||
float4x4 proj, eyeToWorld;
|
||||
if (unity_StereoEyeIndex == 0)
|
||||
{
|
||||
proj = _LeftViewFromScreen;
|
||||
eyeToWorld = _LeftWorldFromView;
|
||||
}
|
||||
else
|
||||
{
|
||||
proj = _RightViewFromScreen;
|
||||
eyeToWorld = _RightWorldFromView;
|
||||
}
|
||||
|
||||
//bit of matrix math to take the screen space coord (u,v,depth) and transform to world space
|
||||
float2 uvClip = i.uv * 2.0 - 1.0;
|
||||
float clipDepth = rawDepth; // Fix for OpenGl Core thanks to Lars Bertram
|
||||
clipDepth = (UNITY_NEAR_CLIP_VALUE < 0) ? clipDepth * 2 - 1 : clipDepth;
|
||||
float4 clipPos = float4(uvClip, clipDepth, 1.0);
|
||||
float4 viewPos = mul(proj, clipPos); // inverse projection by clip position
|
||||
viewPos /= viewPos.w; // perspective division
|
||||
float4 wsPos = float4(mul(eyeToWorld, viewPos).xyz, 1);
|
||||
float4 wsDir = wsPos - float4(_WorldSpaceCameraPos, 0);
|
||||
float3 viewDir = normalize(wsDir);
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
half fogFac = 0;
|
||||
float4 finalFog = 0;
|
||||
float g = _DistanceParams.x;
|
||||
half gHeight = 0;
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//Scene
|
||||
if (dpth < 0.99)
|
||||
{
|
||||
// Calculate Distance Fog
|
||||
if (_EnviroParams.y > 0)
|
||||
{
|
||||
g += ComputeDistance(wsDir, dpth);
|
||||
g *= _distanceFogIntensity;
|
||||
}
|
||||
|
||||
if (_EnviroParams.z > 0)
|
||||
{
|
||||
gHeight = ComputeHalfSpaceWithNoise(wsDir) * (1 - dpth);
|
||||
}
|
||||
//gHeight = lerp(0.75, 1.0, dpth);
|
||||
|
||||
|
||||
// Add Height Fog
|
||||
g += gHeight;
|
||||
|
||||
// Compute fog amount
|
||||
fogFac = ComputeFogFactor(max(0.0, g));
|
||||
|
||||
|
||||
#ifdef ENVIRO_DEPTHBLENDING
|
||||
float4 clouds = tex2D(_EnviroCloudsTex, UnityStereoTransformScreenSpaceTex(i.uv));
|
||||
|
||||
if (clouds.a > 0.9)
|
||||
{
|
||||
|
||||
if (_EnviroParams.z > 0 && _SceneFogMode.w == 1)
|
||||
{
|
||||
gHeight = ComputeHalfSpace(wsDir);
|
||||
}
|
||||
|
||||
half fogFacSky = ComputeFogFactor(max(0.0, gHeight));
|
||||
float f = saturate(_EnviroSkyFog.x * (viewDir.y + _EnviroSkyFog.z));
|
||||
f = pow(f, _EnviroSkyFog.y);
|
||||
|
||||
fogFac = (clamp(f, 0, 1));
|
||||
|
||||
float skyLerp = Remap(_WorldSpaceCameraPos.y, 0, _SunParameters.w, 0, 1);
|
||||
fogFac = lerp(fogFac, 1, skyLerp);
|
||||
}
|
||||
//fogFac = 1;
|
||||
#endif
|
||||
|
||||
|
||||
fogFac = lerp(_maximumFogDensity, 1.0f, fogFac);
|
||||
finalFog = ComputeScatteringScene(viewDir, i.sky.xy);
|
||||
|
||||
}
|
||||
else //SKY
|
||||
{
|
||||
if (_EnviroParams.z > 0 && _SceneFogMode.w == 1)
|
||||
{
|
||||
gHeight = ComputeHalfSpace(wsDir);
|
||||
}
|
||||
|
||||
half fogFacSky = ComputeFogFactor(max(0.0, gHeight));
|
||||
float f = saturate(_EnviroSkyFog.x * (viewDir.y + _EnviroSkyFog.z));
|
||||
f = pow(f, _EnviroSkyFog.y);
|
||||
|
||||
fogFac = (clamp(f, 0, 1));
|
||||
|
||||
if (fogFac > fogFacSky)
|
||||
fogFac = fogFacSky;
|
||||
|
||||
float skyLerp = Remap(_WorldSpaceCameraPos.y, 0, _SunParameters.w, 0, 1);
|
||||
fogFac = lerp(fogFac, 1, skyLerp);
|
||||
float4 skyFog = ComputeScatteringScene(viewDir, i.sky.xy);
|
||||
|
||||
finalFog = skyFog;
|
||||
}
|
||||
|
||||
//Dithering
|
||||
finalFog.rgb = finalFog.rgb + ScreenSpaceDither(i.pos.xy, finalFog.rgb);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// Composing
|
||||
|
||||
// Start: LuxWater
|
||||
#if defined(LUXWATER_DEFERREDFOG)
|
||||
half4 fogMask = tex2D(_UnderWaterMask, UnityStereoTransformScreenSpaceTex(i.uv));
|
||||
float watersurfacefrombelow = DecodeFloatRG(fogMask.ba);
|
||||
|
||||
// Get distance and lower it a bit in order to handle edge blending artifacts (edge blended parts would not get ANY fog)
|
||||
float dist = (watersurfacefrombelow - dpth) + _LuxUnderWaterDeferredFogParams.y * _ProjectionParams.w;
|
||||
// Fade fog from above water to below water
|
||||
float fogFactor = saturate(1.0 + _ProjectionParams.z * _LuxUnderWaterDeferredFogParams.z * dist);
|
||||
// Clamp above result to where water is actually rendered
|
||||
fogFactor = (fogMask.r == 1) ? fogFactor : 1.0;
|
||||
// Mask fog on underwarter parts - only if we are inside a volume (bool... :( )
|
||||
if (_LuxUnderWaterDeferredFogParams.x) {
|
||||
fogFactor *= saturate(1.0 - fogMask.g * 8.0);
|
||||
if (dist < -_ProjectionParams.w * 4 && fogMask.r == 0 && fogMask.g < 1.0) {
|
||||
fogFactor = 1.0;
|
||||
}
|
||||
}
|
||||
// Tweak fog factor
|
||||
fogFac = lerp(1.0, fogFac, fogFactor);
|
||||
#endif
|
||||
// End: LuxWater
|
||||
|
||||
float4 final;
|
||||
float4 source = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, UnityStereoTransformScreenSpaceTex(i.uv));
|
||||
|
||||
#if defined (ENVIROVOLUMELIGHT)
|
||||
float4 volumeLighting = tex2D(_EnviroVolumeLightingTex, UnityStereoTransformScreenSpaceTex(i.uv));
|
||||
volumeLighting *= _EnviroParams.x;
|
||||
|
||||
if (_EnviroParams.w == 1)
|
||||
{
|
||||
volumeLighting.rgb = tonemapACES(volumeLighting.rgb, 1.0);
|
||||
}
|
||||
|
||||
// Start: LuxWater
|
||||
#if defined(LUXWATER_DEFERREDFOG)
|
||||
volumeLighting *= fogFactor;
|
||||
#endif
|
||||
// End: LuxWater
|
||||
final *= volumeLighting.w;
|
||||
|
||||
final = lerp (lerp(finalFog, finalFog + volumeLighting, _EnviroVolumeDensity), lerp(source, source + volumeLighting, _EnviroVolumeDensity), fogFac);
|
||||
#else
|
||||
final = lerp (finalFog, source, fogFac);
|
||||
#endif
|
||||
|
||||
return final;
|
||||
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
Fallback Off
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 78aa7501e8e951446b1be533c73e8de6
|
||||
timeCreated: 1459178236
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
-96
@@ -1,96 +0,0 @@
|
||||
|
||||
Shader "Enviro/Standard/EnviroFogRenderingDisabled"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_EnviroVolumeLightingTex("Volume Lighting Tex", Any) = ""{}
|
||||
_MainTex("Source", Any) = "black"{}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Pass
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off Fog { Mode Off }
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 3.0
|
||||
#pragma multi_compile ENVIROVOLUMELIGHT
|
||||
#pragma exclude_renderers gles
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
UNITY_DECLARE_SCREENSPACE_TEXTURE(_MainTex);
|
||||
uniform sampler2D _EnviroVolumeLightingTex;
|
||||
uniform float4 _MainTex_TexelSize;
|
||||
uniform float4 _EnviroParams;
|
||||
uniform float _EnviroVolumeDensity;
|
||||
|
||||
struct appdata_t
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float3 texcoord : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float3 texcoord : TEXCOORD0;
|
||||
float3 sky : TEXCOORD1;
|
||||
float2 uv : TEXCOORD2;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
|
||||
v2f vert(appdata_img v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v); //Insert
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o); //Insert
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); //Ins
|
||||
o.pos = v.vertex * float4(2, 2, 1, 1) + float4(-1, -1, 0, 0);
|
||||
o.uv.xy = v.texcoord.xy;
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
if (_MainTex_TexelSize.y > 0)
|
||||
o.uv.y = 1 - o.uv.y;
|
||||
#endif
|
||||
return o;
|
||||
}
|
||||
|
||||
half3 tonemapACES(half3 color, float Exposure)
|
||||
{
|
||||
color *= Exposure;
|
||||
|
||||
// See https://knarkowicz.wordpress.com/2016/01/06/aces-filmic-tone-mapping-curve/
|
||||
const half a = 2.51;
|
||||
const half b = 0.03;
|
||||
const half c = 2.43;
|
||||
const half d = 0.59;
|
||||
const half e = 0.14;
|
||||
return saturate((color * (a * color + b)) / (color * (c * color + d) + e));
|
||||
}
|
||||
|
||||
fixed4 frag(v2f i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
float4 source = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, UnityStereoTransformScreenSpaceTex(i.uv));
|
||||
|
||||
#if defined (ENVIROVOLUMELIGHT)
|
||||
float4 volumeLighting = tex2D(_EnviroVolumeLightingTex, UnityStereoTransformScreenSpaceTex(i.uv));
|
||||
volumeLighting *= _EnviroParams.x;
|
||||
if (_EnviroParams.w == 1)
|
||||
{
|
||||
volumeLighting.rgb = tonemapACES(volumeLighting.rgb, 1.0);
|
||||
}
|
||||
return lerp(source, source + volumeLighting, _EnviroVolumeDensity);
|
||||
#else
|
||||
return source;
|
||||
#endif
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
Fallback Off
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e5dbacd27b280d345a34f2ecef4d76fb
|
||||
timeCreated: 1459178236
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
-205
@@ -1,205 +0,0 @@
|
||||
|
||||
Shader "Enviro/Standard/EnviroFogRenderingSimple"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_EnviroVolumeLightingTex("Volume Lighting Tex", Any) = ""{}
|
||||
_MainTex("Source", Any) = "black"{}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Pass
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off Fog { Mode Off }
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 3.0
|
||||
#pragma multi_compile ENVIROVOLUMELIGHT
|
||||
#pragma exclude_renderers gles
|
||||
|
||||
// Start: LuxWater
|
||||
#pragma multi_compile __ LUXWATER_DEFERREDFOG
|
||||
|
||||
#if defined(LUXWATER_DEFERREDFOG)
|
||||
sampler2D _UnderWaterMask;
|
||||
float4 _LuxUnderWaterDeferredFogParams; // x: IsInsideWatervolume?, y: BelowWaterSurface shift, z: EdgeBlend
|
||||
#endif
|
||||
// End: LuxWater
|
||||
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "../Core/EnviroVolumeLightCore.cginc"
|
||||
#include "../../../../Core/Resources/Shaders/Core/EnviroFogCore.cginc"
|
||||
|
||||
UNITY_DECLARE_SCREENSPACE_TEXTURE(_MainTex);
|
||||
uniform float4 _MainTex_TexelSize;
|
||||
|
||||
struct appdata_t
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float3 texcoord : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float3 texcoord : TEXCOORD0;
|
||||
float3 sky : TEXCOORD1;
|
||||
float2 uv : TEXCOORD2;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
|
||||
v2f vert(appdata_img v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v); //Insert
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o); //Insert
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); //Insert
|
||||
o.pos = v.vertex * float4(2, 2, 1, 1) + float4(-1, -1, 0, 0);
|
||||
o.uv.xy = v.texcoord.xy;
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
if (_MainTex_TexelSize.y > 0)
|
||||
o.uv.y = 1 - o.uv.y;
|
||||
#endif
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag(v2f i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
|
||||
float rawDepth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoTransformScreenSpaceTex(i.uv));
|
||||
float dpth = Linear01Depth(rawDepth);
|
||||
|
||||
|
||||
float4x4 proj, eyeToWorld;
|
||||
if (unity_StereoEyeIndex == 0)
|
||||
{
|
||||
proj = _LeftViewFromScreen;
|
||||
eyeToWorld = _LeftWorldFromView;
|
||||
}
|
||||
else
|
||||
{
|
||||
proj = _RightViewFromScreen;
|
||||
eyeToWorld = _RightWorldFromView;
|
||||
}
|
||||
|
||||
//bit of matrix math to take the screen space coord (u,v,depth) and transform to world space
|
||||
float2 uvClip = i.uv * 2.0 - 1.0;
|
||||
float clipDepth = rawDepth; // Fix for OpenGl Core thanks to Lars Bertram
|
||||
clipDepth = (UNITY_NEAR_CLIP_VALUE < 0) ? clipDepth * 2 - 1 : clipDepth;
|
||||
float4 clipPos = float4(uvClip, clipDepth, 1.0);
|
||||
float4 viewPos = mul(proj, clipPos); // inverse projection by clip position
|
||||
viewPos /= viewPos.w; // perspective division
|
||||
|
||||
float4 wsPos = float4(mul(eyeToWorld, viewPos).xyz, 1);
|
||||
float4 wsDir = wsPos - float4(_WorldSpaceCameraPos, 0);
|
||||
|
||||
float3 viewDir = normalize(wsDir);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
half fogFac = 0;
|
||||
float4 finalFog = unity_FogColor;
|
||||
float g = _DistanceParams.x;
|
||||
half gAdd = 0;
|
||||
|
||||
if (_EnviroParams.z > 0)
|
||||
{
|
||||
gAdd = ComputeHalfSpace (wsDir);
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//Scene
|
||||
if (dpth < 0.99999)
|
||||
{
|
||||
// Calculate Distance Fog
|
||||
if (_EnviroParams.y > 0)
|
||||
{
|
||||
g += ComputeDistance(wsDir, dpth);
|
||||
g *= _distanceFogIntensity;
|
||||
}
|
||||
|
||||
// AAdd Height Fog
|
||||
g += gAdd;
|
||||
|
||||
// Compute fog amount
|
||||
fogFac = ComputeFogFactor(max(0.0, g));
|
||||
fogFac = lerp(_maximumFogDensity, 1.0f, fogFac);
|
||||
}
|
||||
else //SKY
|
||||
{
|
||||
half fogFacSky = ComputeFogFactor(max(0.0, gAdd));
|
||||
float f = saturate(_EnviroSkyFog.x * (viewDir.y + _EnviroSkyFog.z));
|
||||
f = pow(f, _EnviroSkyFog.y);
|
||||
fogFac = (clamp(f, 0, 1));
|
||||
|
||||
if (fogFac > fogFacSky)
|
||||
fogFac = fogFacSky;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Start: LuxWater
|
||||
#if defined(LUXWATER_DEFERREDFOG)
|
||||
half4 fogMask = tex2D(_UnderWaterMask, UnityStereoTransformScreenSpaceTex(i.uv));
|
||||
float watersurfacefrombelow = DecodeFloatRG(fogMask.ba);
|
||||
|
||||
// Get distance and lower it a bit in order to handle edge blending artifacts (edge blended parts would not get ANY fog)
|
||||
float dist = (watersurfacefrombelow - dpth) + _LuxUnderWaterDeferredFogParams.y * _ProjectionParams.w;
|
||||
// Fade fog from above water to below water
|
||||
float fogFactor = saturate(1.0 + _ProjectionParams.z * _LuxUnderWaterDeferredFogParams.z * dist);
|
||||
// Clamp above result to where water is actually rendered
|
||||
fogFactor = (fogMask.r == 1) ? fogFactor : 1.0;
|
||||
// Mask fog on underwarter parts - only if we are inside a volume (bool... :( )
|
||||
if (_LuxUnderWaterDeferredFogParams.x) {
|
||||
fogFactor *= saturate(1.0 - fogMask.g * 8.0);
|
||||
if (dist < -_ProjectionParams.w * 4 && fogMask.r == 0 && fogMask.g < 1.0) {
|
||||
fogFactor = 1.0;
|
||||
}
|
||||
}
|
||||
// Tweak fog factor
|
||||
fogFac = lerp(1.0, fogFac, fogFactor);
|
||||
#endif
|
||||
// End: LuxWater
|
||||
|
||||
|
||||
|
||||
float4 final;
|
||||
float4 source = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, UnityStereoTransformScreenSpaceTex(i.uv));
|
||||
|
||||
#if defined (ENVIROVOLUMELIGHT)
|
||||
float4 volumeLighting = tex2D(_EnviroVolumeLightingTex, UnityStereoTransformScreenSpaceTex(i.uv));
|
||||
volumeLighting *= _EnviroParams.x;
|
||||
if (_EnviroParams.w == 1)
|
||||
{
|
||||
volumeLighting.rgb = tonemapACES(volumeLighting.rgb, 1.0);
|
||||
}
|
||||
// Start: LuxWater
|
||||
#if defined(LUXWATER_DEFERREDFOG)
|
||||
volumeLighting *= fogFactor;
|
||||
#endif
|
||||
// End: LuxWater
|
||||
final = lerp (lerp(finalFog, finalFog + volumeLighting, _EnviroVolumeDensity), lerp(source, source + volumeLighting, _EnviroVolumeDensity), fogFac);
|
||||
#else
|
||||
final = lerp (finalFog, source, fogFac);
|
||||
#endif
|
||||
|
||||
return final;
|
||||
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
Fallback Off
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 899fe52a053808b40b4f6517d18538bd
|
||||
timeCreated: 1459178236
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
-454
@@ -1,454 +0,0 @@
|
||||
// Copyright(c) 2016, Michal Skalsky
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software without
|
||||
// specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
// OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
// TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
//Modified for use with Enviro - Sky and Weather
|
||||
|
||||
|
||||
|
||||
Shader "Enviro/Standard/VolumeLight"
|
||||
{
|
||||
Properties
|
||||
{ _MainTex("Texture", any) = "" {}
|
||||
[HideInInspector]_ZTest ("ZTest", Float) = 0
|
||||
[HideInInspector]_LightColor("_LightColor", Color) = (1,1,1,1)
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Opaque" }
|
||||
LOD 100
|
||||
|
||||
CGINCLUDE
|
||||
#if defined(SHADOWS_DEPTH) || defined(SHADOWS_CUBE)
|
||||
#define SHADOWS_NATIVE
|
||||
#endif
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityDeferredLibrary.cginc"
|
||||
#include "../Core/EnviroVolumeLightCore.cginc"
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float4 uv : TEXCOORD0;
|
||||
float3 wpos : TEXCOORD1;
|
||||
float4 interpolatedRay : TEXCOORD2;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v); //Insert
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o); //Insert
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); //Ins
|
||||
if (unity_StereoEyeIndex == 0)
|
||||
o.pos = mul(_WorldViewProj, v.vertex);
|
||||
else
|
||||
o.pos = mul(_WorldViewProj_SP, v.vertex);
|
||||
|
||||
o.uv = ComputeScreenPos(o.pos);
|
||||
o.wpos = mul(unity_ObjectToWorld, v.vertex);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
// pass 0 - point light, camera inside
|
||||
Pass
|
||||
{
|
||||
ZTest Off
|
||||
Cull Front
|
||||
ZWrite Off
|
||||
Blend One One
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment fragPointInside
|
||||
#pragma target 3.5
|
||||
#pragma exclude_renderers d3d9 gles
|
||||
|
||||
#define UNITY_HDR_ON
|
||||
|
||||
#pragma shader_feature HEIGHT_FOG
|
||||
#pragma shader_feature NOISE
|
||||
#pragma shader_feature SHADOWS_CUBE
|
||||
#pragma shader_feature POINT_COOKIE
|
||||
#pragma shader_feature POINT
|
||||
|
||||
#ifdef SHADOWS_DEPTH
|
||||
#define SHADOWS_NATIVE
|
||||
#endif
|
||||
|
||||
|
||||
fixed4 fragPointInside(v2f i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
float2 uv = i.uv.xy / i.uv.w;
|
||||
|
||||
// read depth and reconstruct world position
|
||||
float depth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(uv,_CameraDepthTexture_ST));
|
||||
|
||||
float3 rayStart = _WorldSpaceCameraPos;
|
||||
float3 rayEnd = i.wpos;
|
||||
|
||||
float3 rayDir = (rayEnd - rayStart);
|
||||
float rayLength = length(rayDir);
|
||||
|
||||
rayDir /= rayLength;
|
||||
|
||||
float linearDepth = LinearEyeDepth(depth);
|
||||
float projectedDepth = linearDepth / dot(_CameraForward, rayDir);
|
||||
rayLength = min(rayLength, projectedDepth);
|
||||
|
||||
return RayMarch(i.pos.xy, rayStart, rayDir, rayLength);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
// pass 1 - spot light, camera inside
|
||||
Pass
|
||||
{
|
||||
ZTest Off
|
||||
Cull Front
|
||||
ZWrite Off
|
||||
Blend One One
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment fragPointInside
|
||||
#pragma target 3.5
|
||||
#pragma exclude_renderers d3d9 gles
|
||||
|
||||
#define UNITY_HDR_ON
|
||||
|
||||
#pragma shader_feature HEIGHT_FOG
|
||||
#pragma shader_feature NOISE
|
||||
#pragma shader_feature SHADOWS_DEPTH
|
||||
#pragma shader_feature SPOT
|
||||
|
||||
#ifdef SHADOWS_DEPTH
|
||||
#define SHADOWS_NATIVE
|
||||
#endif
|
||||
|
||||
fixed4 fragPointInside(v2f i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
float2 uv = i.uv.xy / i.uv.w;
|
||||
|
||||
// read depth and reconstruct world position
|
||||
float depth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(uv,_CameraDepthTexture_ST));
|
||||
|
||||
float3 rayStart = _WorldSpaceCameraPos;
|
||||
float3 rayEnd = i.wpos;
|
||||
|
||||
float3 rayDir = (rayEnd - rayStart);
|
||||
float rayLength = length(rayDir);
|
||||
|
||||
rayDir /= rayLength;
|
||||
|
||||
float linearDepth = LinearEyeDepth(depth);
|
||||
float projectedDepth = linearDepth / dot(_CameraForward, rayDir);
|
||||
rayLength = min(rayLength, projectedDepth);
|
||||
|
||||
return RayMarch(i.pos.xy, rayStart, rayDir, rayLength);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
// pass 2 - point light, camera outside
|
||||
Pass
|
||||
{
|
||||
//ZTest Off
|
||||
ZTest [_ZTest]
|
||||
Cull Back
|
||||
ZWrite Off
|
||||
Blend One One
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment fragPointOutside
|
||||
#pragma target 3.5
|
||||
#pragma exclude_renderers d3d9 gles
|
||||
|
||||
#define UNITY_HDR_ON
|
||||
|
||||
#pragma shader_feature HEIGHT_FOG
|
||||
#pragma shader_feature SHADOWS_CUBE
|
||||
#pragma shader_feature NOISE
|
||||
#pragma shader_feature POINT_COOKIE
|
||||
#pragma shader_feature POINT
|
||||
|
||||
fixed4 fragPointOutside(v2f i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
float2 uv = i.uv.xy / i.uv.w;
|
||||
|
||||
// read depth and reconstruct world position
|
||||
float depth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(uv,_CameraDepthTexture_ST));
|
||||
|
||||
float3 rayStart = _WorldSpaceCameraPos;
|
||||
float3 rayEnd = i.wpos;
|
||||
|
||||
float3 rayDir = (rayEnd - rayStart);
|
||||
float rayLength = length(rayDir);
|
||||
|
||||
rayDir /= rayLength;
|
||||
|
||||
float3 lightToCamera = _WorldSpaceCameraPos - _LightPos;
|
||||
|
||||
float b = dot(rayDir, lightToCamera);
|
||||
float c = dot(lightToCamera, lightToCamera) - (_VolumetricLight.z * _VolumetricLight.z);
|
||||
|
||||
float d = sqrt((b*b) - c);
|
||||
float start = -b - d;
|
||||
float end = -b + d;
|
||||
|
||||
float linearDepth = LinearEyeDepth(depth);
|
||||
float projectedDepth = linearDepth / dot(_CameraForward, rayDir);
|
||||
end = min(end, projectedDepth);
|
||||
|
||||
rayStart = rayStart + rayDir * start;
|
||||
rayLength = end - start;
|
||||
|
||||
return RayMarch(i.pos.xy, rayStart, rayDir, rayLength);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
// pass 3 - spot light, camera outside
|
||||
Pass
|
||||
{
|
||||
//ZTest Off
|
||||
ZTest[_ZTest]
|
||||
Cull Back
|
||||
ZWrite Off
|
||||
Blend One One
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment fragSpotOutside
|
||||
#pragma target 3.5
|
||||
#pragma exclude_renderers d3d9 gles
|
||||
|
||||
#define UNITY_HDR_ON
|
||||
|
||||
#pragma shader_feature HEIGHT_FOG
|
||||
#pragma shader_feature SHADOWS_DEPTH
|
||||
#pragma shader_feature NOISE
|
||||
#pragma shader_feature SPOT
|
||||
|
||||
#ifdef SHADOWS_DEPTH
|
||||
#define SHADOWS_NATIVE
|
||||
#endif
|
||||
|
||||
float _CosAngle;
|
||||
float4 _ConeAxis;
|
||||
float4 _ConeApex;
|
||||
float _PlaneD;
|
||||
|
||||
fixed4 fragSpotOutside(v2f i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
float2 uv = i.uv.xy / i.uv.w;
|
||||
|
||||
// read depth and reconstruct world position
|
||||
float depth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(uv,_CameraDepthTexture_ST));
|
||||
|
||||
float3 rayStart = _WorldSpaceCameraPos;
|
||||
float3 rayEnd = i.wpos;
|
||||
|
||||
float3 rayDir = (rayEnd - rayStart);
|
||||
float rayLength = length(rayDir);
|
||||
|
||||
rayDir /= rayLength;
|
||||
|
||||
|
||||
// inside cone
|
||||
float3 r1 = rayEnd + rayDir * 0.001;
|
||||
|
||||
// plane intersection
|
||||
float planeCoord = RayPlaneIntersect(_ConeAxis, _PlaneD, r1, rayDir);
|
||||
// ray cone intersection
|
||||
float2 lineCoords = RayConeIntersect(_ConeApex, _ConeAxis, _CosAngle, r1, rayDir);
|
||||
|
||||
float linearDepth = LinearEyeDepth(depth);
|
||||
float projectedDepth = linearDepth / dot(_CameraForward, rayDir);
|
||||
|
||||
float z = (projectedDepth - rayLength);
|
||||
rayLength = min(planeCoord, min(lineCoords.x, lineCoords.y));
|
||||
rayLength = min(rayLength, z);
|
||||
|
||||
return RayMarch(i.pos.xy, rayEnd, rayDir, rayLength);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
// pass 4 - directional light
|
||||
Pass
|
||||
{
|
||||
ZTest Off
|
||||
Cull Off
|
||||
ZWrite Off
|
||||
Blend One One, One Zero
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vertDir
|
||||
#pragma fragment fragDir
|
||||
#pragma target 3.5
|
||||
#pragma exclude_renderers d3d9 gles
|
||||
|
||||
#define UNITY_HDR_ON
|
||||
|
||||
#pragma shader_feature HEIGHT_FOG
|
||||
#pragma shader_feature NOISE
|
||||
#pragma shader_feature SHADOWS_DEPTH
|
||||
#pragma shader_feature DIRECTIONAL_COOKIE
|
||||
#pragma shader_feature DIRECTIONAL
|
||||
|
||||
#ifdef SHADOWS_DEPTH
|
||||
#define SHADOWS_NATIVE
|
||||
#endif
|
||||
|
||||
v2f vertDir(appdata_img v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v); //Insert
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o); //Insert
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); //Ins
|
||||
o.pos = v.vertex * float4(2,2,1,1) + float4(-1,-1,0,0);
|
||||
o.uv.xy = v.texcoord.xy;
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
o.uv.y = 1.0f - o.uv.y; //blit flips the uv for some reason
|
||||
#endif
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 fragDir(v2f i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
float2 uv = i.uv.xy;
|
||||
|
||||
float depth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(uv, _CameraDepthTexture_ST));
|
||||
|
||||
float4x4 proj, eyeToWorld;
|
||||
if (unity_StereoEyeIndex == 0)
|
||||
{
|
||||
proj = _LeftViewFromScreen;
|
||||
eyeToWorld = _LeftWorldFromView;
|
||||
}
|
||||
else
|
||||
{
|
||||
proj = _RightViewFromScreen;
|
||||
eyeToWorld = _RightWorldFromView;
|
||||
}
|
||||
|
||||
//bit of matrix math to take the screen space coord (u,v,depth) and transform to world space
|
||||
float2 uvClip = i.uv * 2.0 - 1.0;
|
||||
float clipDepth = depth; // Fix for OpenGl Core thanks to Lars Bertram
|
||||
clipDepth = (UNITY_NEAR_CLIP_VALUE < 0) ? clipDepth * 2 - 1 : clipDepth;
|
||||
float4 clipPos = float4(uvClip, clipDepth, 1.0);
|
||||
float4 viewPos = mul(proj, clipPos); // inverse projection by clip position
|
||||
viewPos /= viewPos.w; // perspective division
|
||||
float3 wpos = mul(eyeToWorld, viewPos).xyz;
|
||||
|
||||
|
||||
//float3 wpos = i.interpolatedRay + _WorldSpaceCameraPos;
|
||||
|
||||
float linearDepth = Linear01Depth(depth);
|
||||
|
||||
float3 rayStart = _WorldSpaceCameraPos;
|
||||
float3 rayDir = wpos - _WorldSpaceCameraPos;
|
||||
|
||||
//Problem with VR?! Need more tests
|
||||
//rayDir *= linearDepth;
|
||||
|
||||
float rayLength = length(rayDir);
|
||||
rayDir /= rayLength;
|
||||
|
||||
rayLength = min(rayLength, _MaxRayLength);
|
||||
|
||||
float4 color = RayMarch(i.pos.xy, rayStart, rayDir, rayLength);
|
||||
|
||||
|
||||
if (linearDepth > 0.999999)
|
||||
{
|
||||
color.w = lerp(color.w, 1, _VolumetricLight.w);
|
||||
}
|
||||
|
||||
return color;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
// pass 5 - black
|
||||
Pass
|
||||
{
|
||||
ZTest Off
|
||||
Cull Off
|
||||
ZWrite Off
|
||||
Blend One One, One Zero
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vertW
|
||||
#pragma fragment fragW
|
||||
#pragma target 3.5
|
||||
#pragma exclude_renderers d3d9 gles
|
||||
|
||||
#ifdef SHADOWS_DEPTH
|
||||
#define SHADOWS_NATIVE
|
||||
#endif
|
||||
|
||||
|
||||
v2f vertW(appdata_img i)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(i); //Insert
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o); //Insert
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); //Ins
|
||||
half index = i.vertex.z;
|
||||
i.vertex.z = 0.1;
|
||||
o.pos = UnityObjectToClipPos(i.vertex);
|
||||
o.uv.xy = i.texcoord.xy;
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 fragW(v2f i) : SV_Target
|
||||
{
|
||||
return float4(0,0,0,0);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d9f3d22da4b08c84eb26827873f2a233
|
||||
timeCreated: 1459178237
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,175 +0,0 @@
|
||||
Shader "Enviro/Standard/Blit"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex("Base (RGB)", any) = "white" {}
|
||||
_CloudsTex("Clouds (RGB)", any) = "white" {}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Pass
|
||||
{
|
||||
Cull Off
|
||||
ZWrite Off
|
||||
Ztest LEqual
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
#pragma exclude_renderers gles
|
||||
#pragma multi_compile __ ENVIRO_DEPTHBLENDING
|
||||
|
||||
UNITY_DECLARE_SCREENSPACE_TEXTURE(_MainTex);
|
||||
uniform half4 _MainTex_ST;
|
||||
uniform half4 _MainTex_TexelSize;
|
||||
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
|
||||
uniform half4 _CameraDepthTexture_ST;
|
||||
|
||||
uniform UNITY_DECLARE_SCREENSPACE_TEXTURE(_SubFrame);
|
||||
uniform half4 _SubFrame_ST;
|
||||
uniform UNITY_DECLARE_SCREENSPACE_TEXTURE(_PrevFrame);
|
||||
uniform half4 _PrevFrame_ST;
|
||||
|
||||
uniform float4x4 _Projection;
|
||||
uniform float4x4 _ProjectionSPVR;
|
||||
uniform float4x4 _InverseProjection;
|
||||
uniform float4x4 _InverseProjectionSPVR;
|
||||
|
||||
uniform float4x4 _InverseRotation;
|
||||
uniform float4x4 _InverseRotationSPVR;
|
||||
|
||||
uniform float4x4 _PreviousRotation;
|
||||
uniform float4x4 _PreviousRotationSPVR;
|
||||
|
||||
uniform float _FrameNumber;
|
||||
uniform float _ReprojectionPixelSize;
|
||||
|
||||
uniform float2 _SubFrameDimension;
|
||||
uniform float2 _FrameDimension;
|
||||
|
||||
|
||||
struct v2f {
|
||||
float4 position : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float2 uv1 : TEXCOORD1;
|
||||
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f vert(appdata_img v)
|
||||
{
|
||||
v2f o;
|
||||
|
||||
UNITY_SETUP_INSTANCE_ID(v); //Insert
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o); //Insert
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); //Insert
|
||||
|
||||
o.position = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.texcoord;
|
||||
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
o.uv1 = v.texcoord.xy;
|
||||
if (_MainTex_TexelSize.y < 0)
|
||||
o.uv1.y = 1 - o.uv1.y;
|
||||
#endif
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 frag(v2f i) : COLOR
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
float4 main = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1, _MainTex_ST));
|
||||
#else
|
||||
float4 main = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv, _MainTex_ST));
|
||||
#endif
|
||||
|
||||
float4 final = main;
|
||||
|
||||
|
||||
#ifndef ENVIRO_DEPTHBLENDING
|
||||
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
float depthSample = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST));
|
||||
#else
|
||||
float depthSample = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _CameraDepthTexture_ST));
|
||||
#endif
|
||||
|
||||
depthSample = Linear01Depth(depthSample);
|
||||
|
||||
if (depthSample > 0.9999)
|
||||
{
|
||||
#endif
|
||||
|
||||
float2 uv = (floor(i.uv * _FrameDimension) + 0.5) / _FrameDimension;
|
||||
float2 uv2 = (floor(i.uv * _SubFrameDimension) + 0.5) / _SubFrameDimension;
|
||||
|
||||
float x = fmod(uv.x, _ReprojectionPixelSize);
|
||||
float y = fmod(uv.y, _ReprojectionPixelSize);
|
||||
float currentFrame = y * _ReprojectionPixelSize + x;
|
||||
|
||||
float4 cloud;
|
||||
|
||||
if (currentFrame == _FrameNumber)
|
||||
{
|
||||
cloud = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_SubFrame, UnityStereoScreenSpaceUVAdjust(uv2, _MainTex_ST));
|
||||
}
|
||||
else
|
||||
{
|
||||
float4 reprojection;
|
||||
float4 pos = float4(i.uv * 2.0 - 1.0, 1.0, 1.0);
|
||||
|
||||
#if UNITY_SINGLE_PASS_STEREO || ENVIRO_SINGLEPASSINSTANCED
|
||||
if (unity_StereoEyeIndex == 0)
|
||||
{
|
||||
pos = mul(_InverseProjection, pos);
|
||||
pos = pos / pos.w;
|
||||
pos.xyz = mul((float3x3)_InverseRotation, pos.xyz);
|
||||
pos.xyz = mul((float3x3)_PreviousRotation, pos.xyz);
|
||||
|
||||
reprojection = mul(_Projection, pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
pos = mul(_InverseProjectionSPVR, pos);
|
||||
pos = pos / pos.w;
|
||||
pos.xyz = mul((float3x3)_InverseRotationSPVR, pos.xyz);
|
||||
pos.xyz = mul((float3x3)_PreviousRotationSPVR, pos.xyz);
|
||||
|
||||
reprojection = mul(_ProjectionSPVR, pos);
|
||||
}
|
||||
#else
|
||||
pos = mul(_InverseProjection, pos);
|
||||
pos = pos / pos.w;
|
||||
pos.xyz = mul((float3x3)_InverseRotation, pos.xyz);
|
||||
pos.xyz = mul((float3x3)_PreviousRotation, pos.xyz);
|
||||
|
||||
reprojection = mul(_Projection, pos);
|
||||
#endif
|
||||
|
||||
if (reprojection.y < 0.0 || reprojection.y > 1.0 || reprojection.x < 0.0 || reprojection.x > 1.0)
|
||||
{
|
||||
cloud = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_SubFrame, UnityStereoScreenSpaceUVAdjust(i.uv, _MainTex_ST));
|
||||
}
|
||||
else
|
||||
{
|
||||
cloud = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_PrevFrame, UnityStereoScreenSpaceUVAdjust(reprojection.xy, _MainTex_ST));
|
||||
}
|
||||
}
|
||||
|
||||
final = float4 (main * (1 - cloud.a) + cloud.rgb * cloud.a, 1.0);
|
||||
|
||||
#ifndef ENVIRO_DEPTHBLENDING
|
||||
}
|
||||
#endif
|
||||
return final;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cb6002680e4d34e4f8df84689f672fcb
|
||||
timeCreated: 1506988736
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
-98
@@ -1,98 +0,0 @@
|
||||
Shader "Hidden/Enviro/Upsample"
|
||||
{
|
||||
SubShader
|
||||
{
|
||||
Pass
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off Fog{ Mode Off }
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
UNITY_DECLARE_SCREENSPACE_TEXTURE(_LowResTexture);
|
||||
UNITY_DECLARE_SCREENSPACE_TEXTURE(_CameraDepthLowRes);
|
||||
UNITY_DECLARE_SCREENSPACE_TEXTURE(_MainTex);
|
||||
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
|
||||
float2 _LowResPixelSize;
|
||||
float2 _LowResTextureSize;
|
||||
float _DepthMult;
|
||||
float _Threshold;
|
||||
float4 _MainTex_TexelSize;
|
||||
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float4 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float2 uv00 : TEXCOORD1;
|
||||
float2 uv10 : TEXCOORD2;
|
||||
float2 uv01 : TEXCOORD3;
|
||||
float2 uv11 : TEXCOORD4;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = UnityStereoTransformScreenSpaceTex(v.uv);
|
||||
o.uv00 = v.uv - 0.5 * _LowResPixelSize;
|
||||
o.uv10 = o.uv00 + float2(_LowResPixelSize.x, 0.0);
|
||||
o.uv01 = o.uv00 + float2(0.0, _LowResPixelSize.y);
|
||||
o.uv11 = o.uv00 + _LowResPixelSize;
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 ClosestDepthFast(v2f i)
|
||||
{
|
||||
float z00 = DecodeFloatRGBA(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_CameraDepthLowRes, i.uv00));
|
||||
float z10 = DecodeFloatRGBA(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_CameraDepthLowRes, i.uv10));
|
||||
float z01 = DecodeFloatRGBA(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_CameraDepthLowRes, i.uv01));
|
||||
float z11 = DecodeFloatRGBA(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_CameraDepthLowRes, i.uv11));
|
||||
|
||||
float zfull = Linear01Depth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, i.uv));
|
||||
|
||||
float dist00 = abs(z00 - zfull);
|
||||
float dist10 = abs(z10 - zfull);
|
||||
float dist01 = abs(z01 - zfull);
|
||||
float dist11 = abs(z11 - zfull);
|
||||
|
||||
float3 uvd00 = float3(i.uv00, dist00);
|
||||
float3 uvd10 = float3(i.uv10, dist10);
|
||||
float3 uvd01 = float3(i.uv01, dist01);
|
||||
float3 uvd11 = float3(i.uv11, dist11);
|
||||
|
||||
float3 finalUV = lerp(uvd10, uvd00, saturate(99999 * (uvd10.z - uvd00.z)));
|
||||
finalUV = lerp(uvd01, finalUV, saturate(99999 * (uvd01.z - finalUV.z)));
|
||||
finalUV = lerp(uvd11, finalUV, saturate(99999 * (uvd11.z - finalUV.z)));
|
||||
|
||||
float maxDist = max(max(max(dist00, dist10), dist01), dist11) - _Threshold;
|
||||
|
||||
fixed r = saturate(maxDist * 99999);
|
||||
float2 uv = lerp(i.uv, finalUV.xy, r);
|
||||
return UNITY_SAMPLE_SCREENSPACE_TEXTURE(_LowResTexture, uv);
|
||||
}
|
||||
|
||||
fixed4 frag(v2f i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
return ClosestDepthFast(i);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
Fallback Off
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6e6470b3792ea7f45a1ad88440d75c5a
|
||||
timeCreated: 1554514626
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
-58
@@ -1,58 +0,0 @@
|
||||
Shader "Hidden/Enviro/DepthDownsample"
|
||||
{
|
||||
|
||||
CGINCLUDE
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
|
||||
float2 _PixelSize;
|
||||
float4 _MainTex_TexelSize;
|
||||
|
||||
v2f vert(appdata_img v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.texcoord.xy;
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 frag(v2f i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
|
||||
float d = Linear01Depth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, i.uv));
|
||||
|
||||
if (d>0.99999)
|
||||
return half4(1,1,1,1);
|
||||
else
|
||||
return EncodeFloatRGBA(d);
|
||||
}
|
||||
|
||||
ENDCG
|
||||
|
||||
|
||||
Subshader
|
||||
{
|
||||
Pass
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
Fallback off
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 897d02806d3ff664f9e08ff9e5d23ba1
|
||||
timeCreated: 1554514794
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
-114
@@ -1,114 +0,0 @@
|
||||
Shader "Enviro/Standard/FlatCloudMap" {
|
||||
Properties{
|
||||
|
||||
}
|
||||
SubShader{
|
||||
Tags { "RenderType" = "Opaque" }
|
||||
LOD 200
|
||||
Pass {
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
#pragma target 3.0
|
||||
#pragma exclude_renderers gles
|
||||
|
||||
uniform sampler2D _NoiseTex;
|
||||
uniform float _Softness = 0.2;
|
||||
uniform float _Coverage = 0.6;
|
||||
uniform float _Brightness = 1.0;
|
||||
uniform float _CloudScale = 2.5;
|
||||
uniform float2 _CloudAnimation;
|
||||
uniform int noiseOctaves = 8;
|
||||
uniform float _MorphingSpeed;
|
||||
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 Position : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 pos : TEXCOORD1;
|
||||
};
|
||||
|
||||
v2f vert(appdata_img v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o);
|
||||
o.Position = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.texcoord;
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
return o;
|
||||
}
|
||||
|
||||
float noise(float2 uv)
|
||||
{
|
||||
return tex2D(_NoiseTex, uv).r;
|
||||
}
|
||||
|
||||
float2 rotate(float2 uv)
|
||||
{
|
||||
float curlStrain = 3.0;
|
||||
uv = uv + noise(uv*0.2)*0.005;
|
||||
float rot = curlStrain;
|
||||
float sinRot = sin(rot);
|
||||
float cosRot = cos(rot);
|
||||
float2x2 rotMat = float2x2(cosRot, -sinRot, sinRot, cosRot);
|
||||
return mul(rotMat,uv);
|
||||
}
|
||||
|
||||
float fbm(float2 uv)
|
||||
{
|
||||
float rot = 1.57;
|
||||
float sinRot = sin(rot);
|
||||
float cosRot = cos(rot);
|
||||
float f = 0.0;
|
||||
float total = 0.0;
|
||||
float mul = 0.5;
|
||||
float2x2 rotMat = float2x2(cosRot, -sinRot, sinRot, cosRot);
|
||||
float timeScale = 10.0;
|
||||
|
||||
for (int i = 0; i < noiseOctaves; i++)
|
||||
{
|
||||
f += noise(uv + _Time.y * (_MorphingSpeed * 0.0001) * timeScale * (1.0 - mul)) * mul;
|
||||
total += mul;
|
||||
uv *= 3.0;
|
||||
uv = rotate(uv);
|
||||
mul *= 0.5;
|
||||
}
|
||||
return f / total;
|
||||
}
|
||||
|
||||
float4 frag(v2f i) : SV_Target
|
||||
{
|
||||
|
||||
float timeScale = 2.0;
|
||||
float2 uv = i.pos.xy / (20.0 * _CloudScale);
|
||||
|
||||
float bright = _Brightness;
|
||||
|
||||
float color1 = fbm(uv - 0.5 + -_CloudAnimation * 0.1);
|
||||
float color2 = fbm(uv - 10.5 + -_CloudAnimation * 0.2);
|
||||
|
||||
float clouds1 = smoothstep(1.0 - _Coverage, min((1.0 - _Coverage) + _Softness * 2.0, 1.0), color1);
|
||||
float clouds2 = smoothstep(1.0 - _Coverage, min((1.0 - _Coverage) + _Softness, 1.0), color2);
|
||||
|
||||
float cloudsFormComb = saturate(clouds1 + clouds2);
|
||||
|
||||
float4 skyCol = float4(1,1,1,0.0);
|
||||
float cloudCol = saturate(saturate(1.0 - pow(color1, 1.0) * 0.2) * bright);
|
||||
float cloudCol2 = saturate(saturate(1.0 - pow(color2, 1.0) * 0.5) * bright);
|
||||
|
||||
float4 clouds1Color = float4(cloudCol, cloudCol, cloudCol, cloudsFormComb);
|
||||
float4 clouds2Color = lerp(clouds1Color, float4(cloudCol2, cloudCol2, cloudCol2, cloudCol2), clouds2);
|
||||
float4 cloudColComb = lerp(clouds1Color, clouds2Color, saturate(clouds2 - clouds1));
|
||||
|
||||
float4 final = lerp(skyCol, cloudColComb, cloudsFormComb);
|
||||
|
||||
return float4(final.rgb, cloudsFormComb);
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
FallBack "Diffuse"
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c1cfc743f76fac6449270514fc84b6f7
|
||||
timeCreated: 1507124107
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
-107
@@ -1,107 +0,0 @@
|
||||
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
|
||||
|
||||
Shader "Enviro/Standard/MoonShaderPhased"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Moon Texture", 2D) = "white" {}
|
||||
_Phase ("Moon Phase", float) = 0
|
||||
_Brightness ("Moon Brightness", Range(0.1,5)) = 0.5
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{"Queue"="Transparent"
|
||||
"RenderType"="Transparent"
|
||||
"IgnoreProjector"="True"
|
||||
}
|
||||
|
||||
Fog
|
||||
{
|
||||
Mode Off
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Cull Back
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
float _Phase;
|
||||
float _Brightness;
|
||||
|
||||
struct v2f {
|
||||
float4 position : POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 uv_MainTex : TEXCOORD0;
|
||||
float3 normal : TEXCOORD1;
|
||||
float3 viewdir : TEXCOORD2;
|
||||
};
|
||||
|
||||
float MoonPhaseFactor(float2 uv, float phase)
|
||||
{
|
||||
float alpha = 1.0;
|
||||
|
||||
float srefx = uv.x - 0.5;
|
||||
float refx = abs(uv.x - 0.5);
|
||||
float refy = abs(uv.y - 0.5);
|
||||
float refxfory = sqrt(0.25 - refy * refy);
|
||||
float xmin = -refxfory;
|
||||
float xmax = refxfory;
|
||||
float xmin1 = (xmax - xmin) * (phase / 2) + xmin;
|
||||
float xmin2 = (xmax - xmin) * phase + xmin;
|
||||
if (srefx < xmin1) {
|
||||
alpha = 0;
|
||||
} else if (srefx < xmin2 && xmin1 != xmin2) {
|
||||
alpha = (srefx - xmin1) / (xmin2 - xmin1);
|
||||
}
|
||||
return alpha;
|
||||
}
|
||||
|
||||
v2f vert(appdata_base v) {
|
||||
v2f o;
|
||||
|
||||
float phaseabs = abs(_Phase);
|
||||
float3 offset = 10 * float3(_Phase, -phaseabs, -phaseabs);
|
||||
|
||||
float3 normal = v.normal;
|
||||
float3 viewdir = normalize(ObjSpaceViewDir(v.vertex));
|
||||
|
||||
o.position = UnityObjectToClipPos(v.vertex);
|
||||
o.color.rgb = 1 - phaseabs;
|
||||
o.color.a = 1;
|
||||
o.uv_MainTex = TRANSFORM_TEX(v.texcoord, _MainTex);
|
||||
o.normal = v.normal;
|
||||
o.viewdir = normalize(viewdir + offset);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag(v2f i) : COLOR {
|
||||
fixed4 color = i.color;
|
||||
|
||||
float alpha = MoonPhaseFactor(i.uv_MainTex, abs(_Phase));
|
||||
fixed shading = max(0, dot(i.normal, i.viewdir));
|
||||
color.rgb *= pow(shading, 0.5);
|
||||
|
||||
// Moon texture
|
||||
fixed3 moontex = tex2D(_MainTex, i.uv_MainTex);
|
||||
color.rgb *= moontex.rgb * 2.5;
|
||||
|
||||
float lum = dot(color.rgb, float3(0.8, 0.8, 0.8));
|
||||
color.a = min(color.a, lum * alpha);
|
||||
color.rgb = saturate(1.0 - exp(-_Brightness * color.rgb));
|
||||
return color;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7a0acf2dae5705a47b6458d7c791cace
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
-419
@@ -1,419 +0,0 @@
|
||||
Shader "Enviro/Standard/RaymarchClouds"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Cull Off ZWrite Off ZTest Always
|
||||
|
||||
Tags{ "RenderType" = "Opaque" }
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 3.0
|
||||
#pragma exclude_renderers gles d3d9
|
||||
#pragma multi_compile __ UNITY_COLORSPACE_GAMMA
|
||||
#pragma multi_compile __ ENVIRO_DEPTHBLENDING
|
||||
#pragma multi_compile __ ENVIRO_CURLNOISE
|
||||
#pragma multi_compile __ ENVIRO_HALTONOFFSET
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "../../../Core/Resources/Shaders/Core/EnviroFogCore.cginc"
|
||||
#include "Core/EnviroVolumeCloudsCore.cginc"
|
||||
|
||||
uniform half4 _MainTex_ST;
|
||||
float4x4 _LeftWorldFromView;
|
||||
float4x4 _RightWorldFromView;
|
||||
float4x4 _LeftViewFromScreen;
|
||||
float4x4 _RightViewFromScreen;
|
||||
|
||||
#ifdef ENVIRO_HALTONOFFSET
|
||||
float _RaymarchOffset;
|
||||
float4 _TexelSize;
|
||||
#else
|
||||
#define BAYER_FACTOR (1.0/16.0)
|
||||
const float bayerFilter[16] =
|
||||
{
|
||||
0.0*(1.0 / 16.0) ,
|
||||
8.0*(1.0 / 16.0),
|
||||
2.0*(1.0 / 16.0),
|
||||
10.0*(1.0 / 16.0),
|
||||
12.0*(1.0 / 16.0),
|
||||
4.0*(1.0 / 16.0),
|
||||
14.0*(1.0 / 16.0),
|
||||
6.0*(1.0 / 16.0),
|
||||
3.0*(1.0 / 16.0),
|
||||
11.0*(1.0 / 16.0),
|
||||
1.0*(1.0 / 16.0),
|
||||
9.0*(1.0 / 16.0),
|
||||
15.0*(1.0 / 16.0),
|
||||
7.0*(1.0 / 16.0),
|
||||
13.0*(1.0 / 16.0),
|
||||
5.0*(1.0 / 16.0)
|
||||
};
|
||||
#endif
|
||||
float3 ScreenSpaceDither(float2 vScreenPos, float3 clr)
|
||||
{
|
||||
float d = dot(float2(131.0, 312.0), vScreenPos.xy + _Time.y);
|
||||
float3 vDither = float3(d, d, d);
|
||||
vDither.rgb = frac(vDither.rgb / float3(103.0, 71.0, 97.0)) - float3(0.5, 0.5, 0.5);
|
||||
return (vDither.rgb / 15.0) * 1.0 * Luminance(clr);
|
||||
}
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 position : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float3 sky : TEXCOORD1;
|
||||
float4 screenPos : TEXCOORD2;
|
||||
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
|
||||
v2f vert(appdata_img v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
o.position = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.texcoord;
|
||||
o.sky.x = saturate(_SunDir.y + 0.25);
|
||||
o.sky.y = saturate(clamp(1.0 - _SunDir.y, 0.0, 0.5));
|
||||
o.screenPos = ComputeScreenPos(o.position);
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
float4 frag(v2f i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
|
||||
|
||||
//return lerp(float4(1, 1, 1, 1), float4(0, 0, 0, 0), unity_StereoEyeIndex);
|
||||
|
||||
|
||||
float4 cameraRay = float4(i.uv * 2.0 - 1.0, 1.0, 1.0);
|
||||
//World Space
|
||||
float3 EyePosition = _CameraPosition;
|
||||
float3 EyePositionDepth = _WorldSpaceCameraPos;
|
||||
//Workaround for large scale games where player position will be resetted.
|
||||
//float3 EyePosition = float3(0.0,_CameraPosition.y, 0.0);
|
||||
|
||||
float2 sPos = i.position.xy;
|
||||
|
||||
float3 ray = 0;
|
||||
|
||||
//#if UNITY_SINGLE_PASS_STEREO
|
||||
if (unity_StereoEyeIndex == 0)
|
||||
{
|
||||
cameraRay = mul(_InverseProjection, cameraRay);
|
||||
cameraRay = cameraRay / cameraRay.w;
|
||||
ray = normalize(mul((float3x3)_InverseRotation, cameraRay.xyz));
|
||||
}
|
||||
else
|
||||
{
|
||||
cameraRay = mul(_InverseProjection_SP, cameraRay);
|
||||
cameraRay = cameraRay / cameraRay.w;
|
||||
ray = normalize(mul((float3x3)_InverseRotation_SP, cameraRay.xyz));
|
||||
}
|
||||
//#else
|
||||
// cameraRay = mul(_InverseProjection, cameraRay);
|
||||
// cameraRay = cameraRay / cameraRay.w;
|
||||
// ray = normalize(mul((float3x3)_InverseRotation, cameraRay.xyz));
|
||||
//#endif
|
||||
|
||||
float rawDepth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoTransformScreenSpaceTex(i.uv));
|
||||
bool depthPresent = rawDepth > 0.0;
|
||||
float dpth = Linear01Depth(rawDepth);
|
||||
|
||||
#ifdef ENVIRO_DEPTHBLENDING
|
||||
float4x4 proj, eyeToWorld;
|
||||
|
||||
if (unity_StereoEyeIndex == 0)
|
||||
{
|
||||
proj = _LeftViewFromScreen;
|
||||
eyeToWorld = _LeftWorldFromView;
|
||||
}
|
||||
else
|
||||
{
|
||||
proj = _RightViewFromScreen;
|
||||
eyeToWorld = _RightWorldFromView;
|
||||
}
|
||||
|
||||
//bit of matrix math to take the screen space coord (u,v,depth) and transform to world space
|
||||
float2 uvClip = i.uv * 2.0 - 1.0;
|
||||
float clipDepth = rawDepth; // Fix for OpenGl Core thanks to Lars Bertram
|
||||
clipDepth = (UNITY_NEAR_CLIP_VALUE < 0) ? clipDepth * 2 - 1 : clipDepth;
|
||||
float4 clipPos = float4(uvClip, clipDepth, 1.0);
|
||||
float4 viewPos = mul(proj, clipPos); // inverse projection by clip position
|
||||
viewPos /= viewPos.w; // perspective division
|
||||
float4 wsPos = float4(mul(eyeToWorld, viewPos).xyz, 1);
|
||||
float4 wsDir = wsPos - float4(EyePosition, 0);
|
||||
float3 viewDir = normalize(wsDir);
|
||||
#endif
|
||||
|
||||
float4 sky = ComputeScatteringClouds(ray, i.sky.xy, _gameTime);
|
||||
float4 color = float4(0,0,0,1);
|
||||
|
||||
float3 LightDirection = _LightDir;
|
||||
float3 LightColor = _LightColor.rgb;
|
||||
|
||||
//Switch to Moon Light Color
|
||||
if (_CloudDensityScale.w < _CloudDensityScale.z)
|
||||
LightColor = _MoonLightColor.rgb;
|
||||
|
||||
float pRad = _CloudsParameter.w;
|
||||
float3 pCent = float3(EyePosition.x, -pRad, EyePosition.z);
|
||||
|
||||
float3 startPos;
|
||||
float3 endPos;
|
||||
|
||||
// find nearest inner shell point
|
||||
float2 ih = 0.0f;
|
||||
uint innerShellHits = intersectRaySphere(
|
||||
EyePosition,
|
||||
ray,
|
||||
pCent,
|
||||
pRad + _CloudsParameter.x,
|
||||
ih);
|
||||
|
||||
// find nearest outer shell point
|
||||
float2 oh = 0.0f;
|
||||
uint outerShellHits = intersectRaySphere(
|
||||
EyePosition,
|
||||
ray,
|
||||
pCent,
|
||||
pRad + _CloudsParameter.y,
|
||||
oh);
|
||||
|
||||
// world space ray intersections
|
||||
float3 innerShellHit = EyePositionDepth + (ray * ih.x);
|
||||
float3 outerShellHit = EyePositionDepth + (ray * oh.x);
|
||||
|
||||
float2 hitDistance;
|
||||
// eye radius from planet center
|
||||
float ch = length(EyePosition - pCent) - _CloudsParameter.w;
|
||||
|
||||
if (ch < _CloudsParameter.x)
|
||||
{
|
||||
|
||||
#ifdef ENVIRO_DEPTHBLENDING
|
||||
// exit if there's something in front of the start of the cloud volume
|
||||
if ((depthPresent && (distance(wsPos, EyePositionDepth) < distance(innerShellHit, EyePositionDepth))) || ray.y < -0.05) // shell hits are guaranteed, but the ground may be occluding cloud layer
|
||||
{
|
||||
return float4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
#else
|
||||
|
||||
if (ray.y < -0.02)
|
||||
return float4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
#endif
|
||||
|
||||
endPos = outerShellHit;
|
||||
|
||||
hitDistance = float2(ih.x, oh.x);
|
||||
}
|
||||
else if (ch > _CloudsParameter.y)
|
||||
{
|
||||
float3 firstShellHit = outerShellHit;
|
||||
float3 secondShellHit = outerShellHits == 2u && innerShellHits == 0u ? EyePosition + (ray * oh.y) : innerShellHit;
|
||||
|
||||
#ifdef ENVIRO_DEPTHBLENDING
|
||||
if (outerShellHits == 0u || depthPresent && (distance(wsPos, EyePositionDepth) <= distance(firstShellHit, EyePositionDepth)))
|
||||
{
|
||||
return float4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
#endif
|
||||
|
||||
endPos = secondShellHit;
|
||||
|
||||
float hit2 = outerShellHits == 2u && innerShellHits == 0u ? oh.y : ih.x;
|
||||
hitDistance = float2(oh.x, hit2);
|
||||
|
||||
}
|
||||
else // between shells
|
||||
{
|
||||
float3 shellHit = innerShellHits > 0u ? innerShellHit : outerShellHit;
|
||||
float hit = innerShellHits > 0u ? ih.x : oh.x;
|
||||
float height = Remap(EyePosition.y, _CloudsParameter.x, _CloudsParameter.y, 0, 1);
|
||||
hitDistance = ResolveInside(EyePosition.xyz, ray, lerp(25000, 100000, height));
|
||||
|
||||
#ifdef ENVIRO_DEPTHBLENDING
|
||||
if (depthPresent && (distance(wsPos, EyePositionDepth) < distance(shellHit, EyePositionDepth)))
|
||||
{
|
||||
shellHit = wsPos;
|
||||
hitDistance.y = (wsPos - EyePositionDepth) / viewDir;
|
||||
}
|
||||
#endif
|
||||
endPos = shellHit;
|
||||
|
||||
//float reducedDistance = 500 * (1.0 + 0.0) / (1 * lerp(1.0, 0.015, smoothstep(-0.2, -0.6, 0.1)));
|
||||
//hit = min(hit, 0.0 + reducedDistance);
|
||||
//hitDistance = float2(0.0, hit);
|
||||
}
|
||||
|
||||
hitDistance.x = max(0.0, hitDistance.x);
|
||||
///
|
||||
|
||||
int steps = (int)lerp(_Steps.x, _Steps.x, ray.y);
|
||||
float rayStepLength = (1 * (hitDistance.y - hitDistance.x) / steps);
|
||||
float3 rayStep = ray * rayStepLength;
|
||||
|
||||
#ifdef ENVIRO_HALTONOFFSET
|
||||
const float bayerOffsets[3][3] = {
|
||||
{ 0, 7, 3 },
|
||||
{ 6, 5, 2 },
|
||||
{ 4, 1, 8 }
|
||||
};
|
||||
|
||||
float2 screenPos = i.screenPos.xy / i.screenPos.w;
|
||||
int2 texelID = int2(fmod(screenPos / _TexelSize, 3.0)); //Calculate a texel id to index bayer matrix.
|
||||
|
||||
float bayerOffset = (bayerOffsets[texelID.x][texelID.y]) / 9.0f; //bayeroffset between[0,1)
|
||||
float offset = -fmod(_RaymarchOffset + bayerOffset, 1.0f); //final offset combined. The value will be multiplied by sample step in GetDensity.
|
||||
|
||||
float3 pos = (EyePosition + (hitDistance.x + offset * rayStepLength) * ray);
|
||||
rayStepLength = rayStepLength * offset;
|
||||
|
||||
#else
|
||||
float3 pos = (EyePosition + (hitDistance.x + rayStepLength) * ray);
|
||||
uint a = uint(i.uv.x) % 4;
|
||||
uint b = uint(i.uv.y) % 4;
|
||||
pos += bayerFilter[a * 4 + b] * rayStep;
|
||||
#endif
|
||||
|
||||
float cloud_test = 0.0;
|
||||
int zero_density_sample_count = 0;
|
||||
float sampled_density_previous = -1.0;
|
||||
float ds = 0.0;
|
||||
float trans = 1.0;
|
||||
float intensity = 0.0;
|
||||
float alpha = 1.0;
|
||||
float eyeToEnd = distance(EyePosition, endPos);
|
||||
float lod = saturate((0.5 - Remap(eyeToEnd, 0, _CloudsParameter.w * 0.1, 0, 1.25) ) * 1.25);
|
||||
float inScatteringAngle = dot(normalize(ray), normalize(LightDirection));
|
||||
|
||||
#ifndef ENVIRO_DEPTHBLENDING
|
||||
// Reduce steps when rendering behind objects.
|
||||
if (dpth < 1)
|
||||
steps *= _stepsInDepth;
|
||||
#else
|
||||
#endif
|
||||
//Raymarching
|
||||
[loop]
|
||||
for (int i = 0; i < steps; i++)
|
||||
{
|
||||
|
||||
#ifdef ENVIRO_HALTONOFFSET
|
||||
pos += rayStep;
|
||||
#endif
|
||||
//Calculate projection height
|
||||
float height = GetSamplingHeight(pos, pCent);
|
||||
|
||||
//Get out of expensive raymarching
|
||||
if (alpha <= 0.01 || height > 1.0 || height < 0.0 || _CloudsCoverageSettings.x <= -0.9)
|
||||
break;
|
||||
|
||||
// Get Weather Data
|
||||
float3 weather = GetWeather(pos);
|
||||
|
||||
if (cloud_test > 0.0)
|
||||
{
|
||||
float sampled_density = CalculateCloudDensity(pos, pCent, weather, 0, lod, true);
|
||||
|
||||
if (sampled_density == 0.0 && sampled_density_previous == 0.0)
|
||||
{
|
||||
zero_density_sample_count++;
|
||||
}
|
||||
|
||||
if (zero_density_sample_count < 11 && sampled_density != 0.0)
|
||||
{
|
||||
float dl = GetDensityAlongRay(pos, pCent, LightDirection, weather, lod);
|
||||
ds += saturate(sampled_density);
|
||||
|
||||
float extinction = _CloudDensityScale.x * sampled_density;
|
||||
float transmittance = exp(-extinction );
|
||||
|
||||
float hg = max(HenryGreenstein(inScatteringAngle, _CloudsLighting.y) * 0.5, _CloudsLighting.z * 2 * HenryGreenstein(inScatteringAngle, 0.99 - _CloudsLighting.w));
|
||||
float luminance = GetLightEnergy(pos, height, dl, ds, hg, inScatteringAngle, rayStepLength, _CloudsLighting.x, weather);
|
||||
|
||||
float integScatt = (luminance - luminance * transmittance);
|
||||
|
||||
intensity += trans * integScatt;
|
||||
trans *= transmittance;
|
||||
alpha *= max(trans, 0.0);
|
||||
|
||||
float3 sunLight = pow(LightColor, 2) * _LightIntensity;
|
||||
sunLight.rgb = sunLight.rgb * intensity * saturate(alpha);
|
||||
color.rgb += sunLight.rgb;
|
||||
|
||||
if (alpha <= _CloudsCoverageSettings.z)
|
||||
alpha = 0.0;
|
||||
}
|
||||
// if not, then set cloud_test to zero so that we go back to the cheap sample case
|
||||
else
|
||||
{
|
||||
cloud_test = 0.0;
|
||||
zero_density_sample_count = 0;
|
||||
}
|
||||
|
||||
sampled_density_previous = sampled_density;
|
||||
}
|
||||
else
|
||||
{
|
||||
// sample density the cheap way, only using the low frequency noise
|
||||
cloud_test = CalculateCloudDensity(pos, pCent, weather, 0, lod, false);
|
||||
|
||||
if (cloud_test == 0.0)
|
||||
{
|
||||
pos += rayStep * 2;
|
||||
}
|
||||
else //take a step back and capture area we skipped.
|
||||
{
|
||||
pos -= rayStep;
|
||||
}
|
||||
}
|
||||
#ifndef ENVIRO_HALTONOFFSET
|
||||
pos += rayStep;
|
||||
#endif
|
||||
}
|
||||
|
||||
color.a = saturate(1 - alpha);
|
||||
|
||||
// Ambient Lighting
|
||||
float3 ambientColor = (sky.rgb * _AmbientLightColor.rgb);
|
||||
color = color + float4(ambientColor * _AmbientSkyColorIntensity * _CloudsLightingExtended.y, 0) * saturate(1 - (color));
|
||||
|
||||
//Tonemapping
|
||||
if (_CloudsLightingExtended.z == 0)
|
||||
{
|
||||
color.rgb = tonemapACES(color.rgb, _CloudsLightingExtended.w);
|
||||
}
|
||||
|
||||
//Dithering
|
||||
color.rgb += ScreenSpaceDither(sPos, color.rgb);
|
||||
|
||||
|
||||
#if defined(UNITY_COLORSPACE_GAMMA)
|
||||
color.rgb = LinearToGammaSpace(color.rgb);
|
||||
#endif
|
||||
return color;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8e7d19434a8599346833ad990a557ac5
|
||||
timeCreated: 1472025985
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
-54
@@ -1,54 +0,0 @@
|
||||
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
|
||||
|
||||
Shader "Enviro/Standard/ShadowCookie"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Texture", 2D) = "white" {}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
// No culling or depth
|
||||
Cull Off ZWrite Off ZTest Always
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 2.0
|
||||
#include "UnityCG.cginc"
|
||||
#pragma exclude_renderers gles
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.uv;
|
||||
return o;
|
||||
}
|
||||
|
||||
uniform sampler2D _MainTex;
|
||||
uniform float _shadowIntensity;
|
||||
uniform int _shadowMode;
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
fixed4 col = 1 - (tex2D(_MainTex, i.uv) * _shadowIntensity);
|
||||
return float4(col.r,col.r,col.r,col.r);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 46afaaf9d09758a48b16c30a783221a8
|
||||
timeCreated: 1512200192
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
-469
@@ -1,469 +0,0 @@
|
||||
|
||||
Shader "Enviro/Standard/Skybox"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_Stars("Stars Cubemap", Cube) = "black" {}
|
||||
_StarsTwinklingNoise("Stars Noise", Cube) = "black" {}
|
||||
_Galaxy("Galaxy Cubemap", Cube) = "black" {}
|
||||
_SatTex("Satellites Tex", 2D) = "black" {}
|
||||
_MoonTex("Moon Tex", 2D) = "black" {}
|
||||
_GlowTex("Glow Tex", 2D) = "black" {}
|
||||
_Aurora_Layer_1("Aurora Layer 1", 2D) = "black" {}
|
||||
_Aurora_Layer_2("Aurora Layer 2", 2D) = "black" {}
|
||||
_Aurora_Colorshift("Aurora Color Shift", 2D) = "black" {}
|
||||
//_Background("Background Cubemap", Cube) = "black" {}
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags{ "Queue" = "Background" "RenderType" = "Background" "PreviewType" = "Skybox" }
|
||||
Cull Off
|
||||
Fog{ Mode Off }
|
||||
ZWrite Off
|
||||
|
||||
Pass
|
||||
{
|
||||
|
||||
CGPROGRAM
|
||||
#pragma target 3.0
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile __ UNITY_COLORSPACE_GAMMA
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
uniform float3 _Br;
|
||||
uniform float3 _Bm;
|
||||
uniform float3 _mieG;
|
||||
uniform float _SunIntensity;
|
||||
uniform float _Tonemapping;
|
||||
uniform float _SkyExposure;
|
||||
uniform float _SkyLuminance;
|
||||
uniform float _scatteringPower;
|
||||
uniform float _SunDiskSize;
|
||||
uniform float _SunDiskIntensity;
|
||||
uniform float _StarsIntensity;
|
||||
uniform float4 _scatteringColor;
|
||||
uniform float4 _sunDiskColor;
|
||||
uniform samplerCUBE _Stars;
|
||||
uniform samplerCUBE _StarsTwinklingNoise;
|
||||
uniform float4x4 _StarsMatrix;
|
||||
uniform float4x4 _StarsTwinklingMatrix;
|
||||
uniform float _SkyColorPower;
|
||||
uniform float3 _SunDir;
|
||||
uniform float3 _MoonDir;
|
||||
uniform float4 _weatherSkyMod;
|
||||
uniform float4 _moonGlowColor;
|
||||
uniform sampler2D _MoonTex;
|
||||
uniform sampler2D _GlowTex;
|
||||
uniform sampler2D _SatTex;
|
||||
uniform float4 _MoonColor;
|
||||
uniform float4 _moonParams;
|
||||
uniform float _GalaxyIntensity;
|
||||
uniform samplerCUBE _Galaxy;
|
||||
uniform int _blackGround;
|
||||
uniform float _StarsTwinkling;
|
||||
uniform float _DitheringIntensity;
|
||||
|
||||
//uniform samplerCUBE _Background;
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float3 texcoord : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 Position : SV_POSITION;
|
||||
float4 moonPos : TEXCOORD0;
|
||||
float4 sky : TEXCOORD1;
|
||||
float night : TEXCOORD2;
|
||||
float3 texcoord : TEXCOORD3;
|
||||
float3 starPos : TEXCOORD4;
|
||||
float4 screenUV : TEXCOORD5;
|
||||
float3 starsTwinklingPos : TEXCOORD6;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
o.Position = UnityObjectToClipPos(v.vertex);
|
||||
float3 viewDir = normalize(v.texcoord + float3(0.0,0.1,0.0));
|
||||
|
||||
o.sky.x = saturate(_SunDir.y + 0.25);
|
||||
o.sky.y = saturate(clamp(1.0 - _SunDir.y, 0.0, 0.5));
|
||||
o.sky.z = saturate(dot(-_MoonDir.xyz,viewDir));
|
||||
|
||||
float3 r = normalize(cross(_MoonDir.xyz, float3(0, -1, 0)));
|
||||
float3 u = cross(_MoonDir.xyz,r);
|
||||
o.moonPos.xy = float2(dot(r, v.vertex.xyz), dot(u, v.vertex.xyz)) * (21.0 - _moonParams.x) + 0.5;
|
||||
o.moonPos.zw = float2(dot(r, v.vertex.xyz), dot(u, v.vertex.xyz)) * (21.0 - _moonParams.y) + 0.5;
|
||||
|
||||
o.starPos = mul((float3x3)_StarsMatrix,v.vertex.xyz);
|
||||
o.starsTwinklingPos = mul((float3x3)_StarsTwinklingMatrix, v.vertex.xyz);
|
||||
o.night = pow(max(0.0,viewDir.y),1.25);
|
||||
o.texcoord = v.texcoord;
|
||||
o.screenUV = ComputeScreenPos(o.Position);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
float MoonPhaseFactor(float2 uv, float phase)
|
||||
{
|
||||
float alpha = 1.0;
|
||||
|
||||
|
||||
float srefx = uv.x - 0.5;
|
||||
float refx = abs(uv.x - 0.5);
|
||||
|
||||
if (phase > 0)
|
||||
{
|
||||
srefx = (1 - uv.x) - 0.5;
|
||||
refx = abs((1 - uv.x) - 0.5);
|
||||
}
|
||||
|
||||
phase = abs(_moonParams.w);
|
||||
float refy = abs(uv.y - 0.5);
|
||||
float refxfory = sqrt(0.25 - refy * refy);
|
||||
float xmin = -refxfory;
|
||||
float xmax = refxfory;
|
||||
float xmin1 = (xmax - xmin) * (phase / 2) + xmin;
|
||||
float xmin2 = (xmax - xmin) * phase + xmin;
|
||||
|
||||
if (srefx < xmin1)
|
||||
{
|
||||
alpha = 0;
|
||||
}
|
||||
else if (srefx < xmin2 && xmin1 != xmin2)
|
||||
{
|
||||
alpha = (srefx - xmin1) / (xmin2 - xmin1);
|
||||
}
|
||||
|
||||
return alpha;
|
||||
}
|
||||
|
||||
float3 ScreenSpaceDither(float2 vScreenPos, float3 clr)
|
||||
{
|
||||
float d = dot(float2(131.0, 312.0), vScreenPos.xy + _Time.y);
|
||||
float3 vDither = float3(d, d, d);
|
||||
vDither.rgb = frac(vDither.rgb / float3(103.0, 71.0, 97.0)) - float3(0.5, 0.5, 0.5);
|
||||
return (vDither.rgb / 15.0) * _DitheringIntensity;
|
||||
}
|
||||
|
||||
half3 tonemapACES(half3 color, float Exposure)
|
||||
{
|
||||
color *= Exposure;
|
||||
|
||||
// See https://knarkowicz.wordpress.com/2016/01/06/aces-filmic-tone-mapping-curve/
|
||||
const half a = 2.51;
|
||||
const half b = 0.03;
|
||||
const half c = 2.43;
|
||||
const half d = 0.59;
|
||||
const half e = 0.14;
|
||||
return saturate((color * (a * color + b)) / (color * (c * color + d) + e));
|
||||
}
|
||||
|
||||
float4 frag(v2f i) : SV_Target
|
||||
{
|
||||
float2 screenPosition = (i.screenUV.xy / i.screenUV.w);
|
||||
float3 viewDir = normalize(i.texcoord);
|
||||
float cosTheta = dot(viewDir,_SunDir);
|
||||
viewDir = normalize(i.texcoord + float3(0.0,0.1,0.0));
|
||||
float zen = acos(saturate(viewDir.y));
|
||||
float alb = (cos(zen) + 0.5 * pow(93.885 - ((zen * 180.0) / 3.141592), -0.253));
|
||||
float3 fex = exp(-(_Br * (4 / alb) + _Bm * (1.25 / alb)));
|
||||
float rayPhase = 2.5 + pow(cosTheta,1);
|
||||
float miePhase = _mieG.x / pow(_mieG.y - _mieG.z * cosTheta, 1);
|
||||
float3 BrTheta = 0.059683 * _Br * rayPhase;
|
||||
float3 BmTheta = 0.079577 * _Bm * miePhase;
|
||||
float3 BrmTheta = (BrTheta + BmTheta * 2.0) / ((_Bm + _Br) * 0.75);
|
||||
float3 scattering = BrmTheta * _SunIntensity * (1.0 - fex);
|
||||
float3 sunClr = lerp(fex, _sunDiskColor.rgb, 0.75) * _SunDiskIntensity;
|
||||
float3 sunDisk = (min(2, pow((1 - cosTheta) * (_SunDiskSize * 100), -2)) * sunClr) * (_sunDiskColor * 10);
|
||||
|
||||
float4 moonSampler = tex2D(_MoonTex, i.moonPos.xy);
|
||||
float alpha = MoonPhaseFactor(i.moonPos.xy, _moonParams.w);
|
||||
float3 moonArea = clamp(moonSampler * 10, 0, 1)* i.sky.z;
|
||||
moonSampler = lerp(float4(0,0,0,0),moonSampler,alpha);
|
||||
moonSampler = (moonSampler * _MoonColor) * 2;
|
||||
|
||||
float4 moonGlow = tex2D(_GlowTex, i.moonPos.zw) * i.sky.z;
|
||||
|
||||
float3 skyFinalize = saturate((pow(1.0 - fex, 2.0) * 0.234) * (1 - i.sky.x)) * _SkyLuminance;
|
||||
skyFinalize = saturate(lerp(float3(0.01,0.01,0.01), skyFinalize, saturate(dot(viewDir.y + 0.3, float3(0,1,0)))) * (1 - fex));
|
||||
//skyFinalize = saturate(lerp(float3(0.1,0.1,0.1), skyFinalize, saturate(dot(viewDir.y + 0.3, float3(0,1,0)))) * (1 - fex));
|
||||
|
||||
|
||||
float fadeStar = i.night * _StarsIntensity * 75;
|
||||
float3 starsMap = texCUBE(_Stars, i.starPos.xyz);
|
||||
|
||||
if (_StarsTwinkling > 0)
|
||||
{
|
||||
float3 starsTwinklingMap = texCUBE(_StarsTwinklingNoise, i.starsTwinklingPos.xyz);
|
||||
starsMap = starsMap * starsTwinklingMap;
|
||||
}
|
||||
|
||||
float starsBehindMoon = 1 - clamp((moonArea * 5), 0, 1);
|
||||
float3 stars = pow(clamp((starsMap * fadeStar) * starsBehindMoon,0,4),2);
|
||||
|
||||
float3 galaxyMap = texCUBE(_Galaxy, i.starPos.xyz);
|
||||
float3 galaxy = galaxyMap * starsBehindMoon * (i.night * _GalaxyIntensity);
|
||||
|
||||
scattering *= saturate((lerp(float3(_scatteringPower, _scatteringPower, _scatteringPower), pow(2000.0f * BrmTheta * fex, 0.75f), i.sky.y) * 0.05));
|
||||
scattering *= (_SkyLuminance * _scatteringColor.rgb) * pow((1 - fex), 2) * i.sky.x;
|
||||
|
||||
if (viewDir.y - 0.08 < 0)
|
||||
sunDisk = float3(0,0,0);
|
||||
|
||||
float3 skyScattering = (scattering + sunDisk) + (skyFinalize + galaxy + stars);
|
||||
float4 satSampler = tex2D(_SatTex, screenPosition);
|
||||
|
||||
skyScattering = satSampler.rgb + skyScattering * (1 - satSampler.a);
|
||||
skyScattering += (moonSampler.rgb * i.sky.z) + ((moonGlow.xyz * _moonGlowColor) * _moonParams.z) * (1 - moonSampler.a);
|
||||
|
||||
//Tonemapping
|
||||
if (_Tonemapping == 1)
|
||||
{
|
||||
skyScattering.rgb = tonemapACES(skyScattering.rgb, _SkyExposure);
|
||||
}
|
||||
|
||||
skyScattering = pow(skyScattering,_SkyColorPower);
|
||||
|
||||
//half4 background = texCUBE(_Background, i.texcoord);
|
||||
//skyScattering = skyScattering * (1 - background.a) + background.rgb * background.a;
|
||||
|
||||
skyScattering = lerp(skyScattering, (lerp(skyScattering,_weatherSkyMod.rgb,_weatherSkyMod.a)),_weatherSkyMod.a);
|
||||
|
||||
#if defined(UNITY_COLORSPACE_GAMMA)
|
||||
skyScattering = LinearToGammaSpace(skyScattering);
|
||||
#endif
|
||||
|
||||
if (viewDir.y + 0.1 < 0 && _blackGround > 0)
|
||||
skyScattering = 0;
|
||||
|
||||
float3 final = float3(0, 0, 0);
|
||||
|
||||
//Dithering
|
||||
final = skyScattering + ScreenSpaceDither(i.Position.xy, final.rgb);
|
||||
|
||||
return float4(final , 1);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
|
||||
|
||||
//AURORA
|
||||
Pass
|
||||
{
|
||||
Blend One One
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile __ ENVIRO_AURORA
|
||||
#include "UnityCG.cginc"
|
||||
#pragma exclude_renderers gles
|
||||
|
||||
|
||||
sampler2D _Aurora_Layer_1;
|
||||
sampler2D _Aurora_Layer_2;
|
||||
sampler2D _Aurora_Colorshift;
|
||||
|
||||
float4 _AuroraColor;
|
||||
float _AuroraIntensity;
|
||||
float _AuroraBrightness;
|
||||
float _AuroraContrast;
|
||||
float _AuroraHeight;
|
||||
float _AuroraScale;
|
||||
float _AuroraSpeed;
|
||||
float _AuroraSteps;
|
||||
|
||||
float4 _Aurora_Tiling_Layer1;
|
||||
float4 _Aurora_Tiling_Layer2;
|
||||
float4 _Aurora_Tiling_ColorShift;
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
float3 worldPos : TEXCOORD0;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f vert(appdata_full v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v); //Insert
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o); //Insert
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); //Insert
|
||||
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
|
||||
return o;
|
||||
}
|
||||
|
||||
float randomNoise(float3 co) {
|
||||
return frac(sin(dot(co.xyz ,float3(17.2486,32.76149, 368.71564))) * 32168.47512);
|
||||
}
|
||||
|
||||
half4 SampleAurora(float3 uv) {
|
||||
|
||||
float2 uv_1 = uv.xy * _Aurora_Tiling_Layer1.xy + (_Aurora_Tiling_Layer1.zw * _AuroraSpeed * _Time.y);
|
||||
|
||||
half4 aurora = tex2Dlod(_Aurora_Layer_1, float4(uv_1.xy,0,0));
|
||||
|
||||
float2 uv_2 = uv_1 * _Aurora_Tiling_Layer2.xy + (_Aurora_Tiling_Layer2.zw * _AuroraSpeed * _Time.y);
|
||||
half4 aurora2 = tex2Dlod(_Aurora_Layer_2, float4(uv_2.xy,0,0));
|
||||
aurora += (aurora2 - 0.5) * 0.5;
|
||||
|
||||
aurora.w = aurora.w * 0.8 + 0.05;
|
||||
|
||||
float3 uv_3 = float3(uv.xy * _Aurora_Tiling_ColorShift.xy + (_Aurora_Tiling_ColorShift.zw * _AuroraSpeed * _Time.y), 0.0);
|
||||
half4 cloudColor = tex2Dlod(_Aurora_Colorshift, float4(uv_3.xy,0,0));
|
||||
|
||||
half contrastMask = 1.0 - saturate(aurora.a);
|
||||
contrastMask = pow(contrastMask, _AuroraContrast);
|
||||
aurora.rgb *= lerp(half3(0,0,0), _AuroraColor.rgb * cloudColor.rgb * _AuroraBrightness, contrastMask);
|
||||
|
||||
half cloudSub = 1.0 - uv.z;
|
||||
aurora.a = aurora.a - cloudSub * cloudSub;
|
||||
aurora.a = saturate(aurora.a * _AuroraIntensity);
|
||||
aurora.rgb *= aurora.a;
|
||||
|
||||
return aurora;
|
||||
}
|
||||
|
||||
fixed4 frag(v2f i) : SV_Target
|
||||
{
|
||||
#if defined(ENVIRO_AURORA)
|
||||
|
||||
if (_AuroraIntensity < 0.05)
|
||||
return float4(0,0,0,0);
|
||||
|
||||
float3 viewDir = normalize(i.worldPos - _WorldSpaceCameraPos);
|
||||
|
||||
float viewFalloff = 1.0 - saturate(dot(viewDir, float3(0,1,0)));
|
||||
|
||||
if (viewDir.y < 0 || viewDir.y > 1)
|
||||
return half4(0, 0, 0, 0);
|
||||
|
||||
float3 traceDir = normalize(viewDir + float3(0, viewFalloff * 0.2 ,0));
|
||||
|
||||
float3 worldPos = _WorldSpaceCameraPos + traceDir * ((_AuroraHeight - _WorldSpaceCameraPos.y) / max(traceDir.y, 0.01));
|
||||
float3 uv = float3(worldPos.xz * 0.01 * _AuroraScale, 0);
|
||||
|
||||
half3 uvStep = half3(traceDir.xz * -1.0 * (1.0 / traceDir.y), 1.0) * (1.0 / _AuroraSteps);
|
||||
uv += uvStep * randomNoise(i.worldPos + _SinTime.w);
|
||||
|
||||
half4 finalColor = half4(0,0,0,0);
|
||||
|
||||
[loop]
|
||||
for (int i = 0; i < _AuroraSteps; i++)
|
||||
{
|
||||
if (finalColor.a > 1)
|
||||
break;
|
||||
|
||||
uv += uvStep;
|
||||
finalColor += SampleAurora(uv) * (1.0 - finalColor.a);
|
||||
}
|
||||
|
||||
finalColor *= viewDir.y;
|
||||
|
||||
return finalColor;
|
||||
#else
|
||||
return half4(0, 0, 0, 0);
|
||||
#endif
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
//Cirrus Clouds
|
||||
Pass
|
||||
{
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
|
||||
CGPROGRAM
|
||||
#pragma target 3.0
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
uniform sampler2D _CloudMap;
|
||||
uniform float _CloudAlpha;
|
||||
uniform float _CloudCoverage;
|
||||
uniform float _CloudAltitude;
|
||||
uniform float4 _CloudColor;
|
||||
uniform float _CloudColorPower;
|
||||
uniform float2 _CloudCirrusAnimation;
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 Position : SV_POSITION;
|
||||
float4 uv : TEXCOORD0;
|
||||
float3 worldPos : TEXCOORD1;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v); //Insert
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o); //Insert
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); //Insert
|
||||
|
||||
o.Position = UnityObjectToClipPos(v.vertex);
|
||||
o.worldPos = normalize(v.vertex).xyz;
|
||||
float3 viewDir = normalize(o.worldPos + float3(0,1,0));
|
||||
o.worldPos.y *= 1 - dot(viewDir.y + _CloudAltitude, float3(0,-0.15,0));
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 frag(v2f i) : SV_Target
|
||||
{
|
||||
float3 uvs = normalize(i.worldPos);
|
||||
|
||||
float4 uv1;
|
||||
float4 uv2;
|
||||
|
||||
uv1.xy = (uvs.xz * 0.2) + _CloudCirrusAnimation;
|
||||
uv2.xy = (uvs.xz * 0.4) + _CloudCirrusAnimation;
|
||||
|
||||
float4 clouds1 = tex2D(_CloudMap, uv1.xy);
|
||||
float4 clouds2 = tex2D(_CloudMap, uv2.xy);
|
||||
|
||||
float color1 = pow(clouds1.g + clouds2.g, 0.1);
|
||||
float color2 = pow(clouds2.b * clouds1.r, 0.2);
|
||||
|
||||
float4 finalClouds = lerp(clouds1, clouds2, color1 * color2);
|
||||
float cloudExtinction = pow(uvs.y , 2);
|
||||
|
||||
|
||||
finalClouds.a *= _CloudAlpha;
|
||||
finalClouds.a *= cloudExtinction;
|
||||
|
||||
if (uvs.y < 0)
|
||||
finalClouds.a = 0;
|
||||
|
||||
finalClouds.rgb = finalClouds.a * pow(_CloudColor,_CloudColorPower);
|
||||
finalClouds.rgb = pow(finalClouds.rgb,1 - _CloudCoverage);
|
||||
|
||||
return finalClouds;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
///CIRRUS END
|
||||
}
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9207df900c02ffe42bf6f6b07842dd9c
|
||||
timeCreated: 1468137264
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
-602
@@ -1,602 +0,0 @@
|
||||
Shader "Enviro/Standard/SkyboxFlatClouds"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_Stars("Stars Cubemap", Cube) = "black" {}
|
||||
_StarsTwinklingNoise("Stars Noise", Cube) = "black" {}
|
||||
_Galaxy("Galaxy Cubemap", Cube) = "black" {}
|
||||
_SatTex("Satellites Tex", 2D) = "black" {}
|
||||
_MoonTex("Moon Tex", 2D) = "black" {}
|
||||
_GlowTex("Glow Tex", 2D) = "black" {}
|
||||
_DitheringTex("Dithering Tex", 2D) = "black" {}
|
||||
_FlatCloudsBaseTexture("Base Map", 2D) = "black" {}
|
||||
_FlatCloudsDetailTexture("Detail Map", 2D) = "black" {}
|
||||
_Aurora_Layer_1("Aurora Layer 1", 2D) = "black" {}
|
||||
_Aurora_Layer_2("Aurora Layer 2", 2D) = "black" {}
|
||||
_Aurora_Colorshift("Aurora Color Shift", 2D) = "black" {}
|
||||
|
||||
//_Background("Background Cubemap", Cube) = "black" {}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags{ "Queue" = "Background" "RenderType" = "Background" "PreviewType" = "Skybox" }
|
||||
Cull Off
|
||||
Fog{ Mode Off }
|
||||
ZWrite Off
|
||||
|
||||
Pass
|
||||
{
|
||||
|
||||
CGPROGRAM
|
||||
#pragma target 3.0
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile __ UNITY_COLORSPACE_GAMMA
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
uniform float3 _Br;
|
||||
uniform float3 _Bm;
|
||||
uniform float3 _mieG;
|
||||
uniform float _SunIntensity;
|
||||
uniform float _Tonemapping;
|
||||
uniform float _SkyExposure;
|
||||
uniform float _SkyLuminance;
|
||||
uniform float _scatteringPower;
|
||||
uniform float _SunDiskSize;
|
||||
uniform float _SunDiskIntensity;
|
||||
uniform float _StarsIntensity;
|
||||
uniform float4 _scatteringColor;
|
||||
uniform float4 _sunDiskColor;
|
||||
uniform samplerCUBE _Stars;
|
||||
uniform samplerCUBE _StarsTwinklingNoise;
|
||||
uniform float4x4 _StarsMatrix;
|
||||
uniform float4x4 _StarsTwinklingMatrix;
|
||||
uniform float _SkyColorPower;
|
||||
uniform float3 _SunDir;
|
||||
uniform float3 _MoonDir;
|
||||
uniform float4 _weatherSkyMod;
|
||||
uniform float4 _moonGlowColor;
|
||||
uniform sampler2D _MoonTex;
|
||||
uniform sampler2D _GlowTex;
|
||||
uniform sampler2D _SatTex;
|
||||
uniform float4 _MoonColor;
|
||||
uniform float4 _moonParams; // _MoonSize, _GlowSize, _GlowIntensity, _MoonPhase
|
||||
uniform float _GalaxyIntensity;
|
||||
uniform samplerCUBE _Galaxy;
|
||||
uniform int _blackGround;
|
||||
uniform float _StarsTwinkling;
|
||||
uniform float _DitheringIntensity;
|
||||
|
||||
//uniform samplerCUBE _Background;
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float3 texcoord : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 Position : SV_POSITION;
|
||||
float4 moonPos : TEXCOORD0;
|
||||
float4 sky : TEXCOORD1;
|
||||
float night : TEXCOORD2;
|
||||
float3 texcoord : TEXCOORD3;
|
||||
float3 starPos : TEXCOORD4;
|
||||
float4 screenUV : TEXCOORD5;
|
||||
float3 starsTwinklingPos : TEXCOORD6;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v); //Insert
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o); //Insert
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); //Insert
|
||||
o.Position = UnityObjectToClipPos(v.vertex);
|
||||
float3 viewDir = normalize(v.texcoord + float3(0.0,0.1,0.0));
|
||||
o.sky.x = saturate(_SunDir.y + 0.25);
|
||||
o.sky.y = saturate(clamp(1.0 - _SunDir.y, 0.0, 0.5));
|
||||
o.sky.z = saturate(dot(-_MoonDir.xyz,viewDir));
|
||||
|
||||
float3 r = normalize(cross(_MoonDir.xyz, float3(0, -1, 0)));
|
||||
float3 u = cross(_MoonDir.xyz, r);
|
||||
o.moonPos.xy = float2(dot(r, v.vertex.xyz), dot(u, v.vertex.xyz)) * (21.0 - _moonParams.x) + 0.5;
|
||||
o.moonPos.zw = float2(dot(r, v.vertex.xyz), dot(u, v.vertex.xyz)) * (21.0 - _moonParams.y) + 0.5;
|
||||
|
||||
o.starPos = mul((float3x3)_StarsMatrix,v.vertex.xyz);
|
||||
o.starsTwinklingPos = mul((float3x3)_StarsTwinklingMatrix, v.vertex.xyz);
|
||||
o.night = pow(max(0.0,viewDir.y),1.25);
|
||||
o.texcoord = v.texcoord;
|
||||
o.screenUV = ComputeScreenPos(o.Position);
|
||||
return o;
|
||||
}
|
||||
|
||||
float MoonPhaseFactor(float2 uv, float phase)
|
||||
{
|
||||
float alpha = 1.0;
|
||||
|
||||
|
||||
float srefx = uv.x - 0.5;
|
||||
float refx = abs(uv.x - 0.5);
|
||||
|
||||
if (phase > 0)
|
||||
{
|
||||
srefx = (1 - uv.x) - 0.5;
|
||||
refx = abs((1 - uv.x) - 0.5);
|
||||
}
|
||||
|
||||
phase = abs(_moonParams.w);
|
||||
float refy = abs(uv.y - 0.5);
|
||||
float refxfory = sqrt(0.25 - refy * refy);
|
||||
float xmin = -refxfory;
|
||||
float xmax = refxfory;
|
||||
float xmin1 = (xmax - xmin) * (phase / 2) + xmin;
|
||||
float xmin2 = (xmax - xmin) * phase + xmin;
|
||||
|
||||
if (srefx < xmin1)
|
||||
{
|
||||
alpha = 0;
|
||||
}
|
||||
else if (srefx < xmin2 && xmin1 != xmin2)
|
||||
{
|
||||
alpha = (srefx - xmin1) / (xmin2 - xmin1);
|
||||
}
|
||||
|
||||
return alpha;
|
||||
}
|
||||
|
||||
float3 ScreenSpaceDither(float2 vScreenPos, float3 clr)
|
||||
{
|
||||
float d = dot(float2(131.0, 312.0), vScreenPos.xy + _Time.y);
|
||||
float3 vDither = float3(d, d, d);
|
||||
vDither.rgb = frac(vDither.rgb / float3(103.0, 71.0, 97.0)) - float3(0.5, 0.5, 0.5);
|
||||
return (vDither.rgb / 15.0) * _DitheringIntensity;
|
||||
}
|
||||
half3 tonemapACES(half3 color, float Exposure)
|
||||
{
|
||||
color *= Exposure;
|
||||
|
||||
// See https://knarkowicz.wordpress.com/2016/01/06/aces-filmic-tone-mapping-curve/
|
||||
const half a = 2.51;
|
||||
const half b = 0.03;
|
||||
const half c = 2.43;
|
||||
const half d = 0.59;
|
||||
const half e = 0.14;
|
||||
return saturate((color * (a * color + b)) / (color * (c * color + d) + e));
|
||||
}
|
||||
float4 frag(v2f i) : SV_Target
|
||||
{
|
||||
float2 screenPosition = (i.screenUV.xy / i.screenUV.w);
|
||||
float3 viewDir = normalize(i.texcoord);
|
||||
float cosTheta = dot(viewDir,_SunDir);
|
||||
viewDir = normalize(i.texcoord + float3(0.0,0.1,0.0));
|
||||
float zen = acos(saturate(viewDir.y));
|
||||
float alb = (cos(zen) + 0.5 * pow(93.885 - ((zen * 180.0) / 3.141592), -0.253));
|
||||
float3 fex = exp(-(_Br * (4 / alb) + _Bm * (1.25 / alb)));
|
||||
float rayPhase = 2.5 + pow(cosTheta,1);
|
||||
float miePhase = _mieG.x / pow(_mieG.y - _mieG.z * cosTheta, 1);
|
||||
float3 BrTheta = 0.059683 * _Br * rayPhase;
|
||||
float3 BmTheta = 0.079577 * _Bm * miePhase;
|
||||
float3 BrmTheta = (BrTheta + BmTheta * 2.0) / ((_Bm + _Br) * 0.75);
|
||||
float3 scattering = BrmTheta * _SunIntensity * (1.0 - fex);
|
||||
float3 sunClr = lerp(fex, _sunDiskColor.rgb, 0.75) * _SunDiskIntensity;
|
||||
float3 sunDisk = (min(2, pow((1 - cosTheta) * (_SunDiskSize * 100), -2)) * sunClr) * (_sunDiskColor * 10);
|
||||
|
||||
float4 moonSampler = tex2D(_MoonTex, i.moonPos.xy);
|
||||
float alpha = MoonPhaseFactor(i.moonPos.xy, _moonParams.w);
|
||||
float3 moonArea = clamp(moonSampler * 10, 0, 1) * i.sky.z;
|
||||
moonSampler = lerp(float4(0,0,0,0),moonSampler,alpha);
|
||||
moonSampler = (moonSampler * _MoonColor) * 2;
|
||||
|
||||
//float3 moonBright = saturate((float3(1,1,1)) * pow(dot(viewDir, -_MoonDir), (21.0 - _MoonSize) * 10) * i.night);
|
||||
float4 moonGlow = tex2D(_GlowTex, i.moonPos.zw) * i.sky.z;
|
||||
float3 skyFinalize = saturate((pow(1.0 - fex, 2.0) * 0.234) * (1 - i.sky.x)) * _SkyLuminance;
|
||||
skyFinalize = saturate(lerp(float3(0.1,0.1,0.1), skyFinalize, saturate(dot(viewDir.y + 0.3, float3(0,1,0)))) * (1 - fex));
|
||||
float fadeStar = i.night * _StarsIntensity * 75;
|
||||
float3 starsMap = texCUBE(_Stars, i.starPos.xyz);
|
||||
if (_StarsTwinkling > 0)
|
||||
{
|
||||
float3 starsTwinklingMap = texCUBE(_StarsTwinklingNoise, i.starsTwinklingPos.xyz);
|
||||
starsMap = starsMap * starsTwinklingMap;
|
||||
}
|
||||
float starsBehindMoon = 1 - clamp((moonArea * 5), 0, 1);
|
||||
float3 stars = pow(clamp((starsMap * fadeStar) * starsBehindMoon, 0, 4), 2);
|
||||
float3 galaxyMap = texCUBE(_Galaxy, i.starPos.xyz);
|
||||
float3 galaxy = galaxyMap * starsBehindMoon * (i.night * _GalaxyIntensity);
|
||||
scattering *= saturate((lerp(float3(_scatteringPower, _scatteringPower, _scatteringPower), pow(2000.0f * BrmTheta * fex, 0.75f), i.sky.y) * 0.05));
|
||||
scattering *= (_SkyLuminance * _scatteringColor.rgb) * pow((1 - fex), 2) * i.sky.x;
|
||||
|
||||
if (viewDir.y - 0.08 < 0)
|
||||
sunDisk = float3(0,0,0);
|
||||
|
||||
float3 skyScattering = (scattering + sunDisk) + (skyFinalize + galaxy + stars);
|
||||
float4 satSampler = tex2D(_SatTex, screenPosition);
|
||||
skyScattering = satSampler.rgb + skyScattering * (1 - satSampler.a);
|
||||
skyScattering += (moonSampler.rgb * i.sky.z) + ((moonGlow.xyz * _moonGlowColor) * _moonParams.z) * (1 - moonSampler.a);
|
||||
|
||||
//Tonemapping
|
||||
if (_Tonemapping == 1)
|
||||
{
|
||||
skyScattering.rgb = tonemapACES(skyScattering.rgb, _SkyExposure);
|
||||
}
|
||||
|
||||
skyScattering = pow(skyScattering,_SkyColorPower);
|
||||
|
||||
//half4 background = texCUBE(_Background, i.texcoord);
|
||||
//skyScattering = skyScattering * (1 - background.a) + background.rgb * background.a;
|
||||
|
||||
skyScattering = lerp(skyScattering, (lerp(skyScattering,_weatherSkyMod.rgb,_weatherSkyMod.a)),_weatherSkyMod.a);
|
||||
|
||||
#if defined(UNITY_COLORSPACE_GAMMA)
|
||||
skyScattering = pow(skyScattering,0.454545);
|
||||
#endif
|
||||
|
||||
if (viewDir.y+0.1 < 0 && _blackGround > 0)
|
||||
skyScattering = 0;
|
||||
|
||||
float3 final = float3(0, 0, 0);
|
||||
|
||||
//Dithering
|
||||
final = skyScattering + ScreenSpaceDither(i.Position.xy, final.rgb);
|
||||
|
||||
return float4(final, 1);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//AURORA
|
||||
Pass
|
||||
{
|
||||
Blend One One
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile __ ENVIRO_AURORA
|
||||
#include "UnityCG.cginc"
|
||||
#pragma exclude_renderers gles
|
||||
|
||||
|
||||
sampler2D _Aurora_Layer_1;
|
||||
sampler2D _Aurora_Layer_2;
|
||||
sampler2D _Aurora_Colorshift;
|
||||
|
||||
float4 _AuroraColor;
|
||||
float _AuroraIntensity;
|
||||
float _AuroraBrightness;
|
||||
float _AuroraContrast;
|
||||
float _AuroraHeight;
|
||||
float _AuroraScale;
|
||||
float _AuroraSpeed;
|
||||
float _AuroraSteps;
|
||||
|
||||
float4 _Aurora_Tiling_Layer1;
|
||||
float4 _Aurora_Tiling_Layer2;
|
||||
float4 _Aurora_Tiling_ColorShift;
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
float3 worldPos : TEXCOORD0;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f vert(appdata_full v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v); //Insert
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o); //Insert
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); //Insert
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
|
||||
return o;
|
||||
}
|
||||
|
||||
float randomNoise(float3 co) {
|
||||
return frac(sin(dot(co.xyz ,float3(17.2486,32.76149, 368.71564))) * 32168.47512);
|
||||
}
|
||||
|
||||
half4 SampleAurora(float3 uv) {
|
||||
|
||||
float2 uv_1 = uv.xy * _Aurora_Tiling_Layer1.xy + (_Aurora_Tiling_Layer1.zw * _AuroraSpeed * _Time.y);
|
||||
|
||||
half4 aurora = tex2Dlod(_Aurora_Layer_1, float4(uv_1.xy,0,0));
|
||||
|
||||
float2 uv_2 = uv_1 * _Aurora_Tiling_Layer2.xy + (_Aurora_Tiling_Layer2.zw * _AuroraSpeed * _Time.y);
|
||||
half4 aurora2 = tex2Dlod(_Aurora_Layer_2, float4(uv_2.xy,0,0));
|
||||
aurora += (aurora2 - 0.5) * 0.5;
|
||||
|
||||
aurora.w = aurora.w * 0.8 + 0.05;
|
||||
|
||||
float3 uv_3 = float3(uv.xy * _Aurora_Tiling_ColorShift.xy + (_Aurora_Tiling_ColorShift.zw * _AuroraSpeed * _Time.y), 0.0);
|
||||
half4 cloudColor = tex2Dlod(_Aurora_Colorshift, float4(uv_3.xy,0,0));
|
||||
|
||||
half contrastMask = 1.0 - saturate(aurora.a);
|
||||
contrastMask = pow(contrastMask, _AuroraContrast);
|
||||
aurora.rgb *= lerp(half3(0,0,0), _AuroraColor.rgb * cloudColor.rgb * _AuroraBrightness, contrastMask);
|
||||
|
||||
half cloudSub = 1.0 - uv.z;
|
||||
aurora.a = aurora.a - cloudSub * cloudSub;
|
||||
aurora.a = saturate(aurora.a * _AuroraIntensity);
|
||||
aurora.rgb *= aurora.a;
|
||||
|
||||
return aurora;
|
||||
}
|
||||
|
||||
fixed4 frag(v2f i) : SV_Target
|
||||
{
|
||||
#if defined(ENVIRO_AURORA)
|
||||
|
||||
if (_AuroraIntensity < 0.05)
|
||||
return float4(0,0,0,0);
|
||||
|
||||
float3 viewDir = normalize(i.worldPos - _WorldSpaceCameraPos);
|
||||
|
||||
float viewFalloff = 1.0 - saturate(dot(viewDir, float3(0,1,0)));
|
||||
|
||||
if (viewDir.y < 0 || viewDir.y > 1)
|
||||
return half4(0, 0, 0, 0);
|
||||
|
||||
float3 traceDir = normalize(viewDir + float3(0, viewFalloff * 0.2 ,0));
|
||||
|
||||
float3 worldPos = _WorldSpaceCameraPos + traceDir * ((_AuroraHeight - _WorldSpaceCameraPos.y) / max(traceDir.y, 0.01));
|
||||
float3 uv = float3(worldPos.xz * 0.01 * _AuroraScale, 0);
|
||||
|
||||
half3 uvStep = half3(traceDir.xz * -1.0 * (1.0 / traceDir.y), 1.0) * (1.0 / _AuroraSteps);
|
||||
uv += uvStep * randomNoise(i.worldPos + _SinTime.w);
|
||||
|
||||
half4 finalColor = half4(0,0,0,0);
|
||||
|
||||
[loop]
|
||||
for (int i = 0; i < _AuroraSteps; i++)
|
||||
{
|
||||
if (finalColor.a > 1)
|
||||
break;
|
||||
|
||||
uv += uvStep;
|
||||
finalColor += SampleAurora(uv) * (1.0 - finalColor.a);
|
||||
}
|
||||
|
||||
finalColor *= viewDir.y;
|
||||
|
||||
return finalColor;
|
||||
#else
|
||||
return half4(0, 0, 0, 0);
|
||||
#endif
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------
|
||||
Pass
|
||||
{
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
|
||||
CGPROGRAM
|
||||
#pragma target 3.0
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
uniform sampler2D _CloudMap;
|
||||
uniform float _CloudAlpha;
|
||||
uniform float _CloudCoverage;
|
||||
uniform float _CloudAltitude;
|
||||
uniform float4 _CloudColor;
|
||||
uniform float _CloudColorPower;
|
||||
uniform float2 _CloudCirrusAnimation;
|
||||
uniform float _Tonemapping;
|
||||
|
||||
struct appdata {
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 Position : SV_POSITION;
|
||||
float4 uv : TEXCOORD0;
|
||||
float3 worldPos : TEXCOORD1;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
half3 tonemapACES(half3 color, float Exposure)
|
||||
{
|
||||
color *= Exposure;
|
||||
|
||||
// See https://knarkowicz.wordpress.com/2016/01/06/aces-filmic-tone-mapping-curve/
|
||||
const half a = 2.51;
|
||||
const half b = 0.03;
|
||||
const half c = 2.43;
|
||||
const half d = 0.59;
|
||||
const half e = 0.14;
|
||||
return saturate((color * (a * color + b)) / (color * (c * color + d) + e));
|
||||
}
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v); //Insert
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o); //Insert
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); //Insert
|
||||
o.Position = UnityObjectToClipPos(v.vertex);
|
||||
o.worldPos = normalize(v.vertex).xyz;
|
||||
float3 viewDir = normalize(o.worldPos + float3(0,1,0));
|
||||
o.worldPos.y *= 1 - dot(viewDir.y + _CloudAltitude, float3(0,-0.15,0));
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 frag(v2f i) : SV_Target
|
||||
{
|
||||
float3 uvs = normalize(i.worldPos);
|
||||
float2 uv1 = (uvs.xz * 0.2) + _CloudCirrusAnimation;
|
||||
float2 uv2 = (uvs.xz * 0.4) + _CloudCirrusAnimation;
|
||||
float4 clouds1 = tex2D(_CloudMap, uv1.xy);
|
||||
float4 clouds2 = tex2D(_CloudMap, uv2.xy);
|
||||
float color1 = pow(clouds1.g + clouds2.g, 0.1);
|
||||
float color2 = pow(clouds2.b * clouds1.r, 0.2);
|
||||
float4 finalClouds = lerp(clouds1, clouds2, color1 * color2);
|
||||
float cloudExtinction = pow(uvs.y , 2);
|
||||
finalClouds.a *= _CloudAlpha;
|
||||
finalClouds.a *= cloudExtinction;
|
||||
if (uvs.y < 0)
|
||||
finalClouds.a = 0;
|
||||
finalClouds.rgb = finalClouds.a * pow(_CloudColor,2);
|
||||
|
||||
finalClouds.rgb = pow(finalClouds.rgb ,1 - _CloudCoverage);
|
||||
finalClouds.rgb *= _CloudColorPower;
|
||||
|
||||
if (_Tonemapping == 1)
|
||||
{
|
||||
finalClouds.rgb = tonemapACES(finalClouds.rgb, 1);
|
||||
}
|
||||
|
||||
return finalClouds;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------
|
||||
//Flat Clouds
|
||||
Pass
|
||||
{
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
|
||||
CGPROGRAM
|
||||
#pragma target 3.0
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
uniform sampler2D _FlatCloudsBaseTexture;
|
||||
uniform sampler2D _FlatCloudsDetailTexture;
|
||||
uniform float4 _FlatCloudsAnimation;
|
||||
uniform float3 _FlatCloudsLightDirection;
|
||||
uniform float3 _FlatCloudsLightColor;
|
||||
uniform float3 _FlatCloudsAmbientColor;
|
||||
uniform float4 _FlatCloudsLightingParams; // x = LightIntensity, y = AmbientIntensity, z = Absorbtion, w = HgPhase
|
||||
uniform float4 _FlatCloudsParams; // x = Coverage, y = Density, z = Altitude, w = tonemapping
|
||||
uniform float4 _FlatCloudsTiling; // x = Base, y = Detail
|
||||
uniform float _CloudsExposure;
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 Position : SV_POSITION;
|
||||
float4 uv : TEXCOORD0;
|
||||
float3 worldPos : TEXCOORD1;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f vert(appdata_base v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
o.Position = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = normalize(v.vertex).xyzw;
|
||||
float3 viewDir = normalize(o.uv + float3(0, 1, 0));
|
||||
o.uv.y *= 1 - dot(viewDir.y + _FlatCloudsParams.z, float3(0, -0.2, 0));
|
||||
o.worldPos = mul(unity_ObjectToWorld, v.vertex);
|
||||
return o;
|
||||
}
|
||||
|
||||
float Remap(float org_val, float org_min, float org_max, float new_min, float new_max)
|
||||
{
|
||||
return new_min + saturate(((org_val - org_min) / (org_max - org_min))*(new_max - new_min));
|
||||
}
|
||||
|
||||
float HenryGreenstein(float cosTheta, float g)
|
||||
{
|
||||
float k = 3.0 / (8.0 * 3.1415926f) * (1.0 - g * g) / (2.0 + g * g);
|
||||
return k * (1.0 + cosTheta * cosTheta) / pow(abs(1.0 + g * g - 2.0 * g * cosTheta), 1.5);
|
||||
}
|
||||
half3 tonemapACES(half3 color, float Exposure)
|
||||
{
|
||||
color *= Exposure;
|
||||
|
||||
// See https://knarkowicz.wordpress.com/2016/01/06/aces-filmic-tone-mapping-curve/
|
||||
const half a = 2.51;
|
||||
const half b = 0.03;
|
||||
const half c = 2.43;
|
||||
const half d = 0.59;
|
||||
const half e = 0.14;
|
||||
return saturate((color * (a * color + b)) / (color * (c * color + d) + e));
|
||||
}
|
||||
|
||||
float CalculateCloudDensity(float2 posBase, float2 posDetail, float coverage)
|
||||
{
|
||||
float4 baseNoise = tex2D(_FlatCloudsBaseTexture, posBase);
|
||||
float low_freq_fBm = (baseNoise.g * 0.625) + (baseNoise.b * 0.25) + (baseNoise.a * 0.125);
|
||||
float base_cloud = Remap(baseNoise.r, -(1.0 - low_freq_fBm), 1.0, 0.0, 1.0) * coverage;
|
||||
|
||||
float4 detailNoise = tex2D(_FlatCloudsDetailTexture, posDetail * 2);
|
||||
float high_freq_fBm = (detailNoise.r * 0.625) + (detailNoise.g * 0.25) + (detailNoise.b * 0.125);
|
||||
float density = Remap(base_cloud, 1.0 - high_freq_fBm * 0.5, 1.0, 0.0, 1.0);
|
||||
|
||||
density *= pow(high_freq_fBm, 0.4);
|
||||
density *= _FlatCloudsParams.y;
|
||||
|
||||
return density;
|
||||
}
|
||||
|
||||
half4 frag(v2f i) : SV_Target
|
||||
{
|
||||
half4 col = 0;
|
||||
float3 uvs = normalize(i.uv);
|
||||
|
||||
float4 uv1;
|
||||
uv1.xy = (uvs.xz * _FlatCloudsTiling.x) + _FlatCloudsAnimation.xy;
|
||||
uv1.zw = (uvs.xz * _FlatCloudsTiling.y) + _FlatCloudsAnimation.zw;
|
||||
|
||||
float cloudExtinction = pow(uvs.y, 2);
|
||||
half density = CalculateCloudDensity(uv1.xy, uv1.zw, _FlatCloudsParams.x);
|
||||
|
||||
//Lighting
|
||||
fixed absorbtion = exp2(-1 * (density * _FlatCloudsLightingParams.z));
|
||||
float3 viewDir = normalize(i.worldPos - _WorldSpaceCameraPos);
|
||||
float inscatterAngle = dot(normalize(_FlatCloudsLightDirection), -viewDir);
|
||||
fixed hg = HenryGreenstein(inscatterAngle, _FlatCloudsLightingParams.w) * 2 * absorbtion;
|
||||
fixed lighting = density * (absorbtion + hg);
|
||||
float3 lightColor = pow(_FlatCloudsLightColor, 2) * (_FlatCloudsLightingParams.x );
|
||||
col.rgb = lightColor * lighting;
|
||||
col.rgb = col.rgb + (_FlatCloudsAmbientColor * _FlatCloudsLightingParams.y);
|
||||
|
||||
//Tonemapping
|
||||
if (_FlatCloudsParams.w == 1)
|
||||
col.rgb = tonemapACES(col.rgb, _CloudsExposure);
|
||||
|
||||
|
||||
col.a = saturate(density * cloudExtinction);
|
||||
|
||||
if (uvs.y < 0)
|
||||
col.a = 0;
|
||||
|
||||
return col;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c197b0132b688e242908e7cebabca5eb
|
||||
timeCreated: 1468137264
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
-554
@@ -1,554 +0,0 @@
|
||||
Shader "Enviro/Standard/SkyboxSimple"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_SkyColor ("Sky Color", Color) = (0, 0, 0, 0)
|
||||
_HorizonColor ("Horizon Color", Color) = (0, 0, 0, 0)
|
||||
_HorizonBackColor("Horizon Back Color", Color) = (0, 0, 0, 0)
|
||||
_SunColor ("Sun Color", Color) = (0, 0, 0, 0)
|
||||
_Stars ("StarsMap", Cube) = "white" {}
|
||||
_StarsTwinklingNoise("Stars Noise", Cube) = "black" {}
|
||||
_Galaxy("Galaxy Cubemap", Cube) = "black" {}
|
||||
_MoonTex("Moon Tex", 2D) = "black" {}
|
||||
_GlowTex("Glow Tex", 2D) = "black" {}
|
||||
_Aurora_Layer_1("Aurora Layer 1", 2D) = "black" {}
|
||||
_Aurora_Layer_2("Aurora Layer 2", 2D) = "black" {}
|
||||
_Aurora_Colorshift("Aurora Color Shift", 2D) = "black" {}
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Lod 300
|
||||
Tags { "Queue"="Background" "RenderType"="Background" "PreviewType"="Skybox" "IgnoreProjector"="True" }
|
||||
|
||||
Pass
|
||||
{
|
||||
Cull Back
|
||||
ZWrite Off
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
#pragma target 3.0
|
||||
|
||||
uniform half4 _SkyColor;
|
||||
uniform half4 _HorizonColor;
|
||||
uniform half4 _HorizonBackColor;
|
||||
uniform half4 _GroundColor;
|
||||
uniform half4 _SunColor;
|
||||
|
||||
|
||||
uniform samplerCUBE _Stars;
|
||||
uniform float4x4 _StarsMatrix;
|
||||
uniform samplerCUBE _StarsTwinklingNoise;
|
||||
uniform float4x4 _StarsTwinklingMatrix;
|
||||
uniform float _StarsTwinkling;
|
||||
uniform half _StarsIntensity;
|
||||
uniform half _SunDiskSizeSimple;
|
||||
uniform float4 _weatherSkyMod;
|
||||
uniform float4 _moonParams;
|
||||
uniform float4 _MoonColor;
|
||||
uniform float4 _moonGlowColor;
|
||||
uniform float3 _SunDir;
|
||||
uniform float3 _MoonDir;
|
||||
uniform sampler2D _MoonTex;
|
||||
uniform sampler2D _GlowTex;
|
||||
uniform float _GalaxyIntensity;
|
||||
uniform samplerCUBE _Galaxy;
|
||||
|
||||
struct VertexInput
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
|
||||
struct v2f {
|
||||
float4 position : POSITION;
|
||||
float4 WorldPosition : TEXCOORD0;
|
||||
half3 vertex : TEXCOORD1;
|
||||
float3 starPos : TEXCOORD2;
|
||||
float3 starsTwinklingPos : TEXCOORD3;
|
||||
float4 moonPos : TEXCOORD4;
|
||||
float4 sky : TEXCOORD5;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f vert(VertexInput v) {
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v); //Insert
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o); //Insert
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); //Insert
|
||||
o.position = UnityObjectToClipPos(v.vertex);
|
||||
o.WorldPosition = normalize(mul((float4x4)unity_ObjectToWorld, v.vertex)).xyzw;
|
||||
o.starPos = mul((float3x3)_StarsMatrix,v.vertex.xyz);
|
||||
o.starsTwinklingPos = mul((float3x3)_StarsTwinklingMatrix, v.vertex.xyz);
|
||||
float3 r = normalize(cross(_MoonDir.xyz, float3(0, -1, 0)));
|
||||
float3 u = cross(_MoonDir.xyz, r);
|
||||
o.moonPos.xy = float2(dot(r, v.vertex.xyz), dot(u, v.vertex.xyz)) * (21.0 - _moonParams.x) + 0.5;
|
||||
o.moonPos.zw = float2(dot(r, v.vertex.xyz), dot(u, v.vertex.xyz)) * (21.0 - _moonParams.y) + 0.5;
|
||||
|
||||
o.sky.x = saturate(_SunDir.y + 0.25);
|
||||
o.sky.y = saturate(clamp(1.0 - _SunDir.y, 0.0, 0.5));
|
||||
o.sky.z = saturate(dot(-_MoonDir.xyz, v.texcoord));
|
||||
|
||||
o.vertex = -v.vertex;
|
||||
return o;
|
||||
}
|
||||
|
||||
half getMiePhase(half eyeCos, half eyeCos2, half y)
|
||||
{
|
||||
half temp = 1.0 + 0.9801 - 2.0 * (-0.990) * eyeCos;
|
||||
temp = pow(temp, pow(_SunDiskSizeSimple, 0.65) * 10);
|
||||
temp = max(temp, 1.0e-4); // prevent division by zero, esp. in half precision
|
||||
temp = 1.5 * ((1.0 - 0.9801) / (2.0 + 0.9801)) * (1.0 + eyeCos2) / temp;
|
||||
//#if defined(UNITY_COLORSPACE_GAMMA) && SKYBOX_COLOR_IN_TARGET_COLOR_SPACE
|
||||
// temp = pow(temp, .454545);
|
||||
//#endif
|
||||
return temp;
|
||||
}
|
||||
|
||||
float MoonPhaseFactor(float2 uv, float phase)
|
||||
{
|
||||
float alpha = 1.0;
|
||||
|
||||
|
||||
float srefx = uv.x - 0.5;
|
||||
float refx = abs(uv.x - 0.5);
|
||||
|
||||
if (phase > 0)
|
||||
{
|
||||
srefx = (1 - uv.x) - 0.5;
|
||||
refx = abs((1 - uv.x) - 0.5);
|
||||
}
|
||||
|
||||
phase = abs(_moonParams.w);
|
||||
float refy = abs(uv.y - 0.5);
|
||||
float refxfory = sqrt(0.25 - refy * refy);
|
||||
float xmin = -refxfory;
|
||||
float xmax = refxfory;
|
||||
float xmin1 = (xmax - xmin) * (phase / 2) + xmin;
|
||||
float xmin2 = (xmax - xmin) * phase + xmin;
|
||||
|
||||
if (srefx < xmin1)
|
||||
{
|
||||
alpha = 0;
|
||||
}
|
||||
else if (srefx < xmin2 && xmin1 != xmin2)
|
||||
{
|
||||
alpha = (srefx - xmin1) / (xmin2 - xmin1);
|
||||
}
|
||||
|
||||
return alpha;
|
||||
}
|
||||
|
||||
float Remap(float org_val, float org_min, float org_max, float new_min, float new_max)
|
||||
{
|
||||
return new_min + saturate(((org_val - org_min) / (org_max - org_min))*(new_max - new_min));
|
||||
}
|
||||
|
||||
float4 frag(v2f i) : COLOR
|
||||
{
|
||||
half3 ray = normalize(mul((float3x3)unity_ObjectToWorld, i.vertex));
|
||||
half y = ray.y / 0.02;
|
||||
float3 skyColor = float3(0, 0, 0);
|
||||
|
||||
|
||||
float3 viewDir = normalize(i.WorldPosition + float3(0, 0.2, 0));
|
||||
float3 viewDir2 = normalize(i.WorldPosition + float3(0, 0.1, 0));
|
||||
|
||||
float cosTheta = saturate(dot(normalize(i.WorldPosition), _SunDir));
|
||||
|
||||
float fade = pow(max(0.0, viewDir.y), 1.25);
|
||||
|
||||
//Stars
|
||||
float3 starsMap = texCUBE(_Stars, i.starPos.xyz);
|
||||
if (_StarsTwinkling > 0)
|
||||
{
|
||||
float3 starsTwinklingMap = texCUBE(_StarsTwinklingNoise, i.starsTwinklingPos.xyz);
|
||||
starsMap = starsMap * starsTwinklingMap * 50 * _StarsIntensity * fade;
|
||||
}
|
||||
|
||||
//Galaxy
|
||||
float3 galaxyMap = texCUBE(_Galaxy, i.starPos.xyz);
|
||||
float3 galaxy = galaxyMap * _GalaxyIntensity * fade;
|
||||
|
||||
//Moon
|
||||
float4 moonSampler = tex2D(_MoonTex, i.moonPos.xy);
|
||||
float4 moonGlow = tex2D(_GlowTex, i.moonPos.zw) * i.sky.z;
|
||||
float alpha = MoonPhaseFactor(i.moonPos.xy, _moonParams.w);
|
||||
float3 moonArea = clamp(moonSampler * 10, 0, 1) * i.sky.z;
|
||||
moonSampler = lerp(float4(0, 0, 0, 0), moonSampler, alpha);
|
||||
moonSampler = (moonSampler * _MoonColor) * 2;
|
||||
float starsBehindMoon = 1 - clamp((moonArea * 5), 0, 1);
|
||||
|
||||
float3 nightSky = (starsMap + galaxy) * starsBehindMoon;
|
||||
|
||||
//Sky Colors
|
||||
float3 horizonColor = lerp(_HorizonBackColor.rgb, _HorizonColor.rgb, cosTheta);
|
||||
|
||||
|
||||
skyColor = lerp(horizonColor,_SkyColor.rgb,smoothstep(dot(viewDir.y, float3(0,3,0)),0,0.3));
|
||||
|
||||
|
||||
if (y < 50.0 && y > 5.0)
|
||||
skyColor = horizonColor;
|
||||
|
||||
skyColor = skyColor + nightSky;
|
||||
|
||||
//Add moon
|
||||
skyColor += ((moonSampler.rgb * i.sky.z) + ((moonGlow.xyz * _moonGlowColor) * _moonParams.z) * (1 - moonSampler.a));
|
||||
|
||||
//Sun Disc
|
||||
half eyeCos = dot(_SunDir, ray);
|
||||
half eyeCos2 = eyeCos * eyeCos;
|
||||
half mie = getMiePhase(eyeCos, eyeCos2, y);
|
||||
skyColor += mie * _SunColor.rgb;
|
||||
|
||||
float ground = Remap(viewDir2.y, -0.15, 0, 0, 1);
|
||||
//Ground Color
|
||||
skyColor = lerp(skyColor * _GroundColor.rgb, skyColor, saturate(ground));
|
||||
|
||||
//Weather Color Mod
|
||||
skyColor = lerp(skyColor, (lerp(skyColor, _weatherSkyMod.rgb, _weatherSkyMod.a)), _weatherSkyMod.a);
|
||||
|
||||
return float4(skyColor,1);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
|
||||
//AURORA
|
||||
Pass
|
||||
{
|
||||
Blend One One
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile __ ENVIRO_AURORA
|
||||
#include "UnityCG.cginc"
|
||||
#pragma exclude_renderers gles
|
||||
|
||||
|
||||
sampler2D _Aurora_Layer_1;
|
||||
sampler2D _Aurora_Layer_2;
|
||||
sampler2D _Aurora_Colorshift;
|
||||
|
||||
float4 _AuroraColor;
|
||||
float _AuroraIntensity;
|
||||
float _AuroraBrightness;
|
||||
float _AuroraContrast;
|
||||
float _AuroraHeight;
|
||||
float _AuroraScale;
|
||||
float _AuroraSpeed;
|
||||
float _AuroraSteps;
|
||||
|
||||
float4 _Aurora_Tiling_Layer1;
|
||||
float4 _Aurora_Tiling_Layer2;
|
||||
float4 _Aurora_Tiling_ColorShift;
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
float3 worldPos : TEXCOORD0;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f vert(appdata_full v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v); //Insert
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o); //Insert
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); //Insert
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
|
||||
return o;
|
||||
}
|
||||
|
||||
float randomNoise(float3 co) {
|
||||
return frac(sin(dot(co.xyz ,float3(17.2486,32.76149, 368.71564))) * 32168.47512);
|
||||
}
|
||||
|
||||
half4 SampleAurora(float3 uv) {
|
||||
|
||||
float2 uv_1 = uv.xy * _Aurora_Tiling_Layer1.xy + (_Aurora_Tiling_Layer1.zw * _AuroraSpeed * _Time.y);
|
||||
|
||||
half4 aurora = tex2Dlod(_Aurora_Layer_1, float4(uv_1.xy,0,0));
|
||||
|
||||
float2 uv_2 = uv_1 * _Aurora_Tiling_Layer2.xy + (_Aurora_Tiling_Layer2.zw * _AuroraSpeed * _Time.y);
|
||||
half4 aurora2 = tex2Dlod(_Aurora_Layer_2, float4(uv_2.xy,0,0));
|
||||
aurora += (aurora2 - 0.5) * 0.5;
|
||||
|
||||
aurora.w = aurora.w * 0.8 + 0.05;
|
||||
|
||||
float3 uv_3 = float3(uv.xy * _Aurora_Tiling_ColorShift.xy + (_Aurora_Tiling_ColorShift.zw * _AuroraSpeed * _Time.y), 0.0);
|
||||
half4 cloudColor = tex2Dlod(_Aurora_Colorshift, float4(uv_3.xy,0,0));
|
||||
|
||||
half contrastMask = 1.0 - saturate(aurora.a);
|
||||
contrastMask = pow(contrastMask, _AuroraContrast);
|
||||
aurora.rgb *= lerp(half3(0,0,0), _AuroraColor.rgb * cloudColor.rgb * _AuroraBrightness, contrastMask);
|
||||
|
||||
half cloudSub = 1.0 - uv.z;
|
||||
aurora.a = aurora.a - cloudSub * cloudSub;
|
||||
aurora.a = saturate(aurora.a * _AuroraIntensity);
|
||||
aurora.rgb *= aurora.a;
|
||||
|
||||
return aurora;
|
||||
}
|
||||
|
||||
fixed4 frag(v2f i) : SV_Target
|
||||
{
|
||||
#if defined(ENVIRO_AURORA)
|
||||
|
||||
if (_AuroraIntensity < 0.05)
|
||||
return float4(0,0,0,0);
|
||||
|
||||
float3 viewDir = normalize(i.worldPos - _WorldSpaceCameraPos);
|
||||
|
||||
float viewFalloff = 1.0 - saturate(dot(viewDir, float3(0,1,0)));
|
||||
|
||||
if (viewDir.y < 0 || viewDir.y > 1)
|
||||
return half4(0, 0, 0, 0);
|
||||
|
||||
float3 traceDir = normalize(viewDir + float3(0, viewFalloff * 0.2 ,0));
|
||||
|
||||
float3 worldPos = _WorldSpaceCameraPos + traceDir * ((_AuroraHeight - _WorldSpaceCameraPos.y) / max(traceDir.y, 0.01));
|
||||
float3 uv = float3(worldPos.xz * 0.01 * _AuroraScale, 0);
|
||||
|
||||
half3 uvStep = half3(traceDir.xz * -1.0 * (1.0 / traceDir.y), 1.0) * (1.0 / _AuroraSteps);
|
||||
uv += uvStep * randomNoise(i.worldPos + _SinTime.w);
|
||||
|
||||
half4 finalColor = half4(0,0,0,0);
|
||||
|
||||
[loop]
|
||||
for (int i = 0; i < _AuroraSteps; i++)
|
||||
{
|
||||
if (finalColor.a > 1)
|
||||
break;
|
||||
|
||||
uv += uvStep;
|
||||
finalColor += SampleAurora(uv) * (1.0 - finalColor.a);
|
||||
}
|
||||
|
||||
finalColor *= viewDir.y;
|
||||
|
||||
return finalColor;
|
||||
#else
|
||||
return half4(0, 0, 0, 0);
|
||||
#endif
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
|
||||
//Cirrus Clouds
|
||||
Pass
|
||||
{
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
|
||||
CGPROGRAM
|
||||
#pragma target 2.0
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
uniform sampler2D _CloudMap;
|
||||
uniform float _CloudAlpha;
|
||||
uniform float _CloudCoverage;
|
||||
uniform float _CloudAltitude;
|
||||
uniform float4 _CloudColor;
|
||||
uniform float _CloudColorPower;
|
||||
uniform float2 _CloudAnimation;
|
||||
|
||||
struct appdata {
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 Position : SV_POSITION;
|
||||
float4 uv : TEXCOORD0;
|
||||
float3 worldPos : TEXCOORD1;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v); //Insert
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o); //Insert
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); //Insert
|
||||
o.Position = UnityObjectToClipPos(v.vertex);
|
||||
o.worldPos = normalize(v.vertex).xyz;
|
||||
float3 viewDir = normalize(o.worldPos + float3(0,1,0));
|
||||
o.worldPos.y *= 1 - dot(viewDir.y + _CloudAltitude, float3(0,-0.15,0));
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 frag(v2f i) : SV_Target
|
||||
{
|
||||
float3 uvs = normalize(i.worldPos);
|
||||
|
||||
float4 uv1;
|
||||
float4 uv2;
|
||||
|
||||
uv1.xy = (uvs.xz * 0.2) + _CloudAnimation;
|
||||
uv2.xy = (uvs.xz * 0.4) + _CloudAnimation;
|
||||
|
||||
float4 clouds1 = tex2D(_CloudMap, uv1.xy);
|
||||
float4 clouds2 = tex2D(_CloudMap, uv2.xy);
|
||||
|
||||
float color1 = pow(clouds1.g + clouds2.g, 0.1);
|
||||
float color2 = pow(clouds2.b * clouds1.r, 0.2);
|
||||
|
||||
float4 finalClouds = lerp(clouds1, clouds2, color1 * color2);
|
||||
float cloudExtinction = pow(uvs.y , 2);
|
||||
|
||||
|
||||
finalClouds.a *= _CloudAlpha;
|
||||
finalClouds.a *= cloudExtinction;
|
||||
|
||||
if (uvs.y < 0)
|
||||
finalClouds.a = 0;
|
||||
|
||||
finalClouds.rgb = finalClouds.a * pow(_CloudColor,_CloudColorPower);
|
||||
finalClouds.rgb = pow(finalClouds.rgb,1 - _CloudCoverage);
|
||||
|
||||
return finalClouds;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
|
||||
CGPROGRAM
|
||||
#pragma target 3.0
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
uniform sampler2D _FlatCloudsBaseTexture;
|
||||
uniform sampler2D _FlatCloudsDetailTexture;
|
||||
uniform float4 _FlatCloudsAnimation;
|
||||
uniform float3 _FlatCloudsLightDirection;
|
||||
uniform float3 _FlatCloudsLightColor;
|
||||
uniform float3 _FlatCloudsAmbientColor;
|
||||
uniform float4 _FlatCloudsLightingParams; // x = LightIntensity, y = AmbientIntensity, z = Absorbtion, w = HgPhase
|
||||
uniform float4 _FlatCloudsParams; // x = Coverage, y = Density, z = Altitude, w = tonemapping
|
||||
uniform float4 _FlatCloudsTiling; // x = Base, y = Detail
|
||||
uniform float _CloudsExposure;
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 Position : SV_POSITION;
|
||||
float4 uv : TEXCOORD0;
|
||||
float3 worldPos : TEXCOORD1;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f vert(appdata_base v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
o.Position = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = normalize(v.vertex).xyzw;
|
||||
float3 viewDir = normalize(o.uv + float3(0, 1, 0));
|
||||
o.uv.y *= 1 - dot(viewDir.y + _FlatCloudsParams.z, float3(0, -0.2, 0));
|
||||
o.worldPos = mul(unity_ObjectToWorld, v.vertex);
|
||||
return o;
|
||||
}
|
||||
|
||||
float Remap(float org_val, float org_min, float org_max, float new_min, float new_max)
|
||||
{
|
||||
return new_min + saturate(((org_val - org_min) / (org_max - org_min))*(new_max - new_min));
|
||||
}
|
||||
|
||||
float HenryGreenstein(float cosTheta, float g)
|
||||
{
|
||||
float k = 3.0 / (8.0 * 3.1415926f) * (1.0 - g * g) / (2.0 + g * g);
|
||||
return k * (1.0 + cosTheta * cosTheta) / pow(abs(1.0 + g * g - 2.0 * g * cosTheta), 1.5);
|
||||
}
|
||||
half3 tonemapACES(half3 color, float Exposure)
|
||||
{
|
||||
color *= Exposure;
|
||||
|
||||
// See https://knarkowicz.wordpress.com/2016/01/06/aces-filmic-tone-mapping-curve/
|
||||
const half a = 2.51;
|
||||
const half b = 0.03;
|
||||
const half c = 2.43;
|
||||
const half d = 0.59;
|
||||
const half e = 0.14;
|
||||
return saturate((color * (a * color + b)) / (color * (c * color + d) + e));
|
||||
}
|
||||
|
||||
float CalculateCloudDensity(float2 posBase, float2 posDetail, float coverage)
|
||||
{
|
||||
float4 baseNoise = tex2D(_FlatCloudsBaseTexture, posBase);
|
||||
float low_freq_fBm = (baseNoise.g * 0.625) + (baseNoise.b * 0.25) + (baseNoise.a * 0.125);
|
||||
float base_cloud = Remap(baseNoise.r, -(1.0 - low_freq_fBm), 1.0, 0.0, 1.0) * coverage;
|
||||
|
||||
float4 detailNoise = tex2D(_FlatCloudsDetailTexture, posDetail * 2);
|
||||
float high_freq_fBm = (detailNoise.r * 0.625) + (detailNoise.g * 0.25) + (detailNoise.b * 0.125);
|
||||
float density = Remap(base_cloud, 1.0 - high_freq_fBm * 0.5, 1.0, 0.0, 1.0);
|
||||
|
||||
density *= pow(high_freq_fBm, 0.4);
|
||||
density *= _FlatCloudsParams.y;
|
||||
|
||||
return density;
|
||||
}
|
||||
|
||||
half4 frag(v2f i) : SV_Target
|
||||
{
|
||||
half4 col = 0;
|
||||
float3 uvs = normalize(i.uv);
|
||||
|
||||
float4 uv1;
|
||||
uv1.xy = (uvs.xz * _FlatCloudsTiling.x) + _FlatCloudsAnimation.xy;
|
||||
uv1.zw = (uvs.xz * _FlatCloudsTiling.y) + _FlatCloudsAnimation.zw;
|
||||
|
||||
float cloudExtinction = pow(uvs.y, 2);
|
||||
half density = CalculateCloudDensity(uv1.xy, uv1.zw, _FlatCloudsParams.x);
|
||||
|
||||
//Lighting
|
||||
fixed absorbtion = exp2(-1 * (density * _FlatCloudsLightingParams.z));
|
||||
float3 viewDir = normalize(i.worldPos - _WorldSpaceCameraPos);
|
||||
float inscatterAngle = dot(normalize(_FlatCloudsLightDirection), -viewDir);
|
||||
fixed hg = HenryGreenstein(inscatterAngle, _FlatCloudsLightingParams.w) * 2 * absorbtion;
|
||||
fixed lighting = density * (absorbtion + hg);
|
||||
float3 lightColor = pow(_FlatCloudsLightColor, 2) * (_FlatCloudsLightingParams.x);
|
||||
col.rgb = lightColor * lighting;
|
||||
col.rgb = col.rgb + (_FlatCloudsAmbientColor * _FlatCloudsLightingParams.y);
|
||||
|
||||
//Tonemapping
|
||||
if (_FlatCloudsParams.w == 1)
|
||||
col.rgb = tonemapACES(col.rgb, _CloudsExposure);
|
||||
|
||||
|
||||
col.a = saturate(density * cloudExtinction);
|
||||
|
||||
if (uvs.y < 0)
|
||||
col.a = 0;
|
||||
|
||||
return col;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
}
|
||||
FallBack "None"
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8e6e0603052e7ce47b1d8c48aa9ee67e
|
||||
timeCreated: 1503929340
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
-125
@@ -1,125 +0,0 @@
|
||||
Shader "Enviro/Standard/WeatherMap" {
|
||||
Properties {
|
||||
_Coverage ("Coverage", Range(0,1)) = 0.5
|
||||
_Tiling ("Tiling", Range(1,100)) = 10
|
||||
}
|
||||
SubShader {
|
||||
Tags { "RenderType"="Opaque" }
|
||||
LOD 200
|
||||
Pass {
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
#include "/Core/EnviroNoiseCore.cginc"
|
||||
#pragma target 3.0
|
||||
#pragma exclude_renderers gles
|
||||
|
||||
|
||||
#define CLASSICPERLIN
|
||||
|
||||
sampler2D _MainTex;
|
||||
|
||||
struct VertexInput {
|
||||
half4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VertexOutput {
|
||||
float4 position : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
VertexOutput vert (VertexInput v) {
|
||||
VertexOutput o;
|
||||
o.position = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.uv;
|
||||
return o;
|
||||
}
|
||||
|
||||
float4x4 world_view_proj;
|
||||
|
||||
float _Coverage;
|
||||
float _CloudsType;
|
||||
float _CoverageType;
|
||||
int _Tiling;
|
||||
float2 _WindDir;
|
||||
float2 _Location;
|
||||
float _AnimSpeedScale;
|
||||
float4 _LightingVariance;
|
||||
|
||||
float set_range(float value, float low, float high) {
|
||||
return saturate((value - low)/(high - low));
|
||||
}
|
||||
|
||||
float remap(float value, float original_min, float original_max, float new_min, float new_max)
|
||||
{
|
||||
return new_min + saturate(((value - original_min) / (original_max - original_min)) * (new_max - new_min));
|
||||
}
|
||||
|
||||
float dilate_perlin_worley(float p, float w, float x) {
|
||||
float curve = 0.75;
|
||||
if (x < 0.5) {
|
||||
x = x / 0.5;
|
||||
float n = p + w * x;
|
||||
return n * lerp(1, 0.5, pow(x, curve));
|
||||
}
|
||||
else {
|
||||
x = (x - 0.5) / 0.5;
|
||||
float n = w + p * (1.0 - x);
|
||||
return n * lerp(0.5, 1.0, pow(x, 1.0 / curve));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
float4 frag(VertexInput input) : SV_Target
|
||||
{
|
||||
float2 xy_offset = _WindDir * 10 * _AnimSpeedScale;
|
||||
float2 xy_offset1 = xy_offset;
|
||||
float2 xy_offset2 = xy_offset + float2(50,100);
|
||||
float2 xy_offset3 = xy_offset + float2(100, 50);
|
||||
float2 xy_offset4 = xy_offset + float2(100, 500);
|
||||
|
||||
float2 sampling_pos0 = float2(input.uv + xy_offset1 + _Location) * _Tiling;
|
||||
float2 sampling_pos01 = float2(input.uv + xy_offset4 + _Location) * _Tiling;
|
||||
float2 sampling_pos02 = float2(input.uv + xy_offset2 + _Location) * 2 * _Tiling;
|
||||
float2 sampling_pos03 = float2(input.uv + xy_offset3 + _Location) * _LightingVariance.y * _Tiling;
|
||||
|
||||
float perlinT1 = saturate(CalculatePerlinTileing5(sampling_pos0.xy,float2(_Tiling, _Tiling)));
|
||||
float perlinT2 = saturate(CalculatePerlinTileing5(sampling_pos01.xy, float2(_Tiling, _Tiling)));
|
||||
float perlinT3 = saturate(CalculatePerlinTileing5(sampling_pos02.xy, float2(_Tiling, _Tiling)));
|
||||
|
||||
float perlinT = perlinT1 + saturate(perlinT2 - perlinT1);
|
||||
float worleyT = CalculateWorley3oct(sampling_pos0.xy, 1.5, 2, 2.5);
|
||||
|
||||
//float worley2 = saturate( pow( CalculateWorley1(sampling_pos0.xy, 5),0.5));
|
||||
|
||||
float perlin_worleyCov = dilate_perlin_worley(perlinT3, worleyT, 0.6);
|
||||
|
||||
float perlin_worley = dilate_perlin_worley(perlinT, perlin_worleyCov, _CoverageType);
|
||||
|
||||
float worleyFull = saturate((CalculateWorley1(sampling_pos01.xy, 4) - perlin_worley));
|
||||
|
||||
//float perlin_worleyFull = dilate_perlin_worley(perlinT3, worleyFull, 0.75);
|
||||
float coverage = perlin_worley + (_Coverage * worleyFull);
|
||||
//float coverage = perlin_worley * worley2 + (_Coverage * worleyFull);
|
||||
|
||||
if (_Coverage < 0)
|
||||
coverage += _Coverage;
|
||||
|
||||
float type = (coverage + (_Coverage - perlin_worley) * (1-_CloudsType)) * _CloudsType;
|
||||
/////
|
||||
|
||||
//Clouds Lighting Variance
|
||||
float perlinT4 = saturate(CalculatePerlinTileing5(sampling_pos03.xy, float2(_Tiling, _Tiling)));
|
||||
|
||||
perlinT4 = clamp(perlinT4, _LightingVariance.x, 1);
|
||||
|
||||
return float4(coverage, perlinT4, type, 0);
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
FallBack "Diffuse"
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8c0c433dbcbd62f4d8cf13545909d440
|
||||
timeCreated: 1507124107
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,233 +0,0 @@
|
||||
Shader "KriptoFX/BFX/BFX_Blood"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_Color("Color", Color) = (1,1,1,1)
|
||||
|
||||
_boundingMax("Bounding Max", Float) = 1.0
|
||||
_boundingMin("Bounding Min", Float) = 1.0
|
||||
_numOfFrames("Number Of Frames", int) = 240
|
||||
_speed("Speed", Float) = 0.33
|
||||
_HeightOffset("_Height Offset", Vector) = (0, 0, 0)
|
||||
//[MaterialToggle] _pack_normal("Pack Normal", Float) = 0
|
||||
_posTex("Position Map (RGB)", 2D) = "white" {}
|
||||
_nTex("Normal Map (RGB)", 2D) = "grey" {}
|
||||
_SunPos("Sun Pos", Vector) = (1, 0.5, 1, 0)
|
||||
|
||||
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
|
||||
Tags{ "Queue" = "AlphaTest+1"}
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
Cull Back
|
||||
ZWrite On
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#pragma multi_compile_instancing
|
||||
#pragma multi_compile_fog
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 tangent : TEXCOORD2;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
|
||||
float4 pos : SV_POSITION;
|
||||
float3 worldNormal : TEXCOORD2;
|
||||
float4 screenPos : TEXCOORD4;
|
||||
float3 viewDir : TEXCOORD5;
|
||||
float height : TEXCOORD6;
|
||||
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
sampler2D _GrabTexture;
|
||||
sampler2D _posTex;
|
||||
sampler2D _nTex;
|
||||
uniform float _boundingMax;
|
||||
uniform float _boundingMin;
|
||||
uniform float _speed;
|
||||
uniform int _numOfFrames;
|
||||
half4 _Color;
|
||||
|
||||
float4 _HeightOffset;
|
||||
float _HDRFix;
|
||||
float4 _SunPos;
|
||||
|
||||
UNITY_INSTANCING_BUFFER_START(Props)
|
||||
UNITY_DEFINE_INSTANCED_PROP(float, _UseCustomTime)
|
||||
UNITY_DEFINE_INSTANCED_PROP(float, _TimeInFrames)
|
||||
UNITY_DEFINE_INSTANCED_PROP(float, _LightIntencity)
|
||||
UNITY_INSTANCING_BUFFER_END(Props)
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o);
|
||||
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
float timeInFrames;
|
||||
float currentSpeed = 1.0f / (_numOfFrames / _speed);
|
||||
timeInFrames = UNITY_ACCESS_INSTANCED_PROP(Props, _UseCustomTime) > 0.5 ? UNITY_ACCESS_INSTANCED_PROP(Props, _TimeInFrames) : 1;
|
||||
|
||||
float4 texturePos = tex2Dlod(_posTex, float4(v.uv.x, (timeInFrames + v.uv.y), 0, 0));
|
||||
float3 textureN = tex2Dlod(_nTex, float4(v.uv.x, (timeInFrames + v.uv.y), 0, 0));
|
||||
|
||||
|
||||
#if !UNITY_COLORSPACE_GAMMA
|
||||
texturePos.xyz = LinearToGammaSpace(texturePos.xyz);
|
||||
textureN = LinearToGammaSpace(textureN);
|
||||
#endif
|
||||
|
||||
float expand = _boundingMax - _boundingMin;
|
||||
texturePos.xyz *= expand;
|
||||
texturePos.xyz += _boundingMin;
|
||||
texturePos.x *= -1;
|
||||
v.vertex.xyz = texturePos.xzy;
|
||||
v.vertex.xyz += _HeightOffset.xyz;
|
||||
|
||||
o.worldNormal = textureN.xzy * 2 - 1;
|
||||
o.worldNormal.x *= -1;
|
||||
o.viewDir = ObjSpaceViewDir(v.vertex);
|
||||
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
o.screenPos = ComputeGrabScreenPos(o.pos);
|
||||
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 frag(v2f i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(i);
|
||||
|
||||
i.worldNormal = normalize(i.worldNormal);
|
||||
i.viewDir = normalize(i.viewDir);
|
||||
|
||||
half fresnel = saturate(1 - dot(i.worldNormal, i.viewDir));
|
||||
half intencity = UNITY_ACCESS_INSTANCED_PROP(Props, _LightIntencity);
|
||||
half3 grabColor = intencity * 0.75;
|
||||
half light = max(0.001, dot(normalize(i.worldNormal), normalize(_SunPos.xyz)));
|
||||
light = pow(light, 50) * 10;
|
||||
#if !UNITY_COLORSPACE_GAMMA
|
||||
_Color.rgb = _Color.rgb * .65;
|
||||
fresnel = fresnel * fresnel;
|
||||
#endif
|
||||
grabColor *= _Color.rgb;
|
||||
grabColor = lerp(grabColor * 0.15, grabColor, fresnel);
|
||||
grabColor = min(grabColor, _Color.rgb * 0.55);
|
||||
|
||||
half3 color = grabColor.xyz + saturate(light) * intencity;
|
||||
return half4(color, _Color.a);
|
||||
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
//you can optimize it by removing shadow rendering and depth writing
|
||||
//start remove line
|
||||
|
||||
Pass
|
||||
{
|
||||
Tags {"LightMode" = "ShadowCaster"}
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile_shadowcaster
|
||||
#pragma multi_compile_instancing
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
sampler2D _GrabTexture;
|
||||
sampler2D _posTex;
|
||||
sampler2D _nTex;
|
||||
uniform float _boundingMax;
|
||||
uniform float _boundingMin;
|
||||
uniform float _speed;
|
||||
uniform int _numOfFrames;
|
||||
half4 _Color;
|
||||
|
||||
float4 _HeightOffset;
|
||||
|
||||
UNITY_INSTANCING_BUFFER_START(Props)
|
||||
UNITY_DEFINE_INSTANCED_PROP(float, _TimeInFrames)
|
||||
UNITY_INSTANCING_BUFFER_END(Props)
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f {
|
||||
V2F_SHADOW_CASTER;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o);
|
||||
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
float timeInFrames;
|
||||
float currentSpeed = 1.0f / (_numOfFrames / _speed);
|
||||
timeInFrames = UNITY_ACCESS_INSTANCED_PROP(Props, _TimeInFrames);
|
||||
|
||||
float4 texturePos = tex2Dlod(_posTex, float4(v.uv.x, (timeInFrames + v.uv.y), 0, 0));
|
||||
|
||||
#if !UNITY_COLORSPACE_GAMMA
|
||||
texturePos.xyz = LinearToGammaSpace(texturePos.xyz);
|
||||
#endif
|
||||
|
||||
float expand = _boundingMax - _boundingMin;
|
||||
texturePos.xyz *= expand;
|
||||
texturePos.xyz += _boundingMin;
|
||||
texturePos.x *= -1;
|
||||
v.vertex.xyz = texturePos.xzy;
|
||||
v.vertex.xyz += _HeightOffset.xyz;
|
||||
|
||||
TRANSFER_SHADOW_CASTER_NORMALOFFSET(o)
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 frag(v2f i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(i);
|
||||
SHADOW_CASTER_FRAGMENT(i)
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
//end remove light
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 178af239732bb6042a96790731226ce2
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,216 +0,0 @@
|
||||
Shader "KriptoFX/BFX/BFX_Decal"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[HDR] _TintColor("Tint Color", Color) = (1,1,1,1)
|
||||
_MainTex("NormalAlpha", 2D) = "white" {}
|
||||
_LookupFade("Lookup Fade Texture", 2D) = "white" {}
|
||||
_Cutout("Cutout", Range(0, 1)) = 1
|
||||
_CutoutTex("CutoutDepth(XZ)", 2D) = "white" {}
|
||||
[Space]
|
||||
_SunPos("Sun Pos", Vector) = (1, 0.5, 1, 0)
|
||||
//[Toggle(CLAMP_SIDE_SURFACE)] _ClampSideSurface("Clamp side surface", Int) = 0
|
||||
}
|
||||
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags{ "Queue" = "AlphaTest"}
|
||||
Blend DstColor SrcColor
|
||||
//Blend SrcAlpha OneMinusSrcAlpha
|
||||
Cull Front
|
||||
ZTest Always
|
||||
ZWrite Off
|
||||
|
||||
Pass
|
||||
{
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#pragma multi_compile_fog
|
||||
#pragma multi_compile_instancing
|
||||
#pragma multi_compile _ USE_CUSTOM_DECAL_LAYERS
|
||||
#pragma shader_feature CLAMP_SIDE_SURFACE
|
||||
#pragma multi_compile _ USE_CUSTOM_DECAL_LAYERS_IGNORE_MODE
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
sampler2D _MainTex;
|
||||
sampler2D _Flowmap;
|
||||
sampler2D _LookupFade;
|
||||
sampler2D _CutoutTex;
|
||||
|
||||
float4 _MainTex_ST;
|
||||
float4 _MainTex_NextFrame;
|
||||
float4 _CutoutTex_ST;
|
||||
|
||||
UNITY_INSTANCING_BUFFER_START(Props)
|
||||
UNITY_DEFINE_INSTANCED_PROP(half4, _TintColor)
|
||||
UNITY_DEFINE_INSTANCED_PROP(half, _Cutout)
|
||||
UNITY_DEFINE_INSTANCED_PROP(float, _LightIntencity)
|
||||
UNITY_INSTANCING_BUFFER_END(Props)
|
||||
|
||||
|
||||
half4 _CutoutColor;
|
||||
half4 _FresnelColor;
|
||||
half4 _DistortionSpeedScale;
|
||||
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
|
||||
UNITY_DECLARE_DEPTH_TEXTURE(_LayerDecalDepthTexture);
|
||||
half InterpolationValue;
|
||||
half _AlphaPow;
|
||||
half _DistortSpeed;
|
||||
half _DistortScale;
|
||||
float4 _SunPos;
|
||||
half _DepthMul;
|
||||
half3 _DecalForwardDir;
|
||||
|
||||
struct appdata_t {
|
||||
float4 vertex : POSITION;
|
||||
float4 normal : NORMAL;
|
||||
half4 color : COLOR;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f {
|
||||
float4 vertex : SV_POSITION;
|
||||
half4 color : COLOR;
|
||||
|
||||
float4 screenUV : TEXCOORD0;
|
||||
float4 ray : TEXCOORD1;
|
||||
float3 rayCameraOffset : TEXCOORD2;
|
||||
float3 viewDir : TEXCOORD3;
|
||||
float4 screenPos : TEXCOORD4;
|
||||
|
||||
UNITY_FOG_COORDS(5)
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
|
||||
v2f vert(appdata_t v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.color = v.color;
|
||||
|
||||
|
||||
o.screenUV = ComputeScreenPos(o.vertex);
|
||||
o.viewDir = normalize(ObjSpaceViewDir(v.vertex));
|
||||
o.screenPos = ComputeGrabScreenPos(o.vertex);
|
||||
UNITY_TRANSFER_FOG(o,o.vertex);
|
||||
|
||||
|
||||
float3 viewRay = UnityObjectToViewPos(v.vertex).xyz;
|
||||
o.ray.w = viewRay.z;
|
||||
viewRay *= -1;
|
||||
o.ray.xyz = mul((float3x3)mul(unity_WorldToObject, UNITY_MATRIX_I_V), viewRay);
|
||||
o.rayCameraOffset = mul(mul(unity_WorldToObject, UNITY_MATRIX_I_V), float4(0, 0, 0, 1)).xyz;
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
half4 frag(v2f i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(i);
|
||||
|
||||
|
||||
#if USE_CUSTOM_DECAL_LAYERS
|
||||
float depth = SAMPLE_DEPTH_TEXTURE(_LayerDecalDepthTexture, (i.screenUV.xy / i.screenUV.w));
|
||||
float depthMask = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, (i.screenUV.xy / i.screenUV.w));
|
||||
float fade = depth < depthMask - 0.0005 ? 0 : 1;
|
||||
#if USE_CUSTOM_DECAL_LAYERS_IGNORE_MODE
|
||||
fade = 1 - fade;
|
||||
depth = depthMask;
|
||||
#endif
|
||||
#else
|
||||
float depth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, (i.screenUV.xy / i.screenUV.w));
|
||||
#endif
|
||||
|
||||
i.ray /= i.ray.w;
|
||||
float zEye = LinearEyeDepth(depth);
|
||||
float3 decalSpaceScenePos = i.rayCameraOffset + i.ray.xyz * zEye;
|
||||
|
||||
|
||||
|
||||
|
||||
float3 stepVal = saturate((0.5 - abs(decalSpaceScenePos.xyz)) * 10000);
|
||||
half lookupHeight = tex2D(_LookupFade, float2(decalSpaceScenePos.y + 0.5, 0));
|
||||
|
||||
float projClipFade = stepVal.x * stepVal.y * stepVal.z * lookupHeight;
|
||||
#if USE_CUSTOM_DECAL_LAYERS
|
||||
projClipFade *= fade;
|
||||
#endif
|
||||
|
||||
|
||||
#if CLAMP_SIDE_SURFACE
|
||||
#ifdef UNITY_UV_STARTS_AT_TOP
|
||||
half3 n = normalize(cross(ddx(decalSpaceScenePos), ddy(decalSpaceScenePos) * _ProjectionParams.x));
|
||||
#else
|
||||
half3 n = normalize(cross(ddx(decalSpaceScenePos), -ddy(decalSpaceScenePos) * _ProjectionParams.x));
|
||||
#endif
|
||||
|
||||
half angle = abs(dot(n, _DecalForwardDir));
|
||||
|
||||
angle = angle > 0.1 ? 1 : 0;
|
||||
projClipFade *= angle;
|
||||
//return float4(saturate(angle), 0, 0, 1);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
float2 uv = decalSpaceScenePos.xz + 0.5;
|
||||
float2 uvMain = uv * _MainTex_ST.xy + _MainTex_ST.zw;
|
||||
float2 uvCutout = (decalSpaceScenePos.xz + 0.5) * _CutoutTex_ST.xy + _CutoutTex_ST.zw;
|
||||
|
||||
half4 normAlpha = tex2D(_MainTex, uvMain);
|
||||
half4 res = 0;
|
||||
res.a = saturate(normAlpha.w * 2);
|
||||
if (res.a < 0.1 || projClipFade < 0.1) discard;
|
||||
|
||||
normAlpha.xy = normAlpha.xy * 2 - 1;
|
||||
float3 normal = normalize(float3(normAlpha.x, 1, normAlpha.y));
|
||||
|
||||
half3 mask = tex2D(_CutoutTex, uvCutout).xyz;
|
||||
half cutout = 0.5 + UNITY_ACCESS_INSTANCED_PROP(Props, _Cutout) * i.color.a * 0.5;
|
||||
|
||||
half alphaMask = saturate((mask.r - (cutout * 2 - 1)) * 20) * res.a;
|
||||
half colorMask = saturate((mask.r - (cutout * 2 - 1)) * 5) * res.a;
|
||||
res.a = alphaMask;
|
||||
res.a = saturate(res.a * projClipFade);
|
||||
|
||||
|
||||
float intencity = UNITY_ACCESS_INSTANCED_PROP(Props, _LightIntencity);
|
||||
float light = max(0.001, dot(normal, normalize(_SunPos.xyz)));
|
||||
light = pow(light, 150) * 3 * intencity;
|
||||
light *= (1 - mask.z * colorMask);
|
||||
|
||||
float4 tintColor = UNITY_ACCESS_INSTANCED_PROP(Props, _TintColor);
|
||||
#if !UNITY_COLORSPACE_GAMMA
|
||||
tintColor = tintColor * 1.35;
|
||||
#endif
|
||||
res.rgb = lerp(tintColor.rgb, tintColor.rgb * 0.25, mask.z * colorMask) + light;
|
||||
|
||||
|
||||
half fresnel = (1 - dot(normal, normalize(i.viewDir)));
|
||||
fresnel = pow(fresnel + 0.1, 5);
|
||||
|
||||
UNITY_APPLY_FOG_COLOR(i.fogCoord, res, half4(1, 1, 1, 1));
|
||||
return lerp(0.5, res, res.a * tintColor.a);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bd420104d99485e45b901bffcc31e6dd
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,173 +0,0 @@
|
||||
// Author: vinipc
|
||||
// Forum post: https://forum.unity3d.com/threads/simple-optimized-blur-shader.185327/#post-3038561
|
||||
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
|
||||
// Based on cician's shader from: https://forum.unity3d.com/threads/simple-optimized-blur-shader.185327/#post-1267642
|
||||
|
||||
Shader "Custom/MaskedUIBlur"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_Size("Blur", Range(0, 30)) = 1
|
||||
[HideInInspector] _MainTex("Tint Color (RGB)", 2D) = "white" {}
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"Queue" = "Transparent"
|
||||
"IgnoreProjector" = "True"
|
||||
"RenderType" = "Opaque"
|
||||
}
|
||||
|
||||
Cull Off
|
||||
Lighting Off
|
||||
ZWrite Off
|
||||
ZTest[unity_GUIZTestMode]
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
|
||||
// Horizontal blur
|
||||
GrabPass
|
||||
{
|
||||
"_HBlur"
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata_t {
|
||||
float4 vertex : POSITION;
|
||||
float2 texcoord: TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f {
|
||||
float4 vertex : POSITION;
|
||||
float4 uvgrab : TEXCOORD0;
|
||||
float2 uvmain : TEXCOORD1;
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
|
||||
v2f vert(appdata_t v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
float scale = -1.0;
|
||||
#else
|
||||
float scale = 1.0;
|
||||
#endif
|
||||
|
||||
o.uvgrab.xy = (float2(o.vertex.x, o.vertex.y * scale) + o.vertex.w) * 0.5;
|
||||
o.uvgrab.zw = o.vertex.zw;
|
||||
|
||||
o.uvmain = TRANSFORM_TEX(v.texcoord, _MainTex);
|
||||
return o;
|
||||
}
|
||||
|
||||
sampler2D _HBlur;
|
||||
float4 _HBlur_TexelSize;
|
||||
float _Size;
|
||||
|
||||
half4 frag(v2f i) : COLOR
|
||||
{
|
||||
float alpha = tex2D(_MainTex, i.uvmain).a;
|
||||
half4 sum = half4(0,0,0,0);
|
||||
|
||||
#define GRABPIXEL(weight,kernelx) tex2Dproj( _HBlur, UNITY_PROJ_COORD(float4(i.uvgrab.x + _HBlur_TexelSize.x * kernelx * _Size * alpha, i.uvgrab.y, i.uvgrab.z, i.uvgrab.w))) * weight
|
||||
|
||||
sum += GRABPIXEL(0.05, -4.0);
|
||||
sum += GRABPIXEL(0.09, -3.0);
|
||||
sum += GRABPIXEL(0.12, -2.0);
|
||||
sum += GRABPIXEL(0.15, -1.0);
|
||||
sum += GRABPIXEL(0.18, 0.0);
|
||||
sum += GRABPIXEL(0.15, +1.0);
|
||||
sum += GRABPIXEL(0.12, +2.0);
|
||||
sum += GRABPIXEL(0.09, +3.0);
|
||||
sum += GRABPIXEL(0.05, +4.0);
|
||||
|
||||
return sum;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
// Vertical blur
|
||||
GrabPass
|
||||
{
|
||||
"_VBlur"
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata_t {
|
||||
float4 vertex : POSITION;
|
||||
float2 texcoord: TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f {
|
||||
float4 vertex : POSITION;
|
||||
float4 uvgrab : TEXCOORD0;
|
||||
float2 uvmain : TEXCOORD1;
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
|
||||
v2f vert(appdata_t v) {
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
float scale = -1.0;
|
||||
#else
|
||||
float scale = 1.0;
|
||||
#endif
|
||||
|
||||
o.uvgrab.xy = (float2(o.vertex.x, o.vertex.y * scale) + o.vertex.w) * 0.5;
|
||||
o.uvgrab.zw = o.vertex.zw;
|
||||
|
||||
o.uvmain = TRANSFORM_TEX(v.texcoord, _MainTex);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
sampler2D _VBlur;
|
||||
float4 _VBlur_TexelSize;
|
||||
float _Size;
|
||||
|
||||
half4 frag(v2f i) : COLOR
|
||||
{
|
||||
float alpha = tex2D(_MainTex, i.uvmain).a;
|
||||
half4 sum = half4(0,0,0,0);
|
||||
|
||||
#define GRABPIXEL(weight,kernely) tex2Dproj( _VBlur, UNITY_PROJ_COORD(float4(i.uvgrab.x, i.uvgrab.y + _VBlur_TexelSize.y * kernely * _Size * alpha, i.uvgrab.z, i.uvgrab.w))) * weight
|
||||
|
||||
sum += GRABPIXEL(0.05, -4.0);
|
||||
sum += GRABPIXEL(0.09, -3.0);
|
||||
sum += GRABPIXEL(0.12, -2.0);
|
||||
sum += GRABPIXEL(0.15, -1.0);
|
||||
sum += GRABPIXEL(0.18, 0.0);
|
||||
sum += GRABPIXEL(0.15, +1.0);
|
||||
sum += GRABPIXEL(0.12, +2.0);
|
||||
sum += GRABPIXEL(0.09, +3.0);
|
||||
sum += GRABPIXEL(0.05, +4.0);
|
||||
|
||||
return sum;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8d4b9dd97e73e304f8ffa86967a64be7
|
||||
timeCreated: 1498987905
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,56 +0,0 @@
|
||||
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
|
||||
|
||||
Shader "GizmosShader"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_Color("Main Color", Color) = (1,1,1,1)
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags{ "Queue" = "Transparent+1" "IgnoreProjector" = "True" "RenderType" = "Opaque" }
|
||||
Lighting Off
|
||||
ZTest Off
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
|
||||
Cull Off
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma target 3.0
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
float4 _Color;
|
||||
float _Scale;
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
};
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o = (v2f)0;
|
||||
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 frag (v2f i) : COLOR
|
||||
{
|
||||
return _Color;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5600d4972a5910646b12d14cf5ad3ee2
|
||||
timeCreated: 1481857916
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,64 +0,0 @@
|
||||
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
|
||||
|
||||
Shader "RotateShader"
|
||||
{
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue"="Transparent+1" "IgnoreProjector"="True" "RenderType"="Transparent" }
|
||||
Lighting Off
|
||||
//ZTest LEqual
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ZWrite Off
|
||||
Cull Off
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma target 3.0
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
float4 _Color;
|
||||
float _Scale;
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float4 color : COLOR;
|
||||
float3 normal : NORMAL;
|
||||
};
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o = (v2f)0;
|
||||
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
o.color = v.color;
|
||||
/*float3 pos = v.vertex.xyz + float3(0.01,0.01,0.0);
|
||||
pos.y = 0;
|
||||
o.normal = mul((float3x3)UNITY_MATRIX_MV, normalize(pos));*/
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 frag (v2f i) : COLOR
|
||||
{
|
||||
/*float angle = dot(i.normal,float3(0,0,1));
|
||||
if (angle < 0)
|
||||
{
|
||||
i.color = i.color.r * 0.299 + i.color.g * 0.587 + i.color.b * 0.114;
|
||||
}*/
|
||||
return i.color;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f5c68f471b9c97347baea380d21fa12b
|
||||
timeCreated: 1481857916
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,55 +0,0 @@
|
||||
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
|
||||
|
||||
Shader "TransparentShader"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_Color("Color Tint", Color) = (1,1,1,1)
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
|
||||
Lighting Off
|
||||
ZTest Off
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ZWrite On
|
||||
Cull Back
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
float4 _Color;
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
};
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 frag (v2f i) : COLOR
|
||||
{
|
||||
return _Color;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5b6767f2de9fd3b42b1149059c1d0da5
|
||||
timeCreated: 1481859361
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,142 +0,0 @@
|
||||
Shader "TextMeshPro/Bitmap Custom Atlas" {
|
||||
|
||||
Properties {
|
||||
_MainTex ("Font Atlas", 2D) = "white" {}
|
||||
_FaceTex ("Font Texture", 2D) = "white" {}
|
||||
_FaceColor ("Text Color", Color) = (1,1,1,1)
|
||||
|
||||
_VertexOffsetX ("Vertex OffsetX", float) = 0
|
||||
_VertexOffsetY ("Vertex OffsetY", float) = 0
|
||||
_MaskSoftnessX ("Mask SoftnessX", float) = 0
|
||||
_MaskSoftnessY ("Mask SoftnessY", float) = 0
|
||||
|
||||
_ClipRect("Clip Rect", vector) = (-32767, -32767, 32767, 32767)
|
||||
_Padding ("Padding", float) = 0
|
||||
|
||||
_StencilComp("Stencil Comparison", Float) = 8
|
||||
_Stencil("Stencil ID", Float) = 0
|
||||
_StencilOp("Stencil Operation", Float) = 0
|
||||
_StencilWriteMask("Stencil Write Mask", Float) = 255
|
||||
_StencilReadMask("Stencil Read Mask", Float) = 255
|
||||
|
||||
_ColorMask("Color Mask", Float) = 15
|
||||
}
|
||||
|
||||
SubShader{
|
||||
|
||||
Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
|
||||
|
||||
Stencil
|
||||
{
|
||||
Ref[_Stencil]
|
||||
Comp[_StencilComp]
|
||||
Pass[_StencilOp]
|
||||
ReadMask[_StencilReadMask]
|
||||
WriteMask[_StencilWriteMask]
|
||||
}
|
||||
|
||||
|
||||
Lighting Off
|
||||
Cull [_CullMode]
|
||||
ZTest [unity_GUIZTestMode]
|
||||
ZWrite Off
|
||||
Fog { Mode Off }
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ColorMask[_ColorMask]
|
||||
|
||||
Pass {
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#pragma multi_compile __ UNITY_UI_CLIP_RECT
|
||||
#pragma multi_compile __ UNITY_UI_ALPHACLIP
|
||||
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata_t {
|
||||
float4 vertex : POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
};
|
||||
|
||||
struct v2f {
|
||||
float4 vertex : SV_POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
float4 mask : TEXCOORD2;
|
||||
};
|
||||
|
||||
uniform sampler2D _MainTex;
|
||||
uniform sampler2D _FaceTex;
|
||||
uniform float4 _FaceTex_ST;
|
||||
uniform fixed4 _FaceColor;
|
||||
|
||||
uniform float _VertexOffsetX;
|
||||
uniform float _VertexOffsetY;
|
||||
uniform float4 _ClipRect;
|
||||
uniform float _MaskSoftnessX;
|
||||
uniform float _MaskSoftnessY;
|
||||
|
||||
float2 UnpackUV(float uv)
|
||||
{
|
||||
float2 output;
|
||||
output.x = floor(uv / 4096);
|
||||
output.y = uv - 4096 * output.x;
|
||||
|
||||
return output * 0.001953125;
|
||||
}
|
||||
|
||||
v2f vert (appdata_t v)
|
||||
{
|
||||
float4 vert = v.vertex;
|
||||
vert.x += _VertexOffsetX;
|
||||
vert.y += _VertexOffsetY;
|
||||
|
||||
vert.xy += (vert.w * 0.5) / _ScreenParams.xy;
|
||||
|
||||
float4 vPosition = UnityPixelSnap(UnityObjectToClipPos(vert));
|
||||
|
||||
fixed4 faceColor = v.color;
|
||||
faceColor *= _FaceColor;
|
||||
|
||||
v2f OUT;
|
||||
OUT.vertex = vPosition;
|
||||
OUT.color = faceColor;
|
||||
OUT.texcoord0 = v.texcoord0;
|
||||
OUT.texcoord1 = TRANSFORM_TEX(UnpackUV(v.texcoord1), _FaceTex);
|
||||
float2 pixelSize = vPosition.w;
|
||||
pixelSize /= abs(float2(_ScreenParams.x * UNITY_MATRIX_P[0][0], _ScreenParams.y * UNITY_MATRIX_P[1][1]));
|
||||
|
||||
// Clamp _ClipRect to 16bit.
|
||||
float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
|
||||
OUT.mask = float4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + pixelSize.xy));
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f IN) : SV_Target
|
||||
{
|
||||
fixed4 color = tex2D(_MainTex, IN.texcoord0) * tex2D(_FaceTex, IN.texcoord1) * IN.color;
|
||||
|
||||
// Alternative implementation to UnityGet2DClipping with support for softness.
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(IN.mask.xy)) * IN.mask.zw);
|
||||
color *= m.x * m.y;
|
||||
#endif
|
||||
|
||||
#if UNITY_UI_ALPHACLIP
|
||||
clip(color.a - 0.001);
|
||||
#endif
|
||||
|
||||
return color;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
CustomEditor "TMPro.EditorUtilities.TMP_BitmapShaderGUI"
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 48bb5f55d8670e349b6e614913f9d910
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,144 +0,0 @@
|
||||
Shader "TextMeshPro/Mobile/Bitmap" {
|
||||
|
||||
Properties {
|
||||
_MainTex ("Font Atlas", 2D) = "white" {}
|
||||
_Color ("Text Color", Color) = (1,1,1,1)
|
||||
_DiffusePower ("Diffuse Power", Range(1.0,4.0)) = 1.0
|
||||
|
||||
_VertexOffsetX("Vertex OffsetX", float) = 0
|
||||
_VertexOffsetY("Vertex OffsetY", float) = 0
|
||||
_MaskSoftnessX("Mask SoftnessX", float) = 0
|
||||
_MaskSoftnessY("Mask SoftnessY", float) = 0
|
||||
|
||||
_ClipRect("Clip Rect", vector) = (-32767, -32767, 32767, 32767)
|
||||
|
||||
_StencilComp("Stencil Comparison", Float) = 8
|
||||
_Stencil("Stencil ID", Float) = 0
|
||||
_StencilOp("Stencil Operation", Float) = 0
|
||||
_StencilWriteMask("Stencil Write Mask", Float) = 255
|
||||
_StencilReadMask("Stencil Read Mask", Float) = 255
|
||||
|
||||
_ColorMask("Color Mask", Float) = 15
|
||||
}
|
||||
|
||||
SubShader {
|
||||
|
||||
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
|
||||
|
||||
Stencil
|
||||
{
|
||||
Ref[_Stencil]
|
||||
Comp[_StencilComp]
|
||||
Pass[_StencilOp]
|
||||
ReadMask[_StencilReadMask]
|
||||
WriteMask[_StencilWriteMask]
|
||||
}
|
||||
|
||||
|
||||
Lighting Off
|
||||
Cull Off
|
||||
ZTest [unity_GUIZTestMode]
|
||||
ZWrite Off
|
||||
Fog { Mode Off }
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ColorMask[_ColorMask]
|
||||
|
||||
Pass {
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
|
||||
#pragma multi_compile __ UNITY_UI_CLIP_RECT
|
||||
#pragma multi_compile __ UNITY_UI_ALPHACLIP
|
||||
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata_t {
|
||||
float4 vertex : POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
};
|
||||
|
||||
struct v2f {
|
||||
float4 vertex : POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float4 mask : TEXCOORD2;
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
fixed4 _Color;
|
||||
float _DiffusePower;
|
||||
|
||||
uniform float _VertexOffsetX;
|
||||
uniform float _VertexOffsetY;
|
||||
uniform float4 _ClipRect;
|
||||
uniform float _MaskSoftnessX;
|
||||
uniform float _MaskSoftnessY;
|
||||
|
||||
v2f vert (appdata_t v)
|
||||
{
|
||||
v2f OUT;
|
||||
float4 vert = v.vertex;
|
||||
vert.x += _VertexOffsetX;
|
||||
vert.y += _VertexOffsetY;
|
||||
|
||||
vert.xy += (vert.w * 0.5) / _ScreenParams.xy;
|
||||
|
||||
OUT.vertex = UnityPixelSnap(UnityObjectToClipPos(vert));
|
||||
OUT.color = v.color;
|
||||
OUT.color *= _Color;
|
||||
OUT.color.rgb *= _DiffusePower;
|
||||
OUT.texcoord0 = v.texcoord0;
|
||||
|
||||
float2 pixelSize = OUT.vertex.w;
|
||||
//pixelSize /= abs(float2(_ScreenParams.x * UNITY_MATRIX_P[0][0], _ScreenParams.y * UNITY_MATRIX_P[1][1]));
|
||||
|
||||
// Clamp _ClipRect to 16bit.
|
||||
float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
|
||||
OUT.mask = float4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + pixelSize.xy));
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f IN) : COLOR
|
||||
{
|
||||
fixed4 color = fixed4(IN.color.rgb, IN.color.a * tex2D(_MainTex, IN.texcoord0).a);
|
||||
|
||||
// Alternative implementation to UnityGet2DClipping with support for softness.
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(IN.mask.xy)) * IN.mask.zw);
|
||||
color *= m.x * m.y;
|
||||
#endif
|
||||
|
||||
#if UNITY_UI_ALPHACLIP
|
||||
clip(color.a - 0.001);
|
||||
#endif
|
||||
|
||||
return color;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
SubShader {
|
||||
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
|
||||
Lighting Off Cull Off ZTest Always ZWrite Off Fog { Mode Off }
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
BindChannels {
|
||||
Bind "Color", color
|
||||
Bind "Vertex", vertex
|
||||
Bind "TexCoord", texcoord0
|
||||
}
|
||||
Pass {
|
||||
SetTexture [_MainTex] {
|
||||
constantColor [_Color] combine constant * primary, constant * texture
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CustomEditor "TMPro.EditorUtilities.TMP_BitmapShaderGUI"
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1e3b057af24249748ff873be7fafee47
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,142 +0,0 @@
|
||||
Shader "TextMeshPro/Bitmap" {
|
||||
|
||||
Properties {
|
||||
_MainTex ("Font Atlas", 2D) = "white" {}
|
||||
_FaceTex ("Font Texture", 2D) = "white" {}
|
||||
_FaceColor ("Text Color", Color) = (1,1,1,1)
|
||||
|
||||
_VertexOffsetX ("Vertex OffsetX", float) = 0
|
||||
_VertexOffsetY ("Vertex OffsetY", float) = 0
|
||||
_MaskSoftnessX ("Mask SoftnessX", float) = 0
|
||||
_MaskSoftnessY ("Mask SoftnessY", float) = 0
|
||||
|
||||
_ClipRect("Clip Rect", vector) = (-32767, -32767, 32767, 32767)
|
||||
|
||||
_StencilComp("Stencil Comparison", Float) = 8
|
||||
_Stencil("Stencil ID", Float) = 0
|
||||
_StencilOp("Stencil Operation", Float) = 0
|
||||
_StencilWriteMask("Stencil Write Mask", Float) = 255
|
||||
_StencilReadMask("Stencil Read Mask", Float) = 255
|
||||
|
||||
_ColorMask("Color Mask", Float) = 15
|
||||
}
|
||||
|
||||
SubShader{
|
||||
|
||||
Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
|
||||
|
||||
Stencil
|
||||
{
|
||||
Ref[_Stencil]
|
||||
Comp[_StencilComp]
|
||||
Pass[_StencilOp]
|
||||
ReadMask[_StencilReadMask]
|
||||
WriteMask[_StencilWriteMask]
|
||||
}
|
||||
|
||||
|
||||
Lighting Off
|
||||
Cull [_CullMode]
|
||||
ZTest [unity_GUIZTestMode]
|
||||
ZWrite Off
|
||||
Fog { Mode Off }
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ColorMask[_ColorMask]
|
||||
|
||||
Pass {
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#pragma multi_compile __ UNITY_UI_CLIP_RECT
|
||||
#pragma multi_compile __ UNITY_UI_ALPHACLIP
|
||||
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata_t {
|
||||
float4 vertex : POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
};
|
||||
|
||||
struct v2f {
|
||||
float4 vertex : SV_POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
float4 mask : TEXCOORD2;
|
||||
};
|
||||
|
||||
uniform sampler2D _MainTex;
|
||||
uniform sampler2D _FaceTex;
|
||||
uniform float4 _FaceTex_ST;
|
||||
uniform fixed4 _FaceColor;
|
||||
|
||||
uniform float _VertexOffsetX;
|
||||
uniform float _VertexOffsetY;
|
||||
uniform float4 _ClipRect;
|
||||
uniform float _MaskSoftnessX;
|
||||
uniform float _MaskSoftnessY;
|
||||
|
||||
float2 UnpackUV(float uv)
|
||||
{
|
||||
float2 output;
|
||||
output.x = floor(uv / 4096);
|
||||
output.y = uv - 4096 * output.x;
|
||||
|
||||
return output * 0.001953125;
|
||||
}
|
||||
|
||||
v2f vert (appdata_t v)
|
||||
{
|
||||
float4 vert = v.vertex;
|
||||
vert.x += _VertexOffsetX;
|
||||
vert.y += _VertexOffsetY;
|
||||
|
||||
vert.xy += (vert.w * 0.5) / _ScreenParams.xy;
|
||||
|
||||
float4 vPosition = UnityPixelSnap(UnityObjectToClipPos(vert));
|
||||
|
||||
fixed4 faceColor = v.color;
|
||||
faceColor *= _FaceColor;
|
||||
|
||||
v2f OUT;
|
||||
OUT.vertex = vPosition;
|
||||
OUT.color = faceColor;
|
||||
OUT.texcoord0 = v.texcoord0;
|
||||
OUT.texcoord1 = TRANSFORM_TEX(UnpackUV(v.texcoord1), _FaceTex);
|
||||
float2 pixelSize = vPosition.w;
|
||||
pixelSize /= abs(float2(_ScreenParams.x * UNITY_MATRIX_P[0][0], _ScreenParams.y * UNITY_MATRIX_P[1][1]));
|
||||
|
||||
// Clamp _ClipRect to 16bit.
|
||||
float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
|
||||
OUT.mask = float4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + pixelSize.xy));
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f IN) : SV_Target
|
||||
{
|
||||
fixed4 color = tex2D(_MainTex, IN.texcoord0);
|
||||
color = fixed4 (tex2D(_FaceTex, IN.texcoord1).rgb * IN.color.rgb, IN.color.a * color.a);
|
||||
|
||||
// Alternative implementation to UnityGet2DClipping with support for softness.
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(IN.mask.xy)) * IN.mask.zw);
|
||||
color *= m.x * m.y;
|
||||
#endif
|
||||
|
||||
#if UNITY_UI_ALPHACLIP
|
||||
clip(color.a - 0.001);
|
||||
#endif
|
||||
|
||||
return color;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
CustomEditor "TMPro.EditorUtilities.TMP_BitmapShaderGUI"
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 128e987d567d4e2c824d754223b3f3b0
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,304 +0,0 @@
|
||||
Shader "TextMeshPro/Distance Field Overlay" {
|
||||
|
||||
Properties {
|
||||
_FaceTex ("Face Texture", 2D) = "white" {}
|
||||
_FaceUVSpeedX ("Face UV Speed X", Range(-5, 5)) = 0.0
|
||||
_FaceUVSpeedY ("Face UV Speed Y", Range(-5, 5)) = 0.0
|
||||
_FaceColor ("Face Color", Color) = (1,1,1,1)
|
||||
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
|
||||
|
||||
_OutlineColor ("Outline Color", Color) = (0,0,0,1)
|
||||
_OutlineTex ("Outline Texture", 2D) = "white" {}
|
||||
_OutlineUVSpeedX ("Outline UV Speed X", Range(-5, 5)) = 0.0
|
||||
_OutlineUVSpeedY ("Outline UV Speed Y", Range(-5, 5)) = 0.0
|
||||
_OutlineWidth ("Outline Thickness", Range(0, 1)) = 0
|
||||
_OutlineSoftness ("Outline Softness", Range(0,1)) = 0
|
||||
|
||||
_Bevel ("Bevel", Range(0,1)) = 0.5
|
||||
_BevelOffset ("Bevel Offset", Range(-0.5,0.5)) = 0
|
||||
_BevelWidth ("Bevel Width", Range(-.5,0.5)) = 0
|
||||
_BevelClamp ("Bevel Clamp", Range(0,1)) = 0
|
||||
_BevelRoundness ("Bevel Roundness", Range(0,1)) = 0
|
||||
|
||||
_LightAngle ("Light Angle", Range(0.0, 6.2831853)) = 3.1416
|
||||
_SpecularColor ("Specular", Color) = (1,1,1,1)
|
||||
_SpecularPower ("Specular", Range(0,4)) = 2.0
|
||||
_Reflectivity ("Reflectivity", Range(5.0,15.0)) = 10
|
||||
_Diffuse ("Diffuse", Range(0,1)) = 0.5
|
||||
_Ambient ("Ambient", Range(1,0)) = 0.5
|
||||
|
||||
_BumpMap ("Normal map", 2D) = "bump" {}
|
||||
_BumpOutline ("Bump Outline", Range(0,1)) = 0
|
||||
_BumpFace ("Bump Face", Range(0,1)) = 0
|
||||
|
||||
_ReflectFaceColor ("Reflection Color", Color) = (0,0,0,1)
|
||||
_ReflectOutlineColor("Reflection Color", Color) = (0,0,0,1)
|
||||
_Cube ("Reflection Cubemap", Cube) = "black" { /* TexGen CubeReflect */ }
|
||||
_EnvMatrixRotation ("Texture Rotation", vector) = (0, 0, 0, 0)
|
||||
|
||||
|
||||
_UnderlayColor ("Border Color", Color) = (0,0,0, 0.5)
|
||||
_UnderlayOffsetX ("Border OffsetX", Range(-1,1)) = 0
|
||||
_UnderlayOffsetY ("Border OffsetY", Range(-1,1)) = 0
|
||||
_UnderlayDilate ("Border Dilate", Range(-1,1)) = 0
|
||||
_UnderlaySoftness ("Border Softness", Range(0,1)) = 0
|
||||
|
||||
_GlowColor ("Color", Color) = (0, 1, 0, 0.5)
|
||||
_GlowOffset ("Offset", Range(-1,1)) = 0
|
||||
_GlowInner ("Inner", Range(0,1)) = 0.05
|
||||
_GlowOuter ("Outer", Range(0,1)) = 0.05
|
||||
_GlowPower ("Falloff", Range(1, 0)) = 0.75
|
||||
|
||||
_WeightNormal ("Weight Normal", float) = 0
|
||||
_WeightBold ("Weight Bold", float) = 0.5
|
||||
|
||||
_ShaderFlags ("Flags", float) = 0
|
||||
_ScaleRatioA ("Scale RatioA", float) = 1
|
||||
_ScaleRatioB ("Scale RatioB", float) = 1
|
||||
_ScaleRatioC ("Scale RatioC", float) = 1
|
||||
|
||||
_MainTex ("Font Atlas", 2D) = "white" {}
|
||||
_TextureWidth ("Texture Width", float) = 512
|
||||
_TextureHeight ("Texture Height", float) = 512
|
||||
_GradientScale ("Gradient Scale", float) = 5.0
|
||||
_ScaleX ("Scale X", float) = 1.0
|
||||
_ScaleY ("Scale Y", float) = 1.0
|
||||
_PerspectiveFilter ("Perspective Correction", Range(0, 1)) = 0.875
|
||||
|
||||
_VertexOffsetX ("Vertex OffsetX", float) = 0
|
||||
_VertexOffsetY ("Vertex OffsetY", float) = 0
|
||||
|
||||
_MaskCoord ("Mask Coordinates", vector) = (0, 0, 32767, 32767)
|
||||
_ClipRect ("Clip Rect", vector) = (-32767, -32767, 32767, 32767)
|
||||
_MaskSoftnessX ("Mask SoftnessX", float) = 0
|
||||
_MaskSoftnessY ("Mask SoftnessY", float) = 0
|
||||
|
||||
_StencilComp ("Stencil Comparison", Float) = 8
|
||||
_Stencil ("Stencil ID", Float) = 0
|
||||
_StencilOp ("Stencil Operation", Float) = 0
|
||||
_StencilWriteMask ("Stencil Write Mask", Float) = 255
|
||||
_StencilReadMask ("Stencil Read Mask", Float) = 255
|
||||
|
||||
_ColorMask ("Color Mask", Float) = 15
|
||||
}
|
||||
|
||||
SubShader {
|
||||
|
||||
Tags
|
||||
{
|
||||
"Queue"="Overlay"
|
||||
"IgnoreProjector"="True"
|
||||
"RenderType"="Transparent"
|
||||
}
|
||||
|
||||
Stencil
|
||||
{
|
||||
Ref [_Stencil]
|
||||
Comp [_StencilComp]
|
||||
Pass [_StencilOp]
|
||||
ReadMask [_StencilReadMask]
|
||||
WriteMask [_StencilWriteMask]
|
||||
}
|
||||
|
||||
Cull [_CullMode]
|
||||
ZWrite Off
|
||||
Lighting Off
|
||||
Fog { Mode Off }
|
||||
ZTest Always
|
||||
Blend One OneMinusSrcAlpha
|
||||
ColorMask [_ColorMask]
|
||||
|
||||
Pass {
|
||||
CGPROGRAM
|
||||
#pragma target 3.0
|
||||
#pragma vertex VertShader
|
||||
#pragma fragment PixShader
|
||||
#pragma shader_feature __ BEVEL_ON
|
||||
#pragma shader_feature __ UNDERLAY_ON UNDERLAY_INNER
|
||||
#pragma shader_feature __ GLOW_ON
|
||||
|
||||
#pragma multi_compile __ UNITY_UI_CLIP_RECT
|
||||
#pragma multi_compile __ UNITY_UI_ALPHACLIP
|
||||
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityUI.cginc"
|
||||
#include "TMPro_Properties.cginc"
|
||||
#include "TMPro.cginc"
|
||||
|
||||
struct vertex_t {
|
||||
float4 position : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
};
|
||||
|
||||
|
||||
struct pixel_t {
|
||||
float4 position : SV_POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 atlas : TEXCOORD0; // Atlas
|
||||
float4 param : TEXCOORD1; // alphaClip, scale, bias, weight
|
||||
float4 mask : TEXCOORD2; // Position in object space(xy), pixel Size(zw)
|
||||
float3 viewDir : TEXCOORD3;
|
||||
|
||||
#if (UNDERLAY_ON || UNDERLAY_INNER)
|
||||
float4 texcoord2 : TEXCOORD4; // u,v, scale, bias
|
||||
fixed4 underlayColor : COLOR1;
|
||||
#endif
|
||||
float4 textures : TEXCOORD5;
|
||||
};
|
||||
|
||||
// Used by Unity internally to handle Texture Tiling and Offset.
|
||||
float4 _FaceTex_ST;
|
||||
float4 _OutlineTex_ST;
|
||||
|
||||
pixel_t VertShader(vertex_t input)
|
||||
{
|
||||
float bold = step(input.texcoord1.y, 0);
|
||||
|
||||
float4 vert = input.position;
|
||||
vert.x += _VertexOffsetX;
|
||||
vert.y += _VertexOffsetY;
|
||||
float4 vPosition = UnityObjectToClipPos(vert);
|
||||
|
||||
float2 pixelSize = vPosition.w;
|
||||
pixelSize /= float2(_ScaleX, _ScaleY) * abs(mul((float2x2)UNITY_MATRIX_P, _ScreenParams.xy));
|
||||
float scale = rsqrt(dot(pixelSize, pixelSize));
|
||||
scale *= abs(input.texcoord1.y) * _GradientScale * 1.5;
|
||||
if (UNITY_MATRIX_P[3][3] == 0) scale = lerp(abs(scale) * (1 - _PerspectiveFilter), scale, abs(dot(UnityObjectToWorldNormal(input.normal.xyz), normalize(WorldSpaceViewDir(vert)))));
|
||||
|
||||
float weight = lerp(_WeightNormal, _WeightBold, bold) / 4.0;
|
||||
weight = (weight + _FaceDilate) * _ScaleRatioA * 0.5;
|
||||
|
||||
float bias =(.5 - weight) + (.5 / scale);
|
||||
|
||||
float alphaClip = (1.0 - _OutlineWidth*_ScaleRatioA - _OutlineSoftness*_ScaleRatioA);
|
||||
|
||||
#if GLOW_ON
|
||||
alphaClip = min(alphaClip, 1.0 - _GlowOffset * _ScaleRatioB - _GlowOuter * _ScaleRatioB);
|
||||
#endif
|
||||
|
||||
alphaClip = alphaClip / 2.0 - ( .5 / scale) - weight;
|
||||
|
||||
#if (UNDERLAY_ON || UNDERLAY_INNER)
|
||||
float4 underlayColor = _UnderlayColor;
|
||||
underlayColor.rgb *= underlayColor.a;
|
||||
|
||||
float bScale = scale;
|
||||
bScale /= 1 + ((_UnderlaySoftness*_ScaleRatioC) * bScale);
|
||||
float bBias = (0.5 - weight) * bScale - 0.5 - ((_UnderlayDilate * _ScaleRatioC) * 0.5 * bScale);
|
||||
|
||||
float x = -(_UnderlayOffsetX * _ScaleRatioC) * _GradientScale / _TextureWidth;
|
||||
float y = -(_UnderlayOffsetY * _ScaleRatioC) * _GradientScale / _TextureHeight;
|
||||
float2 bOffset = float2(x, y);
|
||||
#endif
|
||||
|
||||
// Generate UV for the Masking Texture
|
||||
float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
|
||||
float2 maskUV = (vert.xy - clampedRect.xy) / (clampedRect.zw - clampedRect.xy);
|
||||
|
||||
// Support for texture tiling and offset
|
||||
float2 textureUV = UnpackUV(input.texcoord1.x);
|
||||
float2 faceUV = TRANSFORM_TEX(textureUV, _FaceTex);
|
||||
float2 outlineUV = TRANSFORM_TEX(textureUV, _OutlineTex);
|
||||
|
||||
pixel_t output = {
|
||||
vPosition,
|
||||
input.color,
|
||||
input.texcoord0,
|
||||
float4(alphaClip, scale, bias, weight),
|
||||
half4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + pixelSize.xy)),
|
||||
mul((float3x3)_EnvMatrix, _WorldSpaceCameraPos.xyz - mul(unity_ObjectToWorld, vert).xyz),
|
||||
#if (UNDERLAY_ON || UNDERLAY_INNER)
|
||||
float4(input.texcoord0 + bOffset, bScale, bBias),
|
||||
underlayColor,
|
||||
#endif
|
||||
float4(faceUV, outlineUV),
|
||||
};
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
fixed4 PixShader(pixel_t input) : SV_Target
|
||||
{
|
||||
float c = tex2D(_MainTex, input.atlas).a;
|
||||
|
||||
#ifndef UNDERLAY_ON
|
||||
clip(c - input.param.x);
|
||||
#endif
|
||||
|
||||
float scale = input.param.y;
|
||||
float bias = input.param.z;
|
||||
float weight = input.param.w;
|
||||
float sd = (bias - c) * scale;
|
||||
|
||||
float outline = (_OutlineWidth * _ScaleRatioA) * scale;
|
||||
float softness = (_OutlineSoftness * _ScaleRatioA) * scale;
|
||||
|
||||
half4 faceColor = _FaceColor;
|
||||
half4 outlineColor = _OutlineColor;
|
||||
|
||||
faceColor.rgb *= input.color.rgb;
|
||||
|
||||
faceColor *= tex2D(_FaceTex, input.textures.xy + float2(_FaceUVSpeedX, _FaceUVSpeedY) * _Time.y);
|
||||
outlineColor *= tex2D(_OutlineTex, input.textures.zw + float2(_OutlineUVSpeedX, _OutlineUVSpeedY) * _Time.y);
|
||||
|
||||
faceColor = GetColor(sd, faceColor, outlineColor, outline, softness);
|
||||
|
||||
#if BEVEL_ON
|
||||
float3 dxy = float3(0.5 / _TextureWidth, 0.5 / _TextureHeight, 0);
|
||||
float3 n = GetSurfaceNormal(input.atlas, weight, dxy);
|
||||
|
||||
float3 bump = UnpackNormal(tex2D(_BumpMap, input.textures.xy + float2(_FaceUVSpeedX, _FaceUVSpeedY) * _Time.y)).xyz;
|
||||
bump *= lerp(_BumpFace, _BumpOutline, saturate(sd + outline * 0.5));
|
||||
n = normalize(n- bump);
|
||||
|
||||
float3 light = normalize(float3(sin(_LightAngle), cos(_LightAngle), -1.0));
|
||||
|
||||
float3 col = GetSpecular(n, light);
|
||||
faceColor.rgb += col*faceColor.a;
|
||||
faceColor.rgb *= 1-(dot(n, light)*_Diffuse);
|
||||
faceColor.rgb *= lerp(_Ambient, 1, n.z*n.z);
|
||||
|
||||
fixed4 reflcol = texCUBE(_Cube, reflect(input.viewDir, -n));
|
||||
faceColor.rgb += reflcol.rgb * lerp(_ReflectFaceColor.rgb, _ReflectOutlineColor.rgb, saturate(sd + outline * 0.5)) * faceColor.a;
|
||||
#endif
|
||||
|
||||
#if UNDERLAY_ON
|
||||
float d = tex2D(_MainTex, input.texcoord2.xy).a * input.texcoord2.z;
|
||||
faceColor += input.underlayColor * saturate(d - input.texcoord2.w) * (1 - faceColor.a);
|
||||
#endif
|
||||
|
||||
#if UNDERLAY_INNER
|
||||
float d = tex2D(_MainTex, input.texcoord2.xy).a * input.texcoord2.z;
|
||||
faceColor += input.underlayColor * (1 - saturate(d - input.texcoord2.w)) * saturate(1 - sd) * (1 - faceColor.a);
|
||||
#endif
|
||||
|
||||
#if GLOW_ON
|
||||
float4 glowColor = GetGlowColor(sd, scale);
|
||||
faceColor.rgb += glowColor.rgb * glowColor.a;
|
||||
#endif
|
||||
|
||||
// Alternative implementation to UnityGet2DClipping with support for softness.
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(input.mask.xy)) * input.mask.zw);
|
||||
faceColor *= m.x * m.y;
|
||||
#endif
|
||||
|
||||
#if UNITY_UI_ALPHACLIP
|
||||
clip(faceColor.a - 0.001);
|
||||
#endif
|
||||
|
||||
return faceColor * input.color.a;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
Fallback "TextMeshPro/Mobile/Distance Field"
|
||||
CustomEditor "TMPro.EditorUtilities.TMP_SDFShaderGUI"
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dd89cf5b9246416f84610a006f916af7
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user