Shapes not rendering in builds (investigation megathread)

Avatar
  • updated

sometimes Shapes doesn't render in builds, and as far as I can tell, this is caused by Unity excluding GPU instancing variants of Shapes shaders

1. Unity excluded Shapes shaders from the build (most likely cause)

Unity excludes unused shaders from builds, but can sometimes get this wrong, and this seems to affect instancing variants of shaders in particular, which often leads to Shapes working fine if you only draw one shape, but as soon as you draw multiple in a row, instancing kicks in, and the shader fails to load, and nothing is rendered. Sometimes, it can also be caused by unity messing up in-place update of assets, like when updating Shapes

Fix 1A: Go to Project Settings > Graphics > Instancing Variants, and set it to "Keep All". This might fix it on its own, and you might not need to do fix 1B

Fix 1B: Go to Project Settings > Graphics > Always included shaders, and then add the shaders you use in Shapes. You'll find the shaders Shapes uses in its folder, named after the shape type, split according to which blend mode they are using. If you're shipping to mobile, it might be good to only add the ones you actually use to reduce the build size, but if you're developing for desktop, you can probably just shove all Shapes shaders in there without any big issue

2. Unity corrupted your Shapes install (somewhat unlikely)

Unity sometimes has issues updating asset store packages in-place, leading to corrupt asset states

Fix 2: Do a clean reinstall of Shapes, and see if you still have issues. This is very important to do before reporting any bugs in general. The package manager and Unity in general often struggle to update assets cleanly, so you may have cached files in a broken state, which often leads to weird issues like this. We have multiple reports [1] [2] [3] of clean reinstalls solving this issue

3. Your platform doesn't support GPU instancing (unlikely)

You can test whether it does using SystemInfo.supportsInstancing.

Fix 3: If your platform doesn't support GPU instancing, you need to disable GPU instancing in the Shapes settings window, which means drawing multiple shapes in a row won't be able to get the performance benefits of instancing ;-;

    Still not working?

    I would start by testing a few things to investigate further:

    1. Please check for any build or runtime logs for warnings/errors related to Shapes or shaders
    2. If you are using immediate mode rendering in Shapes, try disabling immediate mode GPU instancing in the Shapes settings window, and then see if it works. If it works after this, we know that it's related to GPU instancing. If it still doesn't work, then let me know!
    3. Again, make sure all shader instancing variants of Shapes shaders are included in your graphics settings (see Fix 1B above). Unity can't predict which shaders you will use in immediate mode, and so it will sometimes strip them from builds

    other than that I'm at as much of a loss as you are - I've implemented instancing support the way one should, it works just fine on many platforms, including iOS and Android for many, so I don't know why it seems to fail in some specific cases. There might be some hidden setting somewhere that disables GPU instancing elsewhere, though that's something I wouldn't know of

    Do let me know if you find something out that might help us resolve this!

    Reported issues:

    Target platformUnity versionRender PipelineInstancing off works?
    iOS (iPhone 13 pro)2020.3.24URPyes
    Android/iOS2021.2.0 & 2020.3.5URPyes
    M1 mac mini???
    WebGL in chrome2019 & 2020Built-inyes
    WebGL 2.02019.4.12??
    WebGL 2.02019.3.0
    2020.1.3
    2020.1.11
    2020.2.13
    Built-in?
    Editor2021.2.0Built-inyes
    Editor2021.1.10URPyes

    Reporting a bug? please specify Unity version:
    Reporting a bug? please specify Shapes version:
    Reporting a bug? please specify Render Pipeline:
    Built-in render pipeline
    Avatar
    rehawk_

    Hi all,

    I have a similar issue with multiple Draw.Line not drawn. If I just draw a single line it works. 

    I did a full clean install of shapes, added all shapes shaders to the "Always Included Shaders", turned Instancing Variants to "Keep All" and Shader Precision Model to "Use full sampler precision by default...".

    Thanks!

    Target platform: WebGL 2 (Edge, Chrome, Firefox)

    Unity version: 2022.3.1

    Shapes version: 4.3.1
    Pipeline: URP

    Works with GPU instancing OFF: no

    Avatar
    Alexander Simakhin
    Quote from Freya Holmér

    I think this might actually be due to a regression. There's a potential hotfix here!
    https://shapes.userecho.com/communities/1/topics/640-getting-error-destroying-assets-is-not-permitted-to-avoid-data-loss-in-unity-6-shapes-450-in-the

    Great, it works, thanks!

    Avatar
    Freya Holmér creator
    Quote from Alexander Simakhin

    Line stops rendering in WebGL on scene reload with custom zTest

    Unity 6


    Hi all,

    I’m encountering a specific issue with Unity 6 (WebGL 2.0, URP) related to the Line component.

    Context:

    • I’m using a custom zTest in the LineRenderer’s material.

    • On the first scene load, everything renders correctly.

    • After unloading the scene and loading it again (the scene is fully destroyed and a new one is instantiated), the Line stops rendering completely.

    • The prefab is destroyed and re-instantiated, so everything is fresh.

    Important notes:

    • If I revert to line default settings, rendering works fine across reloads.

    • The issue only happens when IsInstanced == false in the line.cs

    • Other primitives (meshes, UI, etc.) render normally.

    • In the Unity Editor, the bug does not occur. This seems to be WebGL-specific.

    It feels like something related to the render state or draw call gets cached or corrupted between reloads, and there’s no mechanism that resets it when using custom zTest + non-instanced setup.

    Has anyone run into this before, or is there a known workaround?

    Is there a way to force a render pipeline reset or flush internal GL state on WebGL?

    The bug can be seen here https://broengine.org/webgl/z19/ - just finish first mission, at the second one the line dissaper

    Image 899

    Thanks in advance!


    I think this might actually be due to a regression. There's a potential hotfix here!
    https://shapes.userecho.com/communities/1/topics/640-getting-error-destroying-assets-is-not-permitted-to-avoid-data-loss-in-unity-6-shapes-450-in-the

    Avatar
    Alexander Simakhin

    Line stops rendering in WebGL on scene reload with custom zTest

    Unity 6


    Hi all,

    I’m encountering a specific issue with Unity 6 (WebGL 2.0, URP) related to the Line component.

    Context:

    • I’m using a custom zTest in the LineRenderer’s material.

    • On the first scene load, everything renders correctly.

    • After unloading the scene and loading it again (the scene is fully destroyed and a new one is instantiated), the Line stops rendering completely.

    • The prefab is destroyed and re-instantiated, so everything is fresh.

    Important notes:

    • If I revert to line default settings, rendering works fine across reloads.

    • The issue only happens when IsInstanced == false in the line.cs

    • Other primitives (meshes, UI, etc.) render normally.

    • In the Unity Editor, the bug does not occur. This seems to be WebGL-specific.

    It feels like something related to the render state or draw call gets cached or corrupted between reloads, and there’s no mechanism that resets it when using custom zTest + non-instanced setup.

    Has anyone run into this before, or is there a known workaround?

    Is there a way to force a render pipeline reset or flush internal GL state on WebGL?

    The bug can be seen here https://broengine.org/webgl/z19/ - just finish first mission, at the second one the line dissaper

    Image 899

    Thanks in advance!


    Avatar
    Freya Holmér creator
    Quote from paul m. christian

    Same issue for me on Meta Quest 3, Unity 6, URP, OpenXR, Vulkan, Single Pass Instanced \ Multi-view

    Specifically what happens is that with immediate mode, drawing a single ring makes it so nothing renders, not even my other gameObjects. All I see is passthrough layer. Switching to Disc component works a charm. I would like to get immediate mode working at some point though. I used to love working in Processing and want to have some of that spontaneity in Unity.

    I suspect special case rendering like VR likely has different render pipeline characteristics! I'd play with the second parameter of the Draw.Command() function, to see if it shows up in any of them, as well as looking at the frame debugger to see where/when/if the Shapes command buffer is rendering. it's possible it's getting sandwiched into a weird spot in certain cases

    Avatar
    paul m. christian
    Quote from Maks Michalski

    I've noticed this issue when rendering discs in immediate mode in 2021.2.9f1. None of the suggestions had helped, but strangely if i add a disc component to the scene (even disabled) all starts to work normally, which is an acceptable workaround for now. Hope that info helps.

    Same issue for me on Meta Quest 3, Unity 6, URP, OpenXR, Vulkan, Single Pass Instanced \ Multi-view

    Specifically what happens is that with immediate mode, drawing a single ring makes it so nothing renders, not even my other gameObjects. All I see is passthrough layer. Switching to Disc component works a charm. I would like to get immediate mode working at some point though. I used to love working in Processing and want to have some of that spontaneity in Unity.

    Avatar
    Harper Rhett
    Quote from Trevor G

    Here's my saga with a happy ending...(using 2021.3.6f1 (LTS) and Shapes 4.3.1).

    1.  Everything worked in the Editor with GPU Instancing On (except Draw.Texture, single Texture would render, but if I called Draw.Texture twice, nothing would render)

    2. On Build, about half the Draw Commands worked (with and without GPU Instancing).  

    3. I deleted my ShaderCache and PlayerCache folders from Library as suggested in an earlier post.

    4. Now the Editor looked like how previous builds did (about half the lines being rendered).  However, with GPU instancing OFF, everything worked in the Editor AND Build (good enough).

    5.  I tried to do a clean install, but deleting the Library folder caused lots of problems in my project (elsewhere), so I backed off that.

    6.  I was randomly trying some things...In the Settings, I changed the "Local AA Quality" from HIGH to MEDIUM.  Now, everything renders correctly in Editor/Build with or without GPU Instancing.  YAY!

    7.  I also had an issue rendering textures...feeling lucky, I changed the "Quad Interpolation Quality" from MEDIUM to LOW and this fixed my Texture issue as well (In Editor And Build with and without GPU instancing. Double YAY!

    Hopefully there's something helpful in that chaos.

    After hours of troubleshooting, #3 worked for me! Try deleting your "ShaderCache" and "BuildPlayerData" folders!

    It's worth acknowledging I also have "Instancing Variants" set to "Keep All" and the shaders I was using added under "Always Included Shaders."

    Performance is so smooth now I could cry.

    (Building to Meta Quest 2 from Unity 2022.3.27)

    Avatar
    ando

    Hello everyone, I've bumped into the same issue. Unfortunately I am using v4.1.3 (can't update because I lost access to the plugin in the Asset Store and Support is taking months to figure it out). Anyways, I've had issues with the rectangle using (border rounded corners) and the ring. The shapes wont render on an old iphone 6/7. Tried all the suggestion. Nothing worked.

    Eventually, I made a GameObject that had some odd scale x/y/z - 100/100/100. Obviously the sizes in Shapes had to compensate for that so I made them < 1 in radius and thickness. This fixed the issue and now I can see the disc.


    Hope this helps others.


    Freya, Shapes is great! Thank you for making it. I hope you find what's causing the rendering bug.

    Avatar
    Tiger Tang

    My immediate mode drawn shapes are randomly disappearing. I can confirm turning off GPU instancing works. I also set shader stripping to Keep All, but turning off GPU instancing is the one that did it. This is on a Meta Quest 3.

    Avatar
    patrick cheng
    Quote from patrick cheng

    Hi, I'm having issues for shapes or lines to render in the editor in general.

    I'm on Unity 2022.3.39f1, using URP and having Android as the targeted platform.

    I wanted to experiment with Shape so I created a polygon and a line in the scene, but neither of them will show up.

    Image 862

    I get a warning in the inspector saying that "Note: this object is not GPU instanced due to custom depth/mask settings". So I hit reset, click on another game object, and click back on the object I just reset, and the warning is there again.

    Image 863

    The option of "Regenerate Shader & Material" did help for a second, when I clicked on this the shape will show up for a while, but then will disappear again eventually.

    Image 864

    Image 865


    One thing I did noticed is that whenever the shape is showing/rendering, the changelog in git shows that the _ColorMask in PolygonTransparent.mat gets set to 15 instead of -1. When the shape is not rendering this changelog goes away, so something is hard resetting this..?

    Adding an update to this issue, as it is now resolved.

    Apparently I had the Unity editor debug panel open, and it somehow might have conflict with the custom editor of Shape components, thus not being able to render any shapes for me.

    By simply closing the menu fixed the issue for me, just wanted to post this for future awareness. 

    Shapes and Unity editor debug menu can't be opened at the same time.

    Avatar
    patrick cheng
    Quote from Freya Holmér

    that's, bizarre, 15 should be the default value, -1 is an invalid value


    are there any warnings in the console that says something about the shader that material is using?

    Unfortunately no, there is no warning nor errors popping up. 

    Avatar
    Freya Holmér creator
    Quote from patrick cheng

    Hi, I'm having issues for shapes or lines to render in the editor in general.

    I'm on Unity 2022.3.39f1, using URP and having Android as the targeted platform.

    I wanted to experiment with Shape so I created a polygon and a line in the scene, but neither of them will show up.

    Image 862

    I get a warning in the inspector saying that "Note: this object is not GPU instanced due to custom depth/mask settings". So I hit reset, click on another game object, and click back on the object I just reset, and the warning is there again.

    Image 863

    The option of "Regenerate Shader & Material" did help for a second, when I clicked on this the shape will show up for a while, but then will disappear again eventually.

    Image 864

    Image 865


    One thing I did noticed is that whenever the shape is showing/rendering, the changelog in git shows that the _ColorMask in PolygonTransparent.mat gets set to 15 instead of -1. When the shape is not rendering this changelog goes away, so something is hard resetting this..?

    that's, bizarre, 15 should be the default value, -1 is an invalid value


    are there any warnings in the console that says something about the shader that material is using?

    Avatar
    patrick cheng

    Hi, I'm having issues for shapes or lines to render in the editor in general.

    I'm on Unity 2022.3.39f1, using URP and having Android as the targeted platform.

    I wanted to experiment with Shape so I created a polygon and a line in the scene, but neither of them will show up.

    Image 862

    I get a warning in the inspector saying that "Note: this object is not GPU instanced due to custom depth/mask settings". So I hit reset, click on another game object, and click back on the object I just reset, and the warning is there again.

    Image 863

    The option of "Regenerate Shader & Material" did help for a second, when I clicked on this the shape will show up for a while, but then will disappear again eventually.

    Image 864

    Image 865


    One thing I did noticed is that whenever the shape is showing/rendering, the changelog in git shows that the _ColorMask in PolygonTransparent.mat gets set to 15 instead of -1. When the shape is not rendering this changelog goes away, so something is hard resetting this..?

    Avatar
    Freya Holmér creator
    Quote from oliver andreas thunæs

    No relevant warnings/errors. Adding a dummy mesh didn't have an effect.

    hm, at that point I'd report a bug to unity!

    Avatar
    oliver andreas thunæs
    Quote from Freya Holmér

    any relevant errors/warnings on build or at runtime? also, what happens if you include a dummy mesh renderer in the main scene, that uses the instanced variant of the line shaders you're using?

    No relevant warnings/errors. Adding a dummy mesh didn't have an effect.

    Avatar
    Freya Holmér creator
    Quote from oliver andreas thunæs

    Adding to this.

    Target platform: iOS 18 iPhone 15 Pro

    Unity version: 6000.0.23f1 (although this also happened in Unity 2022)

    Shapes version: 4.4.0 (this also happened in 4.3.*)

    Works with GPU instancing OFF: yes.

    And it's only affecting a specific line renderer.

    My project is setup in such a way that I'm pretty much only using immediate mode. Everything is rendered from a central script which calls render methods on a list of objects that each handle their own rendering.


    Anything that's using Draw.Line() does not show up in a build if GPU instancing is enabled. Everything else renders correctly.

    I've tried to include the shaders for 2D and 3D lines, as well as setting instancing variants to Keep All. I've done a complete re-install of shapes as per the instructions from that post on this forum.

    any relevant errors/warnings on build or at runtime? also, what happens if you include a dummy mesh renderer in the main scene, that uses the instanced variant of the line shaders you're using?

    Avatar
    oliver andreas thunæs

    Adding to this.

    Target platform: iOS 18 iPhone 15 Pro

    Unity version: 6000.0.23f1 (although this also happened in Unity 2022)

    Shapes version: 4.4.0 (this also happened in 4.3.*)

    Works with GPU instancing OFF: yes.

    And it's only affecting a specific line renderer.

    My project is setup in such a way that I'm pretty much only using immediate mode. Everything is rendered from a central script which calls render methods on a list of objects that each handle their own rendering.


    Anything that's using Draw.Line() does not show up in a build if GPU instancing is enabled. Everything else renders correctly.

    I've tried to include the shaders for 2D and 3D lines, as well as setting instancing variants to Keep All. I've done a complete re-install of shapes as per the instructions from that post on this forum.

    Avatar
    Andy

    FYI Volumetric3D lines were not drawing for me in WebGL, had to turn off GPU Instancing. 

    (Unity 2022 LTS URP, Windows11, Edge, Nvidia beast etc!)

    Perhaps could be automatic if determined to be incompatible with WebGL? But seems that may not be clear...

    Avatar
    Freya Holmér creator
    Quote from Anne

    I'm encountering issues on specific devices like the iPad Pro (10.5) and some Android models.

    None of the previously mentioned solutions have resolved the problem. Through investigation, I've discovered that:

    When shapes are children of a Canvas set to "Canvas - Camera Space," only rectangles render correctly in the build. However, if the shapes are not children of the canvas, they render correctly.

    Everything functions properly in Unity version 2021.3.16f1, but I haven't managed to get it to work in newer versions. Additionally, it works as expected on all other devices I have tested and within the Editor across all Unity versions I've tested so far. This issue was tested with an empty project.

    Any clues on what could be the cause? I'd hate to remove Shapes just because a few models are experiencing issues.

    I've updated the first post/OP with some more steps! Specifically I would recommend trying the 1A and 1B fixes!

    Avatar
    Anne

    I'm encountering issues on specific devices like the iPad Pro (10.5) and some Android models.

    None of the previously mentioned solutions have resolved the problem. Through investigation, I've discovered that:

    When shapes are children of a Canvas set to "Canvas - Camera Space," only rectangles render correctly in the build. However, if the shapes are not children of the canvas, they render correctly.

    Everything functions properly in Unity version 2021.3.16f1, but I haven't managed to get it to work in newer versions. Additionally, it works as expected on all other devices I have tested and within the Editor across all Unity versions I've tested so far. This issue was tested with an empty project.

    Any clues on what could be the cause? I'd hate to remove Shapes just because a few models are experiencing issues.

    Avatar
    Jim Chan

    I have problem with running example "FPS HUD" and "IMCanvas" on device.And finally found the following steps work for me:

    1. On Project Settings -> Graphics -> Shader Stripping -> Instancing Variants, set to "Keep all".

    2. On Shape Settings -> Shader Settings -> Quad interpolation quality, set to "Low". (Thanks to Edvard Rutström for the suggestion)

    3. Click "Apply shader settings" button.

    4. Click "Regenerate Shaders & Materials" button.

    Environment:

    Unity: 2022.3.24 Shapes version 4.3.1

    Render pipeline: URP 14.0.10

    Device: Google Pixel 6 (Android)

    Avatar
    edvard rutström

    Sergeys comment seems to have fixed the issue. Seems like we were stripping instancing variants, which made Shapes not work in builds (duh). Thanks for the help Sergey! 

    Avatar
    Sergey Khanin

    Unity 2022.3.19f1

    Its works for me:
    Project settings -> Graphics -> Instancing Variants - Keep All 

    Image 822



    GraphicsSettings.asset

      m_InstancingStripping: 2
    Avatar
    edvard rutström
    Quote from Trevor G

    Here's my saga with a happy ending...(using 2021.3.6f1 (LTS) and Shapes 4.3.1).

    1.  Everything worked in the Editor with GPU Instancing On (except Draw.Texture, single Texture would render, but if I called Draw.Texture twice, nothing would render)

    2. On Build, about half the Draw Commands worked (with and without GPU Instancing).  

    3. I deleted my ShaderCache and PlayerCache folders from Library as suggested in an earlier post.

    4. Now the Editor looked like how previous builds did (about half the lines being rendered).  However, with GPU instancing OFF, everything worked in the Editor AND Build (good enough).

    5.  I tried to do a clean install, but deleting the Library folder caused lots of problems in my project (elsewhere), so I backed off that.

    6.  I was randomly trying some things...In the Settings, I changed the "Local AA Quality" from HIGH to MEDIUM.  Now, everything renders correctly in Editor/Build with or without GPU Instancing.  YAY!

    7.  I also had an issue rendering textures...feeling lucky, I changed the "Quad Interpolation Quality" from MEDIUM to LOW and this fixed my Texture issue as well (In Editor And Build with and without GPU instancing. Double YAY!

    Hopefully there's something helpful in that chaos.

    I can confirm that 6. above helped us with the GPU instancing issue. GPU instancing is working properly in the rest of the game, so this might be a lead?

    Best of luck, and thanks for a really great plugin!

    Edit: this actually didn't seem to fix all the issues, but Sergeys comment below helped!

    Avatar
    Trevor G

    Here's my saga with a happy ending...(using 2021.3.6f1 (LTS) and Shapes 4.3.1).

    1.  Everything worked in the Editor with GPU Instancing On (except Draw.Texture, single Texture would render, but if I called Draw.Texture twice, nothing would render)

    2. On Build, about half the Draw Commands worked (with and without GPU Instancing).  

    3. I deleted my ShaderCache and PlayerCache folders from Library as suggested in an earlier post.

    4. Now the Editor looked like how previous builds did (about half the lines being rendered).  However, with GPU instancing OFF, everything worked in the Editor AND Build (good enough).

    5.  I tried to do a clean install, but deleting the Library folder caused lots of problems in my project (elsewhere), so I backed off that.

    6.  I was randomly trying some things...In the Settings, I changed the "Local AA Quality" from HIGH to MEDIUM.  Now, everything renders correctly in Editor/Build with or without GPU Instancing.  YAY!

    7.  I also had an issue rendering textures...feeling lucky, I changed the "Quad Interpolation Quality" from MEDIUM to LOW and this fixed my Texture issue as well (In Editor And Build with and without GPU instancing. Double YAY!

    Hopefully there's something helpful in that chaos.

    Avatar
    peter roth

    The clean install worked for me. WebGL Build.
    -Flat
    2DLines were not working unless GPU instancing was turned off. --> After a clean install, they do!

    -I did a clean install according to the instructions (more than just deleting and reinstalling the shapes package must delete Library to force a reimport...see Freya's instructions: 

    Avatar
    Clee

    I was also experiencing the same issue with Unity 2022.3 when building for Android, with both URP and Built-in.

    The solution mentioned in the previous reply did work for me. The GameObjects with the Shapes materials can even be in a scene that is never actually loaded, it just needs to be included in the build.

    Alternatively, putting all the generated materials in a 'Resources' folder did also work for me, as it should have the same effect of forcing the materials to be included in the build.

    Either way, the most important thing I have found is that after changing this, it is important to trigger a recompile of all the shaders or nothing changes in the build for some reason. In theory this should work by making a "Clean Build", but at least for me this did not change anything when using "Build & Run" afterwards to install the game on an Android phone.

    What did work in the end was deleting the "ShaderCache" and "PlayerDataCache" folders inside the "Library" folder. (Only deleting ShaderCache also did not consistently trigger a recompile)

    Avatar
    D. Park

    Without the shader variants stripping, my project build takes too long. To go around this issue while keeping 'Strip Unused' options ON, I tried to identify the specific type of immediate draw and made dummy GameObjects, and applied the relevant materials for them. Those immediate draw types(for me, spheres) finally showed up in the build and I kept the 'Strip Unused' Option ON, so build time is intact.

    Image 711

    Avatar
    Anthony Massingham

    I was experiencing the same issue when deploying to Android (Pixel 3a and Galaxy Tab S8+) in 2022.2.13.

    Changing the instancing variants option from 'Strip Unused' to 'Keep All' resolves the issue.

    Image 710

    Avatar
    Hamster On Coke

    Update:

    - All devices that uses PowerVR GE8320 GPU seems affected. It's actually quite popular budget GPU used in a lot of samsung devices.
    - That GPU is known for having issues with shader compilation.
    - Unity is working on providing bugfixes to other GE8320 related errors.
    - For the shapes part, this is where it gets interesting:
    I've narrowed down the issue, and the shader compilation error only happens when MSAA is turned on. As soon as I switch it off, all Opaque shaders starts to render again.

    SOLUTION: Turn off MSAA if you detect PowerVR GE8320.