LineRenderer2D: GPU pixel-perfect 2D line renderer for Unity URP (2D Renderer)

LineRenderer2D: GPU pixel-perfect 2D line renderer for Unity URP (2D Renderer)

Code repository: GitHub - QThund/LineRenderer2D: Scripts for rendering pixel-perfect GPU-calculated lines in 2D (Unity URP 2D Renderer).
More on Twitter: @SiliconHeartDev
Other code I shared:
Script for generating ShadowCaster2Ds for Tilemaps
Delaunay Triangulation with constrained edges

Technical details in this thread: LineRenderer2D: GPU pixel-perfect 2D line renderer for Unity URP (2D Renderer)

1 Like

New commit:
Fixed: The multi line was not working properly with OpenGL due to wrong texture sampler configuration.
Now you can use standard shaders instead of Shadergraph.
Standard shaders allow to make the line unlit by enabling a checkbox in the material.
Files moved to 2 folders: Shadergraph and Shaders.
The .hlsl files are shared among both versions.
The test scene has been updated. 2 new lines have been added which use the new standard shaders. A 2D point light has been added to demonstrate how the light affects the lines, unless they are unlit.

@ThundThund is there any chance you could help me with basic usage? I am relatively new to Unity, especially shaders. My basic questions are:
Can this be imported as a package? If so, how?
If I just run the project, it seems to run as a 3D project, and I can’t get any lines to render… How do I get it to run as a 2D project, and what are the instructions for running a basic single line test?

It’s not a package, just copy the files to the right place.
You may need to press the 2D button at the top bar of the Scene view.

I dug into your code and used one of your prefabs and changed around some project settings and it works beautifully - this is a really cool implementation, and it’s exactly what I’m looking to add to my game for a pixel perfect zipline. Thank you for sharing.

1 Like

I’m glad you find it useful.