mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-08-22 02:24:57 -05:00
suppress unnecessary diffs
This commit is contained in:
@@ -10,8 +10,7 @@ namespace UniVRM10
|
||||
{
|
||||
public static class BuiltInVrm10MToonMaterialExporter
|
||||
{
|
||||
public static bool TryExportMaterialAsMToon(Material src, ITextureExporter textureExporter,
|
||||
out glTFMaterial dst)
|
||||
public static bool TryExportMaterialAsMToon(Material src, ITextureExporter textureExporter, out glTFMaterial dst)
|
||||
{
|
||||
if (src.shader.name != MToon10Meta.UnityShaderName)
|
||||
{
|
||||
@@ -40,10 +39,8 @@ namespace UniVRM10
|
||||
|
||||
// Lighting
|
||||
dst.pbrMetallicRoughness = new glTFPbrMetallicRoughness();
|
||||
dst.pbrMetallicRoughness.baseColorFactor =
|
||||
context.BaseColorFactorSrgb.ToFloat4(ColorSpace.sRGB, ColorSpace.Linear);
|
||||
var baseColorTextureIndex = textureExporter.RegisterExportingAsSRgb(context.BaseColorTexture,
|
||||
context.AlphaMode != MToon10AlphaMode.Opaque);
|
||||
dst.pbrMetallicRoughness.baseColorFactor = context.BaseColorFactorSrgb.ToFloat4(ColorSpace.sRGB, ColorSpace.Linear);
|
||||
var baseColorTextureIndex = textureExporter.RegisterExportingAsSRgb(context.BaseColorTexture, context.AlphaMode != MToon10AlphaMode.Opaque);
|
||||
if (baseColorTextureIndex != -1)
|
||||
{
|
||||
dst.pbrMetallicRoughness.baseColorTexture = new glTFMaterialBaseColorTextureInfo
|
||||
@@ -51,10 +48,8 @@ namespace UniVRM10
|
||||
index = baseColorTextureIndex,
|
||||
};
|
||||
}
|
||||
|
||||
mtoon.ShadeColorFactor = context.ShadeColorFactorSrgb.ToFloat3(ColorSpace.sRGB, ColorSpace.Linear);
|
||||
var shadeColorTextureIndex =
|
||||
textureExporter.RegisterExportingAsSRgb(context.ShadeColorTexture, needsAlpha: false);
|
||||
var shadeColorTextureIndex = textureExporter.RegisterExportingAsSRgb(context.ShadeColorTexture, needsAlpha: false);
|
||||
if (shadeColorTextureIndex != -1)
|
||||
{
|
||||
mtoon.ShadeMultiplyTexture = new TextureInfo
|
||||
@@ -62,7 +57,6 @@ namespace UniVRM10
|
||||
Index = shadeColorTextureIndex,
|
||||
};
|
||||
}
|
||||
|
||||
var normalTextureIndex = textureExporter.RegisterExportingAsNormal(context.NormalTexture);
|
||||
if (normalTextureIndex != -1)
|
||||
{
|
||||
@@ -72,10 +66,8 @@ namespace UniVRM10
|
||||
scale = context.NormalTextureScale,
|
||||
};
|
||||
}
|
||||
|
||||
mtoon.ShadingShiftFactor = context.ShadingShiftFactor;
|
||||
var shadingShiftTextureIndex =
|
||||
textureExporter.RegisterExportingAsLinear(context.ShadingShiftTexture, needsAlpha: false);
|
||||
var shadingShiftTextureIndex = textureExporter.RegisterExportingAsLinear(context.ShadingShiftTexture, needsAlpha: false);
|
||||
if (shadingShiftTextureIndex != -1)
|
||||
{
|
||||
mtoon.ShadingShiftTexture = new ShadingShiftTextureInfo
|
||||
@@ -84,7 +76,6 @@ namespace UniVRM10
|
||||
Scale = context.ShadingShiftTextureScale,
|
||||
};
|
||||
}
|
||||
|
||||
mtoon.ShadingToonyFactor = context.ShadingToonyFactor;
|
||||
|
||||
// GI
|
||||
@@ -99,10 +90,8 @@ namespace UniVRM10
|
||||
UniGLTF.glTF_KHR_materials_emissive_strength.Serialize(ref dst.extensions, maxColorComponent);
|
||||
emissiveFactor /= maxColorComponent;
|
||||
}
|
||||
|
||||
dst.emissiveFactor = emissiveFactor.ToFloat3(ColorSpace.Linear, ColorSpace.Linear);
|
||||
var emissiveTextureIndex =
|
||||
textureExporter.RegisterExportingAsSRgb(context.EmissiveTexture, needsAlpha: false);
|
||||
var emissiveTextureIndex = textureExporter.RegisterExportingAsSRgb(context.EmissiveTexture, needsAlpha: false);
|
||||
if (emissiveTextureIndex != -1)
|
||||
{
|
||||
dst.emissiveTexture = new glTFMaterialEmissiveTextureInfo
|
||||
@@ -122,12 +111,10 @@ namespace UniVRM10
|
||||
};
|
||||
}
|
||||
|
||||
mtoon.ParametricRimColorFactor =
|
||||
context.ParametricRimColorFactorSrgb.ToFloat3(ColorSpace.sRGB, ColorSpace.Linear);
|
||||
mtoon.ParametricRimColorFactor = context.ParametricRimColorFactorSrgb.ToFloat3(ColorSpace.sRGB, ColorSpace.Linear);
|
||||
mtoon.ParametricRimFresnelPowerFactor = context.ParametricRimFresnelPowerFactor;
|
||||
mtoon.ParametricRimLiftFactor = context.ParametricRimLiftFactor;
|
||||
var rimMultiplyTextureIndex =
|
||||
textureExporter.RegisterExportingAsSRgb(context.RimMultiplyTexture, needsAlpha: false);
|
||||
var rimMultiplyTextureIndex = textureExporter.RegisterExportingAsSRgb(context.RimMultiplyTexture, needsAlpha: false);
|
||||
if (rimMultiplyTextureIndex != -1)
|
||||
{
|
||||
mtoon.RimMultiplyTexture = new TextureInfo
|
||||
@@ -135,14 +122,12 @@ namespace UniVRM10
|
||||
Index = rimMultiplyTextureIndex,
|
||||
};
|
||||
}
|
||||
|
||||
mtoon.RimLightingMixFactor = context.RimLightingMixFactor;
|
||||
|
||||
// Outline
|
||||
mtoon.OutlineWidthMode = ExportOutlineWidthMode(context.OutlineWidthMode);
|
||||
mtoon.OutlineWidthFactor = context.OutlineWidthFactor;
|
||||
var outlineWidthMultiplyTextureIndex =
|
||||
textureExporter.RegisterExportingAsLinear(context.OutlineWidthMultiplyTexture, needsAlpha: false);
|
||||
var outlineWidthMultiplyTextureIndex = textureExporter.RegisterExportingAsLinear(context.OutlineWidthMultiplyTexture, needsAlpha: false);
|
||||
if (outlineWidthMultiplyTextureIndex != -1)
|
||||
{
|
||||
mtoon.OutlineWidthMultiplyTexture = new TextureInfo
|
||||
@@ -150,13 +135,11 @@ namespace UniVRM10
|
||||
Index = outlineWidthMultiplyTextureIndex,
|
||||
};
|
||||
}
|
||||
|
||||
mtoon.OutlineColorFactor = context.OutlineColorFactorSrgb.ToFloat3(ColorSpace.sRGB, ColorSpace.Linear);
|
||||
mtoon.OutlineLightingMixFactor = context.OutlineLightingMixFactor;
|
||||
|
||||
// UV Animation
|
||||
var uvAnimationMaskTextureIndex =
|
||||
textureExporter.RegisterExportingAsLinear(context.UvAnimationMaskTexture, needsAlpha: false);
|
||||
var uvAnimationMaskTextureIndex = textureExporter.RegisterExportingAsLinear(context.UvAnimationMaskTexture, needsAlpha: false);
|
||||
if (uvAnimationMaskTextureIndex != -1)
|
||||
{
|
||||
mtoon.UvAnimationMaskTexture = new TextureInfo
|
||||
@@ -164,7 +147,6 @@ namespace UniVRM10
|
||||
Index = uvAnimationMaskTextureIndex,
|
||||
};
|
||||
}
|
||||
|
||||
mtoon.UvAnimationScrollXSpeedFactor = context.UvAnimationScrollXSpeedFactor;
|
||||
{
|
||||
// Coordinate Conversion
|
||||
@@ -173,8 +155,7 @@ namespace UniVRM10
|
||||
}
|
||||
// Speed unit Conversion
|
||||
const float rotationPerSecToRadianPerSec = Mathf.PI * 2f;
|
||||
mtoon.UvAnimationRotationSpeedFactor =
|
||||
context.UvAnimationRotationSpeedFactor * rotationPerSecToRadianPerSec;
|
||||
mtoon.UvAnimationRotationSpeedFactor = context.UvAnimationRotationSpeedFactor * rotationPerSecToRadianPerSec;
|
||||
|
||||
// Texture Transforms
|
||||
var scale = context.TextureScale;
|
||||
|
||||
Reference in New Issue
Block a user