Procedural Grid Material

Just ran across this tweet showing a useful solution for creating multi-cell grids. I often use things like this to draw a wireframe in my pixel shader for debugging.

3 Likes

the lava river looks smart aswell :> thanks for sharing keith!

I do a lot of random stuff with procedural tiling just for fun, remember that solutions like this alias like mad because of lack of mip filtering and binary operations like step, fmod, ceil, floor. The solution is to make yourself a manual mip bias in the math and then rather than using binary interpolation like step(), use smoothstep() and then bias your min and max smoothstep values by the result of the DDX/DDY gradient. It’s a global filter width solution that “anti aliases” your procedural math.

Someday I’ll do a blog post on procedural shader tiling, I have a folder full of them :wink:

12 Likes

I’m dying to see how you did your Truchet shader. Mine was based on actually rotating the coordinates and would suffer from precision errors over large distances.

@William_Mauritzen Sure, it’s not like it’s a secret or anything :smile:

The function at the end is as I described it before, smoothstep with an edge bias and an additional mip bias using texture coordinate derivitives. The “Classic” truchet is just another cosine at the end or whatever you want to do with the math at that point.

7 Likes

could not find filterstep node