// The look of the people on the video calls (the Director, his assistant): lit by the studio's own lamps, fixed in view // space, so the planet's sun, its night and its fog have nothing to do with them. A warm key from up front and to one side, // a cool fill, a rim from behind, soft wrap-round light like a toy under studio lamps. _Lit 0 is the plain picture // behind them. _Flush reddens the skin when he's angry. Shader "GrassCutter/Studio" { Properties { _BaseMap ("Texture", 2D) = "white" {} _BaseColor ("Colour", Color) = (1, 1, 1, 1) _Lit ("Lit", Float) = 1 _Flush ("Flush", Color) = (0, 0, 0, 0) [Enum(UnityEngine.Rendering.CullMode)] _Cull ("Cull", Float) = 2 } SubShader { Tags { "RenderType" = "Opaque" "Queue" = "Geometry" "RenderPipeline" = "UniversalPipeline" } Pass { Name "Studio" Tags { "LightMode" = "UniversalForward" } Cull [_Cull] HLSLPROGRAM #pragma vertex vert #pragma fragment frag #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" TEXTURE2D(_BaseMap); SAMPLER(sampler_BaseMap); CBUFFER_START(UnityPerMaterial) float4 _BaseMap_ST; float4 _BaseColor; float _Lit; float4 _Flush; float _Cull; CBUFFER_END struct Attributes { float4 positionOS : POSITION; float3 normalOS : NORMAL; float2 uv : TEXCOORD0; }; struct Varyings { float4 positionCS : SV_POSITION; float3 normalVS : TEXCOORD0; float2 uv : TEXCOORD1; float3 viewVS : TEXCOORD2; }; Varyings vert(Attributes i) { Varyings o; float3 ws = TransformObjectToWorld(i.positionOS.xyz); o.positionCS = TransformWorldToHClip(ws); o.normalVS = mul((float3x3)UNITY_MATRIX_V, TransformObjectToWorldNormal(i.normalOS)); o.viewVS = -TransformWorldToView(ws); o.uv = TRANSFORM_TEX(i.uv, _BaseMap); return o; } float4 frag(Varyings i, bool front : SV_IsFrontFace) : SV_Target { float3 albedo = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, i.uv).rgb * _BaseColor.rgb; if (_Lit < 0.5) return float4(albedo, 1); float3 n = normalize(i.normalVS) * (front ? 1 : -1); float3 v = normalize(i.viewVS); // view space: x right, y up, z toward the viewer float3 key = normalize(float3(-0.55, 0.6, 0.6)); float3 fill = normalize(float3(0.7, 0.1, 0.5)); float3 rim = normalize(float3(0.35, 0.45, -0.8)); float k = saturate(dot(n, key) * 0.6 + 0.4); // wrapped, so the shadow side never goes black float f = saturate(dot(n, fill) * 0.5 + 0.5); float r = pow(saturate(1 - dot(n, v)), 3) * saturate(dot(n, rim) + 0.6); float3 light = 0.38 * float3(0.92, 0.95, 1.05) // the room + 0.6 * k * float3(1.03, 0.99, 0.94) // the key, a little warm + 0.14 * f * float3(0.82, 0.9, 1.0) // the fill, cool + 0.32 * r * float3(1.0, 0.98, 0.94); // the rim float3 c = albedo * light; // a touch of shine where the key glances off float3 h = normalize(key + v); c += pow(saturate(dot(n, h)), 40) * 0.08; // red in the face: skin is the warm, light colours float skin = saturate((albedo.r - albedo.b) * 2.2 - 0.3) * saturate((albedo.r - 0.35) * 3); c = lerp(c, c * float3(1.25, 0.62, 0.55), _Flush.a * skin); // the painted colours are strong: taken down a little toward grey, and a soft shoulder on the brights, // as the planet's camera does with its tone mapping float l = dot(c, float3(0.2126, 0.7152, 0.0722)); c = lerp(l.xxx, c, 0.8); c = c / (1 + 0.2 * c) * 1.12; return float4(c, 1); } ENDHLSL } } }