Skip to content

Commit

Permalink
Fix CPlugMaterial
Browse files Browse the repository at this point in the history
  • Loading branch information
BigBang1112 committed Aug 14, 2024
1 parent e594d70 commit b2e1e93
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Src/GBX.NET/Engines/Plug/CPlugMaterial.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ public partial class CPlugMaterial
{
private CPlug? shader;
[AppliedWithChunk<Chunk0907900D>]
public CPlug? Shader { get => shaderFile?.GetNode(ref shader) ?? shader; set => shader = value; }
public CPlug? Shader { get => shaderFile?.GetNode(ref shader) ?? shader; set => shader = value; } // probably m_Material
private Components.GbxRefTableFile? shaderFile;
public Components.GbxRefTableFile? ShaderFile { get => shaderFile; set => shaderFile = value; }
public CPlug? GetShader(GbxReadSettings settings = default, bool exceptions = false) => shaderFile?.GetNode(ref shader, settings, exceptions) ?? shader;
Expand All @@ -21,7 +21,7 @@ public override void ReadWrite(CPlugMaterial n, GbxReaderWriter rw)
{
rw.NodeRef(ref n.shader, ref n.shaderFile);

if (n.shader is not null && n.shaderFile is not null)
if (n.shader is not null || n.shaderFile is not null)
{
return;
}
Expand Down
36 changes: 35 additions & 1 deletion Src/GBX.NET/Engines/Plug/CPlugMaterialCustom.chunkl
Original file line number Diff line number Diff line change
@@ -1,2 +1,36 @@
CPlugMaterialCustom 0x0903A000
- inherits: CPlug
- inherits: CPlug

0x004
int[]

0x006
Bitmap[] Textures

0x00A
GpuFx[] GpuFxs1
GpuFx[] GpuFxs2

0x00C
BitmapSkip[] SkipSamplers

0x00D
ulong U01
ulong U02
if (U01 & 1) != 0 // SPlugVisibleFilter
short U03
short U04

archive Bitmap
id
int
int
v1+
int
int

archive GpuFx

archive BitmapSkip
id Name
bool
49 changes: 49 additions & 0 deletions Src/GBX.NET/Engines/Plug/CPlugMaterialCustom.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
namespace GBX.NET.Engines.Plug;

public partial class CPlugMaterialCustom
{
[ChunkGenerationOptions(StructureKind = StructureKind.SeparateReadAndWrite)]
public partial class Chunk0903A00A;

[ArchiveGenerationOptions(StructureKind = StructureKind.SeparateReadAndWrite)]
public partial class GpuFx
{
public string U01 { get; set; } = "";
public bool U02 { get; set; }
public float[][] U03 { get; set; } = [];

public void Read(GbxReader r, int v = 0)
{
U01 = r.ReadId();
var count1 = r.ReadInt32();
var count2 = r.ReadInt32();
U02 = r.ReadBoolean();

U03 = new float[count2][];

for (var i = 0; i < count2; i++)
{
U03[i] = r.ReadArray<float>(count1);
}
}

public void Write(GbxWriter w, int v = 0)
{
var count2 = U03.Length;
var count1 = U03.Length > 0 ? U03[0].Length : 0;

w.WriteIdAsString(U01);
w.Write(count1);
w.Write(count2);
w.Write(U02);

for (var i = 0; i < count2; i++)
{
for (var j = 0; j < count1; j++)
{
w.Write(U03[i][j]);
}
}
}
}
}

0 comments on commit b2e1e93

Please sign in to comment.