-
Notifications
You must be signed in to change notification settings - Fork 321
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
Derivatives of centroid
-interpolated variables
#4854
Comments
Am I interpreting correctly that it's not that the derivatives are wrong, but that the values of the inputs might not be what authors anticipate? If that's the case I wouldn't want to change derivatives, but it might make sense to add a note to centroid sampling that calls out the situation in some way. |
That's my understanding of Vulkan, yes. I would be surprised if OpenGL is ever actually worse than that in practice, even if the spec allows that (or used to allow it - I didn't dig up the current OpenGL spec text). |
This sounds like a note in the spec is sufficient? |
Yeah it's probably useful to as an example call out that "because centroids are not necessarily one pixel width apart, derivative functions might not have the values you expect". |
MSL and Vulkan wording is simliar to what exists in WGSL: MSL: (5.4 sampling and interpolation attributes)
Vulkan: 9.12 interpolation decorations (the normative above the paragraph Kai quoted):
WGSL:
D3D is more prescriptive about exactly what sample location is chosen, while the others allow a lot more choices, potentially. But all three have the "you're not likely to get something intuitive" vibe. I'd go with a note at best. |
This very useful 2007 article about
centroid
shading says that - in OpenGL in 2007 - derivatives on centroid-interpolated variables have undefined results: https://www.opengl.org/pipeline/article/vol003_6/Vulkan is a bit less harsh than that, at least in this non-normative note (I couldn't find normative text):
FWIW, D3D is very strict about centroid interpolation, so it probably doesn't have issues with derivatives: https://microsoft.github.io/DirectX-Specs/d3d/archive/D3D11_3_FunctionalSpec.htm#3.5.5%20Centroid%20Sampling%20of%20Attributes
But anyway, should WGSL say this is a dynamic error? Should it be a compile-time warning or error? Or is it fine to allow?
The text was updated successfully, but these errors were encountered: