GL.LINES and GL functionality with URP

I’m hoping to use some of the GL.*() class of functions, in particular rendering with GL.LINES. However, I tried upgrading my project to the LWRP, and those functions no longer seem to work/render.

Is that in the roadmap for LWRP (or any of the custom render pipelines), is there a workaround for using GL.LINES currently, or is that something that I’d have to create custom on top of the LWRP?

Actually I imagine it’s something related to this issue , which I’d posted earlier, or will have a similar response.

How are you drawing the GL.LINES?

Previously, I was rending the lines in OnPostRender(), on the main camera:

void OnPostRender() {
    GL.PushMatrix();
    lineMaterial.SetPass(0);
    GL.Begin(GL.LINES);
    foreach(var l in linesList) {
        GL.Vertex3(l.p0.x, l.p0.y, l.p0.z);
        GL.Vertex3(l.p1.x, l.p1.y, l.p1.z);
    }
    GL.End();
    GL.PopMatrix();

    return;
}

I’ve since migrated rendering to the objects themselves, using OnRenderObject():

public void OnRenderObject() {
    GL.PushMatrix();
    lineMaterial.SetPass(0);
    GL.Begin(GL.LINES);
    foreach (var l in linesList) {
        GL.Vertex3(l.p0.x, l.p0.y, l.p0.z);
        GL.Vertex3(l.p1.x, l.p1.y, l.p1.z);
    }
    GL.End();
    GL.PopMatrix();
    return;
}

In both cases, the lines render properly in the legacy rendering system, but they don’t render at all with the LWRP.

I have the same issue with GL.LINE_STRIP, worked with normal post processing, LW only displays the lines in scene view not game view. Same installs as nickfourtimes. I’ve tried 2018.3.3f1 and the latest beta 2019.1.0b1.

Could you guys open a bug report for this? We’ll take a look at it.

Sent.

1 Like

Shall I provide the same or is there/will there be an open issue # to contribute to?

I recommend you send yours in. We can compare answers :smile:

1 Like

Alrighty, I’ve submitted a bug along with a repro project; I can provide a case ID if that would help.

2 Likes

Looks like they’ve been able to reproduce the problem and have sent it along for investigation.

1 Like

Are you winning? Doesn’t look good my end, I’m told that GL is going to be deprecated in LWRP :confused: Which pushes me back to the normal post processing.

I haven’t heard back from them at all, but this was pretty much what I was expecting. Luckily using LWRP isn’t a dealbreaker for me, and I can run fine with legacy rendering, but I was hoping to use LWRP to future-proof the project at least a little bit.

Hopefully folks will come up with a custom RP in the future that supports GL commands, but that’s way outside my wheelhouse.

It’s not the same but worth looking at if you haven’t already…

http://www.everyday3d.com/blog/index.php/2010/03/15/3-ways-to-draw-3d-lines-in-unity3d/

scene: linesGR

4184692--370234--Capture.PNG

Hi, regarding the two issues:

  1. Debug.DrawLines work as expected. However the rendering callbacks are deprecated in SRP. We are adding atm a callback to render after camera is finished.
  2. GL.* API can be replaced with CommandBuffer.DrawMesh and CommandBuffer.DrawProcedural Unity - Scripting API: CommandBuffer
1 Like

Ok well thanks for everything phil. For the time being I’m going back to the regular v2 PostProcessing. When I have the time I’ll likely implement the drawmesh for LW. :slight_smile:

~ update ~

I’ve migrated along to Unity 2019.3.0b6, and it seems like the GL.Lines are working!

1 Like

I’ve the same problem. When using LWRP OnRenderObject / OnPostRender is not called in game. My unity’s edition is 2019.3.2f1,

what should i set up ?

Hm. I’m essentially calling this code in 2019.3.1f1:

    void OnRenderObject() {
        myMaterial.SetPass(0);
        GL.Begin(GL.LINES);
        {
            GL.Vertex(from);
            GL.Vertex(to);
        }
        GL.End();

        return;
    }

…and it’s working just fine. I’m using URP since the upgrade/rename, rather than LWRP, not sure if that changes anything.