i would like to create a diagram shader in unity shader graph, but i cannot find anything on how its made
it should like something like the red line going from point to point
any pointers ?
i could propably do this with c# and the line renderer, but i would like to have it as a shader
Replies
The code in the Combining Powers section on this page shows you how to generate the distance field for an ngon
https://thebookofshaders.com/07/
At the end he smoothsteps the distance field to get a nice antialiased mask - if you subtract from the distance (offsetting the zero point) and abs() the distance field you will get a line :
eg.
d = abs(cos(floor(.5+a/r)*r-a)*length(st) - 0.5);
color = vec3(1.0-smoothstep(.0,.01,d));
this next bit is speculative (as in I haven't tried it)
To get the wobble you would offset the distance by adding/subtracting from the distance field prior to calculating d
The rectangular stripes/texture you have now but converted to polar coordinates would probably be quite good for that
should add that atan is a lot less good than atan2 so if you have the option, always use atan2