Advertisement

How can create normalized object space position?

Started by December 11, 2021 06:29 PM
1 comment, last by JoeJ 2 years, 11 months ago

Hi guys, how's it going?

I'm working on a tri-planar mapping shader that uses Object space position to sample a texture.

The only problem is that when I make the objects larger, the texture tiles, and doesn't stretch with the geo.

I could connect the scale value as input slider, and divide the UVs by that value, but that won't really be ideal since I don't always know the value of the scale.

Is there any way to have the texture scale with the object automatically?

Thanks in advance

You can calculate the bounding box of the object and match uv scale so the texture fits exactly this box. Then it's guaranteed no tiling can happen.
To avoid texture stretching because the box is a box and not a cube, you can calculate such cube from the largest dimension of the box.
Ofc. texture resolution may be too low in practice, which is why with tri-planar mapping tiling textures are usually preferred.

This topic is closed to new replies.

Advertisement