🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

How can create normalized object space position?

Started by
1 comment, last by JoeJ 2 years, 6 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

Advertisement

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