Lighting bug with mirror flipped UVs

(Photonmammoth) #1

Hey guys! So something I found out through a bunch of frustrating trial and error was this: I had horrendous, different lighting between a specific set of UV islands on my shield I uploaded, and couldn't figure out why. After restructuring my UVs, it seemed to have come down to flipped UV islands in 3DS Max. In Substance Painter the textures looked fine, but in Sketchfab the lighting on ONLY the UV islands that had been flipped goes haywire. Anyone know why this might be?
photos can be found in the link to the forum post I listed above

(Shaderbytes) #2

Well you rectified the problem now before anyone could have a look?

It would be helpful to see the normal map that was baked previously with the flipped islands issue.

(Photonmammoth) #3

Moreover I wanted to post here to see if there was any way to get rid of this lighting error with mirror flipped UV islands, cause it can be very helpful in the unwrap process and in the models I upload in the future I'd like to do that.

Here's an image of the normals when some UV islands were flipped

and here's the one without flipped islands

(Shaderbytes) #4

sorry not worded well on my side i meant to see the normal map on the model ( and see the error it produced ).

Anyway im sure it can be reproduced in a simple test. I will do one shortly and upload and see what is happening

(Photonmammoth) #5

I'm also gonna try baking normals on the flipped island version of my mesh in xNormal cause I think Substance Painter has been having some issues with normal map baking as of late (just judging from what I've been reading on their forums/discord)

(Stephomi) #6

Go in the sketchfab editor->material tab -> normalmap channel -> uncheck flipy ?

(Shaderbytes) #7

Hey Stephomi , he mentioned it had issues only on some of the uv islands , namely the ones he had mirrored. So it is not an issue of y swizzle. Anyway not sure if it is something on your end or something wrong in the OP's map baking software.

(Shaderbytes) #8

@stephomi @photonmammoth I just tested this and found no issues , look here :

simple plane one loop cut down the middle. In version one I baked a high to low with standard uv unwrapping. In version 2 I selected the uv for the one half of the plane and inverted along the x axis. I rebaked a high to low on this , the proof is evident in the maps , uploaded both and compared and found no issues.

map of first sample :

map of second sample :

(Stephomi) #9

I'm just refering to the model uploaded on sketchfab :

"flip Y" should be ticked off in that case.

As for the "flipped UV islands" issue, the model is not on sketchfab so I can't debug.
I'd say it's a tangent/normal issue though, if possible they should be exported from substance when uploading to sketchfab.

(Photonmammoth) #10

@shaderbytes @stephomi Unchecking flip y actually helped a TON! Here's an example of a previous version of the shield I had uploaded with a lot more flipped islands in the unwrap, with a more obvious material that differentiates the seams and messes with lighting

and as for the exporting from Substance, what exactly do you mean stephomi? When I export from there to sketchfab it should be exporting all the maps should I perhaps export it as regular Document Channels + Normal + AO and then toss that together into a .zip with my fbx?

(Shaderbytes) #11

yeah this must be an error in the baking process in substance for flipped uv islands because as seen I tested this now myself via some baking in blender on flipped uv islands and there was no issue.

EDIT it looks like both those images are the same model and the error only displays when not swizzled .. interesting. Another interesting aspect is that the default setting for normal maps in substance is the same as the default for sketchfab which is DirectX version, meaning you should not have to disable the swizzle., unless you have gone into the preferences of substance and opted for OpenGL manually?

(Photonmammoth) #12

I did another test export from Substance to Sketchfab ensuring that DirectX was on (which it should've been as the preset for the project I was using was UE4, which uses DirectX) by going to Edit > Project Configuration, reselecting DirectX and loading in my low poly, and then exporting. The issue of flipped normals still remained!

(Photonmammoth) #14

Here's a test export I did the manual way like I mentioned with the zip and the model (although it seems I may have goofed on my other materials with this one, the concept is still there on the metal)

The normals are oriented the correct direction with the flip -Y checked.

I'll bring this up with the guys on the Allegorithmic forums as well

(Stephomi) #15

Normals and tangents are computed once and for all when you upload the mesh, if they are already provided we re-use the existing ones. If you have issues with normalmap, it's best to ensure the tangents are serialised inside the file (fbx, obj) otherwise it's possible we won't recompute them exactly the same.
I forgot that the sketchfab substance exporter doesn't give any controls on whether they are exported or not (but they are exported by default though), Sorry about that!

I'm not sure it makes any differences but we compute the tangent frame per pixel (like UE4) :

small tip: a quick way to debug normal/tangent/normalmap is to switch to matcap in sketchfab with the "metal" matcap.
Alternatively, switching to a fully metal + fully gloss (rough 0) material but that's more click.

Edit: actually, I wrote a mistake : obj doesn't support tangents so we'll always compute them if we receive an obj

(Stephomi) #16

As for flipY.
Actually the issue is on our side, substance is expecting sketchfab to use opengl nmap by default (it was our default value at the time).
At some point we changed our default value to directX but we forgot to handle the case of substance painter exporter.
So in a nutshell : we'll fix the issue and next time you are using the substance painter sketchfab exporter the flipY will be ticked off by default.

Note that substance actually converts the normalmap depending of the exporter presets so if you create a project :
- with unity preset (opengl) and export with unreal preset (directx), the nmap will be flipped
- with unreal preset (directx) and export with unity preset (opengl), the nmap will be flipped
- with unity preset (opengl) and export with sketchfab (opengl*), the nmap won't be flipped
- with unreal preset (directx) and export with sketchfab (opengl*), the nmap will be flipped

opengl* should be opengl but is currently directx because of the bug

So basically for now, the only work directly in sketchfab is when you have the wrong rendering in substance :slight_smile:
Sorry for the inconvenience, we'll try to fix that quickly

(Photonmammoth) #17

This is all lovely information! I'll be sure to keep my files in fbx (which is the norm for me thankfully) and can rest assured that the UE4 preset is gonna work just fine for the scenarios I need.

Nice troubleshooting tip with the metal matcap! That'll be of great help in the future :).

You guys are awesome! I look forward to the fix, but changing one checkbox, especially when I'm already gonna be mucking around in the 3D settings anyway, is no big deal :smile:
<3 much love

(Stephomi) #19

The flipY fix is live, so in theory if you upload from the substance exporter, it should work fine now.