← All ideas
  • Published 19 Nov 2018

Mirror Modifier: Offset for UVs

Edit: This feature have been implemented and it is in master. developer.blender.org/rB1c5f5fb95f13

Link: wiki.polycount.com/wiki/Texture_Baking

Why? In gamedev it is common to reuse same texture space. So on models that are symmetrical we generally want to use UVs that refers to same texture's pixels. But if we leave UVs as they are after applying mirror modifier while baking we can encounter artifacts because there are multiple triangles on same spot. Why not just disable mirror for baking? When mirrored mesh is not merging there is no problem. We can turn off mirror. But when vertices at center are merged, their normals are a bit different, so it will cause seam in eg. baked normal maps. So what can be done? Normal map baking tools only capture details within the 0-1 UV square, any UV bits outside this area are ignored. Only one copy of the forward-facing UVs should remain in the 0-1 UV square at baking time. If the mesh uses overlapping UVs, this will likely cause artifacts to appear in the baked map, since the baker will try render each UV shell into the map. Before baking, it's best to move all the overlaps and mirrored parts outside the 0-1 square. This simple hack allows to selectable disable certain UVs from baking without need to implement other kind of baking limitation. It is industry standard. In 2.79 there is change: "Mirror Modifier: add offsets for mirrored UVs. " (via developer.blender.org/T47436 ) Isin't that enough? Well, almost. If we set eg. U mirroring point to 1, we will have all mirrored UV outside 0-1, so baking will now can be done fawless. But this in not perfect solution. Those UVs are also flipped, and in 99% texture beyond 0-1 is just repeated. So mirrored mesh have wrong textures applied. If you move all the overlaps and mirrored bits exactly 1 UV unit (any whole number will do), then you can leave them there after the bake and they will still be mapped correctly. You can move them back if you want, it doesn't matter to most game engines. Why not just translate/mirror them by hand? This is what i currently do. But often i want to fix something on model, and re-bake. And it would be time saver if i wouldn't have to do it manually every time.

2.79 - mirror + offset UVs What i want - add option fo just offset (translate) mirrored UVs

Task: developer.blender.org/T52226

DFCfG4q.png

100%

Development Status: Done

Upvote 5 Downvote 0
zuorion
19 Nov 2018

6 Comments

campbell

Good suggestion, added a quick hack - developer.blender.org/T52226

1
jyriunt

For whoever does not have patience and can make their own builds, you can modify MOD_Mirror.c ( dmloopuv->uv[0] = 1.0f + dmloopuv->uv[0]; // added +1.0f. Please also consider that this should also apply to ARRAY MODIFIER. I have been using it in production for over half a year now. It really is a must.

moniewski

Great proposal. I've always did this manually, not convenient at all.

lsscpp

flipping the uv or flipping the texture, what is the difference? I already obtain what you ask checking the UV squares under texture

zuorion Author

Repeat is more common than mirror. wiki.polycount.com/wiki/Texture_Coordinates

Eg. Substance painter uses repeat and it can't be changed. In UE4 repeat is default (it can be changed), and in Unity as far as i can see it can't. Even in Blender repeat it is default setting, and you can't change it (at least in most places - i can see that option only in interinal): i.imgur.com/2N4PDW3.png

Currently i have to apply mirror and by hand move all mirrored UVs to correct place. Witch is not so handy when i have to do this quite often.

lsscpp

Oh I see, so the problem happens the moment you apply the modifier. I didn't think of that