-1
\$\begingroup\$

With the new Renderer Pipelines, the OnPostRender-callback is gone, which means GL.Lines is gone.

LineRenderer looks terrible (aliases really badly, and scales with distance from camera).

How do I draw UI lines (similar to the editor "grid", solid color, preferably with controllable width)?

\$\endgroup\$
  • 3
    \$\begingroup\$ We can't speculate about "why" the Unity development team chose to implement the rendering systems the way they did. Can we rephrase your question to "how" to achieve a specific line effect? For instance, if you want to render an anti-aliased grid like in your example, we have existing Q&A on how to solve that specific problem \$\endgroup\$ – DMGregory Dec 28 '18 at 22:29
1
\$\begingroup\$

GL.Lines are not gone, if using the Scriptable Render Pipeline you can use your GL methods in this event: RenderPipeline.beginCameraRender

void Start(){
  RenderPipeline.beginCameraRendering = OnPostProcess(yourCamera);
}

void OnPostProcess(Camera camera){
  OnLineRender(Material mat, Vector3 startPos, Vector3 endPos, Color color);
}

public void OnLineRender(Material mat, Vector3 startPos, Vector3 endPos, Color color)
{
   RenderPipeline.beginCameraRendering = OnPostProcess(yourCamera)
   GL.PushMatrix();
   GL.LoadProjectionMatrix(Camera.main.projectionMatrix);
   GL.modelview = Camera.main.worldToCameraMatrix;

   mat.SetPass(0);

   GL.Begin(GL.LINES);
   GL.Color(color);
   GL.Vertex3(startPos.x, startPos.y, startPos.z);
   GL.Vertex3(endPos.x, endPos.y, endPos.z);
   GL.End();

   GL.PopMatrix();
}
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.