RoundedLine

I am trying to achieve a rounded Line where Line will go through point A to point B with GLSL. I am able to do it on Shader Graph however I don’t want to create my project while using Universal Render Pipeline since it is increasing the size of the project.

I also tried to generate the code from a test project using Shader Graph; however, importing was successful for my project using the built-in renderer.

Does anyone know how I can achieve a rounded line on GLSL?

Thanks

Presumably you’re using the rounded rectangle node. If that’s the case, the documentation shows the HLSL code for most nodes:
https://docs.unity3d.com/Packages/com.unity.shadergraph@6.9/manual/Rounded-Rectangle-Node.html

And presumably you’d be using HLSL, and not GLSL. It is possible to use GLSL for Unity, but Unity will auto translate HLSL to GLSL for you so there’s not a real reason to use GLSL unless you’re looking for extreme control over the code, and are running the editor in OpenGL mode and targeting quite old mobile devices.

That is acutally a good one. Thank you!

I was checking 2D SDF implementation and trying to move to the HLSL. However, I failed so far. Your example might help me. Did not know there is an build in rounded rectangle

float LineSegment2dSDF(float2 p,float2 a, float2 b) {
    float2 ba = b - a;
    float2 pa = p - a;
    float k = saturate(dot(pa, ba) / dot(ba, ba));
    return length(pa - ba * k);
}
fixed4 frag (v2f i) : SV_Target
            {
                float length = LineSegment2dSDF((0.5,0.5), _aPos, _bPos);
                float step = smoothstep(_thick, _thick + _crisp, length);
                float reversed = 1 - step;
                fixed4 col = lerp(_Color, _Color, reversed);
                return col;
            }