Creating a simple three color pattern on top of a triangle

Hello!

I’m trying to create an equally divided three color pattern on top of a triangle-shaped mesh, like so:

So far, I’ve been able to apply a color to just the top of the mesh using dot product

Result:

Any tips on how to achieve this effect on top would be appreciated!

Hi,

I think you could use some polar math here, something like in my example below.
It might contain some mistakes as I cooked it up pretty quick, but for an equilateral triangle this should work:

So basically you would just create polar coordinates, and then scale and quantize the values so that you get the desired range of numbers. In this case it would be a shape divided to three parts.

You need to zoom in to see the details.I commented the image so that it would explain this visually.

First off, I really appreciate your response- that is so much more complex than I had expected :smile:.

It seems to work well on Unity primitives, but sadly for my unwrapped tile object it’s a bit off:

If I feed just the one-minus’d UVs into the color, I get this:

In Blender, here’s my unwrapped tile mesh:

My basic knowledge of shader graph makes me think this should be done with triplanar projection (vs. mapping to the UVs), but I’m not exactly sure of the best approach. Any thoughts? I’ll keep tinkering in the meantime.

Coordinates have to of course match, in my example I just made the assumption that the triangle would fill the UV space etc.

Another way could be to use object space coordinates. Then you would not need to worry about UVs. Here’s an example:

Basically you just need to feed in the object space coordinates and then offset the origin. This type of solution would allow you to rotate the objects freely etc. I brought in an equilateral triangle I made in Blender (it does not have UVs.)

This is how the shader looks like on a few different objects I imported from Blender.

So the texture will follow the model when it translates and rotates in the world.

This is great! So helpful- you’ve got a new follower on Twitter :slight_smile: