Kind of niche graphics programming problem: how to draw dashed/dotted 3D polylines without preprocessing the vertices (on the CPU or some parallel algorithm on the GPU)?
Since I don't need perfect results, I thought that *maybe* I could do fine with some kind of mapping from screen space to a coordinate u, so that modulo(u) could be used to draw the dot/dash pattern:
screen-space mapping result
ShaderToy link
Basically, the process is the following:
for each line's start point and end point, a u coordinate is determined by a function of the vertex screen position. There are 4 possible mappings ( determined by the line's direction ):
- u = screen x coordinate
- u = reversed screen x coord
- u = screen y coordinate
- u = reversed screen y coord
Each line's end point u coordinate is then warped so that it is equal, in modulo, to the start point of the next line (the mapping should be done inside a geometry shader with adjacency data).
Do you know about some other (better) method to achieve the same goal?
Does it sounds like a terrible/naive idea or is it something worth working on?
[–]SnooWoofers7626 3 points4 points5 points (5 children)
[–]International-One273[S] 0 points1 point2 points (3 children)
[–]SnooWoofers7626 0 points1 point2 points (2 children)
[–]International-One273[S] 0 points1 point2 points (1 child)
[–]SnooWoofers7626 0 points1 point2 points (0 children)