Hey people,
I’m having issues with rendering animated sprites. When the sprites are loaded in the scene (delivered from an asset bundle) console is throwing out warnings like this:
"[sprite_name_heree] is using a shader without GPU deformation support. Switching the renderer over to CPU deformation."
The sprites use 2d bone animation (all done using the built-in system) and they have a custom shader assigned. The shader allows me to use a mask so that I can recolour a part of the image.
When I instantiate the sprites in the project used to build the asset bundles, it all works fine without console warnings. Warnings only appear when loaded from the bundles in the main project, for each sprite in a given prefab. The shader is specifically included in the exported bundle. I’ve also enabled GPU skinning in Project Settings/Player and I’m using the most up-to-date 2d animation package for U2023.2
Does anyone have any idea why this is happening? Is this a shader issue, asset bundle issue or something else entirely? I’d appreciate your help!
2 Likes
Same Here. Did you find the reason?
Unfortunately no, upgrading to a newer Unity release also did not help.
Please note that GPU Sprite deformation support is currently supported in the default shaders (Sprite-Lit-Default and Sprite-Unlit-Default).
To add support for custom shaders, please check the following macro in the shader:
UNITY_SKINNED_VERTEX_COMPUTE(v);
implemented in com.unity.render-pipelines.universal\Shaders\2D\Include\Core2D.hlsl
Add a multi_compile flag to the custom shader.
#pragma multi_compile _ SKINNED_SPRITE
We are currently working on adding support in ShaderGraph for custom shaders through adding a new node. Will post an update once its available.
2 Likes
Warnings disappeared after adding the flag. Thank you! 
Hey how did you add this to your shader graph? I’m new to keywords and HLSL. Adding the SKINNED_SPRITE as a bool keyword seems to have disabled any deformation, whether set to true or false.
I’ve opened the shader code and added “#pragma multi_compile _ SKINNED_SPRITE” up where all the other pragmas sit, saved and exported the bundles. Checked in the main project and no warnings appeared.
HOWEVER, and I’m questioning my sanity here, two days later I opened the shader code again and the change wasn’t there. So what I think has happened, after saving and coming back to Unity, my change has been overwritten, but if that’s what happened, I still don’t know what caused the warnings to go away.
UPDATE - just as ended writing this post, I asked our coder and turns out he got annoyed by the warning and suppressed it, that’s why I didn’t see it.
Maybe saving the shader code with the flag added as a new file would help but I’m yet to try that.
1 Like
Ah haha righto. Well I checked another forum with Venkify explaining that ShaderGraph support is on its way: Using ShaderGraph to Sprite Renderer Throws [GPU deformation support] Error at Unity6 - #5 by enosh15
As mentioned above, we are working on ShaderGraph support for Sprite GPU Skinning and will be posting an update soon. Until then, please
- Add the suggestion above to make Shaders compatible for Sprite GPU Skinning.
- Disable GPU Skinning in Player Settings (Player → Other Settings → Rendering → GPU Skinning → CPU). This will fallback to CPU skinning / Dynamic Batching.
Here is a simple sample for option 1 (check comments with Sprite GPU Skinning):
Shader "Sprites/GPUAnimate"
{
Properties
{
_MainTex ("Sprite Texture", 2D) = "white" {}
[HideInInspector] _Color ("Tint", Color) = (1,1,1,1)
}
SubShader
{
Tags {"Queue" = "Transparent" "RenderType" = "Transparent" "RenderPipeline" = "UniversalPipeline" }
Pass
{
Cull Off
Blend SrcAlpha OneMinusSrcAlpha, One OneMinusSrcAlpha
ZWrite Off
HLSLPROGRAM
// Sprite GPU Skinning : The following includes define the macros explained below.
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/Core2D.hlsl"
#pragma vertex SpriteVertex
#pragma fragment SpriteFragment
// Sprite GPU Skinning : Keyword to indicate shader supports GPU Sprite Skinning.
#pragma multi_compile _ SKINNED_SPRITE
TEXTURE2D(_MainTex);
SAMPLER(sampler_MainTex);
struct Attributes
{
float3 positionOS : POSITION;
float4 color : COLOR;
float2 uv : TEXCOORD0;
// Sprite GPU Skinning : Add UNITY_SKINNED_VERTEX_INPUTS macro to include Blend Indices and Blend Weights Channel to Vertex Inputs.
UNITY_SKINNED_VERTEX_INPUTS
};
struct Varyings
{
float4 positionCS : SV_POSITION;
half4 color : COLOR;
float2 uv : TEXCOORD0;
};
CBUFFER_START(UnityPerMaterial)
half4 _Color;
CBUFFER_END
Varyings SpriteVertex (Attributes a)
{
Varyings o = (Varyings)0;
// Sprite GPU Skinning : Add UNITY_SKINNED_VERTEX_COMPUTE macro to compute Skinning.
UNITY_SKINNED_VERTEX_COMPUTE(a);
o.positionCS = TransformObjectToHClip(a.positionOS);
o.uv = a.uv;
o.color = a.color * _Color * unity_SpriteColor;
return o;
}
half4 SpriteFragment(Varyings i) : SV_Target
{
float4 color = i.color * SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv);
return color;
}
ENDHLSL
}
}
Fallback "Sprites/Diffuse"
}```
2 Likes