Aliasing on Math Generated Materials

I am making some simple grid and gradients using Texture Coordinate math. This results in very crisp and performant results, however there is no Mipping or AA being done on these materials. They create an aliased look at certain angles and distances. I have found some resources that state that I need to do some DDX DDY based masking in conjunction with SmoothStepping. I cannot find a lot of information on this process, below are two links that seem close to what I need to do, but lack explanation of certain steps.

Here we see Wyeth explain the theory a bit and show some of the DDX DDY calculations.

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.

Hey there! This did clarify a bit, I think I am still missing some pivotal parts, if you could potentially message me on discord → Montreseur#0001 . I would love to circle back and post the answer after we hash it out!