Several Draw.Line not working in ImmediateModeShapeDrawer (starting with the sample)

Avatar
  • updated
  • Unity's Fault

Hi,

First of all, great job job with this asset!
I've looked around to see if this had been asked before, but I didn't find anything, so I wonder if this is something related to my Unity version/setup or if it is a recent issue.

I started by playing around with the default shape components, and everything was going well and being nicely rendered.
Then I moved on to trying to create shapes procedurally using the ImmediateModeShapeDrawer, so I started with your doc sample:

[ExecuteAlways] public class MyScript : ImmediateModeShapeDrawer {

public override void DrawShapes( Camera cam ){

using( Draw.Command( cam ) ){

// set up static parameters. these are used for all following Draw.Line calls
Draw.LineGeometry = LineGeometry.Volumetric3D;
Draw.ThicknessSpace = ThicknessSpace.Pixels;
Draw.Thickness = 4; // 4px wide

// set static parameter to draw in the local space of this object
Draw.Matrix = transform.localToWorldMatrix;

// draw lines
Draw.Line( Vector3.zero, Vector3.right, Color.red );
Draw.Line( Vector3.zero, Vector3.up, Color.green );
Draw.Line( Vector3.zero, Vector3.forward, Color.blue );
}

}
}

But nothing would appear on the screen. After trying some of your other sample scripts, I saw that ImmediateMode was working, so I started from there. That's when I realized that the problem lied in trying to render more than one line. So, for the above example, if I comment the last two Draw Lines:

			// draw lines
Draw.Line( Vector3.zero, Vector3.right, Color.red );
//Draw.Line( Vector3.zero, Vector3.up, Color.green );
//Draw.Line( Vector3.zero, Vector3.forward, Color.blue );

It does render the red line. But once I uncomment one of the other Draw.Line calls, none of them is rendered.

Also, I'm not sure if this is related, but nothing appears on the Procedural Tree sample scene (just a complete black canvas and a grey, empty scene in the editor - the objects are there but no shapes are drawn).

Not sure if relevant, but I'm targeting Windows. But the issue occurs both on the editor, play mode and builds.

Thanks in advance,

Pedro

Reporting a bug? please specify Unity version:
2021.1.24f
Reporting a bug? please specify Shapes version:
4.4.1
Reporting a bug? please specify Render Pipeline:
Built-in render pipeline
Pinned replies
Avatar
pedro silva
  • Answer

To be honest, I don't think so. This project does have a couple of third-party assets, but mostly 3D models and scripts, nothing in particular that would mess with rendering.


At first I thought it could be related to the Unity version. So I tried the library on a different project I had on Unity 2020, and it was working correctly. So I tried moved that project to the same 2021 project and it kept working. So I excluded the Unity version as a possible reason.


Then I saw the suggestion here on the Knowledge base to do a clean reinstall.
So I first tried cleaning up the Unity Library folder, and apparently that alone was enough! The shapes are visible in ImmediateMode (even with GPU instancing).


So I guess it's solved. Let's hope it remains that way.

Thanks for the quick responses!

Avatar
Freya Holmér creator

hm, it sounds like GPU instancing is broken somehow. I presume if you disable it in the shapes settings, all three will draw? although instancing should work regardless, I don't know why it wouldn't work, especially in the editor

Avatar
pedro silva

Exactly, they do draw if I disable GPU Instancing.

Avatar
Freya Holmér creator

anything special about your Unity setup I should know?

Avatar
pedro silva
  • Answer

To be honest, I don't think so. This project does have a couple of third-party assets, but mostly 3D models and scripts, nothing in particular that would mess with rendering.


At first I thought it could be related to the Unity version. So I tried the library on a different project I had on Unity 2020, and it was working correctly. So I tried moved that project to the same 2021 project and it kept working. So I excluded the Unity version as a possible reason.


Then I saw the suggestion here on the Knowledge base to do a clean reinstall.
So I first tried cleaning up the Unity Library folder, and apparently that alone was enough! The shapes are visible in ImmediateMode (even with GPU instancing).


So I guess it's solved. Let's hope it remains that way.

Thanks for the quick responses!

Avatar
Freya Holmér creator
  • Unity's Fault

ah, glad it worked out!

Avatar
jon coughlin

I am having this exact same issue. Multiple sequential Draw.Line calls not rendering (other sequential Draw.[any other shape] calls work just fine). If I stick to drawing one line it renders but if I draw more than one in a row none of them render. I will try cleaning the Unity Library folder.

Avatar
jon coughlin
Quote from jon coughlin

I am having this exact same issue. Multiple sequential Draw.Line calls not rendering (other sequential Draw.[any other shape] calls work just fine). If I stick to drawing one line it renders but if I draw more than one in a row none of them render. I will try cleaning the Unity Library folder.

I deleted the shader cache from my library and the line drawing now works again.