mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-10 18:27:41 +00:00
CElementGenShaders, CDecalShaders fixes
Add conditions for HSH_PROFILE_MODE
This commit is contained in:
@@ -29,6 +29,14 @@ CDecal::CDecal(const TToken<CDecalDescription>& desc, const zeus::CTransform& xf
|
||||
} else {
|
||||
x5c_29_modelInvalid = true;
|
||||
}
|
||||
|
||||
for (auto& decal : x3c_decalQuads) {
|
||||
hsh::texture2d tex{};
|
||||
if (CUVElement* texDesc = decal.m_desc->x14_TEX.get()) {
|
||||
tex = texDesc->GetValueTexture(x58_frameIdx)->GetBooTexture();
|
||||
}
|
||||
CDecalShaders::BuildShaderDataBinding(decal.m_binding, decal, tex);
|
||||
}
|
||||
}
|
||||
|
||||
bool CDecal::InitQuad(CQuadDecal& quad, const SQuadDescr& desc) {
|
||||
@@ -97,18 +105,16 @@ void CDecal::RenderQuad(CQuadDecal& decal, const SQuadDescr& desc) {
|
||||
modXf.origin += offset;
|
||||
CGraphics::SetModelMatrix(modXf);
|
||||
|
||||
#if !HSH_PROFILE_MODE
|
||||
SParticleUniforms uniformData = {
|
||||
CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f(),
|
||||
{1.f, 1.f, 1.f, 1.f},
|
||||
};
|
||||
decal.m_uniformBuf.load(uniformData);
|
||||
#endif
|
||||
|
||||
SUVElementSet uvSet = {0.f, 1.f, 0.f, 1.f};
|
||||
if (CUVElement* tex = desc.x14_TEX.get()) {
|
||||
TLockedToken<CTexture> texObj = tex->GetValueTexture(x58_frameIdx);
|
||||
if (!texObj.IsLoaded()) {
|
||||
return;
|
||||
}
|
||||
tex->GetValueUV(x58_frameIdx, uvSet);
|
||||
|
||||
g_instTexData.clear();
|
||||
@@ -135,9 +141,10 @@ void CDecal::RenderQuad(CQuadDecal& decal, const SQuadDescr& desc) {
|
||||
inst.uvs[2] = hsh::float2(uvSet.xMin, uvSet.yMax);
|
||||
inst.uvs[3] = hsh::float2(uvSet.xMax, uvSet.yMax);
|
||||
|
||||
#if !HSH_PROFILE_MODE
|
||||
decal.m_instBuf.load(hsh::detail::ArrayProxy{g_instTexData.data(), g_instTexData.size()});
|
||||
m_shaderBuilder.BuildShaderDataBinding(decal, texObj->GetBooTexture())
|
||||
.draw_instanced(0, 4, g_instIndTexData.size());
|
||||
#endif
|
||||
decal.m_binding.draw_instanced(0, 4, g_instTexData.size());
|
||||
} else {
|
||||
g_instNoTexData.clear();
|
||||
g_instNoTexData.reserve(1);
|
||||
@@ -159,8 +166,10 @@ void CDecal::RenderQuad(CQuadDecal& decal, const SQuadDescr& desc) {
|
||||
}
|
||||
inst.color = color;
|
||||
|
||||
#if !HSH_PROFILE_MODE
|
||||
decal.m_instBuf.load(hsh::detail::ArrayProxy{g_instNoTexData.data(), g_instNoTexData.size()});
|
||||
m_shaderBuilder.BuildShaderDataBinding(decal, hsh::texture2d{}).draw_instanced(0, 4, g_instNoTexData.size());
|
||||
#endif
|
||||
decal.m_binding.draw_instanced(0, 4, g_instNoTexData.size());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ struct CQuadDecal {
|
||||
CQuadDecal() = default;
|
||||
CQuadDecal(s32 i, float f) : x4_lifetime(i), x8_rotation(f) {}
|
||||
|
||||
hsh::binding m_binding;
|
||||
hsh::dynamic_owner<hsh::vertex_buffer_typeless> m_instBuf;
|
||||
hsh::dynamic_owner<hsh::uniform_buffer<SParticleUniforms>> m_uniformBuf;
|
||||
};
|
||||
@@ -41,8 +42,6 @@ class CDecal {
|
||||
bool x5c_29_modelInvalid : 1 = false;
|
||||
zeus::CVector3f x60_rotation;
|
||||
|
||||
CDecalShaders m_shaderBuilder{};
|
||||
|
||||
bool InitQuad(CQuadDecal& quad, const SQuadDescr& desc);
|
||||
|
||||
public:
|
||||
|
||||
@@ -238,6 +238,8 @@ CElementGen::CElementGen(TToken<CGenDescription> gen, EModelOrientationType orie
|
||||
}
|
||||
m_uniformBufPmus = hsh::create_dynamic_uniform_buffer<SParticleUniforms>();
|
||||
}
|
||||
if (!x26c_31_LINE)
|
||||
CElementGenShaders::BuildShaderDataBinding(*this);
|
||||
}
|
||||
|
||||
CElementGen::~CElementGen() {
|
||||
@@ -912,7 +914,9 @@ void CElementGen::RenderModels(const CActorLights* actorLights) {
|
||||
break;
|
||||
}
|
||||
|
||||
#if !HSH_PROFILE_MODE
|
||||
m_uniformBufPmus.load({CGraphics::GetPerspectiveProjectionMatrix(true), {1.f, 1.f, 1.f, 1.f}});
|
||||
#endif
|
||||
}
|
||||
|
||||
zeus::CTransform orient = zeus::CTransform();
|
||||
@@ -1044,9 +1048,7 @@ void CElementGen::RenderModels(const CActorLights* actorLights) {
|
||||
if (g_subtractBlend) {
|
||||
model->Draw({5, 0, 1, zeus::CColor(1.f, 0.5f)});
|
||||
} else if (desc->x44_31_x31_25_PMAB) {
|
||||
CModelFlags flags{7, 0, 1, col};
|
||||
flags.m_extendedShader = EExtendedShader::ForcedAdditiveNoZWrite;
|
||||
model->Draw(flags);
|
||||
model->Draw({7, 0, 1, col});
|
||||
} else if (1.f == col.a()) {
|
||||
model->Draw({0, 0, 3, zeus::skWhite});
|
||||
} else {
|
||||
@@ -1061,12 +1063,16 @@ void CElementGen::RenderModels(const CActorLights* actorLights) {
|
||||
if (desc->x45_24_x31_26_PMUS) {
|
||||
switch (m_shaderClass) {
|
||||
case CElementGenShaders::EShaderClass::Tex:
|
||||
#if !HSH_PROFILE_MODE
|
||||
m_instBufPmus.load<SParticleInstanceTex>(g_instTexData);
|
||||
m_shaderBuilder.BuildShaderDataBinding(*this, true).draw_instanced(0, 4, g_instTexData.size());
|
||||
#endif
|
||||
m_bindingPmus.draw_instanced(0, 4, g_instTexData.size());
|
||||
break;
|
||||
case CElementGenShaders::EShaderClass::NoTex:
|
||||
#if !HSH_PROFILE_MODE
|
||||
m_instBufPmus.load<SParticleInstanceNoTex>(g_instNoTexData);
|
||||
m_shaderBuilder.BuildShaderDataBinding(*this, true).draw_instanced(0, 4, g_instNoTexData.size());
|
||||
#endif
|
||||
m_bindingPmus.draw_instanced(0, 4, g_instNoTexData.size());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -1076,7 +1082,7 @@ void CElementGen::RenderModels(const CActorLights* actorLights) {
|
||||
if (x26d_26_modelsUseLights)
|
||||
CGraphics::DisableAllLights();
|
||||
|
||||
CGraphics::SetCullMode(ERglCullMode::Front);
|
||||
CGraphics::SetCullMode(ERglCullMode::Back);
|
||||
if (moveRedToAlphaBuffer) {
|
||||
/* Restore passthrough */
|
||||
}
|
||||
@@ -1238,7 +1244,9 @@ void CElementGen::RenderParticles() {
|
||||
constUVs = texr->HasConstantUV();
|
||||
}
|
||||
|
||||
#if !HSH_PROFILE_MODE
|
||||
m_uniformBuf.load(uniformData);
|
||||
#endif
|
||||
|
||||
std::vector<CParticleListItem> sortItems;
|
||||
if (desc->x44_28_x30_28_SORT) {
|
||||
@@ -1257,9 +1265,9 @@ void CElementGen::RenderParticles() {
|
||||
});
|
||||
}
|
||||
|
||||
bool moveRedToAlphaBuffer = false;
|
||||
if (sMoveRedToAlphaBuffer && x26c_26_AAPH)
|
||||
moveRedToAlphaBuffer = true;
|
||||
// bool moveRedToAlphaBuffer = false;
|
||||
// if (sMoveRedToAlphaBuffer && x26c_26_AAPH)
|
||||
// moveRedToAlphaBuffer = true;
|
||||
|
||||
int mbspVal = std::max(1, x270_MBSP);
|
||||
|
||||
@@ -1471,12 +1479,16 @@ void CElementGen::RenderParticles() {
|
||||
|
||||
switch (m_shaderClass) {
|
||||
case CElementGenShaders::EShaderClass::Tex:
|
||||
#if !HSH_PROFILE_MODE
|
||||
m_instBuf.load<SParticleInstanceTex>(g_instTexData);
|
||||
m_shaderBuilder.BuildShaderDataBinding(*this, false).draw_instanced(0, 4, g_instTexData.size());
|
||||
#endif
|
||||
m_binding.draw_instanced(0, 4, g_instTexData.size());
|
||||
break;
|
||||
case CElementGenShaders::EShaderClass::NoTex:
|
||||
#if !HSH_PROFILE_MODE
|
||||
m_instBuf.load<SParticleInstanceNoTex>(g_instNoTexData);
|
||||
m_shaderBuilder.BuildShaderDataBinding(*this, false).draw_instanced(0, 4, g_instNoTexData.size());
|
||||
#endif
|
||||
m_binding.draw_instanced(0, 4, g_instNoTexData.size());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -1585,12 +1597,16 @@ void CElementGen::RenderParticles() {
|
||||
}
|
||||
switch (m_shaderClass) {
|
||||
case CElementGenShaders::EShaderClass::Tex:
|
||||
#if !HSH_PROFILE_MODE
|
||||
m_instBuf.load<SParticleInstanceTex>(g_instTexData);
|
||||
m_shaderBuilder.BuildShaderDataBinding(*this, false).draw_instanced(0, 4, g_instTexData.size());
|
||||
#endif
|
||||
m_binding.draw_instanced(0, 4, g_instTexData.size());
|
||||
break;
|
||||
case CElementGenShaders::EShaderClass::NoTex:
|
||||
#if !HSH_PROFILE_MODE
|
||||
m_instBuf.load<SParticleInstanceNoTex>(g_instNoTexData);
|
||||
m_shaderBuilder.BuildShaderDataBinding(*this, false).draw_instanced(0, 4, g_instNoTexData.size());
|
||||
#endif
|
||||
m_binding.draw_instanced(0, 4, g_instNoTexData.size());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -1609,8 +1625,10 @@ void CElementGen::RenderParticlesIndirectTexture() {
|
||||
x178_localScaleTransform;
|
||||
CGraphics::SetModelMatrix(systemViewPointMatrix);
|
||||
|
||||
#if !HSH_PROFILE_MODE
|
||||
m_uniformBuf.load(
|
||||
{CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f(), {1.f, 1.f, 1.f, 1.f}});
|
||||
#endif
|
||||
|
||||
CGraphics::SetAlphaCompare(ERglAlphaFunc::Always, 0, ERglAlphaOp::And, ERglAlphaFunc::Always, 0);
|
||||
|
||||
@@ -1721,13 +1739,14 @@ void CElementGen::RenderParticlesIndirectTexture() {
|
||||
inst.texrTindUVs[3] = zeus::CVector4f{uvs.xMin, uvs.yMin, uvsInd.xMin, uvsInd.yMin};
|
||||
inst.sceneUVs =
|
||||
zeus::CVector4f{clipRect.x18_uvXMin, 1.f - clipRect.x24_uvYMax, clipRect.x1c_uvXMax, 1.f - clipRect.x20_uvYMin};
|
||||
m_shaderBuilder.BuildShaderDataBinding(*this, false).draw_instanced(0, 4, g_instIndTexData.size() - 1);
|
||||
m_binding.draw_instanced(0, 4, g_instIndTexData.size() - 1);
|
||||
}
|
||||
|
||||
if (!g_instIndTexData.empty()) {
|
||||
#if !HSH_PROFILE_MODE
|
||||
m_instBuf.load<SParticleInstanceIndTex>(g_instIndTexData);
|
||||
// CGraphics::SetShaderDataBinding(m_normalDataBind);
|
||||
// CGraphics::DrawInstances(0, 4, g_instIndTexData.size());
|
||||
#endif
|
||||
m_binding.draw_instanced(0, 4, g_instIndTexData.size());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -134,6 +134,8 @@ private:
|
||||
|
||||
std::unique_ptr<CLineRenderer> m_lineRenderer;
|
||||
CElementGenShaders::EShaderClass m_shaderClass;
|
||||
hsh::binding m_binding;
|
||||
hsh::binding m_bindingPmus;
|
||||
|
||||
void AccumulateBounds(const zeus::CVector3f& pos, float size);
|
||||
|
||||
|
||||
@@ -1002,11 +1002,13 @@ void CParticleSwoosh::Render(const CActorLights*) {
|
||||
}
|
||||
}
|
||||
|
||||
#if !HSH_PROFILE_MODE
|
||||
zeus::CMatrix4f mvp = CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f();
|
||||
m_uniformBuf.load({mvp});
|
||||
if (!m_cachedVerts.empty()) {
|
||||
m_vertBuf.load(m_cachedVerts);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void CParticleSwoosh::SetOrientation(const zeus::CTransform& xf) {
|
||||
|
||||
Reference in New Issue
Block a user