Giter VIP home page Giter VIP logo

linerenderer2d's Introduction

LineRenderer2D

Scripts for rendering pixel-perfect GPU-calculated lines in 2D (Unity URP 2D Renderer). It allows: -Single line or multiline (different script). -Dotted line. -Usage of any material, lines can be affected by 2D lights. -The single line allows the usage of different colors for both endpoints. -Any thickness. -Local or world space points. -You can use either shadergraph version or standard shaders version. -Tested with DirectX and OpenGLCore.

linerenderer2d's People

Contributors

qthund avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

linerenderer2d's Issues

Outline?

Would there be a performant way of adding an outline?

Checking all neighboring pixels with IsPixelInLine_float seem to be a lot of work.

MultiLineRenderer not displaying all lines in certain configurations

Sampling tPackedPoints in S_BresenhamMultiLine.hlsl to get packedPoints/packedPoints2 returns the wrong packed point in a variety of configurations, which causes some lines to not get rendered entirely.

I managed to fix it by replacing the first part of the outer for loop of IsPixelInLine_float with

int xCoord = floor(t/2.0f);
float4 packedPoints = tPackedPoints.Load(int3(xCoord, 0, 0));
float4 packedPoints2 = tPackedPoints.Load(int3(xCoord+1, 0, 0));

The lines are not visible on build

I downloaded the repo and copied the Assets/LineRenderer2D folder to my project. I fixed the shader errors using this commit.
I put MultiLineRenderer2D prefab to the scene and adjusted the points. It is visible in the editor window but when I build the game, it becomes invisible. Is there a way to fix it?

"Couldnt open include file" on 2022 LTS

Hello, sorry I am terrible with shaders, but I am getting this error with several files, specifically these:
Couldn't open include file 'Assets/LineRenderer2D/Shaders/S_BresenhamLine.hlsl'.
Couldn't open include file 'Assets/LineRenderer2D/Shaders/S_BresenhamMultiLine.hlsl'.

Any advice on what i need to change/update to get these fixed?

Doesn't work when is child of a canvas?

Currently using 2023.2.

The provided components work fine when not part of any canvas, but when put on a canvas, the gizmos will show the correct end points but the line is not drawn.

image

It is worth noting, what considered "center" of the object (the transform handle) is not even on the magenta gizmos line.

I ain't prodigy in shaders but... could there be a way to make this work on canvases?

Compilation error fix.

To make this work in Unity 2021.3 I had to replace all instances of

if (_IsUnlit == 0.0f)
{
    // Lighting
    finalColor = CombinedShapeLightShared(finalColor, maskColor, i.screenPos);
}

with:

if (_IsUnlit == 0.0f)
{
    // Lighting
    SurfaceData2D surfaceData;
    InputData2D inputData;
    surfaceData.albedo = finalColor.rgb;
    surfaceData.alpha = 1;
    surfaceData.mask = maskColor;
    inputData.uv = i.screenPos;
    finalColor = half4(CombinedShapeLightShared(surfaceData, inputData).rgb, finalColor.a);
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.