Differents texture scales on a cube

Hello,

I have been searching the solution for hours but I couldn’t find a working one, so here’s my problem :

I create my level using Unity’s cubes, but the textures are messed up because Unity fit the texture and I do not want that, so I searched everywhere to fix this but couldn’t find, see the image to see what I mean :

[30122-sans+titre.jpg|30122]

What I want is that face “A” has the same texture scaling as face “B”, same goes for face “D” to have the same texture scaling as face “C”.

Notes :

  • There is only 2 materials used (floor/wall) which scaling and tiling are not edited, they are diffuse.
  • Like I said, those are Unity’s cube, they aren’t planes/models or anything else.

So what I can do to fix the problem and get the result I want ?

Thanks

Shepard

The texture scales on A and B are the same. They both have 5 horizontal copies of the texture. That's how scales work. You get to specify # of repeats for the face. You can't give it repeats per meter, except by doing the math to convert.

–

2 Answers

2

You’re seeing texture stretching/distortion as a result of the fact that all of the cubes have the same UV mapping, but different sizes. If you’re not aware, a 3D model’s UV map specifies the relationship between its geometry and its texture.

There are a few ways you can fix this.

First, you could use a modeling program to create more geometry with proper UVs. Maybe a bit tedious, though.

Second, you could use various materials with tweaked scale. This option is probably the simplest, especially if you’re not sure what all this is about.

Third, you could use a custom shader that fixes the problem automatically. This option is probably difficult if you haven’t mucked around with shaders, before.

I tried the second solution, what I have done is that I edited a wall’s Mesh Renderer to have 2 materials instead of 1. I made a copy of the material and change it’s properties to have the desired scaling, but the problem is that both materials are applied to all faces. Is there a way to apply a material to a set of faces only instead of the whole cube ?

The actual model, when you make it, can have faces broken up over a certain number of materials (aka sub meshes.) If the model was made with all faces using the same material, then it will only ever use one material. Adding a second one just confuses it. If it helps, this is standard 3D modeling stuff. So any 3D site will explain it better. A cheap trick to get two materials is to use, in Unity, two different cubes (or planes.) One for wall A, one for wall B. Then you can give each its own material.

–