mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-08 13:44:56 +00:00
Various bug fixes
This commit is contained in:
@@ -270,6 +270,7 @@ void CBooRenderer::ActivateLightsForModel(CAreaListItem* item, CBooModel& model)
|
||||
void CBooRenderer::RenderBucketItems(CAreaListItem* item)
|
||||
{
|
||||
CModelFlags flags;
|
||||
flags.m_noZWrite = true;
|
||||
flags.m_extendedShader = EExtendedShader::Lighting;
|
||||
|
||||
for (u16 idx : Buckets::sBucketIndex)
|
||||
@@ -831,7 +832,7 @@ void CBooRenderer::UpdateAreaUniforms(int areaIdx, bool shadowRender)
|
||||
continue;
|
||||
|
||||
item.m_shaderSet->m_geomLayout->Update(flags, nullptr, nullptr, &item.m_shaderSet->m_matSet,
|
||||
item.m_shaderSet->m_geomLayout->m_sharedBuffer[bufIdx]);
|
||||
item.m_shaderSet->m_geomLayout->m_sharedBuffer[bufIdx], nullptr);
|
||||
|
||||
for (auto it = item.x10_models.begin(); it != item.x10_models.end(); ++it)
|
||||
{
|
||||
|
||||
@@ -97,7 +97,8 @@ struct GeometryUniformLayout
|
||||
|
||||
GeometryUniformLayout(const CModel* model, const MaterialSet* matSet);
|
||||
void Update(const CModelFlags& flags, const CSkinRules* cskr, const CPoseAsTransforms* pose,
|
||||
const MaterialSet* matSet, const boo::ObjToken<boo::IGraphicsBufferD>& buf) const;
|
||||
const MaterialSet* matSet, const boo::ObjToken<boo::IGraphicsBufferD>& buf,
|
||||
const CBooModel* parent) const;
|
||||
};
|
||||
|
||||
struct SShader
|
||||
@@ -161,7 +162,8 @@ private:
|
||||
{
|
||||
static void ProcessAnimation(u8*& bufOut, const UVAnimation& anim);
|
||||
static void PadOutBuffer(u8*& bufStart, u8*& bufOut);
|
||||
static void Update(u8*& bufOut, const MaterialSet* matSet, const CModelFlags& flags);
|
||||
static void Update(u8*& bufOut, const MaterialSet* matSet,
|
||||
const CModelFlags& flags, const CBooModel* parent);
|
||||
};
|
||||
|
||||
CModelShaders::LightingUniform m_lightingData;
|
||||
@@ -185,6 +187,7 @@ private:
|
||||
boo::ObjToken<boo::ITexture> m_txtrOverrides[8];
|
||||
|
||||
boo::ObjToken<boo::ITexture> m_lastDrawnShadowMap;
|
||||
boo::ObjToken<boo::ITexture> m_lastDrawnOneTexture;
|
||||
|
||||
ModelInstance* PushNewModelInstance(int sharedLayoutBuf = -1);
|
||||
void DrawAlphaSurfaces(const CModelFlags& flags) const;
|
||||
@@ -268,10 +271,15 @@ public:
|
||||
static void EnableShadowMaps(const boo::ObjToken<boo::ITexture>& map, const zeus::CTransform& texXf);
|
||||
static void DisableShadowMaps();
|
||||
|
||||
static boo::ObjToken<boo::ITexture> g_disintegrateTexture;
|
||||
static void SetDisintegrateTexture(const boo::ObjToken<boo::ITexture>& map) { g_disintegrateTexture = map; }
|
||||
|
||||
static void SetDummyTextures(bool b) { g_DummyTextures = b; }
|
||||
static void SetRenderModelBlack(bool b) { g_RenderModelBlack = b; }
|
||||
|
||||
static void AssertAllFreed();
|
||||
|
||||
const zeus::CAABox& GetAABB() const { return x20_aabb; }
|
||||
};
|
||||
|
||||
class CModel
|
||||
|
||||
@@ -149,6 +149,7 @@ void CBooModel::EnsureViewDepStateCached(const CBooModel& model, const CBooSurfa
|
||||
|
||||
boo::ObjToken<boo::ITexture> CBooModel::g_shadowMap;
|
||||
zeus::CTransform CBooModel::g_shadowTexXf;
|
||||
boo::ObjToken<boo::ITexture> CBooModel::g_disintegrateTexture;
|
||||
|
||||
void CBooModel::EnableShadowMaps(const boo::ObjToken<boo::ITexture>& map, const zeus::CTransform& texXf)
|
||||
{
|
||||
@@ -198,7 +199,7 @@ CBooModel::CBooModel(TToken<CModel>& token, CModel* parent, std::vector<CBooSurf
|
||||
{
|
||||
u32 matId = it->m_data.matIdx;
|
||||
const MaterialSet::Material& matData = GetMaterialByIndex(matId);
|
||||
if (matData.flags.depthSorting() || matData.heclIr.m_doAlpha)
|
||||
if (matData.flags.depthSorting())
|
||||
{
|
||||
it->m_next = x3c_firstSortedSurface;
|
||||
x3c_firstSortedSurface = &*it;
|
||||
@@ -251,7 +252,7 @@ GeometryUniformLayout::GeometryUniformLayout(const CModel* model, const Material
|
||||
/* Skinned */
|
||||
for (size_t i=0 ; i<m_skinBankCount ; ++i)
|
||||
{
|
||||
size_t thisSz = ROUND_UP_256(sizeof(zeus::CMatrix4f) * (2 * m_weightVecCount * 4 + 1));
|
||||
size_t thisSz = ROUND_UP_256(sizeof(zeus::CMatrix4f) * (2 * m_weightVecCount * 4 + 3));
|
||||
m_skinOffs.push_back(m_geomBufferSize);
|
||||
m_skinSizes.push_back(thisSz);
|
||||
m_geomBufferSize += thisSz;
|
||||
@@ -445,6 +446,14 @@ CBooModel::ModelInstance* CBooModel::PushNewModelInstance(int sharedLayoutBuf)
|
||||
texs[7] = g_Renderer->x220_sphereRamp.get();
|
||||
ltexs = texs;
|
||||
}
|
||||
else if (idx == EExtendedShader::Disintegrate)
|
||||
{
|
||||
if (g_disintegrateTexture)
|
||||
texs[7] = g_disintegrateTexture;
|
||||
else
|
||||
texs[7] = g_Renderer->x220_sphereRamp.get();
|
||||
ltexs = texs;
|
||||
}
|
||||
else if (useReflection)
|
||||
{
|
||||
ltexs = texs;
|
||||
@@ -757,11 +766,8 @@ void CBooModel::UVAnimationBuffer::ProcessAnimation(u8*& bufOut, const UVAnimati
|
||||
{
|
||||
case UVAnimation::Mode::MvInvNoTranslation:
|
||||
{
|
||||
/* Handled in-shader
|
||||
texMtxOut = CGraphics::g_GXModelViewInvXpose.toMatrix4f();
|
||||
texMtxOut.vec[3].zeroOut();
|
||||
texMtxOut.vec[3].w = 1.f;
|
||||
*/
|
||||
postMtxOut.vec[0].x = 0.5f;
|
||||
postMtxOut.vec[1].y = 0.5f;
|
||||
postMtxOut.vec[3].x = 0.5f;
|
||||
@@ -770,6 +776,7 @@ void CBooModel::UVAnimationBuffer::ProcessAnimation(u8*& bufOut, const UVAnimati
|
||||
}
|
||||
case UVAnimation::Mode::MvInv:
|
||||
{
|
||||
texMtxOut = CGraphics::g_GXModelViewInvXpose.toMatrix4f();
|
||||
texMtxOut.vec[3] = CGraphics::g_ViewMatrix.inverse() * CGraphics::g_GXModelMatrix.origin;
|
||||
texMtxOut.vec[3].w = 1.f;
|
||||
postMtxOut.vec[0].x = 0.5f;
|
||||
@@ -822,11 +829,7 @@ void CBooModel::UVAnimationBuffer::ProcessAnimation(u8*& bufOut, const UVAnimati
|
||||
}
|
||||
case UVAnimation::Mode::CylinderEnvironment:
|
||||
{
|
||||
/* Handled in-shader
|
||||
//texMtxOut = (CGraphics::g_ViewMatrix.inverse() * CGraphics::g_GXModelMatrix).toMatrix4f();
|
||||
texMtxOut = CGraphics::g_GXModelView.toMatrix4f();
|
||||
texMtxOut.vec[3].zeroOut();
|
||||
*/
|
||||
texMtxOut = CGraphics::g_GXModelViewInvXpose.toMatrix4f();
|
||||
|
||||
const zeus::CVector3f& viewOrigin = CGraphics::g_ViewMatrix.origin;
|
||||
float xy = (viewOrigin.x + viewOrigin.y) * 0.025f * anim.vals[1];
|
||||
@@ -862,13 +865,19 @@ static const zeus::CMatrix4f MBShadowPost1(0.f, 0.f, 0.f, 1.f,
|
||||
0.f, 0.f, 0.f, 1.f,
|
||||
0.f, 0.f, 0.f, 1.f);
|
||||
|
||||
void CBooModel::UVAnimationBuffer::Update(u8*& bufOut, const MaterialSet* matSet, const CModelFlags& flags)
|
||||
static const zeus::CMatrix4f DisintegratePost(1.f, 1.f, 0.f, 0.f,
|
||||
0.f, 0.f, 1.f, 0.f,
|
||||
0.f, 0.f, 0.f, 1.f,
|
||||
0.f, 0.f, 0.f, 1.f);
|
||||
|
||||
void CBooModel::UVAnimationBuffer::Update(u8*& bufOut, const MaterialSet* matSet,
|
||||
const CModelFlags& flags, const CBooModel* parent)
|
||||
{
|
||||
u8* start = bufOut;
|
||||
|
||||
/* Special matrices for MorphBall shadow rendering */
|
||||
if (flags.m_extendedShader == EExtendedShader::MorphBallShadow)
|
||||
{
|
||||
/* Special matrices for MorphBall shadow rendering */
|
||||
zeus::CMatrix4f texMtx =
|
||||
(zeus::CTransform::Scale(1.f / (flags.mbShadowBox.max.x - flags.mbShadowBox.min.x),
|
||||
1.f / (flags.mbShadowBox.max.y - flags.mbShadowBox.min.y),
|
||||
@@ -889,6 +898,34 @@ void CBooModel::UVAnimationBuffer::Update(u8*& bufOut, const MaterialSet* matSet
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (flags.m_extendedShader == EExtendedShader::Disintegrate)
|
||||
{
|
||||
assert(parent != nullptr && "Parent CBooModel not set");
|
||||
zeus::CTransform xf = zeus::CTransform::RotateX(-zeus::degToRad(45.f));
|
||||
zeus::CAABox aabb = parent->GetAABB().getTransformedAABox(xf);
|
||||
xf = zeus::CTransform::Scale(5.f / (aabb.max - aabb.min)) *
|
||||
zeus::CTransform::Translate(-aabb.min) * xf;
|
||||
zeus::CMatrix4f texMtx = xf.toMatrix4f();
|
||||
zeus::CMatrix4f post0 = DisintegratePost;
|
||||
post0[3].x = flags.addColor.a;
|
||||
post0[3].y = 6.f * -(1.f - flags.addColor.a) + 1.f;
|
||||
zeus::CMatrix4f post1 = DisintegratePost;
|
||||
post1[3].x = -0.85f * flags.addColor.a - 0.15f;
|
||||
post1[3].y = post0[3].y;
|
||||
/* Special matrices for disintegration rendering */
|
||||
for (const MaterialSet::Material& mat : matSet->materials)
|
||||
{
|
||||
(void)mat;
|
||||
std::array<zeus::CMatrix4f, 2>* mtxs = reinterpret_cast<std::array<zeus::CMatrix4f, 2>*>(bufOut);
|
||||
mtxs[0][0] = texMtx;
|
||||
mtxs[0][1] = post0;
|
||||
mtxs[1][0] = texMtx;
|
||||
mtxs[1][1] = post1;
|
||||
bufOut += sizeof(zeus::CMatrix4f) * 2 * 8;
|
||||
PadOutBuffer(start, bufOut);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
std::experimental::optional<std::array<zeus::CMatrix4f, 2>> specialMtxOut;
|
||||
if (flags.m_extendedShader == EExtendedShader::Thermal)
|
||||
@@ -946,7 +983,8 @@ void GeometryUniformLayout::Update(const CModelFlags& flags,
|
||||
const CSkinRules* cskr,
|
||||
const CPoseAsTransforms* pose,
|
||||
const MaterialSet* matSet,
|
||||
const boo::ObjToken<boo::IGraphicsBufferD>& buf) const
|
||||
const boo::ObjToken<boo::IGraphicsBufferD>& buf,
|
||||
const CBooModel* parent) const
|
||||
{
|
||||
u8* dataOut = reinterpret_cast<u8*>(buf->map(m_geomBufferSize));
|
||||
u8* dataCur = dataOut;
|
||||
@@ -965,25 +1003,20 @@ void GeometryUniformLayout::Update(const CModelFlags& flags,
|
||||
|
||||
for (size_t w=0 ; w<weightCount ; ++w)
|
||||
{
|
||||
zeus::CMatrix4f& mv = reinterpret_cast<zeus::CMatrix4f&>(*dataCur);
|
||||
zeus::CMatrix4f& obj = reinterpret_cast<zeus::CMatrix4f&>(*dataCur);
|
||||
if (w >= bankTransforms.size())
|
||||
mv = CGraphics::g_GXModelView.toMatrix4f();
|
||||
obj = zeus::CMatrix4f::skIdentityMatrix4f;
|
||||
else
|
||||
mv = (CGraphics::g_GXModelView * *bankTransforms[w]).toMatrix4f();
|
||||
obj = bankTransforms[w]->toMatrix4f();
|
||||
dataCur += sizeof(zeus::CMatrix4f);
|
||||
}
|
||||
for (size_t w=0 ; w<weightCount ; ++w)
|
||||
{
|
||||
zeus::CMatrix4f& mvinv = reinterpret_cast<zeus::CMatrix4f&>(*dataCur);
|
||||
zeus::CMatrix4f& objInv = reinterpret_cast<zeus::CMatrix4f&>(*dataCur);
|
||||
if (w >= bankTransforms.size())
|
||||
mvinv = CGraphics::g_GXModelViewInvXpose.toMatrix4f();
|
||||
objInv = zeus::CMatrix4f::skIdentityMatrix4f;
|
||||
else
|
||||
{
|
||||
zeus::CTransform xf = (CGraphics::g_GXModelView.basis * bankTransforms[w]->basis);
|
||||
xf.basis.invert();
|
||||
xf.basis.transpose();
|
||||
mvinv = xf.toMatrix4f();
|
||||
}
|
||||
objInv = bankTransforms[w]->basis;
|
||||
dataCur += sizeof(zeus::CMatrix4f);
|
||||
}
|
||||
|
||||
@@ -994,16 +1027,24 @@ void GeometryUniformLayout::Update(const CModelFlags& flags,
|
||||
for (size_t w=0 ; w<weightCount ; ++w)
|
||||
{
|
||||
zeus::CMatrix4f& mv = reinterpret_cast<zeus::CMatrix4f&>(*dataCur);
|
||||
mv = CGraphics::g_GXModelView.toMatrix4f();
|
||||
mv = zeus::CMatrix4f::skIdentityMatrix4f;
|
||||
dataCur += sizeof(zeus::CMatrix4f);
|
||||
}
|
||||
for (size_t w=0 ; w<weightCount ; ++w)
|
||||
{
|
||||
zeus::CMatrix4f& mvinv = reinterpret_cast<zeus::CMatrix4f&>(*dataCur);
|
||||
mvinv = CGraphics::g_GXModelViewInvXpose.toMatrix4f();
|
||||
mvinv = zeus::CMatrix4f::skIdentityMatrix4f;
|
||||
dataCur += sizeof(zeus::CMatrix4f);
|
||||
}
|
||||
}
|
||||
zeus::CMatrix4f& mv = reinterpret_cast<zeus::CMatrix4f&>(*dataCur);
|
||||
mv = CGraphics::g_GXModelView.toMatrix4f();
|
||||
dataCur += sizeof(zeus::CMatrix4f);
|
||||
|
||||
zeus::CMatrix4f& mvinv = reinterpret_cast<zeus::CMatrix4f&>(*dataCur);
|
||||
mvinv = CGraphics::g_GXModelViewInvXpose.toMatrix4f();
|
||||
dataCur += sizeof(zeus::CMatrix4f);
|
||||
|
||||
zeus::CMatrix4f& proj = reinterpret_cast<zeus::CMatrix4f&>(*dataCur);
|
||||
proj = CGraphics::GetPerspectiveProjectionMatrix(true);
|
||||
dataCur += sizeof(zeus::CMatrix4f);
|
||||
@@ -1029,7 +1070,7 @@ void GeometryUniformLayout::Update(const CModelFlags& flags,
|
||||
dataCur = dataOut + ROUND_UP_256(dataCur - dataOut);
|
||||
}
|
||||
|
||||
CBooModel::UVAnimationBuffer::Update(dataCur, matSet, flags);
|
||||
CBooModel::UVAnimationBuffer::Update(dataCur, matSet, flags, parent);
|
||||
buf->unmap();
|
||||
}
|
||||
|
||||
@@ -1046,6 +1087,14 @@ boo::ObjToken<boo::IGraphicsBufferD> CBooModel::UpdateUniformData(const CModelFl
|
||||
const_cast<CBooModel*>(this)->m_instances.clear();
|
||||
}
|
||||
|
||||
/* Invalidate instances if new one-texture being drawn */
|
||||
if (flags.m_extendedShader == EExtendedShader::Disintegrate &&
|
||||
m_lastDrawnOneTexture != g_disintegrateTexture)
|
||||
{
|
||||
const_cast<CBooModel*>(this)->m_lastDrawnOneTexture = g_disintegrateTexture;
|
||||
const_cast<CBooModel*>(this)->m_instances.clear();
|
||||
}
|
||||
|
||||
const ModelInstance* inst;
|
||||
if (sharedLayoutBuf >= 0)
|
||||
{
|
||||
@@ -1076,7 +1125,7 @@ boo::ObjToken<boo::IGraphicsBufferD> CBooModel::UpdateUniformData(const CModelFl
|
||||
}
|
||||
|
||||
if (inst->m_geomUniformBuffer)
|
||||
m_geomLayout->Update(flags, cskr, pose, x4_matSet, inst->m_geomUniformBuffer);
|
||||
m_geomLayout->Update(flags, cskr, pose, x4_matSet, inst->m_geomUniformBuffer, this);
|
||||
|
||||
u8* dataOut = reinterpret_cast<u8*>(inst->m_uniformBuffer->map(m_uniformDataSize));
|
||||
u8* dataCur = dataOut;
|
||||
@@ -1100,6 +1149,12 @@ boo::ObjToken<boo::IGraphicsBufferD> CBooModel::UpdateUniformData(const CModelFl
|
||||
shadowOut.shadowUp.w = flags.x4_color.a;
|
||||
shadowOut.shadowId = flags.x4_color.r;
|
||||
}
|
||||
else if (flags.m_extendedShader == EExtendedShader::Disintegrate)
|
||||
{
|
||||
CModelShaders::OneTextureUniform& oneTexOut = *reinterpret_cast<CModelShaders::OneTextureUniform*>(dataCur);
|
||||
oneTexOut.addColor = flags.addColor;
|
||||
oneTexOut.fog = CGraphics::g_Fog;
|
||||
}
|
||||
else
|
||||
{
|
||||
CModelShaders::LightingUniform& lightingOut = *reinterpret_cast<CModelShaders::LightingUniform*>(dataCur);
|
||||
@@ -1230,7 +1285,7 @@ SShader::BuildShader(const hecl::HMDLMeta& meta, const MaterialSet::Material& ma
|
||||
hecl::Backend::ShaderTag tag(mat.heclIr,
|
||||
meta.colorCount, meta.uvCount, meta.weightCount,
|
||||
meta.weightCount * 4, boo::Primitive(meta.topology),
|
||||
reflectionType, true, true, true);
|
||||
reflectionType, true, true, true, mat.flags.alphaTest());
|
||||
return CModelShaders::BuildExtendedShader(tag, mat.heclIr);
|
||||
}
|
||||
|
||||
|
||||
@@ -62,9 +62,11 @@ public:
|
||||
|
||||
class CMorphableSkinnedModel : public CSkinnedModel
|
||||
{
|
||||
std::unique_ptr<float[]> x40_morphMagnitudes;
|
||||
public:
|
||||
CMorphableSkinnedModel(IObjectStore& store, CAssetId model, CAssetId skinRules,
|
||||
CAssetId layoutInfo, int shaderIdx, int drawInsts);
|
||||
const float* GetMorphMagnitudes() const { return x40_morphMagnitudes.get(); }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -71,6 +71,12 @@ static const hecl::Backend::TextureInfo WorldShadowTextures[] =
|
||||
{hecl::Backend::TexGenSrc::Position, 7, 0, 7, false} // Shadow tex
|
||||
};
|
||||
|
||||
static const hecl::Backend::TextureInfo DisintegrateTextures[] =
|
||||
{
|
||||
{hecl::Backend::TexGenSrc::Position, 7, 0, 0, false}, // Ashy tex
|
||||
{hecl::Backend::TexGenSrc::Position, 7, 0, 1, false} // Ashy tex
|
||||
};
|
||||
|
||||
static const char* BlockNames[] = {"LightingUniform"};
|
||||
static const char* ThermalBlockNames[] = {"ThermalUniform"};
|
||||
static const char* SolidBlockNames[] = {"SolidUniform"};
|
||||
@@ -157,7 +163,11 @@ static hecl::Backend::ExtensionSlot g_ExtensionSlots[] =
|
||||
/* Depth GEqual no Z-write */
|
||||
{1, BlockNames, 0, nullptr, hecl::Backend::BlendFactor::SrcAlpha,
|
||||
hecl::Backend::BlendFactor::InvSrcAlpha, hecl::Backend::ZTest::GEqual,
|
||||
hecl::Backend::CullMode::Backface, true, false, true}
|
||||
hecl::Backend::CullMode::Backface, true, false, true},
|
||||
/* Disintegration */
|
||||
{1, BlockNames, 2, DisintegrateTextures, hecl::Backend::BlendFactor::SrcAlpha,
|
||||
hecl::Backend::BlendFactor::InvSrcAlpha, hecl::Backend::ZTest::LEqual,
|
||||
hecl::Backend::CullMode::Original, false, false, true, false, false, true}
|
||||
};
|
||||
|
||||
extern const hecl::Backend::Function ExtensionLightingFuncsGLSL[];
|
||||
|
||||
@@ -35,6 +35,7 @@ enum EExtendedShader : uint8_t
|
||||
ForcedAlphaNoCullNoZWrite,
|
||||
ForcedAdditiveNoCullNoZWrite,
|
||||
DepthGEqualNoZWrite,
|
||||
Disintegrate,
|
||||
MAX
|
||||
};
|
||||
|
||||
@@ -79,6 +80,12 @@ public:
|
||||
float shadowId;
|
||||
};
|
||||
|
||||
struct OneTextureUniform
|
||||
{
|
||||
zeus::CColor addColor;
|
||||
CGraphics::CFogState fog;
|
||||
};
|
||||
|
||||
static void Initialize();
|
||||
static void Shutdown();
|
||||
|
||||
|
||||
@@ -8,6 +8,46 @@ using namespace std::literals;
|
||||
extern const hecl::Backend::Function ExtensionLightingFuncsGLSL[];
|
||||
extern const hecl::Backend::Function ExtensionPostFuncsGLSL[];
|
||||
|
||||
#define FOG_STRUCT_GLSL \
|
||||
"struct Fog\n" \
|
||||
"{\n" \
|
||||
" int mode;\n" \
|
||||
" vec4 color;\n" \
|
||||
" float rangeScale;\n" \
|
||||
" float start;\n" \
|
||||
"};\n"
|
||||
|
||||
#define FOG_ALGORITHM_GLSL \
|
||||
" float fogZ, temp;\n" \
|
||||
" switch (fog.mode)\n" \
|
||||
" {\n" \
|
||||
" case 2:\n" \
|
||||
" fogZ = (-vtf.mvPos.z - fog.start) * fog.rangeScale;\n" \
|
||||
" break;\n" \
|
||||
" case 4:\n" \
|
||||
" fogZ = 1.0 - exp2(-8.0 * (-vtf.mvPos.z - fog.start) * fog.rangeScale);\n" \
|
||||
" break;\n" \
|
||||
" case 5:\n" \
|
||||
" temp = (-vtf.mvPos.z - fog.start) * fog.rangeScale;\n" \
|
||||
" fogZ = 1.0 - exp2(-8.0 * temp * temp);\n" \
|
||||
" break;\n" \
|
||||
" case 6:\n" \
|
||||
" fogZ = exp2(-8.0 * (fog.start + vtf.mvPos.z) * fog.rangeScale);\n" \
|
||||
" break;\n" \
|
||||
" case 7:\n" \
|
||||
" temp = (fog.start + vtf.mvPos.z) * fog.rangeScale;\n" \
|
||||
" fogZ = exp2(-8.0 * temp * temp);\n" \
|
||||
" break;\n" \
|
||||
" default:\n" \
|
||||
" fogZ = 0.0;\n" \
|
||||
" break;\n" \
|
||||
" }\n" \
|
||||
"#ifdef BLEND_DST_ONE\n" \
|
||||
" return vec4(mix(colorIn, vec4(0.0), clamp(fogZ, 0.0, 1.0)).rgb, colorIn.a);\n" \
|
||||
"#else\n" \
|
||||
" return vec4(mix(colorIn, fog.color, clamp(fogZ, 0.0, 1.0)).rgb, colorIn.a);\n" \
|
||||
"#endif\n"
|
||||
|
||||
static std::string_view LightingGLSL =
|
||||
"struct Light\n"
|
||||
"{\n"
|
||||
@@ -17,13 +57,7 @@ static std::string_view LightingGLSL =
|
||||
" vec4 linAtt;\n"
|
||||
" vec4 angAtt;\n"
|
||||
"};\n"
|
||||
"struct Fog\n"
|
||||
"{\n"
|
||||
" int mode;\n"
|
||||
" vec4 color;\n"
|
||||
" float rangeScale;\n"
|
||||
" float start;\n"
|
||||
"};\n"
|
||||
FOG_STRUCT_GLSL
|
||||
"\n"
|
||||
"UBINDING2 uniform LightingUniform\n"
|
||||
"{\n"
|
||||
@@ -124,35 +158,7 @@ static std::string_view LightingShadowGLSL =
|
||||
static std::string_view MainPostGLSL =
|
||||
"vec4 MainPostFunc(vec4 colorIn)\n"
|
||||
"{\n"
|
||||
" float fogZ, temp;\n"
|
||||
" switch (fog.mode)\n"
|
||||
" {\n"
|
||||
" case 2:\n"
|
||||
" fogZ = (-vtf.mvPos.z - fog.start) * fog.rangeScale;\n"
|
||||
" break;\n"
|
||||
" case 4:\n"
|
||||
" fogZ = 1.0 - exp2(-8.0 * (-vtf.mvPos.z - fog.start) * fog.rangeScale);\n"
|
||||
" break;\n"
|
||||
" case 5:\n"
|
||||
" temp = (-vtf.mvPos.z - fog.start) * fog.rangeScale;\n"
|
||||
" fogZ = 1.0 - exp2(-8.0 * temp * temp);\n"
|
||||
" break;\n"
|
||||
" case 6:\n"
|
||||
" fogZ = exp2(-8.0 * (fog.start + vtf.mvPos.z) * fog.rangeScale);\n"
|
||||
" break;\n"
|
||||
" case 7:\n"
|
||||
" temp = (fog.start + vtf.mvPos.z) * fog.rangeScale;\n"
|
||||
" fogZ = exp2(-8.0 * temp * temp);\n"
|
||||
" break;\n"
|
||||
" default:\n"
|
||||
" fogZ = 0.0;\n"
|
||||
" break;\n"
|
||||
" }\n"
|
||||
"#ifdef BLEND_DST_ONE\n"
|
||||
" return vec4(mix(colorIn, vec4(0.0), clamp(fogZ, 0.0, 1.0)).rgb, colorIn.a);\n"
|
||||
"#else\n"
|
||||
" return vec4(mix(colorIn, fog.color, clamp(fogZ, 0.0, 1.0)).rgb, colorIn.a);\n"
|
||||
"#endif\n"
|
||||
FOG_ALGORITHM_GLSL
|
||||
"}\n"
|
||||
"\n"sv;
|
||||
|
||||
@@ -197,6 +203,23 @@ static std::string_view MBShadowPostGLSL =
|
||||
"}\n"
|
||||
"\n"sv;
|
||||
|
||||
static std::string_view DisintegratePostGLSL =
|
||||
FOG_STRUCT_GLSL
|
||||
"UBINDING2 uniform DisintegrateUniform\n"
|
||||
"{\n"
|
||||
" vec4 addColor;\n"
|
||||
" Fog fog;\n"
|
||||
"};\n"
|
||||
"vec4 DisintegratePostFunc(vec4 colorIn)\n"
|
||||
"{\n"
|
||||
" vec4 texel0 = texture(extTex7, vtf.extTcgs[0]);\n"
|
||||
" vec4 texel1 = texture(extTex7, vtf.extTcgs[1]);\n"
|
||||
" colorIn = mix(vec4(0.0), texel1, texel0);\n"
|
||||
" colorIn.rgb += addColor.rgb;\n"
|
||||
FOG_ALGORITHM_GLSL
|
||||
"}\n"
|
||||
"\n"sv;
|
||||
|
||||
const hecl::Backend::Function ExtensionLightingFuncsGLSL[] =
|
||||
{
|
||||
{},
|
||||
@@ -218,7 +241,8 @@ const hecl::Backend::Function ExtensionLightingFuncsGLSL[] =
|
||||
{LightingGLSL, "LightingFunc"},
|
||||
{LightingGLSL, "LightingFunc"},
|
||||
{LightingGLSL, "LightingFunc"},
|
||||
{LightingGLSL, "LightingFunc"}
|
||||
{LightingGLSL, "LightingFunc"},
|
||||
{},
|
||||
};
|
||||
|
||||
const hecl::Backend::Function ExtensionPostFuncsGLSL[] =
|
||||
@@ -243,6 +267,7 @@ const hecl::Backend::Function ExtensionPostFuncsGLSL[] =
|
||||
{MainPostGLSL, "MainPostFunc"},
|
||||
{MainPostGLSL, "MainPostFunc"},
|
||||
{MainPostGLSL, "MainPostFunc"},
|
||||
{DisintegratePostGLSL, "DisintegratePostFunc"},
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user