Skip to content

Instantly share code, notes, and snippets.

@noisecrime
Forked from Farfarer/SmoothingAngleFix.cs
Last active August 29, 2015 14:21
Show Gist options
  • Save noisecrime/a2f13fd0aeb8a01ffd8d to your computer and use it in GitHub Desktop.
Save noisecrime/a2f13fd0aeb8a01ffd8d to your computer and use it in GitHub Desktop.
// Place this file into a directory called Editor inside of your Assets directory.
// Models imported after you do that will have:
// - Smoothing Angle seto to 180.
// - Normals set to Import.
// - Tangents set to Calculate.
// - Tangents set to Split Tangents.
// Any models that are already imported can have this applied by selecting them in
// the Project panel, right clicking and selecting "Reimport" from the pop-op menu.
// These are the settings required for using tangent space maps generated by:
// - UnityTSpace xNormal Plugin
// - www.farfarer.com/blog/2012/06/12/unity3d-tangent-basis-plugin-xnormal/
// - Handplane3D's Unity output
// - www.handplane3d.com
class SmoothingAngleFix extends AssetPostprocessor {
function OnPreprocessModel () {
var modelImporter : ModelImporter = (assetImporter as ModelImporter);
// Set Smoothing Angle to 180.
modelImporter.normalImportMode = ModelImporterTangentSpaceMode.Calculate;
modelImporter.normalSmoothingAngle = 180.0;
// Set Normals to Import.
modelImporter.normalImportMode = ModelImporterTangentSpaceMode.Import;
// Set Tangents to Calculate.
modelImporter.tangentImportMode = ModelImporterTangentSpaceMode.Calculate;
// Set Split Tangents to True.
modelImporter.splitTangentsAcrossSeams = true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment