Worldspace shader for "brush" objects.

Hey there, I’m rather new to shaders. I understand the syntax and flow, but I don’t know much about actual techniques. Any help would be appreciated.

What I’m trying to do is display a tiled texture in world-space, so that instead of being tiled based on the object’s UV coordinates, it’s based on the world space. So like, a 5x5 texture wouldn’t just repeat 5 times on the object, but would repeat 5 times per meter.

I’ve managed to make this work on one side, but I’d like it to appear on all sides, and I’ll post an attachment. I’m basically doing it through this line:

o.Albedo = tex2D (_MainTex, IN.worldPos).rgb;

EDIT: OH! I think I remember now! Triplanar shaders or something. Anyone know of a good resource on that for objects rather than terrain?

1485725--82622--$Worldspace.png

Using coords, world coords have 3 parts - xyz, but tex2d only uses xy, so you will inevitably either have to use 3d textures or come up with some other method like the triplanar you mentioned. Or perhaps a procedural 3d texture like some noise function. The texture basically needs to be volumetric, not flat.

If you’re making this for brush objects, it may be easier to have whatever is generating the brush objects to have it also make proper UV’s. That way, you could use any shader you would like. Otherwise, “triplanar” should work fine.