mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-19 15:52:53 +00:00
Progress on reversing technique flags
This commit is contained in:
parent
9e063a30f0
commit
cb45bdaadc
@ -968,6 +968,18 @@ namespace IW4
|
|||||||
int arrayStride;
|
int arrayStride;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
MTL_TYPE_DEFAULT = 0x0,
|
||||||
|
MTL_TYPE_MODEL = 0x1, // m_
|
||||||
|
MTL_TYPE_MODEL_VERTCOL = 0x2, // mc_
|
||||||
|
MTL_TYPE_MODEL_VERTCOL_GREY = 0x3, // ?
|
||||||
|
MTL_TYPE_WORLD = 0x4, // w_
|
||||||
|
MTL_TYPE_WORLD_VERTCOL = 0x5, // wc_
|
||||||
|
|
||||||
|
MTL_TYPE_COUNT,
|
||||||
|
};
|
||||||
|
|
||||||
enum MaterialConstantSource
|
enum MaterialConstantSource
|
||||||
{
|
{
|
||||||
CONST_SRC_CODE_MAYBE_DIRTY_PS_BEGIN = 0x0,
|
CONST_SRC_CODE_MAYBE_DIRTY_PS_BEGIN = 0x0,
|
||||||
@ -1202,6 +1214,21 @@ namespace IW4
|
|||||||
MaterialShaderArgument* args;
|
MaterialShaderArgument* args;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum TechniqueFlags
|
||||||
|
{
|
||||||
|
// Guesses purely based on data analysis:
|
||||||
|
TECHNIQUE_FLAG_1 = 0x1, // uses resolvedPostSun code sampler
|
||||||
|
TECHNIQUE_FLAG_2 = 0x2, // uses resolvedScene code sampler
|
||||||
|
TECHNIQUE_FLAG_4 = 0x4, // zprepass only
|
||||||
|
TECHNIQUE_FLAG_8 = 0x8, // build_floatz only
|
||||||
|
TECHNIQUE_FLAG_10 = 0x10, // build_shadowmap_depth + build_shadowmap_model only
|
||||||
|
TECHNIQUE_FLAG_20 = 0x20, // techniques with _i_ in its name (all use texcoord[1] in decl -> other optional stream sources are not used at all so might be any optional)
|
||||||
|
TECHNIQUE_FLAG_40 = 0x40, // uses code constant light.spotDir or light.spotFactors
|
||||||
|
TECHNIQUE_FLAG_80 = 0x80, // uses floatZ sampler and does not have 0x100 flag
|
||||||
|
TECHNIQUE_FLAG_100 = 0x100, // distortion_scale_zfeather_dtex + distortion_scale_ua_zfeather
|
||||||
|
TECHNIQUE_FLAG_200 = 0x200, // ?
|
||||||
|
};
|
||||||
|
|
||||||
struct MaterialTechnique
|
struct MaterialTechnique
|
||||||
{
|
{
|
||||||
const char* name;
|
const char* name;
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "Utils/Alignment.h"
|
#include "Utils/Alignment.h"
|
||||||
|
|
||||||
using namespace IW4;
|
using namespace IW4;
|
||||||
|
using namespace std::string_literals;
|
||||||
|
|
||||||
namespace IW4
|
namespace IW4
|
||||||
{
|
{
|
||||||
@ -992,6 +993,13 @@ namespace IW4
|
|||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void UpdateTechniqueFlags(MaterialTechnique& technique)
|
||||||
|
{
|
||||||
|
// This is stupid but that's what the game does
|
||||||
|
if("zprepass"s == technique.name)
|
||||||
|
technique.flags |= 4u;
|
||||||
|
}
|
||||||
|
|
||||||
static void UpdateTechniqueFlagsForArgument(uint16_t& techniqueFlags, const TechniqueCreator::PassShaderArgument& arg)
|
static void UpdateTechniqueFlagsForArgument(uint16_t& techniqueFlags, const TechniqueCreator::PassShaderArgument& arg)
|
||||||
{
|
{
|
||||||
if(arg.m_arg.type == MTL_ARG_CODE_PIXEL_SAMPLER)
|
if(arg.m_arg.type == MTL_ARG_CODE_PIXEL_SAMPLER)
|
||||||
@ -999,10 +1007,10 @@ namespace IW4
|
|||||||
switch(arg.m_arg.u.codeSampler)
|
switch(arg.m_arg.u.codeSampler)
|
||||||
{
|
{
|
||||||
case TEXTURE_SRC_CODE_RESOLVED_POST_SUN:
|
case TEXTURE_SRC_CODE_RESOLVED_POST_SUN:
|
||||||
techniqueFlags |= 1u;
|
techniqueFlags |= TECHNIQUE_FLAG_1;
|
||||||
break;
|
break;
|
||||||
case TEXTURE_SRC_CODE_RESOLVED_SCENE:
|
case TEXTURE_SRC_CODE_RESOLVED_SCENE:
|
||||||
techniqueFlags |= 2u;
|
techniqueFlags |= TECHNIQUE_FLAG_2;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -1065,6 +1073,8 @@ namespace IW4
|
|||||||
out.perPrimArgCount = static_cast<unsigned char>(perPrimArgCount);
|
out.perPrimArgCount = static_cast<unsigned char>(perPrimArgCount);
|
||||||
out.stableArgCount = static_cast<unsigned char>(stableArgCount);
|
out.stableArgCount = static_cast<unsigned char>(stableArgCount);
|
||||||
|
|
||||||
|
UpdateTechniqueFlags(technique);
|
||||||
|
|
||||||
if (in.m_vertex_shader)
|
if (in.m_vertex_shader)
|
||||||
dependencies.push_back(in.m_vertex_shader);
|
dependencies.push_back(in.m_vertex_shader);
|
||||||
if (in.m_pixel_shader)
|
if (in.m_pixel_shader)
|
||||||
@ -1170,6 +1180,9 @@ bool AssetLoaderTechniqueSet::CreateTechsetFromDefinition(const std::string& ass
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto* disAsset = GlobalAssetPool<MaterialTechniqueSet>::GetAssetByName("distortion_scale");
|
||||||
|
const auto* dis = disAsset ? disAsset->Asset() : nullptr;
|
||||||
|
|
||||||
manager->AddAsset(ASSET_TYPE_TECHNIQUE_SET, assetName, techset, std::vector(dependencies.begin(), dependencies.end()), std::vector<scr_string_t>());
|
manager->AddAsset(ASSET_TYPE_TECHNIQUE_SET, assetName, techset, std::vector(dependencies.begin(), dependencies.end()), std::vector<scr_string_t>());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user