Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug Normals fragmented when FBX exported to Unity with textures from Adobe Susbtance painter.

Discussion in 'Pixyz' started by bjornsyse, Aug 2, 2023.

  1. bjornsyse

    bjornsyse

    Joined:
    Mar 28, 2017
    Posts:
    92
    Hi, I'm trying to troubleshoot this issue we've seen in our pipeline which goes PiXYZ -> Substance painter -> Unity.

    We export a mesh (FBX) from Pixyz, and import it in Substance painter for baking from hipoly mesh and texture painting. We then take those textures, and import them together with the exact same mesh into Unity but can't recreate the look of the mesh as seen in Substance painter. Instead, the normals of the object look fragmented or erroneous.

    However, If we instead EXPORT the mesh from Substance painter and use that mesh together with the baked normal map the mesh looks fine in Unity. All other import settings are harmonized.

    This leads me to either assume Substance painter does something to the mesh or normals upon import, but not declaring quite what. Or if PiXYZ somehow omits something from the FBX.

    Can't really wrap my head around this. Anyone have any ideas? Has anyone seen this too in their workflow?

    I've tried posting on the Adobe forum aswell to see.

    chrome_s0mCH1CmWS.png

    Original FBX with substance textures in Unity, looking bad:

    Unity_j91MWiaqky.png

    Re-exported FBX from substance with substance textures in Unity, looking good.
    Unity_pF7VL8oWi5.png

    Regards
    - Björn
     
  2. laurent-milon

    laurent-milon

    Unity Technologies

    Joined:
    Nov 30, 2022
    Posts:
    14
    Hi @bjornsyse sorry for the late reply.
    Quick question: have you created normals and tangent in Pixyz Studio before exporting as an FBX? MESH menu, then "Create Normals" and "Create Tangents" (or from the api function list).
     
  3. bjornsyse

    bjornsyse

    Joined:
    Mar 28, 2017
    Posts:
    92
    Hi Laurent,

    Yes, I do that via script but I've tried via the menu as well. Does not seem to do any difference.

    Code (python):
    1.  # Create tangents and normals
    2. algo.createNormals([_proxyMesh])
    3. algo.createTangents([_proxyMesh])
     
  4. AxelJacquet

    AxelJacquet

    Unity Technologies

    Joined:
    Oct 18, 2021
    Posts:
    13
    Hello @bjornsyse !
    A few questions for you:
    • How do you import the FBX generated from Pixyz Studio in Unity Editor? Which import parameters do you use?
    • Does it look ok if you import it directly in Unity (without the roundtrip in Substance)?
    • How do you generate the Low Poly model in Studio? Do you bake maps in Studio?
    • After baking and applying the baked maps to the low poly mesh in Substance, do you see the same artifacts?
    • Have you tried reimporting the exported FBX from Painter into Painter or Blender or Studio and seen the same artifacts?
    Feel free to share dummy data so we can try and reproduce the bug on our end.
    Thanks!
     
  5. bjornsyse

    bjornsyse

    Joined:
    Mar 28, 2017
    Posts:
    92
    Hi Axel!

    Here is a snapshot of my import settings. I should say they are the same for both the Pixyz-exported mesh and the Painter-exported mesh. What I'm comparing here is what you mention - one on hand importing mesh directly to Unity from Pixyz. and on the other hand comparing that with the mesh exported from Painter. That's where I see the difference.
    Unity_KHFcAi5p4K.png
    I create the Low poly model in Pixyz using this code summarized:

    Code (CSharp):
    1. # Create a proxy from meshes
    2.         _proxyMesh = algo.proxyMesh(occurrences, voxelSize, ELEMENTS_FILTER)
    3.  
    4.         # Decimates the newly created proxy mesh to optimize polygon count
    5.         algo.decimate([_proxyParent], 0.5, -1, -1, -1, False)
    6.        
    7.         # Create UV maps
    8.         algo.mapUvOnAABB([_proxyParent], False, 100.000000, 0, True)
    9.    
    10.         # This line seems to crash PiXYZ.
    11.         # algo.automaticUVMapping([_proxyMesh], 0, 0.500000000000, -1, True, True)
    12.            
    13.         algo.repackUV([_proxyParent], 0, True, textureSize, padding * 2, True)
    14.         algo.normalizeUV([_proxyParent], 0, -1, False, False)
    15.        
    16.         # Copy UV channel 0 to 1.
    17.         algo.copyUV([_proxyParent], 0, 1)
    18.        
    19.         # Create tangents and normal (for easier baking later)
    20.         algo.createNormals([_proxyParent])
    21.         algo.createTangents([_proxyParent])
    I have the opportunity to bake maps (like normal or ID map (diffuse)) in Pixyz but I resorted to baking all the maps in Painter using the Hipolymesh as reference because I knew I needed to bake certain maps there anyway which Pixyz wont let me bake - and I also got the impression Painter did an overall better job with an easier tweaking interface when baking normals.

    In substance painter, everything looks good without artifacts. The mesh I export from Painter looks good in Unity.

    I've attached a zip file with the files and how to try to reproduce:

    1. I've created a proxy mesh with normals and tangents and UV which I've exported alongsside it's LOD0 original as FBX.
    2. Import Platform_LOD1_fromPixyz.fbx in Painter, and bake texturings using Platform_LOD0_fromPixyz.fbx as reference hi-polymesh.
    3. Apply any material or no materials at all, and export textures.
    4. Also Export the mesh (File -> Export mesh) to Platform_LOD1_fromPainter.fbx from Painter and import both that one and the original Platform_LOD1_fromPixyz.fbx to Unity and apply a material using the exported textures.
    Here are screenshots from Painter:

    Adobe_Substance_3D_Painter_IjH13RQqd0.png

    And pictures from Unity showing the Pixyz mesh first and the Painter mesh second
    Unity_1lCIOUeenX.png
    Unity_ptSBxjxGhW.png

    Regards

    - Björn
     

    Attached Files:

  6. AxelJacquet

    AxelJacquet

    Unity Technologies

    Joined:
    Oct 18, 2021
    Posts:
    13
    Hello @bjornsyse !

    Thank you for providing this information.

    It seems Painter is changing/recreating the normals on the LOD1 when importing it, proabably because it is required by the software to obtain good baking results. Maybe it is possible to prevent that. Do you have any news from Adobe?
    Taking the hypothesis it is possible to disable the normals recomputation/modification by Substance, the way normals are calculated in Studio may not be optimal, and you may have to fiddle a little with the parameters to get a good baking result in Painter.

    Side question I had: why do you use Proxy mesh to create the LOD1 version? I'm just asking because in the example you provided, the polycouny for LOD1 is higher than LOD0. But maybe it's not the case with all your models.
    Anyway, you probably know that decimation (or even retessellate with coarser values) might be a good solution too (and potentially other optimization functions like Hidden Removal)
     
    Last edited: Aug 24, 2023