I want to take all the vertices of my primitive (in particular, 2 vertices of a GL_LINE
), and compute some stuff with them to be used by the fragment shader (in particular, the coefficients of the line equation ax + by + c = 0
).
Since I don't see the other vertices of the primitive in the vertex shader, is there a shader stage best suited to compute such information?
I don't want to do in CPU because I want the information after transformation and projection. Can I do it in one of the tesselation or geometry shaders, and pass the output as a flat varying to fragment shader. In this case, the same primitive would be output, unchanged.
Is it possible? Is it a good idea?
lines
input (and output?) primitive would do the trick. Might be a better way though. – G.M.ax + by + c = 0
." That sounds suspiciously like something that you can avoid having to compute per-primitive and can just interpolate if you're sufficiently clever. Can you explain what you're doing with this equation in the FS? If it's some kind of linear math, I'd bet it can be precomputed in the VS and interpolated. – Nicol BolasGL_LINE_SMOOTH
in shader, and use the line equation to compute its distance to the fragment. – lvella