Multiple discs wont draw in an Immediate Mode loop

Avatar
  • updated
  • Under Review

I'm using Shapes Immediate Mode in URP to draw polygons and draw discs on the points of those polygons. In Unity 2020.3.10 this functionality worked, but my team has updated to 2021.1.10 and now only the first point in a shape gets its disc drawn - adding any more shapes causes no discs at all to be drawn. I've tested with different color and alpha values and the result is the same.

I've also debugged out all of my data so there are multiple points there to be drawn when I'm expecting it to, so I think it's something to do with Shapes and the latest version of URP.

Also, multiple Polygon shapes are drawn flawlessly - it just seems to be these specific looped discs.

Here's the logic:

Image 441

Thanks in advance for any support, and thanks for making an amazing tool!

Reporting a bug? please specify Unity version:
2021.1.10
Reporting a bug? please specify Shapes version:
3.2.3
Reporting a bug? please specify Render Pipeline:
URP
Avatar
Freya Holmér creator
  • Under Review

sounds like it's GPU instancing or shader related!


  1. make sure your project supports GPU instancing. I think URP might have some setting that will force it off in favor of the SRP batcher
  2. you can check if it's instancing related by turning off GPU instancing in the Shapes settings window. It will very likely start working as soon as you turn it off, but, ideally it should of course be on!
  3. try doing a clean install of Shapes

let me know if it makes a difference!

Avatar
Tom Kail

We also had this problem - except with lines! It was working fine for weeks, until I noticed it wasn't - "Regenerate Shaders and Materials" in the Shapes Settings fixed it for us!

Avatar
dom

Thanks! Disabling GPU instancing on Shapes did it! however re-enabling it and disabling the SRP batcher didn't fix it. Also had no luck with regenerating the shaders/materials

Avatar
Freya Holmér creator
Quote from dom

Thanks! Disabling GPU instancing on Shapes did it! however re-enabling it and disabling the SRP batcher didn't fix it. Also had no luck with regenerating the shaders/materials

you should be able to leave it on though - did you try a clean reinstall?

Avatar
dom
Quote from Freya Holmér

you should be able to leave it on though - did you try a clean reinstall?

sorry for the late reply, but I did a clean reinstall, updated to the latest, and it didn't help this im afraid /:

Avatar
Freya Holmér creator

4.1.0 has now been submitted to the asset store - can you try it again once you see the update on your end? :)

Avatar
dom
Quote from Freya Holmér

4.1.0 has now been submitted to the asset store - can you try it again once you see the update on your end? :)

I gave it a shot and it didn't seem to fix it - if I'm the only one experiencing this after trying the above I'm wondering if it's an implementation problem? Not sure what I could've done wrong though.

Avatar
Freya Holmér creator

do you have a more minimal repro case?

Avatar
Grant Davies

Just wanted to chime in and say I'm experiencing something that sounds very similar. In immediate mode, I can draw any number of lines and a single disc, but as soon as I draw more than one disc, all discs disappear (the lines continue to render).

Disabling GPU instancing resolves the issue - all discs appear when I toggle that option off. I can toggle GPU instancing on and off and the discs will appear and disappear.

Unity 2021.2.0b2.3053
Shapes 4.1.0

Default render pipeline

I'm using this code:

Fantastic asset, thank you for making it!

Avatar
Freya Holmér creator

It might be worth deleting the shader cache in the Library/ folder, or do a full clean reinstall when this happens. some people have reported that this makes it work for them, so it's worth a try!

https://shapes.userecho.com/en/knowledge-bases/2/articles/383-when-shapes-doesnt-render-in-builds

Avatar
old fort

I am experiencing this too, and following other recommended steps (cache, install, etc.) only disabling GPU Instancing worked.

Hoping as a less costly approach to disabled GPU Instancing, a workaround I use is to draw a non-shape between any calls. I opted for Draw.Sphere(Vector3.zero, 0f, Color.clear);. Not great, but it means my immediate mode iterators using the same shape type repeatedly now works.

Avatar
Freya Holmér creator

does it work if you place a meshrenderer in the scene with the same material that you're using for the discs, and making sure instancing is enabled on that mesh?

basically to force unity to include that shader - does it make a difference?

otherwise I'm pretty much at a loss if you've tried all the steps


Avatar
old fort

I just tried with the 4 materials I can see used (Cone Lighten, Line 2D Lighten, Line 2D Lighten (CAP_SQUARE), Line 2D Lighten (CAP_ROUND)), no luck.


I will try prepare a minimum repro example to share when I get the chance off of my current project.

Thanks for your responsiveness, and this amazing asset, it is fundamental to the polished result I've been looking for.

Avatar
Freya Holmér creator
Quote from old fort

I just tried with the 4 materials I can see used (Cone Lighten, Line 2D Lighten, Line 2D Lighten (CAP_SQUARE), Line 2D Lighten (CAP_ROUND)), no luck.


I will try prepare a minimum repro example to share when I get the chance off of my current project.

Thanks for your responsiveness, and this amazing asset, it is fundamental to the polished result I've been looking for.

is your rendering just broken when using the lighten blend mode? I would try opaque and transparent as well just to make sure, which are way more common

Avatar
old fort

Testing these, Transparent produces the same problem, but I was surprised to see that Opaque causes further issues, where it isn't just calling two of the same Draw.[Shape]s subsequently that won't render, but all my immediate mode shapes aren't rendering (i.e. Line then Cone).

In the editor this is fine, but across Android and Web builds (the only two I'm tested) this is present.

I appreciate the follow up. I'll try pull back the scenario to see if it happens with a simple setup.