JuiceTin đã viết
- Our entire game is built around the new 2D pipeline and 2D lights, thus using the 2D sprite shader. Does this mean Spine is not compatible with 2D sprite shaders either? (In addition to URP)
(Note: Seems to work perfectly fine in editor)
Here I do not understand what you mean by "In addition to URP", could you please clarify? I assume you mean you are using URP with the 2D Renderer pipeline, is this correct? The line "thus using the 2D sprite shader" is also very ambiguous, could you please provide the full shader name such as Universal Render Pipeline/2D/Spine/Sprite
?
In general I did not say Spine is incompatible with anything per se, but you need to use the suitable shaders with the respective components and pipelines. Normal Unity rules apply here, the shader has to fit the application.
- HDRP is the only pipeline that is currently not supported.
- When using a
CanvasRenderer
, you need to use UI CanvasRenderer
shaders, such as Spine/SkeletonGraphic
. You can also use other CanvasRenderer
compatible shaders, but Spine/Skeleton
or Universal Render Pipeline/*
are not compatible with a CanvasRenderer
.
- When using
URP
with a 2D Renderer
(using 2D lights, etc.) then you need to use URP 2D shaders, such as Universal Render Pipeline/2D/Spine/Sprite
.
- When using
URP
with a normal (3D) renderer, then you need to use URP 3D shaders, such as Universal Render Pipeline/Spine/Sprite
.
- When not using
URP
and the component is not a SkeletonGraphic
component, use normal shaders that don't start with Universal Render Pipeline/
and are not Spine/SkeletonGraphic
shaders. So any other shader of the spine-unity unitypackage.
See these documentation sections:
spine-unity Runtime Documentation: Shaders
spine-unity Runtime Documentation: URP Shaders Extension UPM Package
You can also use non-Spine shaders, you just need to make sure to use UI CanvasRenderer
compatible shaders at a CanvasRenderer
, which is used by SkeletonGraphic
since it's a UI component. And you either (a) need to make sure that your shader handles premultiplied alpha (PMA) accordingly, or (b) not use PMA at the atlas texture and the SkeletonRenderer
or SkeletonGraphic
component.
OR is this strictly just for UI and CanvasRenderer?
What is stricly for UI and CanvasRenderer, what do you mean by "this"? In general please always be as precise as possible to save the back and forth of posting questions and answers.
- The shader is custom made with RGBA masks, etc. Using MaterialPropertyBlocks to change the data.
(Note: There are thousands of weapons/parts/etc, thus changing textures on the materials, can't use normal atlas/skin setup)
Using MaterialPropertyBlocks
is a valid approach (also documented here on the spine-unity docs pages). Note that spine-unity also offers multiple means to repack skins at runtime, just in case this is interesting for future projects.
Is it possible to somehow make my custom shader use the same properties as Spine/SkeletonGraphic so it works?
Of course that's possible, see this documentation section for additional info. When using a SkeletonGraphic
component you should however start with a UI CanvasRenderer
compatible shader.
Are you sure that you want to use SkeletonGraphic
in the first place? It all sounds a bit as if you want to use a normal non-UI component for rendering. Then you should be using the SkeletonAnimation
component instead and use e.g. a URP 2D shader and material.
(Wondering the purpose of MaterialPropertyBlock if we're forced to use spine's shaders)
I'm afraid I don't fully understand this sentence. You are not forced to use Spine shaders, you can also use other suitable shaders. Also, MaterialPropertyBlock
just overrides parameters at the Material instance at a Renderer, no matter which shader you're using.