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
    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.

    Avatar
    Hamster On Coke

    Hey,

    I'm having issues using normal Component Shapes (not immediate draw mode) on Samsung Galaxy A12 device.

    Using URP.

    Shapes component that use transparent shaders are drawn correctly, however Opaque components are not drawn.

    The logcat outputs shows  fragment shader link errors:

    Image 703

     The device specs:

    Image 704

    Clean installation of Shapes doesn't help. 
    Rebuilding shaders and materials doesn't help.

    Any clues on how to debug this?

    Thanks,

    Cheers

    Mike

    Avatar
    Olle Landin

    Unity: 2021.3k.21

    Device: Pixel 3 - Android 12

    URP 12.1.10

    Shapes 4.2.1


    I have had a lot of trouble getting my 3d lines to show in IM-mode on my android. The only thing that works is to turn off GPU Instancing. On my Pixel 3 i got SystemInfo.supportsInstancing == true, so it should work?

    I also tried this approach

    https://shapes.userecho.com/communities/1/topics/385-shapes-not-rendering-in-builds-investigation-megathread?redirect_to_reply=1217#comment-1217.


    ...but that caused even bigger issues. With the shaders built for the built in RP, IM-mode did not even work in the editor (Mac M1). 


    I also tried Edit-->Project Settings->Graphics-->Instancing Variants: Keep All, but that made no difference. 

    Is there any other way to ask the device if GPU instancing is supported? Seems like a huge waste being forced to keep it off.

    Avatar
    Gavin Rossiter

    I had this issue too.
    Immediate mode lines were not rendering in builds only (other non-line shapes e.g. ring/disc worked) .
    Unity 2022.2.0f1, HDRP 14.0.4, Shapes 4.2.1.
    Shapes was compiled for HDRP with GPU Instancing on. 
    I turned off GPU Instancing and then immediate mode line rendering worked in one scene, but not in another, very odd.

    I did a clean install of Shapes, which compiled it for Built-In and now everything works, even with GPU Instancing.  It's strange that the Built-In shaders work in HDRP but I'm not looking a gift horse in the mouth.
    So I guess this fix mentioned earlier in the thread works in HDRP too https://shapes.userecho.com/communities/1/topics/385-shapes-not-rendering-in-builds-investigation-megathread?redirect_to_reply=1217#comment-1217.
    Perhaps the issue lies somewhere in the compilation process from Built-In to a scriptable render pipeline.

    Avatar
    John Murphy
    Quote from Freya Holmér

    are you using the latest version? a clean reinstall should really fix this, unless you have some custom shader stripping that removes Shapes shader

    Not sure if I'm late to the party and missing something. I've been using Unity 2021.3.15f1 and URP on Windows 11 Desktop. Ran into Shapes not working in build on a project using a HUD for an XR project, (Works in editor but elements missing in build) so I decided to see if the same symptoms showed up in the sample project, and sure-enough it also works in the editor but not the build. Tried turning off GPU instancing but it was worse. A full re-install of Shapes made no difference.
    Tried same version of unity with URP on Windows 10 Laptop same result so at least it is readily reproducible.

    Image 660

    Avatar
    yinon oshrat

    I did reimport the plugin as you suggested and it solved the problem for me.
    Will it help you to get my git diff between the version before the reimport and after it? 

    Avatar
    Freya Holmér creator

    Unity does strip shaders, but later versions of Shapes *should* force include shaders regardless. but it's possible it's broken, or it's broken on Unity's end. At this point I truly don't know why it wouldn't work I'm afraid

    Avatar
    rswa

    is there any code strip when build optimize?

    It's normal in unity editor(2021.3.12), but got the issue in unity player (release and development  build).

    I already clean reinstalled shapes and use Built-in RP

    my pc is window 10 pro

    I tested GPU Instancing off in the setting of shapes. all my rectangles gone in unity player omg (editor working but low fps)

    I think this is not GPU instancing issue..