Enable placeable sun deck attractions and finish project rebrand
This commit is contained in:
95
Assets/BigShipTycoon/Resources/PortScenerySurface.shader
Normal file
95
Assets/BigShipTycoon/Resources/PortScenerySurface.shader
Normal file
@@ -0,0 +1,95 @@
|
||||
Shader "BigShipTycoon/Port Scenery Surface"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_Color ("Material color", Color) = (.65,.64,.58,1)
|
||||
_HazeColor ("Harbor atmosphere", Color) = (.60,.63,.66,1)
|
||||
_Detail ("Surface finish", Float) = 0
|
||||
_Glow ("Window light", Range(0,1)) = 0
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Opaque" }
|
||||
Cull Off
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma target 3.0
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
float4 _Color, _HazeColor;
|
||||
float _Detail, _Glow;
|
||||
struct Input { float4 position : POSITION; float3 normal : NORMAL; };
|
||||
struct Output { float4 screen : SV_POSITION; float3 position : TEXCOORD0; float3 normal : TEXCOORD1; };
|
||||
|
||||
Output vert(Input input)
|
||||
{
|
||||
Output output;
|
||||
output.screen = UnityObjectToClipPos(input.position);
|
||||
output.position = mul(unity_ObjectToWorld, input.position).xyz;
|
||||
output.normal = UnityObjectToWorldNormal(input.normal);
|
||||
return output;
|
||||
}
|
||||
|
||||
float Lattice(float2 cell)
|
||||
{
|
||||
float3 p = frac(cell.xyx * .1031);
|
||||
p += dot(p, p.yzx + 33.33);
|
||||
return frac((p.x + p.y) * p.z);
|
||||
}
|
||||
|
||||
float GroundNoise(float2 position)
|
||||
{
|
||||
float2 cell = floor(position);
|
||||
float2 blend = frac(position);
|
||||
blend *= blend * (3 - 2 * blend);
|
||||
return lerp(lerp(Lattice(cell), Lattice(cell + float2(1,0)), blend.x),
|
||||
lerp(Lattice(cell + float2(0,1)), Lattice(cell + 1), blend.x), blend.y);
|
||||
}
|
||||
|
||||
fixed4 frag(Output input, fixed side : VFACE) : SV_Target
|
||||
{
|
||||
float3 p = input.position;
|
||||
float3 n = normalize(input.normal) * (side >= 0 ? 1 : -1);
|
||||
float3 view = normalize(_WorldSpaceCameraPos.xyz - p);
|
||||
float3 sun = normalize(float3(-.69,.40,-.43));
|
||||
float2 samplePosition = p.xz + p.y * float2(.42,.76);
|
||||
float relief = GroundNoise(samplePosition * .22) - .5;
|
||||
float fine = (GroundNoise(samplePosition * 1.35) - .5) * (1 - smoothstep(.35,.91, length(fwidth(samplePosition))));
|
||||
float coarse = GroundNoise(samplePosition * .071) - .5;
|
||||
float3 albedo = _Color.rgb * (1 + relief * .10 + fine * .075);
|
||||
if (_Detail == 1)
|
||||
{
|
||||
float stone = smoothstep(-.23,.29, .55 * relief + .24 * fine + .42 * coarse);
|
||||
albedo *= .79 + .30 * stone + coarse * .19;
|
||||
albedo *= lerp(.72, 1, smoothstep(-.12, 1.4, p.y));
|
||||
}
|
||||
if (_Detail == 2)
|
||||
{
|
||||
float tile = 1 - smoothstep(.024,.094, abs(frac((p.z + p.y * .56) * 1.9 + .5) - .5));
|
||||
albedo *= 1 + fine * .11 - tile * .10 * (1 - smoothstep(.28, .68, fwidth(p.z * 1.9)));
|
||||
}
|
||||
if (_Detail == 4)
|
||||
albedo *= .87 + relief * .16 + fine * .12 + coarse * .13;
|
||||
|
||||
float diffuse = saturate(dot(n, sun));
|
||||
float sky = n.y * .5 + .5;
|
||||
float3 bounce = lerp(float3(.28,.32,.43),float3(.67,.71,.78),sky);
|
||||
float3 color = albedo * (bounce + diffuse * float3(.71,.51,.33));
|
||||
if (_Detail == 3)
|
||||
{
|
||||
float reflectedSky = saturate(reflect(-view, n).y * 2 + .11);
|
||||
float edge = pow(1 - saturate(dot(n, view)), 2.4);
|
||||
float3 reflection = lerp(float3(.13,.22,.27), _HazeColor.rgb * .85, reflectedSky);
|
||||
color = lerp(color, reflection, (.44 + .51 * edge) * (1 - _Glow)) + _Color.rgb * _Glow;
|
||||
}
|
||||
float distance = length(_WorldSpaceCameraPos.xyz - p);
|
||||
float haze = smoothstep(120, 640, distance) * .87;
|
||||
return fixed4(lerp(color, _HazeColor.rgb, haze), 1);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user