Hi!
I’d like to write a shader that works like the UV Along Stroke node from Blender.
Basically, I need UV coordinates that follow the edge of an object and wrap.
I’m good with writing CG, but I honestly can’t wrap my head around the math involved.
Ideally I’d like to do this without baking data into the mesh itself, but as a last resort I’m willing to consider it.
Any idea where to get started?
You wouldn’t be able to do that with a regular vert/frag shader. It’s rendering outside the bounds of the cube’s geometry, and if you were to do an expand in the vertex program of a mesh with split verts like that it would break the vine line (but even then, there’s other issues like properly determining that thick of an edge and computing the right UVs).
You could perhaps work something out using a geometry shader to construct strips that run alongside each outside edge with appropriate UVs to sample the vine, though it’d be a bit tricky, you can look up information that’ll get you most of the way there by researching “geometry shader silhouette”, and you’d have to use DrawProcedural with the Quads overload (though even then I’m not sure Unity has all the geo shader features to make that work). There’s a partially working example here for purely geo shader.
I’d wager this is a cpu-side effect that generates some poly strips to render right after the mesh does. You could test this by applying the effect to some very high poly meshes and see if it start to impact your CPU usage a fair bit when the effect is turned on.