UnityChanToonShaderVer2_Project icon indicating copy to clipboard operation
UnityChanToonShaderVer2_Project copied to clipboard

Small error in UnityToonBody.HLSL for editors>= 202310

Open famousclark opened this issue 1 year ago • 0 comments

Describe the bug A small error in Unity versions >= 202310, that causes materials with the shader to go pink. below is the error spot and the small fix. (OUTPUT_SH should be OUTPUT_SH4 if editor version is >= 202310) Love the shader and just wanted to helpful to other users of it

Error in code

#if UNITY_VERSION >= 202310
                OUTPUT_SH(positionWS, o.normalDir.xyz, GetWorldSpaceNormalizeViewDir(positionWS), o.vertexSH);
#else
                OUTPUT_SH(o.normalDir.xyz, o.vertexSH);
#endif

#if defined(_ADDITIONAL_LIGHTS_VERTEX) ||  (VERSION_LOWER(12, 0))  
            o.fogFactorAndVertexLight = half4(fogFactor, vertexLight);
#else
            o.fogFactor = fogFactor;
#endif 

Fixed Code

#if UNITY_VERSION >= 202310
                OUTPUT_SH4(positionWS, o.normalDir.xyz, GetWorldSpaceNormalizeViewDir(positionWS), o.vertexSH);
#else
                OUTPUT_SH(o.normalDir.xyz, o.vertexSH);
#endif

#if defined(_ADDITIONAL_LIGHTS_VERTEX) ||  (VERSION_LOWER(12, 0))  
            o.fogFactorAndVertexLight = half4(fogFactor, vertexLight);
#else
            o.fogFactor = fogFactor;
#endif 

famousclark avatar Aug 12 '23 03:08 famousclark