From 8930122e929c7038af268b0df9bf991f7ed1010e Mon Sep 17 00:00:00 2001 From: nibu-hands Date: Tue, 1 Dec 2026 11:00:45 +0100 Subject: [PATCH] FaunaSkinned: a Standard surface shader; the hand-written ForwardBase pass is deleted Metallic workflow with _MainTex, _Color, _Glossiness, _Metallic and _Cull (the first three the names SkinMaterial and the checks use). vertex:vert skins position and normal with SpringSkin; addshadow makes the shadow caster skin the same way, so the whale casts its skinned silhouette. It is the look shader. SpringSkin.cginc stays as it is. The surface shader's analysis pass cannot parse its StructuredBuffer ("Unexpected identifier StructuredBuffer"), and defines no UNITY_PASS_*, so the shader includes the file only under UNITY_PASS_FORWARDBASE, FORWARDADD, SHADOWCASTER or DEFERRED and gives the analysis pass a one-line stub of SpringSkin. skin-matches-cpu passes on it. Co-Authored-By: Claude Sonnet 5.5 --- Assets/Shaders/FaunaSkinned.shader | 101 +++++++++++++++-------------- 1 file changed, 51 insertions(+), 50 deletions(-) diff --git a/Assets/Shaders/FaunaSkinned.shader b/Assets/Shaders/FaunaSkinned.shader index 034feca21..266a8b5b4 100644 --- a/Assets/Shaders/FaunaSkinned.shader +++ b/Assets/Shaders/FaunaSkinned.shader @@ -1,67 +1,68 @@ -// Minimal lit built-in-pipeline shader for a SpringRig mesh: base colour texture, one directional light and ambient. -// The leviathan's look shader is later work (follow-up whale-rig-leviathan-asset); it includes SpringSkin.cginc the same way. +// The fauna look shader: Unity's Standard lighting (Metallic workflow, directional and ambient light, shadows received and cast) +// on a SpringRig mesh. The vertex hook skins position and normal from the rig's bone matrices (SpringSkin.cginc), and addshadow +// makes the shadow caster skin the same way. SpringRigImporter makes the material: _MainTex from the file's base colour, +// _Glossiness as 1 - roughness, _Metallic 0. Shader "Aetheria/FaunaSkinned" { Properties { _MainTex ("Base colour", 2D) = "white" {} _Color ("Tint", Color) = (1, 1, 1, 1) + _Glossiness ("Smoothness", Range(0, 1)) = 0.1 + _Metallic ("Metallic", Range(0, 1)) = 0 [Enum(UnityEngine.Rendering.CullMode)] _Cull ("Cull", Float) = 2 } SubShader { Tags { "RenderType" = "Opaque" } - Pass + Cull [_Cull] + CGPROGRAM + #pragma surface surf Standard fullforwardshadows vertex:vert addshadow + #pragma target 4.5 + // The surface shader's analysis pass cannot parse SpringSkin.cginc's StructuredBuffer and defines no UNITY_PASS_*: it gets the + // signature only; every generated pass (forward, forward add, shadow caster, deferred) includes the skinning. + #if defined(UNITY_PASS_FORWARDBASE) || defined(UNITY_PASS_FORWARDADD) || defined(UNITY_PASS_SHADOWCASTER) || defined(UNITY_PASS_DEFERRED) + #include "SpringSkin.cginc" + #else + void SpringSkin(inout float3 position, inout float3 normal, uint4 indices, float4 weights) { } + #endif + + sampler2D _MainTex; + fixed4 _Color; + half _Glossiness, _Metallic; + + struct appdata { - Tags { "LightMode" = "ForwardBase" } - Cull [_Cull] - CGPROGRAM - #pragma vertex vert - #pragma fragment frag - #pragma target 4.5 - #include "UnityCG.cginc" - #include "UnityLightingCommon.cginc" - #include "SpringSkin.cginc" + float4 vertex : POSITION; + float3 normal : NORMAL; + float4 texcoord : TEXCOORD0; + float4 texcoord1 : TEXCOORD1; + float4 texcoord2 : TEXCOORD2; + uint4 bones : BLENDINDICES; + float4 weights : BLENDWEIGHTS; + }; - sampler2D _MainTex; - float4 _MainTex_ST; - fixed4 _Color; + struct Input + { + float2 uv_MainTex; + }; - struct appdata - { - float4 vertex : POSITION; - float3 normal : NORMAL; - float2 uv : TEXCOORD0; - uint4 bones : BLENDINDICES; - float4 weights : BLENDWEIGHTS; - }; - - struct v2f - { - float4 pos : SV_POSITION; - float2 uv : TEXCOORD0; - float3 normal : TEXCOORD1; - }; - - v2f vert(appdata v) - { - float3 position = v.vertex.xyz, normal = v.normal; - SpringSkin(position, normal, v.bones, v.weights); - v2f o; - o.pos = UnityObjectToClipPos(float4(position, 1)); - o.uv = TRANSFORM_TEX(v.uv, _MainTex); - o.normal = UnityObjectToWorldNormal(normal); - return o; - } - - fixed4 frag(v2f i) : SV_Target - { - fixed4 albedo = tex2D(_MainTex, i.uv) * _Color; - float3 n = normalize(i.normal); - float3 light = _LightColor0.rgb * max(0, dot(n, _WorldSpaceLightPos0.xyz)) + ShadeSH9(float4(n, 1)); - return fixed4(albedo.rgb * light, 1); - } - ENDCG + void vert(inout appdata v) + { + float3 position = v.vertex.xyz, normal = v.normal; + SpringSkin(position, normal, v.bones, v.weights); + v.vertex = float4(position, 1); + v.normal = normal; } + + void surf(Input i, inout SurfaceOutputStandard o) + { + fixed4 albedo = tex2D(_MainTex, i.uv_MainTex) * _Color; + o.Albedo = albedo.rgb; + o.Metallic = _Metallic; + o.Smoothness = _Glossiness; + o.Alpha = 1; + } + ENDCG } }