• RuntimesUnity
  • Unity Runtime Outline Material Turns Sprite Invisible

  • Изменено

Checking the "Outline" box for any of my skeleton materials:

Turns the sprites invisible:

Unchecking the box does turn them back to normal as expected.

I think this might be related to the fact I'm using URP 2D. I installed the com.esotericsoftware.spine.urp-shaders package via Git URL but there are no Spine shaders under Universal Render Pipeline:

I do see the Spine URP shaders in Library\PackageCache\com.esotericsoftware.spine.urp-shaders@7a5c6995ef\Shaders so it does seem like the package successfully installed, but on installing the package there's an error logged like this for 7 different shaders:

Shader error in 'Universal Render Pipeline/2D/Spine/Skeleton Lit': Couldn't open include file 'Packages/com.esotericsoftware.spine.spine-unity/Runtime/spine-unity/Shaders/CGIncludes/Spine-Common.cginc'. at Library/PackageCache/com.esotericsoftware.spine.urp-shaders@7a5c6995ef/Shaders/Include/SpineCoreShaders/Spine-Common.cginc(2)

Compiling Subshader: 0, Pass: <Unnamed Pass 0>, Fragment program with <no keywords>
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

I found this forum post where someone else described the same errors: https://zh.esotericsoftware.com/forum/d/17743-shader-error-in-universal-render-pipeline2dspinesprite

Their fix "Looks like I solved the issue by installing the runtimes via Unitypackage and by installing the URP shaders from a locally downloaded zip. i.e. I didn't use Install with GIT URL." did remove the errors for me and I can see some Spine shaders, but then the manifest.json had a hardcoded path that won't work on other computers, and also the only outline shader is called "Skeleton-OutlineOnly" and looks exactly the same as my previous screenshot where the sprite itself is transparent:

If I choose the Universal Render Pipeline > 2D > Spine > Skeleton Lit the sprite appears, but there's no Outline option in the material inspector.

For now I have copied the files from the "Shaders" folder in the URP zip directly into my project, and am just using that URP Skeleton Lit shader and will investigate other options for achieving the outline.

Related Discussions
...

Sorry to hear that you've encountered problems with UPM package installation! Please note that if you want to install the UPM package directly via the Package Manager via + Add package from git URL... then you also need the spine-csharp and spine-unity packages installed via the Package Manager, and not as unitypackage. Otherwise the include path "Packages/com.esotericsoftware.spine.spine-unity" will not be resolved.

I just noticed that the documentation pages don't state this yet, I'm sorry for the oversight! We will update the documentation accordingly to mention this requirement.

[..] but then the manifest.json had a hardcoded path that won't work on other computers

Regarding using a local UPM package: You should be able to use relative paths in your manifest.json file like this:
"com.esotericsoftware.spine.urp-shaders": "file:../Modules/com.esotericsoftware.spine.urp-shaders",
Then you can have your package located in a common directory relative to your project directory (but not inside). Other solutions are extracting the zip package into the <projectname>/Packages/ directory and letting the Package Manager automatically load it, or using a symlink which each user would need to setup accordingly however.

Regarding URP outline rendering:
In general you should not use non-URP shaders when using Universal RP as your pipeline (except for CanvasRenderer shaders). Normal multi-pass shaders will all be broken when used with Universal RP.

Please see the documentation of the URP shaders here, especially the section regarding the Universal Render Pipeline/Spine/Outline/Skeleton-OutlineOnly shader. You can check out the mentioned Outline Shaders URP example scene as a reference on outline setup using URP.