0
\$\begingroup\$

In Unity Shadergraph, how can I create a checkerboard pattern that works independently of the size of the quad that it is applied to?

Here's what I got so far. Since I have set the Frequency to 10x6, this will work for a quad that has a scale of 20x12. However, if I increase the scale of the quad, the checkerboard will get stretched to fit. But instead, I would like it to "add more squares" to fit the new size.

Is there a way to get it to somehow use the size of the quad instead of manually specifying the frequency?

enter image description here

\$\endgroup\$
2
  • \$\begingroup\$ What quads will you be drawing these on? If they're axis-aligned and don't move, you may be able to use worldspace texturing to solve this problem. \$\endgroup\$
    – DMGregory
    Commented Mar 28, 2021 at 12:07
  • \$\begingroup\$ Just one big quad to cover the whole level. Using this as a background for prototyping. \$\endgroup\$
    – Ben
    Commented Mar 28, 2021 at 12:21

1 Answer 1

1
\$\begingroup\$

Pipe a worldspace position value into the checkerboard's UV input, instead of the default texture coordinate:

Position node with space = Absolute World plugged into Checkerboard UV

This assumes you want your quad to sit in the XY plane. If you want it in XZ, you'll want to swizzle the vector first to move Z into the Y slot.

Here are two ways to do that swizzle:

Swizzling with either a Swizzle Node or a Split and a Vector2

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Thank you, the first solution (XY plane) works for me. However, I noticed that the resulting checkerboard is offset from my tilegrid by 0.5 on both the x and y axis (even though my quad is positioned at (0,0,0). So I piped the Position output into an Add node, and that result into the UV input of the Checkerboard. \$\endgroup\$
    – Ben
    Commented Mar 28, 2021 at 15:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .