Non-interpolated varyings?

Is there any way to pass a per-vertex attribute from a vertex shader to a fragment shader without that value being interpolated?

The situation I have is this: I need to specify the radius used by a vertex shader during the computation of the gl_PointSize on a per-particle basis. That shouldn’t be a problem because I can pass the appropriate value from the app to the vertex shader as a vertex attribute. The difficulty arises because I need to use that same radius for each fragment that is generated by the vertex so the fragment shader can do depth-correction. When I use a varying to pass the radius from the vertex shader to the fragment shader, weirdness ensues. This undoubtedly results from the perspective-correct interpolation performed on varying variables.

So, is there anyway around this issue, or is it going to be impossible to know what radius was used to generate the fragment? I’m open to anything that works, but something clean and fast would be preferable. :slight_smile:

I don’t quite understand. How exactly do you generate your “particles” ? Do you use points (point-sprites?) or quads? or something else?

If you use polygons (triangles, quads, whatever) and specify the same radius at every vertex of the polygon, then there should be no interpolation at all. So i don’t quite get it how any depth-perspective-correction could screw that.

However, AFAIK, there is no way to disable the interpolation. Storing the same value in the varying at every vertex should do the trick.

Jan.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.