VRChat/Substance Painter

From VR Wiki
Revision as of 20:54, 5 September 2021 by N3X15 (talk | contribs) (→‎Exporting for Unity)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Substance Painter is great software for painting textures and baking AO. However, getting it to work with Unity can be a massive pain in the ass.

Substance Painter
Software
MSRP
USD $150
Sellers
$149.99


So, here's how.

Exporting From

Blender

  1. Install CATS.
  2. Ensure you've tweaked the UV atlas as best you can, as you will be unable to use the Auto-Unwrap feature in Substance (rigs get nuked).
  3. Export as an FBX using CATS.

Importing Meshes

  1. Open Substance.
  2. Select File > New...
    1. Select the Unity HD Render Pipeline (Metallic Standard) template. A pipeline for specular is apparently missing.
    2. Select the FBX or OBJ you want.
    3. Set Document Resolution to as much as your PC will suffer. I personally use 4096 for everything.
    4. Make absolutely certain you're using OpenGL Normal Map Format.
    5. If your atlas is screwed up and you're OK with nuking rigs/etc, go ahead and check Auto-Unwrap.
      • Seams: Will automatically recalculate all seams if set to Recompute All. Recommend leaving this on Generate Only Missing Data unless the model is turbofucked.
      • UV Islands: UV Islands are the chunks of mesh thrown onto the atlas. This setting affects whether Substance will automatically re-generate islands (Recompute) or use existing ones.
      • Packing: Packing is how well the islands are crammed onto the atlas so they all fit. Substance does an excellent job with this, so if you can, Recompute all. (Don't use for anything with rigging)
    6. Smack OK and wait.
  3. Important: Press CTRL+SHIFT+B to bring up the baking window. so you can bake AOs and normals. These are used in Smart Materials.
    1. In Common Settings:
      1. Change Output Size to something like half of your document resolution. (2048 in 4096 documents, etc)
      2. Change Antialiasing to as high as your computer will suffer. I use Subsampling 8x8. This will significantly impact baking time.
      3. Change Match to By Mesh Name so you get fewer weird ray-tracing issues caused by intersecting with clothing or whatnot.
    2. Hit OK to Bake. Go grab a coke.

Exporting for Unity

  1. If you've Auto-Unwrapped anything, export the mesh as an OBJ.
    1. Select File > Export Mesh...
    2. Use Without displacement/tesselation.
    3. Ensure Apply triangulation is checked.
  2. Select File > Export Textures...
  3. First, we need to make a Unity 2018 output template. If you've already done this, skip it.
    1. Go to the Output Templates tab.
    2. Press the + button at the top of the left pane to add a new template.
    3. Right-click new_export_template.
    4. Rename it to Unity HD Render Pipeline (2018).
    5. Now we'll make the Albedo layer texture.
      1. Click the RGB+A button at the top of the center pane to create a new RGB+A layer.
      2. Rename RGB Alpha to $mesh_$textureSet_Albedo.
      3. Drag Base Color from the columns in the pane on the right to the pad labelled RGB.
      4. Drag Opacity to the A (Alpha) pad.
      5. Ensure the layer is set to be an 8-bit PNG.
    6. Now for the Metallic layer.
      1. Create an R+G+B+A layer.
      2. Name it $mesh_$textureSet_Metallic.
      3. Bind Metallic to the R (Red) channel pad.
      4. Bind Mixed AO to the G (Green) channel.
      5. Bind Height to the B (Blue) channel.
      6. Bind Glossiness to the A (Alpha) channel.
      7. Ensure it's an 8-bit PNG.
    7. To make the Normal layer:
      1. Create an RGB layer.
      2. Rename it to $mesh_$textureSet_Normal.
      3. Bind Normal OpenGL to the RGB channels.
      4. Change it to a 16-bit PNG.
    8. For the Emissive layer:
      1. Create an RGB layer.
      2. Rename it to $mesh_$textureSet_Emissive.
      3. Bind Emissive to the RGB channels.
      4. Ensure it's an 8-bit PNG.
    9. Finally, for the Occlusion layer:
      1. Create a Gray layer.
      2. Rename it to $mesh_textureSet_Occlusion.
      3. Bind Ambient Occlusion to the Gr (grayscale) channel.
      4. Ensure it's an 8-bit PNG.
  4. Click back to the Settings tab.
  5. Change Output directory to wherever you want your textures. Recommended: [Avatar]/Textures.
  6. Change Output template to Unity HD Render Pipeline (2018).
  7. Change File Type to png / 16 bits.
  8. Ensure Size is left at Based on each Texture Set's size.
  9. Ensure Padding is left at Dilation Infinite.
  10. Click Save Settings and do not panic when the dialog closes.
  11. Save your project. Recommended: [Avatar]/Substance/[Avatar].spp
  12. Select File > Export Textures... again.
  13. Hit Export.
Our output template for Unity 2018.

Importing Textures into Unity

  1. Select your mesh in Assets.
    • If you used Auto-Unwrap, use the one you exported from Substance..
  2. Open the Materials tab.
  3. Create a folder for materials. Recommended: [Avatar]/Materials.
  4. Select all the *_Normal textures in your textures folder.
  5. Change Texture Type to Normal map.
  6. Select all your textures.
  7. In the crunch settings box:
    1. Set max size to 4096.
    2. Use Normal Quality compression.
    3. Check Use Crunch Compression.
    4. Set Compressor Quality to 90ish.
  8. Create a new Material to replace a material on your avatar. You will have to do this for every material.
    1. Click the lock button at the top of the inspector so you don't move around. You'll thank me later.
    2. Drag the matching _Albedo texture to the box to the left of the Albedo label.
    3. Similarly, map _Metallic to Metallic.
    4. Map _Normal to Normal.
    5. Map _Occlusion to Occlusion.
    6. If you have an emission layer, check Emission.
      1. Map _Emission to the Emission Color.
    7. If you have Opacity in your albedo, fiddle with Rendering Mode until it looks OK.