Which fragment is being processed currently?

Although I haven’t yet got answer to the previous question, I’m asking another one :slight_smile:
Is there any way to determine which fragment is being processed while executing in the fragment shader? eg. if line rasterization produces 8 pixels, would I be able to know exactly what pixel it is (first, second, third…) ?

Thanks in advance

I don’t think it’s possible as the fragment processing is massively parallelized.

the best you can do is try and figure it out based on varyings that you place on vertices.
if you know enough about your output geometry you can do this easily. but there’s no built in fragment id or anything.

I am not sure if this is going to be what you are looking for… but you can know the position of the fragment in the 3D world.

You only have to do the following:

VS
varying vec4 position;

position = gl_ModelViewProjectionMatrix * gl_Vertex;

FS
varying vec4 position;

If you asking for the order in which fragments are calcuated, I dont see any sense in it. Do you have an example of the utility of knowing it?

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