1
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
#ifndef FILE_INCLUDED
|
||||
#define FILE_INCLUDED
|
||||
|
||||
|
||||
|
||||
#endif
|
@@ -0,0 +1,162 @@
|
||||
#ifndef COMMON_INCLUDED
|
||||
#define COMMON_INCLUDED
|
||||
|
||||
sampler2D _NoiseTex;
|
||||
sampler2D _CloudTex;
|
||||
|
||||
float NoiseTexFrag(float2 uv)
|
||||
{
|
||||
return tex2D(_NoiseTex, uv).r*2 - 1;
|
||||
}
|
||||
|
||||
float NoiseTexVert(float2 uv)
|
||||
{
|
||||
return tex2Dlod(_NoiseTex, float4(uv.xy, 0, 0)).r*2 - 1;
|
||||
}
|
||||
|
||||
float CloudTexFrag(float2 uv)
|
||||
{
|
||||
return tex2D(_CloudTex, uv).r*2 - 1;
|
||||
}
|
||||
|
||||
float CloudTexLod0(float2 uv)
|
||||
{
|
||||
return tex2Dlod(_CloudTex, float4(uv.xy, 0, 0)).r*2 - 1;
|
||||
}
|
||||
|
||||
float CloudTexVert(float2 uv)
|
||||
{
|
||||
return CloudTexLod0(uv);
|
||||
}
|
||||
|
||||
float2 GradientNoise_dir(float2 p)
|
||||
{
|
||||
p = p % 289;
|
||||
float x = (34 * p.x + 1) * p.x % 289 + p.y;
|
||||
x = (34 * x + 1) * x % 289;
|
||||
x = frac(x / 41) * 2 - 1;
|
||||
return normalize(float2(x - floor(x + 0.5), abs(x) - 0.5));
|
||||
}
|
||||
|
||||
float GradientNoise(float2 p)
|
||||
{
|
||||
float2 ip = floor(p);
|
||||
float2 fp = frac(p);
|
||||
float d00 = dot(GradientNoise_dir(ip), fp);
|
||||
float d01 = dot(GradientNoise_dir(ip + float2(0, 1)), fp - float2(0, 1));
|
||||
float d10 = dot(GradientNoise_dir(ip + float2(1, 0)), fp - float2(1, 0));
|
||||
float d11 = dot(GradientNoise_dir(ip + float2(1, 1)), fp - float2(1, 1));
|
||||
fp = fp * fp * fp * (fp * (fp * 6 - 15) + 10);
|
||||
return lerp(lerp(d00, d01, fp.y), lerp(d10, d11, fp.y), fp.x);
|
||||
}
|
||||
|
||||
float InverseLerpUnclamped(float a, float b, float value)
|
||||
{
|
||||
//adding a==b check if needed
|
||||
return (value - a) / (b - a + 0.00000001);
|
||||
}
|
||||
|
||||
float RandomValue(float seed)
|
||||
{
|
||||
return frac(seed*23.456*(1+ceil(seed)*12.345));
|
||||
}
|
||||
|
||||
float RandomValue(float3 seed)
|
||||
{
|
||||
float3 value = frac(seed*23.456*(1+ceil(seed)*12.345));
|
||||
return max(value.x, min(value.y, value.z));
|
||||
}
|
||||
|
||||
float2 VoronoiRandomVector (float2 UV, float offset)
|
||||
{
|
||||
float2x2 m = float2x2(15.27, 47.63, 99.41, 89.98);
|
||||
UV = frac(sin(mul(UV, m)) * 46839.32);
|
||||
return float2(sin(UV.y*+offset)*0.5+0.5, cos(UV.x*offset)*0.5+0.5);
|
||||
}
|
||||
|
||||
float Voronoi(float2 UV, float AngleOffset, float CellDensity)
|
||||
{
|
||||
float2 g = floor(UV * CellDensity);
|
||||
float2 f = frac(UV * CellDensity);
|
||||
float t = 8.0;
|
||||
float3 res = float3(8.0, 0.0, 0.0);
|
||||
float noiseValue = 0;
|
||||
|
||||
for(int y=-1; y<=1; y++)
|
||||
{
|
||||
for(int x=-1; x<=1; x++)
|
||||
{
|
||||
float2 lattice = float2(x,y);
|
||||
float2 offset = VoronoiRandomVector(lattice + g, AngleOffset);
|
||||
float d = distance(lattice + offset, f);
|
||||
if(d < res.x)
|
||||
{
|
||||
res = float3(d, offset.x, offset.y);
|
||||
noiseValue = res.x;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return noiseValue;
|
||||
}
|
||||
|
||||
float2 PanUV(float2 uv, float2 speed)
|
||||
{
|
||||
return uv + _Time.y*speed;
|
||||
}
|
||||
|
||||
half IsOrtho()
|
||||
{
|
||||
return unity_OrthoParams.w;
|
||||
}
|
||||
|
||||
half GetNearPlane()
|
||||
{
|
||||
return _ProjectionParams.y;
|
||||
}
|
||||
|
||||
half GetFarPlane()
|
||||
{
|
||||
return _ProjectionParams.z;
|
||||
}
|
||||
|
||||
float SqrDistance(float3 pt1, float3 pt2)
|
||||
{
|
||||
float3 v = pt2 - pt1;
|
||||
return dot(v,v);
|
||||
}
|
||||
|
||||
fixed SqrDistance(fixed pt1, fixed pt2)
|
||||
{
|
||||
fixed v = pt2 - pt1;
|
||||
return dot(v,v);
|
||||
}
|
||||
|
||||
float SqrMagnitude(float2 p)
|
||||
{
|
||||
return p.x*p.x + p.y*p.y;
|
||||
}
|
||||
|
||||
float SqrMagnitude(float3 p)
|
||||
{
|
||||
return p.x*p.x + p.y*p.y + p.z*p.z;
|
||||
}
|
||||
|
||||
float StepValue(float v, float count)
|
||||
{
|
||||
float step = 1.0/count;
|
||||
return v-v%step;
|
||||
}
|
||||
|
||||
float TriangleWave(float t)
|
||||
{
|
||||
return 2.0 * abs( 2 * (t - floor(0.5 + t)) ) - 1.0;
|
||||
}
|
||||
|
||||
fixed4 BlendOverlay(fixed4 src, fixed4 des)
|
||||
{
|
||||
fixed4 result = src*src.a + des*(1-src.a);
|
||||
result.a = 1 - (1-src.a)*(1-des.a);
|
||||
return result;
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,33 @@
|
||||
#ifndef DETAIL_OVERLAY_INCLUDED
|
||||
#define DETAIL_OVERLAY_INCLUDED
|
||||
|
||||
void CalculateDetailOverlayColor(
|
||||
float4 localPos,
|
||||
samplerCUBE cubemap,
|
||||
fixed4 tint,
|
||||
out fixed4 color)
|
||||
{
|
||||
color = texCUBE(cubemap, localPos.xyz);
|
||||
color *= tint;
|
||||
}
|
||||
|
||||
void CalculateDetailOverlayColor(
|
||||
float4 localPos,
|
||||
samplerCUBE cubemap,
|
||||
fixed4 tint,
|
||||
float rotationSpeed,
|
||||
out fixed4 color)
|
||||
{
|
||||
float angle = rotationSpeed*_Time.y;
|
||||
float sinY = sin(radians(angle));
|
||||
float cosY = cos(radians(angle));
|
||||
float3x3 ry = float3x3(cosY, 0, sinY,
|
||||
0, 1, 0,
|
||||
-sinY, 0, cosY);
|
||||
localPos.xyz = mul(ry, localPos.xyz);
|
||||
|
||||
color = texCUBE(cubemap, localPos.xyz);
|
||||
color *= tint;
|
||||
}
|
||||
|
||||
#endif
|
@@ -0,0 +1,52 @@
|
||||
#ifndef HORIZON_CLOUD_INCLUDED
|
||||
#define HORIZON_CLOUD_INCLUDED
|
||||
|
||||
#include "JCommon.cginc"
|
||||
|
||||
void CalculateHorizonCloudColor(
|
||||
float4 localPos,
|
||||
fixed4 cloudColor,
|
||||
fixed cloudStart, fixed cloudEnd,
|
||||
fixed cloudSize, fixed cloudStep,
|
||||
fixed animationSpeed,
|
||||
out fixed4 color)
|
||||
{
|
||||
fixed fadeBottom = saturate(InverseLerpUnclamped(cloudStart, 0, localPos.y));
|
||||
fixed fadeTop = saturate(InverseLerpUnclamped(cloudEnd, 0, localPos.y));
|
||||
fixed fade = saturate(lerp(fadeBottom, fadeTop, localPos.y >= 0));
|
||||
fade = fade*fade;
|
||||
|
||||
fixed loop;
|
||||
#if SHADER_API_MOBILE
|
||||
loop = 1;
|
||||
#else
|
||||
loop = 2;
|
||||
#endif
|
||||
|
||||
fixed noise = 0;
|
||||
fixed sample0 = 0;
|
||||
fixed sample1 = 0;
|
||||
fixed noiseSize = cloudSize + 0.0001;
|
||||
fixed noiseAmp = 1;
|
||||
fixed sign = -1;
|
||||
fixed2 span = animationSpeed*_Time.y*0.0001;
|
||||
for (fixed i=0; i<loop; ++i)
|
||||
{
|
||||
sample0 = CloudTexLod0((localPos.xy)/noiseSize + sign*span)*noiseAmp;
|
||||
sample1 = CloudTexLod0((localPos.yz)/noiseSize + sign*span)*noiseAmp;
|
||||
noise += (sample0 + sample1)*0.5;
|
||||
noiseSize *= 0.5;
|
||||
noiseAmp *= 0.5;
|
||||
sign *= -1;
|
||||
}
|
||||
|
||||
noise = noise*0.5 + 0.5;
|
||||
|
||||
#if ALLOW_STEP_EFFECT
|
||||
noise = StepValue(noise, cloudStep);
|
||||
#endif
|
||||
|
||||
color = fixed4(1, 1, 1, fade*noise*2)*cloudColor;
|
||||
}
|
||||
|
||||
#endif
|
@@ -0,0 +1,65 @@
|
||||
#ifndef OVERHEAD_CLOUD_INCLUDED
|
||||
#define OVERHEAD_CLOUD_INCLUDED
|
||||
|
||||
#include "JCommon.cginc"
|
||||
|
||||
void CalculateOverheadCloudColor(
|
||||
float4 localPos,
|
||||
fixed4 cloudColor,
|
||||
fixed cloudAltitude,
|
||||
fixed cloudSize, fixed cloudStep,
|
||||
fixed animationSpeed,
|
||||
fixed flowX, fixed flowZ,
|
||||
fixed remapMin, fixed remapMax,
|
||||
out fixed4 color)
|
||||
{
|
||||
fixed3 rayDir = localPos.xyz;
|
||||
float3 cloudPlaneOrigin = float3(0, cloudAltitude, 0);
|
||||
float3 cloudPlaneNormal = float3(0, 1, 0);
|
||||
|
||||
float rayLength = dot(cloudPlaneOrigin, cloudPlaneNormal) / (dot(rayDir, cloudPlaneNormal) + 0.000001);
|
||||
float3 intersectionPoint = rayDir * rayLength;
|
||||
|
||||
fixed loop;
|
||||
#if SHADER_API_MOBILE
|
||||
loop = 1;
|
||||
#else
|
||||
loop = 2;
|
||||
#endif
|
||||
|
||||
fixed noise = 0;
|
||||
fixed sample = 0;
|
||||
fixed noiseSize = cloudSize * 1000 + 0.0001;
|
||||
fixed noiseAmp = 1;
|
||||
fixed sign = -1;
|
||||
fixed2 span = fixed2(flowX, flowZ) * animationSpeed * _Time.y * 0.0001;
|
||||
for (fixed i = 0; i < loop; ++i)
|
||||
{
|
||||
sample = CloudTexLod0((intersectionPoint.xz) / noiseSize + sign * span) * noiseAmp;
|
||||
noise += sample;
|
||||
noiseSize *= 0.5;
|
||||
noiseAmp *= 0.5;
|
||||
sign *= -1;
|
||||
}
|
||||
noise = noise * 0.5 + 0.5;
|
||||
noise = noise * cloudColor.a;
|
||||
noise = lerp(remapMin, remapMax, noise);
|
||||
noise = saturate(noise);
|
||||
|
||||
#if ALLOW_STEP_EFFECT
|
||||
noise = StepValue(noise, cloudStep);
|
||||
#endif
|
||||
|
||||
color = fixed4(cloudColor.rgb, noise);
|
||||
|
||||
float sqrCloudDiscRadius = 100000000;
|
||||
float sqrDistanceToCloudPlaneOrigin = SqrDistance(intersectionPoint, cloudPlaneOrigin);
|
||||
|
||||
fixed fDistance = saturate(1 - InverseLerpUnclamped(0, sqrCloudDiscRadius, sqrDistanceToCloudPlaneOrigin));
|
||||
color.a *= fDistance * fDistance;
|
||||
|
||||
fixed4 clear = fixed4(0, 0, 0, 0);
|
||||
color = lerp(clear, color, localPos.y > 0);
|
||||
}
|
||||
|
||||
#endif
|
@@ -0,0 +1,25 @@
|
||||
#ifndef SKY_GRADIENT_INCLUDED
|
||||
#define SKY_GRADIENT_INCLUDED
|
||||
|
||||
#include "JCommon.cginc"
|
||||
|
||||
void CalculateSkyGradientColor(
|
||||
float4 localPos,
|
||||
fixed4 skyColor, fixed4 horizonColor, fixed4 groundColor,
|
||||
fixed horizonThickness, fixed horizonExponent, fixed horizonStep,
|
||||
out fixed4 skyBlendColor, out fixed4 horizonBlendColor)
|
||||
{
|
||||
skyBlendColor = lerp(groundColor, skyColor, localPos.y > 0);
|
||||
horizonThickness *= lerp(0.25, 1, localPos.y > 0);
|
||||
|
||||
#if ALLOW_STEP_EFFECT
|
||||
localPos.y = StepValue(localPos.y, horizonStep);
|
||||
#endif
|
||||
|
||||
fixed horizonBlendFactor = saturate(1 - InverseLerpUnclamped(0, horizonThickness, abs(localPos.y)));
|
||||
horizonBlendFactor = pow(horizonBlendFactor, horizonExponent);
|
||||
//horizon = lerp(color, horizonColor, horizonBlendFactor);
|
||||
horizonBlendColor = fixed4(horizonColor.xyz, horizonBlendFactor*horizonColor.a);
|
||||
}
|
||||
|
||||
#endif
|
@@ -0,0 +1,55 @@
|
||||
#ifndef STARS_INCLUDED
|
||||
#define STARS_INCLUDED
|
||||
|
||||
#include "JCommon.cginc"
|
||||
|
||||
void CalculateStarsColor(
|
||||
float4 localPos,
|
||||
float starsStartPosition, float starsEndPosition,
|
||||
fixed4 starsColor, fixed starsOpacity,
|
||||
float starsDensity,
|
||||
float starsSize,
|
||||
fixed starsGlow,
|
||||
fixed starsTwinkle,
|
||||
out fixed4 color)
|
||||
{
|
||||
float cellCount = starsDensity*50;
|
||||
float cellSize = 1/cellCount;
|
||||
|
||||
float3 cellCenter = floor(localPos.xyz/cellSize)*cellSize + 0.5*cellSize*float3(1,1,1);
|
||||
float rand = RandomValue(cellCenter.xyz) - 0.5;
|
||||
float3 starPos = cellCenter + float3(1,1,1)*cellSize*rand;
|
||||
float sqrDistance = SqrDistance(localPos.xyz, starPos);
|
||||
float sqrDistanceThreshold = 0.00001*starsSize*starsSize;
|
||||
|
||||
fixed4 clear = fixed4(0,0,0,0);
|
||||
fixed4 white = fixed4(1,1,1,1);
|
||||
|
||||
color = lerp(clear, white, sqrDistance <= sqrDistanceThreshold);
|
||||
color *= starsColor;
|
||||
color.a *= 2*(1 + starsGlow)*(rand + 0.5);
|
||||
float wave = TriangleWave(rand*_Time.y*starsTwinkle)*0.5 + 0.5;
|
||||
color.a *= lerp(0.5, 1, (1-wave));
|
||||
color.a *= starsOpacity;
|
||||
|
||||
color = lerp(clear, color, cellCenter.y >= starsStartPosition);
|
||||
color = lerp(clear, color, cellCenter.y <= starsEndPosition);
|
||||
color = lerp(clear, color, rand <= starsDensity);
|
||||
}
|
||||
|
||||
void CalculateStarsColorBaked(
|
||||
float4 localPos,
|
||||
samplerCUBE starsCubemap,
|
||||
sampler2D starsTwinkleMap,
|
||||
fixed starsOpacity,
|
||||
out fixed4 color)
|
||||
{
|
||||
float2 span = float2(1,1)*_Time.y*0.1;
|
||||
fixed twinkle = tex2D(starsTwinkleMap, localPos.xy + span).r;
|
||||
|
||||
color = texCUBE(starsCubemap, localPos.xyz);
|
||||
color.a *= twinkle;
|
||||
color.a *= starsOpacity;
|
||||
}
|
||||
|
||||
#endif
|
@@ -0,0 +1,90 @@
|
||||
#ifndef SUN_MOON_INCLUDED
|
||||
#define SUN_MOON_INCLUDED
|
||||
|
||||
#include "JCommon.cginc"
|
||||
|
||||
void CalculateSunMoonColorTextured(
|
||||
float4 localPos,
|
||||
sampler2D tex, float4x4 posToUvMatrix,
|
||||
fixed4 tintColor,
|
||||
float size, fixed softEdge, fixed glow,
|
||||
float4 direction,
|
||||
out fixed4 color)
|
||||
{
|
||||
fixed3 sunPos = -direction;
|
||||
fixed3 rayDir = localPos.xyz;
|
||||
fixed3 sunPlaneOrigin = sunPos;
|
||||
fixed3 sunPlaneNormal = sunPos;
|
||||
|
||||
fixed rayLength = dot(sunPlaneOrigin, sunPlaneNormal)/(dot(rayDir, sunPlaneNormal)+0.000001);
|
||||
fixed3 intersectionPoint = rayDir*rayLength;
|
||||
fixed sqrDistanceToSun = SqrDistance(intersectionPoint, sunPos);
|
||||
fixed fSize = 1 - InverseLerpUnclamped(0, size*size*0.25, sqrDistanceToSun);
|
||||
fixed fGlow = 1 - InverseLerpUnclamped(0, size*size*400*glow*glow, sqrDistanceToSun);
|
||||
fGlow = saturate(fGlow);
|
||||
|
||||
fixed4 clear = fixed4(0,0,0,0);
|
||||
fixed4 white = fixed4(1,1,1,1);
|
||||
|
||||
fixed4 glowColor = fixed4(tintColor.xyz, fGlow*fGlow*fGlow*fGlow*fGlow*fGlow*glow);
|
||||
float4 uvSpacePos = mul(posToUvMatrix, localPos);
|
||||
fixed4 texColor = tex2D(tex, uvSpacePos.xy - float2(0.5, 0.5));
|
||||
texColor.a = lerp(0, texColor.a, SqrMagnitude(uvSpacePos.xy) <= 0.25);
|
||||
float texAlpha = texColor.a;
|
||||
|
||||
float fSoftEdge = saturate(lerp(0, 1/(softEdge+0.0000001), fSize));
|
||||
texColor = lerp(glowColor, texColor, fSoftEdge*texAlpha);
|
||||
texColor.a = texAlpha*fSoftEdge;
|
||||
|
||||
color = texColor + glowColor*glowColor.a;
|
||||
color *= tintColor;
|
||||
color.a = saturate(color.a);
|
||||
|
||||
float dotProduct = dot(localPos.xyz, sunPos);
|
||||
color = lerp(clear, color, dotProduct >= 0);
|
||||
}
|
||||
|
||||
void CalculateSunMoonColor(
|
||||
float4 localPos,
|
||||
fixed4 tintColor,
|
||||
float size, fixed softEdge, fixed glow,
|
||||
float4 direction,
|
||||
out fixed4 color)
|
||||
{
|
||||
fixed3 sunPos = -direction;
|
||||
fixed3 rayDir = localPos.xyz;
|
||||
fixed3 sunPlaneOrigin = sunPos;
|
||||
fixed3 sunPlaneNormal = sunPos;
|
||||
|
||||
fixed rayLength = dot(sunPlaneOrigin, sunPlaneNormal)/(dot(rayDir, sunPlaneNormal)+0.000001);
|
||||
fixed3 intersectionPoint = rayDir*rayLength;
|
||||
fixed sqrDistanceToSun = SqrDistance(intersectionPoint, sunPos);
|
||||
fixed fSize = 1 - InverseLerpUnclamped(0, size*size*0.25, sqrDistanceToSun);
|
||||
fixed fGlow = 1 - InverseLerpUnclamped(0, size*size*400*glow*glow, sqrDistanceToSun);
|
||||
fGlow = saturate(fGlow);
|
||||
|
||||
fixed4 clear = fixed4(0,0,0,0);
|
||||
fixed4 white = fixed4(1,1,1,1);
|
||||
|
||||
fixed4 texColor = white;
|
||||
fixed4 glowColor = fixed4(tintColor.xyz, fGlow*fGlow*fGlow*fGlow*fGlow*fGlow*glow);
|
||||
fixed fSoftEdge = saturate(lerp(0, 1/(softEdge+0.0000001), fSize));
|
||||
texColor = lerp(glowColor, texColor, fSoftEdge);
|
||||
|
||||
color = texColor + glowColor*glowColor.a*glowColor.a;
|
||||
color *= tintColor;
|
||||
color.a = saturate(color.a);
|
||||
|
||||
fixed dotProduct = dot(localPos.xyz, sunPos);
|
||||
color = lerp(clear, color, dotProduct >= 0);
|
||||
}
|
||||
|
||||
void CalculateSunMoonColorBaked(
|
||||
float4 localPos, float4x4 rotationMatrix,
|
||||
samplerCUBE sunCubemap,
|
||||
out fixed4 color)
|
||||
{
|
||||
localPos = mul(rotationMatrix, float4(localPos.xyz,0));
|
||||
color = texCUBE(sunCubemap, localPos.xyz);
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,69 @@
|
||||
Shader "Hidden/Griffin/CopyTexture"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Texture", 2D) = "white" {}
|
||||
_StartUV ("Start UV", Vector) = (0,0,0,0)
|
||||
_EndUV ("End UV", Vector) = (1,1,1,1)
|
||||
_DefaultColor ("Default Color", Color) = (0,0,0,0)
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Opaque" }
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
float4 _StartUV;
|
||||
float4 _EndUV;
|
||||
float4 _DefaultColor;
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
||||
return o;
|
||||
}
|
||||
|
||||
float2 TransformUV(float2 uv)
|
||||
{
|
||||
return lerp(_StartUV, _EndUV, uv);
|
||||
}
|
||||
|
||||
float IsInRange01(float2 uv)
|
||||
{
|
||||
return uv.x>=0 && uv.x<=1 && uv.y>=0 && uv.y<=1;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
float2 transformedUV = TransformUV(i.uv);
|
||||
float4 texColor = tex2D(_MainTex, transformedUV);
|
||||
float inRange = IsInRange01(transformedUV);
|
||||
float4 result = texColor*inRange + _DefaultColor*(1-inRange);
|
||||
return result;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,49 @@
|
||||
Shader "Hidden/Griffin/SolidColor"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_Color ("Color", Color) = (1,1,1,1)
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Transparent" }
|
||||
Blend One Zero
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
float4 _Color;
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.uv;
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
return _Color;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,483 @@
|
||||
Shader "Jupiter/Sky"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[HideInInspector] _SkyColor("Sky Color", Color) = (0.15, 0.4, 0.65, 1)
|
||||
[HideInInspector] _HorizonColor("Horizon Color", Color) = (1, 1, 1, 1)
|
||||
[HideInInspector] _GroundColor("Ground Color", Color) = (0.4, 0.4, 0.4, 1)
|
||||
[HideInInspector] _HorizonThickness("Horizon Thickness", Range(0.0, 1.0)) = 0.3
|
||||
[HideInInspector] _HorizonExponent("Horizon Exponent", Float) = 1.0
|
||||
[HideInInspector] _HorizonStep("Horizon Step", Float) = 25
|
||||
[HideInInspector] _FogColor("Custom Fog Color", Color) = (0, 0, 0, 1)
|
||||
|
||||
[HideInInspector] _StarsStartPosition("Stars Start", Float) = 0.3
|
||||
[HideInInspector] _StarsEndPosition("Stars End", Float) = 1
|
||||
[HideInInspector] _StarsOpacity("Stars Opacity", Float) = 1
|
||||
|
||||
[HideInInspector] _StarsColor0("Stars Color 0", Color) = (1, 1, 1, 1)
|
||||
[HideInInspector] _StarsColor1("Stars Color 1", Color) = (1, 1, 1, 1)
|
||||
[HideInInspector] _StarsColor2("Stars Color 2", Color) = (1, 1, 1, 1)
|
||||
|
||||
[HideInInspector] _StarsDensity0("Stars Density 0", Float) = 1
|
||||
[HideInInspector] _StarsDensity1("Stars Density 1", Float) = 1
|
||||
[HideInInspector] _StarsDensity2("Stars Density 2", Float) = 1
|
||||
|
||||
[HideInInspector] _StarsSize0("Stars Size 0", Float) = 1
|
||||
[HideInInspector] _StarsSize1("Stars Size 1", Float) = 1
|
||||
[HideInInspector] _StarsSize2("Stars Size 2", Float) = 1
|
||||
|
||||
[HideInInspector] _StarsGlow0("Stars Glow 0", Float) = 0
|
||||
[HideInInspector] _StarsGlow1("Stars Glow 1", Float) = 0
|
||||
[HideInInspector] _StarsGlow2("Stars Glow 2", Float) = 0
|
||||
|
||||
[HideInInspector] _StarsTwinkle0("Stars Twinkle 0", Float) = 1
|
||||
[HideInInspector] _StarsTwinkle1("Stars Twinkle 1", Float) = 1
|
||||
[HideInInspector] _StarsTwinkle2("Stars Twinkle 2", Float) = 1
|
||||
|
||||
[HideInInspector] _StarsCubemap("Stars Cubemap", CUBE) = "any" {}
|
||||
[HideInInspector] _StarsTwinkleMap("Stars Twinkle Map", 2D) = "white" {}
|
||||
|
||||
[HideInInspector] _SunTex("Sun Texture", 2D) = "white" {}
|
||||
[HideInInspector] _SunColor("Sun Color", Color) = (1, 1, 1, 1)
|
||||
[HideInInspector] _SunSize("Sun Size", Float) = 0.1
|
||||
[HideInInspector] _SunSoftEdge("Sun Soft Edge", Float) = 0
|
||||
[HideInInspector] _SunGlow("Sun Glow", Float) = 0
|
||||
[HideInInspector] _SunDirection("Sun Direction", Vector) = (-1, -1, -1, 0)
|
||||
[HideInInspector] _SunCubemap("Sun Cubemap", CUBE) = "any" {}
|
||||
[HideInInspector] _SunLightColor("Sun Light Color", Color) = (1,1,1,1)
|
||||
[HideInInspector] _SunLightIntensity("Sun Light Intensity", Float) = 1
|
||||
|
||||
[HideInInspector] _MoonTex("Moon Texture", 2D) = "white" {}
|
||||
[HideInInspector] _MoonColor("Moon Color", Color) = (1, 1, 1, 1)
|
||||
[HideInInspector] _MoonSize("Moon Size", Float) = 0.1
|
||||
[HideInInspector] _MoonSoftEdge("Moon Soft Edge", Float) = 0
|
||||
[HideInInspector] _MoonGlow("Moon Glow", Float) = 0
|
||||
[HideInInspector] _MoonDirection("Moon Direction", Vector) = (1, 1, 1, 0)
|
||||
[HideInInspector] _MoonCubemap("Moon Cubemap", CUBE) = "any" {}
|
||||
[HideInInspector] _MoonLightColor("Moon Light Color", Color) = (1,1,1,1)
|
||||
[HideInInspector] _MoonLightIntensity("Moon Light Intensity", Float) = 1
|
||||
|
||||
[HideInInspector] _HorizonCloudColor("Horizon Cloud Color", Color) = (1, 1, 1, 0.5)
|
||||
[HideInInspector] _HorizonCloudStartPosition("Horizon Cloud Start", Float) = -0.1
|
||||
[HideInInspector] _HorizonCloudEndPosition("Horizon Cloud End", Float) = 0.5
|
||||
[HideInInspector] _HorizonCloudSize("Horizon Cloud Size", Float) = 10
|
||||
[HideInInspector] _HorizonCloudStep("Horizon Cloud Step", Float) = 25
|
||||
[HideInInspector] _HorizonCloudAnimationSpeed("Horizon Cloud Animation Speed", Float) = 1
|
||||
|
||||
[HideInInspector] _OverheadCloudColor("Overhead Cloud Color", Color) = (1, 1, 1, 0.5)
|
||||
[HideInInspector] _OverheadCloudAltitude("Overhead Cloud Altitude", Float) = 1000
|
||||
[HideInInspector] _OverheadCloudSize("Overhead Cloud Size", Float) = 100
|
||||
[HideInInspector] _OverheadCloudStep("Overhead Cloud Step", Float) = 25
|
||||
[HideInInspector] _OverheadCloudAnimationSpeed("Overhead Cloud Animation Speed", Float) = 1
|
||||
[HideInInspector] _OverheadCloudFlowDirectionX("Overhead Cloud Flow X", Float) = 1
|
||||
[HideInInspector] _OverheadCloudFlowDirectionZ("Overhead Cloud Flow X", Float) = 1
|
||||
[HideInInspector] _OverheadCloudRemapMin("Overhead Cloud Remap Min", Float) = 0
|
||||
[HideInInspector] _OverheadCloudRemapMax("Overhead Cloud Remap Max", Float) = 1
|
||||
|
||||
[HideInInspector] _DetailOverlayTintColor("Detail Overlay Color", COLOR) = (1, 1, 1, 0.5)
|
||||
[HideInInspector] _DetailOverlayCubemap("Detail Overlay Cubemap", CUBE) = "any" {}
|
||||
[HideInInspector] _DetailOverlayLayer("Detail Overlay Layer", Float) = 0
|
||||
[HideInInspector] _DetailOverlayRotationSpeed("Detail Overlay Rotation Speed", Float) = 0
|
||||
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue" = "Background" "RenderType" = "Background" "PreviewType" = "Skybox" }
|
||||
Cull Off ZWrite Off
|
||||
LOD 100
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile_instancing
|
||||
|
||||
#pragma shader_feature_local STARS
|
||||
#pragma shader_feature_local STARS_LAYER_0
|
||||
#pragma shader_feature_local STARS_LAYER_1
|
||||
#pragma shader_feature_local STARS_LAYER_2
|
||||
#pragma shader_feature_local STARS_BAKED
|
||||
|
||||
#pragma shader_feature_local SUN
|
||||
#pragma shader_feature_local SUN_USE_TEXTURE
|
||||
#pragma shader_feature_local SUN_BAKED
|
||||
|
||||
#pragma shader_feature_local MOON
|
||||
#pragma shader_feature_local MOON_USE_TEXTURE
|
||||
#pragma shader_feature_local MOON_BAKED
|
||||
|
||||
#pragma shader_feature_local HORIZON_CLOUD
|
||||
#pragma shader_feature_local OVERHEAD_CLOUD
|
||||
#pragma shader_feature_local DETAIL_OVERLAY
|
||||
#pragma shader_feature_local DETAIL_OVERLAY_ROTATION
|
||||
#pragma shader_feature_local ALLOW_STEP_EFFECT
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "./CGIncludes/JCommon.cginc"
|
||||
#include "./CGIncludes/JSkyGradient.cginc"
|
||||
#include "./CGIncludes/JStars.cginc"
|
||||
#include "./CGIncludes/JSunMoon.cginc"
|
||||
#include "./CGIncludes/JHorizonCloud.cginc"
|
||||
#include "./CGIncludes/JOverheadCloud.cginc"
|
||||
#include "./CGIncludes/JDetailOverlay.cginc"
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
float4 localPos : TEXCOORD1;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
uniform fixed4 _SkyColor;
|
||||
uniform fixed4 _HorizonColor;
|
||||
uniform fixed4 _GroundColor;
|
||||
uniform fixed _HorizonThickness;
|
||||
uniform fixed _HorizonExponent;
|
||||
uniform fixed _HorizonStep;
|
||||
uniform fixed4 _FogColor;
|
||||
|
||||
#if STARS
|
||||
uniform fixed _StarsOpacity;
|
||||
#if STARS_BAKED
|
||||
uniform samplerCUBE _StarsCubemap;
|
||||
uniform sampler2D _StarsTwinkleMap;
|
||||
#else
|
||||
uniform float _StarsStartPosition;
|
||||
uniform float _StarsEndPosition;
|
||||
|
||||
uniform fixed4 _StarsColor0;
|
||||
uniform fixed4 _StarsColor1;
|
||||
uniform fixed4 _StarsColor2;
|
||||
|
||||
uniform float _StarsDensity0;
|
||||
uniform float _StarsDensity1;
|
||||
uniform float _StarsDensity2;
|
||||
|
||||
uniform float _StarsSize0;
|
||||
uniform float _StarsSize1;
|
||||
uniform float _StarsSize2;
|
||||
|
||||
uniform fixed _StarsGlow0;
|
||||
uniform fixed _StarsGlow1;
|
||||
uniform fixed _StarsGlow2;
|
||||
|
||||
uniform fixed _StarsTwinkle0;
|
||||
uniform fixed _StarsTwinkle1;
|
||||
uniform fixed _StarsTwinkle2;
|
||||
#endif //STARS_BAKED
|
||||
#endif //STARS
|
||||
|
||||
#if SUN
|
||||
#if SUN_BAKED
|
||||
uniform samplerCUBE _SunCubemap;
|
||||
uniform float4x4 _SunRotationMatrix;
|
||||
#else
|
||||
#if SUN_USE_TEXTURE
|
||||
uniform sampler2D _SunTex;
|
||||
uniform float4x4 _PositionToSunUV;
|
||||
#endif //SUN_USE_TEXTURE
|
||||
uniform fixed4 _SunColor;
|
||||
uniform float _SunSize;
|
||||
uniform fixed _SunSoftEdge;
|
||||
uniform fixed _SunGlow;
|
||||
uniform float4 _SunDirection;
|
||||
uniform float4 _SunLightColor;
|
||||
uniform float4 _SunLightIntensity;
|
||||
#endif //SUN_BAKED
|
||||
#endif //SUN
|
||||
|
||||
#if MOON
|
||||
#if MOON_BAKED
|
||||
uniform samplerCUBE _MoonCubemap;
|
||||
uniform float4x4 _MoonRotationMatrix;
|
||||
#else
|
||||
#if MOON_USE_TEXTURE
|
||||
uniform sampler2D _MoonTex;
|
||||
uniform float4x4 _PositionToMoonUV;
|
||||
#endif //MOON_USE_TEXTURE
|
||||
uniform fixed4 _MoonColor;
|
||||
uniform float _MoonSize;
|
||||
uniform fixed _MoonSoftEdge;
|
||||
uniform fixed _MoonGlow;
|
||||
uniform float4 _MoonDirection;
|
||||
uniform float4 _MoonLightColor;
|
||||
uniform float4 _MoonLightIntensity;
|
||||
#endif //MOON_BAKED
|
||||
#endif //MOON
|
||||
|
||||
#if HORIZON_CLOUD
|
||||
uniform fixed4 _HorizonCloudColor;
|
||||
uniform fixed _HorizonCloudStartPosition;
|
||||
uniform fixed _HorizonCloudEndPosition;
|
||||
uniform fixed _HorizonCloudSize;
|
||||
uniform fixed _HorizonCloudStep;
|
||||
uniform fixed _HorizonCloudAnimationSpeed;
|
||||
#endif //HORIZON_CLOUD
|
||||
|
||||
#if OVERHEAD_CLOUD
|
||||
uniform fixed4 _OverheadCloudColor;
|
||||
uniform fixed _OverheadCloudAltitude;
|
||||
uniform fixed _OverheadCloudSize;
|
||||
uniform fixed _OverheadCloudStep;
|
||||
uniform fixed _OverheadCloudAnimationSpeed;
|
||||
uniform fixed _OverheadCloudFlowDirectionX;
|
||||
uniform fixed _OverheadCloudFlowDirectionZ;
|
||||
uniform fixed _OverheadCloudRemapMin;
|
||||
uniform fixed _OverheadCloudRemapMax;
|
||||
#endif //OVERHEAD_CLOUD
|
||||
|
||||
#if DETAIL_OVERLAY
|
||||
uniform fixed4 _DetailOverlayTintColor;
|
||||
uniform samplerCUBE _DetailOverlayCubemap;
|
||||
uniform fixed _DetailOverlayLayer;
|
||||
uniform fixed _DetailOverlayRotationSpeed;
|
||||
#endif
|
||||
|
||||
//uniform float4x4 _SkyTransform;
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.uv;
|
||||
o.localPos = v.vertex;
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag(v2f i) : SV_Target
|
||||
{
|
||||
float4 localPos = float4(i.localPos.xyz, 1);
|
||||
//localPos = mul(_SkyTransform, localPos);
|
||||
float4 normalizedLocalPos = float4(normalize(localPos.xyz), 1);
|
||||
fixed4 color = fixed4(0,0,0,0);
|
||||
|
||||
fixed4 skyBlendColor;
|
||||
fixed4 horizonBlendColor;
|
||||
CalculateSkyGradientColor(
|
||||
normalizedLocalPos,
|
||||
_SkyColor, _HorizonColor, _GroundColor,
|
||||
_HorizonThickness, _HorizonExponent, _HorizonStep,
|
||||
skyBlendColor, horizonBlendColor);
|
||||
color = BlendOverlay(skyBlendColor, color);
|
||||
|
||||
#if DETAIL_OVERLAY
|
||||
fixed4 detailOverlayColor;
|
||||
#if DETAIL_OVERLAY_ROTATION
|
||||
CalculateDetailOverlayColor(
|
||||
i.localPos,
|
||||
_DetailOverlayCubemap,
|
||||
_DetailOverlayTintColor,
|
||||
_DetailOverlayRotationSpeed,
|
||||
detailOverlayColor);
|
||||
#else
|
||||
CalculateDetailOverlayColor(
|
||||
i.localPos,
|
||||
_DetailOverlayCubemap,
|
||||
_DetailOverlayTintColor,
|
||||
detailOverlayColor);
|
||||
#endif //DETAIL_OVERLAY_ROTATION
|
||||
|
||||
fixed isLayerEqual = _DetailOverlayLayer == 0;
|
||||
fixed4 overlay = detailOverlayColor;
|
||||
overlay.a *= isLayerEqual;
|
||||
color = BlendOverlay(overlay, color);
|
||||
#endif //DETAIL_OVERLAY
|
||||
|
||||
#if STARS
|
||||
fixed4 starsColor;
|
||||
#if STARS_BAKED
|
||||
CalculateStarsColorBaked(
|
||||
normalizedLocalPos,
|
||||
_StarsCubemap,
|
||||
_StarsTwinkleMap,
|
||||
_StarsOpacity,
|
||||
starsColor);
|
||||
#else
|
||||
#if STARS_LAYER_0
|
||||
fixed4 starsColor0;
|
||||
CalculateStarsColor(
|
||||
normalizedLocalPos,
|
||||
_StarsStartPosition, _StarsEndPosition,
|
||||
_StarsColor0, _StarsOpacity,
|
||||
_StarsDensity0,
|
||||
_StarsSize0,
|
||||
_StarsGlow0,
|
||||
_StarsTwinkle0,
|
||||
starsColor0);
|
||||
starsColor = starsColor0;
|
||||
#endif //STARS_LAYER_0
|
||||
|
||||
#if STARS_LAYER_1
|
||||
fixed4 starsColor1;
|
||||
CalculateStarsColor(
|
||||
normalizedLocalPos,
|
||||
_StarsStartPosition, _StarsEndPosition,
|
||||
_StarsColor1, _StarsOpacity,
|
||||
_StarsDensity1,
|
||||
_StarsSize1,
|
||||
_StarsGlow1,
|
||||
_StarsTwinkle1,
|
||||
starsColor1);
|
||||
starsColor = lerp(starsColor, starsColor1, starsColor1.a);
|
||||
#endif //STARS_LAYER_1
|
||||
|
||||
#if STARS_LAYER_2
|
||||
fixed4 starsColor2;
|
||||
CalculateStarsColor(
|
||||
normalizedLocalPos,
|
||||
_StarsStartPosition, _StarsEndPosition,
|
||||
_StarsColor2, _StarsOpacity,
|
||||
_StarsDensity2,
|
||||
_StarsSize2,
|
||||
_StarsGlow2,
|
||||
_StarsTwinkle2,
|
||||
starsColor2);
|
||||
starsColor = lerp(starsColor, starsColor2, starsColor2.a);
|
||||
#endif //STARS_LAYER_2
|
||||
#endif //STARS_BAKED
|
||||
|
||||
color = BlendOverlay(starsColor, color);
|
||||
#endif //STARS
|
||||
|
||||
#if DETAIL_OVERLAY
|
||||
isLayerEqual = _DetailOverlayLayer == 1;
|
||||
overlay = detailOverlayColor;
|
||||
overlay.a *= isLayerEqual;
|
||||
color = BlendOverlay(overlay, color);
|
||||
#endif //DETAIL_OVERLAY
|
||||
|
||||
#if SUN
|
||||
fixed4 sunColor;
|
||||
#if SUN_BAKED
|
||||
CalculateSunMoonColorBaked(
|
||||
normalizedLocalPos, _SunRotationMatrix,
|
||||
_SunCubemap,
|
||||
sunColor);
|
||||
#else
|
||||
#if SUN_USE_TEXTURE
|
||||
CalculateSunMoonColorTextured(
|
||||
normalizedLocalPos,
|
||||
_SunTex, _PositionToSunUV,
|
||||
_SunColor,
|
||||
_SunSize, _SunSoftEdge, _SunGlow,
|
||||
_SunDirection,
|
||||
sunColor);
|
||||
#else
|
||||
CalculateSunMoonColor(
|
||||
normalizedLocalPos,
|
||||
_SunColor,
|
||||
_SunSize, _SunSoftEdge, _SunGlow,
|
||||
_SunDirection,
|
||||
sunColor);
|
||||
#endif //SUN_USE_TEXTURE
|
||||
#endif //SUN_BAKED
|
||||
color = BlendOverlay(sunColor, color);
|
||||
#endif //SUN
|
||||
|
||||
#if DETAIL_OVERLAY
|
||||
isLayerEqual = _DetailOverlayLayer == 2;
|
||||
overlay = detailOverlayColor;
|
||||
overlay.a *= isLayerEqual;
|
||||
color = BlendOverlay(overlay, color);
|
||||
#endif //DETAIL_OVERLAY
|
||||
|
||||
#if MOON
|
||||
fixed4 moonColor;
|
||||
#if MOON_BAKED
|
||||
CalculateSunMoonColorBaked(
|
||||
normalizedLocalPos, _MoonRotationMatrix,
|
||||
_MoonCubemap,
|
||||
moonColor);
|
||||
#else
|
||||
#if MOON_USE_TEXTURE
|
||||
CalculateSunMoonColorTextured(
|
||||
normalizedLocalPos,
|
||||
_MoonTex, _PositionToMoonUV,
|
||||
_MoonColor,
|
||||
_MoonSize, _MoonSoftEdge, _MoonGlow,
|
||||
_MoonDirection,
|
||||
moonColor);
|
||||
#else
|
||||
CalculateSunMoonColor(
|
||||
normalizedLocalPos,
|
||||
_MoonColor,
|
||||
_MoonSize, _MoonSoftEdge, _MoonGlow,
|
||||
_MoonDirection,
|
||||
moonColor);
|
||||
#endif //MOON_USE_TEXTURE
|
||||
#endif //MOON_BAKED
|
||||
color = BlendOverlay(moonColor, color);
|
||||
#endif //MOON
|
||||
|
||||
#if DETAIL_OVERLAY
|
||||
isLayerEqual = _DetailOverlayLayer == 3;
|
||||
overlay = detailOverlayColor;
|
||||
overlay.a *= isLayerEqual;
|
||||
color = BlendOverlay(overlay, color);
|
||||
#endif
|
||||
|
||||
#if HORIZON_CLOUD
|
||||
fixed4 horizonCloudColor;
|
||||
CalculateHorizonCloudColor(
|
||||
normalizedLocalPos,
|
||||
_HorizonCloudColor,
|
||||
_HorizonCloudStartPosition, _HorizonCloudEndPosition,
|
||||
_HorizonCloudSize, _HorizonCloudStep,
|
||||
_HorizonCloudAnimationSpeed,
|
||||
horizonCloudColor);
|
||||
color = BlendOverlay(horizonCloudColor, color);
|
||||
#endif
|
||||
|
||||
#if DETAIL_OVERLAY
|
||||
isLayerEqual = _DetailOverlayLayer == 4;
|
||||
overlay = detailOverlayColor;
|
||||
overlay.a *= isLayerEqual;
|
||||
color = BlendOverlay(overlay, color);
|
||||
#endif
|
||||
|
||||
#if OVERHEAD_CLOUD
|
||||
fixed4 overheadCloudColor;
|
||||
CalculateOverheadCloudColor(
|
||||
normalizedLocalPos,
|
||||
_OverheadCloudColor,
|
||||
_OverheadCloudAltitude,
|
||||
_OverheadCloudSize,
|
||||
_OverheadCloudStep,
|
||||
_OverheadCloudAnimationSpeed,
|
||||
_OverheadCloudFlowDirectionX,
|
||||
_OverheadCloudFlowDirectionZ,
|
||||
_OverheadCloudRemapMin,
|
||||
_OverheadCloudRemapMax,
|
||||
overheadCloudColor);
|
||||
color = BlendOverlay(overheadCloudColor, color);
|
||||
#endif
|
||||
|
||||
#if DETAIL_OVERLAY
|
||||
isLayerEqual = _DetailOverlayLayer == 5;
|
||||
overlay = detailOverlayColor;
|
||||
overlay.a *= isLayerEqual;
|
||||
color = BlendOverlay(overlay, color);
|
||||
#endif
|
||||
|
||||
color = BlendOverlay(horizonBlendColor, color);
|
||||
|
||||
//color = float4(localPos.xyz, 1);
|
||||
return color;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
Fallback "Unlit/Color"
|
||||
}
|
@@ -0,0 +1,86 @@
|
||||
Shader "Jupiter/SkyShadow"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[HideInInspector] _OverheadCloudColor("Overhead Cloud Color", Color) = (1, 1, 1, 0.5)
|
||||
[HideInInspector] _OverheadCloudAltitude("Overhead Cloud Altitude", Float) = 1000
|
||||
[HideInInspector] _OverheadCloudSize("Overhead Cloud Size", Float) = 100
|
||||
[HideInInspector] _OverheadCloudStep("Overhead Cloud Step", Float) = 25
|
||||
[HideInInspector] _OverheadCloudAnimationSpeed("Overhead Cloud Animation Speed", Float) = 1
|
||||
[HideInInspector] _OverheadCloudFlowDirectionX("Overhead Cloud Flow X", Float) = 1
|
||||
[HideInInspector] _OverheadCloudFlowDirectionZ("Overhead Cloud Flow X", Float) = 1
|
||||
[HideInInspector] _OverheadCloudRemapMin("Overhead Cloud Remap Min", Float) = 0
|
||||
[HideInInspector] _OverheadCloudRemapMax("Overhead Cloud Remap Max", Float) = 1
|
||||
[HideInInspector] _OverheadCloudShadowClipMask("Overhead Cloud Shadow Clip Mask", Float) = 0.1
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Opaque" }
|
||||
LOD 100
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "ShadowCaster"
|
||||
Tags { "LightMode" = "ShadowCaster" }
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 2.0
|
||||
#pragma multi_compile_shadowcaster
|
||||
#pragma multi_compile_instancing // allow instanced shadow pass for most of the shaders
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
#pragma shader_feature_local ALLOW_STEP_EFFECT
|
||||
|
||||
#include "./CGIncludes/JCommon.cginc"
|
||||
#include "./CGIncludes/JOverheadCloud.cginc"
|
||||
|
||||
struct v2f {
|
||||
V2F_SHADOW_CASTER;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
float3 localPos : TEXCOORD1;
|
||||
};
|
||||
|
||||
uniform fixed4 _OverheadCloudColor;
|
||||
uniform fixed _OverheadCloudAltitude;
|
||||
uniform fixed _OverheadCloudSize;
|
||||
uniform fixed _OverheadCloudStep;
|
||||
uniform fixed _OverheadCloudAnimationSpeed;
|
||||
uniform fixed _OverheadCloudFlowDirectionX;
|
||||
uniform fixed _OverheadCloudFlowDirectionZ;
|
||||
uniform fixed _OverheadCloudRemapMin;
|
||||
uniform fixed _OverheadCloudRemapMax;
|
||||
uniform fixed _OverheadCloudShadowClipMask;
|
||||
|
||||
v2f vert(appdata_base v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
TRANSFER_SHADOW_CASTER_NORMALOFFSET(o)
|
||||
o.localPos = v.vertex;
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 frag(v2f i) : SV_Target
|
||||
{
|
||||
float4 localPos = float4(i.localPos.xyz, 1);
|
||||
float4 normalizedLocalPos = float4(normalize(localPos.xyz), 1);
|
||||
fixed4 overheadCloudColor;
|
||||
CalculateOverheadCloudColor(
|
||||
normalizedLocalPos,
|
||||
_OverheadCloudColor,
|
||||
_OverheadCloudAltitude,
|
||||
_OverheadCloudSize, _OverheadCloudStep,
|
||||
_OverheadCloudAnimationSpeed,
|
||||
_OverheadCloudFlowDirectionX, _OverheadCloudFlowDirectionZ,
|
||||
_OverheadCloudRemapMin, _OverheadCloudRemapMax,
|
||||
overheadCloudColor);
|
||||
clip(overheadCloudColor.a - _OverheadCloudShadowClipMask);
|
||||
SHADOW_CASTER_FRAGMENT(i)
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user