Ben Golus
1 min readOct 21, 2021

--

The linked to article that image is from sort of covers that, but the short version is by default it comes from the center of the pixel. So yes, the values can be over interpolated. In HLSL you can tell the GPU to use the 'centroid' position, which uses an interpolated position that's on the visible triangle, either one of the coverage sample positions or an average of the visible coverage sample positions.

Neither option is perfect. Centroid sampling all the time can cause subpixel artifacts to show up across otherwise visually continuous surfaces along the triangle edges, which can be especially obvious on dense geometry. The default pixel center sampling can cause artifacts due to over interpolation, especially on geometry silhouettes, sampling texture positions outside of the explicit UV range or vertex normals that are greater than 1.0 in length.

Usually interpolated normals have a length equal to or less than 1.0, so you can use that to detect when values have been over interpolated "too much" and choose between a centroid and pixel center interpolated value. If you pass both to the fragment shader all of the time. Valve uses their VR stuff to reduce aliasing on mesh silhouettes caused by specular artifacts from over interpolated normals.

Valve talks about this in their paper on Advanced VR Rendering here:

https://media.steampowered.com/apps/valve/2015/Alex_Vlachos_Advanced_VR_Rendering_GDC2015.pdf

And I posted an example shader for Unity that implements centroid sampling and geometry roughness, along with comparison images, here:

https://forum.unity.com/threads/trying-to-create-custom-standard-shader-with-geometric-specular-aliasing.494588/#post-3218526

--

--

Ben Golus
Ben Golus

Written by Ben Golus

Tech Artist & Graphics Programmer lately focused on Unity VR game dev. https://ko-fi.com/bgolus

Responses (1)