Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

centroid details seem contradictory #627

Open
greggman opened this issue Jul 22, 2024 · 4 comments
Open

centroid details seem contradictory #627

greggman opened this issue Jul 22, 2024 · 4 comments
Assignees

Comments

@greggman
Copy link

In the GLSL ES 3.2 spec in relation to gl_FragCoord

In section 4.5 it says

If a fragment shader input is qualified with centroid, a single value may be assigned to that variable for all samples in the pixel, but that value must be interpolated at a location that lies in both the pixel and in the primitive being rendered, including any of the pixel’s samples covered by the primitive.

Where as in section 7.1.5 it says

The use of centroid does not further restrict this value to be inside the current primitive.

It seems like section 4.5 says in centroid mode "that value must be ... in the primitive being rendered" where as 7.1.5 says it doesn't.

@gnl21
Copy link
Contributor

gnl21 commented Aug 5, 2024

I think that the text in section 7.1.5 is intended to apply here instead of the more general langauge. I'll create an MR to update the spec to make this clearer.

@greggman
Copy link
Author

greggman commented Aug 5, 2024

That seems strange. I would think 4.5 is the entire point of centroid. Otherwise, what does centroid do?

@gnl21
Copy link
Contributor

gnl21 commented Aug 5, 2024

Maybe I wasn't clear, sorry. The text in 7.1.5 should apply to gl_FragCoord, the text in 4.5 will apply to everything else. 4.5 is the entire point of centroid and 7.1.5 is saying that it just doesn't do anything for gl_FragCoord. GLSL has (what I consider to be) a bad habit of allowing these things that don't work and just having them mean nothing instead of giving an error message.

I imagine that the reason centroid doesn't work on FragCoord is related to hardware differences between varyings interpolation and the fixed-function positions that come from the rasteriser, which probably don't always support forcing to within the primitive.

@greggman
Copy link
Author

greggman commented Aug 5, 2024

Oh! right. that makes sense. Thanks

@zmike zmike added this to the Needs Action/PR milestone Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants