2d sprites throwing GPU deformation support warnings

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!

3 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! :slight_smile:

1 Like

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.

2 Likes

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

  1. Add the suggestion above to make Shaders compatible for Sprite GPU Skinning.
  2. 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

I do not understand how to make the changes with #pragma multi_compile _ SKINNED_SPRITE in the shadergraph generated shader. Everytime I add it and save it gets removed and the warnings still pops.

Alternatively is there some progress on adding it’s inclusing in shadergraph?

Sprite GPU Skinning support for ShaderGraph was added in 17.3.0

Please find more info here:

Thanks. Please let us know if you need more info.

2 Likes

Thanks for the help.
However I do not see a sprite skinning node ( I have GPU skinning in settings enabled and SRP in pipeline asset), only linear blending skinning. I am using URP.

edit: oh my version of the shader graph is 17.0.3, I dont see a more recent one

Kindly note that this feature landed in Unity 6000.2.0a2.
Hence URP versions 17.2 and above have support for Sprite GPU Skinning.

1 Like

Ohhh I see, guess I’ll have to upgrade at some point.
Thanks!

I added the Sprite Skinning node to the Shader Graph, but the same error message is still displayed.

[Worker0] (spriteName) is using a shader without GPU deformation support. Switching the renderer over to CPU deformation.
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

Also, when I move the sprite skin’s bone, the image gets distorted, but the normal map doesn’t.

SRP Batcher is enabled.

The following will disable SRP-Batcher/GPU-Skinning even if Shader has SkinningNode enabled:

  1. Use of TexelSize/Offset. Please toggle them off.
  2. Use of MaterialPropertyBlock in user script.
  3. Use of SpriteMask. Turn off.

Could you please let us know if this fixes the issue?

I followed your instructions, but the same error still occurs.

I created a new, very simple shader to test it, but the result was the same.

What version of Unity do you use?
Also can you post the simple repro here? It will help us analyze the issue better.

Unity Version is 6.2 (6000.2.0f1)
and URP version is 17.2.0

The error continues to occur.

When SRP batcher is enabled:

  • Error message is displayed (“~without GPU deformation support”)
  • Normal maps are not applied to sprite skins and move separately

Would you like to get the shader graph and sprite by email? (I do not want it to be made public.) Or could you please provide a little more detail about what kind of reproduction you would like to upload?

Just did a quick test on 6000.2.1f1 with a similar setup. Could you please verify whether all 3 Texture2D properties have TexelSize and Offset disabled. (Please see the attached screenshot).

If the issue persists, please submit a minimal repro project as per instructions below:

https://support.unity.com/hc/en-us/articles/206336985-How-do-I-submit-a-bug-report