portals and dash. Also a bit of terrain building and level design

This commit is contained in:
2022-03-13 00:26:35 +02:00
parent 813cd0c451
commit e82799c36a
6242 changed files with 2160679 additions and 188245 deletions

View File

@@ -0,0 +1,6 @@
#ifndef FILE_INCLUDED
#define FILE_INCLUDED
#endif

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 3c059265d03c297408a316f58ccb37a3
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: f0303c57b5706684594ad27c88d2a37d
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 3b1f874b66731a847b92da319d75fe24
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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 = InverseLerpUnclamped(cloudStart, 0, localPos.y);
fixed fadeTop = 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

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: bbd8ba78921750d40b3e4e70613b06a2
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 9512fc8a4d695464590e82d39ec78719
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 6a99e12682a251a418901c7b6f70bb20
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 87ddcc1ef32a551499b588a6c2f6c1f4
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 05f169cc85471d442958b8585d1f1fb1
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant: