mirror of https://github.com/AxioDL/metaforce.git
Implement tessellation shader for HLSL
This commit is contained in:
parent
1456026875
commit
8f9d7da3ee
|
@ -90,7 +90,7 @@ static const char* FS_HLSL =
|
||||||
"};\n"
|
"};\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Texture2D tex : register(t0);\n"
|
"Texture2D tex : register(t0);\n"
|
||||||
"SamplerState samp : register(s3);\n"
|
"SamplerState samp : register(s4);\n"
|
||||||
"\n"
|
"\n"
|
||||||
"float4 main(in VertToFrag vtf) : SV_Target0\n"
|
"float4 main(in VertToFrag vtf) : SV_Target0\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
namespace urde
|
namespace urde
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
class CRandom16
|
class CRandom16
|
||||||
{
|
{
|
||||||
u32 m_seed;
|
u32 m_seed;
|
||||||
|
|
|
@ -70,7 +70,7 @@ u32 CAnimTreeDoubleChild::VGetBoolPOIList(const CCharAnimTime& time, CBoolPOINod
|
||||||
if (newCapacity > capacity)
|
if (newCapacity > capacity)
|
||||||
newCapacity = capacity;
|
newCapacity = capacity;
|
||||||
|
|
||||||
std::sort(listOut, listOut + newCapacity, CPOINode::compare);
|
std::qsort(listOut, newCapacity, sizeof(CBoolPOINode), CPOINode::compare);
|
||||||
|
|
||||||
return newCapacity;
|
return newCapacity;
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ u32 CAnimTreeDoubleChild::VGetInt32POIList(const CCharAnimTime& time, CInt32POIN
|
||||||
if (newCapacity > capacity)
|
if (newCapacity > capacity)
|
||||||
newCapacity = capacity;
|
newCapacity = capacity;
|
||||||
|
|
||||||
std::sort(listOut, listOut + newCapacity, CPOINode::compare);
|
std::qsort(listOut, newCapacity, sizeof(CInt32POINode), CPOINode::compare);
|
||||||
|
|
||||||
return newCapacity;
|
return newCapacity;
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ u32 CAnimTreeDoubleChild::VGetParticlePOIList(const CCharAnimTime& time, CPartic
|
||||||
if (newCapacity > capacity)
|
if (newCapacity > capacity)
|
||||||
newCapacity = capacity;
|
newCapacity = capacity;
|
||||||
|
|
||||||
std::sort(listOut, listOut + newCapacity, CPOINode::compare);
|
std::qsort(listOut, newCapacity, sizeof(CParticlePOINode), CPOINode::compare);
|
||||||
|
|
||||||
return newCapacity;
|
return newCapacity;
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,8 @@ u32 CAnimTreeDoubleChild::VGetSoundPOIList(const CCharAnimTime& time, CSoundPOIN
|
||||||
if (newCapacity > capacity)
|
if (newCapacity > capacity)
|
||||||
newCapacity = capacity;
|
newCapacity = capacity;
|
||||||
|
|
||||||
std::sort(listOut, listOut + newCapacity, CPOINode::compare);
|
std::qsort(listOut, newCapacity, sizeof(CSoundPOINode), CPOINode::compare);
|
||||||
|
|
||||||
return newCapacity;
|
return newCapacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,11 +43,15 @@ bool CPOINode::operator<(const CPOINode& other) const
|
||||||
return x1c_time > other.x1c_time;
|
return x1c_time > other.x1c_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CPOINode::compare(const CPOINode& a, const CPOINode& b)
|
int CPOINode::compare(const void* a, const void* b)
|
||||||
{
|
{
|
||||||
if (a > b)
|
const CPOINode& na = *reinterpret_cast<const CPOINode*>(a);
|
||||||
|
const CPOINode& nb = *reinterpret_cast<const CPOINode*>(b);
|
||||||
|
if (na > nb)
|
||||||
return 1;
|
return 1;
|
||||||
return (a < b);
|
else if (na < nb)
|
||||||
|
return -1;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
|
|
|
@ -49,7 +49,7 @@ public:
|
||||||
|
|
||||||
bool operator>(const CPOINode& other) const;
|
bool operator>(const CPOINode& other) const;
|
||||||
bool operator<(const CPOINode& other) const;
|
bool operator<(const CPOINode& other) const;
|
||||||
static bool compare(const CPOINode& a, const CPOINode& b);
|
static int compare(const void* a, const void* b);
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
|
|
|
@ -882,7 +882,7 @@ CFluidPlaneShader::BuildBinding(boo::GLDataFactory::Context& ctx, const ShaderPa
|
||||||
size_t ubufOffs[] = {0, 0, 1280};
|
size_t ubufOffs[] = {0, 0, 1280};
|
||||||
size_t ubufSizes[] = {1280, 1280, sizeof(CModelShaders::LightingUniform)};
|
size_t ubufSizes[] = {1280, 1280, sizeof(CModelShaders::LightingUniform)};
|
||||||
size_t texCount = 0;
|
size_t texCount = 0;
|
||||||
boo::ObjToken<boo::ITexture> texs[7];
|
boo::ObjToken<boo::ITexture> texs[8];
|
||||||
if (m_patternTex1)
|
if (m_patternTex1)
|
||||||
texs[texCount++] = m_patternTex1->GetBooTexture();
|
texs[texCount++] = m_patternTex1->GetBooTexture();
|
||||||
if (m_patternTex2)
|
if (m_patternTex2)
|
||||||
|
@ -927,7 +927,7 @@ CFluidPlaneShader::BuildBinding(boo::VulkanDataFactory::Context& ctx, const Shad
|
||||||
size_t ubufOffs[] = {0, 0, 1280};
|
size_t ubufOffs[] = {0, 0, 1280};
|
||||||
size_t ubufSizes[] = {1280, 1280, sizeof(CModelShaders::LightingUniform)};
|
size_t ubufSizes[] = {1280, 1280, sizeof(CModelShaders::LightingUniform)};
|
||||||
size_t texCount = 0;
|
size_t texCount = 0;
|
||||||
boo::ObjToken<boo::ITexture> texs[7] = {};
|
boo::ObjToken<boo::ITexture> texs[8] = {};
|
||||||
if (m_patternTex1)
|
if (m_patternTex1)
|
||||||
texs[texCount++] = m_patternTex1->GetBooTexture();
|
texs[texCount++] = m_patternTex1->GetBooTexture();
|
||||||
if (m_patternTex2)
|
if (m_patternTex2)
|
||||||
|
|
|
@ -4,6 +4,7 @@ namespace urde
|
||||||
{
|
{
|
||||||
|
|
||||||
static boo::ObjToken<boo::IVertexFormat> s_vtxFmt;
|
static boo::ObjToken<boo::IVertexFormat> s_vtxFmt;
|
||||||
|
static boo::ObjToken<boo::IVertexFormat> s_vtxFmtTess;
|
||||||
|
|
||||||
static const char* VS =
|
static const char* VS =
|
||||||
"struct VertData\n"
|
"struct VertData\n"
|
||||||
|
@ -38,12 +39,13 @@ static const char* VS =
|
||||||
"{\n"
|
"{\n"
|
||||||
" VertToFrag vtf;\n"
|
" VertToFrag vtf;\n"
|
||||||
" float4 pos = float4(v.posIn.xyz, 1.0);\n"
|
" float4 pos = float4(v.posIn.xyz, 1.0);\n"
|
||||||
|
" float4 normalIn = v.normalIn;\n"
|
||||||
" vtf.mvPos = mul(mv, pos);\n"
|
" vtf.mvPos = mul(mv, pos);\n"
|
||||||
" vtf.pos = mul(proj, vtf.mvPos);\n"
|
" vtf.pos = mul(proj, vtf.mvPos);\n"
|
||||||
" vtf.mvNorm = mul(mvNorm, v.normalIn);\n"
|
" vtf.mvNorm = mul(mvNorm, v.normalIn);\n"
|
||||||
" vtf.mvBinorm = mul(mvNorm, v.binormalIn);\n"
|
" vtf.mvBinorm = mul(mvNorm, v.binormalIn);\n"
|
||||||
" vtf.mvTangent = mul(mvNorm, v.tangentIn);\n"
|
" vtf.mvTangent = mul(mvNorm, v.tangentIn);\n"
|
||||||
" vtf.color = v.colorIn;\n"
|
" vtf.color = float4(v.colorIn.xyz, 1.0);\n"
|
||||||
" vtf.uvs[0] = mul(texMtxs[0], pos).xy;\n"
|
" vtf.uvs[0] = mul(texMtxs[0], pos).xy;\n"
|
||||||
" vtf.uvs[1] = mul(texMtxs[1], pos).xy;\n"
|
" vtf.uvs[1] = mul(texMtxs[1], pos).xy;\n"
|
||||||
" vtf.uvs[2] = mul(texMtxs[2], pos).xy;\n"
|
" vtf.uvs[2] = mul(texMtxs[2], pos).xy;\n"
|
||||||
|
@ -51,6 +53,161 @@ static const char* VS =
|
||||||
" return vtf;\n"
|
" return vtf;\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
|
static const char* TessVS =
|
||||||
|
"struct VertData\n"
|
||||||
|
"{\n"
|
||||||
|
" float4 posIn : POSITION;\n"
|
||||||
|
" float4 outerLevelsIn : UV0;\n"
|
||||||
|
" float2 innerLevelsIn : UV1;\n"
|
||||||
|
"};\n"
|
||||||
|
"\n"
|
||||||
|
"struct VertToControl\n"
|
||||||
|
"{\n"
|
||||||
|
" float4 minMaxPos : POSITION;\n"
|
||||||
|
" float4 outerLevels : OUTERLEVELS;\n"
|
||||||
|
" float2 innerLevels : INNERLEVELS;\n"
|
||||||
|
"};\n"
|
||||||
|
"\n"
|
||||||
|
"VertToControl main(in VertData v)\n"
|
||||||
|
"{\n"
|
||||||
|
" VertToControl vtc;\n"
|
||||||
|
" vtc.minMaxPos = v.posIn;\n"
|
||||||
|
" vtc.outerLevels = v.outerLevelsIn;\n"
|
||||||
|
" vtc.innerLevels = v.innerLevelsIn;\n"
|
||||||
|
" return vtc;\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
static const char* TessCS =
|
||||||
|
"struct VertToControl\n"
|
||||||
|
"{\n"
|
||||||
|
" float4 minMaxPos : POSITION;\n"
|
||||||
|
" float4 outerLevels : OUTERLEVELS;\n"
|
||||||
|
" float2 innerLevels : INNERLEVELS;\n"
|
||||||
|
"};\n"
|
||||||
|
"\n"
|
||||||
|
"struct ControlToEvaluation\n"
|
||||||
|
"{\n"
|
||||||
|
" float4 minMaxPos : POSITION;\n"
|
||||||
|
" float outerLevels[4] : SV_TessFactor;\n"
|
||||||
|
" float innerLevels[2] : SV_InsideTessFactor;\n"
|
||||||
|
"};\n"
|
||||||
|
"\n"
|
||||||
|
"struct ControlPoint\n"
|
||||||
|
"{};\n"
|
||||||
|
"\n"
|
||||||
|
"ControlToEvaluation patchmain(InputPatch<VertToControl, 1> vtc, uint id : SV_PrimitiveID)\n"
|
||||||
|
"{\n"
|
||||||
|
" ControlToEvaluation cte;\n"
|
||||||
|
" cte.minMaxPos = vtc[id].minMaxPos;\n"
|
||||||
|
" for (int i=0 ; i<4 ; ++i)\n"
|
||||||
|
" cte.outerLevels[i] = vtc[id].outerLevels[i];\n"
|
||||||
|
" for (int i=0 ; i<2 ; ++i)\n"
|
||||||
|
" cte.innerLevels[i] = vtc[id].innerLevels[i];\n"
|
||||||
|
" return cte;\n"
|
||||||
|
"}\n"
|
||||||
|
"\n"
|
||||||
|
"[domain(\"quad\")]\n"
|
||||||
|
"[partitioning(\"integer\")]\n"
|
||||||
|
"[outputtopology(\"triangle_cw\")]\n"
|
||||||
|
"[outputcontrolpoints(1)]\n"
|
||||||
|
"[patchconstantfunc(\"patchmain\")]\n"
|
||||||
|
"ControlPoint main(InputPatch<VertToControl, 1> vtc, uint i : SV_OutputControlPointID, uint id : SV_PrimitiveID)\n"
|
||||||
|
"{\n"
|
||||||
|
" ControlPoint pt;\n"
|
||||||
|
" return pt;\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
static const char* TessES =
|
||||||
|
"struct Ripple\n"
|
||||||
|
"{\n"
|
||||||
|
" float4 center; // time, distFalloff\n"
|
||||||
|
" float4 params; // amplitude, lookupPhase, lookupTime\n"
|
||||||
|
"};\n"
|
||||||
|
"\n"
|
||||||
|
"cbuffer FluidPlaneUniform : register(b0)\n"
|
||||||
|
"{\n"
|
||||||
|
" float4x4 mv;\n"
|
||||||
|
" float4x4 mvNorm;\n"
|
||||||
|
" float4x4 proj;\n"
|
||||||
|
" float4x4 texMtxs[6];\n"
|
||||||
|
" Ripple ripples[20];\n"
|
||||||
|
" float4 colorMul;\n"
|
||||||
|
" float rippleNormResolution;\n"
|
||||||
|
"};\n"
|
||||||
|
"\n"
|
||||||
|
"struct VertToFrag\n"
|
||||||
|
"{\n"
|
||||||
|
" float4 pos : SV_Position;\n"
|
||||||
|
" float4 mvPos : POSITION;\n"
|
||||||
|
" float4 mvNorm : NORMAL;\n"
|
||||||
|
" float4 mvBinorm : BINORMAL;\n"
|
||||||
|
" float4 mvTangent : TANGENT;\n"
|
||||||
|
" float4 color : COLOR;\n"
|
||||||
|
" float2 uvs[7] : UV;\n"
|
||||||
|
"};\n"
|
||||||
|
"\n"
|
||||||
|
"struct ControlToEvaluation\n"
|
||||||
|
"{\n"
|
||||||
|
" float4 minMaxPos : POSITION;\n"
|
||||||
|
" float outerLevels[4] : SV_TessFactor;\n"
|
||||||
|
" float innerLevels[2] : SV_InsideTessFactor;\n"
|
||||||
|
"};\n"
|
||||||
|
"\n"
|
||||||
|
"struct ControlPoint\n"
|
||||||
|
"{};\n"
|
||||||
|
"\n"
|
||||||
|
"Texture2D RippleMap : register(t%d);\n"
|
||||||
|
"SamplerState samp : register(s2);\n"
|
||||||
|
"\n"
|
||||||
|
"static const float PI_X2 = 6.283185307179586;\n"
|
||||||
|
"\n"
|
||||||
|
"static void ApplyRipple(in Ripple ripple, in float2 pos, inout float height)\n"
|
||||||
|
"{\n"
|
||||||
|
" float dist = length(ripple.center.xy - pos);\n"
|
||||||
|
" float rippleV = RippleMap.SampleLevel(samp, float2(dist * ripple.center.w, ripple.center.z), 0.0).r;\n"
|
||||||
|
" height += rippleV * ripple.params.x * sin((dist * ripple.params.y + ripple.params.z) * PI_X2);\n"
|
||||||
|
"}\n"
|
||||||
|
"\n"
|
||||||
|
"[domain(\"quad\")]\n"
|
||||||
|
"VertToFrag main(in ControlToEvaluation cte, in float2 TessCoord : SV_DomainLocation,\n"
|
||||||
|
" const OutputPatch<ControlPoint, 1> bezpatch)\n"
|
||||||
|
"{\n"
|
||||||
|
" float2 posIn = float2(lerp(cte.minMaxPos.x, cte.minMaxPos.z, TessCoord.x),\n"
|
||||||
|
" lerp(cte.minMaxPos.y, cte.minMaxPos.w, TessCoord.y));\n"
|
||||||
|
" float height = 0.0;\n"
|
||||||
|
" float upHeight = 0.0;\n"
|
||||||
|
" float downHeight = 0.0;\n"
|
||||||
|
" float rightHeight = 0.0;\n"
|
||||||
|
" float leftHeight = 0.0;\n"
|
||||||
|
" for (int i=0 ; i<20 ; ++i)\n"
|
||||||
|
" {\n"
|
||||||
|
" ApplyRipple(ripples[i], posIn, height);\n"
|
||||||
|
" ApplyRipple(ripples[i], posIn + float2(0.0, rippleNormResolution), upHeight);\n"
|
||||||
|
" ApplyRipple(ripples[i], posIn - float2(0.0, rippleNormResolution), downHeight);\n"
|
||||||
|
" ApplyRipple(ripples[i], posIn + float2(rippleNormResolution, 0.0), rightHeight);\n"
|
||||||
|
" ApplyRipple(ripples[i], posIn - float2(rippleNormResolution, 0.0), leftHeight);\n"
|
||||||
|
" }\n"
|
||||||
|
" float4 normalIn = float4(normalize(float3((leftHeight - rightHeight),\n"
|
||||||
|
" (downHeight - upHeight),\n"
|
||||||
|
" rippleNormResolution)), 1.0);\n"
|
||||||
|
" float4 binormalIn = float4(normalIn.x, normalIn.z, -normalIn.y, 1.0);\n"
|
||||||
|
" float4 tangentIn = float4(normalIn.z, normalIn.y, -normalIn.x, 1.0);\n"
|
||||||
|
" float4 pos = float4(posIn, height, 1.0);\n"
|
||||||
|
" VertToFrag vtf;\n"
|
||||||
|
" vtf.mvPos = mul(mv, pos);\n"
|
||||||
|
" vtf.pos = mul(proj, vtf.mvPos);\n"
|
||||||
|
" vtf.mvNorm = mul(mvNorm, normalIn);\n"
|
||||||
|
" vtf.mvBinorm = mul(mvNorm, binormalIn);\n"
|
||||||
|
" vtf.mvTangent = mul(mvNorm, tangentIn);\n"
|
||||||
|
" vtf.color = max(height, 0.0) * colorMul;\n"
|
||||||
|
" vtf.color.a = 1.0;\n"
|
||||||
|
" vtf.uvs[0] = mul(texMtxs[0], pos).xy;\n"
|
||||||
|
" vtf.uvs[1] = mul(texMtxs[1], pos).xy;\n"
|
||||||
|
" vtf.uvs[2] = mul(texMtxs[2], pos).xy;\n"
|
||||||
|
"%s\n" // Additional TCGs here
|
||||||
|
" return vtf;\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
static const char* FS =
|
static const char* FS =
|
||||||
"struct Light\n"
|
"struct Light\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
@ -168,7 +325,7 @@ static const char* FSDoor =
|
||||||
" return colorOut;\n"
|
" return colorOut;\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
boo::ObjToken<boo::IShaderPipeline>
|
CFluidPlaneShader::ShaderPair
|
||||||
CFluidPlaneShader::BuildShader(boo::D3DDataFactory::Context& ctx, const SFluidPlaneShaderInfo& info)
|
CFluidPlaneShader::BuildShader(boo::D3DDataFactory::Context& ctx, const SFluidPlaneShaderInfo& info)
|
||||||
{
|
{
|
||||||
if (!s_vtxFmt)
|
if (!s_vtxFmt)
|
||||||
|
@ -215,7 +372,7 @@ CFluidPlaneShader::BuildShader(boo::D3DDataFactory::Context& ctx, const SFluidPl
|
||||||
if (info.m_hasEnvBumpMap)
|
if (info.m_hasEnvBumpMap)
|
||||||
{
|
{
|
||||||
envBumpMapUv = nextTCG;
|
envBumpMapUv = nextTCG;
|
||||||
additionalTCGs += hecl::Format(" vtf.uvs[%d] = mul(texMtxs[3], float4(v.normalIn.xyz, 1.0)).xy;\n", nextTCG++);
|
additionalTCGs += hecl::Format(" vtf.uvs[%d] = mul(texMtxs[3], float4(normalIn.xyz, 1.0)).xy;\n", nextTCG++);
|
||||||
}
|
}
|
||||||
if (info.m_hasEnvMap)
|
if (info.m_hasEnvMap)
|
||||||
{
|
{
|
||||||
|
@ -230,9 +387,9 @@ CFluidPlaneShader::BuildShader(boo::D3DDataFactory::Context& ctx, const SFluidPl
|
||||||
|
|
||||||
switch (info.m_type)
|
switch (info.m_type)
|
||||||
{
|
{
|
||||||
case CFluidPlane::EFluidType::NormalWater:
|
case EFluidType::NormalWater:
|
||||||
case CFluidPlane::EFluidType::PhazonFluid:
|
case EFluidType::PhazonFluid:
|
||||||
case CFluidPlane::EFluidType::Four:
|
case EFluidType::Four:
|
||||||
if (info.m_hasLightmap)
|
if (info.m_hasLightmap)
|
||||||
{
|
{
|
||||||
combiner += hecl::Format(" float4 lightMapTexel = lightMap.Sample(samp, vtf.uvs[%d]);\n", lightmapUv);
|
combiner += hecl::Format(" float4 lightMapTexel = lightMap.Sample(samp, vtf.uvs[%d]);\n", lightmapUv);
|
||||||
|
@ -247,7 +404,7 @@ CFluidPlaneShader::BuildShader(boo::D3DDataFactory::Context& ctx, const SFluidPl
|
||||||
// Output reg 2
|
// Output reg 2
|
||||||
// KColor 3
|
// KColor 3
|
||||||
// Tex * K2 + Lighting
|
// Tex * K2 + Lighting
|
||||||
combiner += " lighting += mix(lightMapTexel * kColor2, lightMapTexel, kColor3);\n";
|
combiner += " lighting += lerp(lightMapTexel * kColor2, lightMapTexel, kColor3);\n";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -303,7 +460,7 @@ CFluidPlaneShader::BuildShader(boo::D3DDataFactory::Context& ctx, const SFluidPl
|
||||||
combiner += " colorOut += colorTex.Sample(samp, vtf.uvs[2]) * lighting;\n";
|
combiner += " colorOut += colorTex.Sample(samp, vtf.uvs[2]) * lighting;\n";
|
||||||
combiner += hecl::Format(" float2 indUvs = (envBumpMap.Sample(samp, vtf.uvs[%d]).ra - float2(0.5, 0.5)) *\n"
|
combiner += hecl::Format(" float2 indUvs = (envBumpMap.Sample(samp, vtf.uvs[%d]).ra - float2(0.5, 0.5)) *\n"
|
||||||
" float2(fog.indScale, -fog.indScale);\n", envBumpMapUv);
|
" float2(fog.indScale, -fog.indScale);\n", envBumpMapUv);
|
||||||
combiner += hecl::Format(" colorOut = mix(colorOut, envMap.Sample(samp, indUvs + vtf.uvs[%d]), kColor1);\n",
|
combiner += hecl::Format(" colorOut = lerp(colorOut, envMap.Sample(samp, indUvs + vtf.uvs[%d]), kColor1);\n",
|
||||||
envMapUv);
|
envMapUv);
|
||||||
}
|
}
|
||||||
else if (info.m_hasColorTex)
|
else if (info.m_hasColorTex)
|
||||||
|
@ -313,7 +470,7 @@ CFluidPlaneShader::BuildShader(boo::D3DDataFactory::Context& ctx, const SFluidPl
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CFluidPlane::EFluidType::PoisonWater:
|
case EFluidType::PoisonWater:
|
||||||
if (info.m_hasLightmap)
|
if (info.m_hasLightmap)
|
||||||
{
|
{
|
||||||
combiner += hecl::Format(" float4 lightMapTexel = lightMap.Sample(samp, vtf.uvs[%d]);\n", lightmapUv);
|
combiner += hecl::Format(" float4 lightMapTexel = lightMap.Sample(samp, vtf.uvs[%d]);\n", lightmapUv);
|
||||||
|
@ -328,7 +485,7 @@ CFluidPlaneShader::BuildShader(boo::D3DDataFactory::Context& ctx, const SFluidPl
|
||||||
// Output reg 2
|
// Output reg 2
|
||||||
// KColor 3
|
// KColor 3
|
||||||
// Tex * K2 + Lighting
|
// Tex * K2 + Lighting
|
||||||
combiner += " lighting += mix(lightMapTexel * kColor2, lightMapTexel, kColor3);\n";
|
combiner += " lighting += lerp(lightMapTexel * kColor2, lightMapTexel, kColor3);\n";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -381,7 +538,7 @@ CFluidPlaneShader::BuildShader(boo::D3DDataFactory::Context& ctx, const SFluidPl
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CFluidPlane::EFluidType::Lava:
|
case EFluidType::Lava:
|
||||||
// 0: Tex0TCG, Tex0, GX_COLOR0A0
|
// 0: Tex0TCG, Tex0, GX_COLOR0A0
|
||||||
// ZERO, TEX, KONST, RAS
|
// ZERO, TEX, KONST, RAS
|
||||||
// Output reg prev
|
// Output reg prev
|
||||||
|
@ -439,7 +596,7 @@ CFluidPlaneShader::BuildShader(boo::D3DDataFactory::Context& ctx, const SFluidPl
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CFluidPlane::EFluidType::ThickLava:
|
case EFluidType::ThickLava:
|
||||||
// 0: Tex0TCG, Tex0, GX_COLOR0A0
|
// 0: Tex0TCG, Tex0, GX_COLOR0A0
|
||||||
// ZERO, TEX, KONST, RAS
|
// ZERO, TEX, KONST, RAS
|
||||||
// Output reg prev
|
// Output reg prev
|
||||||
|
@ -488,19 +645,46 @@ CFluidPlaneShader::BuildShader(boo::D3DDataFactory::Context& ctx, const SFluidPl
|
||||||
asprintf(&finalVS, VS, additionalTCGs.c_str());
|
asprintf(&finalVS, VS, additionalTCGs.c_str());
|
||||||
asprintf(&finalFS, FS, textures.c_str(), combiner.c_str());
|
asprintf(&finalFS, FS, textures.c_str(), combiner.c_str());
|
||||||
|
|
||||||
auto ret = ctx.newShaderPipeline(finalVS, finalFS, nullptr, nullptr, nullptr, s_vtxFmt,
|
auto regular = ctx.newShaderPipeline(finalVS, finalFS, nullptr, nullptr, nullptr, s_vtxFmt,
|
||||||
info.m_additive ? boo::BlendFactor::One : boo::BlendFactor::SrcAlpha,
|
info.m_additive ? boo::BlendFactor::One : boo::BlendFactor::SrcAlpha,
|
||||||
info.m_additive ? boo::BlendFactor::One : boo::BlendFactor::InvSrcAlpha,
|
info.m_additive ? boo::BlendFactor::One : boo::BlendFactor::InvSrcAlpha,
|
||||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, false,
|
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, false,
|
||||||
boo::CullMode::None);
|
boo::CullMode::None);
|
||||||
|
|
||||||
|
boo::ObjToken<boo::IShaderPipeline> tessellation;
|
||||||
|
if (info.m_tessellation)
|
||||||
|
{
|
||||||
|
if (!s_vtxFmtTess)
|
||||||
|
{
|
||||||
|
boo::VertexElementDescriptor elements[] =
|
||||||
|
{
|
||||||
|
{nullptr, nullptr, boo::VertexSemantic::Position4},
|
||||||
|
{nullptr, nullptr, boo::VertexSemantic::UV4, 0},
|
||||||
|
{nullptr, nullptr, boo::VertexSemantic::UV4, 1}
|
||||||
|
};
|
||||||
|
s_vtxFmtTess = ctx.newVertexFormat(3, elements);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *finalESs;
|
||||||
|
asprintf(&finalESs, TessES, nextTex, additionalTCGs.c_str());
|
||||||
|
|
||||||
|
tessellation = ctx.newTessellationShaderPipeline(
|
||||||
|
TessVS, finalFS, TessCS, finalESs,
|
||||||
|
nullptr, nullptr, nullptr, nullptr, nullptr, s_vtxFmtTess,
|
||||||
|
info.m_additive ? boo::BlendFactor::One : boo::BlendFactor::SrcAlpha,
|
||||||
|
info.m_additive ? boo::BlendFactor::One : boo::BlendFactor::InvSrcAlpha,
|
||||||
|
1, boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
|
||||||
|
|
||||||
|
free(finalESs);
|
||||||
|
}
|
||||||
|
|
||||||
free(finalVS);
|
free(finalVS);
|
||||||
free(finalFS);
|
free(finalFS);
|
||||||
|
|
||||||
return ret;
|
return {regular, tessellation};
|
||||||
}
|
}
|
||||||
|
|
||||||
boo::ObjToken<boo::IShaderPipeline>
|
CFluidPlaneShader::ShaderPair
|
||||||
CFluidPlaneShader::BuildShader(boo::D3DDataFactory::Context& ctx, const SFluidPlaneDoorShaderInfo& info)
|
CFluidPlaneShader::BuildShader(boo::D3DDataFactory::Context& ctx, const SFluidPlaneDoorShaderInfo& info)
|
||||||
{
|
{
|
||||||
if (!s_vtxFmt)
|
if (!s_vtxFmt)
|
||||||
|
@ -558,42 +742,50 @@ CFluidPlaneShader::BuildShader(boo::D3DDataFactory::Context& ctx, const SFluidPl
|
||||||
free(finalVS);
|
free(finalVS);
|
||||||
free(finalFS);
|
free(finalFS);
|
||||||
|
|
||||||
return ret;
|
return {ret, {}};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void CFluidPlaneShader::_Shutdown<boo::D3DDataFactory>()
|
void CFluidPlaneShader::_Shutdown<boo::D3DDataFactory>()
|
||||||
{
|
{
|
||||||
s_vtxFmt.reset();
|
s_vtxFmt.reset();
|
||||||
|
s_vtxFmtTess.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
boo::ObjToken<boo::IShaderDataBinding>
|
CFluidPlaneShader::BindingPair
|
||||||
CFluidPlaneShader::BuildBinding(boo::D3DDataFactory::Context& ctx,
|
CFluidPlaneShader::BuildBinding(boo::D3DDataFactory::Context& ctx, const ShaderPair& pipeline)
|
||||||
const boo::ObjToken<boo::IShaderPipeline>& pipeline, bool door)
|
|
||||||
{
|
{
|
||||||
boo::ObjToken<boo::IGraphicsBuffer> ubufs[] = { m_uniBuf.get(), m_uniBuf.get(), m_uniBuf.get() };
|
boo::ObjToken<boo::IGraphicsBuffer> ubufs[] = { m_uniBuf.get(), m_uniBuf.get(), m_uniBuf.get() };
|
||||||
boo::PipelineStage ubufStages[] = { boo::PipelineStage::Vertex, boo::PipelineStage::Vertex,
|
boo::PipelineStage ubufStages[] = { boo::PipelineStage::Vertex, boo::PipelineStage::Vertex,
|
||||||
boo::PipelineStage::Fragment };
|
boo::PipelineStage::Fragment };
|
||||||
size_t ubufOffs[] = {0, 0, 768};
|
size_t ubufOffs[] = {0, 0, 1280};
|
||||||
size_t ubufSizes[] = {768, 768, sizeof(CModelShaders::LightingUniform)};
|
size_t ubufSizes[] = {1280, 1280, sizeof(CModelShaders::LightingUniform)};
|
||||||
size_t texCount = 0;
|
size_t texCount = 0;
|
||||||
boo::ObjToken<boo::ITexture> texs[7] = {};
|
boo::ObjToken<boo::ITexture> texs[8] = {};
|
||||||
if (m_patternTex1)
|
if (m_patternTex1)
|
||||||
texs[texCount++] = (*m_patternTex1)->GetBooTexture();
|
texs[texCount++] = m_patternTex1->GetBooTexture();
|
||||||
if (m_patternTex2)
|
if (m_patternTex2)
|
||||||
texs[texCount++] = (*m_patternTex2)->GetBooTexture();
|
texs[texCount++] = m_patternTex2->GetBooTexture();
|
||||||
if (m_colorTex)
|
if (m_colorTex)
|
||||||
texs[texCount++] = (*m_colorTex)->GetBooTexture();
|
texs[texCount++] = m_colorTex->GetBooTexture();
|
||||||
if (m_bumpMap)
|
if (m_bumpMap)
|
||||||
texs[texCount++] = (*m_bumpMap)->GetBooTexture();
|
texs[texCount++] = m_bumpMap->GetBooTexture();
|
||||||
if (m_envMap)
|
if (m_envMap)
|
||||||
texs[texCount++] = (*m_envMap)->GetBooTexture();
|
texs[texCount++] = m_envMap->GetBooTexture();
|
||||||
if (m_envBumpMap)
|
if (m_envBumpMap)
|
||||||
texs[texCount++] = (*m_envBumpMap)->GetBooTexture();
|
texs[texCount++] = m_envBumpMap->GetBooTexture();
|
||||||
if (m_lightmap)
|
if (m_lightmap)
|
||||||
texs[texCount++] = (*m_lightmap)->GetBooTexture();
|
texs[texCount++] = m_lightmap->GetBooTexture();
|
||||||
return ctx.newShaderDataBinding(pipeline, s_vtxFmt, m_vbo.get(), nullptr, nullptr, 3,
|
auto regular = ctx.newShaderDataBinding(pipeline.m_regular, s_vtxFmt, m_vbo.get(), nullptr, nullptr, 3,
|
||||||
ubufs, ubufStages, ubufOffs, ubufSizes, texCount, texs, nullptr, nullptr);
|
ubufs, ubufStages, ubufOffs, ubufSizes, texCount, texs, nullptr, nullptr);
|
||||||
|
boo::ObjToken<boo::IShaderDataBinding> tessellation;
|
||||||
|
if (pipeline.m_tessellation)
|
||||||
|
{
|
||||||
|
texs[texCount++] = m_rippleMap.get();
|
||||||
|
tessellation = ctx.newShaderDataBinding(pipeline.m_tessellation, s_vtxFmtTess, m_pvbo.get(), nullptr, nullptr,
|
||||||
|
3, ubufs, ubufStages, ubufOffs, ubufSizes, texCount, texs, nullptr, nullptr);
|
||||||
|
}
|
||||||
|
return {regular, tessellation};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@ static const char* FS =
|
||||||
" float2 maskUv : UV2;\n"
|
" float2 maskUv : UV2;\n"
|
||||||
"};\n"
|
"};\n"
|
||||||
"\n"
|
"\n"
|
||||||
"SamplerState samp : register(s2);\n"
|
"SamplerState samp : register(s3);\n"
|
||||||
"Texture2D screenTex : register(t0);\n"
|
"Texture2D screenTex : register(t0);\n"
|
||||||
"Texture2D maskTex : register(t1);\n"
|
"Texture2D maskTex : register(t1);\n"
|
||||||
"Texture2D maskTexBlur : register(t2);\n"
|
"Texture2D maskTexBlur : register(t2);\n"
|
||||||
|
@ -124,7 +124,7 @@ static const char* BlurFS =
|
||||||
" float2 blurDir : BLURDIR;\n"
|
" float2 blurDir : BLURDIR;\n"
|
||||||
"};\n"
|
"};\n"
|
||||||
"\n"
|
"\n"
|
||||||
"SamplerState samp : register(s2);\n"
|
"SamplerState samp : register(s3);\n"
|
||||||
"Texture2D maskTex : register(t0);\n"
|
"Texture2D maskTex : register(t0);\n"
|
||||||
"float4 main(in VertToFrag vtf) : SV_Target0\n"
|
"float4 main(in VertToFrag vtf) : SV_Target0\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
|
|
@ -53,7 +53,7 @@ static const char* TextFS =
|
||||||
"};\n"
|
"};\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Texture2DArray tex : register(t0);\n"
|
"Texture2DArray tex : register(t0);\n"
|
||||||
"SamplerState samp : register(s2);\n"
|
"SamplerState samp : register(s3);\n"
|
||||||
"\n"
|
"\n"
|
||||||
"float4 main(in VertToFrag vtf) : SV_Target0\n"
|
"float4 main(in VertToFrag vtf) : SV_Target0\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
@ -100,7 +100,7 @@ static const char* ImgFS =
|
||||||
"};\n"
|
"};\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Texture2D tex : register(t0);\n"
|
"Texture2D tex : register(t0);\n"
|
||||||
"SamplerState samp : register(s2);\n"
|
"SamplerState samp : register(s3);\n"
|
||||||
"\n"
|
"\n"
|
||||||
"float4 main(in VertToFrag vtf) : SV_Target0\n"
|
"float4 main(in VertToFrag vtf) : SV_Target0\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
|
|
@ -79,7 +79,7 @@ static const char* FS =
|
||||||
"};\n"
|
"};\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Texture2D tex : register(t0);\n"
|
"Texture2D tex : register(t0);\n"
|
||||||
"SamplerState samp : register(s2);\n"
|
"SamplerState samp : register(s3);\n"
|
||||||
"\n"
|
"\n"
|
||||||
"float4 main(in VertToFrag vtf) : SV_Target0\n"
|
"float4 main(in VertToFrag vtf) : SV_Target0\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
@ -96,7 +96,7 @@ static const char* FSAlpha =
|
||||||
"};\n"
|
"};\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Texture2D tex : register(t0);\n"
|
"Texture2D tex : register(t0);\n"
|
||||||
"SamplerState samp : register(s2);\n"
|
"SamplerState samp : register(s3);\n"
|
||||||
"\n"
|
"\n"
|
||||||
"float4 main(in VertToFrag vtf) : SV_Target0\n"
|
"float4 main(in VertToFrag vtf) : SV_Target0\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
|
|
@ -50,7 +50,7 @@ static const char* VS =
|
||||||
static const char* FS =
|
static const char* FS =
|
||||||
"Texture2D sceneTex : register(t0);\n"
|
"Texture2D sceneTex : register(t0);\n"
|
||||||
"Texture2D shiftTex : register(t1);\n"
|
"Texture2D shiftTex : register(t1);\n"
|
||||||
"SamplerState samp : register(s2);\n"
|
"SamplerState samp : register(s3);\n"
|
||||||
"struct VertToFrag\n"
|
"struct VertToFrag\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" float4 position : SV_Position;\n"
|
" float4 position : SV_Position;\n"
|
||||||
|
|
|
@ -63,7 +63,7 @@ static const char* VS =
|
||||||
static const char* FS =
|
static const char* FS =
|
||||||
"Texture2D sceneTex : register(t0);\n"
|
"Texture2D sceneTex : register(t0);\n"
|
||||||
"Texture2D paletteTex : register(t1);\n"
|
"Texture2D paletteTex : register(t1);\n"
|
||||||
"SamplerState samp : register(s2);\n"
|
"SamplerState samp : register(s3);\n"
|
||||||
"struct VertToFrag\n"
|
"struct VertToFrag\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" float4 position : SV_Position;\n"
|
" float4 position : SV_Position;\n"
|
||||||
|
|
|
@ -164,10 +164,14 @@ CElementGen::CElementGen(const TToken<CGenDescription>& gen,
|
||||||
else
|
else
|
||||||
x268_PSLT = INT_MAX;
|
x268_PSLT = INT_MAX;
|
||||||
|
|
||||||
|
int useMAXP = 256;
|
||||||
if (CIntElement* maxpElem = desc->x28_x1c_MAXP.get())
|
if (CIntElement* maxpElem = desc->x28_x1c_MAXP.get())
|
||||||
|
{
|
||||||
maxpElem->GetValue(x74_curFrame, x90_MAXP);
|
maxpElem->GetValue(x74_curFrame, x90_MAXP);
|
||||||
|
useMAXP = maxpElem->GetMaxValue();
|
||||||
|
}
|
||||||
|
|
||||||
int useMAXP = std::min(x90_MAXP, 256);
|
useMAXP = std::min(useMAXP, 256);
|
||||||
x30_particles.reserve(useMAXP);
|
x30_particles.reserve(useMAXP);
|
||||||
if (x2c_orientType == EModelOrientationType::One)
|
if (x2c_orientType == EModelOrientationType::One)
|
||||||
x50_parentMatrices.resize(useMAXP);
|
x50_parentMatrices.resize(useMAXP);
|
||||||
|
@ -231,7 +235,7 @@ CElementGen::CElementGen(const TToken<CGenDescription>& gen,
|
||||||
m_shaderClass = CElementGenShaders::GetShaderClass(*this);
|
m_shaderClass = CElementGenShaders::GetShaderClass(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t maxInsts = x26c_30_MBLR ? (m_maxMBSP * x90_MAXP) : x90_MAXP;
|
size_t maxInsts = x26c_30_MBLR ? (m_maxMBSP * useMAXP) : useMAXP;
|
||||||
maxInsts = (maxInsts == 0 ? 256 : maxInsts);
|
maxInsts = (maxInsts == 0 ? 256 : maxInsts);
|
||||||
|
|
||||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
|
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
|
||||||
|
|
|
@ -60,6 +60,15 @@ bool CIEKeyframeEmitter::GetValue(int frame, int& valOut) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CIEKeyframeEmitter::GetMaxValue() const
|
||||||
|
{
|
||||||
|
int maxVal = INT_MIN;
|
||||||
|
for (int k : x18_keys)
|
||||||
|
if (k > maxVal)
|
||||||
|
maxVal = k;
|
||||||
|
return maxVal;
|
||||||
|
}
|
||||||
|
|
||||||
bool CIEDeath::GetValue(int frame, int &valOut) const
|
bool CIEDeath::GetValue(int frame, int &valOut) const
|
||||||
{
|
{
|
||||||
x4_a->GetValue(frame, valOut);
|
x4_a->GetValue(frame, valOut);
|
||||||
|
@ -69,6 +78,11 @@ bool CIEDeath::GetValue(int frame, int &valOut) const
|
||||||
return frame > b;
|
return frame > b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CIEDeath::GetMaxValue() const
|
||||||
|
{
|
||||||
|
return x4_a->GetMaxValue();
|
||||||
|
}
|
||||||
|
|
||||||
bool CIEClamp::GetValue(int frame, int& valOut) const
|
bool CIEClamp::GetValue(int frame, int& valOut) const
|
||||||
{
|
{
|
||||||
int a, b;
|
int a, b;
|
||||||
|
@ -82,6 +96,19 @@ bool CIEClamp::GetValue(int frame, int& valOut) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CIEClamp::GetMaxValue() const
|
||||||
|
{
|
||||||
|
int a, b, valOut;
|
||||||
|
a = x4_min->GetMaxValue();
|
||||||
|
b = x8_max->GetMaxValue();
|
||||||
|
valOut = xc_val->GetMaxValue();
|
||||||
|
if (valOut > b)
|
||||||
|
valOut = b;
|
||||||
|
if (valOut < a)
|
||||||
|
valOut = a;
|
||||||
|
return valOut;
|
||||||
|
}
|
||||||
|
|
||||||
bool CIETimeChain::GetValue(int frame, int& valOut) const
|
bool CIETimeChain::GetValue(int frame, int& valOut) const
|
||||||
{
|
{
|
||||||
int v;
|
int v;
|
||||||
|
@ -92,6 +119,11 @@ bool CIETimeChain::GetValue(int frame, int& valOut) const
|
||||||
return x4_a->GetValue(frame, valOut);
|
return x4_a->GetValue(frame, valOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CIETimeChain::GetMaxValue() const
|
||||||
|
{
|
||||||
|
return std::max(x8_b->GetMaxValue(), x4_a->GetMaxValue());
|
||||||
|
}
|
||||||
|
|
||||||
bool CIEAdd::GetValue(int frame, int& valOut) const
|
bool CIEAdd::GetValue(int frame, int& valOut) const
|
||||||
{
|
{
|
||||||
int a, b;
|
int a, b;
|
||||||
|
@ -101,12 +133,25 @@ bool CIEAdd::GetValue(int frame, int& valOut) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CIEAdd::GetMaxValue() const
|
||||||
|
{
|
||||||
|
int a, b;
|
||||||
|
a = x4_a->GetMaxValue();
|
||||||
|
b = x8_b->GetMaxValue();
|
||||||
|
return a + b;
|
||||||
|
}
|
||||||
|
|
||||||
bool CIEConstant::GetValue(int frame, int& valOut) const
|
bool CIEConstant::GetValue(int frame, int& valOut) const
|
||||||
{
|
{
|
||||||
valOut = x4_val;
|
valOut = x4_val;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CIEConstant::GetMaxValue() const
|
||||||
|
{
|
||||||
|
return x4_val;
|
||||||
|
}
|
||||||
|
|
||||||
bool CIEImpulse::GetValue(int frame, int& valOut) const
|
bool CIEImpulse::GetValue(int frame, int& valOut) const
|
||||||
{
|
{
|
||||||
if (frame == 0)
|
if (frame == 0)
|
||||||
|
@ -116,15 +161,28 @@ bool CIEImpulse::GetValue(int frame, int& valOut) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CIEImpulse::GetMaxValue() const
|
||||||
|
{
|
||||||
|
return x4_a->GetMaxValue();
|
||||||
|
}
|
||||||
|
|
||||||
bool CIELifetimePercent::GetValue(int frame, int& valOut) const
|
bool CIELifetimePercent::GetValue(int frame, int& valOut) const
|
||||||
{
|
{
|
||||||
int a;
|
int a;
|
||||||
x4_percentVal->GetValue(frame, a);
|
x4_percentVal->GetValue(frame, a);
|
||||||
a = std::max(0, a);
|
a = std::max(0, a);
|
||||||
valOut = (a / 100.0f) * CParticleGlobals::g_ParticleLifetimeReal;
|
valOut = (a / 100.0f) * CParticleGlobals::g_ParticleLifetimeReal + 0.5f;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CIELifetimePercent::GetMaxValue() const
|
||||||
|
{
|
||||||
|
int a;
|
||||||
|
a = x4_percentVal->GetMaxValue();
|
||||||
|
a = std::max(0, a);
|
||||||
|
return (a / 100.0f) * 10000 + 0.5f; /* Assume 10000 frames max (not ideal estimate) */
|
||||||
|
}
|
||||||
|
|
||||||
bool CIEInitialRandom::GetValue(int frame, int& valOut) const
|
bool CIEInitialRandom::GetValue(int frame, int& valOut) const
|
||||||
{
|
{
|
||||||
if (frame == 0)
|
if (frame == 0)
|
||||||
|
@ -137,6 +195,11 @@ bool CIEInitialRandom::GetValue(int frame, int& valOut) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CIEInitialRandom::GetMaxValue() const
|
||||||
|
{
|
||||||
|
return x8_b->GetMaxValue();
|
||||||
|
}
|
||||||
|
|
||||||
bool CIEPulse::GetValue(int frame, int& valOut) const
|
bool CIEPulse::GetValue(int frame, int& valOut) const
|
||||||
{
|
{
|
||||||
int a, b;
|
int a, b;
|
||||||
|
@ -158,6 +221,10 @@ bool CIEPulse::GetValue(int frame, int& valOut) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CIEPulse::GetMaxValue() const
|
||||||
|
{
|
||||||
|
return std::max(xc_aVal->GetMaxValue(), x10_bVal->GetMaxValue());
|
||||||
|
}
|
||||||
|
|
||||||
bool CIEMultiply::GetValue(int frame, int& valOut) const
|
bool CIEMultiply::GetValue(int frame, int& valOut) const
|
||||||
{
|
{
|
||||||
|
@ -168,6 +235,11 @@ bool CIEMultiply::GetValue(int frame, int& valOut) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CIEMultiply::GetMaxValue() const
|
||||||
|
{
|
||||||
|
return x4_a->GetMaxValue() * x8_b->GetMaxValue();
|
||||||
|
}
|
||||||
|
|
||||||
bool CIESampleAndHold::GetValue(int frame, int& valOut) const
|
bool CIESampleAndHold::GetValue(int frame, int& valOut) const
|
||||||
{
|
{
|
||||||
if (x8_nextSampleFrame < frame)
|
if (x8_nextSampleFrame < frame)
|
||||||
|
@ -185,6 +257,11 @@ bool CIESampleAndHold::GetValue(int frame, int& valOut) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CIESampleAndHold::GetMaxValue() const
|
||||||
|
{
|
||||||
|
return x4_sampleSource->GetMaxValue();
|
||||||
|
}
|
||||||
|
|
||||||
bool CIERandom::GetValue(int frame, int& valOut) const
|
bool CIERandom::GetValue(int frame, int& valOut) const
|
||||||
{
|
{
|
||||||
int a, b;
|
int a, b;
|
||||||
|
@ -197,6 +274,14 @@ bool CIERandom::GetValue(int frame, int& valOut) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CIERandom::GetMaxValue() const
|
||||||
|
{
|
||||||
|
if (x4_min->GetMaxValue() > 0)
|
||||||
|
return x8_max->GetMaxValue();
|
||||||
|
else
|
||||||
|
return 65535;
|
||||||
|
}
|
||||||
|
|
||||||
bool CIETimeScale::GetValue(int frame, int& valOut) const
|
bool CIETimeScale::GetValue(int frame, int& valOut) const
|
||||||
{
|
{
|
||||||
float a;
|
float a;
|
||||||
|
@ -205,24 +290,44 @@ bool CIETimeScale::GetValue(int frame, int& valOut) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CIETimeScale::GetMaxValue() const
|
||||||
|
{
|
||||||
|
return 10000; /* Assume 10000 frames max (not ideal estimate) */
|
||||||
|
}
|
||||||
|
|
||||||
bool CIEGetCumulativeParticleCount::GetValue(int frame, int& valOut) const
|
bool CIEGetCumulativeParticleCount::GetValue(int frame, int& valOut) const
|
||||||
{
|
{
|
||||||
valOut = CParticleGlobals::g_currentParticleSystem->x4_system->GetCumulativeParticleCount();
|
valOut = CParticleGlobals::g_currentParticleSystem->x4_system->GetCumulativeParticleCount();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CIEGetCumulativeParticleCount::GetMaxValue() const
|
||||||
|
{
|
||||||
|
return 256;
|
||||||
|
}
|
||||||
|
|
||||||
bool CIEGetActiveParticleCount::GetValue(int frame, int &valOut) const
|
bool CIEGetActiveParticleCount::GetValue(int frame, int &valOut) const
|
||||||
{
|
{
|
||||||
valOut = CParticleGlobals::g_currentParticleSystem->x4_system->GetParticleCount();
|
valOut = CParticleGlobals::g_currentParticleSystem->x4_system->GetParticleCount();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CIEGetActiveParticleCount::GetMaxValue() const
|
||||||
|
{
|
||||||
|
return 256;
|
||||||
|
}
|
||||||
|
|
||||||
bool CIEGetEmitterTime::GetValue(int frame, int &valOut) const
|
bool CIEGetEmitterTime::GetValue(int frame, int &valOut) const
|
||||||
{
|
{
|
||||||
valOut = CParticleGlobals::g_currentParticleSystem->x4_system->GetEmitterTime();
|
valOut = CParticleGlobals::g_currentParticleSystem->x4_system->GetEmitterTime();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CIEGetEmitterTime::GetMaxValue() const
|
||||||
|
{
|
||||||
|
return 10000; /* Assume 10000 frames max (not ideal estimate) */
|
||||||
|
}
|
||||||
|
|
||||||
bool CIEModulo::GetValue(int frame, int& valOut) const
|
bool CIEModulo::GetValue(int frame, int& valOut) const
|
||||||
{
|
{
|
||||||
int a, b;
|
int a, b;
|
||||||
|
@ -235,6 +340,17 @@ bool CIEModulo::GetValue(int frame, int& valOut) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CIEModulo::GetMaxValue() const
|
||||||
|
{
|
||||||
|
int a, b;
|
||||||
|
a = x4_a->GetMaxValue();
|
||||||
|
b = x8_b->GetMaxValue();
|
||||||
|
if (b != 0)
|
||||||
|
return b - 1;
|
||||||
|
else
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
bool CIESubtract::GetValue(int frame, int& valOut) const
|
bool CIESubtract::GetValue(int frame, int& valOut) const
|
||||||
{
|
{
|
||||||
int a, b;
|
int a, b;
|
||||||
|
@ -244,4 +360,12 @@ bool CIESubtract::GetValue(int frame, int& valOut) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CIESubtract::GetMaxValue() const
|
||||||
|
{
|
||||||
|
int a, b;
|
||||||
|
a = x4_a->GetMaxValue();
|
||||||
|
b = x8_b->GetMaxValue();
|
||||||
|
return a - b;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ class CIEKeyframeEmitter : public CIntElement
|
||||||
public:
|
public:
|
||||||
CIEKeyframeEmitter(CInputStream& in);
|
CIEKeyframeEmitter(CInputStream& in);
|
||||||
bool GetValue(int frame, int& valOut) const;
|
bool GetValue(int frame, int& valOut) const;
|
||||||
|
int GetMaxValue() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CIEDeath : public CIntElement
|
class CIEDeath : public CIntElement
|
||||||
|
@ -30,6 +31,7 @@ public:
|
||||||
CIEDeath(std::unique_ptr<CIntElement>&& a, std::unique_ptr<CIntElement>&& b)
|
CIEDeath(std::unique_ptr<CIntElement>&& a, std::unique_ptr<CIntElement>&& b)
|
||||||
: x4_a(std::move(a)), x8_b(std::move(b)) {}
|
: x4_a(std::move(a)), x8_b(std::move(b)) {}
|
||||||
bool GetValue(int frame, int& valOut) const;
|
bool GetValue(int frame, int& valOut) const;
|
||||||
|
int GetMaxValue() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CIEClamp : public CIntElement
|
class CIEClamp : public CIntElement
|
||||||
|
@ -41,6 +43,7 @@ public:
|
||||||
CIEClamp(std::unique_ptr<CIntElement>&& a, std::unique_ptr<CIntElement>&& b, std::unique_ptr<CIntElement>&& c)
|
CIEClamp(std::unique_ptr<CIntElement>&& a, std::unique_ptr<CIntElement>&& b, std::unique_ptr<CIntElement>&& c)
|
||||||
: x4_min(std::move(a)), x8_max(std::move(b)), xc_val(std::move(c)) {}
|
: x4_min(std::move(a)), x8_max(std::move(b)), xc_val(std::move(c)) {}
|
||||||
bool GetValue(int frame, int& valOut) const;
|
bool GetValue(int frame, int& valOut) const;
|
||||||
|
int GetMaxValue() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CIETimeChain : public CIntElement
|
class CIETimeChain : public CIntElement
|
||||||
|
@ -52,6 +55,7 @@ public:
|
||||||
CIETimeChain(std::unique_ptr<CIntElement>&& a, std::unique_ptr<CIntElement>&& b, std::unique_ptr<CIntElement>&& c)
|
CIETimeChain(std::unique_ptr<CIntElement>&& a, std::unique_ptr<CIntElement>&& b, std::unique_ptr<CIntElement>&& c)
|
||||||
: x4_a(std::move(a)), x8_b(std::move(b)), xc_swFrame(std::move(c)) {}
|
: x4_a(std::move(a)), x8_b(std::move(b)), xc_swFrame(std::move(c)) {}
|
||||||
bool GetValue(int frame, int& valOut) const;
|
bool GetValue(int frame, int& valOut) const;
|
||||||
|
int GetMaxValue() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CIEAdd : public CIntElement
|
class CIEAdd : public CIntElement
|
||||||
|
@ -62,6 +66,7 @@ public:
|
||||||
CIEAdd(std::unique_ptr<CIntElement>&& a, std::unique_ptr<CIntElement>&& b)
|
CIEAdd(std::unique_ptr<CIntElement>&& a, std::unique_ptr<CIntElement>&& b)
|
||||||
: x4_a(std::move(a)), x8_b(std::move(b)) {}
|
: x4_a(std::move(a)), x8_b(std::move(b)) {}
|
||||||
bool GetValue(int frame, int& valOut) const;
|
bool GetValue(int frame, int& valOut) const;
|
||||||
|
int GetMaxValue() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CIEConstant : public CIntElement
|
class CIEConstant : public CIntElement
|
||||||
|
@ -70,6 +75,7 @@ class CIEConstant : public CIntElement
|
||||||
public:
|
public:
|
||||||
CIEConstant(int val) : x4_val(val) {}
|
CIEConstant(int val) : x4_val(val) {}
|
||||||
bool GetValue(int frame, int& valOut) const;
|
bool GetValue(int frame, int& valOut) const;
|
||||||
|
int GetMaxValue() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CIEImpulse : public CIntElement
|
class CIEImpulse : public CIntElement
|
||||||
|
@ -79,6 +85,7 @@ public:
|
||||||
CIEImpulse(std::unique_ptr<CIntElement>&& a)
|
CIEImpulse(std::unique_ptr<CIntElement>&& a)
|
||||||
: x4_a(std::move(a)) {}
|
: x4_a(std::move(a)) {}
|
||||||
bool GetValue(int frame, int& valOut) const;
|
bool GetValue(int frame, int& valOut) const;
|
||||||
|
int GetMaxValue() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CIELifetimePercent : public CIntElement
|
class CIELifetimePercent : public CIntElement
|
||||||
|
@ -88,6 +95,7 @@ public:
|
||||||
CIELifetimePercent(std::unique_ptr<CIntElement>&& a)
|
CIELifetimePercent(std::unique_ptr<CIntElement>&& a)
|
||||||
: x4_percentVal(std::move(a)) {}
|
: x4_percentVal(std::move(a)) {}
|
||||||
bool GetValue(int frame, int& valOut) const;
|
bool GetValue(int frame, int& valOut) const;
|
||||||
|
int GetMaxValue() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CIEInitialRandom : public CIntElement
|
class CIEInitialRandom : public CIntElement
|
||||||
|
@ -98,6 +106,7 @@ public:
|
||||||
CIEInitialRandom(std::unique_ptr<CIntElement>&& a, std::unique_ptr<CIntElement>&& b)
|
CIEInitialRandom(std::unique_ptr<CIntElement>&& a, std::unique_ptr<CIntElement>&& b)
|
||||||
: x4_a(std::move(a)), x8_b(std::move(b)) {}
|
: x4_a(std::move(a)), x8_b(std::move(b)) {}
|
||||||
bool GetValue(int frame, int& valOut) const;
|
bool GetValue(int frame, int& valOut) const;
|
||||||
|
int GetMaxValue() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CIEPulse : public CIntElement
|
class CIEPulse : public CIntElement
|
||||||
|
@ -111,6 +120,7 @@ public:
|
||||||
std::unique_ptr<CIntElement>&& c, std::unique_ptr<CIntElement>&& d)
|
std::unique_ptr<CIntElement>&& c, std::unique_ptr<CIntElement>&& d)
|
||||||
: x4_aDuration(std::move(a)), x8_bDuration(std::move(b)), xc_aVal(std::move(c)), x10_bVal(std::move(d)) {}
|
: x4_aDuration(std::move(a)), x8_bDuration(std::move(b)), xc_aVal(std::move(c)), x10_bVal(std::move(d)) {}
|
||||||
bool GetValue(int frame, int& valOut) const;
|
bool GetValue(int frame, int& valOut) const;
|
||||||
|
int GetMaxValue() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CIEMultiply : public CIntElement
|
class CIEMultiply : public CIntElement
|
||||||
|
@ -121,6 +131,7 @@ public:
|
||||||
CIEMultiply(std::unique_ptr<CIntElement>&& a, std::unique_ptr<CIntElement>&& b)
|
CIEMultiply(std::unique_ptr<CIntElement>&& a, std::unique_ptr<CIntElement>&& b)
|
||||||
: x4_a(std::move(a)), x8_b(std::move(b)) {}
|
: x4_a(std::move(a)), x8_b(std::move(b)) {}
|
||||||
bool GetValue(int frame, int& valOut) const;
|
bool GetValue(int frame, int& valOut) const;
|
||||||
|
int GetMaxValue() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CIESampleAndHold : public CIntElement
|
class CIESampleAndHold : public CIntElement
|
||||||
|
@ -135,6 +146,7 @@ public:
|
||||||
std::unique_ptr<CIntElement>&& c)
|
std::unique_ptr<CIntElement>&& c)
|
||||||
: x4_sampleSource(std::move(a)), xc_waitFramesMin(std::move(b)), x10_waitFramesMax(std::move(c)) {}
|
: x4_sampleSource(std::move(a)), xc_waitFramesMin(std::move(b)), x10_waitFramesMax(std::move(c)) {}
|
||||||
bool GetValue(int frame, int& valOut) const;
|
bool GetValue(int frame, int& valOut) const;
|
||||||
|
int GetMaxValue() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CIERandom : public CIntElement
|
class CIERandom : public CIntElement
|
||||||
|
@ -145,6 +157,7 @@ public:
|
||||||
CIERandom(std::unique_ptr<CIntElement>&& a, std::unique_ptr<CIntElement>&& b)
|
CIERandom(std::unique_ptr<CIntElement>&& a, std::unique_ptr<CIntElement>&& b)
|
||||||
: x4_min(std::move(a)), x8_max(std::move(b)) {}
|
: x4_min(std::move(a)), x8_max(std::move(b)) {}
|
||||||
bool GetValue(int frame, int& valOut) const;
|
bool GetValue(int frame, int& valOut) const;
|
||||||
|
int GetMaxValue() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CIETimeScale : public CIntElement
|
class CIETimeScale : public CIntElement
|
||||||
|
@ -154,24 +167,28 @@ public:
|
||||||
CIETimeScale(std::unique_ptr<CRealElement>&& a)
|
CIETimeScale(std::unique_ptr<CRealElement>&& a)
|
||||||
: x4_a(std::move(a)) {}
|
: x4_a(std::move(a)) {}
|
||||||
bool GetValue(int frame, int& valOut) const;
|
bool GetValue(int frame, int& valOut) const;
|
||||||
|
int GetMaxValue() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CIEGetCumulativeParticleCount : public CIntElement
|
class CIEGetCumulativeParticleCount : public CIntElement
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool GetValue(int frame, int& valOut) const;
|
bool GetValue(int frame, int& valOut) const;
|
||||||
|
int GetMaxValue() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CIEGetActiveParticleCount : public CIntElement
|
class CIEGetActiveParticleCount : public CIntElement
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool GetValue(int frame, int &valOut) const;
|
bool GetValue(int frame, int &valOut) const;
|
||||||
|
int GetMaxValue() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CIEGetEmitterTime : public CIntElement
|
class CIEGetEmitterTime : public CIntElement
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool GetValue(int frame, int &valOut) const;
|
bool GetValue(int frame, int &valOut) const;
|
||||||
|
int GetMaxValue() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CIEModulo : public CIntElement
|
class CIEModulo : public CIntElement
|
||||||
|
@ -182,6 +199,7 @@ public:
|
||||||
CIEModulo(std::unique_ptr<CIntElement>&& a, std::unique_ptr<CIntElement>&& b)
|
CIEModulo(std::unique_ptr<CIntElement>&& a, std::unique_ptr<CIntElement>&& b)
|
||||||
: x4_a(std::move(a)), x8_b(std::move(b)) {}
|
: x4_a(std::move(a)), x8_b(std::move(b)) {}
|
||||||
bool GetValue(int frame, int& valOut) const;
|
bool GetValue(int frame, int& valOut) const;
|
||||||
|
int GetMaxValue() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CIESubtract : public CIntElement
|
class CIESubtract : public CIntElement
|
||||||
|
@ -192,6 +210,7 @@ public:
|
||||||
CIESubtract(std::unique_ptr<CIntElement>&& a, std::unique_ptr<CIntElement>&& b)
|
CIESubtract(std::unique_ptr<CIntElement>&& a, std::unique_ptr<CIntElement>&& b)
|
||||||
: x4_a(std::move(a)), x8_b(std::move(b)) {}
|
: x4_a(std::move(a)), x8_b(std::move(b)) {}
|
||||||
bool GetValue(int frame, int& valOut) const;
|
bool GetValue(int frame, int& valOut) const;
|
||||||
|
int GetMaxValue() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ class CIntElement : public IElement
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual bool GetValue(int frame, int& valOut) const=0;
|
virtual bool GetValue(int frame, int& valOut) const=0;
|
||||||
|
virtual int GetMaxValue() const=0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CVectorElement : public IElement
|
class CVectorElement : public IElement
|
||||||
|
|
2
hecl
2
hecl
|
@ -1 +1 @@
|
||||||
Subproject commit c9e057fa6e314257909edcd9758a0628bbc91918
|
Subproject commit 439a90dbb4fda47b7f71b740a0f709c3b2dc7ca4
|
Loading…
Reference in New Issue