unity3d-jp / UnityChanToonShaderVer2_Project

UnityChanToonShaderVer2 Project / v.2.0.9 Release
3.82k stars 811 forks source link

Small error in UnityToonBody.HLSL for editors>= 202310 #124

Open famousclark opened 1 year ago

famousclark commented 1 year ago

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