Skip to content

Commit 9d511e9

Browse files
pandaGaumeDrigax
andauthored
Keep emissive factor to [0,1] (#920)
GetSelfIllumColor(0, false) is returning value in range of [0,PI] so divide the result by PI to get value of [0,1] range Co-authored-by: Nicholas Barlow <whoisdrigax@gmail.com>
1 parent 0785b04 commit 9d511e9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

3ds Max/Max2Babylon/Exporter/BabylonExporter.Material.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ namespace Max2Babylon
1919
{
2020
partial class BabylonExporter
2121
{
22+
// use as scale for GetSelfIllumColor to convert [0,PI] to [O,1]
23+
private const float selfIllumScale = (float)(1.0 / Math.PI);
24+
2225
readonly List<IIGameMaterial> referencedMaterials = new List<IIGameMaterial>();
2326
Dictionary<ClassIDWrapper, IMaxMaterialExporter> materialExporters;
2427

@@ -208,7 +211,7 @@ private void ExportStandardMaterial(IIGameMaterial materialNode, IIPropertyConta
208211
babylonMaterial.specularPower = materialNode.MaxMaterial.GetShininess(0, false) * 256;
209212
babylonMaterial.emissive =
210213
isSelfIllumColor
211-
? materialNode.MaxMaterial.GetSelfIllumColor(0, false).ToArray()
214+
? materialNode.MaxMaterial.GetSelfIllumColor(0, false).Scale(selfIllumScale).ToArray()
212215
: materialNode.MaxMaterial.GetDiffuse(0, false).Scale(materialNode.MaxMaterial.GetSelfIllum(0, false)); // compute the pre-multiplied emissive color
213216

214217
// If Self-Illumination color checkbox is checked
@@ -433,9 +436,10 @@ private void ExportPhysicalMaterial(IIGameMaterial materialNode, IIPropertyConta
433436
babylonMaterial.roughness = 1 - babylonMaterial.roughness;
434437
}
435438

439+
436440
// Self illumination is computed from emission color, luminance, temperature and weight
437441
babylonMaterial.emissive = materialNode.MaxMaterial.GetSelfIllumColorOn(0, false)
438-
? materialNode.MaxMaterial.GetSelfIllumColor(0, false).ToArray()
442+
? materialNode.MaxMaterial.GetSelfIllumColor(0, false).Scale(selfIllumScale).ToArray()
439443
: materialNode.MaxMaterial.GetDiffuse(0, false).Scale(materialNode.MaxMaterial.GetSelfIllum(0, false));
440444
}
441445
else

0 commit comments

Comments
 (0)