Immediate mode Draw.Ring creating a duplicate Draw Mesh

Avatar
  • updated

For some reason, my Draw.Ring immediate mode call seems to be getting duplicated.

My draw call is as simple as the following

public override void DrawShapes(Camera camera)
{
if (camera != Camera.main)
{
return;
}

using(Draw.Command(camera,CameraEvent.BeforeForwardAlpha))
{
Draw.Ring(transform.position,Quaternion.Euler(-90,0,0),10f,1f,new Color(1,1,1,0.3f));
}
}

And for some reason I get the following results using frame debugger.

Image 560

These duplicate meshes appear to occurring regardless of the shapes I am drawing, so I'm thinking it might just be something I'm doing wrong here.

Reporting a bug? please specify Unity version:
2018.4.30f1
Reporting a bug? please specify Shapes version:
4.1.3
Reporting a bug? please specify Render Pipeline:
Built-in render pipeline
Avatar
Maks Michalski
Quote from Freya Holmér

as long as it doesn't adversely affect the rest of the project then URP is likely more stable!

(long story short, URP has a more sophisticated system for command buffer callbacks and injection points, whereas in BIRP I've had to work around the lack of callbacks with lots of guesswork, that likely is causing this issue in BIRP)

though be sure to back it up, there's still a small chance it's unrelated to BIRP and happens in URP too!

Got a repository, so no worries about backup there!
I'll test it out in URP and come back with the results, then.

EDIT: Switching to URP fixed the issue for me.

Avatar
Freya Holmér creator

as long as it doesn't adversely affect the rest of the project then URP is likely more stable!

(long story short, URP has a more sophisticated system for command buffer callbacks and injection points, whereas in BIRP I've had to work around the lack of callbacks with lots of guesswork, that likely is causing this issue in BIRP)

though be sure to back it up, there's still a small chance it's unrelated to BIRP and happens in URP too!

Avatar
Maks Michalski
Quote from Freya Holmér

my cursory investigation is, not looking good, I'm not sure if I'll be able to fix this anytime soon as I'm currently busy with another project :(

it seems to be related to pretty cursed timing related stuff in the built-in timeline, it's possible I might be able to fix it, but it's also possible it's a unity bug

Ah, i see. In that case, should switching to URP fix the issue? My project is based entierly on immediate drawing, so that should be an easy workaround for now.

Avatar
Freya Holmér creator

my cursory investigation is, not looking good, I'm not sure if I'll be able to fix this anytime soon as I'm currently busy with another project :(

it seems to be related to pretty cursed timing related stuff in the built-in timeline, it's possible I might be able to fix it, but it's also possible it's a unity bug

Avatar
Maks Michalski

I too am noticing this issue, and can confirm that all events prior to BeforeImageEffects are rendered twice. Are there any updates on this?

Avatar
Thomas Brown

Glad to hear it wasn't just my lack of rendering experience that was the issue haha.


But yup, I did some additional investigation yesterday and I put together a small repro project (this time with Unity 2020) and was experiencing exactly the same behavior. 

Let me know if I can help further in any way 👍.

Avatar
Freya Holmér creator

in testing now, it seems like all events prior to CameraEvent.BeforeImageEffects have this behavior, which is a bug, so you're not doing anything wrong!

Avatar
Thomas Brown

Just a quick follow, this seems to be happening whenever I pass a camera event in to Draw.Command