diff --git a/src/Common/Game/IW4/IW4_Assets.h b/src/Common/Game/IW4/IW4_Assets.h index 399a7922..d4b2e5d1 100644 --- a/src/Common/Game/IW4/IW4_Assets.h +++ b/src/Common/Game/IW4/IW4_Assets.h @@ -920,8 +920,8 @@ namespace IW4 struct MaterialArgumentCodeConst { uint16_t index; - char firstRow; - char rowCount; + unsigned char firstRow; + unsigned char rowCount; }; union MaterialArgumentDef @@ -937,14 +937,19 @@ namespace IW4 MTL_ARG_MATERIAL_VERTEX_CONST = 0x0, MTL_ARG_LITERAL_VERTEX_CONST = 0x1, MTL_ARG_MATERIAL_PIXEL_SAMPLER = 0x2, + MTL_ARG_CODE_PRIM_BEGIN = 0x3, + MTL_ARG_CODE_VERTEX_CONST = 0x3, MTL_ARG_CODE_PIXEL_SAMPLER = 0x4, MTL_ARG_CODE_PIXEL_CONST = 0x5, + MTL_ARG_CODE_PRIM_END = 0x6, + MTL_ARG_MATERIAL_PIXEL_CONST = 0x6, MTL_ARG_LITERAL_PIXEL_CONST = 0x7, - MTL_ARG_COUNT = 0x8, + + MTL_ARG_COUNT }; struct MaterialShaderArgument @@ -959,10 +964,10 @@ namespace IW4 MaterialVertexDeclaration* vertexDecl; MaterialVertexShader* vertexShader; MaterialPixelShader* pixelShader; - char perPrimArgCount; - char perObjArgCount; - char stableArgCount; - char customSamplerFlags; + unsigned char perPrimArgCount; + unsigned char perObjArgCount; + unsigned char stableArgCount; + unsigned char customSamplerFlags; MaterialShaderArgument* args; }; diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperTechniqueSet.cpp b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperTechniqueSet.cpp index 5e6a702e..94a9e327 100644 --- a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperTechniqueSet.cpp +++ b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperTechniqueSet.cpp @@ -35,6 +35,12 @@ namespace IW4 m_stream << "stateMap \"\"; // TODO\n"; } + void DumpShaderArg(const MaterialShaderArgument& arg) + { + Indent(); + m_stream << "// Some arg dest:" << arg.dest << " type: " << arg.type << "\n"; + } + void DumpVertexShader(const MaterialPass& pass) { if (pass.vertexShader == nullptr) @@ -48,7 +54,22 @@ namespace IW4 m_stream << "{\n"; IncIndent(); - // TODO: Dump vertex shader args + if (pass.args) + { + const auto totalArgCount = static_cast(pass.perPrimArgCount) + + static_cast(pass.perObjArgCount) + + static_cast(pass.stableArgCount); + for (auto i = 0u; i < totalArgCount; i++) + { + const auto& arg = pass.args[i]; + if (arg.type == MTL_ARG_MATERIAL_VERTEX_CONST + || arg.type == MTL_ARG_LITERAL_VERTEX_CONST + || arg.type == MTL_ARG_CODE_VERTEX_CONST) + { + DumpShaderArg(arg); + } + } + } DecIndent(); Indent(); @@ -68,7 +89,24 @@ namespace IW4 m_stream << "{\n"; IncIndent(); - // TODO: Dump pixel shader args + if (pass.args) + { + const auto totalArgCount = static_cast(pass.perPrimArgCount) + + static_cast(pass.perObjArgCount) + + static_cast(pass.stableArgCount); + for (auto i = 0u; i < totalArgCount; i++) + { + const auto& arg = pass.args[i]; + if (arg.type == MTL_ARG_MATERIAL_PIXEL_SAMPLER + || arg.type == MTL_ARG_CODE_PIXEL_SAMPLER + || arg.type == MTL_ARG_CODE_PIXEL_CONST + || arg.type == MTL_ARG_MATERIAL_PIXEL_CONST + || arg.type == MTL_ARG_LITERAL_PIXEL_CONST) + { + DumpShaderArg(arg); + } + } + } DecIndent(); Indent();