foriero

Shader error in 'Universal Render Pipeline/2D/Spine/Skeleton Lit': 'CombinedShapeLightShared': cannot implicitly convert from 'const half4' to 'struct SurfaceData2D' at line 115 (on metal)

Compiling Vertex program with USE_SHAPE_LIGHT_TYPE_0 _LIGHT_AFFECTS_ADDITIVE _STRAIGHT_ALPHA_INPUT
Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_LIGHTMAP_RGBM_ENCODING
Disabled keywords: USE_SHAPE_LIGHT_TYPE_1 USE_SHAPE_LIGHT_TYPE_2 USE_SHAPE_LIGHT_TYPE_3 UNITY_NO_DXT5nm UNITY_FRAMEBUFFER_FETCH_AVAILABLE UNITY_ENABLE_NATIVE_SHADOW_LOOKUPS UNITY_METAL_SHADOWS_USE_POINT_FILTERING UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF2 UNITY_PBS_USE_BRDF3 UNITY_NO_FULL_STANDARD_SHADER UNITY_HARDWARE_TIER1 UNITY_HARDWARE_TIER2 UNITY_HARDWARE_TIER3 UNITY_COLORSPACE_GAMMA UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS UNITY_LIGHTMAP_DLDR_ENCODING UNITY_LIGHTMAP_FULL_HDR UNITY_VIRTUAL_TEXTURING UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION UNITY_ASTC_NORMALMAP_ENCODING SHADER_API_GLES30 UNITY_UNIFIED_SHADER_PRECISION_MODEL
Founder & CEO Foriero s.r.o.
https://studio.foriero.com
User avatar
foriero
  • Posts: 465

Harald

Thanks for the early warning! If this problem still persists after it is both out of alpha and beta, we will eagerly fix the issue.
User avatar
Harald

Harri
  • Posts: 3575

foriero

Harald, I know it is too early but we need to move to 2021.2b1 due to URP Render Features. Is there an easy fix for this issue? Thanks, Marek.

---

Here is temporary fix.

Screenshot 2021-06-28 at 8.30.11.png
You do not have the required permissions to view the files attached to this post.
Founder & CEO Foriero s.r.o.
https://studio.foriero.com
User avatar
foriero
  • Posts: 465

Harald

Sorry for the late reply, I have been on (very short) vacation. Very glad to see that you have already fixed the issue, thanks a lot for sharing!
User avatar
Harald

Harri
  • Posts: 3575

foriero

The final colors are somehow off. May it needs a bit more tweaking. Please let me know once you have it in the repository.
Founder & CEO Foriero s.r.o.
https://studio.foriero.com
User avatar
foriero
  • Posts: 465

Harald

Thanks for the hint. I have created an issue ticket for it here so that it cannot get lost:
https://github.com/EsotericSoftware/spine-runtimes/issues/1912
I will let you know once it's in the reprository.

---

The shader compile error with URP 12.0 has just been fixed.

A new 4.0 spine-unity URP shaders UPM package is available for download here as usual:
Spine Unity Download: spine unity 4.0
User avatar
Harald

Harri
  • Posts: 3575

TetsuroNoda

途中から、すいません。

Unity 2021.2.2f1
Spine
com.esotericsoftware.spine.timeline-4.0-2021-11-09.zip
com.esotericsoftware.spine.urp-shaders-4.0-Unity2019.3-2021-10-29.zip
を利用していますが、以下のエラーが出ています。
どうすればよろしいでしょうか?

Shader error in 'Universal Render Pipeline/2D/Spine/Sprite': 'CombinedShapeLightShared': cannot implicitly convert from 'const half4' to 'struct SurfaceData2D' at Packages/com.esotericsoftware.spine.urp-shaders-4.0-2019.1/Shaders/2D/Include/Spine-Sprite-StandardPass-URP-2D.hlsl(95) (on metal)

Compiling Vertex program with USE_SHAPE_LIGHT_TYPE_0 _ALPHAPREMULTIPLY_ON _FIXED_NORMALS_VIEWSPACE
Platform defines: SHADER_API_DESKTOP UNITY_COLORSPACE_GAMMA UNITY_ENABLE_DETAIL_NORMALMAP UNITY_ENABLE_REFLECTION_BUFFERS UNITY_LIGHTMAP_RGBM_ENCODING UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BLENDING UNITY_SPECCUBE_BOX_PROJECTION UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS
Disabled keywords: INSTANCING_ON PIXELSNAP_ON SHADER_API_GLES30 UNITY_ASTC_NORMALMAP_ENCODING UNITY_ENABLE_NATIVE_SHADOW_LOOKUPS UNITY_FRAMEBUFFER_FETCH_AVAILABLE UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS UNITY_HARDWARE_TIER1 UNITY_HARDWARE_TIER2 UNITY_HARDWARE_TIER3 UNITY_LIGHTMAP_DLDR_ENCODING UNITY_LIGHTMAP_FULL_HDR UNITY_METAL_SHADOWS_USE_POINT_FILTERING UNITY_NO_DXT5nm UNITY_NO_FULL_STANDARD_SHADER UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF2 UNITY_PBS_USE_BRDF3 UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION UNITY_UNIFIED_SHADER_PRECISION_MODEL UNITY_VIRTUAL_TEXTURING USE_SHAPE_LIGHT_TYPE_1 USE_SHAPE_LIGHT_TYPE_2 USE_SHAPE_LIGHT_TYPE_3 _ADDITIVEBLEND _ADDITIVEBLEND_SOFT _ALPHABLEND_ON _ALPHAPREMULTIPLY_VERTEX_ONLY _ALPHA_CLIP _COLOR_ADJUST _EMISSION _FIXED_NORMALS_MODELSPACE _FIXED_NORMALS_MODELSPACE_BACKFACE _FIXED_NORMALS_VIEWSPACE_BACKFACE _LIGHT_AFFECTS_ADDITIVE _MULTIPLYBLEND _MULTIPLYBLEND_X2 _NORMALMAP _RIM_LIGHTING _STRAIGHT_ALPHA_INPUT _TEXTURE_BLEND
TetsuroNoda
  • Posts: 2

Harald

エラーが出てしまうとのことで申し訳ありません。

お手数ですが、ファイルcom.esotericsoftware.spine.urp-shaders/Shaders/2D/Spine-SkeletonLit-URP-2D.shaderを開いて、115行目にこちらのコードがあるかどうか確認していただけますか?
#if UNITY_VERSION < 202120
return half4(CombinedShapeLightShared(half4(main.rgb, 1), mask, i.lightingUV).rgb, main.a);
#else
SurfaceData2D surfaceData;
InputData2D inputData;
surfaceData.albedo = main.rgb;
surfaceData.alpha = 1;
surfaceData.mask = mask;
inputData.uv = i.uv;
inputData.lightingUV = i.lightingUV;
return half4(CombinedShapeLightShared(surfaceData, inputData).rgb, main.a);
#endif
もし115行目にこちらのコードが表示されない場合は、UPMパッケージの更新で必要なファイルの更新に失敗しています。

このコードが表示された場合は、
#if UNITY_VERSION < 202120

#if 0
に変更してみてください。
これにより、常にUnity 2020.2に適したコードブランチが使用されます。

これでも効果がない場合は、別のシェーダーが使われていると思われますので、プロジェクトに同じパッケージを2つのバージョンで入れている、または同じSpine-SkeletonLit-URP-2D.shaderを2つのバージョンで入れてしまっていないか確認してみてください。
-----
Sorry to hear you are having troubles.

Could you please open the file com.esotericsoftware.spine.urp-shaders/Shaders/2D/Spine-SkeletonLit-URP-2D.shader and check if you see this code in line 115:
#if UNITY_VERSION < 202120
return half4(CombinedShapeLightShared(half4(main.rgb, 1), mask, i.lightingUV).rgb, main.a);
#else
SurfaceData2D surfaceData;
InputData2D inputData;
surfaceData.albedo = main.rgb;
surfaceData.alpha = 1;
surfaceData.mask = mask;
inputData.uv = i.uv;
inputData.lightingUV = i.lightingUV;
return half4(CombinedShapeLightShared(surfaceData, inputData).rgb, main.a);
#endif
If you do not see this code in line 115, then something with updating the UPM package has failed updating the necessary files.

If you see this code, you could try changing
#if UNITY_VERSION < 202120
to
#if 0
This will then always use the suitable code branch for Unity 2020.2.

If this also has no effect, then I assume that it is another shader that is used, so please check if you don't have two versions of the same package or two versions of the same Spine-SkeletonLit-URP-2D.shader shader in the project.
User avatar
Harald

Harri
  • Posts: 3575

TetsuroNoda

回答ありがとうございます!

Unity 内に複数パッケージが取り込まれているようなことは確認できませんでした。
Spine Unity Download: spine unity 4.0
などから再度ダウンロードし、

Spine パッケージそのものも削除してから、再度 Import Package してみましたが、
やはり解消されませんでした。
URP shaders も同様に試してみましたが、変化ありませんでした。

手動でエラーの出ているところにコード記述すれば、なんとか回避できることがわかりましたので、
それで対応していくことにします。

ありがとうございました!
TetsuroNoda
  • Posts: 2

Harald

ご返信、および追加情報をお寄せいただきありがとうございます。

このような状況で観察された動作は実に奇妙であり、 #if UNITY_VERSION <202120チェックが期待どおりに機能していないように見えます。 それでも、それに応じてコードを変更することで問題を解決できると聞いてうれしいです。 ご連絡ありがとうございました!
-----
Thanks for getting back to us and for the additional information.

Under these circumstances your observed behaviour is indeed strange, it seems as if the #if UNITY_VERSION < 202120 check does not work as expected. Nevertheless glad to hear that you could resolve the problem by modifying the code accordingly. Thanks for letting us know.
User avatar
Harald

Harri
  • Posts: 3575

Jamez0r

Hey guys, I'm updating my project from Unity 2020.2 to 2021.2. Getting the same error but in Spine-Sprite-StandardPass-URP-2D.hlsl (when using the URP/2D/Spine/Sprite shader, with the latest Spine URP shaders)
Shader error in 'Universal Render Pipeline/2D/Spine/Sprite': 'CombinedShapeLightShared': cannot implicitly convert from 'const half4' to 'struct SurfaceData2D' at /Users/james/PlasticSCM Workspaces/Perennial Order/Packages/com.esotericsoftware.spine.urp-shaders-4.0-2019.1/Shaders/2D/Include/Spine-Sprite-StandardPass-URP-2D.hlsl(95) (on d3d11)

Compiling Vertex program with USE_SHAPE_LIGHT_TYPE_0 _ALPHAPREMULTIPLY_ON _FIXED_NORMALS_VIEWSPACE _NORMALMAP
Platform defines: SHADER_API_DESKTOP UNITY_COLORSPACE_GAMMA UNITY_ENABLE_DETAIL_NORMALMAP UNITY_ENABLE_REFLECTION_BUFFERS UNITY_LIGHTMAP_FULL_HDR UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BLENDING UNITY_SPECCUBE_BOX_PROJECTION UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS
Disabled keywords: INSTANCING_ON PIXELSNAP_ON SHADER_API_GLES30 UNITY_ASTC_NORMALMAP_ENCODING UNITY_ENABLE_NATIVE_SHADOW_LOOKUPS UNITY_FRAMEBUFFER_FETCH_AVAILABLE UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS UNITY_HARDWARE_TIER1 UNITY_HARDWARE_TIER2 UNITY_HARDWARE_TIER3 UNITY_LIGHTMAP_DLDR_ENCODING UNITY_LIGHTMAP_RGBM_ENCODING UNITY_METAL_SHADOWS_USE_POINT_FILTERING UNITY_NO_DXT5nm UNITY_NO_FULL_STANDARD_SHADER UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF2 UNITY_PBS_USE_BRDF3 UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION UNITY_UNIFIED_SHADER_PRECISION_MODEL UNITY_VIRTUAL_TEXTURING USE_SHAPE_LIGHT_TYPE_1 USE_SHAPE_LIGHT_TYPE_2 USE_SHAPE_LIGHT_TYPE_3 _ADDITIVEBLEND _ADDITIVEBLEND_SOFT _ALPHABLEND_ON _ALPHAPREMULTIPLY_VERTEX_ONLY _ALPHA_CLIP _COLOR_ADJUST _EMISSION _FIXED_NORMALS_MODELSPACE _FIXED_NORMALS_MODELSPACE_BACKFACE _FIXED_NORMALS_VIEWSPACE_BACKFACE _LIGHT_AFFECTS_ADDITIVE _MULTIPLYBLEND _MULTIPLYBLEND_X2 _RIM_LIGHTING _STRAIGHT_ALPHA_INPUT _TEXTURE_BLEND
Using you guys' code from this post (minus the UNITY_VERSION stuff), I changed this line:
half4 pixel = half4(CombinedShapeLightShared(half4(main.rgb, 1), mask, input.lightingUV).rgb, main.a);
to this:
SurfaceData2D surfaceData;
InputData2D inputData;
surfaceData.albedo = main.rgb;
surfaceData.alpha = 1;
surfaceData.mask = mask;
inputData.uv = input.texcoord;
inputData.lightingUV = input.lightingUV;
half4 pixel = half4(CombinedShapeLightShared(surfaceData, inputData).rgb, main.a);
So I think the only difference between you guys' code above was changing "i" to "input", and changing what was "i.uv" to "input.texcoord". Was kinda guessing with the "texcoord" there, but I think its correct (referencing TEXCOORD0)

Seems to be working!

Edit: Going to link to this other post I made, in case these two things are related: Issue with URP/2D/Spine/Sprite normalmaps in Unity 2021.2
User avatar
Jamez0r
  • Posts: 321

Luke

Glad to hear things seem to be working! If you need any other help, just let us know.
Luke

Luke
  • Posts: 50

Harald

Sorry for the late reply. Thanks as always @Jamez0r for sharing your insights, and sorry for the troubles! We will have a look at both issues very soon and get back to you as soon as we have a fix to offer.
User avatar
Harald

Harri
  • Posts: 3575


Return to Unity