Skip to content

Commit

Permalink
Mesh Part material checks
Browse files Browse the repository at this point in the history
  • Loading branch information
DeltaDesigns committed Jan 4, 2024
1 parent f0f7ff1 commit 92bbc34
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
7 changes: 6 additions & 1 deletion Tiger/Schema/Entity/EntityModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

using System;
using System.Diagnostics;
using Arithmic;
using Tiger.Schema.Shaders;
Expand Down Expand Up @@ -104,7 +105,11 @@ private List<DynamicMeshPart> GenerateParts(Dictionary<int, Dictionary<int, D2Cl

//We only care about the vertex shader for now for mesh data
//But if theres also no pixel shader then theres no point in adding it
if (dynamicMeshPart.Material is null || dynamicMeshPart.Material.VertexShader is null || dynamicMeshPart.Material.PixelShader is null)
if (dynamicMeshPart.Material is null ||
dynamicMeshPart.Material.VertexShader is null ||
dynamicMeshPart.Material.PixelShader is null ||
dynamicMeshPart.Material.Unk08 != 1 ||
(dynamicMeshPart.Material.Unk20 & 0x8000) != 0)
continue;

dynamicMeshPart.GetAllData(mesh, _tag);
Expand Down
4 changes: 4 additions & 0 deletions Tiger/Schema/Shaders/Material.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public interface IMaterial : ISchema
public uint Unk08 { get; }
public uint Unk10 { get; }
public uint Unk0C { get; } //Seems to be backface culling
public ushort Unk20 { get; }
public IEnumerable<STextureTag> EnumerateVSTextures();
public IEnumerable<STextureTag> EnumeratePSTextures();
public IEnumerable<STextureTag> EnumerateCSTextures();
Expand Down Expand Up @@ -208,6 +209,7 @@ public class Material : Tag<SMaterial_SK>, IMaterial
public uint Unk08 => _tag.Unk08;
public uint Unk10 => _tag.Unk10;
public uint Unk0C => _tag.Unk0C;
public ushort Unk20 => _tag.Unk20;
public ShaderBytecode VertexShader => _tag.VertexShader;
public ShaderBytecode PixelShader => _tag.PixelShader;
public ShaderBytecode ComputeShader => _tag.ComputeShader;
Expand Down Expand Up @@ -260,6 +262,7 @@ public class Material : Tag<SMaterial_BL>, IMaterial
public uint Unk08 => _tag.Unk08;
public uint Unk10 => _tag.Unk10;
public uint Unk0C => _tag.Unk0C;
public ushort Unk20 => _tag.Unk20;
public ShaderBytecode VertexShader => _tag.VertexShader;
public ShaderBytecode PixelShader => _tag.PixelShader;
public ShaderBytecode ComputeShader => _tag.ComputeShader;
Expand Down Expand Up @@ -313,6 +316,7 @@ public class Material : Tag<SMaterial_WQ>, IMaterial
public uint Unk08 => _tag.Unk08;
public uint Unk10 => _tag.Unk10;
public uint Unk0C => _tag.Unk0C;
public ushort Unk20 => _tag.Unk20;
public ShaderBytecode VertexShader => _tag.VertexShader;
public ShaderBytecode PixelShader => _tag.PixelShader;
public ShaderBytecode ComputeShader => _tag.ComputeShader;
Expand Down
9 changes: 6 additions & 3 deletions Tiger/Schema/Shaders/MaterialStructs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ public struct SMaterial_SK
public uint Unk08;
public uint Unk0C;
public uint Unk10;

[SchemaField(0x20)]
public ushort Unk20; // ??
[SchemaField(0x48)]
public ShaderBytecode VertexShader;
[SchemaField(0x50)]
Expand Down Expand Up @@ -52,7 +53,8 @@ public struct SMaterial_BL
public uint Unk08;
public uint Unk0C;
public uint Unk10;

[SchemaField(0x20)]
public ushort Unk20; // ??
[SchemaField(0x58)]
public ShaderBytecode VertexShader;
[SchemaField(0x60)]
Expand Down Expand Up @@ -95,7 +97,8 @@ public struct SMaterial_WQ
public uint Unk08;
public uint Unk0C;
public uint Unk10;

[SchemaField(0x20)]
public ushort Unk20; // ??
[SchemaField(0x70)]
public ShaderBytecode VertexShader;
[SchemaField(0x78)]
Expand Down
16 changes: 16 additions & 0 deletions Tiger/Schema/Static/StaticMeshData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ private List<StaticPart> GenerateParts(Dictionary<int, SStaticMeshPart> staticPa
StaticPart part = new(staticPartEntry);
part.Material = materialMap[i];
part.MaterialType = MaterialType.Opaque;

if (part.Material is null ||
part.Material.VertexShader is null ||
part.Material.PixelShader is null ||
part.Material.Unk08 != 1 ||
(part.Material.Unk20 & 0x8000) != 0)
continue;

part.GetAllData(_tag.Buffers[staticPartEntry.BufferIndex], parent);
parts.Add(part);
}
Expand Down Expand Up @@ -223,6 +231,14 @@ private List<StaticPart> GenerateParts(Dictionary<int, SStaticMeshPart> staticPa
StaticPart part = new StaticPart(staticPartEntry);
part.Material = materialMap[i];
part.MaterialType = MaterialType.Opaque;

if (part.Material is null ||
part.Material.VertexShader is null ||
part.Material.PixelShader is null ||
part.Material.Unk08 != 1 ||
(part.Material.Unk20 & 0x8000) != 0)
continue;

part.GetAllData(mesh, parent);
parts.Add(part);
}
Expand Down

0 comments on commit 92bbc34

Please sign in to comment.