Please explain texture real world scale to me on large objects. I dont get it!

Hi Guys

Coming from an offline rendering background, using 3ds Max, I’m not understanding how real world texture size and UV mapping tie together in Unity.

This is a 3 part question:

Question1

In 3ds Max, I deal mostly with large buildings so pretty much 90% of things get simple box mapping applied, with a tick to enable “Realworld Scale”, which essentially adds a UV of 1meter x 1meter x 1meter. Then in my materials when using any bitmaps…

…I flip a switch from this (similar to what Unity has):
6070713--658125--upload_2020-7-9_10-35-54.png

to this, which let me specify the actual size of the texture:
6070713--658128--upload_2020-7-9_10-37-29.png

That then gives me a realistic representation of my texture on my objects, in this case 4200mm X 140mm.
That is awesome becaue now I can swop out materials as I please without having to worry about the UV box mapping on my object (which is 1 X 1 X 1 all this time)

If I then import this fbx into Unity however, I loose the real world scale I entered on the texture itself, and it reverts to the tiling method, and thus the scale is now totally wrong.

So I tried making things simple, with a 10m X10m cube, and a simple texture. So by default when importing this, it naturally gives me a cube with the texture repeating 10 times. All good so far. Let’s say I now want to make that single texture 10m X 10m to fill my cube and so have no repeats, but only tile 1 time. Logically the tiling should be set to 0,1 X 0.1 right? So I tried this with shader graph, but the texture does not stretch to 10m to fill my cube, but rather results in something that looks like roughly 9.3meter X 9.3 meter and then the texture repeat and I see another 0.7m on either side of it.

Baking anything is not an option as Buildings are large and the textures need to look good both up close and far away. Bricks for example must be at correct scale so if there are 10 bricks between a window in the architects design, then I’d better show 10 bricks!

Question2

In Max I can have multiple UVmaps on an object. If I use the example above as my base texture in Map Channel1, which is affected by my 1m box UV Map, I can add another Box UV Map and set its size to 100m X 100m and its channel to 2. I can then add a mask over my base textrure in channel 2 that is 100mm and affected by the 2nd UV map.
As far I understand I can’t do that in Unity as the 2nd UV Channel is reserved for Lightmaps… Is that correct? How would I then use different textures in a single material, but use different coords for each?

Question3a

If I tile a texture, it would have an obvious repeating pattern. How can I randomly rotate and offset the texture to reduce the repeating pattern effect?

Question3b

Can I then fade the edges of each randomly rotated tile, to blend into each other a bit, so not to have a hard edge on each tile?

additional bits for Question1:

Here is my shader graph:

Resulting in an expected 10 X 10 repeat

Since the UV is center of the object I get 9 full tiles and 0.5 tiles on the edges

Setting tile to 0,1 and 0,1 I expect to get a full coverage of a single tile, but I have to use offset to try and make it fit. Weirdly, the offset is not 0.5 and 0.5!

As you can see, the 0.45 offset is almost there, but not exactly!

On 0.5, I get this weird result:

nobody knows?

  1. For the scale tiling, this is because the origin of the UVs are here :


    When doing a tile 0.1 and offset 0.5, you will indeed stretch the texture to you needs, but will be slightly off with the offset.
    If you count how many “tiles” are needed to go from the origin to the bottom left corner, it’s 4.5 and not 5.
    Apply the 0.1 tile factor to those numbers, and you get your 0.45 offset needed.

  2. Unity can handle up to 8 UV maps in most recent versions. Indeed the second one is reserved to lightmapping, but it only means that the other ones are offseted when importing if you choose to generate lightmap uvs (you can also provide your own lightmap uvs if you want to), so UV1 becomes UV2 etc …

  3. To make this kind of effect you need to sample your texture multiple times with different UVs (this can be done by taking your base uv and using the rotate node), and them blend them together, typically by using a lerp node, with something like a noise for the T input (the interpolation value). You can choose to either do a stepped (0 or 1) or smooth (from 0 to 1) blending.

I have no idea what you just said.

Please explain to me in simpler terms, how can I get my desired result, ie, just get the texture to display at 10m X10m. In other words only have 1 image of that “hd” texture display and streched over my entire object.

At one point, I don’t know how to express myself simpler.
If you want the texture to be displayed over 10x10 meters, why don’t you just simply export your object with proper UVs to match this ?
If you apply the same texture in 3Ds max and Unity, with the same object scale, then the results should be similar, there is no magic here.

My objects already have proper UVs. Thats the entire point. I dont need to touch the UVs after setting it up to real world scale. In Max I can assign any other material to it, that was also setup with correct realistic size. For example I can add a brick and specify the brick size to be 220mm X 80mm and it will tile at correct size for me. I can apply a concrete texzture that covers a 2m X4m grid by simply specifying that in the texture. No need to touch the object UVs as its already setup for world scale. So now I can easily swop between the 2 textures in Max

Now in Unity this seems to be a mission and a half. There’s nothing wrong with my object’s UVs. The issue is with my material setup. I simply want to know how to adjust texture size in Unity so I can easily swop between different materials on my object without having to adjust any of my objects UV coordinates

Is this not possible in Unity? Then how are they creating configuratiors where you can in realtime swop materials if you cant specify correct scal for textures?

I’m simply asking for a solution to my specific situation so I might understand how things are done in Unity. If I can understand how to scale the texture in Unity then I can understand how to do things.

I applied my math and my logic as you suggested to come up with a solution, as per my screenshots. But its not working.

If my UVs are centered on my object of 10m x 10m that has 1m UVs, then naturally my texture will tile 10 times over my object. Thats logical. Because the UV is in the middle, I need to move it over by 500mm. Logic tells me this is 0.5 I need to move over, so I dont get the half of the texture left, half on the right, and the other 9 repeating in the middle. So I need to move it over by half a tile (0.5). Moving it over by half a tile, should result in a full 10 X 10 tile to appear on my object. Logic further tells me if I change the size of my texture to 0.1 X 0.1, that should result in a single texture of 10m and it should stretch over my entire object and fill the 10m X 10m space.

This is not the case at all so I’m asking for examples of how this should work so I can know what I’m doing wrong

I don’t know what black magic 3Ds max does when you set the uv mapping and texture to “use real world scale” but I know what UVs are.
My easiest suggestion would be to map your objects so that one UV tile is one meter size, and then use the tiling/offset on your material to adjust the texture.
Set the tiling to 1/2.5 (you can enter calculation directly in the number field in Unity) and your texture will tile over 2.5 meters instead of one.
In in the shadergraph instead of the tiling/offset node you apply a division node to the UVs, this will act as a “texture size” setting, and you will just have to type 2.5 .

My UVs are already setup as 1m in 3ds Max, with the center of the UV in the center of the object

Can you ask a co-worker to chime in here please? Its pointless us trying to explain to the each other as you obviously dont know Max and I obviously dont know Unity

My math and logic works exactly like I described in Max. Even if I use Unity’s logic of 0.1 as tile size and 0.5 as offset, things work in Max. Why it doesnt work like that in Unity is beyond me. So either there is a bug here, or I’m just clueless in Unity

I haven’t used it for a while but I know max, and I can tell you that in the example you provided the UVs “look” centered, but the UV origin is not at the center of the plane. This is what I tried to show you some posts ago with the red and green arrow.
If you add an UV edit modifier and open the UV editor you will see that.

In Max

UV centered in object with size of 1m X 1m over a 10m X 10m object
Texture set ti tiling just 1, I get 10 tiles (9 full and 0.5 on each side)

Adjust the tiling to 0.1 without worrying about offset, the tile is now fully covering my object. Makes perfects sense.

This same UVs and same logic does not work in Unity

Then I suspect that 3DS max tiles the texture from the 0.5,0.5 coordinate in UV space.
Like I said, if you look at the UV editor in max, I’m pretty sure you’ll find out that the origin (0,0) of uvs is not centered.
My easiest fix would be to align the bottom right corner of the UVW Map gizmo with the bottom right corder of the plane, so not only will you have 10 full tiles, but the uv scale in unity will also take this corner as reference point.

1 Like

Thanks @Remy_Unity for your patience.
Moving the UV gizmo seems like the answer

2 Likes