7
Mirror Modifier: Offset for UVs
Link: http://wiki.polycount.com/wiki/Texture_Baking#UV_Coordinates **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 https://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: https://developer.blender.org/T52226
Mirror Modifier: Offset for UVs
view on imgur.com

Login to comment

Comments(6)

ideasman42 · 3 weeks ago
Good suggestion, added a quick hack - https://developer.blender.org/T52226
1 point reply
lsscpp · 3 weeks ago
flipping the uv or flipping the texture, what is the difference? I already obtain what you ask checking the UV squares under texture
0 points reply
zuorion [OP] · 3 weeks ago
Repeat is more common than mirror. http://wiki.polycount.com/wiki/Texture_Coordinates#UV_Address_Modes 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): http://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.
0 points reply
lsscpp · 3 weeks ago
Oh I see, so the problem happens the moment you apply the modifier. I didn't think of that
0 points reply
zuorion [OP] · 3 weeks ago (edited 3 weeks ago)

i’n not sure did you noticed this, but i wanna use textures outside 0-1 space. To save texture space on some mirrored geometry (gamedev here). And also prevent bakers from baking two times on same pixels, thats why they are outside 0-1 space.

0 points reply
monio4 · 3 weeks ago
Great proposal. I've always did this manually, not convenient at all.
0 points reply
cgstrive · 1 week ago
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.
0 points reply
Choose a category
Upload an image