Cozy Wather + buld systeme
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
TEXTURE2D_SHADOW(_DirectionalShadowAtlas);
|
||||
#define SHADOW_SAMPLER sampler_linear_clamp_compare
|
||||
SAMPLER_CMP(SHADOW_SAMPLER);
|
||||
|
||||
half GetShadowAttenuation(half3 RayPos)
|
||||
{
|
||||
half4 shadowPos = TransformWorldToShadowCoord(RayPos);
|
||||
half4 shadowParams = GetMainLightShadowParams();
|
||||
float shadowStrength = shadowParams.x;
|
||||
float attenuation = _MainLightShadowmapTexture.SampleCmpLevelZero(SHADOW_SAMPLER, shadowPos.xy, shadowPos.z);
|
||||
return saturate(lerp(BEYOND_SHADOW_FAR(shadowPos) ? 1.0 : attenuation, 1.0, GetMainLightShadowFade(RayPos)));
|
||||
}
|
||||
|
||||
float Raymarching( inout float3 position, float3 direction, int maxSteps, float stepSize, float depth, float sensitivity, float densityMultiplier, out float density )
|
||||
{
|
||||
density = 0;
|
||||
float shadowAtten = 0;
|
||||
for (int i = 0; i < maxSteps; i++) {
|
||||
if (density + stepSize < depth) {
|
||||
position+=direction*stepSize;
|
||||
density += stepSize;
|
||||
shadowAtten += GetShadowAttenuation(position) * sensitivity;
|
||||
} else
|
||||
return shadowAtten;
|
||||
}
|
||||
return shadowAtten;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6d9b4b4d8aa743c4387ca12900aa7141
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 271742
|
||||
packageName: 'COZY: Stylized Weather 3'
|
||||
packageVersion: 3.6.20
|
||||
assetPath: Packages/com.distantlands.cozy.core/Runtime/Shaders/Includes/Raymarching.cginc
|
||||
uploadId: 939148
|
||||
+151
@@ -0,0 +1,151 @@
|
||||
|
||||
#ifndef COZY_INCLUDED
|
||||
#define COZY_INCLUDED
|
||||
|
||||
uniform float4 CZY_FogColor1;
|
||||
uniform float4 CZY_FogColor2;
|
||||
uniform float4 CZY_FogColor3;
|
||||
uniform float4 CZY_FogColor4;
|
||||
uniform float4 CZY_FogColor5;
|
||||
|
||||
uniform float CZY_FogColorStart1;
|
||||
uniform float CZY_FogColorStart2;
|
||||
uniform float CZY_FogColorStart3;
|
||||
uniform float CZY_FogColorStart4;
|
||||
|
||||
uniform half CZY_FogDepthMultiplier;
|
||||
|
||||
uniform float4 CZY_LightColor;
|
||||
uniform float3 CZY_SunDirection;
|
||||
uniform half CZY_LightIntensity;
|
||||
uniform half CZY_LightFalloff;
|
||||
|
||||
uniform float CZY_FogSmoothness;
|
||||
uniform float CZY_FogOffset;
|
||||
uniform float CZY_FogIntensity;
|
||||
uniform sampler2D _FogVariationTexture;
|
||||
uniform float3 CZY_VariationWindDirection;
|
||||
uniform float CZY_VariationScale;
|
||||
uniform float CZY_VariationAmount;
|
||||
uniform float CZY_VariationDistance;
|
||||
uniform float3 CZY_MoonDirection;
|
||||
uniform float4 CZY_FogMoonFlareColor;
|
||||
uniform float CZY_LightFlareSquish;
|
||||
uniform float CZY_FilterSaturation;
|
||||
uniform float CZY_FilterValue;
|
||||
uniform float4 CZY_FilterColor;
|
||||
uniform float4 CZY_SunFilterColor;
|
||||
|
||||
|
||||
inline float4 ASE_ComputeGrabScreenPos(float4 pos)
|
||||
{
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
float scale = -1.0;
|
||||
#else
|
||||
float scale = 1.0;
|
||||
#endif
|
||||
float4 o = pos;
|
||||
o.y = pos.w * 0.5f;
|
||||
o.y = (pos.y - o.y) * _ProjectionParams.x * scale + o.y;
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
float3 HSVToRGB(float3 c)
|
||||
{
|
||||
float4 K = float4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
float3 p = abs(frac(c.xxx + K.xyz) * 6.0 - K.www);
|
||||
return c.z * lerp(K.xxx, saturate(p - K.xxx), c.y);
|
||||
}
|
||||
|
||||
|
||||
float3 RGBToHSV(float3 c)
|
||||
{
|
||||
float4 K = float4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||
float4 p = lerp(float4(c.bg, K.wz), float4(c.gb, K.xy), step(c.b, c.g));
|
||||
float4 q = lerp(float4(p.xyw, c.r), float4(c.r, p.yzx), step(p.x, c.r));
|
||||
float d = q.x - min(q.w, q.y);
|
||||
float e = 1.0e-10;
|
||||
return float3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
|
||||
}
|
||||
|
||||
float4 Debug(float4 input) {
|
||||
|
||||
return CZY_FogColor3;
|
||||
|
||||
}
|
||||
|
||||
float4 BlendStylizedFog(float3 worldPos, float4 inColor) {
|
||||
|
||||
//Get Depth
|
||||
float eyeDepth = distance(worldPos, _WorldSpaceCameraPos);
|
||||
float fogDepth = (CZY_FogDepthMultiplier * sqrt(eyeDepth));
|
||||
|
||||
//5 COLOR FOG
|
||||
float4 c1toc2 = lerp( CZY_FogColor1 , CZY_FogColor2 , saturate( ( fogDepth / CZY_FogColorStart1 ) ));
|
||||
float4 c2toc3 = lerp( c1toc2 , CZY_FogColor3 , saturate( ( ( CZY_FogColorStart1 - fogDepth ) / ( CZY_FogColorStart1 - CZY_FogColorStart2 ) ) ));
|
||||
float4 c3toc4 = lerp( c2toc3 , CZY_FogColor4 , saturate( ( ( CZY_FogColorStart2 - fogDepth ) / ( CZY_FogColorStart2 - CZY_FogColorStart3 ) ) ));
|
||||
float4 tempFogColor = lerp( c3toc4 , CZY_FogColor5 , saturate( ( ( CZY_FogColorStart3 - fogDepth ) / ( CZY_FogColorStart3 - CZY_FogColorStart4 ) ) ));
|
||||
float3 fogHSV = RGBToHSV( tempFogColor.rgb );
|
||||
//VARIATION
|
||||
float variatedFogDepth = lerp(fogDepth, (fogDepth * ((1.0 - CZY_VariationAmount) + (tex2D( _FogVariationTexture, ((worldPos).xz + ((CZY_VariationWindDirection).xz * _TimeParameters.x ))*( 0.1 / CZY_VariationScale))).r) * (1.0 - ( 1.0 - CZY_VariationAmount)) / (1.0)), (1.0 - saturate(fogDepth / CZY_VariationDistance)));
|
||||
float newFogAlpha = (tempFogColor).a * saturate((CZY_FogDepthMultiplier * sqrt(variatedFogDepth)));
|
||||
|
||||
|
||||
//SUN FLARE
|
||||
float3 directionAndLengthToClipPlane = normalize(worldPos - _WorldSpaceCameraPos) * _ProjectionParams.z;
|
||||
float sunFlare = dot( normalize( ( ( directionAndLengthToClipPlane * (float3(1.0 , CZY_LightFlareSquish , 1.0)) ) - _WorldSpaceCameraPos ) ) , CZY_SunDirection );
|
||||
half modifiedSunFlare = saturate( pow( abs( ( (sunFlare*0.5 + 0.5) * CZY_LightIntensity ) ) , CZY_LightFalloff ) );
|
||||
float3 hsvTorgb2_g56 = RGBToHSV( ( CZY_LightColor * fogHSV.z * saturate( ( modifiedSunFlare * ( 1.5 * newFogAlpha ) ) ) ).rgb );
|
||||
float3 filteredFogColor = ( float4( HSVToRGB( float3(hsvTorgb2_g56.x,saturate( ( hsvTorgb2_g56.y + CZY_FilterSaturation ) ),( hsvTorgb2_g56.z + CZY_FilterValue )) ) , 0.0 ) * CZY_FilterColor );
|
||||
float3 viewDirection = ( worldPos - _WorldSpaceCameraPos );
|
||||
half moonMask = saturate( pow( abs( ( saturate( (dot( normalize( viewDirection ) , normalize( CZY_MoonDirection ) )*1.0 + 0.0) ) * CZY_LightIntensity ) ) , ( CZY_LightFalloff * 3.0 ) ) );
|
||||
float3 moonColorHSV = RGBToHSV( ( tempFogColor + ( fogHSV.z * saturate( ( newFogAlpha * moonMask ) ) * CZY_FogMoonFlareColor ) ).rgb );
|
||||
float3 moonColorRGB = HSVToRGB(float3(moonColorHSV.x,saturate((moonColorHSV.y + CZY_FilterSaturation)),(moonColorHSV.z + CZY_FilterValue ))) * CZY_FilterColor;
|
||||
|
||||
float3 ase_objectScale = float3( length( GetObjectToWorldMatrix()[ 0 ].xyz ), length( GetObjectToWorldMatrix()[ 1 ].xyz ), length( GetObjectToWorldMatrix()[ 2 ].xyz ) );
|
||||
|
||||
float4 fogColor = float4(( ( filteredFogColor * CZY_SunFilterColor.rgb ) + moonColorRGB ).rgb, 1);
|
||||
// float finalAlpha = ( newFogAlpha * saturate( ( ( 1.0 - saturate( ( ( ( viewDirection.y * 0.1 ) * ( 1.0 / ( ( CZY_FogSmoothness * length( ase_objectScale ) ) * 10.0 ) ) ) + ( 1.0 - CZY_FogOffset ) ) ) ) * CZY_FogIntensity ) ) );
|
||||
float finalAlpha = newFogAlpha;
|
||||
|
||||
return lerp(inColor, fogColor, finalAlpha);
|
||||
|
||||
|
||||
}
|
||||
|
||||
float GetStylizedFogDensity(float3 worldPos) {
|
||||
|
||||
|
||||
|
||||
//float4 ase_screenPos = float4(i.screenPos.xyz, i.screenPos.w + 0.00000000001);
|
||||
//float4 ase_screenPosNorm = ase_screenPos / ase_screenPos.w;
|
||||
//ase_screenPosNorm.z = (UNITY_NEAR_CLIP_VALUE >= 0) ? ase_screenPosNorm.z : ase_screenPosNorm.z * 0.5 + 0.5;
|
||||
float eyeDepth = distance(worldPos, _WorldSpaceCameraPos);
|
||||
|
||||
|
||||
float fogDepth = (CZY_FogDepthMultiplier * sqrt(eyeDepth));
|
||||
|
||||
float4 lerpResult28_g2 = lerp(CZY_FogColor1, CZY_FogColor2, saturate((fogDepth / CZY_FogColorStart1)));
|
||||
float4 lerpResult41_g2 = lerp(saturate(lerpResult28_g2), CZY_FogColor3, saturate(((CZY_FogColorStart1 - fogDepth) / (CZY_FogColorStart1 - CZY_FogColorStart2))));
|
||||
float4 lerpResult35_g2 = lerp(lerpResult41_g2, CZY_FogColor4, saturate(((CZY_FogColorStart2 - fogDepth) / (CZY_FogColorStart2 - CZY_FogColorStart3))));
|
||||
float4 lerpResult113_g2 = lerp(lerpResult35_g2, CZY_FogColor5, saturate(((CZY_FogColorStart3 - fogDepth) / (CZY_FogColorStart3 - CZY_FogColorStart4))));
|
||||
|
||||
float4 tempFogColor = lerpResult113_g2;
|
||||
float3 hsvTorgb31_g1 = RGBToHSV(CZY_LightColor.rgb);
|
||||
float3 hsvTorgb32_g1 = RGBToHSV(tempFogColor.rgb);
|
||||
float3 hsvTorgb39_g1 = HSVToRGB(float3(hsvTorgb31_g1.x, hsvTorgb31_g1.y, (hsvTorgb31_g1.z * hsvTorgb32_g1.z)));
|
||||
float3 normalizeResult5_g1 = normalize((worldPos - _WorldSpaceCameraPos));
|
||||
float dotResult6_g1 = dot(normalizeResult5_g1, CZY_SunDirection);
|
||||
half lightMask = saturate(pow(abs(((dotResult6_g1 * 0.5 + 0.5) * CZY_LightIntensity)), CZY_LightFalloff));
|
||||
|
||||
float alpha = saturate(((1.0 - saturate(((((worldPos - _WorldSpaceCameraPos).y * 0.1) * (1.0 / CZY_FogSmoothness)) + (1.0 - CZY_FogOffset)))) * CZY_FogIntensity));
|
||||
float finalFogDensity = (tempFogColor.a * saturate(fogDepth)) * alpha;
|
||||
|
||||
|
||||
|
||||
return finalFogDensity;
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e9bc566e199a97947a3e600f2563fe85
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 271742
|
||||
packageName: 'COZY: Stylized Weather 3'
|
||||
packageVersion: 3.6.20
|
||||
assetPath: Packages/com.distantlands.cozy.core/Runtime/Shaders/Includes/StylizedFogIncludes.cginc
|
||||
uploadId: 939148
|
||||
+136
@@ -0,0 +1,136 @@
|
||||
|
||||
#ifndef COZY_INCLUDED
|
||||
#define COZY_INCLUDED
|
||||
|
||||
uniform float4 CZY_FogColor1;
|
||||
uniform float4 CZY_FogColor2;
|
||||
uniform float4 CZY_FogColor3;
|
||||
uniform float4 CZY_FogColor4;
|
||||
uniform float4 CZY_FogColor5;
|
||||
|
||||
uniform float CZY_FogColorStart1;
|
||||
uniform float CZY_FogColorStart2;
|
||||
uniform float CZY_FogColorStart3;
|
||||
uniform float CZY_FogColorStart4;
|
||||
|
||||
uniform half CZY_FogDepthMultiplier;
|
||||
|
||||
uniform float4 CZY_LightColor;
|
||||
uniform float3 CZY_SunDirection;
|
||||
uniform half CZY_LightIntensity;
|
||||
uniform half CZY_LightFalloff;
|
||||
|
||||
uniform float CZY_FogSmoothness;
|
||||
uniform float CZY_FogOffset;
|
||||
uniform float CZY_FogIntensity;
|
||||
|
||||
inline float4 ASE_ComputeGrabScreenPos(float4 pos)
|
||||
{
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
float scale = -1.0;
|
||||
#else
|
||||
float scale = 1.0;
|
||||
#endif
|
||||
float4 o = pos;
|
||||
o.y = pos.w * 0.5f;
|
||||
o.y = (pos.y - o.y) * _ProjectionParams.x * scale + o.y;
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
float3 HSVToRGB(float3 c)
|
||||
{
|
||||
float4 K = float4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
float3 p = abs(frac(c.xxx + K.xyz) * 6.0 - K.www);
|
||||
return c.z * lerp(K.xxx, saturate(p - K.xxx), c.y);
|
||||
}
|
||||
|
||||
|
||||
float3 RGBToHSV(float3 c)
|
||||
{
|
||||
float4 K = float4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||
float4 p = lerp(float4(c.bg, K.wz), float4(c.gb, K.xy), step(c.b, c.g));
|
||||
float4 q = lerp(float4(p.xyw, c.r), float4(c.r, p.yzx), step(p.x, c.r));
|
||||
float d = q.x - min(q.w, q.y);
|
||||
float e = 1.0e-10;
|
||||
return float3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
|
||||
}
|
||||
|
||||
float4 Debug(float4 input) {
|
||||
|
||||
return CZY_FogColor3;
|
||||
|
||||
}
|
||||
|
||||
float4 BlendStylizedFog(float3 worldPos, float4 inColor) {
|
||||
|
||||
|
||||
|
||||
//float4 ase_screenPos = float4(i.screenPos.xyz, i.screenPos.w + 0.00000000001);
|
||||
//float4 ase_screenPosNorm = ase_screenPos / ase_screenPos.w;
|
||||
//ase_screenPosNorm.z = (UNITY_NEAR_CLIP_VALUE >= 0) ? ase_screenPosNorm.z : ase_screenPosNorm.z * 0.5 + 0.5;
|
||||
float eyeDepth = distance(worldPos, _WorldSpaceCameraPos);
|
||||
|
||||
|
||||
float fogDepth = (CZY_FogDepthMultiplier * sqrt(eyeDepth));
|
||||
|
||||
float4 lerpResult28_g2 = lerp(CZY_FogColor1, CZY_FogColor2, saturate((fogDepth / CZY_FogColorStart1)));
|
||||
float4 lerpResult41_g2 = lerp(saturate(lerpResult28_g2), CZY_FogColor3, saturate(((CZY_FogColorStart1 - fogDepth) / (CZY_FogColorStart1 - CZY_FogColorStart2))));
|
||||
float4 lerpResult35_g2 = lerp(lerpResult41_g2, CZY_FogColor4, saturate(((CZY_FogColorStart2 - fogDepth) / (CZY_FogColorStart2 - CZY_FogColorStart3))));
|
||||
float4 lerpResult113_g2 = lerp(lerpResult35_g2, CZY_FogColor5, saturate(((CZY_FogColorStart3 - fogDepth) / (CZY_FogColorStart3 - CZY_FogColorStart4))));
|
||||
|
||||
float4 tempFogColor = lerpResult113_g2;
|
||||
float3 hsvTorgb31_g1 = RGBToHSV(CZY_LightColor.rgb);
|
||||
float3 hsvTorgb32_g1 = RGBToHSV(tempFogColor.rgb);
|
||||
float3 hsvTorgb39_g1 = HSVToRGB(float3(hsvTorgb31_g1.x, hsvTorgb31_g1.y, (hsvTorgb31_g1.z * hsvTorgb32_g1.z)));
|
||||
float3 normalizeResult5_g1 = normalize((worldPos - _WorldSpaceCameraPos));
|
||||
float dotResult6_g1 = dot(normalizeResult5_g1, CZY_SunDirection);
|
||||
half lightMask = saturate(pow(abs(((dotResult6_g1 * 0.5 + 0.5) * CZY_LightIntensity)), CZY_LightFalloff));
|
||||
|
||||
float alpha = saturate(((1.0 - saturate(((((worldPos - _WorldSpaceCameraPos).y * 0.1) * (1.0 / CZY_FogSmoothness)) + (1.0 - CZY_FogOffset)))) * CZY_FogIntensity));
|
||||
float finalFogDensity = (tempFogColor.a * saturate(fogDepth)) * alpha;
|
||||
float4 lerpResult43_g1 = lerp(tempFogColor, float4(hsvTorgb39_g1, 0.0), saturate((lightMask * (1.5 * finalFogDensity))));
|
||||
float4 lerpResult46_g1 = lerp(inColor, lerpResult43_g1, finalFogDensity);
|
||||
|
||||
|
||||
return lerpResult46_g1;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
float GetStylizedFogDensity(float3 worldPos) {
|
||||
|
||||
|
||||
|
||||
//float4 ase_screenPos = float4(i.screenPos.xyz, i.screenPos.w + 0.00000000001);
|
||||
//float4 ase_screenPosNorm = ase_screenPos / ase_screenPos.w;
|
||||
//ase_screenPosNorm.z = (UNITY_NEAR_CLIP_VALUE >= 0) ? ase_screenPosNorm.z : ase_screenPosNorm.z * 0.5 + 0.5;
|
||||
float eyeDepth = distance(worldPos, _WorldSpaceCameraPos);
|
||||
|
||||
|
||||
float fogDepth = (CZY_FogDepthMultiplier * sqrt(eyeDepth));
|
||||
|
||||
float4 lerpResult28_g2 = lerp(CZY_FogColor1, CZY_FogColor2, saturate((fogDepth / CZY_FogColorStart1)));
|
||||
float4 lerpResult41_g2 = lerp(saturate(lerpResult28_g2), CZY_FogColor3, saturate(((CZY_FogColorStart1 - fogDepth) / (CZY_FogColorStart1 - CZY_FogColorStart2))));
|
||||
float4 lerpResult35_g2 = lerp(lerpResult41_g2, CZY_FogColor4, saturate(((CZY_FogColorStart2 - fogDepth) / (CZY_FogColorStart2 - CZY_FogColorStart3))));
|
||||
float4 lerpResult113_g2 = lerp(lerpResult35_g2, CZY_FogColor5, saturate(((CZY_FogColorStart3 - fogDepth) / (CZY_FogColorStart3 - CZY_FogColorStart4))));
|
||||
|
||||
float4 tempFogColor = lerpResult113_g2;
|
||||
float3 hsvTorgb31_g1 = RGBToHSV(CZY_LightColor.rgb);
|
||||
float3 hsvTorgb32_g1 = RGBToHSV(tempFogColor.rgb);
|
||||
float3 hsvTorgb39_g1 = HSVToRGB(float3(hsvTorgb31_g1.x, hsvTorgb31_g1.y, (hsvTorgb31_g1.z * hsvTorgb32_g1.z)));
|
||||
float3 normalizeResult5_g1 = normalize((worldPos - _WorldSpaceCameraPos));
|
||||
float dotResult6_g1 = dot(normalizeResult5_g1, CZY_SunDirection);
|
||||
half lightMask = saturate(pow(abs(((dotResult6_g1 * 0.5 + 0.5) * CZY_LightIntensity)), CZY_LightFalloff));
|
||||
|
||||
float alpha = saturate(((1.0 - saturate(((((worldPos - _WorldSpaceCameraPos).y * 0.1) * (1.0 / CZY_FogSmoothness)) + (1.0 - CZY_FogOffset)))) * CZY_FogIntensity));
|
||||
float finalFogDensity = (tempFogColor.a * saturate(fogDepth)) * alpha;
|
||||
|
||||
|
||||
|
||||
return finalFogDensity;
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 57873e167aa618f4e8f3d136941abcd3
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 271742
|
||||
packageName: 'COZY: Stylized Weather 3'
|
||||
packageVersion: 3.6.20
|
||||
assetPath: Packages/com.distantlands.cozy.core/Runtime/Shaders/Includes/StylizedFogNoVariationIncludes.cginc
|
||||
uploadId: 939148
|
||||
+151
@@ -0,0 +1,151 @@
|
||||
|
||||
#ifndef COZY_INCLUDED
|
||||
#define COZY_INCLUDED
|
||||
|
||||
uniform float4 CZY_FogColor1;
|
||||
uniform float4 CZY_FogColor2;
|
||||
uniform float4 CZY_FogColor3;
|
||||
uniform float4 CZY_FogColor4;
|
||||
uniform float4 CZY_FogColor5;
|
||||
|
||||
uniform float CZY_FogColorStart1;
|
||||
uniform float CZY_FogColorStart2;
|
||||
uniform float CZY_FogColorStart3;
|
||||
uniform float CZY_FogColorStart4;
|
||||
|
||||
uniform half CZY_FogDepthMultiplier;
|
||||
|
||||
uniform float4 CZY_LightColor;
|
||||
uniform float3 CZY_SunDirection;
|
||||
uniform half CZY_LightIntensity;
|
||||
uniform half CZY_LightFalloff;
|
||||
|
||||
uniform float CZY_FogSmoothness;
|
||||
uniform float CZY_FogOffset;
|
||||
uniform float CZY_FogIntensity;
|
||||
uniform sampler2D _FogVariationTexture;
|
||||
uniform float3 CZY_VariationWindDirection;
|
||||
uniform float CZY_VariationScale;
|
||||
uniform float CZY_VariationAmount;
|
||||
uniform float CZY_VariationDistance;
|
||||
uniform float3 CZY_MoonDirection;
|
||||
uniform float4 CZY_FogMoonFlareColor;
|
||||
uniform float CZY_LightFlareSquish;
|
||||
uniform float CZY_FilterSaturation;
|
||||
uniform float CZY_FilterValue;
|
||||
uniform float4 CZY_FilterColor;
|
||||
uniform float4 CZY_SunFilterColor;
|
||||
|
||||
inline float4 ASE_ComputeGrabScreenPos(float4 pos)
|
||||
{
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
float scale = -1.0;
|
||||
#else
|
||||
float scale = 1.0;
|
||||
#endif
|
||||
float4 o = pos;
|
||||
o.y = pos.w * 0.5f;
|
||||
o.y = (pos.y - o.y) * _ProjectionParams.x * scale + o.y;
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
float3 HSVToRGB(float3 c)
|
||||
{
|
||||
float4 K = float4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
float3 p = abs(frac(c.xxx + K.xyz) * 6.0 - K.www);
|
||||
return c.z * lerp(K.xxx, saturate(p - K.xxx), c.y);
|
||||
}
|
||||
|
||||
|
||||
float3 RGBToHSV(float3 c)
|
||||
{
|
||||
float4 K = float4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||
float4 p = lerp(float4(c.bg, K.wz), float4(c.gb, K.xy), step(c.b, c.g));
|
||||
float4 q = lerp(float4(p.xyw, c.r), float4(c.r, p.yzx), step(p.x, c.r));
|
||||
float d = q.x - min(q.w, q.y);
|
||||
float e = 1.0e-10;
|
||||
return float3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
|
||||
}
|
||||
|
||||
float4 Debug(float4 input) {
|
||||
|
||||
return CZY_FogColor3;
|
||||
|
||||
}
|
||||
|
||||
void BlendStylizedFog_float(float3 worldPos, float4 inColor, out float4 outColor) {
|
||||
|
||||
//Get Depth
|
||||
float eyeDepth = distance(worldPos, _WorldSpaceCameraPos);
|
||||
float fogDepth = (CZY_FogDepthMultiplier * sqrt(eyeDepth));
|
||||
|
||||
//5 COLOR FOG
|
||||
float4 c1toc2 = lerp( CZY_FogColor1 , CZY_FogColor2 , saturate( ( fogDepth / CZY_FogColorStart1 ) ));
|
||||
float4 c2toc3 = lerp( c1toc2 , CZY_FogColor3 , saturate( ( ( CZY_FogColorStart1 - fogDepth ) / ( CZY_FogColorStart1 - CZY_FogColorStart2 ) ) ));
|
||||
float4 c3toc4 = lerp( c2toc3 , CZY_FogColor4 , saturate( ( ( CZY_FogColorStart2 - fogDepth ) / ( CZY_FogColorStart2 - CZY_FogColorStart3 ) ) ));
|
||||
float4 tempFogColor = lerp( c3toc4 , CZY_FogColor5 , saturate( ( ( CZY_FogColorStart3 - fogDepth ) / ( CZY_FogColorStart3 - CZY_FogColorStart4 ) ) ));
|
||||
float3 fogHSV = RGBToHSV( tempFogColor.rgb );
|
||||
//VARIATION
|
||||
float variatedFogDepth = lerp(fogDepth, (fogDepth * ((1.0 - CZY_VariationAmount) + (tex2D( _FogVariationTexture, ((worldPos).xz + ((CZY_VariationWindDirection).xz * _TimeParameters.x ))*( 0.1 / CZY_VariationScale))).r) * (1.0 - ( 1.0 - CZY_VariationAmount)) / (1.0)), (1.0 - saturate(fogDepth / CZY_VariationDistance)));
|
||||
float newFogAlpha = (tempFogColor).a * saturate((CZY_FogDepthMultiplier * sqrt(variatedFogDepth)));
|
||||
|
||||
|
||||
//SUN FLARE
|
||||
float3 directionAndLengthToClipPlane = normalize(worldPos - _WorldSpaceCameraPos) * _ProjectionParams.z;
|
||||
float sunFlare = dot( normalize( ( ( directionAndLengthToClipPlane * (float3(1.0 , CZY_LightFlareSquish , 1.0)) ) - _WorldSpaceCameraPos ) ) , CZY_SunDirection );
|
||||
half modifiedSunFlare = saturate( pow( abs( ( (sunFlare*0.5 + 0.5) * CZY_LightIntensity ) ) , CZY_LightFalloff ) );
|
||||
float3 hsvTorgb2_g56 = RGBToHSV( ( CZY_LightColor * fogHSV.z * saturate( ( modifiedSunFlare * ( 1.5 * newFogAlpha ) ) ) ).rgb );
|
||||
float3 filteredFogColor = ( float4( HSVToRGB( float3(hsvTorgb2_g56.x,saturate( ( hsvTorgb2_g56.y + CZY_FilterSaturation ) ),( hsvTorgb2_g56.z + CZY_FilterValue )) ) , 0.0 ) * CZY_FilterColor );
|
||||
float3 viewDirection = ( worldPos - _WorldSpaceCameraPos );
|
||||
half moonMask = saturate( pow( abs( ( saturate( (dot( normalize( viewDirection ) , normalize( CZY_MoonDirection ) )*1.0 + 0.0) ) * CZY_LightIntensity ) ) , ( CZY_LightFalloff * 3.0 ) ) );
|
||||
float3 moonColorHSV = RGBToHSV( ( tempFogColor + ( fogHSV.z * saturate( ( newFogAlpha * moonMask ) ) * CZY_FogMoonFlareColor ) ).rgb );
|
||||
float3 moonColorRGB = HSVToRGB(float3(moonColorHSV.x,saturate((moonColorHSV.y + CZY_FilterSaturation)),(moonColorHSV.z + CZY_FilterValue ))) * CZY_FilterColor;
|
||||
|
||||
float3 ase_objectScale = float3( length( GetObjectToWorldMatrix()[ 0 ].xyz ), length( GetObjectToWorldMatrix()[ 1 ].xyz ), length( GetObjectToWorldMatrix()[ 2 ].xyz ) );
|
||||
|
||||
float4 fogColor = float4(( ( filteredFogColor * CZY_SunFilterColor.rgb ) + moonColorRGB ).rgb, 1);
|
||||
// float finalAlpha = ( newFogAlpha * saturate( ( ( 1.0 - saturate( ( ( ( viewDirection.y * 0.1 ) * ( 1.0 / ( ( CZY_FogSmoothness * length( ase_objectScale ) ) * 10.0 ) ) ) + ( 1.0 - CZY_FogOffset ) ) ) ) * CZY_FogIntensity ) ) );
|
||||
float finalAlpha = newFogAlpha;
|
||||
|
||||
outColor = lerp(inColor, fogColor, finalAlpha);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
float GetStylizedFogDensity(float3 worldPos) {
|
||||
|
||||
|
||||
|
||||
//float4 ase_screenPos = float4(i.screenPos.xyz, i.screenPos.w + 0.00000000001);
|
||||
//float4 ase_screenPosNorm = ase_screenPos / ase_screenPos.w;
|
||||
//ase_screenPosNorm.z = (UNITY_NEAR_CLIP_VALUE >= 0) ? ase_screenPosNorm.z : ase_screenPosNorm.z * 0.5 + 0.5;
|
||||
float eyeDepth = distance(worldPos, _WorldSpaceCameraPos);
|
||||
|
||||
|
||||
float fogDepth = (CZY_FogDepthMultiplier * sqrt(eyeDepth));
|
||||
|
||||
float4 lerpResult28_g2 = lerp(CZY_FogColor1, CZY_FogColor2, saturate((fogDepth / CZY_FogColorStart1)));
|
||||
float4 lerpResult41_g2 = lerp(saturate(lerpResult28_g2), CZY_FogColor3, saturate(((CZY_FogColorStart1 - fogDepth) / (CZY_FogColorStart1 - CZY_FogColorStart2))));
|
||||
float4 lerpResult35_g2 = lerp(lerpResult41_g2, CZY_FogColor4, saturate(((CZY_FogColorStart2 - fogDepth) / (CZY_FogColorStart2 - CZY_FogColorStart3))));
|
||||
float4 lerpResult113_g2 = lerp(lerpResult35_g2, CZY_FogColor5, saturate(((CZY_FogColorStart3 - fogDepth) / (CZY_FogColorStart3 - CZY_FogColorStart4))));
|
||||
|
||||
float4 tempFogColor = lerpResult113_g2;
|
||||
float3 hsvTorgb31_g1 = RGBToHSV(CZY_LightColor.rgb);
|
||||
float3 hsvTorgb32_g1 = RGBToHSV(tempFogColor.rgb);
|
||||
float3 hsvTorgb39_g1 = HSVToRGB(float3(hsvTorgb31_g1.x, hsvTorgb31_g1.y, (hsvTorgb31_g1.z * hsvTorgb32_g1.z)));
|
||||
float3 normalizeResult5_g1 = normalize((worldPos - _WorldSpaceCameraPos));
|
||||
float dotResult6_g1 = dot(normalizeResult5_g1, CZY_SunDirection);
|
||||
half lightMask = saturate(pow(abs(((dotResult6_g1 * 0.5 + 0.5) * CZY_LightIntensity)), CZY_LightFalloff));
|
||||
|
||||
float alpha = saturate(((1.0 - saturate(((((worldPos - _WorldSpaceCameraPos).y * 0.1) * (1.0 / CZY_FogSmoothness)) + (1.0 - CZY_FogOffset)))) * CZY_FogIntensity));
|
||||
float finalFogDensity = (tempFogColor.a * saturate(fogDepth)) * alpha;
|
||||
|
||||
|
||||
|
||||
return finalFogDensity;
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 92e8e83e086df884988dc781f367db3d
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 271742
|
||||
packageName: 'COZY: Stylized Weather 3'
|
||||
packageVersion: 3.6.20
|
||||
assetPath: Packages/com.distantlands.cozy.core/Runtime/Shaders/Includes/StylizedFogShaderGraphIncludes.cginc
|
||||
uploadId: 939148
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
|
||||
#ifndef COZY_PUDDLES_INCLUDED
|
||||
#define COZY_PUDDLES_INCLUDED
|
||||
|
||||
uniform float CZY_PuddleScale;
|
||||
uniform float CZY_WetnessAmount;
|
||||
|
||||
|
||||
float2 voronoihash1_g2(float2 p)
|
||||
{
|
||||
|
||||
p = float2(dot(p, float2(127.1, 311.7)), dot(p, float2(269.5, 183.3)));
|
||||
return frac(sin(p) * 43758.5453);
|
||||
}
|
||||
|
||||
|
||||
float voronoi1_g2(float2 v, float time, inout float2 id, inout float2 mr, float smoothness, inout float2 smoothId)
|
||||
{
|
||||
float2 n = floor(v);
|
||||
float2 f = frac(v);
|
||||
float F1 = 8.0;
|
||||
float F2 = 8.0; float2 mg = 0;
|
||||
for (int j = -1; j <= 1; j++)
|
||||
{
|
||||
for (int i = -1; i <= 1; i++)
|
||||
{
|
||||
float2 g = float2(i, j);
|
||||
float2 o = voronoihash1_g2(n + g);
|
||||
o = (sin(time + o * 6.2831) * 0.5 + 0.5); float2 r = f - g - o;
|
||||
float d = 0.5 * dot(r, r);
|
||||
if (d < F1) {
|
||||
F2 = F1;
|
||||
F1 = d; mg = g; mr = r; id = o;
|
||||
}
|
||||
else if (d < F2) {
|
||||
F2 = d;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return (F2 + F1) * 0.5;
|
||||
}
|
||||
|
||||
|
||||
float2 voronoihash8_g2(float2 p)
|
||||
{
|
||||
|
||||
p = float2(dot(p, float2(127.1, 311.7)), dot(p, float2(269.5, 183.3)));
|
||||
return frac(sin(p) * 43758.5453);
|
||||
}
|
||||
|
||||
|
||||
float voronoi8_g2(float2 v, float time, inout float2 id, inout float2 mr, float smoothness, inout float2 smoothId)
|
||||
{
|
||||
float2 n = floor(v);
|
||||
float2 f = frac(v);
|
||||
float F1 = 8.0;
|
||||
float F2 = 8.0; float2 mg = 0;
|
||||
for (int j = -1; j <= 1; j++)
|
||||
{
|
||||
for (int i = -1; i <= 1; i++)
|
||||
{
|
||||
float2 g = float2(i, j);
|
||||
float2 o = voronoihash8_g2(n + g);
|
||||
o = (sin(time + o * 6.2831) * 0.5 + 0.5); float2 r = f - g - o;
|
||||
float d = 0.5 * dot(r, r);
|
||||
if (d < F1) {
|
||||
F2 = F1;
|
||||
F1 = d; mg = g; mr = r; id = o;
|
||||
}
|
||||
else if (d < F2) {
|
||||
F2 = d;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return F1;
|
||||
}
|
||||
|
||||
|
||||
float BlendStylizedPuddles(float3 normal, float3 worldPos)
|
||||
{
|
||||
float3 ase_worldNormal = normal;
|
||||
float temp_output_5_0_g2 = (1.0 / CZY_PuddleScale);
|
||||
float time1_g2 = 0.0;
|
||||
float2 voronoiSmoothId0 = 0;
|
||||
float3 ase_worldPos = worldPos;
|
||||
float2 appendResult3_g2 = (float2(ase_worldPos.x, ase_worldPos.z));
|
||||
float2 coords1_g2 = appendResult3_g2 * temp_output_5_0_g2;
|
||||
float2 id1_g2 = 0;
|
||||
float2 uv1_g2 = 0;
|
||||
float voroi1_g2 = voronoi1_g2(coords1_g2, time1_g2, id1_g2, uv1_g2, 0, voronoiSmoothId0);
|
||||
float time8_g2 = 2.16;
|
||||
float2 coords8_g2 = (temp_output_5_0_g2 * 3.0);
|
||||
float2 id8_g2 = 0;
|
||||
float2 uv8_g2 = 0;
|
||||
float voroi8_g2 = voronoi8_g2(coords8_g2, time8_g2, id8_g2, uv8_g2, 0, voronoiSmoothId0);
|
||||
return ((ase_worldNormal.y * 2.0 * ((1.0 + (voroi1_g2 - 0.0) * (0.0 - 1.0) / (0.4 - 0.0)) + (0.1 + (voroi8_g2 - 0.0) * (-0.3 - 0.1) / (0.21 - 0.0))) * (0.3 + (CZY_WetnessAmount - 0.0) * (1.0 - 0.3) / (1.0 - 0.0))) > (1.0 - (CZY_WetnessAmount * 1.0)) ? 1.0 : 0.0);
|
||||
|
||||
}
|
||||
#endif
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c60262aca928b7749b9e6a95d00c42ec
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 271742
|
||||
packageName: 'COZY: Stylized Weather 3'
|
||||
packageVersion: 3.6.20
|
||||
assetPath: Packages/com.distantlands.cozy.core/Runtime/Shaders/Includes/StylizedPuddlesIncludes.cginc
|
||||
uploadId: 939148
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
|
||||
#ifndef COZY_SNOW_INCLUDED
|
||||
#define COZY_SNOW_INCLUDED
|
||||
|
||||
uniform float4 CZY_SnowColor;
|
||||
uniform sampler2D CZY_SnowTexture;
|
||||
uniform float4 _SnowTexture_ST;
|
||||
uniform float CZY_SnowScale;
|
||||
uniform float CZY_SnowAmount;
|
||||
|
||||
float3 mod2D289(float3 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }
|
||||
|
||||
float2 mod2D289(float2 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }
|
||||
|
||||
float3 permute(float3 x) { return mod2D289(((x * 34.0) + 1.0) * x); }
|
||||
|
||||
float snoise(float2 v)
|
||||
{
|
||||
const float4 C = float4(0.211324865405187, 0.366025403784439, -0.577350269189626, 0.024390243902439);
|
||||
float2 i = floor(v + dot(v, C.yy));
|
||||
float2 x0 = v - i + dot(i, C.xx);
|
||||
float2 i1;
|
||||
i1 = (x0.x > x0.y) ? float2(1.0, 0.0) : float2(0.0, 1.0);
|
||||
float4 x12 = x0.xyxy + C.xxzz;
|
||||
x12.xy -= i1;
|
||||
i = mod2D289(i);
|
||||
float3 p = permute(permute(i.y + float3(0.0, i1.y, 1.0)) + i.x + float3(0.0, i1.x, 1.0));
|
||||
float3 m = max(0.5 - float3(dot(x0, x0), dot(x12.xy, x12.xy), dot(x12.zw, x12.zw)), 0.0);
|
||||
m = m * m;
|
||||
m = m * m;
|
||||
float3 x = 2.0 * frac(p * C.www) - 1.0;
|
||||
float3 h = abs(x) - 0.5;
|
||||
float3 ox = floor(x + 0.5);
|
||||
float3 a0 = x - ox;
|
||||
m *= 1.79284291400159 - 0.85373472095314 * (a0 * a0 + h * h);
|
||||
float3 g;
|
||||
g.x = a0.x * x0.x + h.x * x0.y;
|
||||
g.yz = a0.yz * x12.xz + h.yz * x12.yw;
|
||||
return 130.0 * dot(m, g);
|
||||
}
|
||||
|
||||
|
||||
float2 voronoihash5_g1(float2 p)
|
||||
{
|
||||
|
||||
p = float2(dot(p, float2(127.1, 311.7)), dot(p, float2(269.5, 183.3)));
|
||||
return frac(sin(p) * 43758.5453);
|
||||
}
|
||||
|
||||
|
||||
float voronoi5_g1(float2 v, float time, inout float2 id, inout float2 mr, float smoothness, inout float2 smoothId)
|
||||
{
|
||||
float2 n = floor(v);
|
||||
float2 f = frac(v);
|
||||
float F1 = 8.0;
|
||||
float F2 = 8.0; float2 mg = 0;
|
||||
for (int j = -1; j <= 1; j++)
|
||||
{
|
||||
for (int i = -1; i <= 1; i++)
|
||||
{
|
||||
float2 g = float2(i, j);
|
||||
float2 o = voronoihash5_g1(n + g);
|
||||
o = (sin(time + o * 6.2831) * 0.5 + 0.5); float2 r = f - g - o;
|
||||
float d = 0.5 * dot(r, r);
|
||||
if (d < F1) {
|
||||
F2 = F1;
|
||||
F1 = d; mg = g; mr = r; id = o;
|
||||
}
|
||||
else if (d < F2) {
|
||||
F2 = d;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return F1;
|
||||
}
|
||||
|
||||
|
||||
float3 BlendStylizedSnow(float4 i, float3 normal, float3 worldPos)
|
||||
{
|
||||
float2 uv_SnowTexture = _SnowTexture_ST.xy + _SnowTexture_ST.zw;
|
||||
float3 ase_worldNormal = normal;
|
||||
float3 ase_worldPos = worldPos;
|
||||
float2 worldPos_2D = (float2(ase_worldPos.x, ase_worldPos.z));
|
||||
float temp_output_6_0_g1 = (1.0 / CZY_SnowScale);
|
||||
float simplePerlin2D7_g1 = snoise(worldPos_2D * temp_output_6_0_g1);
|
||||
simplePerlin2D7_g1 = simplePerlin2D7_g1 * 0.5 + 0.5;
|
||||
float2 coords5_g1 = worldPos_2D * (temp_output_6_0_g1 / 0.1);
|
||||
float time5_g2 = 0.0;
|
||||
float2 voronoiSmoothId0 = 0;
|
||||
float2 id5_g2 = 0;
|
||||
float2 uv5_g2 = 0;
|
||||
float voroi5_g1 = voronoi5_g1(coords5_g1, time5_g2, id5_g2, uv5_g2, 0, voronoiSmoothId0);
|
||||
float4 lerpResult19_g1 = lerp((CZY_SnowColor * tex2D(CZY_SnowTexture, uv_SnowTexture)), i, ((pow((pow(ase_worldNormal.y, 7.0) * (simplePerlin2D7_g1 * (1.0 - voroi5_g1))), 0.5) * 1.0) > (1.0 - CZY_SnowAmount) ? 0.0 : 1.0));
|
||||
return lerpResult19_g1.rgb;
|
||||
}
|
||||
#endif
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 721e4e7a7c7f1b440b398b4c09326b3d
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 271742
|
||||
packageName: 'COZY: Stylized Weather 3'
|
||||
packageVersion: 3.6.20
|
||||
assetPath: Packages/com.distantlands.cozy.core/Runtime/Shaders/Includes/StylizedSnowIncludes.cginc
|
||||
uploadId: 939148
|
||||
Reference in New Issue
Block a user