Skip to content

Commit

Permalink
Fixed a stupid issue where GameCube models actually aren't meant to u…
Browse files Browse the repository at this point in the history
…pdate the alpha channel.
  • Loading branch information
MeltyPlayer committed Jul 5, 2024
1 parent 57b761a commit 55c9fd0
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ public class MergedMaterialPrimitivesAcrossMeshesRenderer : IDisposable {
this.material_?.DepthMode ?? DepthMode.USE_DEPTH_BUFFER,
this.material_?.DepthCompareType ??
DepthCompareType.LEqual);
GlUtil.SetChannelUpdateMask(this.material_?.UpdateColorChannel ?? true,
this.material_?.UpdateAlphaChannel ?? true);

this.bufferRenderer_.Render();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ public class MergedMaterialPrimitivesByMeshRenderer : IDisposable {
this.material_?.DepthMode ?? DepthMode.USE_DEPTH_BUFFER,
this.material_?.DepthCompareType ??
DepthCompareType.LEqual);
GlUtil.SetChannelUpdateMask(this.material_?.UpdateColorChannel ?? true,
this.material_?.UpdateAlphaChannel ?? true);

this.bufferRenderer_.Render();
}
Expand Down
28 changes: 28 additions & 0 deletions FinModelUtility/Fin/Fin.Ui/src/rendering/gl/util/GlUtil_Channel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Runtime.CompilerServices;

using OpenTK.Graphics.OpenGL;

namespace fin.ui.rendering.gl;

public partial class GlState {
public bool UpdateColorChannel { get; set; } = true;
public bool UpdateAlphaChannel { get; set; } = true;
}

public static partial class GlUtil {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void SetChannelUpdateMask(bool updateColorChannel,
bool updateAlphaChannel) {
if (GlUtil.currentState_.UpdateColorChannel == updateColorChannel &&
GlUtil.currentState_.UpdateAlphaChannel == updateAlphaChannel) {
return;
}

GlUtil.currentState_.UpdateColorChannel = updateColorChannel;
GlUtil.currentState_.UpdateAlphaChannel = updateAlphaChannel;
GL.ColorMask(updateColorChannel,
updateColorChannel,
updateColorChannel,
updateAlphaChannel);
}
}
7 changes: 5 additions & 2 deletions FinModelUtility/Fin/Fin/src/model/MaterialInterfaces.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;

Expand Down Expand Up @@ -66,7 +67,6 @@ public enum DepthCompareType {
Never,
}


[GenerateReadOnly]
public partial interface IMaterial {
string? Name { get; set; }
Expand All @@ -82,6 +82,9 @@ public partial interface IMaterial {
float Shininess { get; set; }

TransparencyType TransparencyType { get; set; }

bool UpdateColorChannel { get; set; }
bool UpdateAlphaChannel { get; set; }
}

[GenerateReadOnly]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,8 @@ private abstract class BMaterialImpl : IMaterial {

public TransparencyType TransparencyType { get; set; }
= TransparencyType.MASK;

public bool UpdateColorChannel { get; set; } = true;
public bool UpdateAlphaChannel { get; set; } = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public partial class GxFixedFunctionMaterial {
GxCullMode.All => CullingMode.SHOW_NEITHER,
_ => throw new ArgumentOutOfRangeException(),
};
material.UpdateAlphaChannel = false;

var depthFunction = populatedMaterial.DepthFunction;
material.DepthMode =
Expand Down

0 comments on commit 55c9fd0

Please sign in to comment.