Dynamicly scaling textures

I have walls that are made of cubes, they all run on the same script for re-sizing their textures. You can guess my problem, when a cube is not the same length as it is width the texture is off (stretches). How do I go about adjusting the UV map in code in line with the objects scale? If you know other solutions to the problem I am all ears. I am not afraid to solve this in 3DSMAX if it is needed. I couldn’t really makes sense of most of the results I got from my google searching.

Thanks for the help guys! :slight_smile:

If all the cubes have the same size, change the X and Y tiling of the material

If they are different, you have 2 main choices:

  • Different material for each size of brick, each with different tiling values
  • Different mesh for each size of brick, with vertex uvs rescaled to fit

Follow the examples here for editing the mesh

Bonus 3rd choice: Use a shader that calculates the UV lookup by vertex position, that way you dont have to manage any of this

Well currently it is set up to create a new texture and tile it to fit the cube, so all the textures needed are created upon loading the level. The problem is really the UV Map on the cubes. I don’t know how to set them up in code.

And all the cubes are the same object, but a script sets the length, width, and height of the cube which changes their scale. So they are all different sizes, they are the walls of the level.