pixelmeat Ah, sorry my explanation was not complete. If the texture and material settings are not set appropriately for the Straight alpha texture, the error will not be resolved. See this section of the documentation for the correct settings:
Correct Texture Packer export and Texture and Material import settings
See through effect
I haven't touched the PMA option and it was checked (Is this the default?)
Yes, the PMA option is enabled by default. This is because there are some advantages to using PMA textures.
- Using PMA textures can reduce draw calls when using the
Additive
blend mode for skeleton slots. - Better results when creating mip maps.
To understand this, watch the following video from 1:45-4:50:
Misaki
Alright! Now I have configured the color space as Gamma
and enabled PMA back. The warnings are gone and the character renders if I use the Spine/Skeleton shader.
But as soon as I change to the Universal Render Pipeline/Spine/Skeleton shader, the character disappears:
I still have the feeling that something broke in the background, as I had no issues with the Spine URP shaders before. Any ideas?
BTW, thanks so much for your help so far Misaki
- Editado
pixelmeat I haven't touched the PMA option and it was checked (Is this the default?) Now I reexported the character without the PMA option.
Note that exporting as PMA
was always wrong when using Linear
color space then. The warning however will not lead to things not rendering at all, just rendering incorrectly with outline artifacts. If you see nothing, you've likely setup anything completely wrong with your graphics settings or Material settings, or something like that.
pixelmeat I prefer not to change the color space of the project, as Linear is the default and I don't want to change values that I don't understand hehe.
If you leave settings at Linear color space, semi-transparent colors will add up differently than what you're used to in Photoshop or other image editors.
pixelmeat Here's the PNG, in case you need to check that it is NOT-PMA.
It's impossible to check this png image. An object with a black outline and bleed will look pretty much identical. If you had no black outline, then you've exported it incorrectly.
pixelmeat I still have the feeling that something broke in the background, as I had no issues with the Spine URP shaders before. Any ideas?
If you see nothing at all, you've likely messed up your material settings, or any graphics settings in the Project Settings or your Render Pipeline Asset, or with your post-processing settings, etc.
Best revert to an older state in your version control history before performing the breaking changes. If you don't use any version control software, well, we can just recommend to undo the changes that you've made, and use version control software in the future.
@pixelmeat And note that the Universal Render Pipeline/Spine/Skeleton
shader is for use with URP without a 2D Renderer, while Universal Render Pipeline/2D/Spine/Skeleton
is for URP when using a 2D Renderer.
See the documentation here:
https://esotericsoftware.com/spine-unity-rendering#URP-Shaders-Extension-Package
Harald
Wow, I really didn't see that coming, the shaders were not working because I had reverted to the 2D renderer and I was still trying to use the 3D shaders. Changed to the 2D ones and it displays right now. I'll continue from here.
Just one more question for now. Are there versions of the outline shaders for the URP/2D category?
I mean like this one:
@pixelmeat Very glad to hear you've found the issue!
pixelmeat Just one more question for now. Are there versions of the outline shaders for the URP/2D category?
It's a bit more complicated currently, unfortunately there is no single-shader version available yet. This is planned in this issue ticket:
EsotericSoftware/spine-runtimes1824
However in the meantime you can use e.g. the RenderExistingMesh
component and the Universal Render Pipeline/Spine/Outline/Skeleton-OutlineOnly
shader as described here in the documentation.
You can find an outline URP example scene Outline Shaders URP.unity
in the Samples of the Spine URP Shaders UPM package (installed via Package Manager under the Samples tab), there you can see this setup in action.
pixelmeat How can I make the outline object be mask-interactive?
By mask-interactive
, do you mean the masks in the way of Inside-Mask
Outside-Mask
options of the Mask Interaction
parameter of SkeletonAnimation
? If so, that's the Stencil Comparison
parameter (_StencilComp
in the shader and in the Material properties under debug mode). Values are as follows (as names and parameter int-values):
- None - Inside and outside (Default):
Always
,8
- Inside:
LessEqual
,4
- Outside:
Greater
,5
The integer values for each comparison operation can also be found under UnityEngine.Rendering.CompareFunction
.
I have encountered a new problem now. My prototype is using custom axis sorting, so the scene sprites sort themselves using the Y axis instead of Z. All the characters and ground obstacles are in a sorting layer called onGround
, more specifically in position 0 inside that sorting layer.
Now that the outline object is working, I need it to render in position 1, inside the onGround
layer, so the "see through" silhouette will be visible when the character is behind an obstacle.
I've tried using the SortingGroup
component, as I think this has worked for me in the past. Is that the right way to force a mesh to sort using the sprite sorting system? It is not working for me right now.
What do you think I am doing wrong?
Thanks!!
I can't delete my last post, so please ignore it. My mask was not in the wrong place. The setup is working as intended.
OK! Now I have something really similar to what I was trying to do. The problem is... I don't know why it's working! hahaha
Here's the effect in action:
The thing I'm not getting is why the shader that I use for the "silhouette" is working correctly inside the masks.
These are the shader settings:
There's no info there about Stencil Comparison
, not even if I look in debug mode. So I don't know how is it working correctly with the Sprite Mask.
Here's the rest of the components I'm using to create the silhouette, based on the same components used in the outline method:
And that would be all for now, just looking for some enlightenment about why this is working before I happily move on
Thanks!
pixelmeat There's no info there about Stencil Comparison, not even if I look in debug mode. So I don't know how is it working correctly with the Sprite Mask.
Are you sure it's not there in debug mode, named _StencilComp
? If you are switching from a previous shader, the keywords are carried over.
Your game looks so cute BTW! 8)
Oh, I think I found it! Is this the property?
I was only looking under the "valid keywords" and "invalid keywords" not under "saved properties", my bad. Too many new things ^^
I see that the value is set to 4 which is exactly what I needed for the effect, although I don't know why is it set to this value or even if it was me who set it accidentally. Could I change this value somehow if I needed it?
I have a follow up question too. Would it be possible to have a simpler version of this shader that, instead of modifying the texture color via a screen blending effect and an input color, just changed the color value of the texture to the same input color? I'm not a coder, just a tinkerer, and almost had a heart attack when I opened the shader file in Visual Studio :_(
Anyway, thanks again for your help and your compliments Harald. The game is still in pre-production and I'm the game designer, so I'm exploring the possibilities of what we can do and what we can't. I'll make sure to keep posting some showcase bits, as the Spine community is always so kind and appreciative of the works of others.
pixelmeat I was only looking under the "valid keywords" and "invalid keywords" not under "saved properties", my bad. Too many new things ^^
Keywords are for switching between shader variants (active shader branches), properties are actual value paramters.
pixelmeat Could I change this value somehow if I needed it?
Yes, you see it right in front of you. You can click on the 4
and replace it with e.g. 5
.
We have just exposed the Stencil Comparison
parameter for all URP blend modes shaders (via this commit). These were indeed hidden as they don't use the same custom shader GUI code as built-in-RP blend modes shaders which exposes these properties. Thanks for reporting.
A new Spine URP Shaders UPM package is available for download:
https://esotericsoftware.com/spine-unity-download
Harald That's great! TY
I have a follow up question too. Would it be possible to have a simpler version of this shader that, instead of modifying the texture color via a screen blending effect and an input color, just changed the color value of the texture to the same input color? I'm not a coder, just a tinkerer, and almost had a heart attack when I opened the shader file in Visual Studio :_(
Any ideas on that? What I have in mind is a simple shader that paints the character in a constant color and has the stencil interaction property.
pixelmeat Would it be possible to have a simpler version of this shader that, instead of modifying the texture color via a screen blending effect and an input color, just changed the color value of the texture to the same input color?
What do you mean by the last half of the sentence "just changed the color value of the texture to the same input color"? Do you want to output just the tint color in additive blend mode?
In general you can quite easily modify existing shaders if you just need to output a constant color. You can create a copy of the .shader
file, and rename the name in the first line of the file to your desired name to be displayed in the Materials shader property.
Then you can change the line #pragma fragment frag
which defines the following method from the included file "../../Include/Spine-Skeleton-ForwardPass-URP.hlsl"
to be used:
half4 frag(VertexOutput i) : SV_Target{
float4 texColor = tex2D(_MainTex, i.uv0);
#if defined(_ZWRITE)
clip(texColor.a * i.color.a - _Cutoff);
#endif
#if defined(_TINT_BLACK_ON)
return fragTintedColor(texColor, i.darkColor, i.color, _Color.a, _Black.a);
#else
#if defined(_STRAIGHT_ALPHA_INPUT)
texColor.rgb *= texColor.a;
#endif
return (texColor * i.color);
#endif
}
Now you can replace the used fragment program function like this in the .shader
file:
#pragma fragment yourFunction
and below the include statement add your function:
#include "../../Include/Spine-Skeleton-ForwardPass-URP.hlsl"
half4 yourFunction(VertexOutput i) : SV_Target {
float4 texColor = tex2D(_MainTex, i.uv0);
#if defined(_ZWRITE)
clip(texColor.a * i.color.a - _Cutoff);
#endif
return float4(i.color.rgb, texColor.a * i.color.a);
}
Harald What do you mean by the last half of the sentence "just changed the color value of the texture to the same input color"? Do you want to output just the tint color in additive blend mode?
I'd like the shader to output a single color from an input, without any blending, just the input color and the alpha from the character texture. And the shader should have the stencil interaction property.
I'll try to implement your suggestion and see how far my skills get me