mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-03-15 17:33:03 +00:00
fix: inconsistencies on t5 technique compilation
This commit is contained in:
@@ -1533,8 +1533,10 @@ namespace T5
|
||||
// - Any polygon offset that is not GFXS1_POLYGON_OFFSET_0
|
||||
TECHNIQUE_FLAG_80 = 0x80,
|
||||
|
||||
TECHNIQUE_FLAG_100 = 0x100,
|
||||
TECHNIQUE_FLAG_200 = 0x200,
|
||||
// Uses marksHitNormal
|
||||
MTL_TECHFLAG_USES_MARKS_HIT_NORMAL = 0x100,
|
||||
// Uses __characterCharredAmount or destructibleParms. Not sure how those two relate?
|
||||
MTL_TECHFLAG_200 = 0x200,
|
||||
};
|
||||
|
||||
struct MaterialPass
|
||||
|
||||
@@ -315,6 +315,7 @@ namespace T5
|
||||
.arrayCount = 0,
|
||||
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
|
||||
.techFlags = MTL_TECHFLAG_USES_LIGHT_SPOT_FACTORS,
|
||||
.techFlagShaderType = techset::CommonTechniqueShaderType::PIXEL,
|
||||
},
|
||||
{
|
||||
.value = CONST_SRC_CODE_LIGHT_ATTENUATION,
|
||||
@@ -730,6 +731,7 @@ namespace T5
|
||||
.arrayCount = 0,
|
||||
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
|
||||
.techFlags = MTL_TECHFLAG_USES_GRASS,
|
||||
.techFlagShaderType = techset::CommonTechniqueShaderType::VERTEX,
|
||||
},
|
||||
{
|
||||
.value = CONST_SRC_CODE_GRASS_FORCE0,
|
||||
@@ -737,6 +739,7 @@ namespace T5
|
||||
.arrayCount = 0,
|
||||
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
|
||||
.techFlags = MTL_TECHFLAG_USES_GRASS,
|
||||
.techFlagShaderType = techset::CommonTechniqueShaderType::VERTEX,
|
||||
},
|
||||
{
|
||||
.value = CONST_SRC_CODE_GRASS_FORCE1,
|
||||
@@ -744,6 +747,7 @@ namespace T5
|
||||
.arrayCount = 0,
|
||||
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
|
||||
.techFlags = MTL_TECHFLAG_USES_GRASS,
|
||||
.techFlagShaderType = techset::CommonTechniqueShaderType::VERTEX,
|
||||
},
|
||||
{
|
||||
.value = CONST_SRC_CODE_GRASS_WIND_FORCE0,
|
||||
@@ -751,6 +755,7 @@ namespace T5
|
||||
.arrayCount = 0,
|
||||
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
|
||||
.techFlags = MTL_TECHFLAG_USES_GRASS,
|
||||
.techFlagShaderType = techset::CommonTechniqueShaderType::VERTEX,
|
||||
},
|
||||
{
|
||||
.value = CONST_SRC_CODE_MOTIONBLUR_DIRECTION_AND_MAGNITUDE,
|
||||
@@ -841,7 +846,8 @@ namespace T5
|
||||
.accessor = "destructibleParms",
|
||||
.arrayCount = 0,
|
||||
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
|
||||
.techFlags = TECHNIQUE_FLAG_200,
|
||||
.techFlags = MTL_TECHFLAG_200,
|
||||
.techFlagShaderType = techset::CommonTechniqueShaderType::VERTEX,
|
||||
},
|
||||
{
|
||||
.value = CONST_SRC_CODE_CLOUD_WORLD_AREA,
|
||||
@@ -866,7 +872,8 @@ namespace T5
|
||||
.accessor = "__characterCharredAmount",
|
||||
.arrayCount = 0,
|
||||
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::RARELY,
|
||||
.techFlags = TECHNIQUE_FLAG_200,
|
||||
.techFlags = MTL_TECHFLAG_200,
|
||||
.techFlagShaderType = techset::CommonTechniqueShaderType::VERTEX,
|
||||
},
|
||||
{
|
||||
.value = CONST_SRC_CODE_TREECANOPY_PARMS,
|
||||
@@ -879,6 +886,8 @@ namespace T5
|
||||
.accessor = "marksHitNormal",
|
||||
.arrayCount = 0,
|
||||
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::PER_PRIM,
|
||||
.techFlags = MTL_TECHFLAG_USES_MARKS_HIT_NORMAL,
|
||||
.techFlagShaderType = techset::CommonTechniqueShaderType::VERTEX,
|
||||
},
|
||||
{
|
||||
.value = CONST_SRC_CODE_POSTFX_CONTROL0,
|
||||
@@ -1587,7 +1596,7 @@ namespace T5
|
||||
.value = TEXTURE_SRC_CODE_LIGHTMAP_PRIMARY,
|
||||
.accessor = "lightmapSamplerPrimary",
|
||||
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::CUSTOM,
|
||||
.customSamplerIndex = CUSTOM_SAMPLER_LIGHTMAP_SECONDARY,
|
||||
.customSamplerIndex = CUSTOM_SAMPLER_LIGHTMAP_PRIMARY,
|
||||
},
|
||||
{
|
||||
.value = TEXTURE_SRC_CODE_LIGHTMAP_SECONDARY,
|
||||
@@ -1709,6 +1718,7 @@ namespace T5
|
||||
.value = TEXTURE_SRC_CODE_REFLECTION_PROBE,
|
||||
.accessor = "reflectionProbeSampler",
|
||||
.updateFrequency = techset::CommonCodeSourceUpdateFrequency::CUSTOM,
|
||||
.customSamplerIndex = CUSTOM_SAMPLER_REFLECTION_PROBE,
|
||||
},
|
||||
{
|
||||
.value = TEXTURE_SRC_CODE_FEATHER_FLOAT_Z,
|
||||
|
||||
@@ -79,6 +79,7 @@ namespace techset
|
||||
std::uint8_t arrayCount;
|
||||
CommonCodeSourceUpdateFrequency updateFrequency;
|
||||
std::optional<unsigned> techFlags;
|
||||
std::optional<CommonTechniqueShaderType> techFlagShaderType;
|
||||
std::optional<CommonCodeConstSource> transposedMatrix;
|
||||
};
|
||||
|
||||
|
||||
@@ -277,7 +277,7 @@ namespace
|
||||
}
|
||||
|
||||
m_args.emplace_back(argumentType, commonDestination, techset::CommonShaderArgValue{.code_const_source = value});
|
||||
if (maybeInfo->techFlags)
|
||||
if (maybeInfo->techFlags && (!maybeInfo->techFlagShaderType || *maybeInfo->techFlagShaderType == m_shader_type))
|
||||
m_tech_flags |= *maybeInfo->techFlags;
|
||||
|
||||
return NoResult{};
|
||||
@@ -515,7 +515,7 @@ namespace
|
||||
return std::move(result);
|
||||
}
|
||||
|
||||
if (constInfo->techFlags)
|
||||
if (constInfo->techFlags && (!constInfo->techFlagShaderType || *constInfo->techFlagShaderType == m_shader_type))
|
||||
m_tech_flags |= *constInfo->techFlags;
|
||||
|
||||
return NoResult{};
|
||||
@@ -825,6 +825,15 @@ namespace
|
||||
|
||||
result::Expected<NoResult, std::string> AutoCreateConstantArg(const d3d11::ConstantBufferVariable& variable, const size_t bufferIndex)
|
||||
{
|
||||
if (!IsArgumentTypeSupported(
|
||||
techset::CommonShaderArgumentType{.m_shader_type = m_shader_type, .m_value_type = techset::CommonShaderValueType::CODE_CONST}))
|
||||
{
|
||||
con::warn("Shader {} uses unsupported argument type \"{} constant\". This may cause unstable behaviour.",
|
||||
m_shader_name,
|
||||
ShaderTypeName(m_shader_type));
|
||||
return NoResult{};
|
||||
}
|
||||
|
||||
const auto maybeCodeConst = m_common_code_source_infos.GetCodeConstSourceForAccessor(variable.m_name);
|
||||
if (!maybeCodeConst)
|
||||
{
|
||||
@@ -862,7 +871,7 @@ namespace
|
||||
return std::move(result);
|
||||
}
|
||||
|
||||
if (constInfo->techFlags)
|
||||
if (constInfo->techFlags && (!constInfo->techFlagShaderType || *constInfo->techFlagShaderType == m_shader_type))
|
||||
m_tech_flags |= *constInfo->techFlags;
|
||||
|
||||
return NoResult{};
|
||||
@@ -870,6 +879,15 @@ namespace
|
||||
|
||||
result::Expected<NoResult, std::string> AutoCreateSamplerArg(const d3d11::BoundResource& textureResource, const unsigned samplerBindPoint)
|
||||
{
|
||||
if (!IsArgumentTypeSupported(
|
||||
techset::CommonShaderArgumentType{.m_shader_type = m_shader_type, .m_value_type = techset::CommonShaderValueType::CODE_SAMPLER}))
|
||||
{
|
||||
con::warn("Shader {} uses unsupported argument type \"{} sampler\". This may cause unstable behaviour.",
|
||||
m_shader_name,
|
||||
ShaderTypeName(m_shader_type));
|
||||
return NoResult{};
|
||||
}
|
||||
|
||||
const auto maybeCodeSampler = m_common_code_source_infos.GetCodeSamplerSourceForAccessor(textureResource.m_name);
|
||||
if (!maybeCodeSampler)
|
||||
return result::Unexpected(std::format("Missing assignment to shader texture {}", textureResource.m_name));
|
||||
|
||||
@@ -33,6 +33,7 @@ namespace
|
||||
"DarkenPower",
|
||||
"Detail_Amount",
|
||||
"Detail_Normal_Tile",
|
||||
"Diffuse_MapSampler",
|
||||
"Diffuse_Normal_Height_Facing",
|
||||
"Dimensions",
|
||||
"DispersionAmount",
|
||||
@@ -44,6 +45,7 @@ namespace
|
||||
"EdgeMinDist",
|
||||
"EdgeSize",
|
||||
"Edge_Color_Multiplier",
|
||||
"Edge_Intensity",
|
||||
"Emissive_Amount",
|
||||
"EnemiesColor",
|
||||
"Exposure",
|
||||
@@ -143,6 +145,7 @@ namespace
|
||||
"NormalHeightMultiplier",
|
||||
"Normal_Detail_Height",
|
||||
"Normal_Detail_Scale",
|
||||
"Normal_MapSampler",
|
||||
"Normal_Map_Size_Scale",
|
||||
"Normal_Variance_Scale",
|
||||
"NumFrames",
|
||||
@@ -157,6 +160,7 @@ namespace
|
||||
"Player_Lookup_Scale",
|
||||
"PositiveColor",
|
||||
"Power",
|
||||
"PreviewCompID",
|
||||
"PulseColor",
|
||||
"PulseInterval",
|
||||
"PulseTime",
|
||||
@@ -165,6 +169,7 @@ namespace
|
||||
"Radius",
|
||||
"ReflectionAmount",
|
||||
"Reflection_Amount",
|
||||
"Reflection_Amt",
|
||||
"Reflection_Blur",
|
||||
"Reticle_Alt_Color",
|
||||
"Reticle_Color",
|
||||
@@ -177,6 +182,7 @@ namespace
|
||||
"ScanlineSpeed",
|
||||
"ScatterAmount",
|
||||
"ScatterSize",
|
||||
"Scatter_Intensity",
|
||||
"SceneNoise",
|
||||
"SparkleBrightness",
|
||||
"SparkleDensity",
|
||||
@@ -189,6 +195,7 @@ namespace
|
||||
"SpecularAmount",
|
||||
"SpecularColor",
|
||||
"Specular_Amount",
|
||||
"Specular_Color",
|
||||
"Specular_Decay_Threshold",
|
||||
"Speed",
|
||||
"StaticAmount",
|
||||
@@ -202,6 +209,7 @@ namespace
|
||||
"TearLookupSpeed",
|
||||
"TearMultiplier",
|
||||
"TearPower",
|
||||
"Temporal_Sharpness",
|
||||
"Thickness",
|
||||
"TickMarkColorAndHarshness",
|
||||
"Tint",
|
||||
@@ -221,6 +229,9 @@ namespace
|
||||
"WaterScale2",
|
||||
"WaterSpeed1",
|
||||
"WaterSpeed2",
|
||||
"Wetness_Color",
|
||||
"Wetness_Color_Gloss_Bias",
|
||||
"Wetness_Specular_Swatch_Scale",
|
||||
"Zoom",
|
||||
"alphaDissolveParms",
|
||||
"alphaRevealParms",
|
||||
@@ -230,6 +241,11 @@ namespace
|
||||
"alphaRevealParms4",
|
||||
"clipSpaceLookupOffset",
|
||||
"clipSpaceLookupScale",
|
||||
"cloakTextureControl0",
|
||||
"cloakTextureControl1",
|
||||
"clothcharrColorMapScale",
|
||||
"clothcharrEmberColorAndBrightness",
|
||||
"clothcharrMaskMapScale",
|
||||
"cloudsFeather",
|
||||
"cloudsHeights",
|
||||
"cloudsUVMad1",
|
||||
@@ -333,6 +349,7 @@ namespace
|
||||
"CompassMap",
|
||||
"Detail_Map",
|
||||
"Diffuse",
|
||||
"DiffuseBurnt2",
|
||||
"Diffuse_Map",
|
||||
"DpadTexture",
|
||||
"FontTextutre",
|
||||
@@ -374,6 +391,7 @@ namespace
|
||||
"Static",
|
||||
"StaticMap",
|
||||
"Static_Noise_Map",
|
||||
"Stretch_Map",
|
||||
"SunShadowSamplerState",
|
||||
"SunShadowState",
|
||||
"Surface_Normal_Map",
|
||||
|
||||
@@ -231,6 +231,7 @@ namespace
|
||||
static_cast<unsigned>(arg.m_type.m_value_type));
|
||||
return;
|
||||
}
|
||||
|
||||
const auto buffer = std::ranges::find_if(shaderInfo.m_constant_buffers,
|
||||
[&boundResource](const d3d11::ConstantBuffer& constantBuffer)
|
||||
{
|
||||
@@ -409,15 +410,15 @@ namespace
|
||||
Indent();
|
||||
|
||||
std::string materialPropertyName;
|
||||
if (m_constant_zone_state.GetConstantName(arg.m_value.name_hash, materialPropertyName)
|
||||
|| m_constant_zone_state.GetTextureDefName(arg.m_value.name_hash, materialPropertyName))
|
||||
{
|
||||
m_stream << std::format("{} = material.{};\n", codeDestAccessor, materialPropertyName);
|
||||
}
|
||||
else if (m_constant_zone_state.HashString(codeDestAccessor) == arg.m_value.name_hash)
|
||||
if (m_constant_zone_state.HashString(codeDestAccessor) == arg.m_value.name_hash)
|
||||
{
|
||||
m_stream << std::format("{} = material.{};\n", codeDestAccessor, codeDestAccessor);
|
||||
}
|
||||
else if (m_constant_zone_state.GetConstantName(arg.m_value.name_hash, materialPropertyName)
|
||||
|| m_constant_zone_state.GetTextureDefName(arg.m_value.name_hash, materialPropertyName))
|
||||
{
|
||||
m_stream << std::format("{} = material.{};\n", codeDestAccessor, materialPropertyName);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_stream << std::format("{} = material.#0x{:x};\n", codeDestAccessor, arg.m_value.name_hash);
|
||||
|
||||
Reference in New Issue
Block a user