78 lines
3.4 KiB
GLSL
78 lines
3.4 KiB
GLSL
Shader "BigShipTycoon/Passenger Surface"
|
|
{
|
|
SubShader
|
|
{
|
|
Tags { "RenderType"="Opaque" "Queue"="Geometry" }
|
|
Pass
|
|
{
|
|
CGPROGRAM
|
|
#pragma target 3.0
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
#include "UnityCG.cginc"
|
|
#include "TycoonTexturing.cginc"
|
|
|
|
struct Input
|
|
{
|
|
float4 vertex : POSITION;
|
|
float3 normal : NORMAL;
|
|
fixed4 tint : COLOR;
|
|
float4 body : TEXCOORD0;
|
|
};
|
|
struct Output
|
|
{
|
|
float4 clip : SV_POSITION;
|
|
float3 normal : TEXCOORD0;
|
|
float3 world : TEXCOORD1;
|
|
float4 body : TEXCOORD2;
|
|
fixed4 tint : COLOR;
|
|
};
|
|
|
|
Output vert(Input input)
|
|
{
|
|
Output output;
|
|
output.clip = UnityObjectToClipPos(input.vertex);
|
|
output.normal = UnityObjectToWorldNormal(input.normal);
|
|
output.world = mul(unity_ObjectToWorld, input.vertex).xyz;
|
|
output.tint = input.tint;
|
|
output.body = input.body;
|
|
return output;
|
|
}
|
|
|
|
fixed4 frag(Output input) : SV_Target
|
|
{
|
|
float noise = frac(dot(floor(input.clip.xy), float2(.754877, .56984)));
|
|
clip(input.tint.a - noise - .001);
|
|
float surface = input.body.w;
|
|
if (surface > 3.5)
|
|
return fixed4(input.tint.rgb, 1);
|
|
|
|
float3 normal = normalize(input.normal);
|
|
float3 eye = unity_OrthoParams.w > .5 ? UNITY_MATRIX_V[2].xyz : normalize(_WorldSpaceCameraPos.xyz - input.world);
|
|
float3 lightDirection = normalize(float3(-.69,.40,-.43));
|
|
float skin = 1 - saturate(abs(surface - 1));
|
|
float fabric = saturate(1 - surface);
|
|
float sun = saturate(dot(normal, lightDirection));
|
|
float subsurface = max(0, dot(normal, lightDirection) + .34) * .746;
|
|
float lightAngle = lerp(sun, subsurface, skin * .86);
|
|
float overhead = saturate(normal.y * .5 + .5);
|
|
float3 bounce = lerp(float3(.53,.61,.71), float3(.83,.88,.94), overhead);
|
|
float3 light = bounce + lightAngle * lerp(float3(.33,.278,.232), float3(.43,.286,.21), skin);
|
|
float fresnel = pow(1 - saturate(dot(eye, normal)), 3);
|
|
float glint = pow(saturate(dot(normal, normalize(lightDirection + eye))), lerp(47, 12, skin * .72 + fabric * .12));
|
|
float luminousEdge = fresnel * (.023 + .013 * skin);
|
|
float3 sheen = glint * lerp(float3(.112,.131,.145), float3(.102,.068,.055), skin) * (.37 + .64 * sun);
|
|
float2 cloth = input.body.xy + input.body.z * float2(.41, -.37);
|
|
float knit = TycoonWeave(cloth, float2(42, 51));
|
|
float narrowStripe = cos(cloth.y * 137 + cloth.x * 21) * TycoonDetail(cloth.y * 21.8);
|
|
float fabricTone = fabric * (knit * .097 + narrowStripe * .024);
|
|
float pores = TycoonStipple(cloth, 122) * skin * .058;
|
|
float3 color = input.tint.rgb * light * (1 + fabricTone + pores) + sheen
|
|
+ float3(.57,.69,.76) * luminousEdge;
|
|
return fixed4(TycoonHighlightRollOff(color), 1);
|
|
}
|
|
ENDCG
|
|
}
|
|
}
|
|
}
|