Files
cruiseSimulator/Assets/BigShipTycoon/Resources/BridgeGlazing.shader

57 lines
2.2 KiB
GLSL

Shader "BigShipTycoon/Bridge Glazing"
{
Properties
{
_Color ("Glass tint", Color) = (.52,.74,.79,1)
}
SubShader
{
Tags { "Queue" = "Transparent" "RenderType" = "Transparent" }
Blend SrcAlpha OneMinusSrcAlpha
Cull Off
ZWrite Off
Pass
{
CGPROGRAM
#pragma target 3.0
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
#include "TycoonTexturing.cginc"
fixed4 _Color;
struct Input { float4 vertex : POSITION; float3 normal : NORMAL; };
struct Output { float4 clip : SV_POSITION; float3 world : TEXCOORD0; float3 normal : TEXCOORD1; float3 local : TEXCOORD2; };
Output vert(Input input)
{
Output output;
output.clip = UnityObjectToClipPos(input.vertex);
output.world = mul(unity_ObjectToWorld, input.vertex).xyz;
output.normal = UnityObjectToWorldNormal(input.normal);
output.local = input.vertex.xyz;
return output;
}
fixed4 frag(Output input) : SV_Target
{
float3 eye = normalize(_WorldSpaceCameraPos.xyz - input.world);
float3 normal = normalize(input.normal);
float edge = 1 - abs(dot(eye, normal));
float3 reflection = reflect(-eye, normal);
float reflectedSky = smoothstep(.03, .79, reflection.y);
float horizon = 1 - smoothstep(.024, .21, abs(reflection.y - .055));
float wash = sin(input.local.x * .51 + input.local.z * .84) * sin(input.local.y * 2.43)
* TycoonDetail(input.local.y * .386);
float glare = pow(saturate(dot(reflection, float3(-.69,.46,-.43))), 21);
float3 tint = lerp(_Color.rgb * .63, float3(.74,.83,.86), reflectedSky * .46);
tint += horizon * float3(.073,.092,.106) + glare * float3(.08,.068,.051);
float alpha = .044 + edge * edge * .20 + reflectedSky * .041 + wash * .007;
return fixed4(tint, alpha);
}
ENDCG
}
}
}