mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-11-23 05:12:05 +00:00
FIxed techset dumping and loading to be the same, as well as added a missing image check to the BSP compiler to reduce the output prints when an image is missing.
This commit is contained in:
@@ -6,11 +6,11 @@ namespace shader
|
|||||||
{
|
{
|
||||||
std::string GetFileNameForPixelShaderAssetName(const std::string& assetName)
|
std::string GetFileNameForPixelShaderAssetName(const std::string& assetName)
|
||||||
{
|
{
|
||||||
return std::format("shader_bin/ps_{}.cso", assetName);
|
return std::format("techniquesets/shader_bin/ps_{}.cso", assetName);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetFileNameForVertexShaderAssetName(const std::string& assetName)
|
std::string GetFileNameForVertexShaderAssetName(const std::string& assetName)
|
||||||
{
|
{
|
||||||
return std::format("shader_bin/vs_{}.cso", assetName);
|
return std::format("techniquesets/shader_bin/vs_{}.cso", assetName);
|
||||||
}
|
}
|
||||||
} // namespace shader
|
} // namespace shader
|
||||||
|
|||||||
@@ -138,6 +138,14 @@ private:
|
|||||||
|
|
||||||
Material* loadImageIntoMaterial(std::string& imageName)
|
Material* loadImageIntoMaterial(std::string& imageName)
|
||||||
{
|
{
|
||||||
|
std::string imagePath = std::format("images/{}.iwi", imageName);
|
||||||
|
auto imageFile = m_search_path.Open(imagePath);
|
||||||
|
if (!imageFile.IsOpen())
|
||||||
|
{
|
||||||
|
printf("WARN: failed to find image %s.\n", imageName.c_str());
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
Material* material = new Material;
|
Material* material = new Material;
|
||||||
material->info.name = m_memory.Dup(imageName.c_str());
|
material->info.name = m_memory.Dup(imageName.c_str());
|
||||||
|
|
||||||
@@ -1808,7 +1816,7 @@ private:
|
|||||||
|
|
||||||
std::string entityString;
|
std::string entityString;
|
||||||
|
|
||||||
const auto entFile = m_search_path.Open("entities.json");
|
const auto entFile = m_search_path.Open("custom_map/entities.json");
|
||||||
if (!entFile.IsOpen())
|
if (!entFile.IsOpen())
|
||||||
{
|
{
|
||||||
printf("ERROR: can't find entity json!\n");
|
printf("ERROR: can't find entity json!\n");
|
||||||
@@ -1817,7 +1825,7 @@ private:
|
|||||||
json entJs = json::parse(*entFile.m_stream);
|
json entJs = json::parse(*entFile.m_stream);
|
||||||
parseMapEntsJSON(entJs["entities"], entityString);
|
parseMapEntsJSON(entJs["entities"], entityString);
|
||||||
|
|
||||||
const auto spawnFile = m_search_path.Open("spawns.json");
|
const auto spawnFile = m_search_path.Open("custom_map/spawns.json");
|
||||||
json spawnJs;
|
json spawnJs;
|
||||||
if (!spawnFile.IsOpen())
|
if (!spawnFile.IsOpen())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "Game/T6/T6.h"
|
#include "Game/T6/T6.h"
|
||||||
#include "LoaderTechniqueSetT6.h"
|
#include "LoaderTechniqueSetT6.h"
|
||||||
|
#include "Shader/ShaderCommon.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <format>
|
#include <format>
|
||||||
@@ -128,7 +129,7 @@ namespace
|
|||||||
currPass->pixelShader->name = _strdup(pixelName.c_str());
|
currPass->pixelShader->name = _strdup(pixelName.c_str());
|
||||||
currPass->pixelShader->prog.ps = NULL;
|
currPass->pixelShader->prog.ps = NULL;
|
||||||
|
|
||||||
const auto psFileName = std::format("techniquesets/shader_bin/ps_{}", pixelName);
|
const auto psFileName = shader::GetFileNameForPixelShaderAssetName(pixelName);
|
||||||
const auto psFile = m_search_path.Open(psFileName);
|
const auto psFile = m_search_path.Open(psFileName);
|
||||||
if (!psFile.IsOpen())
|
if (!psFile.IsOpen())
|
||||||
{
|
{
|
||||||
@@ -152,7 +153,7 @@ namespace
|
|||||||
currPass->vertexShader->name = _strdup(vertexName.c_str());
|
currPass->vertexShader->name = _strdup(vertexName.c_str());
|
||||||
currPass->vertexShader->prog.vs = NULL;
|
currPass->vertexShader->prog.vs = NULL;
|
||||||
|
|
||||||
const auto vsFileName = std::format("techniquesets/shader_bin/vs_{}", vertexName);
|
const auto vsFileName = shader::GetFileNameForVertexShaderAssetName(vertexName);
|
||||||
const auto vsFile = m_search_path.Open(vsFileName);
|
const auto vsFile = m_search_path.Open(vsFileName);
|
||||||
if (!vsFile.IsOpen())
|
if (!vsFile.IsOpen())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,7 +4,9 @@
|
|||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
using namespace nlohmann;
|
||||||
using namespace T6;
|
using namespace T6;
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
@@ -87,21 +89,111 @@ namespace techset
|
|||||||
const auto* techniqueSet = asset->Asset();
|
const auto* techniqueSet = asset->Asset();
|
||||||
auto* shaderState = context.GetZoneAssetDumperState<ShaderZoneState>();
|
auto* shaderState = context.GetZoneAssetDumperState<ShaderZoneState>();
|
||||||
|
|
||||||
|
const auto assetFile = context.OpenAssetFile(std::format("techniquesets/{}.json", techniqueSet->name));
|
||||||
|
if (!assetFile)
|
||||||
|
return;
|
||||||
|
|
||||||
|
json js;
|
||||||
|
|
||||||
|
js["name"] = techniqueSet->name;
|
||||||
|
js["worldVertFormat"] = techniqueSet->worldVertFormat;
|
||||||
|
|
||||||
|
js["techniques"] = json::array();
|
||||||
for (const auto* technique : techniqueSet->techniques)
|
for (const auto* technique : techniqueSet->techniques)
|
||||||
{
|
{
|
||||||
if (!technique || !shaderState->ShouldDumpTechnique(technique))
|
json techniqueJs = json::object();
|
||||||
continue;
|
|
||||||
|
|
||||||
|
if (technique != NULL)
|
||||||
|
{
|
||||||
|
techniqueJs["name"] = technique->name;
|
||||||
|
techniqueJs["flags"] = technique->flags;
|
||||||
|
techniqueJs["passCount"] = technique->passCount;
|
||||||
|
|
||||||
|
_ASSERT(technique->passCount == 1);
|
||||||
|
|
||||||
|
techniqueJs["passArray"] = json::array();
|
||||||
for (auto passIndex = 0u; passIndex < technique->passCount; passIndex++)
|
for (auto passIndex = 0u; passIndex < technique->passCount; passIndex++)
|
||||||
{
|
{
|
||||||
const auto* pixelShader = technique->passArray[passIndex].pixelShader;
|
const MaterialPass* currPass = &technique->passArray[passIndex];
|
||||||
if (pixelShader && shaderState->ShouldDumpPixelShader(pixelShader))
|
json passJs = json::object();
|
||||||
DumpPixelShader(context, *pixelShader);
|
|
||||||
|
|
||||||
const auto* vertexShader = technique->passArray[passIndex].vertexShader;
|
passJs["perPrimArgCount"] = currPass->perPrimArgCount;
|
||||||
if (vertexShader && shaderState->ShouldDumpVertexShader(vertexShader))
|
passJs["perObjArgCount"] = currPass->perObjArgCount;
|
||||||
DumpVertexShader(context, *vertexShader);
|
passJs["stableArgCount"] = currPass->stableArgCount;
|
||||||
|
passJs["customSamplerFlags"] = currPass->customSamplerFlags;
|
||||||
|
passJs["precompiledIndex"] = currPass->precompiledIndex;
|
||||||
|
passJs["materialType"] = currPass->materialType;
|
||||||
|
|
||||||
|
json vertDeclJs = json::object();
|
||||||
|
if (currPass->vertexDecl != NULL)
|
||||||
|
{
|
||||||
|
vertDeclJs["streamCount"] = currPass->vertexDecl->streamCount;
|
||||||
|
vertDeclJs["hasOptionalSource"] = currPass->vertexDecl->hasOptionalSource;
|
||||||
|
vertDeclJs["isLoaded"] = currPass->vertexDecl->isLoaded;
|
||||||
|
for (int i = 0; i < 16; i++)
|
||||||
|
{
|
||||||
|
vertDeclJs["routing"][i]["source"] = currPass->vertexDecl->routing.data[i].source;
|
||||||
|
vertDeclJs["routing"][i]["dest"] = currPass->vertexDecl->routing.data[i].dest;
|
||||||
|
|
||||||
|
_ASSERT(currPass->vertexDecl->routing.decl[i] == NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
passJs["vertexDecl"] = vertDeclJs;
|
||||||
|
|
||||||
|
passJs["args"] = json::array();
|
||||||
|
if (currPass->args != NULL)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < currPass->perPrimArgCount + currPass->perObjArgCount + currPass->stableArgCount; i++)
|
||||||
|
{
|
||||||
|
json argsJs = json::object();
|
||||||
|
MaterialShaderArgument* currArg = &currPass->args[i];
|
||||||
|
|
||||||
|
argsJs["type"] = currArg->type;
|
||||||
|
argsJs["location"] = currArg->location.offset;
|
||||||
|
argsJs["size"] = currArg->size;
|
||||||
|
argsJs["buffer"] = currArg->buffer;
|
||||||
|
if (currArg->type == MTL_ARG_LITERAL_VERTEX_CONST || currArg->type == MTL_ARG_LITERAL_PIXEL_CONST)
|
||||||
|
{
|
||||||
|
argsJs["u"]["const0"] = currArg->u.literalConst[0];
|
||||||
|
argsJs["u"]["const1"] = currArg->u.literalConst[1];
|
||||||
|
argsJs["u"]["const2"] = currArg->u.literalConst[2];
|
||||||
|
argsJs["u"]["const3"] = currArg->u.literalConst[3];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
argsJs["u"]["value"] = currArg->u.nameHash;
|
||||||
|
}
|
||||||
|
|
||||||
|
passJs["args"].push_back(argsJs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
json pixelJs = json::object();
|
||||||
|
if (currPass->pixelShader != NULL)
|
||||||
|
{
|
||||||
|
pixelJs["name"] = currPass->pixelShader->name;
|
||||||
|
if (shaderState->ShouldDumpPixelShader(currPass->pixelShader))
|
||||||
|
DumpPixelShader(context, *currPass->pixelShader);
|
||||||
|
}
|
||||||
|
passJs["pixelShader"] = pixelJs;
|
||||||
|
|
||||||
|
json vertexJs = json::object();
|
||||||
|
if (currPass->vertexShader != NULL)
|
||||||
|
{
|
||||||
|
vertexJs["name"] = currPass->vertexShader->name;
|
||||||
|
if (shaderState->ShouldDumpVertexShader(currPass->vertexShader))
|
||||||
|
DumpVertexShader(context, *currPass->vertexShader);
|
||||||
|
}
|
||||||
|
passJs["vertexShader"] = vertexJs;
|
||||||
|
|
||||||
|
techniqueJs["passArray"].push_back(passJs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
js["techniques"].push_back(techniqueJs);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string jsonString = js.dump(4);
|
||||||
|
assetFile->write(jsonString.c_str(), jsonString.size());
|
||||||
}
|
}
|
||||||
} // namespace techset
|
} // namespace techset
|
||||||
|
|||||||
Reference in New Issue
Block a user