mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-08 13:44:56 +00:00
Refactor for blender 2.8 and new shader model
This commit is contained in:
@@ -168,7 +168,7 @@ void Buckets::Init() {
|
||||
|
||||
CBooRenderer::CAreaListItem::CAreaListItem(const std::vector<CMetroidModelInstance>* geom,
|
||||
const CAreaRenderOctTree* octTree,
|
||||
std::vector<TCachedToken<CTexture>>&& textures,
|
||||
std::unordered_map<CAssetId, TCachedToken<CTexture>>&& textures,
|
||||
std::vector<CBooModel*>&& models, int areaIdx, const SShader* shaderSet)
|
||||
: x0_geometry(geom)
|
||||
, x4_octTree(octTree)
|
||||
@@ -593,6 +593,22 @@ void CBooRenderer::GenerateScanLinesVBO(boo::IGraphicsDataFactory::Context& ctx)
|
||||
m_scanLinesOddVBO = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts.data(), sizeof(zeus::CVector3f), verts.size());
|
||||
}
|
||||
|
||||
boo::ObjToken<boo::ITexture> CBooRenderer::GetColorTexture(const zeus::CColor& color) {
|
||||
auto search = m_colorTextures.find(color);
|
||||
if (search != m_colorTextures.end())
|
||||
return search->second;
|
||||
u8 pixel[4];
|
||||
color.toRGBA8(pixel[0], pixel[1], pixel[2], pixel[3]);
|
||||
boo::ObjToken<boo::ITexture> tex;
|
||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
||||
tex = ctx.newStaticTexture(1, 1, 1, boo::TextureFormat::RGBA8,
|
||||
boo::TextureClampMode::Repeat, pixel, 4).get();
|
||||
return true;
|
||||
} BooTrace);
|
||||
m_colorTextures.insert(std::make_pair(color, tex));
|
||||
return tex;
|
||||
}
|
||||
|
||||
void CBooRenderer::LoadThermoPalette() {
|
||||
m_thermoPaletteTex = xc_store.GetObj("TXTR_ThermoPalette");
|
||||
CTexture* thermoTexObj = m_thermoPaletteTex.GetObj();
|
||||
@@ -652,8 +668,7 @@ void CBooRenderer::AddWorldSurfaces(CBooModel& model) {
|
||||
zeus::CAABox aabb = surf->GetBounds();
|
||||
zeus::CVector3f pt = aabb.closestPointAlongVector(xb0_viewPlane.normal());
|
||||
Buckets::Insert(pt, aabb, EDrawableType::WorldSurface, surf, xb0_viewPlane,
|
||||
mat.heclIr.m_blendSrc == boo::BlendFactor::SrcAlpha &&
|
||||
mat.heclIr.m_blendDst == boo::BlendFactor::InvSrcAlpha);
|
||||
mat.blendMode == MaterialSet::Material::BlendMaterial::BlendMode::Alpha);
|
||||
surf = surf->m_next;
|
||||
}
|
||||
}
|
||||
@@ -668,7 +683,7 @@ void CBooRenderer::AddStaticGeometry(const std::vector<CMetroidModelInstance>* g
|
||||
const CAreaRenderOctTree* octTree, int areaIdx, const SShader* shaderSet) {
|
||||
auto search = FindStaticGeometry(geometry);
|
||||
if (search == x1c_areaListItems.end()) {
|
||||
std::vector<TCachedToken<CTexture>> textures;
|
||||
std::unordered_map<CAssetId, TCachedToken<CTexture>> textures;
|
||||
std::vector<CBooModel*> models;
|
||||
if (geometry->size()) {
|
||||
(*geometry)[0].m_instance->MakeTexturesFromMats(textures, xc_store);
|
||||
|
||||
@@ -58,7 +58,7 @@ class CBooRenderer final : public IRenderer {
|
||||
const std::vector<CMetroidModelInstance>* x0_geometry;
|
||||
const CAreaRenderOctTree* x4_octTree;
|
||||
/* originally auto_ptrs of vectors */
|
||||
std::vector<TCachedToken<CTexture>> x8_textures;
|
||||
std::unordered_map<CAssetId, TCachedToken<CTexture>> x8_textures;
|
||||
std::vector<CBooModel*> x10_models;
|
||||
int x18_areaIdx;
|
||||
/* Per-area octree-word major, light bits minor */
|
||||
@@ -66,8 +66,8 @@ class CBooRenderer final : public IRenderer {
|
||||
const SShader* m_shaderSet;
|
||||
|
||||
CAreaListItem(const std::vector<CMetroidModelInstance>* geom, const CAreaRenderOctTree* octTree,
|
||||
std::vector<TCachedToken<CTexture>>&& textures, std::vector<CBooModel*>&& models, int areaIdx,
|
||||
const SShader* shaderSet);
|
||||
std::unordered_map<CAssetId, TCachedToken<CTexture>>&& textures, std::vector<CBooModel*>&& models,
|
||||
int areaIdx, const SShader* shaderSet);
|
||||
~CAreaListItem();
|
||||
};
|
||||
|
||||
@@ -109,6 +109,7 @@ class CBooRenderer final : public IRenderer {
|
||||
boo::ObjToken<boo::ITexture> m_clearTexture;
|
||||
boo::ObjToken<boo::ITexture> m_blackTexture;
|
||||
boo::ObjToken<boo::ITexture> m_whiteTexture;
|
||||
std::unordered_map<zeus::CColor, boo::ObjToken<boo::ITexture>> m_colorTextures;
|
||||
|
||||
boo::ObjToken<boo::ITextureR> x14c_reflectionTex;
|
||||
// boo::ITextureS* x150_mirrorRamp = nullptr;
|
||||
@@ -278,6 +279,8 @@ public:
|
||||
const boo::ObjToken<boo::ITexture>& GetBlackTexture() { return m_blackTexture; }
|
||||
const boo::ObjToken<boo::ITexture>& GetWhiteTexture() { return m_whiteTexture; }
|
||||
|
||||
boo::ObjToken<boo::ITexture> GetColorTexture(const zeus::CColor& color);
|
||||
|
||||
static void BindMainDrawTarget() { CGraphics::g_BooMainCommandQueue->setRenderTarget(CGraphics::g_SpareTexture); }
|
||||
void BindReflectionDrawTarget() { CGraphics::g_BooMainCommandQueue->setRenderTarget(x14c_reflectionTex); }
|
||||
void BindBallShadowIdTarget() {
|
||||
|
||||
@@ -24,7 +24,6 @@ set(GRAPHICS_SOURCES
|
||||
Shaders/CColoredQuadFilter.hpp Shaders/CColoredQuadFilter.cpp
|
||||
Shaders/CColoredStripShader.hpp Shaders/CColoredStripShader.cpp
|
||||
Shaders/CModelShaders.hpp Shaders/CModelShaders.cpp
|
||||
Shaders/CModelShadersGLSL.cpp Shaders/CModelShadersHLSL.cpp Shaders/CModelShadersMetal.cpp
|
||||
Shaders/CThermalColdFilter.hpp Shaders/CThermalColdFilter.cpp
|
||||
Shaders/CThermalHotFilter.hpp Shaders/CThermalHotFilter.cpp
|
||||
Shaders/CSpaceWarpFilter.hpp Shaders/CSpaceWarpFilter.cpp
|
||||
|
||||
@@ -75,7 +75,6 @@ struct CBooSurface {
|
||||
};
|
||||
|
||||
using MaterialSet = DataSpec::DNAMP1::HMDLMaterialSet;
|
||||
using UVAnimation = DataSpec::DNAMP1::MaterialSet::Material::UVAnimation;
|
||||
|
||||
struct GeometryUniformLayout {
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_sharedBuffer[2];
|
||||
@@ -96,7 +95,7 @@ struct GeometryUniformLayout {
|
||||
};
|
||||
|
||||
struct SShader {
|
||||
std::vector<TCachedToken<CTexture>> x0_textures;
|
||||
std::unordered_map<CAssetId, TCachedToken<CTexture>> x0_textures;
|
||||
std::unordered_map<int, CModelShaders::ShaderPipelines> m_shaders;
|
||||
MaterialSet m_matSet;
|
||||
rstl::optional<GeometryUniformLayout> m_geomLayout;
|
||||
@@ -134,7 +133,7 @@ private:
|
||||
const GeometryUniformLayout* m_geomLayout;
|
||||
int m_matSetIdx = -1;
|
||||
const std::unordered_map<int, CModelShaders::ShaderPipelines>* m_pipelines;
|
||||
std::vector<TCachedToken<CTexture>> x1c_textures;
|
||||
std::unordered_map<CAssetId, TCachedToken<CTexture>> x1c_textures;
|
||||
zeus::CAABox x20_aabb;
|
||||
CBooSurface* x38_firstUnsortedSurface = nullptr;
|
||||
CBooSurface* x3c_firstSortedSurface = nullptr;
|
||||
@@ -144,7 +143,7 @@ private:
|
||||
u32 x44_areaInstanceIdx = -1;
|
||||
|
||||
struct UVAnimationBuffer {
|
||||
static void ProcessAnimation(u8*& bufOut, const UVAnimation& anim);
|
||||
static void ProcessAnimation(u8*& bufOut, const MaterialSet::Material::PASS& anim);
|
||||
static void PadOutBuffer(u8*& bufStart, u8*& bufOut);
|
||||
static void Update(u8*& bufOut, const MaterialSet* matSet, const CModelFlags& flags, const CBooModel* parent);
|
||||
};
|
||||
@@ -166,8 +165,6 @@ private:
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_staticVbo;
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_staticIbo;
|
||||
|
||||
boo::ObjToken<boo::ITexture> m_txtrOverrides[8];
|
||||
|
||||
boo::ObjToken<boo::ITexture> m_lastDrawnShadowMap;
|
||||
boo::ObjToken<boo::ITexture> m_lastDrawnOneTexture;
|
||||
|
||||
@@ -192,11 +189,12 @@ public:
|
||||
~CBooModel();
|
||||
CBooModel(TToken<CModel>& token, CModel* parent, std::vector<CBooSurface>* surfaces, SShader& shader,
|
||||
const boo::ObjToken<boo::IGraphicsBufferS>& vbo, const boo::ObjToken<boo::IGraphicsBufferS>& ibo,
|
||||
const zeus::CAABox& aabb, u8 renderMask, int numInsts, const boo::ObjToken<boo::ITexture> txtrOverrides[8]);
|
||||
const zeus::CAABox& aabb, u8 renderMask, int numInsts);
|
||||
|
||||
static void MakeTexturesFromMats(const MaterialSet& matSet, std::vector<TCachedToken<CTexture>>& toksOut,
|
||||
static void MakeTexturesFromMats(const MaterialSet& matSet,
|
||||
std::unordered_map<CAssetId, TCachedToken<CTexture>>& toksOut,
|
||||
IObjectStore& store);
|
||||
void MakeTexturesFromMats(std::vector<TCachedToken<CTexture>>& toksOut, IObjectStore& store);
|
||||
void MakeTexturesFromMats(std::unordered_map<CAssetId, TCachedToken<CTexture>>& toksOut, IObjectStore& store);
|
||||
|
||||
bool IsOpaque() const { return x3c_firstSortedSurface == nullptr; }
|
||||
void ActivateLights(const std::vector<CLight>& lights);
|
||||
@@ -284,9 +282,7 @@ public:
|
||||
const zeus::CAABox& GetAABB() const { return m_aabb; }
|
||||
CBooModel& GetInstance() { return *x28_modelInst; }
|
||||
const CBooModel& GetInstance() const { return *x28_modelInst; }
|
||||
std::unique_ptr<CBooModel> MakeNewInstance(int shaderIdx, int subInsts,
|
||||
const boo::ObjToken<boo::ITexture> txtrOverrides[8] = nullptr,
|
||||
bool lockParent = true);
|
||||
std::unique_ptr<CBooModel> MakeNewInstance(int shaderIdx, int subInsts, bool lockParent = true);
|
||||
void UpdateLastFrame() const { const_cast<CModel&>(*this).x38_lastFrame = CGraphics::GetFrameCounter(); }
|
||||
|
||||
size_t GetPoolVertexOffset(size_t idx) const;
|
||||
|
||||
@@ -141,8 +141,7 @@ CBooModel::~CBooModel() {
|
||||
|
||||
CBooModel::CBooModel(TToken<CModel>& token, CModel* parent, std::vector<CBooSurface>* surfaces, SShader& shader,
|
||||
const boo::ObjToken<boo::IGraphicsBufferS>& vbo, const boo::ObjToken<boo::IGraphicsBufferS>& ibo,
|
||||
const zeus::CAABox& aabb, u8 renderMask, int numInsts,
|
||||
const boo::ObjToken<boo::ITexture> txtrOverrides[8])
|
||||
const zeus::CAABox& aabb, u8 renderMask, int numInsts)
|
||||
: m_modelTok(token)
|
||||
, m_model(parent)
|
||||
, x0_surfaces(surfaces)
|
||||
@@ -157,10 +156,6 @@ CBooModel::CBooModel(TToken<CModel>& token, CModel* parent, std::vector<CBooSurf
|
||||
, x41_mask(renderMask)
|
||||
, m_staticVbo(vbo)
|
||||
, m_staticIbo(ibo) {
|
||||
if (txtrOverrides)
|
||||
for (int i = 0; i < 8; ++i)
|
||||
m_txtrOverrides[i] = txtrOverrides[i];
|
||||
|
||||
if (!g_FirstModel)
|
||||
g_FirstModel = this;
|
||||
else {
|
||||
@@ -291,10 +286,6 @@ CBooModel::ModelInstance* CBooModel::PushNewModelInstance(int sharedLayoutBuf) {
|
||||
/* Binding for each surface */
|
||||
newInst.m_shaderDataBindings.reserve(x0_surfaces->size());
|
||||
|
||||
boo::ObjToken<boo::ITexture> mbShadowTexs[8] = {
|
||||
g_Renderer->m_ballShadowId.get(), g_Renderer->x220_sphereRamp.get(), g_Renderer->m_ballFade.get(),
|
||||
g_Renderer->x220_sphereRamp.get(), g_Renderer->x220_sphereRamp.get(), g_Renderer->x220_sphereRamp.get(),
|
||||
g_Renderer->x220_sphereRamp.get(), g_Renderer->x220_sphereRamp.get()};
|
||||
size_t thisOffs[4];
|
||||
size_t thisSizes[4];
|
||||
|
||||
@@ -306,20 +297,23 @@ CBooModel::ModelInstance* CBooModel::PushNewModelInstance(int sharedLayoutBuf) {
|
||||
for (const CBooSurface& surf : *x0_surfaces) {
|
||||
const MaterialSet::Material& mat = x4_matSet->materials.at(surf.m_data.matIdx);
|
||||
|
||||
boo::ObjToken<boo::ITexture> texs[8] = {g_Renderer->x220_sphereRamp.get(), g_Renderer->x220_sphereRamp.get(),
|
||||
g_Renderer->x220_sphereRamp.get(), g_Renderer->x220_sphereRamp.get(),
|
||||
g_Renderer->x220_sphereRamp.get(), g_Renderer->x220_sphereRamp.get(),
|
||||
g_Renderer->x220_sphereRamp.get(), g_Renderer->x220_sphereRamp.get()};
|
||||
u32 texCount = 0;
|
||||
for (atUint32 idx : mat.textureIdxs) {
|
||||
if (boo::ObjToken<boo::ITexture> overtex = m_txtrOverrides[texCount]) {
|
||||
texs[texCount++] = overtex;
|
||||
} else if (g_DummyTextures) {
|
||||
texs[texCount++] = g_Renderer->x220_sphereRamp.get();
|
||||
} else {
|
||||
TCachedToken<CTexture>& tex = x1c_textures[idx];
|
||||
if (boo::ObjToken<boo::ITexture> btex = tex.GetObj()->GetBooTexture())
|
||||
texs[texCount++] = btex;
|
||||
boo::ObjToken<boo::ITexture> texs[12] = {g_Renderer->m_clearTexture.get(), g_Renderer->m_clearTexture.get(),
|
||||
g_Renderer->m_clearTexture.get(), g_Renderer->m_clearTexture.get(),
|
||||
g_Renderer->m_clearTexture.get(), g_Renderer->m_clearTexture.get(),
|
||||
g_Renderer->m_clearTexture.get(), g_Renderer->m_clearTexture.get(),
|
||||
g_Renderer->x220_sphereRamp.get(), g_Renderer->x220_sphereRamp.get(),
|
||||
g_Renderer->x220_sphereRamp.get(), g_Renderer->x220_sphereRamp.get()};
|
||||
if (!g_DummyTextures) {
|
||||
for (const auto& ch : mat.chunks) {
|
||||
if (auto pass = ch.get_if<MaterialSet::Material::PASS>()) {
|
||||
auto search = x1c_textures.find(pass->texId.toUint32());
|
||||
boo::ObjToken<boo::ITexture> btex;
|
||||
if (search != x1c_textures.cend() && (btex = search->second.GetObj()->GetBooTexture()))
|
||||
texs[MaterialSet::Material::TexMapIdx(pass->type)] = btex;
|
||||
} else if (auto pass = ch.get_if<MaterialSet::Material::CLR>()) {
|
||||
boo::ObjToken<boo::ITexture> btex = g_Renderer->GetColorTexture(zeus::CColor(pass->color));
|
||||
texs[MaterialSet::Material::TexMapIdx(pass->type)] = btex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,9 +334,7 @@ CBooModel::ModelInstance* CBooModel::PushNewModelInstance(int sharedLayoutBuf) {
|
||||
bool useReflection = mat.flags.samusReflection() || mat.flags.samusReflectionSurfaceEye();
|
||||
if (useReflection) {
|
||||
if (g_Renderer->x14c_reflectionTex)
|
||||
texs[texCount] = g_Renderer->x14c_reflectionTex.get();
|
||||
else
|
||||
texs[texCount] = g_Renderer->x220_sphereRamp.get();
|
||||
texs[11] = g_Renderer->x14c_reflectionTex.get();
|
||||
thisOffs[3] = curReflect;
|
||||
curReflect += 256;
|
||||
} else {
|
||||
@@ -358,31 +350,25 @@ CBooModel::ModelInstance* CBooModel::PushNewModelInstance(int sharedLayoutBuf) {
|
||||
|
||||
int idx = 0;
|
||||
for (const auto& pipeline : *pipelines) {
|
||||
boo::ObjToken<boo::ITexture>* ltexs;
|
||||
if (idx == EExtendedShader::Thermal) {
|
||||
texs[7] = g_Renderer->x220_sphereRamp.get();
|
||||
ltexs = texs;
|
||||
texs[8] = g_Renderer->x220_sphereRamp.get();
|
||||
} else if (idx == EExtendedShader::MorphBallShadow) {
|
||||
ltexs = mbShadowTexs;
|
||||
texs[8] = g_Renderer->m_ballShadowId.get();
|
||||
texs[9] = g_Renderer->x220_sphereRamp.get();
|
||||
texs[10] = g_Renderer->m_ballFade.get();
|
||||
} else if (idx == EExtendedShader::WorldShadow) {
|
||||
if (g_shadowMap)
|
||||
texs[7] = g_shadowMap;
|
||||
texs[8] = g_shadowMap;
|
||||
else
|
||||
texs[7] = g_Renderer->x220_sphereRamp.get();
|
||||
ltexs = texs;
|
||||
texs[8] = g_Renderer->x220_sphereRamp.get();
|
||||
} else if (idx == EExtendedShader::Disintegrate) {
|
||||
if (g_disintegrateTexture)
|
||||
texs[7] = g_disintegrateTexture;
|
||||
texs[8] = g_disintegrateTexture;
|
||||
else
|
||||
texs[7] = g_Renderer->x220_sphereRamp.get();
|
||||
ltexs = texs;
|
||||
} else if (useReflection) {
|
||||
ltexs = texs;
|
||||
} else {
|
||||
ltexs = texs;
|
||||
texs[8] = g_Renderer->x220_sphereRamp.get();
|
||||
}
|
||||
extendeds.push_back(ctx.newShaderDataBinding(pipeline, newInst.GetBooVBO(*this, ctx), nullptr,
|
||||
m_staticIbo.get(), 4, bufs, stages, thisOffs, thisSizes, 8, ltexs,
|
||||
m_staticIbo.get(), 4, bufs, stages, thisOffs, thisSizes, 12, texs,
|
||||
nullptr, nullptr));
|
||||
++idx;
|
||||
}
|
||||
@@ -393,14 +379,20 @@ CBooModel::ModelInstance* CBooModel::PushNewModelInstance(int sharedLayoutBuf) {
|
||||
return &newInst;
|
||||
}
|
||||
|
||||
void CBooModel::MakeTexturesFromMats(const MaterialSet& matSet, std::vector<TCachedToken<CTexture>>& toksOut,
|
||||
void CBooModel::MakeTexturesFromMats(const MaterialSet& matSet,
|
||||
std::unordered_map<CAssetId, TCachedToken<CTexture>>& toksOut,
|
||||
IObjectStore& store) {
|
||||
toksOut.reserve(matSet.head.textureIDs.size());
|
||||
for (const DataSpec::UniqueID32& id : matSet.head.textureIDs)
|
||||
toksOut.emplace_back(store.GetObj({SBIG('TXTR'), id.toUint32()}));
|
||||
for (const auto& mat : matSet.materials) {
|
||||
for (const auto& chunk : mat.chunks) {
|
||||
if (auto pass = chunk.get_if<MaterialSet::Material::PASS>()) {
|
||||
toksOut.emplace(std::make_pair(pass->texId.toUint32(), store.GetObj({SBIG('TXTR'), pass->texId.toUint32()})));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CBooModel::MakeTexturesFromMats(std::vector<TCachedToken<CTexture>>& toksOut, IObjectStore& store) {
|
||||
void CBooModel::MakeTexturesFromMats(std::unordered_map<CAssetId, TCachedToken<CTexture>>& toksOut,
|
||||
IObjectStore& store) {
|
||||
MakeTexturesFromMats(*x4_matSet, toksOut, store);
|
||||
}
|
||||
|
||||
@@ -445,9 +437,9 @@ void CBooModel::RemapMaterialData(SShader& shader,
|
||||
bool CBooModel::TryLockTextures() const {
|
||||
if (!x40_24_texturesLoaded) {
|
||||
bool allLoad = true;
|
||||
for (TCachedToken<CTexture>& tex : const_cast<std::vector<TCachedToken<CTexture>>&>(x1c_textures)) {
|
||||
tex.Lock();
|
||||
if (!tex.IsLoaded())
|
||||
for (auto& tex : const_cast<std::unordered_map<CAssetId, TCachedToken<CTexture>>&>(x1c_textures)) {
|
||||
tex.second.Lock();
|
||||
if (!tex.second.IsLoaded())
|
||||
allLoad = false;
|
||||
}
|
||||
|
||||
@@ -459,15 +451,15 @@ bool CBooModel::TryLockTextures() const {
|
||||
|
||||
void CBooModel::UnlockTextures() const {
|
||||
const_cast<CBooModel*>(this)->m_instances.clear();
|
||||
for (TCachedToken<CTexture>& tex : const_cast<std::vector<TCachedToken<CTexture>>&>(x1c_textures))
|
||||
tex.Unlock();
|
||||
for (auto& tex : const_cast<std::unordered_map<CAssetId, TCachedToken<CTexture>>&>(x1c_textures))
|
||||
tex.second.Unlock();
|
||||
const_cast<CBooModel*>(this)->x40_24_texturesLoaded = false;
|
||||
}
|
||||
|
||||
void CBooModel::SyncLoadTextures() const {
|
||||
if (!x40_24_texturesLoaded) {
|
||||
for (TCachedToken<CTexture>& tex : const_cast<std::vector<TCachedToken<CTexture>>&>(x1c_textures))
|
||||
tex.GetObj();
|
||||
for (auto& tex : const_cast<std::unordered_map<CAssetId, TCachedToken<CTexture>>&>(x1c_textures))
|
||||
tex.second.GetObj();
|
||||
const_cast<CBooModel*>(this)->x40_24_texturesLoaded = true;
|
||||
}
|
||||
}
|
||||
@@ -534,7 +526,7 @@ static EExtendedShader ResolveExtendedShader(const MaterialSet::Material& data,
|
||||
return EExtendedShader::LightingAlphaWrite;
|
||||
else if (g_Renderer->IsThermalVisorActive())
|
||||
return EExtendedShader::ThermalCold;
|
||||
if (data.heclIr.m_blendSrc == boo::BlendFactor::One && data.heclIr.m_blendDst == boo::BlendFactor::Zero) {
|
||||
if (data.blendMode == MaterialSet::Material::BlendMaterial::BlendMode::Opaque) {
|
||||
/* Override shader if originally opaque (typical for FRME models) */
|
||||
if (flags.x0_blendMode > 6) {
|
||||
if (flags.m_depthGreater)
|
||||
@@ -555,19 +547,19 @@ static EExtendedShader ResolveExtendedShader(const MaterialSet::Material& data,
|
||||
}
|
||||
} else if (flags.m_noCull && noZWrite) {
|
||||
/* Substitute no-cull,no-zwrite pipeline if available */
|
||||
if (data.heclIr.m_blendDst == boo::BlendFactor::One)
|
||||
if (data.blendMode == MaterialSet::Material::BlendMaterial::BlendMode::Additive)
|
||||
extended = EExtendedShader::ForcedAdditiveNoCullNoZWrite;
|
||||
else
|
||||
extended = EExtendedShader::ForcedAlphaNoCullNoZWrite;
|
||||
} else if (flags.m_noCull) {
|
||||
/* Substitute no-cull pipeline if available */
|
||||
if (data.heclIr.m_blendDst == boo::BlendFactor::One)
|
||||
if (data.blendMode == MaterialSet::Material::BlendMaterial::BlendMode::Additive)
|
||||
extended = EExtendedShader::ForcedAdditiveNoCull;
|
||||
else
|
||||
extended = EExtendedShader::ForcedAlphaNoCull;
|
||||
} else if (noZWrite) {
|
||||
/* Substitute no-zwrite pipeline if available */
|
||||
if (data.heclIr.m_blendDst == boo::BlendFactor::One)
|
||||
if (data.blendMode == MaterialSet::Material::BlendMaterial::BlendMode::Additive)
|
||||
extended = EExtendedShader::ForcedAdditiveNoZWrite;
|
||||
else
|
||||
extended = EExtendedShader::ForcedAlphaNoZWrite;
|
||||
@@ -619,21 +611,22 @@ void CBooModel::WarmupDrawSurface(const CBooSurface& surf) const {
|
||||
return;
|
||||
const ModelInstance& inst = m_instances[m_uniUpdateCount - 1];
|
||||
|
||||
// Only warmup normal lighting and thermal visor
|
||||
for (int i = 1; i <= 2; ++i) {
|
||||
auto& binding = inst.m_shaderDataBindings[surf.selfIdx][i];
|
||||
for (auto& binding : inst.m_shaderDataBindings[surf.selfIdx]) {
|
||||
CGraphics::SetShaderDataBinding(binding);
|
||||
CGraphics::DrawArrayIndexed(surf.m_data.idxStart, std::min(u32(3), surf.m_data.idxCount));
|
||||
}
|
||||
}
|
||||
|
||||
void CBooModel::UVAnimationBuffer::ProcessAnimation(u8*& bufOut, const UVAnimation& anim) {
|
||||
void CBooModel::UVAnimationBuffer::ProcessAnimation(u8*& bufOut, const MaterialSet::Material::PASS& anim) {
|
||||
using UVAnimType = MaterialSet::Material::BlendMaterial::UVAnimType;
|
||||
if (anim.uvAnimType == UVAnimType::Invalid)
|
||||
return;
|
||||
zeus::CMatrix4f& texMtxOut = reinterpret_cast<zeus::CMatrix4f&>(*bufOut);
|
||||
zeus::CMatrix4f& postMtxOut = reinterpret_cast<zeus::CMatrix4f&>(*(bufOut + sizeof(zeus::CMatrix4f)));
|
||||
texMtxOut = zeus::CMatrix4f();
|
||||
postMtxOut = zeus::CMatrix4f();
|
||||
switch (anim.mode) {
|
||||
case UVAnimation::Mode::MvInvNoTranslation: {
|
||||
switch (anim.uvAnimType) {
|
||||
case UVAnimType::MvInvNoTranslation: {
|
||||
texMtxOut = CGraphics::g_GXModelViewInvXpose.toMatrix4f();
|
||||
texMtxOut[3].w() = 1.f;
|
||||
postMtxOut[0].x() = 0.5f;
|
||||
@@ -642,7 +635,7 @@ void CBooModel::UVAnimationBuffer::ProcessAnimation(u8*& bufOut, const UVAnimati
|
||||
postMtxOut[3].y() = 0.5f;
|
||||
break;
|
||||
}
|
||||
case UVAnimation::Mode::MvInv: {
|
||||
case UVAnimType::MvInv: {
|
||||
texMtxOut = CGraphics::g_GXModelViewInvXpose.toMatrix4f();
|
||||
texMtxOut[3] = CGraphics::g_ViewMatrix.inverse() * CGraphics::g_GXModelMatrix.origin;
|
||||
texMtxOut[3].w() = 1.f;
|
||||
@@ -652,13 +645,13 @@ void CBooModel::UVAnimationBuffer::ProcessAnimation(u8*& bufOut, const UVAnimati
|
||||
postMtxOut[3].y() = 0.5f;
|
||||
break;
|
||||
}
|
||||
case UVAnimation::Mode::Scroll: {
|
||||
texMtxOut[3].x() = CGraphics::GetSecondsMod900() * anim.vals[2] + anim.vals[0];
|
||||
texMtxOut[3].y() = CGraphics::GetSecondsMod900() * anim.vals[3] + anim.vals[1];
|
||||
case UVAnimType::Scroll: {
|
||||
texMtxOut[3].x() = CGraphics::GetSecondsMod900() * anim.uvAnimParms[2] + anim.uvAnimParms[0];
|
||||
texMtxOut[3].y() = CGraphics::GetSecondsMod900() * anim.uvAnimParms[3] + anim.uvAnimParms[1];
|
||||
break;
|
||||
}
|
||||
case UVAnimation::Mode::Rotation: {
|
||||
float angle = CGraphics::GetSecondsMod900() * anim.vals[1] + anim.vals[0];
|
||||
case UVAnimType::Rotation: {
|
||||
float angle = CGraphics::GetSecondsMod900() * anim.uvAnimParms[1] + anim.uvAnimParms[0];
|
||||
float acos = std::cos(angle);
|
||||
float asin = std::sin(angle);
|
||||
texMtxOut[0].x() = acos;
|
||||
@@ -669,17 +662,17 @@ void CBooModel::UVAnimationBuffer::ProcessAnimation(u8*& bufOut, const UVAnimati
|
||||
texMtxOut[3].y() = (1.0f - (asin + acos)) * 0.5f;
|
||||
break;
|
||||
}
|
||||
case UVAnimation::Mode::HStrip: {
|
||||
float value = anim.vals[0] * anim.vals[2] * (anim.vals[3] + CGraphics::GetSecondsMod900());
|
||||
texMtxOut[3].x() = std::trunc(anim.vals[1] * fmod(value, 1.0f)) * anim.vals[2];
|
||||
case UVAnimType::HStrip: {
|
||||
float value = anim.uvAnimParms[0] * anim.uvAnimParms[2] * (anim.uvAnimParms[3] + CGraphics::GetSecondsMod900());
|
||||
texMtxOut[3].x() = std::trunc(anim.uvAnimParms[1] * fmod(value, 1.0f)) * anim.uvAnimParms[2];
|
||||
break;
|
||||
}
|
||||
case UVAnimation::Mode::VStrip: {
|
||||
float value = anim.vals[0] * anim.vals[2] * (anim.vals[3] + CGraphics::GetSecondsMod900());
|
||||
texMtxOut[3].y() = std::trunc(anim.vals[1] * fmod(value, 1.0f)) * anim.vals[2];
|
||||
case UVAnimType::VStrip: {
|
||||
float value = anim.uvAnimParms[0] * anim.uvAnimParms[2] * (anim.uvAnimParms[3] + CGraphics::GetSecondsMod900());
|
||||
texMtxOut[3].y() = std::trunc(anim.uvAnimParms[1] * fmod(value, 1.0f)) * anim.uvAnimParms[2];
|
||||
break;
|
||||
}
|
||||
case UVAnimation::Mode::Model: {
|
||||
case UVAnimType::Model: {
|
||||
texMtxOut = CGraphics::g_GXModelMatrix.toMatrix4f();
|
||||
texMtxOut[3] = zeus::CVector4f(0.f, 0.f, 0.f, 1.f);
|
||||
postMtxOut[0].x() = 0.5f;
|
||||
@@ -689,16 +682,16 @@ void CBooModel::UVAnimationBuffer::ProcessAnimation(u8*& bufOut, const UVAnimati
|
||||
postMtxOut[3].y() = CGraphics::g_GXModelMatrix.origin.y() * 0.05f;
|
||||
break;
|
||||
}
|
||||
case UVAnimation::Mode::CylinderEnvironment: {
|
||||
case UVAnimType::CylinderEnvironment: {
|
||||
texMtxOut = CGraphics::g_GXModelViewInvXpose.toMatrix4f();
|
||||
|
||||
const zeus::CVector3f& viewOrigin = CGraphics::g_ViewMatrix.origin;
|
||||
float xy = (viewOrigin.x() + viewOrigin.y()) * 0.025f * anim.vals[1];
|
||||
float xy = (viewOrigin.x() + viewOrigin.y()) * 0.025f * anim.uvAnimParms[1];
|
||||
xy = (xy - std::trunc(xy));
|
||||
float z = (viewOrigin.z()) * 0.05f * anim.vals[1];
|
||||
float z = (viewOrigin.z()) * 0.05f * anim.uvAnimParms[1];
|
||||
z = (z - std::trunc(z));
|
||||
|
||||
float halfA = anim.vals[0] * 0.5f;
|
||||
float halfA = anim.uvAnimParms[0] * 0.5f;
|
||||
|
||||
postMtxOut =
|
||||
zeus::CTransform(zeus::CMatrix3f(halfA, 0.0, 0.0, 0.0, 0.0, halfA, 0.0, 0.0, 0.0), zeus::CVector3f(xy, z, 1.0))
|
||||
@@ -808,8 +801,11 @@ void CBooModel::UVAnimationBuffer::Update(u8*& bufOut, const MaterialSet* matSet
|
||||
mtxs[7][1] = (*specialMtxOut)[1];
|
||||
}
|
||||
u8* bufOrig = bufOut;
|
||||
for (const UVAnimation& anim : mat.uvAnims)
|
||||
ProcessAnimation(bufOut, anim);
|
||||
for (const auto& chunk : mat.chunks) {
|
||||
if (auto pass = chunk.get_if<MaterialSet::Material::PASS>()) {
|
||||
ProcessAnimation(bufOut, *pass);
|
||||
}
|
||||
}
|
||||
bufOut = bufOrig + sizeof(zeus::CMatrix4f) * 2 * 8;
|
||||
PadOutBuffer(start, bufOut);
|
||||
}
|
||||
@@ -898,7 +894,7 @@ void GeometryUniformLayout::Update(const CModelFlags& flags, const CSkinRules* c
|
||||
boo::ObjToken<boo::IGraphicsBufferD> CBooModel::UpdateUniformData(const CModelFlags& flags, const CSkinRules* cskr,
|
||||
const CPoseAsTransforms* pose,
|
||||
int sharedLayoutBuf) const {
|
||||
if (!TryLockTextures())
|
||||
if (!g_DummyTextures && !TryLockTextures())
|
||||
return {};
|
||||
|
||||
/* Invalidate instances if new shadow being drawn */
|
||||
@@ -1046,13 +1042,11 @@ static const u8* MemoryFromPartData(const u8*& dataCur, const u32*& secSizeCur)
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::unique_ptr<CBooModel> CModel::MakeNewInstance(int shaderIdx, int subInsts,
|
||||
const boo::ObjToken<boo::ITexture> txtrOverrides[8],
|
||||
bool lockParent) {
|
||||
std::unique_ptr<CBooModel> CModel::MakeNewInstance(int shaderIdx, int subInsts, bool lockParent) {
|
||||
if (shaderIdx >= x18_matSets.size())
|
||||
shaderIdx = 0;
|
||||
auto ret = std::make_unique<CBooModel>(m_selfToken, this, &x8_surfaces, x18_matSets[shaderIdx], m_staticVbo, m_ibo,
|
||||
m_aabb, (m_flags & 0x2) != 0, subInsts, txtrOverrides);
|
||||
m_aabb, (m_flags & 0x2) != 0, subInsts);
|
||||
if (lockParent)
|
||||
ret->LockParent();
|
||||
return ret;
|
||||
@@ -1066,9 +1060,9 @@ CModelShaders::ShaderPipelines SShader::BuildShader(const hecl::HMDLMeta& meta,
|
||||
reflectionType = hecl::Backend::ReflectionType::Simple;
|
||||
else
|
||||
reflectionType = hecl::Backend::ReflectionType::None;
|
||||
hecl::Backend::ShaderTag tag(mat.heclIr, meta.colorCount, meta.uvCount, meta.weightCount, meta.weightCount * 4,
|
||||
hecl::Backend::ShaderTag tag(mat.hash, meta.colorCount, meta.uvCount, meta.weightCount, meta.weightCount * 4,
|
||||
boo::Primitive(meta.topology), reflectionType, true, true, true, mat.flags.alphaTest());
|
||||
return CModelShaders::BuildExtendedShader(tag, mat.heclIr);
|
||||
return CModelShaders::BuildExtendedShader(tag, mat);
|
||||
}
|
||||
|
||||
void SShader::BuildShaders(const hecl::HMDLMeta& meta,
|
||||
@@ -1156,12 +1150,12 @@ CModel::CModel(std::unique_ptr<u8[]>&& in, u32 /* dataLen */, IObjectStore* stor
|
||||
const float* aabbPtr = reinterpret_cast<const float*>(data.get() + 0xc);
|
||||
m_aabb = zeus::CAABox(hecl::SBig(aabbPtr[0]), hecl::SBig(aabbPtr[1]), hecl::SBig(aabbPtr[2]), hecl::SBig(aabbPtr[3]),
|
||||
hecl::SBig(aabbPtr[4]), hecl::SBig(aabbPtr[5]));
|
||||
x28_modelInst = MakeNewInstance(0, 1, nullptr, false);
|
||||
x28_modelInst = MakeNewInstance(0, 1, false);
|
||||
}
|
||||
|
||||
void SShader::UnlockTextures() {
|
||||
for (TCachedToken<CTexture>& tex : x0_textures)
|
||||
tex.Unlock();
|
||||
for (auto& tex : x0_textures)
|
||||
tex.second.Unlock();
|
||||
}
|
||||
|
||||
void CBooModel::VerifyCurrentShader(int shaderIdx) {
|
||||
|
||||
@@ -54,142 +54,138 @@ void CModelShaders::LightingUniform::ActivateLights(const std::vector<CLight>& l
|
||||
}
|
||||
}
|
||||
|
||||
static const hecl::Backend::TextureInfo ThermalTextures[] = {{hecl::Backend::TexGenSrc::Normal, 7, 0, 7, true}};
|
||||
using TexCoordSource = hecl::Backend::TexCoordSource;
|
||||
|
||||
static const hecl::Backend::TextureInfo ThermalTextures[] = {{TexCoordSource::Normal, 7, true}};
|
||||
|
||||
static const hecl::Backend::TextureInfo BallFadeTextures[] = {
|
||||
{hecl::Backend::TexGenSrc::Position, 0, 0, 0, false}, // ID tex
|
||||
{hecl::Backend::TexGenSrc::Position, 1, 0, 0, false}, // Sphere ramp
|
||||
{hecl::Backend::TexGenSrc::Position, 2, 0, 1, false} // TXTR_BallFade
|
||||
{TexCoordSource::Position, 0, false}, // ID tex
|
||||
{TexCoordSource::Position, 0, false}, // Sphere ramp
|
||||
{TexCoordSource::Position, 1, false} // TXTR_BallFade
|
||||
};
|
||||
|
||||
static const hecl::Backend::TextureInfo WorldShadowTextures[] = {
|
||||
{hecl::Backend::TexGenSrc::Position, 7, 0, 7, false} // Shadow tex
|
||||
{TexCoordSource::Position, 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
|
||||
{TexCoordSource::Position, 0, false}, // Ashy tex
|
||||
{TexCoordSource::Position, 1, false} // Ashy tex
|
||||
};
|
||||
|
||||
static const char* BlockNames[] = {"LightingUniform"};
|
||||
static const char* ThermalBlockNames[] = {"ThermalUniform"};
|
||||
static const char* SolidBlockNames[] = {"SolidUniform"};
|
||||
static const char* MBShadowBlockNames[] = {"MBShadowUniform"};
|
||||
static const char* DisintegrateBlockNames[] = {"DisintegrateUniform"};
|
||||
|
||||
static hecl::Backend::ExtensionSlot g_ExtensionSlots[] = {
|
||||
/* Default solid shading */
|
||||
{},
|
||||
/* Normal lit shading */
|
||||
{1, BlockNames, 0, nullptr, hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original,
|
||||
{0, nullptr, hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original,
|
||||
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface, false, false, true},
|
||||
/* Thermal Visor shading */
|
||||
{1, ThermalBlockNames, 1, ThermalTextures, hecl::Backend::BlendFactor::One, hecl::Backend::BlendFactor::One,
|
||||
{1, ThermalTextures, hecl::Backend::BlendFactor::One, hecl::Backend::BlendFactor::One,
|
||||
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface, false, false, false, true},
|
||||
/* Forced alpha shading */
|
||||
{1, BlockNames, 0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::InvSrcAlpha,
|
||||
{0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::InvSrcAlpha,
|
||||
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface, false, false, true},
|
||||
/* Forced additive shading */
|
||||
{1, BlockNames, 0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::One,
|
||||
{0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::One,
|
||||
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface, false, false, true},
|
||||
/* Solid color */
|
||||
{1, SolidBlockNames, 0, nullptr, hecl::Backend::BlendFactor::One, hecl::Backend::BlendFactor::Zero,
|
||||
{0, nullptr, hecl::Backend::BlendFactor::One, hecl::Backend::BlendFactor::Zero,
|
||||
hecl::Backend::ZTest::LEqual, hecl::Backend::CullMode::Backface, false, false, false},
|
||||
/* Solid color additive */
|
||||
{1, SolidBlockNames, 0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::One,
|
||||
{0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::One,
|
||||
hecl::Backend::ZTest::LEqual, hecl::Backend::CullMode::Backface, true, false, true},
|
||||
/* Alpha-only Solid color frontface cull, LEqual */
|
||||
{1, SolidBlockNames, 0, nullptr, hecl::Backend::BlendFactor::Zero, hecl::Backend::BlendFactor::One,
|
||||
{0, nullptr, hecl::Backend::BlendFactor::Zero, hecl::Backend::BlendFactor::One,
|
||||
hecl::Backend::ZTest::LEqual, hecl::Backend::CullMode::Frontface, false, true, false},
|
||||
/* Alpha-only Solid color frontface cull, Always, No Z-write */
|
||||
{1, SolidBlockNames, 0, nullptr, hecl::Backend::BlendFactor::Zero, hecl::Backend::BlendFactor::One,
|
||||
{0, nullptr, hecl::Backend::BlendFactor::Zero, hecl::Backend::BlendFactor::One,
|
||||
hecl::Backend::ZTest::None, hecl::Backend::CullMode::Frontface, true, true, false},
|
||||
/* Alpha-only Solid color backface cull, LEqual */
|
||||
{1, SolidBlockNames, 0, nullptr, hecl::Backend::BlendFactor::Zero, hecl::Backend::BlendFactor::One,
|
||||
{0, nullptr, hecl::Backend::BlendFactor::Zero, hecl::Backend::BlendFactor::One,
|
||||
hecl::Backend::ZTest::LEqual, hecl::Backend::CullMode::Backface, false, true, false},
|
||||
/* Alpha-only Solid color backface cull, Greater, No Z-write */
|
||||
{1, SolidBlockNames, 0, nullptr, hecl::Backend::BlendFactor::Zero, hecl::Backend::BlendFactor::One,
|
||||
{0, nullptr, hecl::Backend::BlendFactor::Zero, hecl::Backend::BlendFactor::One,
|
||||
hecl::Backend::ZTest::Greater, hecl::Backend::CullMode::Backface, true, true, false},
|
||||
/* MorphBall shadow shading */
|
||||
{1, MBShadowBlockNames, 3, BallFadeTextures, hecl::Backend::BlendFactor::SrcAlpha,
|
||||
{3, BallFadeTextures, hecl::Backend::BlendFactor::SrcAlpha,
|
||||
hecl::Backend::BlendFactor::InvSrcAlpha, hecl::Backend::ZTest::Equal, hecl::Backend::CullMode::Backface, false,
|
||||
false, true, false, true},
|
||||
/* World shadow shading (modified lighting) */
|
||||
{1, BlockNames, 1, WorldShadowTextures, hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original,
|
||||
{1, WorldShadowTextures, hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original,
|
||||
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface, false, false, true},
|
||||
/* Forced alpha shading without culling */
|
||||
{1, BlockNames, 0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::InvSrcAlpha,
|
||||
{0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::InvSrcAlpha,
|
||||
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::None, false, false, true},
|
||||
/* Forced additive shading without culling */
|
||||
{1, BlockNames, 0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::One,
|
||||
{0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::One,
|
||||
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::None, false, false, true},
|
||||
/* Forced alpha shading without Z-write */
|
||||
{1, BlockNames, 0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::InvSrcAlpha,
|
||||
{0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::InvSrcAlpha,
|
||||
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Original, true, false, true},
|
||||
/* Forced additive shading without Z-write */
|
||||
{1, BlockNames, 0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::One,
|
||||
{0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::One,
|
||||
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Original, true, false, true},
|
||||
/* Forced alpha shading without culling or Z-write */
|
||||
{1, BlockNames, 0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::InvSrcAlpha,
|
||||
{0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::InvSrcAlpha,
|
||||
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::None, true, false, true},
|
||||
/* Forced additive shading without culling or Z-write */
|
||||
{1, BlockNames, 0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::One,
|
||||
{0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::One,
|
||||
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::None, true, false, true},
|
||||
/* Depth GEqual no Z-write */
|
||||
{1, BlockNames, 0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::InvSrcAlpha,
|
||||
{0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::InvSrcAlpha,
|
||||
hecl::Backend::ZTest::GEqual, hecl::Backend::CullMode::Backface, true, false, true},
|
||||
/* Disintegration */
|
||||
{1, DisintegrateBlockNames, 2, DisintegrateTextures, hecl::Backend::BlendFactor::SrcAlpha,
|
||||
{2, DisintegrateTextures, hecl::Backend::BlendFactor::SrcAlpha,
|
||||
hecl::Backend::BlendFactor::InvSrcAlpha, hecl::Backend::ZTest::LEqual, hecl::Backend::CullMode::Original, false,
|
||||
false, true, false, false, true},
|
||||
/* Forced additive shading without culling or Z-write and greater depth test */
|
||||
{1, BlockNames, 0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::One,
|
||||
{0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::One,
|
||||
hecl::Backend::ZTest::Greater, hecl::Backend::CullMode::None, true, false, true},
|
||||
/* Thermal cold shading */
|
||||
{0, nullptr, 0, nullptr, hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original,
|
||||
{0, nullptr, hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original,
|
||||
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Original,
|
||||
false, false, true, false, false, false, true},
|
||||
/* Normal lit shading with alpha */
|
||||
{1, BlockNames, 0, nullptr, hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original,
|
||||
{0, nullptr, hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original,
|
||||
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface}};
|
||||
|
||||
extern const hecl::Backend::Function ExtensionLightingFuncsGLSL[];
|
||||
extern const hecl::Backend::Function ExtensionPostFuncsGLSL[];
|
||||
extern const hecl::Backend::Function ExtensionLightingFuncsHLSL[];
|
||||
extern const hecl::Backend::Function ExtensionPostFuncsHLSL[];
|
||||
extern const hecl::Backend::Function ExtensionLightingFuncsMetal[];
|
||||
extern const hecl::Backend::Function ExtensionPostFuncsMetal[];
|
||||
const char* ShaderMacros[] = {
|
||||
"URDE_LIGHTING",
|
||||
"URDE_LIGHTING",
|
||||
"URDE_THERMAL_HOT",
|
||||
"URDE_LIGHTING",
|
||||
"URDE_LIGHTING",
|
||||
"URDE_SOLID",
|
||||
"URDE_SOLID",
|
||||
"URDE_SOLID",
|
||||
"URDE_SOLID",
|
||||
"URDE_SOLID",
|
||||
"URDE_SOLID",
|
||||
"URDE_MB_SHADOW",
|
||||
"URDE_LIGHTING_SHADOW",
|
||||
"URDE_LIGHTING",
|
||||
"URDE_LIGHTING",
|
||||
"URDE_LIGHTING",
|
||||
"URDE_LIGHTING",
|
||||
"URDE_LIGHTING",
|
||||
"URDE_LIGHTING",
|
||||
"URDE_LIGHTING",
|
||||
"URDE_DISINTEGRATE",
|
||||
"URDE_LIGHTING",
|
||||
"URDE_THERMAL_COLD",
|
||||
"URDE_LIGHTING",
|
||||
};
|
||||
|
||||
void CModelShaders::Initialize() {
|
||||
const hecl::Backend::Function* lightingFuncs;
|
||||
const hecl::Backend::Function* postFuncs;
|
||||
switch (CGraphics::g_BooPlatform) {
|
||||
case boo::IGraphicsDataFactory::Platform::OpenGL:
|
||||
case boo::IGraphicsDataFactory::Platform::Vulkan:
|
||||
case boo::IGraphicsDataFactory::Platform::NX:
|
||||
default:
|
||||
lightingFuncs = ExtensionLightingFuncsGLSL;
|
||||
postFuncs = ExtensionPostFuncsGLSL;
|
||||
break;
|
||||
case boo::IGraphicsDataFactory::Platform::D3D11:
|
||||
lightingFuncs = ExtensionLightingFuncsHLSL;
|
||||
postFuncs = ExtensionPostFuncsHLSL;
|
||||
break;
|
||||
case boo::IGraphicsDataFactory::Platform::Metal:
|
||||
lightingFuncs = ExtensionLightingFuncsMetal;
|
||||
postFuncs = ExtensionPostFuncsMetal;
|
||||
break;
|
||||
}
|
||||
for (auto& ext : g_ExtensionSlots) {
|
||||
ext.lighting = *lightingFuncs++;
|
||||
ext.post = *postFuncs++;
|
||||
}
|
||||
const char** macro = ShaderMacros;
|
||||
for (auto& ext : g_ExtensionSlots)
|
||||
ext.shaderMacro = *macro++;
|
||||
}
|
||||
|
||||
void CModelShaders::Shutdown() { g_ShaderPipelines.clear(); }
|
||||
|
||||
CModelShaders::ShaderPipelines CModelShaders::BuildExtendedShader(const hecl::Backend::ShaderTag& tag,
|
||||
const hecl::Frontend::IR& ir) {
|
||||
const Material& material) {
|
||||
auto search = g_ShaderPipelines.find(tag.val64());
|
||||
if (search != g_ShaderPipelines.cend())
|
||||
return search->second;
|
||||
@@ -199,9 +195,10 @@ CModelShaders::ShaderPipelines CModelShaders::BuildExtendedShader(const hecl::Ba
|
||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
||||
size_t idx = 0;
|
||||
for (const auto& ext : g_ExtensionSlots)
|
||||
(*newPipelines)[idx++] = hecl::conv->convert(ctx, hecl::HECLIR(ir, tag, ext));
|
||||
(*newPipelines)[idx++] = hecl::conv->convert(ctx, Shader_CModelShaders(SModelShadersInfo(material, tag, ext)));
|
||||
return true;
|
||||
} BooTrace);
|
||||
return newPipelines;
|
||||
}
|
||||
|
||||
} // namespace urde
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "hecl/Runtime.hpp"
|
||||
#include "hecl/Backend/Backend.hpp"
|
||||
#include "hecl/Backend.hpp"
|
||||
#include "optional.hpp"
|
||||
#include "zeus/CVector3f.hpp"
|
||||
#include "zeus/CColor.hpp"
|
||||
#include "Graphics/CGraphics.hpp"
|
||||
#include "DataSpec/DNAMP1/CMDLMaterials.hpp"
|
||||
#include <array>
|
||||
|
||||
#define URDE_MAX_LIGHTS 8
|
||||
@@ -88,7 +89,8 @@ public:
|
||||
using ShaderPipelinesData = std::array<boo::ObjToken<boo::IShaderPipeline>, EExtendedShader::MAX>;
|
||||
using ShaderPipelines = std::shared_ptr<ShaderPipelinesData>;
|
||||
|
||||
static ShaderPipelines BuildExtendedShader(const hecl::Backend::ShaderTag& tag, const hecl::Frontend::IR& ir);
|
||||
using Material = DataSpec::DNAMP1::HMDLMaterialSet::Material;
|
||||
static ShaderPipelines BuildExtendedShader(const hecl::Backend::ShaderTag& tag, const Material& material);
|
||||
|
||||
private:
|
||||
static std::unordered_map<uint64_t, ShaderPipelines> g_ShaderPipelines;
|
||||
|
||||
@@ -1,280 +0,0 @@
|
||||
#include "CModelShaders.hpp"
|
||||
#include "hecl/Backend/GLSL.hpp"
|
||||
|
||||
namespace urde {
|
||||
using namespace std::literals;
|
||||
|
||||
extern const hecl::Backend::Function ExtensionLightingFuncsGLSL[];
|
||||
extern const hecl::Backend::Function ExtensionPostFuncsGLSL[];
|
||||
|
||||
#define FOG_STRUCT_GLSL \
|
||||
"struct Fog\n" \
|
||||
"{\n" \
|
||||
" vec4 color;\n" \
|
||||
" float A;\n" \
|
||||
" float B;\n" \
|
||||
" float C;\n" \
|
||||
" int mode;\n" \
|
||||
"};\n"
|
||||
|
||||
#define FOG_ALGORITHM_GLSL \
|
||||
" float fogZ;\n" \
|
||||
" float fogF = clamp((fog.A / (fog.B - gl_FragCoord.z)) - fog.C, 0.0, 1.0);\n" \
|
||||
" switch (fog.mode)\n" \
|
||||
" {\n" \
|
||||
" case 2:\n" \
|
||||
" fogZ = fogF;\n" \
|
||||
" break;\n" \
|
||||
" case 4:\n" \
|
||||
" fogZ = 1.0 - exp2(-8.0 * fogF);\n" \
|
||||
" break;\n" \
|
||||
" case 5:\n" \
|
||||
" fogZ = 1.0 - exp2(-8.0 * fogF * fogF);\n" \
|
||||
" break;\n" \
|
||||
" case 6:\n" \
|
||||
" fogZ = exp2(-8.0 * (1.0 - fogF));\n" \
|
||||
" break;\n" \
|
||||
" case 7:\n" \
|
||||
" fogF = 1.0 - fogF;\n" \
|
||||
" fogZ = exp2(-8.0 * fogF * fogF);\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"
|
||||
" vec4 pos;\n"
|
||||
" vec4 dir;\n"
|
||||
" vec4 color;\n"
|
||||
" vec4 linAtt;\n"
|
||||
" vec4 angAtt;\n"
|
||||
"};\n"
|
||||
FOG_STRUCT_GLSL
|
||||
"\n"
|
||||
"UBINDING2 uniform LightingUniform\n"
|
||||
"{\n"
|
||||
" Light lights[" _XSTR(URDE_MAX_LIGHTS) "];\n"
|
||||
" vec4 ambient;\n"
|
||||
" vec4 colorReg0;\n"
|
||||
" vec4 colorReg1;\n"
|
||||
" vec4 colorReg2;\n"
|
||||
" vec4 mulColor;\n"
|
||||
" vec4 addColor;\n"
|
||||
" Fog fog;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"vec4 LightingFunc(vec3 mvPosIn, vec3 mvNormIn)\n"
|
||||
"{\n"
|
||||
" vec4 ret = ambient;\n"
|
||||
" \n"
|
||||
" for (int i=0 ; i<" _XSTR(URDE_MAX_LIGHTS) " ; ++i)\n"
|
||||
" {\n"
|
||||
" vec3 delta = mvPosIn - lights[i].pos.xyz;\n"
|
||||
" float dist = length(delta);\n"
|
||||
" vec3 deltaNorm = delta / dist;\n"
|
||||
" float angDot = max(dot(deltaNorm, lights[i].dir.xyz), 0.0);\n"
|
||||
" float att = 1.0 / (lights[i].linAtt[2] * dist * dist +\n"
|
||||
" lights[i].linAtt[1] * dist +\n"
|
||||
" lights[i].linAtt[0]);\n"
|
||||
" float angAtt = lights[i].angAtt[2] * angDot * angDot +\n"
|
||||
" lights[i].angAtt[1] * angDot +\n"
|
||||
" lights[i].angAtt[0];\n"
|
||||
" ret += lights[i].color * angAtt * att * max(dot(-deltaNorm, mvNormIn), 0.0);\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" return clamp(ret, 0.0, 1.0);\n"
|
||||
"}\n"sv;
|
||||
|
||||
static std::string_view LightingShadowGLSL =
|
||||
"struct Light\n"
|
||||
"{\n"
|
||||
" vec4 pos;\n"
|
||||
" vec4 dir;\n"
|
||||
" vec4 color;\n"
|
||||
" vec4 linAtt;\n"
|
||||
" vec4 angAtt;\n"
|
||||
"};\n"
|
||||
FOG_STRUCT_GLSL
|
||||
"\n"
|
||||
"UBINDING2 uniform LightingUniform\n"
|
||||
"{\n"
|
||||
" Light lights[" _XSTR(URDE_MAX_LIGHTS) "];\n"
|
||||
" vec4 ambient;\n"
|
||||
" vec4 colorReg0;\n"
|
||||
" vec4 colorReg1;\n"
|
||||
" vec4 colorReg2;\n"
|
||||
" vec4 mulColor;\n"
|
||||
" vec4 addColor;\n"
|
||||
" Fog fog;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"vec4 LightingShadowFunc(vec3 mvPosIn, vec3 mvNormIn)\n"
|
||||
"{\n"
|
||||
" vec2 shadowUV = vtf.extTcgs[0];\n"
|
||||
" shadowUV.y = 1.0 - shadowUV.y;\n"
|
||||
" \n"
|
||||
" vec4 ret = ambient;\n"
|
||||
" \n"
|
||||
" vec3 delta = mvPosIn - lights[0].pos.xyz;\n"
|
||||
" float dist = length(delta);\n"
|
||||
" vec3 deltaNorm = delta / dist;\n"
|
||||
" float angDot = max(dot(deltaNorm, lights[0].dir.xyz), 0.0);\n"
|
||||
" float att = 1.0 / (lights[0].linAtt[2] * dist * dist +\n"
|
||||
" lights[0].linAtt[1] * dist +\n"
|
||||
" lights[0].linAtt[0]);\n"
|
||||
" float angAtt = lights[0].angAtt[2] * angDot * angDot +\n"
|
||||
" lights[0].angAtt[1] * angDot +\n"
|
||||
" lights[0].angAtt[0];\n"
|
||||
" ret += lights[0].color * angAtt * att * max(dot(-deltaNorm, mvNormIn), 0.0) *\n"
|
||||
" texture(extTex7, shadowUV).r;\n"
|
||||
" \n"
|
||||
" for (int i=1 ; i<" _XSTR(URDE_MAX_LIGHTS) " ; ++i)\n"
|
||||
" {\n"
|
||||
" vec3 delta = mvPosIn - lights[i].pos.xyz;\n"
|
||||
" float dist = length(delta);\n"
|
||||
" vec3 deltaNorm = delta / dist;\n"
|
||||
" float angDot = max(dot(deltaNorm, lights[i].dir.xyz), 0.0);\n"
|
||||
" float att = 1.0 / (lights[i].linAtt[2] * dist * dist +\n"
|
||||
" lights[i].linAtt[1] * dist +\n"
|
||||
" lights[i].linAtt[0]);\n"
|
||||
" float angAtt = lights[i].angAtt[2] * angDot * angDot +\n"
|
||||
" lights[i].angAtt[1] * angDot +\n"
|
||||
" lights[i].angAtt[0];\n"
|
||||
" ret += lights[i].color * angAtt * att * max(dot(-deltaNorm, mvNormIn), 0.0);\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" return clamp(ret, 0.0, 1.0);\n"
|
||||
"}\n"sv;
|
||||
|
||||
static std::string_view MainPostGLSL =
|
||||
"vec4 MainPostFunc(vec4 colorIn)\n"
|
||||
"{\n" FOG_ALGORITHM_GLSL
|
||||
"}\n"
|
||||
"\n"sv;
|
||||
|
||||
static std::string_view ThermalPostGLSL =
|
||||
"UBINDING2 uniform ThermalUniform\n"
|
||||
"{\n"
|
||||
" vec4 tmulColor;\n"
|
||||
" vec4 taddColor;\n"
|
||||
"};\n"
|
||||
"vec4 ThermalPostFunc(vec4 colorIn)\n"
|
||||
"{\n"
|
||||
" return texture(extTex7, vtf.extTcgs[0]).rrrr * tmulColor + taddColor;\n"
|
||||
"}\n"
|
||||
"\n"sv;
|
||||
|
||||
static std::string_view SolidPostGLSL =
|
||||
"UBINDING2 uniform SolidUniform\n"
|
||||
"{\n"
|
||||
" vec4 solidColor;\n"
|
||||
"};\n"
|
||||
"vec4 SolidPostFunc(vec4 colorIn)\n"
|
||||
"{\n"
|
||||
" return solidColor;\n"
|
||||
"}\n"
|
||||
"\n"sv;
|
||||
|
||||
static std::string_view MBShadowPostGLSL =
|
||||
"UBINDING2 uniform MBShadowUniform\n"
|
||||
"{\n"
|
||||
" vec4 shadowUp;\n"
|
||||
" float shadowId;\n"
|
||||
"};\n"
|
||||
"vec4 MBShadowPostFunc(vec4 colorIn)\n"
|
||||
"{\n"
|
||||
" float idTexel = texture(extTex0, vtf.extTcgs[0]).a;\n"
|
||||
" float sphereTexel = texture(extTex1, vtf.extTcgs[1]).a;\n"
|
||||
" float fadeTexel = texture(extTex2, vtf.extTcgs[2]).a;\n"
|
||||
" float val = ((abs(idTexel - shadowId) < 0.001) ?\n"
|
||||
" (dot(vtf.mvNorm.xyz, shadowUp.xyz) * shadowUp.w) : 0.0) *\n"
|
||||
" sphereTexel * fadeTexel;\n"
|
||||
" return vec4(0.0, 0.0, 0.0, val);\n"
|
||||
"}\n"
|
||||
"\n"sv;
|
||||
|
||||
static std::string_view DisintegratePostGLSL = FOG_STRUCT_GLSL
|
||||
"UBINDING2 uniform DisintegrateUniform\n"
|
||||
"{\n"
|
||||
" vec4 daddColor;\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 += daddColor.rgb;\n" FOG_ALGORITHM_GLSL
|
||||
"}\n"
|
||||
"\n"sv;
|
||||
|
||||
static std::string_view ThermalColdPostGLSL =
|
||||
"vec4 ThermalColdPostFunc(vec4 colorIn)\n"
|
||||
"{\n"
|
||||
" return colorIn * vec4(0.75);\n"
|
||||
"}\n"
|
||||
"\n"sv;
|
||||
|
||||
const hecl::Backend::Function ExtensionLightingFuncsGLSL[] = {
|
||||
{},
|
||||
{LightingGLSL, "LightingFunc"},
|
||||
{},
|
||||
{LightingGLSL, "LightingFunc"},
|
||||
{LightingGLSL, "LightingFunc"},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{LightingShadowGLSL, "LightingShadowFunc"},
|
||||
{LightingGLSL, "LightingFunc"},
|
||||
{LightingGLSL, "LightingFunc"},
|
||||
{LightingGLSL, "LightingFunc"},
|
||||
{LightingGLSL, "LightingFunc"},
|
||||
{LightingGLSL, "LightingFunc"},
|
||||
{LightingGLSL, "LightingFunc"},
|
||||
{LightingGLSL, "LightingFunc"},
|
||||
{},
|
||||
{LightingGLSL, "LightingFunc"},
|
||||
{},
|
||||
{LightingGLSL, "LightingFunc"},
|
||||
};
|
||||
|
||||
const hecl::Backend::Function ExtensionPostFuncsGLSL[] = {
|
||||
{},
|
||||
{MainPostGLSL, "MainPostFunc"},
|
||||
{ThermalPostGLSL, "ThermalPostFunc"},
|
||||
{MainPostGLSL, "MainPostFunc"},
|
||||
{MainPostGLSL, "MainPostFunc"},
|
||||
{SolidPostGLSL, "SolidPostFunc"},
|
||||
{SolidPostGLSL, "SolidPostFunc"},
|
||||
{SolidPostGLSL, "SolidPostFunc"},
|
||||
{SolidPostGLSL, "SolidPostFunc"},
|
||||
{SolidPostGLSL, "SolidPostFunc"},
|
||||
{SolidPostGLSL, "SolidPostFunc"},
|
||||
{MBShadowPostGLSL, "MBShadowPostFunc"},
|
||||
{MainPostGLSL, "MainPostFunc"},
|
||||
{MainPostGLSL, "MainPostFunc"},
|
||||
{MainPostGLSL, "MainPostFunc"},
|
||||
{MainPostGLSL, "MainPostFunc"},
|
||||
{MainPostGLSL, "MainPostFunc"},
|
||||
{MainPostGLSL, "MainPostFunc"},
|
||||
{MainPostGLSL, "MainPostFunc"},
|
||||
{MainPostGLSL, "MainPostFunc"},
|
||||
{DisintegratePostGLSL, "DisintegratePostFunc"},
|
||||
{MainPostGLSL, "MainPostFunc"},
|
||||
{ThermalColdPostGLSL, "ThermalColdPostFunc"},
|
||||
{MainPostGLSL, "MainPostFunc"},
|
||||
};
|
||||
|
||||
} // namespace urde
|
||||
@@ -1,271 +0,0 @@
|
||||
#include "CModelShaders.hpp"
|
||||
|
||||
namespace urde {
|
||||
using namespace std::literals;
|
||||
|
||||
extern const hecl::Backend::Function ExtensionLightingFuncsHLSL[];
|
||||
extern const hecl::Backend::Function ExtensionPostFuncsHLSL[];
|
||||
|
||||
#define FOG_STRUCT_HLSL \
|
||||
"struct Fog\n" \
|
||||
"{\n" \
|
||||
" float4 color;\n" \
|
||||
" float A;\n" \
|
||||
" float B;\n" \
|
||||
" float C;\n" \
|
||||
" int mode;\n" \
|
||||
"};\n"
|
||||
|
||||
#define FOG_ALGORITHM_HLSL \
|
||||
" float fogZ;\n" \
|
||||
" float fogF = saturate((fog.A / (fog.B - (1.0 - vtf.mvpPos.z))) - fog.C);\n" \
|
||||
" switch (fog.mode)\n" \
|
||||
" {\n" \
|
||||
" case 2:\n" \
|
||||
" fogZ = fogF;\n" \
|
||||
" break;\n" \
|
||||
" case 4:\n" \
|
||||
" fogZ = 1.0 - exp2(-8.0 * fogF);\n" \
|
||||
" break;\n" \
|
||||
" case 5:\n" \
|
||||
" fogZ = 1.0 - exp2(-8.0 * fogF * fogF);\n" \
|
||||
" break;\n" \
|
||||
" case 6:\n" \
|
||||
" fogZ = exp2(-8.0 * (1.0 - fogF));\n" \
|
||||
" break;\n" \
|
||||
" case 7:\n" \
|
||||
" fogF = 1.0 - fogF;\n" \
|
||||
" fogZ = exp2(-8.0 * fogF * fogF);\n" \
|
||||
" break;\n" \
|
||||
" default:\n" \
|
||||
" fogZ = 0.0;\n" \
|
||||
" break;\n" \
|
||||
" }\n" \
|
||||
"#ifdef BLEND_DST_ONE\n" \
|
||||
" return float4(lerp(colorIn, float4(0.0,0.0,0.0,0.0), saturate(fogZ)).rgb, colorIn.a);\n" \
|
||||
"#else\n" \
|
||||
" return float4(lerp(colorIn, fog.color, saturate(fogZ)).rgb, colorIn.a);\n" \
|
||||
"#endif\n"
|
||||
|
||||
static std::string_view LightingHLSL =
|
||||
"struct Light\n"
|
||||
"{\n"
|
||||
" float4 pos;\n"
|
||||
" float4 dir;\n"
|
||||
" float4 color;\n"
|
||||
" float4 linAtt;\n"
|
||||
" float4 angAtt;\n"
|
||||
"};\n"
|
||||
FOG_STRUCT_HLSL
|
||||
"\n"
|
||||
"cbuffer LightingUniform : register(b2)\n"
|
||||
"{\n"
|
||||
" Light lights[" _XSTR(URDE_MAX_LIGHTS) "];\n"
|
||||
" float4 ambient;\n"
|
||||
" float4 colorReg0;\n"
|
||||
" float4 colorReg1;\n"
|
||||
" float4 colorReg2;\n"
|
||||
" float4 mulColor;\n"
|
||||
" float4 addColor;\n"
|
||||
" Fog fog;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"static float4 LightingFunc(float3 mvPosIn, float3 mvNormIn, in VertToFrag vtf)\n"
|
||||
"{\n"
|
||||
" float4 ret = ambient;\n"
|
||||
" \n"
|
||||
" for (int i=0 ; i<" _XSTR(URDE_MAX_LIGHTS) " ; ++i)\n"
|
||||
" {\n"
|
||||
" float3 delta = mvPosIn - lights[i].pos.xyz;\n"
|
||||
" float dist = length(delta);\n"
|
||||
" float angDot = saturate(dot(normalize(delta), lights[i].dir.xyz));\n"
|
||||
" float att = 1.0 / (lights[i].linAtt[2] * dist * dist +\n"
|
||||
" lights[i].linAtt[1] * dist +\n"
|
||||
" lights[i].linAtt[0]);\n"
|
||||
" float angAtt = lights[i].angAtt[2] * angDot * angDot +\n"
|
||||
" lights[i].angAtt[1] * angDot +\n"
|
||||
" lights[i].angAtt[0];\n"
|
||||
" ret += lights[i].color * angAtt * att * saturate(dot(normalize(-delta), mvNormIn));\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" return saturate(ret);\n"
|
||||
"}\n"sv;
|
||||
|
||||
static std::string_view LightingShadowHLSL =
|
||||
"struct Light\n"
|
||||
"{\n"
|
||||
" float4 pos;\n"
|
||||
" float4 dir;\n"
|
||||
" float4 color;\n"
|
||||
" float4 linAtt;\n"
|
||||
" float4 angAtt;\n"
|
||||
"};\n"
|
||||
FOG_STRUCT_HLSL
|
||||
"\n"
|
||||
"cbuffer LightingUniform : register(b2)\n"
|
||||
"{\n"
|
||||
" Light lights[" _XSTR(URDE_MAX_LIGHTS) "];\n"
|
||||
" float4 ambient;\n"
|
||||
" float4 colorReg0;\n"
|
||||
" float4 colorReg1;\n"
|
||||
" float4 colorReg2;\n"
|
||||
" float4 mulColor;\n"
|
||||
" float4 addColor;\n"
|
||||
" Fog fog;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"static float4 LightingShadowFunc(float3 mvPosIn, float3 mvNormIn, in VertToFrag vtf)\n"
|
||||
"{\n"
|
||||
" float4 ret = ambient;\n"
|
||||
" \n"
|
||||
" float3 delta = mvPosIn - lights[0].pos.xyz;\n"
|
||||
" float dist = length(delta);\n"
|
||||
" float angDot = saturate(dot(normalize(delta), lights[0].dir.xyz));\n"
|
||||
" float att = 1.0 / (lights[0].linAtt[2] * dist * dist +\n"
|
||||
" lights[0].linAtt[1] * dist +\n"
|
||||
" lights[0].linAtt[0]);\n"
|
||||
" float angAtt = lights[0].angAtt[2] * angDot * angDot +\n"
|
||||
" lights[0].angAtt[1] * angDot +\n"
|
||||
" lights[0].angAtt[0];\n"
|
||||
" ret += lights[0].color * saturate(angAtt) * att * saturate(dot(normalize(-delta), mvNormIn)) *\n"
|
||||
" extTex7.Sample(clampSamp, vtf.extTcgs[0]).r;\n"
|
||||
" \n"
|
||||
" for (int i=1 ; i<" _XSTR(URDE_MAX_LIGHTS) " ; ++i)\n"
|
||||
" {\n"
|
||||
" float3 delta = mvPosIn - lights[i].pos.xyz;\n"
|
||||
" float dist = length(delta);\n"
|
||||
" float angDot = saturate(dot(normalize(delta), lights[i].dir.xyz));\n"
|
||||
" float att = 1.0 / (lights[i].linAtt[2] * dist * dist +\n"
|
||||
" lights[i].linAtt[1] * dist +\n"
|
||||
" lights[i].linAtt[0]);\n"
|
||||
" float angAtt = lights[i].angAtt[2] * angDot * angDot +\n"
|
||||
" lights[i].angAtt[1] * angDot +\n"
|
||||
" lights[i].angAtt[0];\n"
|
||||
" ret += lights[i].color * saturate(angAtt) * att * saturate(dot(normalize(-delta), mvNormIn));\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" return ret;\n"
|
||||
"}\n"sv;
|
||||
|
||||
static std::string_view MainPostHLSL =
|
||||
"static float4 MainPostFunc(in VertToFrag vtf, float4 colorIn)\n"
|
||||
"{\n" FOG_ALGORITHM_HLSL
|
||||
"}\n"
|
||||
"\n"sv;
|
||||
|
||||
static std::string_view ThermalPostHLSL =
|
||||
"cbuffer ThermalUniform : register(b2)\n"
|
||||
"{\n"
|
||||
" float4 tmulColor;\n"
|
||||
" float4 taddColor;\n"
|
||||
"};\n"
|
||||
"static float4 ThermalPostFunc(in VertToFrag vtf, float4 colorIn)\n"
|
||||
"{\n"
|
||||
" return extTex7.Sample(samp, vtf.extTcgs[0]).rrrr * tmulColor + taddColor;\n"
|
||||
"}\n"
|
||||
"\n"sv;
|
||||
|
||||
static std::string_view SolidPostHLSL =
|
||||
"cbuffer SolidUniform : register(b2)\n"
|
||||
"{\n"
|
||||
" float4 solidColor;\n"
|
||||
"};\n"
|
||||
"static float4 SolidPostFunc(in VertToFrag vtf, float4 colorIn)\n"
|
||||
"{\n"
|
||||
" return solidColor;\n"
|
||||
"}\n"
|
||||
"\n"sv;
|
||||
|
||||
static std::string_view MBShadowPostHLSL =
|
||||
"cbuffer MBShadowUniform : register(b2)\n"
|
||||
"{\n"
|
||||
" float4 shadowUp;\n"
|
||||
" float shadowId;\n"
|
||||
"};\n"
|
||||
"static float4 MBShadowPostFunc(in VertToFrag vtf, float4 colorIn)\n"
|
||||
"{\n"
|
||||
" float idTexel = extTex0.Sample(samp, vtf.extTcgs[0]).a;\n"
|
||||
" float sphereTexel = extTex1.Sample(samp, vtf.extTcgs[1]).a;\n"
|
||||
" float fadeTexel = extTex2.Sample(samp, vtf.extTcgs[2]).a;\n"
|
||||
" float val = ((abs(idTexel - shadowId) < 0.001) ?\n"
|
||||
" (dot(vtf.mvNorm.xyz, shadowUp.xyz) * shadowUp.w) : 0.0) *\n"
|
||||
" sphereTexel * fadeTexel;\n"
|
||||
" return float4(0.0, 0.0, 0.0, val);\n"
|
||||
"}\n"
|
||||
"\n"sv;
|
||||
|
||||
static std::string_view DisintegratePostHLSL = FOG_STRUCT_HLSL
|
||||
"cbuffer DisintegrateUniform : register(b2)\n"
|
||||
"{\n"
|
||||
" float4 daddColor;\n"
|
||||
" Fog fog;\n"
|
||||
"};\n"
|
||||
"static float4 DisintegratePostFunc(in VertToFrag vtf, float4 colorIn)\n"
|
||||
"{\n"
|
||||
" float4 texel0 = extTex7.Sample(samp, vtf.extTcgs[0]);\n"
|
||||
" float4 texel1 = extTex7.Sample(samp, vtf.extTcgs[1]);\n"
|
||||
" colorIn = lerp(float4(0.0,0.0,0.0,0.0), texel1, texel0);\n"
|
||||
" colorIn.rgb += daddColor.rgb;\n" FOG_ALGORITHM_HLSL
|
||||
"}\n"
|
||||
"\n"sv;
|
||||
|
||||
static std::string_view ThermalColdPostHLSL =
|
||||
"static float4 ThermalColdPostFunc(in VertToFrag vtf, float4 colorIn)\n"
|
||||
"{\n"
|
||||
" return colorIn * float4(0.75, 0.75, 0.75, 0.75);\n"
|
||||
"}\n"
|
||||
"\n"sv;
|
||||
|
||||
const hecl::Backend::Function ExtensionLightingFuncsHLSL[] = {{},
|
||||
{LightingHLSL, "LightingFunc"},
|
||||
{},
|
||||
{LightingHLSL, "LightingFunc"},
|
||||
{LightingHLSL, "LightingFunc"},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{LightingShadowHLSL, "LightingShadowFunc"},
|
||||
{LightingHLSL, "LightingFunc"},
|
||||
{LightingHLSL, "LightingFunc"},
|
||||
{LightingHLSL, "LightingFunc"},
|
||||
{LightingHLSL, "LightingFunc"},
|
||||
{LightingHLSL, "LightingFunc"},
|
||||
{LightingHLSL, "LightingFunc"},
|
||||
{LightingHLSL, "LightingFunc"},
|
||||
{},
|
||||
{LightingHLSL, "LightingFunc"},
|
||||
{},
|
||||
{LightingHLSL, "LightingFunc"},};
|
||||
|
||||
const hecl::Backend::Function ExtensionPostFuncsHLSL[] = {
|
||||
{},
|
||||
{MainPostHLSL, "MainPostFunc"},
|
||||
{ThermalPostHLSL, "ThermalPostFunc"},
|
||||
{MainPostHLSL, "MainPostFunc"},
|
||||
{MainPostHLSL, "MainPostFunc"},
|
||||
{SolidPostHLSL, "SolidPostFunc"},
|
||||
{SolidPostHLSL, "SolidPostFunc"},
|
||||
{SolidPostHLSL, "SolidPostFunc"},
|
||||
{SolidPostHLSL, "SolidPostFunc"},
|
||||
{SolidPostHLSL, "SolidPostFunc"},
|
||||
{SolidPostHLSL, "SolidPostFunc"},
|
||||
{MBShadowPostHLSL, "MBShadowPostFunc"},
|
||||
{MainPostHLSL, "MainPostFunc"},
|
||||
{MainPostHLSL, "MainPostFunc"},
|
||||
{MainPostHLSL, "MainPostFunc"},
|
||||
{MainPostHLSL, "MainPostFunc"},
|
||||
{MainPostHLSL, "MainPostFunc"},
|
||||
{MainPostHLSL, "MainPostFunc"},
|
||||
{MainPostHLSL, "MainPostFunc"},
|
||||
{MainPostHLSL, "MainPostFunc"},
|
||||
{DisintegratePostHLSL, "DisintegratePostFunc"},
|
||||
{MainPostHLSL, "MainPostFunc"},
|
||||
{ThermalColdPostHLSL, "ThermalColdPostFunc"},
|
||||
{MainPostHLSL, "MainPostFunc"},
|
||||
};
|
||||
|
||||
} // namespace urde
|
||||
@@ -1,276 +0,0 @@
|
||||
#include "CModelShaders.hpp"
|
||||
|
||||
namespace urde {
|
||||
using namespace std::literals;
|
||||
|
||||
extern const hecl::Backend::Function ExtensionLightingFuncsMetal[];
|
||||
extern const hecl::Backend::Function ExtensionPostFuncsMetal[];
|
||||
|
||||
#define FOG_STRUCT_METAL \
|
||||
"struct Fog\n" \
|
||||
"{\n" \
|
||||
" float4 color;\n" \
|
||||
" float A;\n" \
|
||||
" float B;\n" \
|
||||
" float C;\n" \
|
||||
" int mode;\n" \
|
||||
"};\n"
|
||||
|
||||
#define FOG_ALGORITHM_METAL \
|
||||
" float fogZ;\n" \
|
||||
" float fogF = saturate((lu.fog.A / (lu.fog.B - (1.0 - vtf.mvpPos.z))) - lu.fog.C);\n" \
|
||||
" switch (lu.fog.mode)\n" \
|
||||
" {\n" \
|
||||
" case 2:\n" \
|
||||
" fogZ = fogF;\n" \
|
||||
" break;\n" \
|
||||
" case 4:\n" \
|
||||
" fogZ = 1.0 - exp2(-8.0 * fogF);\n" \
|
||||
" break;\n" \
|
||||
" case 5:\n" \
|
||||
" fogZ = 1.0 - exp2(-8.0 * fogF * fogF);\n" \
|
||||
" break;\n" \
|
||||
" case 6:\n" \
|
||||
" fogZ = exp2(-8.0 * (1.0 - fogF));\n" \
|
||||
" break;\n" \
|
||||
" case 7:\n" \
|
||||
" fogF = 1.0 - fogF;\n" \
|
||||
" fogZ = exp2(-8.0 * fogF * fogF);\n" \
|
||||
" break;\n" \
|
||||
" default:\n" \
|
||||
" fogZ = 0.0;\n" \
|
||||
" break;\n" \
|
||||
" }\n" \
|
||||
"#ifdef BLEND_DST_ONE\n" \
|
||||
" return float4(mix(colorIn, float4(0.0), saturate(fogZ)).rgb, colorIn.a);\n" \
|
||||
"#else\n" \
|
||||
" return float4(mix(colorIn, lu.fog.color, saturate(fogZ)).rgb, colorIn.a);\n" \
|
||||
"#endif\n"
|
||||
|
||||
static std::string_view LightingMetal =
|
||||
"struct Light\n"
|
||||
"{\n"
|
||||
" float4 pos;\n"
|
||||
" float4 dir;\n"
|
||||
" float4 color;\n"
|
||||
" float4 linAtt;\n"
|
||||
" float4 angAtt;\n"
|
||||
"};\n"
|
||||
FOG_STRUCT_METAL
|
||||
"\n"
|
||||
"struct LightingUniform\n"
|
||||
"{\n"
|
||||
" Light lights[" _XSTR(URDE_MAX_LIGHTS) "];\n"
|
||||
" float4 ambient;\n"
|
||||
" float4 colorReg0;\n"
|
||||
" float4 colorReg1;\n"
|
||||
" float4 colorReg2;\n"
|
||||
" float4 mulColor;\n"
|
||||
" float4 addColor;\n"
|
||||
" Fog fog;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"static float4 LightingFunc(constant LightingUniform& lu, float3 mvPosIn, float3 mvNormIn, thread VertToFrag& vtf)\n"
|
||||
"{\n"
|
||||
" float4 ret = lu.ambient;\n"
|
||||
" \n"
|
||||
" for (int i=0 ; i<" _XSTR(URDE_MAX_LIGHTS) " ; ++i)\n"
|
||||
" {\n"
|
||||
" float3 delta = mvPosIn - lu.lights[i].pos.xyz;\n"
|
||||
" float dist = length(delta);\n"
|
||||
" float angDot = saturate(dot(normalize(delta), lu.lights[i].dir.xyz));\n"
|
||||
" float att = 1.0 / (lu.lights[i].linAtt[2] * dist * dist +\n"
|
||||
" lu.lights[i].linAtt[1] * dist +\n"
|
||||
" lu.lights[i].linAtt[0]);\n"
|
||||
" float angAtt = lu.lights[i].angAtt[2] * angDot * angDot +\n"
|
||||
" lu.lights[i].angAtt[1] * angDot +\n"
|
||||
" lu.lights[i].angAtt[0];\n"
|
||||
" ret += lu.lights[i].color * angAtt * att * saturate(dot(normalize(-delta), mvNormIn));\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" return saturate(ret);\n"
|
||||
"}\n"sv;
|
||||
|
||||
static std::string_view LightingShadowMetal =
|
||||
"struct Light\n"
|
||||
"{\n"
|
||||
" float4 pos;\n"
|
||||
" float4 dir;\n"
|
||||
" float4 color;\n"
|
||||
" float4 linAtt;\n"
|
||||
" float4 angAtt;\n"
|
||||
"};\n"
|
||||
FOG_STRUCT_METAL
|
||||
"\n"
|
||||
"struct LightingUniform\n"
|
||||
"{\n"
|
||||
" Light lights[" _XSTR(URDE_MAX_LIGHTS) "];\n"
|
||||
" float4 ambient;\n"
|
||||
" float4 colorReg0;\n"
|
||||
" float4 colorReg1;\n"
|
||||
" float4 colorReg2;\n"
|
||||
" float4 mulColor;\n"
|
||||
" float4 addColor;\n"
|
||||
" Fog fog;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"static float4 EXTLightingShadowFunc(constant LightingUniform& lu, float3 mvPosIn, float3 mvNormIn,\n"
|
||||
" thread VertToFrag& vtf, sampler samp, sampler clampSamp, texture2d<float> extTex7)\n"
|
||||
"{\n"
|
||||
" float4 ret = lu.ambient;\n"
|
||||
" \n"
|
||||
" float3 delta = mvPosIn - lu.lights[0].pos.xyz;\n"
|
||||
" float dist = length(delta);\n"
|
||||
" float angDot = saturate(dot(normalize(delta), lu.lights[0].dir.xyz));\n"
|
||||
" float att = 1.0 / (lu.lights[0].linAtt[2] * dist * dist +\n"
|
||||
" lu.lights[0].linAtt[1] * dist +\n"
|
||||
" lu.lights[0].linAtt[0]);\n"
|
||||
" float angAtt = lu.lights[0].angAtt[2] * angDot * angDot +\n"
|
||||
" lu.lights[0].angAtt[1] * angDot +\n"
|
||||
" lu.lights[0].angAtt[0];\n"
|
||||
" ret += lu.lights[0].color * saturate(angAtt) * att * saturate(dot(normalize(-delta), mvNormIn)) *\n"
|
||||
" extTex7.sample(clampSamp, vtf.extTcgs0).r;\n"
|
||||
" \n"
|
||||
" for (int i=1 ; i<" _XSTR(URDE_MAX_LIGHTS) " ; ++i)\n"
|
||||
" {\n"
|
||||
" float3 delta = mvPosIn - lu.lights[i].pos.xyz;\n"
|
||||
" float dist = length(delta);\n"
|
||||
" float angDot = saturate(dot(normalize(delta), lu.lights[i].dir.xyz));\n"
|
||||
" float att = 1.0 / (lu.lights[i].linAtt[2] * dist * dist +\n"
|
||||
" lu.lights[i].linAtt[1] * dist +\n"
|
||||
" lu.lights[i].linAtt[0]);\n"
|
||||
" float angAtt = lu.lights[i].angAtt[2] * angDot * angDot +\n"
|
||||
" lu.lights[i].angAtt[1] * angDot +\n"
|
||||
" lu.lights[i].angAtt[0];\n"
|
||||
" ret += lu.lights[i].color * saturate(angAtt) * att * saturate(dot(normalize(-delta), mvNormIn));\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" return ret;\n"
|
||||
"}\n"sv;
|
||||
|
||||
static std::string_view MainPostMetal =
|
||||
"float4 MainPostFunc(thread VertToFrag& vtf, constant LightingUniform& lu, float4 colorIn)\n"
|
||||
"{\n" FOG_ALGORITHM_METAL
|
||||
"}\n"
|
||||
"\n"sv;
|
||||
|
||||
static std::string_view ThermalPostMetal =
|
||||
"struct ThermalUniform\n"
|
||||
"{\n"
|
||||
" float4 tmulColor;\n"
|
||||
" float4 taddColor;\n"
|
||||
"};\n"
|
||||
"static float4 EXTThermalPostFunc(thread VertToFrag& vtf, constant ThermalUniform& lu,\n"
|
||||
" sampler samp, sampler clampSamp, texture2d<float> extTex7, float4 colorIn)\n"
|
||||
"{\n"
|
||||
" return extTex7.sample(samp, vtf.extTcgs0).rrrr * lu.tmulColor + lu.taddColor;\n"
|
||||
"}\n"
|
||||
"\n"sv;
|
||||
|
||||
static std::string_view SolidPostMetal =
|
||||
"struct SolidUniform\n"
|
||||
"{\n"
|
||||
" float4 solidColor;\n"
|
||||
"};\n"
|
||||
"static float4 SolidPostFunc(thread VertToFrag& vtf, constant SolidUniform& lu, float4 colorIn)\n"
|
||||
"{\n"
|
||||
" return lu.solidColor;\n"
|
||||
"}\n"
|
||||
"\n"sv;
|
||||
|
||||
static std::string_view MBShadowPostMetal =
|
||||
"struct MBShadowUniform\n"
|
||||
"{\n"
|
||||
" float4 shadowUp;\n"
|
||||
" float shadowId;\n"
|
||||
"};\n"
|
||||
"static float4 EXTMBShadowPostFunc(thread VertToFrag& vtf, constant MBShadowUniform& su, sampler samp,\n"
|
||||
" sampler clampSamp, texture2d<float> extTex0, texture2d<float> extTex1,\n"
|
||||
" texture2d<float> extTex2, float4 colorIn)\n"
|
||||
"{\n"
|
||||
" float idTexel = extTex0.sample(samp, vtf.extTcgs0).a;\n"
|
||||
" float sphereTexel = extTex1.sample(samp, vtf.extTcgs1).a;\n"
|
||||
" float fadeTexel = extTex2.sample(samp, vtf.extTcgs2).a;\n"
|
||||
" float val = ((fabs(idTexel - su.shadowId) < 0.001) ?\n"
|
||||
" (dot(vtf.mvNorm.xyz, su.shadowUp.xyz) * su.shadowUp.w) : 0.0) *\n"
|
||||
" sphereTexel * fadeTexel;\n"
|
||||
" return float4(0.0, 0.0, 0.0, val);\n"
|
||||
"}\n"
|
||||
"\n"sv;
|
||||
|
||||
static std::string_view DisintegratePostMetal = FOG_STRUCT_METAL
|
||||
"struct DisintegrateUniform\n"
|
||||
"{\n"
|
||||
" float4 daddColor;\n"
|
||||
" Fog fog;\n"
|
||||
"};\n"
|
||||
"static float4 EXTDisintegratePostFunc(thread VertToFrag& vtf, constant DisintegrateUniform& lu, sampler samp,\n"
|
||||
" sampler clampSamp, texture2d<float> extTex7, float4 colorIn)\n"
|
||||
"{\n"
|
||||
" float4 texel0 = extTex7.sample(samp, vtf.extTcgs0);\n"
|
||||
" float4 texel1 = extTex7.sample(samp, vtf.extTcgs1);\n"
|
||||
" colorIn = mix(float4(0.0), texel1, texel0);\n"
|
||||
" colorIn.rgb += lu.daddColor.rgb;\n" FOG_ALGORITHM_METAL
|
||||
"}\n"
|
||||
"\n"sv;
|
||||
|
||||
static std::string_view ThermalColdPostMetal =
|
||||
"static float4 ThermalColdPostFunc(thread VertToFrag& vtf, float4 colorIn)\n"
|
||||
"{\n"
|
||||
" return colorIn * float4(0.75, 0.75, 0.75, 0.75);\n"
|
||||
"}\n"
|
||||
"\n"sv;
|
||||
|
||||
const hecl::Backend::Function ExtensionLightingFuncsMetal[] = {{},
|
||||
{LightingMetal, "LightingFunc"},
|
||||
{},
|
||||
{LightingMetal, "LightingFunc"},
|
||||
{LightingMetal, "LightingFunc"},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{LightingShadowMetal, "EXTLightingShadowFunc"},
|
||||
{LightingMetal, "LightingFunc"},
|
||||
{LightingMetal, "LightingFunc"},
|
||||
{LightingMetal, "LightingFunc"},
|
||||
{LightingMetal, "LightingFunc"},
|
||||
{LightingMetal, "LightingFunc"},
|
||||
{LightingMetal, "LightingFunc"},
|
||||
{LightingMetal, "LightingFunc"},
|
||||
{},
|
||||
{LightingMetal, "LightingFunc"},
|
||||
{},
|
||||
{LightingMetal, "LightingFunc"},};
|
||||
|
||||
const hecl::Backend::Function ExtensionPostFuncsMetal[] = {
|
||||
{},
|
||||
{MainPostMetal, "MainPostFunc"},
|
||||
{ThermalPostMetal, "EXTThermalPostFunc"},
|
||||
{MainPostMetal, "MainPostFunc"},
|
||||
{MainPostMetal, "MainPostFunc"},
|
||||
{SolidPostMetal, "SolidPostFunc"},
|
||||
{SolidPostMetal, "SolidPostFunc"},
|
||||
{SolidPostMetal, "SolidPostFunc"},
|
||||
{SolidPostMetal, "SolidPostFunc"},
|
||||
{SolidPostMetal, "SolidPostFunc"},
|
||||
{SolidPostMetal, "SolidPostFunc"},
|
||||
{MBShadowPostMetal, "EXTMBShadowPostFunc"},
|
||||
{MainPostMetal, "MainPostFunc"},
|
||||
{MainPostMetal, "MainPostFunc"},
|
||||
{MainPostMetal, "MainPostFunc"},
|
||||
{MainPostMetal, "MainPostFunc"},
|
||||
{MainPostMetal, "MainPostFunc"},
|
||||
{MainPostMetal, "MainPostFunc"},
|
||||
{MainPostMetal, "MainPostFunc"},
|
||||
{MainPostMetal, "MainPostFunc"},
|
||||
{DisintegratePostMetal, "EXTDisintegratePostFunc"},
|
||||
{MainPostMetal, "MainPostFunc"},
|
||||
{ThermalColdPostMetal, "ThermalColdPostFunc"},
|
||||
{MainPostMetal, "MainPostFunc"},
|
||||
};
|
||||
|
||||
} // namespace urde
|
||||
Reference in New Issue
Block a user