Aliasing on Math Generated Materials

I took a look at the link to help give some context. What this is doing is widening the shape of a smooth step function (which is not actually shown - hence your confusion i suspect) so that the lines them selves change apparent width by increasing the distance they would ‘fade to black’ if it was a black and white grid (hopefully that makes sense)

checking ddx/ddy should be done on the source coordinates you are using for the grid. again the example you link doesn’t really explain this or makes it clear - in fact its build assuming you are using texture coordinates for the texture mapping, which may not be the case for a procedural grid or gradients that relies on all of x/y/z

broadly the idea is this, you max/add and scale absolute values of ddx/ddy on all of the components involved in texturing before any complex shaping happens - this would be x,y,z scaled by your gridsize for a regular worldspace grid. this gives you a number representing the texel density for that given pixel. then the smooth step used for lines has its min and max values decreased/increased by this value - the result is that at greater distance or sharper angles the lines are wider with softer edges, which looks similar to e.g. bilinear filtering at a distance

hope this helps.