How do I make a grid material work in three dimensions?

I have recreated the material described in this post:

But I was wondering, what can I do to this material to make it create a grid in all three directions? Currently it creates a grid in X and Z directions. But in the Y direction, it only creates vertical lines.

Is there a way to create this same grid, but so that it works in vertical direction as well?

I have tried monkeying with this material as much as I can think and have come up with nothing.

Any help is appreciated.

Thanks,

Sure, here’s an example.

Basically we convert every component (x, y, and z) into -1 or 1.
By multiplying those together, we get an XOR operation which makes a 3d checkerboard.
Then we use that to lerp between two colors.

The small offset added at the beginning is because this process leads to aliasing at grid boundaries. If you have a cube with an edge exactly at a transition point, you’ll get flickering.

Does that help?

127668-images.png

Beautiful!!!

This does EXACTLY what I was wanting!!!

I still have NO IDEA how it works. But, I got the effect I was looking for and that is the most important thing.

A Million thanks to you. You truly ARE a Digital Mage!!!