diff --git a/FinModelUtility/Formats/Dat/src/api/DatModelImporter.cs b/FinModelUtility/Formats/Dat/src/api/DatModelImporter.cs index 51a894e7e..43ee7ca76 100644 --- a/FinModelUtility/Formats/Dat/src/api/DatModelImporter.cs +++ b/FinModelUtility/Formats/Dat/src/api/DatModelImporter.cs @@ -7,6 +7,7 @@ using fin.model.impl; using fin.model.io.importers; using fin.shaders.glsl; +using fin.util.enums; using fin.util.hex; using gx; @@ -200,30 +201,52 @@ private void PopulateFixedFunctionMaterial_( FixedFunctionSource.TEXTURE_ALPHA_0); } + var renderMode = mObj.RenderMode; var material = mObj.Material; - var diffuseRgba = material.DiffuseColor; - var diffuseColor = - colorOps.Multiply( - equations.CreateOrGetColorInput( - FixedFunctionSource.LIGHT_0_COLOR), - equations.CreateColorConstant(diffuseRgba.Rf, - diffuseRgba.Gf, - diffuseRgba.Bf)); - - var ambientRgba = material.AmbientColor; - var ambientColor = - equations.CreateColorConstant(ambientRgba.Rf, - ambientRgba.Gf, - ambientRgba.Bf); - - var lightColor = colorOps.Add(ambientColor, diffuseColor); - - var outputColor = colorOps.Multiply(textureColor, vertexColor); - outputColor = colorOps.Multiply(outputColor, lightColor); - - var outputAlpha = scalarOps.Multiply(textureAlpha, vertexAlpha); - outputAlpha = scalarOps.MultiplyWithConstant(outputAlpha, diffuseRgba.Af); - outputAlpha = scalarOps.MultiplyWithConstant(outputAlpha, material.Alpha); + + var outputColor = textureColor; + + if (renderMode.CheckFlag(RenderMode.VERTEX)) { + outputColor = colorOps.Multiply(outputColor, vertexColor); + } + + // TODO: Is this right?? + if (renderMode.CheckFlag(RenderMode.DIFFUSE)) { + var ambientRgba = material.AmbientColor; + var ambientColor = + equations.CreateColorConstant(ambientRgba.Rf, + ambientRgba.Gf, + ambientRgba.Bf); + var diffuseRgba = material.DiffuseColor; + var diffuseColor = + colorOps.Multiply( + equations.CreateOrGetColorInput( + FixedFunctionSource.LIGHT_0_COLOR), + equations.CreateColorConstant(diffuseRgba.Rf, + diffuseRgba.Gf, + diffuseRgba.Bf)); + + var lightColor = colorOps.Add(ambientColor, diffuseColor); + outputColor = colorOps.Multiply(outputColor, lightColor); + } else if (renderMode.CheckFlag(RenderMode.CONSTANT)) { + var diffuseRgba = material.DiffuseColor; + var diffuseColor = equations.CreateColorConstant(diffuseRgba.Rf, + diffuseRgba.Gf, + diffuseRgba.Bf); + + outputColor = colorOps.Multiply(outputColor, diffuseColor); + } + + var outputAlpha = textureAlpha; + if (renderMode.CheckFlag(RenderMode.ALPHA_VTX)) { + outputAlpha = scalarOps.Multiply(outputAlpha, vertexAlpha); + } + + if (renderMode.CheckFlag(RenderMode.ALPHA_MAT)) { + outputAlpha = + scalarOps.MultiplyWithConstant(outputAlpha, material.Alpha); + } + equations.CreateColorOutput(FixedFunctionSource.OUTPUT_COLOR, outputColor ?? colorOps.Zero);