Add basis for iw4 techset dumping

This commit is contained in:
Jan 2022-03-23 13:45:01 +01:00
parent 9009543c58
commit 66b62611f3
10 changed files with 258 additions and 4 deletions

View File

@ -938,6 +938,62 @@ namespace IW4
MaterialPass passArray[1];
};
enum MaterialTechniqueType
{
TECHNIQUE_DEPTH_PREPASS = 0x0,
TECHNIQUE_BUILD_FLOAT_Z = 0x1,
TECHNIQUE_BUILD_SHADOWMAP_DEPTH = 0x2,
TECHNIQUE_BUILD_SHADOWMAP_COLOR = 0x3,
TECHNIQUE_UNLIT = 0x4,
TECHNIQUE_EMISSIVE = 0x5,
TECHNIQUE_EMISSIVE_DFOG = 0x6,
TECHNIQUE_EMISSIVE_SHADOW = 0x7,
TECHNIQUE_EMISSIVE_SHADOW_DFOG = 0x8,
TECHNIQUE_LIT_BEGIN = 0x9,
TECHNIQUE_LIT = 0x9,
TECHNIQUE_LIT_DFOG = 0xA,
TECHNIQUE_LIT_SUN = 0xB,
TECHNIQUE_LIT_SUN_DFOG = 0xC,
TECHNIQUE_LIT_SUN_SHADOW = 0xD,
TECHNIQUE_LIT_SUN_SHADOW_DFOG = 0xE,
TECHNIQUE_LIT_SPOT = 0xF,
TECHNIQUE_LIT_SPOT_DFOG = 0x10,
TECHNIQUE_LIT_SPOT_SHADOW = 0x11,
TECHNIQUE_LIT_SPOT_SHADOW_DFOG = 0x12,
TECHNIQUE_LIT_OMNI = 0x13,
TECHNIQUE_LIT_OMNI_DFOG = 0x14,
TECHNIQUE_LIT_OMNI_SHADOW = 0x15,
TECHNIQUE_LIT_OMNI_SHADOW_DFOG = 0x16,
TECHNIQUE_LIT_INSTANCED = 0x17,
TECHNIQUE_LIT_INSTANCED_DFOG = 0x18,
TECHNIQUE_LIT_INSTANCED_SUN = 0x19,
TECHNIQUE_LIT_INSTANCED_SUN_DFOG = 0x1A,
TECHNIQUE_LIT_INSTANCED_SUN_SHADOW = 0x1B,
TECHNIQUE_LIT_INSTANCED_SUN_SHADOW_DFOG = 0x1C,
TECHNIQUE_LIT_INSTANCED_SPOT = 0x1D,
TECHNIQUE_LIT_INSTANCED_SPOT_DFOG = 0x1E,
TECHNIQUE_LIT_INSTANCED_SPOT_SHADOW = 0x1F,
TECHNIQUE_LIT_INSTANCED_SPOT_SHADOW_DFOG = 0x20,
TECHNIQUE_LIT_INSTANCED_OMNI = 0x21,
TECHNIQUE_LIT_INSTANCED_OMNI_DFOG = 0x22,
TECHNIQUE_LIT_INSTANCED_OMNI_SHADOW = 0x23,
TECHNIQUE_LIT_INSTANCED_OMNI_SHADOW_DFOG = 0x24,
TECHNIQUE_LIT_END = 0x25,
TECHNIQUE_LIGHT_SPOT = 0x25,
TECHNIQUE_LIGHT_OMNI = 0x26,
TECHNIQUE_LIGHT_SPOT_SHADOW = 0x27,
TECHNIQUE_FAKELIGHT_NORMAL = 0x28,
TECHNIQUE_FAKELIGHT_VIEW = 0x29,
TECHNIQUE_SUNLIGHT_PREVIEW = 0x2A,
TECHNIQUE_CASE_TEXTURE = 0x2B,
TECHNIQUE_WIREFRAME_SOLID = 0x2C,
TECHNIQUE_WIREFRAME_SHADED = 0x2D,
TECHNIQUE_DEBUG_BUMPMAP = 0x2E,
TECHNIQUE_DEBUG_BUMPMAP_INSTANCED = 0x2F,
TECHNIQUE_COUNT
};
struct MaterialTechniqueSet
{
const char* name;

View File

@ -0,0 +1,12 @@
#include "AssetDumperPixelShader.h"
using namespace IW4;
bool AssetDumperPixelShader::ShouldDump(XAssetInfo<MaterialPixelShader>* asset)
{
return true;
}
void AssetDumperPixelShader::DumpAsset(AssetDumpingContext& context, XAssetInfo<MaterialPixelShader>* asset)
{
}

View File

@ -0,0 +1,14 @@
#pragma once
#include "Dumping/AbstractAssetDumper.h"
#include "Game/IW4/IW4.h"
namespace IW4
{
class AssetDumperPixelShader final : public AbstractAssetDumper<MaterialPixelShader>
{
protected:
bool ShouldDump(XAssetInfo<MaterialPixelShader>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<MaterialPixelShader>* asset) override;
};
}

View File

@ -0,0 +1,99 @@
#include "AssetDumperTechniqueSet.h"
#include <sstream>
#include "Dumping/AbstractTextDumper.h"
using namespace IW4;
namespace IW4
{
class TechniqueDumpingZoneState final : public IZoneAssetDumperState
{
std::set<const MaterialTechnique*> m_dumped_techniques;
public:
bool ShouldDumpTechnique(const MaterialTechnique* technique)
{
if (m_dumped_techniques.find(technique) != m_dumped_techniques.end())
return false;
m_dumped_techniques.emplace(technique);
return true;
}
};
class TechniqueFileWriter : public AbstractTextDumper
{
public:
explicit TechniqueFileWriter(std::ostream& stream)
: AbstractTextDumper(stream)
{
}
void DumpTechnique(const MaterialTechnique* technique)
{
m_stream << "technique lol";
}
};
class TechsetFileWriter : public AbstractTextDumper
{
public:
explicit TechsetFileWriter(std::ostream& stream)
: AbstractTextDumper(stream)
{
}
void DumpTechset(const MaterialTechniqueSet* techset)
{
m_stream << "techset lol";
}
};
}
std::string AssetDumperTechniqueSet::GetTechniqueFileName(const MaterialTechnique* technique)
{
std::ostringstream ss;
ss << "techniques/" << technique->name << ".tech";
return ss.str();
}
std::string AssetDumperTechniqueSet::GetTechsetFileName(const MaterialTechniqueSet* techset)
{
std::ostringstream ss;
ss << "techsets/" << techset->name << ".techset";
return ss.str();
}
bool AssetDumperTechniqueSet::ShouldDump(XAssetInfo<MaterialTechniqueSet>* asset)
{
return true;
}
void AssetDumperTechniqueSet::DumpAsset(AssetDumpingContext& context, XAssetInfo<MaterialTechniqueSet>* asset)
{
const auto* techset = asset->Asset();
const auto techsetFile = context.OpenAssetFile(GetTechsetFileName(techset));
if (techsetFile)
{
TechsetFileWriter writer(*techsetFile);
writer.DumpTechset(techset);
}
auto* techniqueState = context.GetZoneAssetDumperState<TechniqueDumpingZoneState>();
for (const auto* technique : techset->techniques)
{
if (technique && techniqueState->ShouldDumpTechnique(technique))
{
const auto techniqueFile = context.OpenAssetFile(GetTechniqueFileName(technique));
if (techniqueFile)
{
TechniqueFileWriter writer(*techniqueFile);
writer.DumpTechnique(technique);
}
}
}
}

View File

@ -0,0 +1,17 @@
#pragma once
#include "Dumping/AbstractAssetDumper.h"
#include "Game/IW4/IW4.h"
namespace IW4
{
class AssetDumperTechniqueSet final : public AbstractAssetDumper<MaterialTechniqueSet>
{
static std::string GetTechniqueFileName(const MaterialTechnique* technique);
static std::string GetTechsetFileName(const MaterialTechniqueSet* techset);
protected:
bool ShouldDump(XAssetInfo<MaterialTechniqueSet>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<MaterialTechniqueSet>* asset) override;
};
}

View File

@ -0,0 +1,12 @@
#include "AssetDumperVertexDecl.h"
using namespace IW4;
bool AssetDumperVertexDecl::ShouldDump(XAssetInfo<MaterialVertexDeclaration>* asset)
{
return true;
}
void AssetDumperVertexDecl::DumpAsset(AssetDumpingContext& context, XAssetInfo<MaterialVertexDeclaration>* asset)
{
}

View File

@ -0,0 +1,14 @@
#pragma once
#include "Dumping/AbstractAssetDumper.h"
#include "Game/IW4/IW4.h"
namespace IW4
{
class AssetDumperVertexDecl final : public AbstractAssetDumper<MaterialVertexDeclaration>
{
protected:
bool ShouldDump(XAssetInfo<MaterialVertexDeclaration>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<MaterialVertexDeclaration>* asset) override;
};
}

View File

@ -0,0 +1,12 @@
#include "AssetDumperVertexShader.h"
using namespace IW4;
bool AssetDumperVertexShader::ShouldDump(XAssetInfo<MaterialVertexShader>* asset)
{
return true;
}
void AssetDumperVertexShader::DumpAsset(AssetDumpingContext& context, XAssetInfo<MaterialVertexShader>* asset)
{
}

View File

@ -0,0 +1,14 @@
#pragma once
#include "Dumping/AbstractAssetDumper.h"
#include "Game/IW4/IW4.h"
namespace IW4
{
class AssetDumperVertexShader final : public AbstractAssetDumper<MaterialVertexShader>
{
protected:
bool ShouldDump(XAssetInfo<MaterialVertexShader>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<MaterialVertexShader>* asset) override;
};
}

View File

@ -13,12 +13,16 @@
#include "AssetDumpers/AssetDumperMenuList.h"
#include "AssetDumpers/AssetDumperPhysCollmap.h"
#include "AssetDumpers/AssetDumperPhysPreset.h"
#include "AssetDumpers/AssetDumperPixelShader.h"
#include "AssetDumpers/AssetDumperRawFile.h"
#include "AssetDumpers/AssetDumperSndCurve.h"
#include "AssetDumpers/AssetDumperStringTable.h"
#include "AssetDumpers/AssetDumperStructuredDataDefSet.h"
#include "AssetDumpers/AssetDumperTechniqueSet.h"
#include "AssetDumpers/AssetDumperTracer.h"
#include "AssetDumpers/AssetDumperVehicle.h"
#include "AssetDumpers/AssetDumperVertexDecl.h"
#include "AssetDumpers/AssetDumperVertexShader.h"
#include "AssetDumpers/AssetDumperWeapon.h"
#include "AssetDumpers/AssetDumperXModel.h"
@ -45,10 +49,10 @@ bool ZoneDumper::DumpZone(AssetDumpingContext& context) const
// DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS)
DUMP_ASSET_POOL(AssetDumperXModel, m_xmodel, ASSET_TYPE_XMODEL)
// DUMP_ASSET_POOL(AssetDumperMaterial, m_material, ASSET_TYPE_MATERIAL)
// DUMP_ASSET_POOL(AssetDumperMaterialPixelShader, m_material_pixel_shader, ASSET_TYPE_PIXELSHADER)
// DUMP_ASSET_POOL(AssetDumperMaterialVertexShader, m_material_vertex_shader, ASSET_TYPE_VERTEXSHADER)
// DUMP_ASSET_POOL(AssetDumperMaterialVertexDeclaration, m_material_vertex_decl, ASSET_TYPE_VERTEXDECL)
// DUMP_ASSET_POOL(AssetDumperMaterialTechniqueSet, m_technique_set, ASSET_TYPE_TECHNIQUE_SET)
DUMP_ASSET_POOL(AssetDumperPixelShader, m_material_pixel_shader, ASSET_TYPE_PIXELSHADER)
DUMP_ASSET_POOL(AssetDumperVertexShader, m_material_vertex_shader, ASSET_TYPE_VERTEXSHADER)
DUMP_ASSET_POOL(AssetDumperVertexDecl, m_material_vertex_decl, ASSET_TYPE_VERTEXDECL)
DUMP_ASSET_POOL(AssetDumperTechniqueSet, m_technique_set, ASSET_TYPE_TECHNIQUE_SET)
DUMP_ASSET_POOL(AssetDumperGfxImage, m_image, ASSET_TYPE_IMAGE)
// DUMP_ASSET_POOL(AssetDumpersnd_alias_list_t, m_sound, ASSET_TYPE_SOUND)
DUMP_ASSET_POOL(AssetDumperSndCurve, m_sound_curve, ASSET_TYPE_SOUND_CURVE)