Cleanup and more migration to Stream

This commit is contained in:
Phillip Stephens 2022-03-05 13:46:53 -08:00
parent 33d0d14fda
commit 24a602c10f
Signed by: Antidote
GPG Key ID: F8BEE4C83DACA60D
12 changed files with 422 additions and 101 deletions

View File

@ -610,18 +610,7 @@ int main(int argc, char** argv) {
.width = icon.width,
.height = icon.height,
};
#ifdef NDEBUG
/* Before we start running the app, lets get a thread going to detect any infinite loops */
metaforce::CInfiniteLoopDetector infiniteLoopDetector;
std::thread infiniteLoopDetectorThread(&metaforce::CInfiniteLoopDetector::run, &infiniteLoopDetector);
infiniteLoopDetectorThread.detach();
aurora::app_run(std::move(app), std::move(data), argc, argv);
infiniteLoopDetector.stop();
#else
/* Debuggers can interrupt the loop detector and make it unable to perform its job correctly, so lets not detect
* infinite loops in a debug build */
aurora::app_run(std::move(app), std::move(data), argc, argv);
#endif
return 0;
}
#endif

View File

@ -576,4 +576,15 @@ void CGraphics::StreamVertex(const zeus::CVector3f& pos) {
}
void CGraphics::StreamEnd() { aurora::gfx::stream_end(); }
void CGraphics::DrawPrimitive(GX::Primitive primitive, const zeus::CVector3f* pos, const zeus::CVector3f& normal,
const zeus::CColor& col, s32 numVerts) {
StreamBegin(primitive);
StreamColor(col);
StreamNormal(normal);
for (u32 i = 0; i < numVerts; ++i) {
StreamVertex(pos[i]);
}
StreamEnd();
}
} // namespace metaforce

View File

@ -302,6 +302,8 @@ public:
static void StreamVertex(float x, float y, float z);
static void StreamVertex(const zeus::CVector3f& pos);
static void StreamEnd();
static void DrawPrimitive(GX::Primitive primitive, const zeus::CVector3f* pos, const zeus::CVector3f& normal,
const zeus::CColor& col, s32 numVerts);
};
template <class VTX>

View File

@ -4,7 +4,60 @@
#include <cstddef>
namespace GX {
enum AttrType { NONE, DIRECT, INDEX8, INDEX16 };
enum Attr {
VA_PNMTXIDX = 0x0,
VA_TEX0MTXIDX = 0x1,
VA_TEX1MTXIDX = 0x2,
VA_TEX2MTXIDX = 0x3,
VA_TEX3MTXIDX = 0x4,
VA_TEX4MTXIDX = 0x5,
VA_TEX5MTXIDX = 0x6,
VA_TEX6MTXIDX = 0x7,
VA_TEX7MTXIDX = 0x8,
VA_POS = 0x9,
VA_NRM = 0xa,
VA_CLR0 = 0xb,
VA_CLR1 = 0xc,
VA_TEX0 = 0xd,
VA_TEX1 = 0xe,
VA_TEX2 = 0xf,
VA_TEX3 = 0x10,
VA_TEX4 = 0x11,
VA_TEX5 = 0x12,
VA_TEX6 = 0x13,
VA_TEX7 = 0x14,
POS_MTX_ARRAY = 0x15,
NRM_MTX_ARRAY = 0x16,
TEX_MTX_ARRAY = 0x17,
LIGHT_ARRAY = 0x18,
VA_NBT = 0x19,
VA_MAX_ATTR = 0x1a,
VA_NULL = 0xff,
};
enum AttrType {
NONE,
DIRECT,
INDEX8,
INDEX16,
};
struct VtxDescList {
Attr attr;
AttrType type;
};
enum VtxFmt {
VTXFMT0 = 0,
VTXFMT1,
VTXFMT2,
VTXFMT3,
VTXFMT4,
VTXFMT5,
VTXFMT6,
VTXFMT7,
MAX_VTXFMT,
};
enum TevColorArg {
CC_CPREV = 0,
@ -36,7 +89,15 @@ enum TevAlphaArg {
CA_ZERO = 7,
};
enum TevKColorSel {
enum TevKColorID {
KCOLOR0 = 0,
KCOLOR1,
KCOLOR2,
KCOLOR3,
MAX_KCOLOR,
};
enum TevKColorSel : uint8_t {
TEV_KCSEL_8_8 = 0x00,
TEV_KCSEL_7_8 = 0x01,
TEV_KCSEL_6_8 = 0x02,
@ -70,7 +131,8 @@ enum TevKColorSel {
TEV_KCSEL_K0_A = 0x1C,
TEV_KCSEL_K1_A = 0x1D,
TEV_KCSEL_K2_A = 0x1E,
TEV_KCSEL_K3_A = 0x1F
TEV_KCSEL_K3_A = 0x1F,
INVALID_KCSEL = 0xFF
};
enum TevKAlphaSel {
@ -103,7 +165,8 @@ enum TevKAlphaSel {
TEV_KASEL_K0_A = 0x1C,
TEV_KASEL_K1_A = 0x1D,
TEV_KASEL_K2_A = 0x1E,
TEV_KASEL_K3_A = 0x1F
TEV_KASEL_K3_A = 0x1F,
INVALID_KASEL = 0xFF
};
enum TevOp {
@ -127,7 +190,22 @@ enum TevBias {
TB_SUBHALF = 2,
};
enum TevScale { CS_SCALE_1 = 0, CS_SCALE_2 = 1, CS_SCALE_4 = 2, CS_DIVIDE_2 = 3 };
enum TevScale {
CS_SCALE_1 = 0,
CS_SCALE_2 = 1,
CS_SCALE_4 = 2,
CS_DIVIDE_2 = 3,
};
enum TexOffset {
TO_ZERO,
TO_SIXTEENTH,
TO_EIGHTH,
TO_FOURTH,
TO_HALF,
TO_ONE,
MAX_TEXOFFSET,
};
enum TexGenType {
TG_MTX3x4 = 0,
@ -205,11 +283,51 @@ enum PTTexMtx {
PTIDENTITY = 125
};
enum TevRegID { TEVPREV = 0, TEVREG0 = 1, TEVREG1 = 2, TEVREG2 = 3, TEVLAZY = 5 };
enum TexCoordID {
TEXCOORD0 = 0x0,
TEXCOORD1,
TEXCOORD2,
TEXCOORD3,
TEXCOORD4,
TEXCOORD5,
TEXCOORD6,
TEXCOORD7,
MAX_TEXCOORD = 8,
TEXCOORD_NULL = 0xff
};
enum DiffuseFn { DF_NONE = 0, DF_SIGN, DF_CLAMP };
enum TevSwapSel {
TEV_SWAP0 = 0x0,
TEV_SWAP1 = 0x1,
TEV_SWAP2 = 0x2,
TEV_SWAP3 = 0x3,
MAX_TEVSWAP = 0x4,
};
enum TevColorChan {
CH_RED = 0x0,
CH_GREEN = 0x1,
CH_BLUE = 0x2,
CH_ALPHA = 0x3,
};
enum TevRegID {
TEVPREV = 0,
TEVREG0 = 1,
TEVREG1 = 2,
TEVREG2 = 3,
TEVLAZY = 5,
};
enum AttnFn { AF_SPEC = 0, AF_SPOT = 1, AF_NONE };
enum DiffuseFn {
DF_NONE = 0,
DF_SIGN,
DF_CLAMP,
};
enum AttnFn {
AF_SPEC = 0,
AF_SPOT = 1,
AF_NONE,
};
enum Primitive {
POINTS = 0xb8,
@ -222,16 +340,69 @@ enum Primitive {
};
enum ChannelID {
GX_COLOR0,
GX_COLOR1,
GX_ALPHA0,
GX_ALPHA1,
GX_COLOR0A0,
GX_COLOR1A1,
GX_COLOR_ZERO,
GX_ALPHA_BUMP,
GX_ALPHA_BUMPN,
GX_COLOR_NULL = 0xff
COLOR0,
COLOR1,
ALPHA0,
ALPHA1,
COLOR0A0,
COLOR1A1,
COLOR_ZERO,
ALPHA_BUMP,
ALPHA_BUMPN,
COLOR_NULL = 0xff
};
enum BlendMode : uint8_t {
BM_NONE,
BM_BLEND,
BM_LOGIC,
BM_SUBTRACT,
MAX_BLENDMODE,
};
enum LogicOp : uint8_t {
LO_CLEAR,
LO_AND,
LO_REVAND,
LO_COPY,
LO_INVAND,
LO_NOOP,
LO_XOR,
LO_OR,
LO_NOR,
LO_EQUIV,
LO_INV,
LO_REVOR,
LO_INVCOPY,
LO_INVOR,
LO_NAND,
LO_SET
};
enum AlphaOp : uint8_t {
AOP_AND,
AOP_OR,
AOP_XOR,
AOP_XNOR,
MAX_ALPHAOP,
};
enum ZTexOp {
ZT_DISABLE,
ZT_ADD,
ZT_REPLACE,
MAX_ZTEXOP,
};
enum Compare {
NEVER,
LESS,
EQUAL,
LEQUAL,
GREATER,
NEQUAL,
GEQUAL,
ALWAYS,
};
enum BlendFactor : uint16_t {
@ -288,6 +459,103 @@ enum TexMapID {
MAX_TEXMAP,
};
enum TevStageID {
TEVSTAGE0,
TEVSTAGE1,
TEVSTAGE2,
TEVSTAGE3,
TEVSTAGE4,
TEVSTAGE5,
TEVSTAGE6,
TEVSTAGE7,
TEVSTAGE8,
TEVSTAGE9,
TEVSTAGE10,
TEVSTAGE11,
TEVSTAGE12,
TEVSTAGE13,
TEVSTAGE14,
TEVSTAGE15,
MAX_TEVSTAGE
};
enum IndTexFormat {
ITF_8,
ITF_5,
ITF_4,
ITF_3,
MAX_ITFORMAT,
};
enum IndTexBiasSel {
ITB_NONE,
ITB_S,
ITB_T,
ITB_ST,
ITB_U,
ITB_SU,
ITB_TU,
ITB_STU,
MAX_ITBIAS,
};
enum IndTexWrap {
ITW_OFF,
ITW_256,
ITW_128,
ITW_64,
ITW_32,
ITW_16,
ITW_0,
MAX_ITWRAP,
};
enum IndTexAlphaSel {
ITBA_OFF,
ITBA_S,
ITBA_T,
ITBA_U,
MAX_ITBALPHA,
};
enum IndTexStageID {
INDTEXSTAGE0,
INDTEXSTAGE1,
INDTEXSTAGE2,
INDTEXSTAGE3,
MAX_INDTEXSTAGE,
};
enum GXIndTexScale {
ITS_1,
ITS_2,
ITS_4,
ITS_8,
ITS_16,
ITS_32,
ITS_64,
ITS_128,
ITS_256,
MAX_ITSCALE,
};
enum IndTexMtxID {
ITM_OFF,
ITM_0,
ITM_1,
ITM_2,
ITM_S0 = 5,
ITM_S1,
ITM_S2,
ITM_T0 = 9,
ITM_T1,
ITM_T2,
};
enum TexMtxType {
MTX3x4 = 0,
MTX2x4,
};
struct Color {
union {
uint8_t color[4];
@ -316,11 +584,43 @@ struct Color {
return *this;
}
explicit Color(uint8_t val) { *this = val; }
explicit Color(uint32_t val) { *this = val; }
bool operator==(const Color& other) const { return num == other.num; }
bool operator!=(const Color& other) const { return num != other.num; }
uint8_t operator[](size_t idx) const { return color[idx]; }
uint8_t& operator[](size_t idx) { return color[idx]; }
};
enum ColorSrc {
SRC_REG = 0,
SRC_VTX,
};
enum LightID {
LIGHT0 = 0x001,
LIGHT1 = 0x002,
LIGHT2 = 0x004,
LIGHT3 = 0x008,
LIGHT4 = 0x010,
LIGHT5 = 0x020,
LIGHT6 = 0x040,
LIGHT7 = 0x080,
MAX_LIGHT = 0x100,
LIGHT_NULL = 0x000,
};
enum FogType {
FOG_NONE = 0x00,
FOG_PERSP_LIN = 0x02,
FOG_PERSP_EXP = 0x04,
FOG_PERSP_EXP2 = 0x05,
FOG_PERSP_REVEXP = 0x06,
FOG_PERSP_REVEXP2 = 0x07,
FOG_ORTHO_LIN = 0x0A,
FOG_ORTHO_EXP = 0x0C,
FOG_ORTHO_EXP2 = 0x0D,
FOG_ORTHO_REVEXP = 0x0E,
FOG_ORTHO_REVEXP2 = 0x0F,
};
} // namespace GX

View File

@ -51,8 +51,8 @@ void CAuiImagePane::Update(float dt) {
CGuiWidget::Update(dt);
}
void CAuiImagePane::DoDrawImagePane(const zeus::CColor& color, const CTexture& tex, int frame, float alpha, bool noBlur,
EFilterType filter) const {
void CAuiImagePane::DoDrawImagePane(const zeus::CColor& color, CTexture& tex, int frame, float alpha,
bool noBlur) const {
zeus::CColor useColor = color;
useColor.a() *= alpha;
@ -75,26 +75,35 @@ void CAuiImagePane::DoDrawImagePane(const zeus::CColor& color, const CTexture& t
useUVs = &x114_uvs;
}
std::vector<zeus::CVector2f> realUseUvs;
realUseUvs.reserve(4);
for (auto v : *useUVs) {
realUseUvs.push_back(v + xd0_uvBias0);
}
bool zTest = xac_drawFlags == EGuiModelDrawFlags::Shadeless || xac_drawFlags == EGuiModelDrawFlags::Opaque;
if (noBlur) {
// aurora::gfx::queue_textured_quad_verts(aurora::gfx::CameraFilterType(filter), tex.GetTexture(),
// aurora::gfx::ZComp::LEqual, zTest, useColor, xe0_coords, realUseUvs, 0);
// quad.drawVerts(useColor, verts);
CGraphics::SetTevOp(ERglTevStage::Stage0, CTevCombiners::sTevPass805a5fec);
CGraphics::SetTevOp(ERglTevStage::Stage1, CTevCombiners::skPassThru);
tex.Load(GX::TEXMAP0, EClampMode::Repeat);
CGraphics::StreamBegin(GX::TRIANGLESTRIP);
CGraphics::StreamColor(useColor);
for (u32 i = 0; i < 4; ++i) {
CGraphics::StreamTexcoord((*useUVs)[i]);
CGraphics::StreamVertex(vec[i]);
}
CGraphics::StreamEnd();
} else if ((x14c_deResFactor == 0.f && alpha == 1.f) || tex.GetNumberOfMipMaps() == 1) {
// aurora::gfx::queue_textured_quad_verts(aurora::gfx::CameraFilterType(filter), tex.GetTexture(),
// aurora::gfx::ZComp::LEqual, zTest, useColor, xe0_coords, realUseUvs, 0);
CGraphics::SetTevOp(ERglTevStage::Stage0, CTevCombiners::sTevPass805a5ebc);
CGraphics::SetTevOp(ERglTevStage::Stage1, CTevCombiners::skPassThru);
tex.LoadMipLevel(0.f, GX::TEXMAP0, EClampMode::Repeat);
CGraphics::StreamBegin(GX::TRIANGLESTRIP);
CGraphics::StreamColor(useColor);
for (u32 i = 0; i < 4; ++i) {
CGraphics::StreamTexcoord((*useUVs)[i] + xd0_uvBias0);
CGraphics::StreamVertex(vec[i]);
}
CGraphics::StreamEnd();
} else {
const float tmp = (1.f - x14c_deResFactor) * alpha;
const float tmp3 = 1.f - tmp * tmp * tmp;
const float mip = tmp3 * static_cast<float>(tex.GetNumberOfMipMaps() - 1);
// aurora::gfx::queue_textured_quad_verts(aurora::gfx::CameraFilterType(filter), tex.GetTexture(),
// aurora::gfx::ZComp::LEqual, zTest, useColor, xe0_coords, realUseUvs, mip);
// aurora::gfx::queue_textured_quad_verts(aurora::gfx::CameraFilterType(filter), tex.GetTexture(),
// aurora::gfx::ZComp::LEqual, zTest, useColor, xe0_coords, realUseUvs,
// mip);
}
}
@ -107,7 +116,9 @@ void CAuiImagePane::Draw(const CGuiWidgetDrawParms& params) {
GetIsFinishedLoadingWidgetSpecific();
zeus::CColor color = xa8_color2;
color.a() *= params.x0_alphaMod;
// SetZUpdate(xac_drawFlags == EGuiModelDrawFlags::Shadeless || xac_drawFlags == EGuiModelDrawFlags::Opaque);
CGraphics::SetDepthWriteMode(true, ERglEnum::LEqual,
xac_drawFlags == EGuiModelDrawFlags::Shadeless ||
xac_drawFlags == EGuiModelDrawFlags::Opaque);
float blur0 = 1.f;
float blur1 = 0.f;
const int frame0 = static_cast<int>(x144_frameTimer);
@ -123,46 +134,62 @@ void CAuiImagePane::Draw(const CGuiWidgetDrawParms& params) {
}
// Alpha blend
DoDrawImagePane(color * zeus::CColor(0.f, 0.5f), *xb8_tex0Tok, frame0, 1.f, true, EFilterType::Blend);
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha, ERglBlendFactor::InvSrcAlpha,
ERglLogicOp::Clear);
DoDrawImagePane(color * zeus::CColor(0.f, 0.5f), *xb8_tex0Tok, frame0, 1.f, true);
if (x150_flashFactor > 0.f) {
// Additive blend
zeus::CColor color2 = xa8_color2;
color2.a() = x150_flashFactor;
DoDrawImagePane(color2, *xb8_tex0Tok, frame0, blur0, false, EFilterType::Blend);
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha, ERglBlendFactor::One, ERglLogicOp::Clear);
DoDrawImagePane(color2, *xb8_tex0Tok, frame0, blur0, false);
if (blur1 > 0.f)
DoDrawImagePane(color2, *xb8_tex0Tok, frame1, blur1, false, EFilterType::Blend);
DoDrawImagePane(color2, *xb8_tex0Tok, frame1, blur1, false);
}
switch (xac_drawFlags) {
case EGuiModelDrawFlags::Shadeless:
case EGuiModelDrawFlags::Opaque:
// Opaque blend
DoDrawImagePane(color, *xb8_tex0Tok, frame0, blur0, false, EFilterType::Blend);
if (blur1 > 0.f)
DoDrawImagePane(color, *xb8_tex0Tok, frame1, blur1, false, EFilterType::Blend);
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha, ERglBlendFactor::InvSrcAlpha,
ERglLogicOp::Clear);
DoDrawImagePane(color, *xb8_tex0Tok, frame0, blur0, false);
if (blur1 > 0.f) {
DoDrawImagePane(color, *xb8_tex0Tok, frame1, blur1, false);
}
break;
case EGuiModelDrawFlags::Alpha:
// Alpha blend
DoDrawImagePane(color, *xb8_tex0Tok, frame0, blur0, false, EFilterType::Blend);
if (blur1 > 0.f)
DoDrawImagePane(color, *xb8_tex0Tok, frame1, blur1, false, EFilterType::Blend);
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha, ERglBlendFactor::InvSrcAlpha,
ERglLogicOp::Clear);
DoDrawImagePane(color, *xb8_tex0Tok, frame0, blur0, false);
if (blur1 > 0.f) {
DoDrawImagePane(color, *xb8_tex0Tok, frame1, blur1, false);
}
break;
case EGuiModelDrawFlags::Additive:
// Additive blend
DoDrawImagePane(color, *xb8_tex0Tok, frame0, blur0, false, EFilterType::Add);
if (blur1 > 0.f)
DoDrawImagePane(color, *xb8_tex0Tok, frame1, blur1, false, EFilterType::Add);
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha, ERglBlendFactor::One, ERglLogicOp::Clear);
DoDrawImagePane(color, *xb8_tex0Tok, frame0, blur0, false);
if (blur1 > 0.f) {
DoDrawImagePane(color, *xb8_tex0Tok, frame1, blur1, false);
}
break;
case EGuiModelDrawFlags::AlphaAdditiveOverdraw:
// Alpha blend
DoDrawImagePane(color, *xb8_tex0Tok, frame0, blur0, false, EFilterType::Blend);
if (blur1 > 0.f)
DoDrawImagePane(color, *xb8_tex0Tok, frame1, blur1, false, EFilterType::Blend);
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha, ERglBlendFactor::InvSrcAlpha,
ERglLogicOp::Clear);
DoDrawImagePane(color, *xb8_tex0Tok, frame0, blur0, false);
if (blur1 > 0.f) {
DoDrawImagePane(color, *xb8_tex0Tok, frame1, blur1, false);
}
// Full additive blend
DoDrawImagePane(color, *xb8_tex0Tok, frame0, blur0, false, EFilterType::Add);
if (blur1 > 0.f)
DoDrawImagePane(color, *xb8_tex0Tok, frame1, blur1, false, EFilterType::Add);
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::One, ERglBlendFactor::One, ERglLogicOp::Clear);
DoDrawImagePane(color, *xb8_tex0Tok, frame0, blur0, false);
if (blur1 > 0.f) {
DoDrawImagePane(color, *xb8_tex0Tok, frame1, blur1, false);
}
break;
default:
break;

View File

@ -32,8 +32,7 @@ class CAuiImagePane : public CGuiWidget {
float x148_fadeDuration = 0.f;
float x14c_deResFactor = 0.f;
float x150_flashFactor = 0.f;
void DoDrawImagePane(const zeus::CColor& color, const CTexture& tex, int frame, float blurAmt, bool noBlur,
EFilterType filter) const;
void DoDrawImagePane(const zeus::CColor& color, CTexture& tex, int frame, float blurAmt, bool noBlur) const;
public:
CAuiImagePane(const CGuiWidgetParms& parms, CSimplePool* sp, CAssetId, CAssetId,

View File

@ -16,8 +16,13 @@ void CGuiPane::Draw(const CGuiWidgetDrawParms& parms) {
auto col = xa8_color2;
col.a() = parms.x0_alphaMod * xa8_color2.a();
#if 0
CGraphics::SetTevOp(ERglTevStage::Stage0, CTevCombiners::skPassThru);
CGraphics::DrawPrimitive(GX::Primitive::TRIANGLESTRIP, xc0_verts.data(), skDefaultNormal, col, xc0_verts.size());
#else
aurora::gfx::queue_colored_quad_verts(aurora::gfx::CameraFilterType::Blend, aurora::gfx::ZComp::Always, false, col,
xc0_verts);
#endif
}
CGuiWidget::Draw(parms);
}

View File

@ -11,6 +11,7 @@
namespace metaforce {
class CGuiPane : public CGuiWidget {
static constexpr zeus::CVector3f skDefaultNormal{0.f, -1.f, 0.f};
protected:
zeus::CVector2f xb8_dim;

View File

@ -18,38 +18,27 @@ CDecal::CDecal(const TToken<CDecalDescription>& desc, const zeus::CTransform& xf
CDecalDescription* d = x0_description.GetObj();
if (d->x38_DMDL) {
if (d->x48_DLFT)
if (d->x48_DLFT) {
d->x48_DLFT->GetValue(0, x54_modelLifetime);
else
} else {
x54_modelLifetime = 0x7FFFFF;
}
if (d->x50_DMRT)
if (d->x50_DMRT) {
d->x50_DMRT->GetValue(0, x60_rotation);
}
} else {
x5c_29_modelInvalid = true;
}
// CGraphics::CommitResources([this](boo::IGraphicsDataFactory::Context& ctx) {
// for (auto& decal : x3c_decalQuads) {
// if (decal.m_desc->x14_TEX) {
// decal.m_instBuf = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(SParticleInstanceTex), 1);
// } else {
// decal.m_instBuf = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(SParticleInstanceNoTex), 1);
// }
// decal.m_uniformBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(SParticleUniforms), 1);
// CDecalShaders::BuildShaderDataBinding(ctx, decal);
// }
// return true;
// } BooTrace);
}
bool CDecal::InitQuad(CQuadDecal& quad, const SQuadDescr& desc) {
quad.m_desc = &desc;
if (desc.x14_TEX) {
if (desc.x0_LFT)
if (desc.x0_LFT) {
desc.x0_LFT->GetValue(0, quad.x4_lifetime);
else
} else {
quad.x4_lifetime = 0x7FFFFF;
}
if (desc.x8_ROT) {
desc.x8_ROT->GetValue(0, quad.x8_rotation);
quad.x0_24_invalid = desc.x8_ROT->IsConstant();
@ -62,8 +51,9 @@ bool CDecal::InitQuad(CQuadDecal& quad, const SQuadDescr& desc) {
quad.x0_24_invalid = size <= 1.f;
}
if (desc.xc_OFF)
if (desc.xc_OFF) {
quad.x0_24_invalid = desc.xc_OFF->IsFastConstant();
}
return false;
}
@ -79,14 +69,16 @@ void CDecal::RenderQuad(CQuadDecal& decal, const SQuadDescr& desc) const {
zeus::CColor color = zeus::skWhite;
float size = 1.f;
zeus::CVector3f offset;
if (CColorElement* clr = desc.x10_CLR.get())
if (CColorElement* clr = desc.x10_CLR.get()) {
clr->GetValue(x58_frameIdx, color);
}
if (CRealElement* sze = desc.x4_SZE.get()) {
sze->GetValue(x58_frameIdx, size);
size *= 0.5f;
}
if (CRealElement* rot = desc.x8_ROT.get())
if (CRealElement* rot = desc.x8_ROT.get()) {
rot->GetValue(x58_frameIdx, decal.x8_rotation);
}
if (CVectorElement* off = desc.xc_OFF.get()) {
off->GetValue(x58_frameIdx, offset);
offset.y() = 0.f;
@ -235,8 +227,9 @@ void CDecal::RenderMdl() {
void CDecal::Render() {
SCOPED_GRAPHICS_DEBUG_GROUP("CDecal::Render", zeus::skYellow);
CGlobalRandom gr(sDecalRandom);
if (x5c_29_modelInvalid && x5c_30_quad2Invalid && x5c_31_quad1Invalid)
if (x5c_29_modelInvalid && x5c_30_quad2Invalid && x5c_31_quad1Invalid) {
return;
}
CGraphics::DisableAllLights();
CParticleGlobals::instance()->SetEmitterTime(x58_frameIdx);

View File

@ -16,14 +16,8 @@ struct CQuadDecal {
bool x0_24_invalid : 1 = true;
s32 x4_lifetime = 0;
float x8_rotation = 0.f;
const SQuadDescr* m_desc = nullptr;
CQuadDecal() = default;
CQuadDecal(s32 i, float f) : x4_lifetime(i), x8_rotation(f) {}
// boo::ObjToken<boo::IGraphicsBufferD> m_instBuf;
// boo::ObjToken<boo::IGraphicsBufferD> m_uniformBuf;
// boo::ObjToken<boo::IShaderDataBinding> m_normalDataBind;
// boo::ObjToken<boo::IShaderDataBinding> m_redToAlphaDataBind;
};
class CDecal {

View File

@ -149,7 +149,7 @@ struct CTevOp {
GX::TevOp x4_op = GX::TevOp::TEV_ADD;
GX::TevBias x8_bias = GX::TevBias::TB_ZERO;
GX::TevScale xc_scale = GX::TevScale::CS_SCALE_1;
GX::TevRegID xc_regId = GX::TevRegID::TEVPREV;
GX::TevRegID x10_regId = GX::TevRegID::TEVPREV;
bool operator<=>(const CTevOp&) const = default;
};

View File

@ -296,13 +296,13 @@ static ShaderRef generate_shader() {
{
std::string op;
std::string outReg;
switch (stage->colorOp.xc_regId) {
switch (stage->colorOp.x10_regId) {
case GX::TevRegID::TEVPREV:
outReg = "prev";
break;
default:
Log.report(logvisor::Fatal, FMT_STRING("TODO: colorOp outReg {}"),
magic_enum::enum_name(stage->colorOp.xc_regId));
magic_enum::enum_name(stage->colorOp.x10_regId));
}
op = fmt::format(FMT_STRING("({3} {4} ((1.0 - {2}) * {0} + {2} * {1}){5}){6}"),
color_arg_reg(stage->colorPass.x0_a, idx), color_arg_reg(stage->colorPass.x4_b, idx),
@ -314,13 +314,13 @@ static ShaderRef generate_shader() {
{
std::string op;
std::string outReg;
switch (stage->alphaOp.xc_regId) {
switch (stage->alphaOp.x10_regId) {
case GX::TevRegID::TEVPREV:
outReg = "prev.a";
break;
default:
Log.report(logvisor::Fatal, FMT_STRING("TODO: alphaOp outReg {}"),
magic_enum::enum_name(stage->alphaOp.xc_regId));
magic_enum::enum_name(stage->alphaOp.x10_regId));
}
op = fmt::format(FMT_STRING("({3} {4} ((1.0 - {2}) * {0} + {2} * {1}){5}){6}"),
alpha_arg_reg(stage->alphaPass.x0_a, idx), alpha_arg_reg(stage->alphaPass.x4_b, idx),