diff --git a/src/Common/Game/IW3/IW3_Assets.h b/src/Common/Game/IW3/IW3_Assets.h index 6415e918..d654aecb 100644 --- a/src/Common/Game/IW3/IW3_Assets.h +++ b/src/Common/Game/IW3/IW3_Assets.h @@ -1240,7 +1240,7 @@ namespace IW3 struct MaterialVertexDeclaration { - char streamCount; + unsigned char streamCount; bool hasOptionalSource; bool isLoaded; MaterialVertexStreamRouting routing; diff --git a/src/ObjCommon/Game/IW3/Techset/TechsetConstantsIW3.h b/src/ObjCommon/Game/IW3/Techset/TechsetConstantsIW3.h index 9916f91c..7a7bdb2a 100644 --- a/src/ObjCommon/Game/IW3/Techset/TechsetConstantsIW3.h +++ b/src/ObjCommon/Game/IW3/Techset/TechsetConstantsIW3.h @@ -738,11 +738,13 @@ namespace IW3 .value = TEXTURE_SRC_CODE_RESOLVED_POST_SUN, .accessor = "resolvedPostSun", .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY, + .techFlags = MTL_TECHFLAG_NEEDS_RESOLVED_POST_SUN, }, { .value = TEXTURE_SRC_CODE_RESOLVED_SCENE, .accessor = "resolvedScene", .updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY, + .techFlags = MTL_TECHFLAG_NEEDS_RESOLVED_SCENE, }, { .value = TEXTURE_SRC_CODE_POST_EFFECT_0, diff --git a/src/ObjCompiling/Game/IW3/ObjCompilerIW3.cpp b/src/ObjCompiling/Game/IW3/ObjCompilerIW3.cpp index 29ea2ee1..ad084e43 100644 --- a/src/ObjCompiling/Game/IW3/ObjCompilerIW3.cpp +++ b/src/ObjCompiling/Game/IW3/ObjCompilerIW3.cpp @@ -1,6 +1,9 @@ #include "ObjCompilerIW3.h" #include "Game/IW3/IW3.h" +#include "Game/IW3/Techset/TechniqueCompilerIW3.h" +#include "Game/IW3/Techset/TechsetCompilerIW3.h" +#include "Game/IW3/Techset/VertexDeclCompilerIW3.h" #include "Image/ImageIwdPostProcessor.h" #include @@ -13,7 +16,10 @@ namespace { auto& memory = zone.Memory(); - // No compilers yet + collection.AddAssetCreator(techset::CreateTechsetCompilerIW3(memory, searchPath)); + + collection.AddSubAssetCreator(techset::CreateTechniqueCompilerIW3(memory, zone, searchPath)); + collection.AddSubAssetCreator(techset::CreateVertexDeclCompilerIW3(memory)); } void ConfigurePostProcessors(AssetCreatorCollection& collection, @@ -39,5 +45,6 @@ void ObjCompiler::ConfigureCreatorCollection(AssetCreatorCollection& collection, IOutputPath& outDir, IOutputPath& cacheDir) const { + ConfigureCompilers(collection, zone, searchPath); ConfigurePostProcessors(collection, zone, zoneDefinition, searchPath, zoneStates, outDir); } diff --git a/src/ObjCompiling/Techset/TechniqueCompiler.cpp.template b/src/ObjCompiling/Techset/TechniqueCompiler.cpp.template index 9d5e194c..14d6facc 100644 --- a/src/ObjCompiling/Techset/TechniqueCompiler.cpp.template +++ b/src/ObjCompiling/Techset/TechniqueCompiler.cpp.template @@ -1,4 +1,4 @@ -#options GAME(IW4, T6) +#options GAME(IW3, IW4, T6) #filename "Game/" + GAME + "/Techset/TechniqueCompiler" + GAME + ".cpp" @@ -9,6 +9,7 @@ #if GAME == "IW3" #define FEATURE_IW3 #define IS_DX9 +#define SHADERS_ARE_SUBASSETS #elif GAME == "IW4" #define FEATURE_IW4 #define IS_DX9 @@ -278,7 +279,10 @@ namespace std::string lowerTechniqueName(commonTechnique.m_name); utils::MakeStringLowerCase(lowerTechniqueName); -#if defined(FEATURE_IW4) +#if defined(FEATURE_IW3) + if (lowerTechniqueName == "zprepass") + technique.flags |= MTL_TECHFLAG_ZPREPASS; +#elif defined(FEATURE_IW4) // Not a particularly cool way to do this but... // the game actually does this :shrug: if (lowerTechniqueName == "zprepass") @@ -290,7 +294,7 @@ namespace if (technique.flags & MTL_TECHFLAG_USES_FLOATZ && lowerTechniqueName.starts_with("distortion_")) technique.flags = (technique.flags & ~MTL_TECHFLAG_USES_FLOATZ) | MTL_TECHFLAG_USES_DISTORTION_FLOATZ; - + if (ShouldApplyFlag200(technique)) technique.flags |= TECHNIQUE_FLAG_200; #elif defined(FEATURE_T6) @@ -454,9 +458,7 @@ namespace void FinalizeZone(AssetCreationContext& context) override { -#if defined(FEATURE_IW4) - // TODO -#elif defined(FEATURE_T6) +#if defined(FEATURE_T6) const auto materials = m_zone.m_pools.PoolAssets(); for (auto* materialAsset : materials) { diff --git a/src/ObjCompiling/Techset/TechniqueCompiler.h.template b/src/ObjCompiling/Techset/TechniqueCompiler.h.template index a1bbe9f0..300d599e 100644 --- a/src/ObjCompiling/Techset/TechniqueCompiler.h.template +++ b/src/ObjCompiling/Techset/TechniqueCompiler.h.template @@ -1,4 +1,4 @@ -#options GAME(IW4, T6) +#options GAME(IW3, IW4, T6) #filename "Game/" + GAME + "/Techset/TechniqueCompiler" + GAME + ".h" diff --git a/src/ObjCompiling/Techset/TechsetCompiler.cpp.template b/src/ObjCompiling/Techset/TechsetCompiler.cpp.template index 38a4890f..980926d0 100644 --- a/src/ObjCompiling/Techset/TechsetCompiler.cpp.template +++ b/src/ObjCompiling/Techset/TechsetCompiler.cpp.template @@ -1,4 +1,4 @@ -#options GAME(IW4, T6) +#options GAME(IW3, IW4, T6) #filename "Game/" + GAME + "/Techset/TechsetCompiler" + GAME + ".cpp" diff --git a/src/ObjCompiling/Techset/TechsetCompiler.h.template b/src/ObjCompiling/Techset/TechsetCompiler.h.template index 6e6d8abd..ce6ff411 100644 --- a/src/ObjCompiling/Techset/TechsetCompiler.h.template +++ b/src/ObjCompiling/Techset/TechsetCompiler.h.template @@ -1,4 +1,4 @@ -#options GAME(IW4, T6) +#options GAME(IW3, IW4, T6) #filename "Game/" + GAME + "/Techset/TechsetCompiler" + GAME + ".h" diff --git a/src/ObjCompiling/Techset/VertexDeclCompiler.cpp.template b/src/ObjCompiling/Techset/VertexDeclCompiler.cpp.template index b3a9ba17..ad6dcc04 100644 --- a/src/ObjCompiling/Techset/VertexDeclCompiler.cpp.template +++ b/src/ObjCompiling/Techset/VertexDeclCompiler.cpp.template @@ -1,4 +1,4 @@ -#options GAME(IW4, T6) +#options GAME(IW3, IW4, T6) #filename "Game/" + GAME + "/Techset/VertexDeclCompiler" + GAME + ".cpp" @@ -8,6 +8,7 @@ #if GAME == "IW3" #define FEATURE_IW3 +#define IS_SUB_ASSET #elif GAME == "IW4" #define FEATURE_IW4 #elif GAME == "IW5" diff --git a/src/ObjCompiling/Techset/VertexDeclCompiler.h.template b/src/ObjCompiling/Techset/VertexDeclCompiler.h.template index c7c4b6a5..32f66784 100644 --- a/src/ObjCompiling/Techset/VertexDeclCompiler.h.template +++ b/src/ObjCompiling/Techset/VertexDeclCompiler.h.template @@ -1,9 +1,10 @@ -#options GAME(IW4, T6) +#options GAME(IW3, IW4, T6) #filename "Game/" + GAME + "/Techset/VertexDeclCompiler" + GAME + ".h" #if GAME == "IW3" #define FEATURE_IW3 +#define IS_SUB_ASSET #elif GAME == "IW4" #define FEATURE_IW4 #elif GAME == "IW5" @@ -12,6 +13,7 @@ #define FEATURE_T5 #elif GAME == "T6" #define FEATURE_T6 +#define IS_SUB_ASSET #endif // This file was templated. @@ -27,7 +29,7 @@ #set CREATE_COMPILER_METHOD "CreateVertexDeclCompiler" + GAME -#if defined(FEATURE_T6) +#if defined(IS_SUB_ASSET) #define INTERFACE_NAME ISubAssetCreator #else #define INTERFACE_NAME IAssetCreator diff --git a/src/ObjLoading/Game/IW3/ObjLoaderIW3.cpp b/src/ObjLoading/Game/IW3/ObjLoaderIW3.cpp index 3d77d604..d8656beb 100644 --- a/src/ObjLoading/Game/IW3/ObjLoaderIW3.cpp +++ b/src/ObjLoading/Game/IW3/ObjLoaderIW3.cpp @@ -6,6 +6,8 @@ #include "Game/IW3/IW3.h" #include "Game/IW3/Image/ImageLoaderEmbeddedIW3.h" #include "Game/IW3/Image/ImageLoaderExternalIW3.h" +#include "Game/IW3/Techset/PixelShaderLoaderIW3.h" +#include "Game/IW3/Techset/VertexShaderLoaderIW3.h" #include "Game/IW3/XModel/LoaderXModelIW3.h" #include "Localize/AssetLoaderLocalizeIW3.h" #include "Material/LoaderMaterialIW3.h" @@ -118,6 +120,9 @@ namespace // collection.AddAssetCreator(std::make_unique(memory)); collection.AddAssetCreator(raw_file::CreateLoaderIW3(memory, searchPath)); collection.AddAssetCreator(string_table::CreateLoaderIW3(memory, searchPath)); + + collection.AddSubAssetCreator(techset::CreateVertexShaderLoaderIW3(memory, searchPath)); + collection.AddSubAssetCreator(techset::CreatePixelShaderLoaderIW3(memory, searchPath)); } } // namespace diff --git a/src/ObjLoading/Techset/PixelShaderLoader.cpp.template b/src/ObjLoading/Techset/PixelShaderLoader.cpp.template index 19de8f72..d02e87bb 100644 --- a/src/ObjLoading/Techset/PixelShaderLoader.cpp.template +++ b/src/ObjLoading/Techset/PixelShaderLoader.cpp.template @@ -1,4 +1,4 @@ -#options GAME(IW4, T6) +#options GAME(IW3, IW4, T6) #filename "Game/" + GAME + "/Techset/PixelShaderLoader" + GAME + ".cpp" @@ -8,6 +8,7 @@ #if GAME == "IW3" #define FEATURE_IW3 #define IS_DX9 +#define IS_SUB_ASSET #elif GAME == "IW4" #define FEATURE_IW4 #define IS_DX9 diff --git a/src/ObjLoading/Techset/PixelShaderLoader.h.template b/src/ObjLoading/Techset/PixelShaderLoader.h.template index 05933dab..bc2a1731 100644 --- a/src/ObjLoading/Techset/PixelShaderLoader.h.template +++ b/src/ObjLoading/Techset/PixelShaderLoader.h.template @@ -1,9 +1,10 @@ -#options GAME(IW4, T6) +#options GAME(IW3, IW4, T6) #filename "Game/" + GAME + "/Techset/PixelShaderLoader" + GAME + ".h" #if GAME == "IW3" #define FEATURE_IW3 +#define IS_SUB_ASSET #elif GAME == "IW4" #define FEATURE_IW4 #elif GAME == "IW5" @@ -12,6 +13,7 @@ #define FEATURE_T5 #elif GAME == "T6" #define FEATURE_T6 +#define IS_SUB_ASSET #endif // This file was templated. @@ -28,7 +30,7 @@ #set CREATE_LOADER_METHOD "CreatePixelShaderLoader" + GAME -#if defined(FEATURE_T6) +#if defined(IS_SUB_ASSET) #define INTERFACE_NAME ISubAssetCreator #else #define INTERFACE_NAME IAssetCreator diff --git a/src/ObjLoading/Techset/VertexShaderLoader.cpp.template b/src/ObjLoading/Techset/VertexShaderLoader.cpp.template index fb68e435..3e02b330 100644 --- a/src/ObjLoading/Techset/VertexShaderLoader.cpp.template +++ b/src/ObjLoading/Techset/VertexShaderLoader.cpp.template @@ -1,4 +1,4 @@ -#options GAME(IW4, T6) +#options GAME(IW3, IW4, T6) #filename "Game/" + GAME + "/Techset/VertexShaderLoader" + GAME + ".cpp" @@ -8,6 +8,7 @@ #if GAME == "IW3" #define FEATURE_IW3 #define IS_DX9 +#define IS_SUB_ASSET #elif GAME == "IW4" #define FEATURE_IW4 #define IS_DX9 diff --git a/src/ObjLoading/Techset/VertexShaderLoader.h.template b/src/ObjLoading/Techset/VertexShaderLoader.h.template index b9e37b0d..83957393 100644 --- a/src/ObjLoading/Techset/VertexShaderLoader.h.template +++ b/src/ObjLoading/Techset/VertexShaderLoader.h.template @@ -1,9 +1,10 @@ -#options GAME(IW4, T6) +#options GAME(IW3, IW4, T6) #filename "Game/" + GAME + "/Techset/VertexShaderLoader" + GAME + ".h" #if GAME == "IW3" #define FEATURE_IW3 +#define IS_SUB_ASSET #elif GAME == "IW4" #define FEATURE_IW4 #elif GAME == "IW5" @@ -12,6 +13,7 @@ #define FEATURE_T5 #elif GAME == "T6" #define FEATURE_T6 +#define IS_SUB_ASSET #endif // This file was templated. @@ -28,7 +30,7 @@ #set CREATE_LOADER_METHOD "CreateVertexShaderLoader" + GAME -#if defined(FEATURE_T6) +#if defined(IS_SUB_ASSET) #define INTERFACE_NAME ISubAssetCreator #else #define INTERFACE_NAME IAssetCreator