2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2026-04-21 10:58:44 +00:00

feat: add shader compilers for IW3,IW5,T5,T6

This commit is contained in:
Jan Laupetin
2026-04-08 10:39:24 +01:00
parent 1d1b9cc4d1
commit 388c0272b0
8 changed files with 58 additions and 10 deletions

View File

@@ -1,9 +1,11 @@
#include "ObjCompilerIW3.h"
#include "Game/IW3/IW3.h"
#include "Game/IW3/Techset/PixelShaderCompilerIW3.h"
#include "Game/IW3/Techset/TechniqueCompilerIW3.h"
#include "Game/IW3/Techset/TechsetCompilerIW3.h"
#include "Game/IW3/Techset/VertexDeclCompilerIW3.h"
#include "Game/IW3/Techset/VertexShaderCompilerIW3.h"
#include "Image/ImageIwdPostProcessor.h"
#include <memory>
@@ -20,6 +22,8 @@ namespace
collection.AddSubAssetCreator(techset::CreateTechniqueCompilerIW3(memory, zone, searchPath));
collection.AddSubAssetCreator(techset::CreateVertexDeclCompilerIW3(memory));
collection.AddSubAssetCreator(techset::CreateVertexShaderCompilerIW3(memory, searchPath));
collection.AddSubAssetCreator(techset::CreatePixelShaderCompilerIW3(memory, searchPath));
}
void ConfigurePostProcessors(AssetCreatorCollection& collection,

View File

@@ -1,9 +1,11 @@
#include "ObjCompilerIW5.h"
#include "Game/IW5/IW5.h"
#include "Game/IW5/Techset/PixelShaderCompilerIW5.h"
#include "Game/IW5/Techset/TechniqueCompilerIW5.h"
#include "Game/IW5/Techset/TechsetCompilerIW5.h"
#include "Game/IW5/Techset/VertexDeclCompilerIW5.h"
#include "Game/IW5/Techset/VertexShaderCompilerIW5.h"
#include "Image/ImageIwdPostProcessor.h"
#include <memory>
@@ -17,6 +19,8 @@ namespace
auto& memory = zone.Memory();
collection.AddAssetCreator(techset::CreateVertexDeclCompilerIW5(memory));
collection.AddAssetCreator(techset::CreateVertexShaderCompilerIW5(memory, searchPath));
collection.AddAssetCreator(techset::CreatePixelShaderCompilerIW5(memory, searchPath));
collection.AddAssetCreator(techset::CreateTechsetCompilerIW5(memory, searchPath));
collection.AddSubAssetCreator(techset::CreateTechniqueCompilerIW5(memory, zone, searchPath));

View File

@@ -1,9 +1,11 @@
#include "ObjCompilerT5.h"
#include "Game/T5/T5.h"
#include "Game/T5/Techset/PixelShaderCompilerT5.h"
#include "Game/T5/Techset/TechniqueCompilerT5.h"
#include "Game/T5/Techset/TechsetCompilerT5.h"
#include "Game/T5/Techset/VertexDeclCompilerT5.h"
#include "Game/T5/Techset/VertexShaderCompilerT5.h"
#include "Image/ImageIwdPostProcessor.h"
#include <memory>
@@ -20,6 +22,8 @@ namespace
collection.AddSubAssetCreator(techset::CreateTechniqueCompilerT5(memory, zone, searchPath));
collection.AddSubAssetCreator(techset::CreateVertexDeclCompilerT5(memory));
collection.AddSubAssetCreator(techset::CreateVertexShaderCompilerT5(memory, searchPath));
collection.AddSubAssetCreator(techset::CreatePixelShaderCompilerT5(memory, searchPath));
}
void ConfigurePostProcessors(AssetCreatorCollection& collection,

View File

@@ -1,9 +1,11 @@
#include "ObjCompilerT6.h"
#include "Game/T6/T6.h"
#include "Game/T6/Techset/PixelShaderCompilerT6.h"
#include "Game/T6/Techset/TechniqueCompilerT6.h"
#include "Game/T6/Techset/TechsetCompilerT6.h"
#include "Game/T6/Techset/VertexDeclCompilerT6.h"
#include "Game/T6/Techset/VertexShaderCompilerT6.h"
#include "Image/ImageIPakPostProcessor.h"
#include "Image/ImageIwdPostProcessor.h"
#include "KeyValuePairs/KeyValuePairsCompilerT6.h"
@@ -27,6 +29,8 @@ namespace
collection.AddSubAssetCreator(techset::CreateTechniqueCompilerT6(memory, zone, searchPath));
collection.AddSubAssetCreator(techset::CreateVertexDeclCompilerT6(memory));
collection.AddSubAssetCreator(techset::CreateVertexShaderCompilerT6(memory, searchPath));
collection.AddSubAssetCreator(techset::CreatePixelShaderCompilerT6(memory, searchPath));
}
void ConfigurePostProcessors(AssetCreatorCollection& collection,

View File

@@ -1,4 +1,4 @@
#options GAME(IW4)
#options GAME(IW3, IW4, IW5, T5, T6)
#filename "Game/" + GAME + "/Techset/PixelShaderCompiler" + GAME + ".cpp"
@@ -66,7 +66,16 @@ namespace
AssetCreationResult OVERRIDDEN_CREATOR_METHOD(const std::string& assetName, AssetCreationContext& context) override
{
auto result = shader::CompileShader(assetName, "PSMain", "ps_3_0", false, m_search_path, m_memory);
auto result = shader::CompileShader(assetName,
"PSMain",
#ifdef IS_DX9
"ps_3_0",
#else
"ps_4_0",
#endif
false,
m_search_path,
m_memory);
if (result.has_value())
{
@@ -76,12 +85,19 @@ namespace
con::info("Compiled pixel shader \"{}\"", assetName);
#ifdef IS_DX9
assert(maybeShader->m_shader_size % sizeof(uint32_t) == 0);
#endif
auto* pixelShader = m_memory.Alloc<MaterialPixelShader>();
pixelShader->name = m_memory.Dup(assetName.c_str());
pixelShader->prog.loadDef.program = static_cast<unsigned int*>(maybeShader->m_shader_bin);
pixelShader->prog.loadDef.programSize = static_cast<uint16_t>(maybeShader->m_shader_size / sizeof(uint32_t));
pixelShader->prog.loadDef.program = static_cast<decltype(GfxPixelShaderLoadDef::program)>(maybeShader->m_shader_bin);
#ifdef IS_DX9
pixelShader->prog.loadDef.programSize = static_cast<decltype(GfxPixelShaderLoadDef::programSize)>(
maybeShader->m_shader_size / sizeof(std::remove_pointer_t<decltype(GfxPixelShaderLoadDef::program)>));
#else
pixelShader->prog.loadDef.programSize = static_cast<decltype(GfxPixelShaderLoadDef::programSize)>(maybeShader->m_shader_size);
#endif
return AssetCreationResult::Success(context.ADD_ASSET_METHOD(AssetRegistration<ASSET_NAME>(assetName, pixelShader)));
}

View File

@@ -1,4 +1,4 @@
#options GAME(IW4)
#options GAME(IW3, IW4, IW5, T5, T6)
#filename "Game/" + GAME + "/Techset/PixelShaderCompiler" + GAME + ".h"

View File

@@ -1,4 +1,4 @@
#options GAME(IW4)
#options GAME(IW3, IW4, IW5, T5, T6)
#filename "Game/" + GAME + "/Techset/VertexShaderCompiler" + GAME + ".cpp"
@@ -66,7 +66,16 @@ namespace
AssetCreationResult OVERRIDDEN_CREATOR_METHOD(const std::string& assetName, AssetCreationContext& context) override
{
auto result = shader::CompileShader(assetName, "VSMain", "vs_3_0", false, m_search_path, m_memory);
auto result = shader::CompileShader(assetName,
"VSMain",
#ifdef IS_DX9
"vs_3_0",
#else
"vs_4_0",
#endif
false,
m_search_path,
m_memory);
if (result.has_value())
{
@@ -76,12 +85,19 @@ namespace
con::info("Compiled vertex shader \"{}\"", assetName);
#ifdef IS_DX9
assert(maybeShader->m_shader_size % sizeof(uint32_t) == 0);
#endif
auto* vertexShader = m_memory.Alloc<MaterialVertexShader>();
vertexShader->name = m_memory.Dup(assetName.c_str());
vertexShader->prog.loadDef.program = static_cast<unsigned int*>(maybeShader->m_shader_bin);
vertexShader->prog.loadDef.programSize = static_cast<uint16_t>(maybeShader->m_shader_size / sizeof(uint32_t));
vertexShader->prog.loadDef.program = static_cast<decltype(GfxVertexShaderLoadDef::program)>(maybeShader->m_shader_bin);
#ifdef IS_DX9
vertexShader->prog.loadDef.programSize = static_cast<decltype(GfxVertexShaderLoadDef::programSize)>(
maybeShader->m_shader_size / sizeof(std::remove_pointer_t<decltype(GfxVertexShaderLoadDef::program)>));
#else
vertexShader->prog.loadDef.programSize = static_cast<decltype(GfxVertexShaderLoadDef::programSize)>(maybeShader->m_shader_size);
#endif
return AssetCreationResult::Success(context.ADD_ASSET_METHOD(AssetRegistration<ASSET_NAME>(assetName, vertexShader)));
}

View File

@@ -1,4 +1,4 @@
#options GAME(IW4)
#options GAME(IW3, IW4, IW5, T5, T6)
#filename "Game/" + GAME + "/Techset/VertexShaderCompiler" + GAME + ".h"