Preserving scale in UV unwrap?

Not sure if this is the correct subforum.

Upon UV unwrapping, I’m finding that the resulting geometry is scaling to fit the square area, and I’d like to preserve the scale of the parts according to the global scale. (to preserve relative size between different parts/models)

Right now I’m re-scaleing manually and eyeballing it to export to Unity. This seems like a relatively basic task, yet I don’t know how to change it.

With proper UV scaling, I can use the same texture in Unity and it will appear at a consistent scale across multiple objects.

1 Like

I am not confident this will solve your problem but it is relevant:

There is also one in the Adjust Last Operation Panel for some of the UV mapping techniques.

Sadly, it does not. I’m not even sure it’s relevant. Since in order to keep the same scale across objects, some items need to be scaled well outside the bounds of the the given UV area. (and some are shrunk to just a tiny portion of it)

You mean texel density? Some uv addons (for example TexTools) have instruments for texel management and there are dedicated addons just for texel density like Texel Density Checker.

Also here is very nice free pdf tutorial what goes into more details about texel density.

1 Like

Hey there
Im not sure it helps, but can you do smart UV unwrap? The type of unwrap usually depends on two things. The type of your texture (procedural should not matter, while PBR maps depend on the type of texture).
If your texture supports it, you can simply smart UV unwrap and check the settings

Can you show / tell us maybe what exact model it is and if you have multiple materials? :blush:

Sorry about that, maybe this:

https://docs.blender.org/manual/en/3.1/modeling/meshes/uv/editing.html#pack-islands

I am using smart unwrap.
Here is a picture to describe what’s happening.
Imgur
The large cube is 3x the size of the small cube, but both unwrap exactly the same to fill the UV grid.
This results in Unity applying the same material at the size of the UV unwrap and not the size of the object.
What needs to happen is that the small cube needs to produce a UV map at a third of the size. Right now I have to do this manually, and it sucks.
But with a correct scale UV unwrap, then unity gives a consistent material scale across different objects.

This seems like it would be an extremely common use for texturing. Is there something simple I missed?

Pack Islands sounds like the opposite of what I’m trying to do.
I don’t want to fill the texture space completely, I want the model to retain it’s size regardless of the texture space. (Assuming texture space is the proper name of the square grid in the UV view)

Uh, maybe? It sounds more complicated that what I mean. I’m not concerned with resolution, I just want object to have the same scale of the material. If a material has 2" dots, then all objects should have 2" dots regardless of their size (at the same scale multiplier)

Yep, that’s texel density :slight_smile: a definition of texel density- “… span roughly the same number of texture pixels per meter of real size”, which is exactly what you’re describing

Well, I figure there’s a lot more in there because it’s 90 pages, and the process to scale the UV map would be, what, 10 lines of code?

It also looks like it’s coming from the perspective of making textures match the models, and I want the models to match the texture.

I guess I’m just surprised there’s not a check box somewhere to preserve real sizes upon unwraping. The default seems to be to scale the shapes to the UV square, and I just want it to not do that.

I think the difficulty here is that “real sizes” don’t really exist in the UV space. Since all the UV islands need to fit into a single texture space, the unit the unwrapper uses is “does this fit in a square texture or not?”

The difficulty is that while it’s easy to scale a UV map down, it’s very tricky to scale it up. Since it can’t scale larger than the bounds of the square texture space, (it technically can, but it doesn’t work well, so unwrappers don’t), we now have a issue. If Blender units correspond to UV sizing, there must be a certain Blender unit that equals a full texture space.

I.e, let’s say ten blender units will perfectly scale and fill the UV space. In that case, five blender units will fill half the UV space. But what about 11 units? It’s going to be larger than the UV space. Any arbitrary unit we choose for the largest- even saying 1000 units will fill the space, will eventually run into problems if we go bigger.

The solution to this problem is texel density. It’s not nearly as complicated as that paper makes it seem, just google “blender texel density” and you’ll find some simpler tutorials. Like this: https://m.youtube.com/watch?v=gvzRpMHBE40

There is one UV operator that does take scale into account and will happily unwrap bigger than the UV space. It’s the Project from View operator. It doesn’t use object scale, though, it uses view distance, so it won’t really help here.

One way to do this is to unwrap all the objects that use the same texture at once into the same UV space.

Select all the objects that use the texture, go to edit mode select all the faces and do the smart UV unwrap.

Note: For this to work correctly you have to apply the scale of all the objects.

If you want more resolution you can scale the UV’s with the mapping node in the shader editor or by scaling the UV’s themselves outside of the “square” in the UV editor.

4 Likes

When importing the model into Unity, Unity thinks the UV size is a real size. Furthermore, Unity doesn’t seem to care if the model parts extend beyond the texture space.

The video method is certainly more precise than what I’ve been doing, but I notice they happily scale beyond the UV bounds. This still seems like a rather silly workaround tbh.

@DNorman
That’s an interesting idea, but it would literally be every single object since all objects can get every texture. I’m not sure hundreds of objects on the same UV grid is a good idea. But I dunno, maybe that’s not a problem?

Well, UV islands should always be in relative correct ratio but the biggest possible (to get the highest detail right?)

So, it may be a stupid question, but why not keep the islands as big as the whole UV grid and simply resize the texture in the material itself on a mapping node for example?

Because the same material is used on multiple objects. If I change the tile size, then it changes for all objects. This means that the objects still have mismatched texture scales, just at a different scale.

Ohh, I see. In that case, can you not duplicate the material and simply assign for the right size? :confused:

That would lead to hundreds of materials if I want to be exact. With less precision I can get away with maybe 3 or 5 variants. This is kinda bad though, and causes much code complication. Essentially, I’m assigning materials randomly - hence the possibility of any object getting any material.

I’d have to group variants into a set, and when assigning a material, I’d have to gather the part size, then give it the correct variant from the chosen set.

All programs treat UV Maps in the same way. Blender does not care either if you scale the UV’s outside of the “square”. Unity maps UV’s in the same way Blender does.

UV maps do not define a “size” they describe the “aspect/ratio” and positional relationship between the faces of your object and the UV space.
The UV “square” represents mapping from the 0,0 position (bottom left corner) to 1,1 (top right corner) of the image you are mapping. The image does not have to be square it can be rectangular.

It is important to note that the mapping values are not restricted from 0 to1 they can be -200 to 625 (or any values!) This is particularly important for procedural textures (which is a different subject).

There is absolutely nothing wrong with scaling UV’s outside of the UV “square” it has exactly the same result as changing the scale of the mapping node to a value above 1.

Has exactly the same result as:

This is common practice and produces a “tilled” texture, tilling a texture INCREASES the resolution of the texture as it gives you more pixels per face.
Tilled textures are used extensively in all 3d applications.

Edit : If the image is not tillable you will run into seams on the faces that extend outside the UV 0-1 range. In this case after unwrapping and scaling the UV’s together you would have to move the UV’s of each object separately so they fall inside the grid. This would be a pain for 100 objects!

Just read this bit:

It is possible to unwrap hundreds of objects at the same time, it will just take a bit longer to calculate.

This is not a problem.
The UV grid is a “virtual” thing each object can still has its own mapping. The mapping is the important aspect of it not the grid.
Each object still has its own mapping. You can still select a specific object individually and move its UV’s around in the UV editor.

Unless you give each object a unique UVMap name (which is not necessary).
If you have a scene with various separately unwrapped objects, select them all go into edit mode and when you select all the faces you will see all their UV’s piled up on top of each other (overlapping) in the UV editor.

Sorry for all the edits UV Mapping can be a complex subject!
There are addons that add functionality to the UV editor I do not use any so I am not sure if they would help in this case.

1 Like

I’m trying the unwrap all objects at once, and it turns out to be a bit of a nightmare.
It looks promising at first - everything is scaled properly to each other. BUT… if any changes need to be made - like un-rotating parts blender decided to rotate, changing where seams are, any changes at all mean I have to re-do all objects to get the relative scales back. And that means it also wipes out any changes I’ve made to the UV map (like fixing rotations)

As a side note, it packs parts in a way that scatter items of the same object so they are spread out all over the place. Re-packing objects doesn’t work because it re-scales them too.

1 Like

Changing the rotation and position of the islands should not be problematic, in the UV editor if you hover over an island and hit the L key it will select the faces of the island, you can then rotate them and move them about. You can do this with just one object at a time.

If you want to change where the seams are it will be necessary to unwrap the object again, so yes, to keep the scale relationship you will have to unwrap all the objects at once again, (loosing the changed rotations and positions)

You should first make sure all the seams are where you want them to be and then unwrap all the objects at once and correct the rotations.

Edit.
I have just had a look at the UV magic addon (comes with Blender) and there is an option to get the UV’s to scale as you want.

This option in manual mode lets you set the density of the texture based on the mesh size and the texture resolution. It gives you a popup like this to adjust the density/scale I have never used it before but it does seem to do the trick (as long as all your textures have the same resolution)

UVMagic2

You can also do this one object at a time (you would have to set each one to the same density value).

2 Likes