Various rendering fixes

This commit is contained in:
Jack Andersen 2019-03-02 20:19:42 -10:00
parent ca5cf5c77c
commit 8b9f073635
32 changed files with 948 additions and 552 deletions

View File

@ -1455,7 +1455,8 @@ bool TXTR::CookPC(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outP
}
/* Track alpha values for DXT1 eligibility */
bool doDXT1 = (colorType == PNG_COLOR_TYPE_RGB || colorType == PNG_COLOR_TYPE_RGB_ALPHA) && width >= 4 && height >= 4;
bool doDXT = (colorType == PNG_COLOR_TYPE_RGB || colorType == PNG_COLOR_TYPE_RGB_ALPHA) && width >= 4 && height >= 4;
bool doDXT3 = false;
/* Read and make RGBA */
for (int r = height - 1; r >= 0; --r) {
@ -1499,7 +1500,9 @@ bool TXTR::CookPC(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outP
bufOut[outbase + 2] = rowBuf[inbase + 2];
bufOut[outbase + 3] = rowBuf[inbase + 3];
if (rowBuf[inbase + 3] != 0 && rowBuf[inbase + 3] != 255)
doDXT1 = false;
doDXT = false;
else if (rowBuf[inbase + 3] == 0)
doDXT3 = true;
}
break;
case PNG_COLOR_TYPE_PALETTE:
@ -1521,7 +1524,7 @@ bool TXTR::CookPC(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outP
unsigned filterWidth = width;
unsigned filterHeight = height;
for (size_t i = 1; i < numMips; ++i) {
BoxFilter(filterIn, nComps, filterWidth, filterHeight, filterOut, doDXT1);
BoxFilter(filterIn, nComps, filterWidth, filterHeight, filterOut, doDXT);
filterIn += filterWidth * filterHeight * nComps;
filterWidth /= 2;
filterHeight /= 2;
@ -1529,15 +1532,16 @@ bool TXTR::CookPC(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outP
}
}
/* Do DXT1 compression */
/* Do DXT compression */
std::unique_ptr<uint8_t[]> compOut;
size_t compLen = 0;
if (doDXT1) {
if (doDXT) {
int compFlags = doDXT3 ? squish::kDxt3 : squish::kDxt1;
int filterWidth = width;
int filterHeight = height;
size_t i;
for (i = 0; i < numMips; ++i) {
compLen += squish::GetStorageRequirements(filterWidth, filterHeight, squish::kDxt1);
compLen += squish::GetStorageRequirements(filterWidth, filterHeight, compFlags);
if (filterWidth == 4 || filterHeight == 4) {
++i;
break;
@ -1554,8 +1558,8 @@ bool TXTR::CookPC(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outP
const uint8_t* rgbaIn = bufOut.get();
uint8_t* blocksOut = compOut.get();
for (i = 0; i < numMips; ++i) {
int thisLen = squish::GetStorageRequirements(filterWidth, filterHeight, squish::kDxt1);
squish::CompressImage(rgbaIn, filterWidth, filterHeight, blocksOut, squish::kDxt1);
int thisLen = squish::GetStorageRequirements(filterWidth, filterHeight, compFlags);
squish::CompressImage(rgbaIn, filterWidth, filterHeight, blocksOut, compFlags);
rgbaIn += filterWidth * filterHeight * nComps;
blocksOut += thisLen;
filterWidth /= 2;
@ -1574,7 +1578,7 @@ bool TXTR::CookPC(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outP
if (paletteBuf && paletteSize)
format = 17;
else if (compOut)
format = 18;
format = doDXT3 ? 19 : 18;
else
format = 16;
outf.writeInt32Big(format);

View File

@ -63,27 +63,17 @@ void CGraphics::SetAmbientColor(const zeus::CColor& col) {
void CGraphics::SetFog(ERglFogMode mode, float startz, float endz, const zeus::CColor& color) {
g_Fog.m_mode = mode > ERglFogMode::PerspRevExp2 ? ERglFogMode(int(mode) - 8) : mode;
switch (g_Fog.m_mode) {
case ERglFogMode::None: {
g_Fog.m_start = 4096.f;
g_Fog.m_rangeScale = 0.f;
break;
}
case ERglFogMode::PerspRevExp:
case ERglFogMode::PerspRevExp2: {
float userRange = endz - startz;
g_Fog.m_color = color;
g_Fog.m_start = endz;
g_Fog.m_rangeScale = 1.f / userRange;
break;
}
default: {
float userRange = endz - startz;
g_Fog.m_color = color;
g_Fog.m_start = startz;
g_Fog.m_rangeScale = 1.f / userRange;
break;
}
if (CGraphics::g_Proj.x18_far == CGraphics::g_Proj.x14_near || endz == startz) {
g_Fog.m_A = 0.f;
g_Fog.m_B = 0.5f;
g_Fog.m_C = 0.f;
} else {
float depthrange = CGraphics::g_Proj.x18_far - CGraphics::g_Proj.x14_near;
float fogrange = endz - startz;
g_Fog.m_A = (CGraphics::g_Proj.x18_far * CGraphics::g_Proj.x14_near) / (depthrange * fogrange);
g_Fog.m_B = CGraphics::g_Proj.x18_far / depthrange;
g_Fog.m_C = startz / fogrange;
}
}

View File

@ -165,6 +165,7 @@ enum class ETexelFormat {
RGBA8PC = 16,
C8PC = 17,
CMPRPC = 18,
CMPRPCA = 19,
};
#define DEPTH_FAR 1.f
@ -191,8 +192,9 @@ public:
struct CFogState {
ERglFogMode m_mode;
zeus::CColor m_color;
float m_rangeScale = 0.f;
float m_start = 4096.f;
float m_A = 0.f;
float m_B = 0.5f;
float m_C = 0.f;
};
static CProjectionState g_Proj;

View File

@ -107,7 +107,7 @@ void CLineRenderer::Reset() {
void CLineRenderer::AddVertex(const zeus::CVector3f& position, const zeus::CColor& color, float width,
const zeus::CVector2f& uv) {
if (m_final || !m_shaderBind || m_nextVert >= m_maxVerts)
if (m_final || !m_shaderBind[0] || m_nextVert >= m_maxVerts)
return;
float adjWidth = width / 480.f;
@ -237,7 +237,7 @@ void CLineRenderer::AddVertex(const zeus::CVector3f& position, const zeus::CColo
++m_nextVert;
}
void CLineRenderer::Render(const zeus::CColor& moduColor) {
void CLineRenderer::Render(bool alphaWrite, const zeus::CColor& moduColor) {
if (!m_final && m_nextVert > 1) {
if (m_mode == EPrimitiveMode::LineLoop) {
{
@ -366,18 +366,18 @@ void CLineRenderer::Render(const zeus::CColor& moduColor) {
m_final = true;
}
m_uniformBuf.access() = SDrawUniform{moduColor};
m_uniformBuf.access() = SDrawUniform{moduColor, CGraphics::g_Fog};
if (m_textured) {
if (!g_StaticLineVertsTex.empty()) {
memmove(m_vertBufTex.access(), g_StaticLineVertsTex.data(), sizeof(SDrawVertTex) * g_StaticLineVertsTex.size());
CGraphics::SetShaderDataBinding(m_shaderBind);
CGraphics::SetShaderDataBinding(m_shaderBind[alphaWrite]);
CGraphics::DrawArray(0, g_StaticLineVertsTex.size());
}
} else {
if (!g_StaticLineVertsNoTex.empty()) {
memmove(m_vertBufNoTex.access(), g_StaticLineVertsNoTex.data(),
sizeof(SDrawVertNoTex) * g_StaticLineVertsNoTex.size());
CGraphics::SetShaderDataBinding(m_shaderBind);
CGraphics::SetShaderDataBinding(m_shaderBind[alphaWrite]);
CGraphics::DrawArray(0, g_StaticLineVertsNoTex.size());
}
}

View File

@ -7,6 +7,7 @@
#include "boo/graphicsdev/IGraphicsDataFactory.hpp"
#include "hecl/VertexBufferPool.hpp"
#include "hecl/UniformBufferPool.hpp"
#include "Graphics/CGraphics.hpp"
namespace urde {
@ -27,6 +28,7 @@ public:
struct SDrawUniform {
zeus::CColor moduColor;
CGraphics::CFogState fog;
};
private:
@ -61,7 +63,7 @@ public:
hecl::VertexBufferPool<SDrawVertTex>::Token m_vertBufTex;
hecl::VertexBufferPool<SDrawVertNoTex>::Token m_vertBufNoTex;
hecl::UniformBufferPool<SDrawUniform>::Token m_uniformBuf;
boo::ObjToken<boo::IShaderDataBinding> m_shaderBind;
boo::ObjToken<boo::IShaderDataBinding> m_shaderBind[2];
CLineRenderer(boo::IGraphicsDataFactory::Context& ctx, EPrimitiveMode mode, u32 maxVerts,
const boo::ObjToken<boo::ITexture>& texture, bool additive, bool zTest = false, bool zGEqual = false);
@ -72,7 +74,7 @@ public:
void Reset();
void AddVertex(const zeus::CVector3f& position, const zeus::CColor& color, float width,
const zeus::CVector2f& uv = zeus::skZero2f);
void Render(const zeus::CColor& moduColor = zeus::skWhite);
void Render(bool alphaWrite = false, const zeus::CColor& moduColor = zeus::skWhite);
static void UpdateBuffers() {
s_vertPoolTex.updateBuffers();

View File

@ -1,6 +1,8 @@
#include "CRainSplashGenerator.hpp"
#include "CStateManager.hpp"
#include "World/CWorld.hpp"
#include "GameGlobalObjects.hpp"
#include "Graphics/CBooRenderer.hpp"
namespace urde {
@ -32,7 +34,7 @@ void CRainSplashGenerator::SSplashLine::Draw(float alpha, float dt, const zeus::
vt += delta;
m_renderer.AddVertex(vec, zeus::CColor(1.f, vertAlpha), 1);
}
m_renderer.Render();
m_renderer.Render(g_Renderer->IsThermalVisorHotPass());
}
}

View File

@ -49,6 +49,7 @@ private:
void BuildC8(const void* data, size_t length);
void BuildC8Font(const void* data, EFontType ftype);
void BuildDXT1(const void* data, size_t length);
void BuildDXT3(const void* data, size_t length);
public:
CTexture(ETexelFormat, s16, s16, s32);

View File

@ -686,6 +686,15 @@ void CTexture::BuildDXT1(const void* data, size_t length) {
} BooTrace);
}
void CTexture::BuildDXT3(const void* data, size_t length) {
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
m_booTex =
ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::DXT3, boo::TextureClampMode::Repeat, data, length)
.get();
return true;
} BooTrace);
}
CTexture::CTexture(ETexelFormat fmt, s16 w, s16 h, s32 mips) : x0_fmt(fmt), x4_w(w), x6_h(h), x8_mips(mips) {
/*
x64_ = sMangleMipmaps;
@ -746,6 +755,9 @@ CTexture::CTexture(std::unique_ptr<u8[]>&& in, u32 length, bool otex) {
case ETexelFormat::CMPRPC:
BuildDXT1(owned.get() + 12, length - 12);
break;
case ETexelFormat::CMPRPCA:
BuildDXT3(owned.get() + 12, length - 12);
break;
default:
Log.report(logvisor::Fatal, "invalid texture type %d for boo", int(x0_fmt));
}

View File

@ -4,92 +4,116 @@
namespace urde {
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_texZTestZWrite;
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_texNoZTestZWrite;
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_texZTestNoZWrite;
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_texNoZTestNoZWrite;
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_texAdditiveZTest;
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_texAdditiveNoZTest;
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_texRedToAlphaZTest;
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_texRedToAlphaNoZTest;
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_texZTestNoZWriteSub;
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_texNoZTestNoZWriteSub;
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_texRedToAlphaZTestSub;
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_texRedToAlphaNoZTestSub;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CElementGenShaders::m_texZTestZWrite;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CElementGenShaders::m_texNoZTestZWrite;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CElementGenShaders::m_texZTestNoZWrite;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CElementGenShaders::m_texNoZTestNoZWrite;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CElementGenShaders::m_texAdditiveZTest;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CElementGenShaders::m_texAdditiveNoZTest;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CElementGenShaders::m_texRedToAlphaZTest;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CElementGenShaders::m_texRedToAlphaNoZTest;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CElementGenShaders::m_texZTestNoZWriteSub;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CElementGenShaders::m_texNoZTestNoZWriteSub;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CElementGenShaders::m_texRedToAlphaZTestSub;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CElementGenShaders::m_texRedToAlphaNoZTestSub;
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_indTexZWrite;
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_indTexNoZWrite;
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_indTexAdditive;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CElementGenShaders::m_indTexZWrite;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CElementGenShaders::m_indTexNoZWrite;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CElementGenShaders::m_indTexAdditive;
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_cindTexZWrite;
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_cindTexNoZWrite;
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_cindTexAdditive;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CElementGenShaders::m_cindTexZWrite;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CElementGenShaders::m_cindTexNoZWrite;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CElementGenShaders::m_cindTexAdditive;
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_noTexZTestZWrite;
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_noTexNoZTestZWrite;
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_noTexZTestNoZWrite;
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_noTexNoZTestNoZWrite;
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_noTexAdditiveZTest;
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_noTexAdditiveNoZTest;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CElementGenShaders::m_noTexZTestZWrite;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CElementGenShaders::m_noTexNoZTestZWrite;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CElementGenShaders::m_noTexZTestNoZWrite;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CElementGenShaders::m_noTexNoZTestNoZWrite;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CElementGenShaders::m_noTexAdditiveZTest;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CElementGenShaders::m_noTexAdditiveNoZTest;
void CElementGenShaders::Initialize() {
m_texZTestZWrite = hecl::conv->convert(Shader_CElementGenShaderTexZTestZWrite{});
m_texNoZTestZWrite = hecl::conv->convert(Shader_CElementGenShaderTexNoZTestZWrite{});
m_texZTestNoZWrite = hecl::conv->convert(Shader_CElementGenShaderTexZTestNoZWrite{});
m_texNoZTestNoZWrite = hecl::conv->convert(Shader_CElementGenShaderTexNoZTestNoZWrite{});
m_texAdditiveZTest = hecl::conv->convert(Shader_CElementGenShaderTexAdditiveZTest{});
m_texAdditiveNoZTest = hecl::conv->convert(Shader_CElementGenShaderTexAdditiveNoZTest{});
m_texRedToAlphaZTest = hecl::conv->convert(Shader_CElementGenShaderTexRedToAlphaZTest{});
m_texRedToAlphaNoZTest = hecl::conv->convert(Shader_CElementGenShaderTexRedToAlphaNoZTest{});
m_texZTestNoZWriteSub = hecl::conv->convert(Shader_CElementGenShaderTexZTestNoZWriteSub{});
m_texNoZTestNoZWriteSub = hecl::conv->convert(Shader_CElementGenShaderTexNoZTestNoZWriteSub{});
m_texRedToAlphaZTestSub = hecl::conv->convert(Shader_CElementGenShaderTexRedToAlphaZTestSub{});
m_texRedToAlphaNoZTestSub = hecl::conv->convert(Shader_CElementGenShaderTexRedToAlphaNoZTestSub{});
m_texZTestZWrite = {hecl::conv->convert(Shader_CElementGenShaderTexZTestZWrite{}),
hecl::conv->convert(Shader_CElementGenShaderTexZTestZWrite{})};
m_texNoZTestZWrite = {hecl::conv->convert(Shader_CElementGenShaderTexNoZTestZWrite{}),
hecl::conv->convert(Shader_CElementGenShaderTexNoZTestZWriteAWrite{})};
m_texZTestNoZWrite = {hecl::conv->convert(Shader_CElementGenShaderTexZTestNoZWrite{}),
hecl::conv->convert(Shader_CElementGenShaderTexZTestNoZWriteAWrite{})};
m_texNoZTestNoZWrite = {hecl::conv->convert(Shader_CElementGenShaderTexNoZTestNoZWrite{}),
hecl::conv->convert(Shader_CElementGenShaderTexNoZTestNoZWriteAWrite{})};
m_texAdditiveZTest = {hecl::conv->convert(Shader_CElementGenShaderTexAdditiveZTest{}),
hecl::conv->convert(Shader_CElementGenShaderTexAdditiveZTestAWrite{})};
m_texAdditiveNoZTest = {hecl::conv->convert(Shader_CElementGenShaderTexAdditiveNoZTest{}),
hecl::conv->convert(Shader_CElementGenShaderTexAdditiveNoZTestAWrite{})};
m_texRedToAlphaZTest = {hecl::conv->convert(Shader_CElementGenShaderTexRedToAlphaZTest{}),
hecl::conv->convert(Shader_CElementGenShaderTexRedToAlphaZTestAWrite{})};
m_texRedToAlphaNoZTest = {hecl::conv->convert(Shader_CElementGenShaderTexRedToAlphaNoZTest{}),
hecl::conv->convert(Shader_CElementGenShaderTexRedToAlphaNoZTestAWrite{})};
m_texZTestNoZWriteSub = {hecl::conv->convert(Shader_CElementGenShaderTexZTestNoZWriteSub{}),
hecl::conv->convert(Shader_CElementGenShaderTexZTestNoZWriteSubAWrite{})};
m_texNoZTestNoZWriteSub = {hecl::conv->convert(Shader_CElementGenShaderTexNoZTestNoZWriteSub{}),
hecl::conv->convert(Shader_CElementGenShaderTexNoZTestNoZWriteSubAWrite{})};
m_texRedToAlphaZTestSub = {hecl::conv->convert(Shader_CElementGenShaderTexRedToAlphaZTestSub{}),
hecl::conv->convert(Shader_CElementGenShaderTexRedToAlphaZTestSubAWrite{})};
m_texRedToAlphaNoZTestSub = {hecl::conv->convert(Shader_CElementGenShaderTexRedToAlphaNoZTestSub{}),
hecl::conv->convert(Shader_CElementGenShaderTexRedToAlphaNoZTestSubAWrite{})};
m_indTexZWrite = hecl::conv->convert(Shader_CElementGenShaderIndTexZWrite{});
m_indTexNoZWrite = hecl::conv->convert(Shader_CElementGenShaderIndTexNoZWrite{});
m_indTexAdditive = hecl::conv->convert(Shader_CElementGenShaderIndTexAdditive{});
m_indTexZWrite = {hecl::conv->convert(Shader_CElementGenShaderIndTexZWrite{}),
hecl::conv->convert(Shader_CElementGenShaderIndTexZWriteAWrite{})};
m_indTexNoZWrite = {hecl::conv->convert(Shader_CElementGenShaderIndTexNoZWrite{}),
hecl::conv->convert(Shader_CElementGenShaderIndTexNoZWriteAWrite{})};
m_indTexAdditive = {hecl::conv->convert(Shader_CElementGenShaderIndTexAdditive{}),
hecl::conv->convert(Shader_CElementGenShaderIndTexAdditiveAWrite{})};
m_cindTexZWrite = hecl::conv->convert(Shader_CElementGenShaderCindTexZWrite{});
m_cindTexNoZWrite = hecl::conv->convert(Shader_CElementGenShaderCindTexNoZWrite{});
m_cindTexAdditive = hecl::conv->convert(Shader_CElementGenShaderCindTexAdditive{});
m_cindTexZWrite = {hecl::conv->convert(Shader_CElementGenShaderCindTexZWrite{}),
hecl::conv->convert(Shader_CElementGenShaderCindTexZWriteAWrite{})};
m_cindTexNoZWrite = {hecl::conv->convert(Shader_CElementGenShaderCindTexNoZWrite{}),
hecl::conv->convert(Shader_CElementGenShaderCindTexNoZWriteAWrite{})};
m_cindTexAdditive = {hecl::conv->convert(Shader_CElementGenShaderCindTexAdditive{}),
hecl::conv->convert(Shader_CElementGenShaderCindTexAdditiveAWrite{})};
m_noTexZTestZWrite = hecl::conv->convert(Shader_CElementGenShaderNoTexZTestZWrite{});
m_noTexNoZTestZWrite = hecl::conv->convert(Shader_CElementGenShaderNoTexNoZTestZWrite{});
m_noTexZTestNoZWrite = hecl::conv->convert(Shader_CElementGenShaderNoTexZTestNoZWrite{});
m_noTexNoZTestNoZWrite = hecl::conv->convert(Shader_CElementGenShaderNoTexNoZTestNoZWrite{});
m_noTexAdditiveZTest = hecl::conv->convert(Shader_CElementGenShaderNoTexAdditiveZTest{});
m_noTexAdditiveNoZTest = hecl::conv->convert(Shader_CElementGenShaderNoTexAdditiveNoZTest{});
m_noTexZTestZWrite = {hecl::conv->convert(Shader_CElementGenShaderNoTexZTestZWrite{}),
hecl::conv->convert(Shader_CElementGenShaderNoTexZTestZWriteAWrite{})};
m_noTexNoZTestZWrite = {hecl::conv->convert(Shader_CElementGenShaderNoTexNoZTestZWrite{}),
hecl::conv->convert(Shader_CElementGenShaderNoTexNoZTestZWriteAWrite{})};
m_noTexZTestNoZWrite = {hecl::conv->convert(Shader_CElementGenShaderNoTexZTestNoZWrite{}),
hecl::conv->convert(Shader_CElementGenShaderNoTexZTestNoZWriteAWrite{})};
m_noTexNoZTestNoZWrite = {hecl::conv->convert(Shader_CElementGenShaderNoTexNoZTestNoZWrite{}),
hecl::conv->convert(Shader_CElementGenShaderNoTexNoZTestNoZWriteAWrite{})};
m_noTexAdditiveZTest = {hecl::conv->convert(Shader_CElementGenShaderNoTexAdditiveZTest{}),
hecl::conv->convert(Shader_CElementGenShaderNoTexAdditiveZTestAWrite{})};
m_noTexAdditiveNoZTest = {hecl::conv->convert(Shader_CElementGenShaderNoTexAdditiveNoZTest{}),
hecl::conv->convert(Shader_CElementGenShaderNoTexAdditiveNoZTestAWrite{})};
}
void CElementGenShaders::Shutdown() {
m_texZTestZWrite.reset();
m_texNoZTestZWrite.reset();
m_texZTestNoZWrite.reset();
m_texNoZTestNoZWrite.reset();
m_texAdditiveZTest.reset();
m_texAdditiveNoZTest.reset();
m_texRedToAlphaZTest.reset();
m_texRedToAlphaNoZTest.reset();
m_texZTestNoZWriteSub.reset();
m_texNoZTestNoZWriteSub.reset();
m_texRedToAlphaZTestSub.reset();
m_texRedToAlphaNoZTestSub.reset();
for (auto& s : m_texZTestZWrite) s.reset();
for (auto& s : m_texNoZTestZWrite) s.reset();
for (auto& s : m_texZTestNoZWrite) s.reset();
for (auto& s : m_texNoZTestNoZWrite) s.reset();
for (auto& s : m_texAdditiveZTest) s.reset();
for (auto& s : m_texAdditiveNoZTest) s.reset();
for (auto& s : m_texRedToAlphaZTest) s.reset();
for (auto& s : m_texRedToAlphaNoZTest) s.reset();
for (auto& s : m_texZTestNoZWriteSub) s.reset();
for (auto& s : m_texNoZTestNoZWriteSub) s.reset();
for (auto& s : m_texRedToAlphaZTestSub) s.reset();
for (auto& s : m_texRedToAlphaNoZTestSub) s.reset();
m_indTexZWrite.reset();
m_indTexNoZWrite.reset();
m_indTexAdditive.reset();
for (auto& s : m_indTexZWrite) s.reset();
for (auto& s : m_indTexNoZWrite) s.reset();
for (auto& s : m_indTexAdditive) s.reset();
m_cindTexZWrite.reset();
m_cindTexNoZWrite.reset();
m_cindTexAdditive.reset();
for (auto& s : m_cindTexZWrite) s.reset();
for (auto& s : m_cindTexNoZWrite) s.reset();
for (auto& s : m_cindTexAdditive) s.reset();
m_noTexZTestZWrite.reset();
m_noTexNoZTestZWrite.reset();
m_noTexZTestNoZWrite.reset();
m_noTexNoZTestNoZWrite.reset();
m_noTexAdditiveZTest.reset();
m_noTexAdditiveNoZTest.reset();
for (auto& s : m_noTexZTestZWrite) s.reset();
for (auto& s : m_noTexNoZTestZWrite) s.reset();
for (auto& s : m_noTexZTestNoZWrite) s.reset();
for (auto& s : m_noTexNoZTestNoZWrite) s.reset();
for (auto& s : m_noTexAdditiveZTest) s.reset();
for (auto& s : m_noTexAdditiveNoZTest) s.reset();
}
CElementGenShaders::EShaderClass CElementGenShaders::GetShaderClass(CElementGen& gen) {
@ -106,97 +130,97 @@ CElementGenShaders::EShaderClass CElementGenShaders::GetShaderClass(CElementGen&
void CElementGenShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CElementGen& gen) {
CGenDescription* desc = gen.x1c_genDesc.GetObj();
boo::ObjToken<boo::IShaderPipeline> regPipeline;
boo::ObjToken<boo::IShaderPipeline> regPipelineSub;
boo::ObjToken<boo::IShaderPipeline> redToAlphaPipeline;
boo::ObjToken<boo::IShaderPipeline> redToAlphaPipelineSub;
boo::ObjToken<boo::IShaderPipeline> regPipelinePmus;
boo::ObjToken<boo::IShaderPipeline> redToAlphaPipelinePmus;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2>* regPipeline = nullptr;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2>* regPipelineSub = nullptr;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2>* redToAlphaPipeline = nullptr;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2>* redToAlphaPipelineSub = nullptr;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2>* regPipelinePmus = nullptr;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2>* redToAlphaPipelinePmus = nullptr;
if (desc->x54_x40_TEXR) {
if (desc->x58_x44_TIND) {
if (desc->x45_30_x32_24_CIND) {
if (gen.x26c_26_AAPH)
regPipeline = m_cindTexAdditive;
regPipeline = &m_cindTexAdditive;
else {
if (gen.x26c_27_ZBUF)
regPipeline = m_cindTexZWrite;
regPipeline = &m_cindTexZWrite;
else
regPipeline = m_cindTexNoZWrite;
regPipeline = &m_cindTexNoZWrite;
}
} else {
if (gen.x26c_26_AAPH)
regPipeline = m_indTexAdditive;
regPipeline = &m_indTexAdditive;
else {
if (gen.x26c_27_ZBUF)
regPipeline = m_indTexZWrite;
regPipeline = &m_indTexZWrite;
else
regPipeline = m_indTexNoZWrite;
regPipeline = &m_indTexNoZWrite;
}
}
} else {
if (gen.x26c_28_zTest) {
redToAlphaPipeline = m_texRedToAlphaZTest;
regPipelineSub = m_texZTestNoZWriteSub;
redToAlphaPipelineSub = m_texRedToAlphaZTestSub;
redToAlphaPipeline = &m_texRedToAlphaZTest;
regPipelineSub = &m_texZTestNoZWriteSub;
redToAlphaPipelineSub = &m_texRedToAlphaZTestSub;
} else {
redToAlphaPipeline = m_texRedToAlphaNoZTest;
regPipelineSub = m_texNoZTestNoZWriteSub;
redToAlphaPipelineSub = m_texRedToAlphaNoZTestSub;
redToAlphaPipeline = &m_texRedToAlphaNoZTest;
regPipelineSub = &m_texNoZTestNoZWriteSub;
redToAlphaPipelineSub = &m_texRedToAlphaNoZTestSub;
}
if (gen.x26c_26_AAPH) {
if (gen.x26c_28_zTest)
regPipeline = m_texAdditiveZTest;
regPipeline = &m_texAdditiveZTest;
else
regPipeline = m_texAdditiveNoZTest;
regPipeline = &m_texAdditiveNoZTest;
} else {
if (gen.x26c_28_zTest) {
if (gen.x26c_27_ZBUF)
regPipeline = m_texZTestZWrite;
regPipeline = &m_texZTestZWrite;
else
regPipeline = m_texZTestNoZWrite;
regPipeline = &m_texZTestNoZWrite;
} else {
if (gen.x26c_27_ZBUF)
regPipeline = m_texNoZTestZWrite;
regPipeline = &m_texNoZTestZWrite;
else
regPipeline = m_texNoZTestNoZWrite;
regPipeline = &m_texNoZTestNoZWrite;
}
}
}
} else {
if (gen.x26c_26_AAPH) {
if (gen.x26c_28_zTest)
regPipeline = m_noTexAdditiveZTest;
regPipeline = &m_noTexAdditiveZTest;
else
regPipeline = m_noTexAdditiveNoZTest;
regPipeline = &m_noTexAdditiveNoZTest;
} else {
if (gen.x26c_28_zTest) {
if (gen.x26c_27_ZBUF)
regPipeline = m_noTexZTestZWrite;
regPipeline = &m_noTexZTestZWrite;
else
regPipeline = m_noTexZTestNoZWrite;
regPipeline = &m_noTexZTestNoZWrite;
} else {
if (gen.x26c_27_ZBUF)
regPipeline = m_noTexNoZTestZWrite;
regPipeline = &m_noTexNoZTestZWrite;
else
regPipeline = m_noTexNoZTestNoZWrite;
regPipeline = &m_noTexNoZTestNoZWrite;
}
}
}
if (desc->x45_24_x31_26_PMUS) {
if (desc->x54_x40_TEXR) {
redToAlphaPipelinePmus = m_texRedToAlphaZTest;
redToAlphaPipelinePmus = &m_texRedToAlphaZTest;
if (desc->x44_31_x31_25_PMAB)
regPipelinePmus = m_texAdditiveZTest;
regPipelinePmus = &m_texAdditiveZTest;
else
regPipelinePmus = m_texZTestZWrite;
regPipelinePmus = &m_texZTestZWrite;
} else {
if (desc->x44_31_x31_25_PMAB)
regPipelinePmus = m_noTexAdditiveZTest;
regPipelinePmus = &m_noTexAdditiveZTest;
else
regPipelinePmus = m_noTexZTestZWrite;
regPipelinePmus = &m_noTexZTestZWrite;
}
}
@ -221,18 +245,24 @@ void CElementGenShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Conte
boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {gen.m_uniformBuf.get()};
if (regPipeline)
gen.m_normalDataBind = ctx.newShaderDataBinding(regPipeline, nullptr, gen.m_instBuf.get(), nullptr, 1, uniforms,
nullptr, texCount, textures, nullptr, nullptr);
for (int i = 0; i < 2; ++i)
gen.m_normalDataBind[i] = ctx.newShaderDataBinding((*regPipeline)[i], nullptr, gen.m_instBuf.get(), nullptr, 1,
uniforms, nullptr, texCount, textures, nullptr, nullptr);
if (regPipelineSub)
gen.m_normalSubDataBind = ctx.newShaderDataBinding(regPipelineSub, nullptr, gen.m_instBuf.get(), nullptr, 1,
uniforms, nullptr, texCount, textures, nullptr, nullptr);
for (int i = 0; i < 2; ++i)
gen.m_normalSubDataBind[i] = ctx.newShaderDataBinding((*regPipelineSub)[i], nullptr, gen.m_instBuf.get(),
nullptr, 1, uniforms, nullptr, texCount, textures,
nullptr, nullptr);
if (redToAlphaPipeline)
gen.m_redToAlphaDataBind = ctx.newShaderDataBinding(redToAlphaPipeline, nullptr, gen.m_instBuf.get(), nullptr, 1,
uniforms, nullptr, texCount, textures, nullptr, nullptr);
for (int i = 0; i < 2; ++i)
gen.m_redToAlphaDataBind[i] = ctx.newShaderDataBinding((*redToAlphaPipeline)[i], nullptr, gen.m_instBuf.get(),
nullptr, 1, uniforms, nullptr, texCount, textures,
nullptr, nullptr);
if (redToAlphaPipelineSub)
gen.m_redToAlphaSubDataBind =
ctx.newShaderDataBinding(redToAlphaPipelineSub, nullptr, gen.m_instBuf.get(), nullptr, 1, uniforms, nullptr,
texCount, textures, nullptr, nullptr);
for (int i = 0; i < 2; ++i)
gen.m_redToAlphaSubDataBind[i] =
ctx.newShaderDataBinding((*redToAlphaPipelineSub)[i], nullptr, gen.m_instBuf.get(), nullptr, 1, uniforms,
nullptr, texCount, textures, nullptr, nullptr);
}
if (gen.m_instBufPmus) {
@ -240,11 +270,14 @@ void CElementGenShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Conte
texCount = std::min(texCount, 1);
if (regPipelinePmus)
gen.m_normalDataBindPmus = ctx.newShaderDataBinding(regPipelinePmus, nullptr, gen.m_instBufPmus.get(), nullptr, 1,
uniforms, nullptr, texCount, textures, nullptr, nullptr);
for (int i = 0; i < 2; ++i)
gen.m_normalDataBindPmus[i] = ctx.newShaderDataBinding((*regPipelinePmus)[i], nullptr, gen.m_instBufPmus.get(),
nullptr, 1, uniforms, nullptr, texCount, textures,
nullptr, nullptr);
if (redToAlphaPipelinePmus)
gen.m_redToAlphaDataBindPmus =
ctx.newShaderDataBinding(redToAlphaPipelinePmus, nullptr, gen.m_instBufPmus.get(), nullptr, 1, uniforms,
for (int i = 0; i < 2; ++i)
gen.m_redToAlphaDataBindPmus[i] =
ctx.newShaderDataBinding((*redToAlphaPipelinePmus)[i], nullptr, gen.m_instBufPmus.get(), nullptr, 1, uniforms,
nullptr, texCount, textures, nullptr, nullptr);
}
}

View File

@ -11,33 +11,33 @@ public:
enum class EShaderClass { Tex, IndTex, NoTex };
private:
static boo::ObjToken<boo::IShaderPipeline> m_texZTestZWrite;
static boo::ObjToken<boo::IShaderPipeline> m_texNoZTestZWrite;
static boo::ObjToken<boo::IShaderPipeline> m_texZTestNoZWrite;
static boo::ObjToken<boo::IShaderPipeline> m_texNoZTestNoZWrite;
static boo::ObjToken<boo::IShaderPipeline> m_texAdditiveZTest;
static boo::ObjToken<boo::IShaderPipeline> m_texAdditiveNoZTest;
static boo::ObjToken<boo::IShaderPipeline> m_texRedToAlphaZTest;
static boo::ObjToken<boo::IShaderPipeline> m_texRedToAlphaNoZTest;
static boo::ObjToken<boo::IShaderPipeline> m_texZTestNoZWriteSub;
static boo::ObjToken<boo::IShaderPipeline> m_texNoZTestNoZWriteSub;
static boo::ObjToken<boo::IShaderPipeline> m_texRedToAlphaZTestSub;
static boo::ObjToken<boo::IShaderPipeline> m_texRedToAlphaNoZTestSub;
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texZTestZWrite;
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texNoZTestZWrite;
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texZTestNoZWrite;
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texNoZTestNoZWrite;
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texAdditiveZTest;
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texAdditiveNoZTest;
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texRedToAlphaZTest;
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texRedToAlphaNoZTest;
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texZTestNoZWriteSub;
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texNoZTestNoZWriteSub;
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texRedToAlphaZTestSub;
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texRedToAlphaNoZTestSub;
static boo::ObjToken<boo::IShaderPipeline> m_indTexZWrite;
static boo::ObjToken<boo::IShaderPipeline> m_indTexNoZWrite;
static boo::ObjToken<boo::IShaderPipeline> m_indTexAdditive;
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_indTexZWrite;
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_indTexNoZWrite;
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_indTexAdditive;
static boo::ObjToken<boo::IShaderPipeline> m_cindTexZWrite;
static boo::ObjToken<boo::IShaderPipeline> m_cindTexNoZWrite;
static boo::ObjToken<boo::IShaderPipeline> m_cindTexAdditive;
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_cindTexZWrite;
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_cindTexNoZWrite;
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_cindTexAdditive;
static boo::ObjToken<boo::IShaderPipeline> m_noTexZTestZWrite;
static boo::ObjToken<boo::IShaderPipeline> m_noTexNoZTestZWrite;
static boo::ObjToken<boo::IShaderPipeline> m_noTexZTestNoZWrite;
static boo::ObjToken<boo::IShaderPipeline> m_noTexNoZTestNoZWrite;
static boo::ObjToken<boo::IShaderPipeline> m_noTexAdditiveZTest;
static boo::ObjToken<boo::IShaderPipeline> m_noTexAdditiveNoZTest;
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexZTestZWrite;
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexNoZTestZWrite;
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexZTestNoZWrite;
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexNoZTestNoZWrite;
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexAdditiveZTest;
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexAdditiveNoZTest;
public:
static void Initialize();

View File

@ -205,7 +205,7 @@ void CFluidPlaneShader::prepareDraw(const RenderSetupInfo& info) {
for (int i = 0; i < 3; ++i)
uni.m_lighting.colorRegs[i] = info.kColors[i];
uni.m_lighting.mulColor = info.kColors[3];
uni.m_lighting.fog.m_rangeScale = info.indScale;
uni.m_pad2.x() = info.indScale;
m_uniBuf->unmap();
}

View File

@ -4,77 +4,86 @@
namespace urde {
boo::ObjToken<boo::IShaderPipeline> CLineRendererShaders::m_texAlpha;
boo::ObjToken<boo::IShaderPipeline> CLineRendererShaders::m_texAdditive;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CLineRendererShaders::m_texAlpha;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CLineRendererShaders::m_texAdditive;
boo::ObjToken<boo::IShaderPipeline> CLineRendererShaders::m_noTexAlpha;
boo::ObjToken<boo::IShaderPipeline> CLineRendererShaders::m_noTexAdditive;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CLineRendererShaders::m_noTexAlpha;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CLineRendererShaders::m_noTexAdditive;
boo::ObjToken<boo::IShaderPipeline> CLineRendererShaders::m_texAlphaZ;
boo::ObjToken<boo::IShaderPipeline> CLineRendererShaders::m_texAdditiveZ;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CLineRendererShaders::m_texAlphaZ;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CLineRendererShaders::m_texAdditiveZ;
boo::ObjToken<boo::IShaderPipeline> CLineRendererShaders::m_noTexAlphaZ;
boo::ObjToken<boo::IShaderPipeline> CLineRendererShaders::m_noTexAdditiveZ;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CLineRendererShaders::m_noTexAlphaZ;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CLineRendererShaders::m_noTexAdditiveZ;
boo::ObjToken<boo::IShaderPipeline> CLineRendererShaders::m_noTexAlphaZGEqual;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CLineRendererShaders::m_noTexAlphaZGEqual;
void CLineRendererShaders::Initialize() {
CGraphics::CommitResources([](boo::IGraphicsDataFactory::Context& ctx) {
m_texAlpha = hecl::conv->convert(ctx, Shader_CLineRendererShaderTexAlpha{});
m_texAdditive = hecl::conv->convert(ctx, Shader_CLineRendererShaderTexAdditive{});
m_noTexAlpha = hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAlpha{});
m_noTexAdditive = hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAdditive{});
m_texAlphaZ = hecl::conv->convert(ctx, Shader_CLineRendererShaderTexAlphaZ{});
m_texAdditiveZ = hecl::conv->convert(ctx, Shader_CLineRendererShaderTexAdditiveZ{});
m_noTexAlphaZ = hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAlphaZ{});
m_noTexAdditiveZ = hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAdditiveZ{});
m_noTexAlphaZGEqual = hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAlphaZGEqual{});
m_texAlpha = {hecl::conv->convert(ctx, Shader_CLineRendererShaderTexAlpha{}),
hecl::conv->convert(ctx, Shader_CLineRendererShaderTexAlphaAWrite{})};
m_texAdditive = {hecl::conv->convert(ctx, Shader_CLineRendererShaderTexAdditive{}),
hecl::conv->convert(ctx, Shader_CLineRendererShaderTexAdditiveAWrite{})};
m_noTexAlpha = {hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAlpha{}),
hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAlphaAWrite{})};
m_noTexAdditive = {hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAdditive{}),
hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAdditiveAWrite{})};
m_texAlphaZ = {hecl::conv->convert(ctx, Shader_CLineRendererShaderTexAlphaZ{}),
hecl::conv->convert(ctx, Shader_CLineRendererShaderTexAlphaZAWrite{})};
m_texAdditiveZ = {hecl::conv->convert(ctx, Shader_CLineRendererShaderTexAdditiveZ{}),
hecl::conv->convert(ctx, Shader_CLineRendererShaderTexAdditiveZAWrite{})};
m_noTexAlphaZ = {hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAlphaZ{}),
hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAlphaZAWrite{})};
m_noTexAdditiveZ = {hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAdditiveZ{}),
hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAdditiveZAWrite{})};
m_noTexAlphaZGEqual = {hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAlphaZGEqual{}),
hecl::conv->convert(ctx, Shader_CLineRendererShaderNoTexAlphaZGEqualAWrite{})};
return true;
} BooTrace);
}
void CLineRendererShaders::Shutdown() {
m_texAlpha.reset();
m_texAdditive.reset();
m_noTexAlpha.reset();
m_noTexAdditive.reset();
m_texAlphaZ.reset();
m_texAdditiveZ.reset();
m_noTexAlphaZ.reset();
m_noTexAdditiveZ.reset();
m_noTexAlphaZGEqual.reset();
for (auto& s : m_texAlpha) s.reset();
for (auto& s : m_texAdditive) s.reset();
for (auto& s : m_noTexAlpha) s.reset();
for (auto& s : m_noTexAdditive) s.reset();
for (auto& s : m_texAlphaZ) s.reset();
for (auto& s : m_texAdditiveZ) s.reset();
for (auto& s : m_noTexAlphaZ) s.reset();
for (auto& s : m_noTexAdditiveZ) s.reset();
for (auto& s : m_noTexAlphaZGEqual) s.reset();
}
void CLineRendererShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CLineRenderer& renderer,
const boo::ObjToken<boo::ITexture>& texture, bool additive,
bool zTest, bool zGEqual) {
boo::ObjToken<boo::IShaderPipeline> pipeline;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2>* pipeline = nullptr;
if (zGEqual) {
pipeline = m_noTexAlphaZGEqual;
pipeline = &m_noTexAlphaZGEqual;
} else if (zTest) {
if (texture) {
if (additive)
pipeline = m_texAdditiveZ;
pipeline = &m_texAdditiveZ;
else
pipeline = m_texAlphaZ;
pipeline = &m_texAlphaZ;
} else {
if (additive)
pipeline = m_noTexAdditiveZ;
pipeline = &m_noTexAdditiveZ;
else
pipeline = m_noTexAlphaZ;
pipeline = &m_noTexAlphaZ;
}
} else {
if (texture) {
if (additive)
pipeline = m_texAdditive;
pipeline = &m_texAdditive;
else
pipeline = m_texAlpha;
pipeline = &m_texAlpha;
} else {
if (additive)
pipeline = m_noTexAdditive;
pipeline = &m_noTexAdditive;
else
pipeline = m_noTexAlpha;
pipeline = &m_noTexAlpha;
}
}
@ -94,12 +103,13 @@ void CLineRendererShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Con
}
boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {ubufInfo.first.get()};
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
boo::PipelineStage stages[] = {boo::PipelineStage::Fragment};
size_t ubufOffs[] = {size_t(ubufInfo.second)};
size_t ubufSizes[] = {sizeof(CLineRenderer::SDrawUniform)};
renderer.m_shaderBind =
ctx.newShaderDataBinding(pipeline, vbufInfo.first.get(), nullptr, nullptr, 1, uniforms, stages, ubufOffs,
for (int i = 0; i < 2; ++i)
renderer.m_shaderBind[i] =
ctx.newShaderDataBinding((*pipeline)[i], vbufInfo.first.get(), nullptr, nullptr, 1, uniforms, stages, ubufOffs,
ubufSizes, texCount, textures, nullptr, nullptr, vbufInfo.second);
}

View File

@ -7,19 +7,19 @@ namespace urde {
class CLineRenderer;
class CLineRendererShaders {
static boo::ObjToken<boo::IShaderPipeline> m_texAlpha;
static boo::ObjToken<boo::IShaderPipeline> m_texAdditive;
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texAlpha;
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texAdditive;
static boo::ObjToken<boo::IShaderPipeline> m_noTexAlpha;
static boo::ObjToken<boo::IShaderPipeline> m_noTexAdditive;
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexAlpha;
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexAdditive;
static boo::ObjToken<boo::IShaderPipeline> m_texAlphaZ;
static boo::ObjToken<boo::IShaderPipeline> m_texAdditiveZ;
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texAlphaZ;
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texAdditiveZ;
static boo::ObjToken<boo::IShaderPipeline> m_noTexAlphaZ;
static boo::ObjToken<boo::IShaderPipeline> m_noTexAdditiveZ;
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexAlphaZ;
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexAdditiveZ;
static boo::ObjToken<boo::IShaderPipeline> m_noTexAlphaZGEqual;
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexAlphaZGEqual;
public:
static void Initialize();

View File

@ -12,30 +12,31 @@ extern const hecl::Backend::Function ExtensionPostFuncsGLSL[];
"{\n" \
" int mode;\n" \
" vec4 color;\n" \
" float rangeScale;\n" \
" float start;\n" \
" float A;\n" \
" float B;\n" \
" float C;\n" \
"};\n"
#define FOG_ALGORITHM_GLSL \
" float fogZ, temp;\n" \
" 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 = (-vtf.mvPos.z - fog.start) * fog.rangeScale;\n" \
" fogZ = fogF;\n" \
" break;\n" \
" case 4:\n" \
" fogZ = 1.0 - exp2(-8.0 * (-vtf.mvPos.z - fog.start) * fog.rangeScale);\n" \
" fogZ = 1.0 - exp2(-8.0 * fogF);\n" \
" break;\n" \
" case 5:\n" \
" temp = (-vtf.mvPos.z - fog.start) * fog.rangeScale;\n" \
" fogZ = 1.0 - exp2(-8.0 * temp * temp);\n" \
" fogZ = 1.0 - exp2(-8.0 * fogF * fogF);\n" \
" break;\n" \
" case 6:\n" \
" fogZ = exp2(-8.0 * (fog.start + vtf.mvPos.z) * fog.rangeScale);\n" \
" fogZ = exp2(-8.0 * (1.0 - fogF));\n" \
" break;\n" \
" case 7:\n" \
" temp = (fog.start + vtf.mvPos.z) * fog.rangeScale;\n" \
" fogZ = exp2(-8.0 * temp * temp);\n" \
" fogF = 1.0 - fogF;\n" \
" fogZ = exp2(-8.0 * fogF * fogF);\n" \
" break;\n" \
" default:\n" \
" fogZ = 0.0;\n" \
@ -101,13 +102,7 @@ static std::string_view LightingShadowGLSL =
" 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"

View File

@ -5,38 +5,46 @@
namespace urde {
boo::ObjToken<boo::IShaderPipeline> CParticleSwooshShaders::m_texZWrite;
boo::ObjToken<boo::IShaderPipeline> CParticleSwooshShaders::m_texNoZWrite;
boo::ObjToken<boo::IShaderPipeline> CParticleSwooshShaders::m_texAdditiveZWrite;
boo::ObjToken<boo::IShaderPipeline> CParticleSwooshShaders::m_texAdditiveNoZWrite;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CParticleSwooshShaders::m_texZWrite;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CParticleSwooshShaders::m_texNoZWrite;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CParticleSwooshShaders::m_texAdditiveZWrite;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CParticleSwooshShaders::m_texAdditiveNoZWrite;
boo::ObjToken<boo::IShaderPipeline> CParticleSwooshShaders::m_noTexZWrite;
boo::ObjToken<boo::IShaderPipeline> CParticleSwooshShaders::m_noTexNoZWrite;
boo::ObjToken<boo::IShaderPipeline> CParticleSwooshShaders::m_noTexAdditiveZWrite;
boo::ObjToken<boo::IShaderPipeline> CParticleSwooshShaders::m_noTexAdditiveNoZWrite;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CParticleSwooshShaders::m_noTexZWrite;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CParticleSwooshShaders::m_noTexNoZWrite;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CParticleSwooshShaders::m_noTexAdditiveZWrite;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CParticleSwooshShaders::m_noTexAdditiveNoZWrite;
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
void CParticleSwooshShaders::Initialize() {
m_texZWrite = hecl::conv->convert(Shader_CParticleSwooshShaderTexZWrite{});
m_texNoZWrite = hecl::conv->convert(Shader_CParticleSwooshShaderTexNoZWrite{});
m_texAdditiveZWrite = hecl::conv->convert(Shader_CParticleSwooshShaderTexAdditiveZWrite{});
m_texAdditiveNoZWrite = hecl::conv->convert(Shader_CParticleSwooshShaderTexAdditiveNoZWrite{});
m_noTexZWrite = hecl::conv->convert(Shader_CParticleSwooshShaderNoTexZWrite{});
m_noTexNoZWrite = hecl::conv->convert(Shader_CParticleSwooshShaderNoTexNoZWrite{});
m_noTexAdditiveZWrite = hecl::conv->convert(Shader_CParticleSwooshShaderNoTexAdditiveZWrite{});
m_noTexAdditiveNoZWrite = hecl::conv->convert(Shader_CParticleSwooshShaderNoTexAdditiveNoZWrite{});
m_texZWrite = {hecl::conv->convert(Shader_CParticleSwooshShaderTexZWrite{}),
hecl::conv->convert(Shader_CParticleSwooshShaderTexZWriteAWrite{})};
m_texNoZWrite = {hecl::conv->convert(Shader_CParticleSwooshShaderTexNoZWrite{}),
hecl::conv->convert(Shader_CParticleSwooshShaderTexNoZWriteAWrite{})};
m_texAdditiveZWrite = {hecl::conv->convert(Shader_CParticleSwooshShaderTexAdditiveZWrite{}),
hecl::conv->convert(Shader_CParticleSwooshShaderTexAdditiveZWriteAWrite{})};
m_texAdditiveNoZWrite = {hecl::conv->convert(Shader_CParticleSwooshShaderTexAdditiveNoZWrite{}),
hecl::conv->convert(Shader_CParticleSwooshShaderTexAdditiveNoZWriteAWrite{})};
m_noTexZWrite = {hecl::conv->convert(Shader_CParticleSwooshShaderNoTexZWrite{}),
hecl::conv->convert(Shader_CParticleSwooshShaderNoTexZWriteAWrite{})};
m_noTexNoZWrite = {hecl::conv->convert(Shader_CParticleSwooshShaderNoTexNoZWrite{}),
hecl::conv->convert(Shader_CParticleSwooshShaderNoTexNoZWriteAWrite{})};
m_noTexAdditiveZWrite = {hecl::conv->convert(Shader_CParticleSwooshShaderNoTexAdditiveZWrite{}),
hecl::conv->convert(Shader_CParticleSwooshShaderNoTexAdditiveZWriteAWrite{})};
m_noTexAdditiveNoZWrite = {hecl::conv->convert(Shader_CParticleSwooshShaderNoTexAdditiveNoZWrite{}),
hecl::conv->convert(Shader_CParticleSwooshShaderNoTexAdditiveNoZWriteAWrite{})};
}
void CParticleSwooshShaders::Shutdown() {
m_texZWrite.reset();
m_texNoZWrite.reset();
m_texAdditiveZWrite.reset();
m_texAdditiveNoZWrite.reset();
m_noTexZWrite.reset();
m_noTexNoZWrite.reset();
m_noTexAdditiveZWrite.reset();
m_noTexAdditiveNoZWrite.reset();
for (auto& s : m_texZWrite) s.reset();
for (auto& s : m_texNoZWrite) s.reset();
for (auto& s : m_texAdditiveZWrite) s.reset();
for (auto& s : m_texAdditiveNoZWrite) s.reset();
for (auto& s : m_noTexZWrite) s.reset();
for (auto& s : m_noTexNoZWrite) s.reset();
for (auto& s : m_noTexAdditiveZWrite) s.reset();
for (auto& s : m_noTexAdditiveNoZWrite) s.reset();
}
CParticleSwooshShaders::EShaderClass CParticleSwooshShaders::GetShaderClass(CParticleSwoosh& gen) {
@ -50,31 +58,31 @@ CParticleSwooshShaders::EShaderClass CParticleSwooshShaders::GetShaderClass(CPar
void CParticleSwooshShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CParticleSwoosh& gen) {
CSwooshDescription* desc = gen.GetDesc();
boo::ObjToken<boo::IShaderPipeline> pipeline;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2>* pipeline = nullptr;
if (desc->x3c_TEXR) {
if (desc->x44_31_AALP) {
if (desc->x45_24_ZBUF)
pipeline = m_texAdditiveZWrite;
pipeline = &m_texAdditiveZWrite;
else
pipeline = m_texAdditiveNoZWrite;
pipeline = &m_texAdditiveNoZWrite;
} else {
if (desc->x45_24_ZBUF)
pipeline = m_texZWrite;
pipeline = &m_texZWrite;
else
pipeline = m_texNoZWrite;
pipeline = &m_texNoZWrite;
}
} else {
if (desc->x44_31_AALP) {
if (desc->x45_24_ZBUF)
pipeline = m_noTexAdditiveZWrite;
pipeline = &m_noTexAdditiveZWrite;
else
pipeline = m_noTexAdditiveNoZWrite;
pipeline = &m_noTexAdditiveNoZWrite;
} else {
if (desc->x45_24_ZBUF)
pipeline = m_noTexZWrite;
pipeline = &m_noTexZWrite;
else
pipeline = m_noTexNoZWrite;
pipeline = &m_noTexNoZWrite;
}
}
@ -82,8 +90,9 @@ void CParticleSwooshShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::C
boo::ObjToken<boo::ITexture> textures[] = {texr ? texr->GetValueTexture(0).GetObj()->GetBooTexture() : nullptr};
boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {gen.m_uniformBuf.get()};
gen.m_dataBind = ctx.newShaderDataBinding(pipeline, gen.m_vertBuf.get(), nullptr, nullptr, 1, uniforms, nullptr,
texr ? 1 : 0, textures, nullptr, nullptr);
for (int i = 0; i < 2; ++i)
gen.m_dataBind[i] = ctx.newShaderDataBinding((*pipeline)[i], gen.m_vertBuf.get(), nullptr, nullptr, 1, uniforms,
nullptr, texr ? 1 : 0, textures, nullptr, nullptr);
}
} // namespace urde

View File

@ -17,15 +17,15 @@ public:
};
private:
static boo::ObjToken<boo::IShaderPipeline> m_texZWrite;
static boo::ObjToken<boo::IShaderPipeline> m_texNoZWrite;
static boo::ObjToken<boo::IShaderPipeline> m_texAdditiveZWrite;
static boo::ObjToken<boo::IShaderPipeline> m_texAdditiveNoZWrite;
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texZWrite;
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texNoZWrite;
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texAdditiveZWrite;
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_texAdditiveNoZWrite;
static boo::ObjToken<boo::IShaderPipeline> m_noTexZWrite;
static boo::ObjToken<boo::IShaderPipeline> m_noTexNoZWrite;
static boo::ObjToken<boo::IShaderPipeline> m_noTexAdditiveZWrite;
static boo::ObjToken<boo::IShaderPipeline> m_noTexAdditiveNoZWrite;
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexZWrite;
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexNoZWrite;
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexAdditiveZWrite;
static std::array<boo::ObjToken<boo::IShaderPipeline>, 2> m_noTexAdditiveNoZWrite;
public:
static void Initialize();

View File

@ -9,6 +9,8 @@
#include "Graphics/Shaders/CElementGenShaders.hpp"
#include "Character/CActorLights.hpp"
#include "CWarp.hpp"
#include "GameGlobalObjects.hpp"
#include "Graphics/CBooRenderer.hpp"
#define MAX_GLOBAL_PARTICLES 2560
@ -881,9 +883,9 @@ void CElementGen::RenderModels(const CActorLights* actorLights) {
m_uniformBufPmus->load(&uniformData, sizeof(SParticleUniforms));
if (moveRedToAlphaBuffer)
CGraphics::SetShaderDataBinding(m_redToAlphaDataBindPmus);
CGraphics::SetShaderDataBinding(m_redToAlphaDataBindPmus[g_Renderer->IsThermalVisorHotPass()]);
else
CGraphics::SetShaderDataBinding(m_normalDataBindPmus);
CGraphics::SetShaderDataBinding(m_normalDataBindPmus[g_Renderer->IsThermalVisorHotPass()]);
}
zeus::CTransform orient = zeus::CTransform();
@ -1149,7 +1151,7 @@ void CElementGen::RenderLines() {
}
}
m_lineRenderer->Render(moduColor);
m_lineRenderer->Render(g_Renderer->IsThermalVisorHotPass(), moduColor);
}
void CElementGen::RenderParticles() {
@ -1234,14 +1236,14 @@ void CElementGen::RenderParticles() {
if (g_subtractBlend) {
if (moveRedToAlphaBuffer)
CGraphics::SetShaderDataBinding(m_redToAlphaSubDataBind);
CGraphics::SetShaderDataBinding(m_redToAlphaSubDataBind[g_Renderer->IsThermalVisorHotPass()]);
else
CGraphics::SetShaderDataBinding(m_normalSubDataBind);
CGraphics::SetShaderDataBinding(m_normalSubDataBind[g_Renderer->IsThermalVisorHotPass()]);
} else {
if (moveRedToAlphaBuffer)
CGraphics::SetShaderDataBinding(m_redToAlphaDataBind);
CGraphics::SetShaderDataBinding(m_redToAlphaDataBind[g_Renderer->IsThermalVisorHotPass()]);
else
CGraphics::SetShaderDataBinding(m_normalDataBind);
CGraphics::SetShaderDataBinding(m_normalDataBind[g_Renderer->IsThermalVisorHotPass()]);
}
int mbspVal = std::max(1, x270_MBSP);
@ -1657,7 +1659,7 @@ void CElementGen::RenderParticlesIndirectTexture() {
g_instIndTexData.reserve(x30_particles.size());
if (!x30_particles.empty())
CGraphics::SetShaderDataBinding(m_normalDataBind);
CGraphics::SetShaderDataBinding(m_normalDataBind[g_Renderer->IsThermalVisorHotPass()]);
for (int i = 0; i < x30_particles.size(); ++i) {
int partIdx = desc->x44_28_x30_28_SORT ? sortItems[i].x0_partIdx : i;

View File

@ -144,15 +144,15 @@ public:
EOptionalSystemFlags flags = EOptionalSystemFlags::One);
~CElementGen();
boo::ObjToken<boo::IShaderDataBinding> m_normalDataBind;
boo::ObjToken<boo::IShaderDataBinding> m_normalSubDataBind;
boo::ObjToken<boo::IShaderDataBinding> m_redToAlphaDataBind;
boo::ObjToken<boo::IShaderDataBinding> m_redToAlphaSubDataBind;
boo::ObjToken<boo::IShaderDataBinding> m_normalDataBind[2];
boo::ObjToken<boo::IShaderDataBinding> m_normalSubDataBind[2];
boo::ObjToken<boo::IShaderDataBinding> m_redToAlphaDataBind[2];
boo::ObjToken<boo::IShaderDataBinding> m_redToAlphaSubDataBind[2];
boo::ObjToken<boo::IGraphicsBufferD> m_instBuf;
boo::ObjToken<boo::IGraphicsBufferD> m_uniformBuf;
boo::ObjToken<boo::IShaderDataBinding> m_normalDataBindPmus;
boo::ObjToken<boo::IShaderDataBinding> m_redToAlphaDataBindPmus;
boo::ObjToken<boo::IShaderDataBinding> m_normalDataBindPmus[2];
boo::ObjToken<boo::IShaderDataBinding> m_redToAlphaDataBindPmus[2];
boo::ObjToken<boo::IGraphicsBufferD> m_instBufPmus;
boo::ObjToken<boo::IGraphicsBufferD> m_uniformBufPmus;

View File

@ -9,6 +9,8 @@
#include "CParticleGlobals.hpp"
#include "zeus/CRelAngle.hpp"
#include "zeus/CQuaternion.hpp"
#include "GameGlobalObjects.hpp"
#include "Graphics/CBooRenderer.hpp"
namespace urde {
@ -96,7 +98,7 @@ void CParticleElectric::DrawLineStrip(const std::vector<zeus::CVector3f>& verts,
renderer.Reset();
for (const zeus::CVector3f& vert : verts)
renderer.AddVertex(vert, useColor, width);
renderer.Render();
renderer.Render(g_Renderer->IsThermalVisorHotPass());
}
void CParticleElectric::RenderLines() {

View File

@ -1,6 +1,8 @@
#include "CParticleSwoosh.hpp"
#include "CSwooshDescription.hpp"
#include "CParticleGlobals.hpp"
#include "GameGlobalObjects.hpp"
#include "Graphics/CBooRenderer.hpp"
#include <chrono>
namespace urde {
@ -441,7 +443,7 @@ void CParticleSwoosh::RenderNSidedSpline() {
}
if (x1bc_prim == GX::LINES)
m_lineRenderer->Render();
m_lineRenderer->Render(g_Renderer->IsThermalVisorHotPass());
}
void CParticleSwoosh::RenderNSidedNoSpline() { RenderNSidedSpline(); }
@ -870,8 +872,8 @@ void CParticleSwoosh::Render(const CActorLights*) {
return;
m_cachedVerts.clear();
if (m_dataBind)
CGraphics::SetShaderDataBinding(m_dataBind);
if (m_dataBind[0])
CGraphics::SetShaderDataBinding(m_dataBind[g_Renderer->IsThermalVisorHotPass()]);
CParticleGlobals::SetParticleLifetime(x1b4_LENG);
CGlobalRandom gr(x1c0_rand);

View File

@ -100,7 +100,7 @@ class CParticleSwoosh : public CParticleGen {
float x208_maxRadius = 0.f;
zeus::CColor x20c_moduColor = zeus::skWhite;
boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
boo::ObjToken<boo::IShaderDataBinding> m_dataBind[2];
boo::ObjToken<boo::IGraphicsBufferD> m_vertBuf;
boo::ObjToken<boo::IGraphicsBufferD> m_uniformBuf;
std::unique_ptr<CLineRenderer> m_lineRenderer;

View File

@ -175,8 +175,8 @@ void CEnvFxManager::CalculateSnowForces(const CVectorFixed8_8& zVec,
void CEnvFxManager::BuildBlockObjectList(rstl::reserved_vector<TUniqueId, 1024>& list, CStateManager& mgr) {
for (CEntity* ent : mgr.GetAllObjectList()) {
if (TCastToPtr<CScriptTrigger> trig = ent) {
if ((trig->GetTriggerFlags() & ETriggerFlags::BlockEnvironmentalEffects) != ETriggerFlags::None)
TCastToPtr<CScriptTrigger> trig = ent;
if (trig && (trig->GetTriggerFlags() & ETriggerFlags::BlockEnvironmentalEffects) != ETriggerFlags::None) {
list.push_back(ent->GetUniqueId());
} else if (TCastToPtr<CScriptWater> water = ent) {
list.push_back(ent->GetUniqueId());
@ -406,7 +406,7 @@ void CEnvFxManagerGrid::RenderRainParticles(const zeus::CTransform& camXf) const
m_lineRenderer.AddVertex(pos0, zeus::skWhite, 1.f, {0.f, uvy0});
m_lineRenderer.AddVertex(pos1, zeus::skClear, 1.f, {0.f, uvy1});
}
m_lineRenderer.Render(zeus::CColor(1.f, 0.15f));
m_lineRenderer.Render(g_Renderer->IsThermalVisorHotPass(), zeus::CColor(1.f, 0.15f));
}
void CEnvFxManagerGrid::RenderUnderwaterParticles(const zeus::CTransform& camXf) const {

View File

@ -13,6 +13,7 @@
#primitive tristrips
#depthtest lequal
#depthwrite true
#alphawrite false
#culling none
#vertex glsl
@ -149,47 +150,79 @@ fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
return vtf.color * tex0.sample(samp, vtf.uv);
}
#shader CElementGenShaderTexZTestZWriteAWrite : CElementGenShaderTexZTestZWrite
#alphawrite true
#shader CElementGenShaderTexNoZTestZWrite : CElementGenShaderTexZTestZWrite
#depthtest none
#depthwrite true
#alphawrite false
#shader CElementGenShaderTexNoZTestZWriteAWrite : CElementGenShaderTexNoZTestZWrite
#alphawrite true
#shader CElementGenShaderTexZTestNoZWrite : CElementGenShaderTexZTestZWrite
#depthtest lequal
#depthwrite false
#alphawrite false
#shader CElementGenShaderTexZTestNoZWriteAWrite : CElementGenShaderTexZTestNoZWrite
#alphawrite true
#shader CElementGenShaderTexNoZTestNoZWrite : CElementGenShaderTexZTestZWrite
#depthtest none
#depthwrite false
#alphawrite false
#shader CElementGenShaderTexNoZTestNoZWriteAWrite : CElementGenShaderTexNoZTestNoZWrite
#alphawrite true
#shader CElementGenShaderTexAdditiveZTest : CElementGenShaderTexZTestZWrite
#srcfac srcalpha
#dstfac one
#depthtest lequal
#depthwrite false
#alphawrite false
#shader CElementGenShaderTexAdditiveZTestAWrite : CElementGenShaderTexAdditiveZTest
#alphawrite true
#shader CElementGenShaderTexAdditiveNoZTest : CElementGenShaderTexZTestZWrite
#srcfac srcalpha
#dstfac one
#depthtest none
#depthwrite false
#alphawrite false
#shader CElementGenShaderTexAdditiveNoZTestAWrite : CElementGenShaderTexAdditiveNoZTest
#alphawrite true
#shader CElementGenShaderTexZTestNoZWriteSub : CElementGenShaderTexZTestZWrite
#srcfac subtract
#dstfac subtract
#depthtest lequal
#depthwrite false
#alphawrite false
#shader CElementGenShaderTexZTestNoZWriteSubAWrite : CElementGenShaderTexZTestNoZWriteSub
#alphawrite true
#shader CElementGenShaderTexNoZTestNoZWriteSub : CElementGenShaderTexZTestZWrite
#srcfac subtract
#dstfac subtract
#depthtest none
#depthwrite false
#alphawrite false
#shader CElementGenShaderTexNoZTestNoZWriteSubAWrite : CElementGenShaderTexNoZTestNoZWriteSub
#alphawrite true
#shader CElementGenShaderTexRedToAlphaZTest : CElementGenShaderTexZTestZWrite
#srcfac srcalpha
#dstfac invsrcalpha
#srcfac one
#dstfac one
#depthtest lequal
#depthwrite false
#alphawrite false
#fragment glsl
struct VertToFrag
@ -203,8 +236,10 @@ layout(location=0) out vec4 colorOut;
TBINDING0 uniform sampler2D tex;
void main()
{
colorOut = vtf.color;
colorOut.a = texture(tex, vtf.uv).r;
vec4 texel = texture(tex, vtf.uv);
vec4 tmp = texel * vtf.color;
colorOut = tmp * tmp.a;
colorOut.a = tmp.a * texel.r;
}
#fragment hlsl
@ -219,7 +254,9 @@ struct VertToFrag
float4 main(in VertToFrag vtf) : SV_Target0
{
return float4(vtf.color.rgb, tex0.Sample(samp, vtf.uv).r);
float4 texel = tex0.Sample(samp, vtf.uv);
float4 tmp = texel * vtf.color;
return float4(tmp * tmp.a, tmp.a * texel.r);
}
#fragment metal
@ -234,21 +271,38 @@ fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
sampler samp [[ sampler(0) ]],
texture2d<float> tex0 [[ texture(0) ]])
{
return float4(vtf.color.rgb, tex0.sample(samp, vtf.uv).r);
float4 texel = tex0.sample(samp, vtf.uv);
float4 tmp = texel * vtf.color;
return float4(tmp * tmp.a, tmp.a * texel.r);
}
#shader CElementGenShaderTexRedToAlphaZTestAWrite : CElementGenShaderTexRedToAlphaZTest
#alphawrite true
#shader CElementGenShaderTexRedToAlphaNoZTest : CElementGenShaderTexRedToAlphaZTest
#depthtest none
#alphawrite false
#shader CElementGenShaderTexRedToAlphaNoZTestAWrite : CElementGenShaderTexRedToAlphaNoZTest
#alphawrite true
#shader CElementGenShaderTexRedToAlphaZTestSub : CElementGenShaderTexRedToAlphaZTest
#srcfac subtract
#dstfac subtract
#depthtest lequal
#alphawrite false
#shader CElementGenShaderTexRedToAlphaZTestSubAWrite : CElementGenShaderTexRedToAlphaZTestSub
#alphawrite true
#shader CElementGenShaderTexRedToAlphaNoZTestSub : CElementGenShaderTexRedToAlphaZTest
#srcfac subtract
#dstfac subtract
#depthtest none
#alphawrite false
#shader CElementGenShaderTexRedToAlphaNoZTestSubAWrite : CElementGenShaderTexRedToAlphaNoZTestSub
#alphawrite true
#shader CElementGenShaderIndTexZWrite
#instattribute position4 0
@ -265,6 +319,7 @@ fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
#dstfac invsrcalpha
#depthtest none
#depthwrite true
#alphawrite false
#vertex glsl
layout(location=0) in vec4 posIn[4];
@ -444,19 +499,31 @@ fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
return float4(colr.rgb, vtf.color.a * texrTexel.a);
}
#shader CElementGenShaderIndTexZWriteAWrite : CElementGenShaderIndTexZWrite
#alphawrite true
#shader CElementGenShaderIndTexNoZWrite : CElementGenShaderIndTexZWrite
#depthwrite false
#alphawrite false
#shader CElementGenShaderIndTexNoZWriteAWrite : CElementGenShaderIndTexNoZWrite
#alphawrite true
#shader CElementGenShaderIndTexAdditive : CElementGenShaderIndTexZWrite
#depthwrite true
#srcfac srcalpha
#dstfac one
#alphawrite false
#shader CElementGenShaderIndTexAdditiveAWrite : CElementGenShaderIndTexAdditive
#alphawrite true
#shader CElementGenShaderCindTexZWrite : CElementGenShaderIndTexZWrite
#srcfac srcalpha
#dstfac invsrcalpha
#depthtest none
#depthwrite true
#alphawrite false
#fragment glsl
struct VertToFrag
@ -521,13 +588,24 @@ fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
return vtf.color * float4(sceneTexel.rgb, 1.0) * tex0.sample(samp, vtf.uvTexr);
}
#shader CElementGenShaderCindTexZWriteAWrite : CElementGenShaderCindTexZWrite
#alphawrite true
#shader CElementGenShaderCindTexNoZWrite : CElementGenShaderCindTexZWrite
#depthwrite false
#alphawrite false
#shader CElementGenShaderCindTexNoZWriteAWrite : CElementGenShaderCindTexNoZWrite
#alphawrite true
#shader CElementGenShaderCindTexAdditive : CElementGenShaderCindTexZWrite
#depthwrite true
#srcfac srcalpha
#dstfac one
#alphawrite false
#shader CElementGenShaderCindTexAdditiveAWrite : CElementGenShaderCindTexAdditive
#alphawrite true
#shader CElementGenShaderNoTexZTestZWrite
#instattribute position4 0
@ -541,6 +619,7 @@ fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
#depthtest lequal
#depthwrite true
#culling none
#alphawrite false
#vertex glsl
layout(location=0) in vec4 posIn[4];
@ -659,26 +738,49 @@ fragment float4 fmain(VertToFrag vtf [[ stage_in ]])
return vtf.color;
}
#shader CElementGenShaderNoTexZTestZWriteAWrite : CElementGenShaderNoTexZTestZWrite
#alphawrite true
#shader CElementGenShaderNoTexNoZTestZWrite : CElementGenShaderNoTexZTestZWrite
#depthtest none
#depthwrite true
#alphawrite false
#shader CElementGenShaderNoTexNoZTestZWriteAWrite : CElementGenShaderNoTexNoZTestZWrite
#alphawrite true
#shader CElementGenShaderNoTexZTestNoZWrite : CElementGenShaderNoTexZTestZWrite
#depthtest lequal
#depthwrite false
#alphawrite false
#shader CElementGenShaderNoTexZTestNoZWriteAWrite : CElementGenShaderNoTexZTestNoZWrite
#alphawrite true
#shader CElementGenShaderNoTexNoZTestNoZWrite : CElementGenShaderNoTexZTestZWrite
#depthtest none
#depthwrite false
#alphawrite false
#shader CElementGenShaderNoTexNoZTestNoZWriteAWrite : CElementGenShaderNoTexNoZTestNoZWrite
#alphawrite true
#shader CElementGenShaderNoTexAdditiveZTest : CElementGenShaderNoTexZTestZWrite
#srcfac srcalpha
#dstfac one
#depthtest lequal
#depthwrite false
#alphawrite false
#shader CElementGenShaderNoTexAdditiveZTestAWrite : CElementGenShaderNoTexAdditiveZTest
#alphawrite true
#shader CElementGenShaderNoTexAdditiveNoZTest : CElementGenShaderNoTexZTestZWrite
#srcfac srcalpha
#dstfac one
#depthtest none
#depthwrite false
#alphawrite false
#shader CElementGenShaderNoTexAdditiveNoZTestAWrite : CElementGenShaderNoTexAdditiveNoZTest
#alphawrite true

View File

@ -66,37 +66,38 @@ UBINDING1 uniform FogUniform
{
int mode;
vec4 color;
float rangeScale;
float start;
float A;
float B;
float C;
};
vec4 MainPostFunc(vec4 colorIn)
{
float fogZ, temp;
float fogZ;
float fogF = clamp((A / (B - gl_FragCoord.z)) - C, 0.0, 1.0);
switch (mode)
{
case 2:
fogZ = (-vtf.mvPos.z - start) * rangeScale;
fogZ = fogF;
break;
case 4:
fogZ = 1.0 - exp2(-8.0 * (-vtf.mvPos.z - start) * rangeScale);
fogZ = 1.0 - exp2(-8.0 * fogF);
break;
case 5:
temp = (-vtf.mvPos.z - start) * rangeScale;
fogZ = 1.0 - exp2(-8.0 * temp * temp);
fogZ = 1.0 - exp2(-8.0 * fogF * fogF);
break;
case 6:
fogZ = exp2(-8.0 * (start + vtf.mvPos.z) * rangeScale);
fogZ = exp2(-8.0 * (1.0 - fogF));
break;
case 7:
temp = (start + vtf.mvPos.z) * rangeScale;
fogZ = exp2(-8.0 * temp * temp);
fogF = 1.0 - fogF;
fogZ = exp2(-8.0 * fogF * fogF);
break;
default:
fogZ = 0.0;
break;
}
return vec4(mix(colorIn, color, clamp(fogZ, 0.0, 1.0)).rgb, colorIn.a);
return vec4(mix(colorIn, vec4(0.0), clamp(fogZ, 0.0, 1.0)).rgb, colorIn.a);
}
void main()
@ -159,37 +160,38 @@ cbuffer FogUniform : register(b1)
{
int mode;
float4 color;
float rangeScale;
float start;
float A;
float B;
float C;
};
static float4 MainPostFunc(in VertToFrag vtf, float4 colorIn)
{
float fogZ, temp;
float fogZ;
float fogF = saturate((A / (B - vtf.position.z)) - C);
switch (mode)
{
case 2:
fogZ = (-vtf.mvPos.z - start) * rangeScale;
fogZ = fogF;
break;
case 4:
fogZ = 1.0 - exp2(-8.0 * (-vtf.mvPos.z - start) * rangeScale);
fogZ = 1.0 - exp2(-8.0 * fogF);
break;
case 5:
temp = (-vtf.mvPos.z - start) * rangeScale;
fogZ = 1.0 - exp2(-8.0 * temp * temp);
fogZ = 1.0 - exp2(-8.0 * fogF * fogF);
break;
case 6:
fogZ = exp2(-8.0 * (start + vtf.mvPos.z) * rangeScale);
fogZ = exp2(-8.0 * (1.0 - fogF));
break;
case 7:
temp = (start + vtf.mvPos.z) * rangeScale;
fogZ = exp2(-8.0 * temp * temp);
fogF = 1.0 - fogF;
fogZ = exp2(-8.0 * fogF * fogF);
break;
default:
fogZ = 0.0;
break;
}
return float4(lerp(colorIn, color, saturate(fogZ)).rgb, colorIn.a);
return float4(lerp(colorIn, float4(0.0,0.0,0.0,0.0), saturate(fogZ)).rgb, colorIn.a);
}
float4 main(in VertToFrag vtf) : SV_Target0
@ -251,37 +253,38 @@ struct FogUniform
{
int mode;
float4 color;
float rangeScale;
float start;
float A;
float B;
float C;
};
float4 MainPostFunc(thread VertToFrag& vtf, constant FogUniform& fu, float4 colorIn)
{
float fogZ, temp;
float fogZ;
float fogF = saturate((fu.A / (fu.B - vtf.position.z)) - fu.C);
switch (fu.mode)
{
case 2:
fogZ = (-vtf.mvPos.z - fu.start) * fu.rangeScale;
fogZ = fogF;
break;
case 4:
fogZ = 1.0 - exp2(-8.0 * (-vtf.mvPos.z - fu.start) * fu.rangeScale);
fogZ = 1.0 - exp2(-8.0 * fogF);
break;
case 5:
temp = (-vtf.mvPos.z - fu.start) * fu.rangeScale;
fogZ = 1.0 - exp2(-8.0 * temp * temp);
fogZ = 1.0 - exp2(-8.0 * fogF * fogF);
break;
case 6:
fogZ = exp2(-8.0 * (fu.start + vtf.mvPos.z) * fu.rangeScale);
fogZ = exp2(-8.0 * (1.0 - fogF));
break;
case 7:
temp = (fu.start + vtf.mvPos.z) * fu.rangeScale;
fogZ = exp2(-8.0 * temp * temp);
fogF = 1.0 - fogF;
fogZ = exp2(-8.0 * fogF * fogF);
break;
default:
fogZ = 0.0;
break;
}
return float4(mix(colorIn, fu.color, saturate(fogZ)).rgb, colorIn.a);
return float4(mix(colorIn, float4(0.0), saturate(fogZ)).rgb, colorIn.a);
}
fragment float4 fmain(VertToFrag vtf [[ stage_in ]],

View File

@ -7,6 +7,7 @@
#primitive tristrips
#depthtest none
#depthwrite false
#alphawrite false
#culling none
#vertex glsl
@ -14,11 +15,6 @@ layout(location=0) in vec4 posIn;
layout(location=1) in vec4 colorIn;
layout(location=2) in vec4 uvIn;
UBINDING0 uniform LineUniform
{
vec4 moduColor;
};
struct VertToFrag
{
vec4 color;
@ -28,24 +24,68 @@ struct VertToFrag
SBINDING(0) out VertToFrag vtf;
void main()
{
vtf.color = colorIn * moduColor;
vtf.color = colorIn;
vtf.uv = uvIn.xy;
gl_Position = posIn;
}
#fragment glsl
struct Fog
{
int mode;
vec4 color;
float A;
float B;
float C;
};
UBINDING0 uniform LineUniform
{
vec4 moduColor;
Fog fog;
};
struct VertToFrag
{
vec4 color;
vec2 uv;
};
vec4 MainPostFunc(vec4 colorIn)
{
float fogZ;
float fogF = clamp((fog.A / (fog.B - gl_FragCoord.z)) - fog.C, 0.0, 1.0);
switch (fog.mode)
{
case 2:
fogZ = fogF;
break;
case 4:
fogZ = 1.0 - exp2(-8.0 * fogF);
break;
case 5:
fogZ = 1.0 - exp2(-8.0 * fogF * fogF);
break;
case 6:
fogZ = exp2(-8.0 * (1.0 - fogF));
break;
case 7:
fogF = 1.0 - fogF;
fogZ = exp2(-8.0 * fogF * fogF);
break;
default:
fogZ = 0.0;
break;
}
return vec4(mix(colorIn, vec4(0.0), clamp(fogZ, 0.0, 1.0)).rgb, colorIn.a);
}
SBINDING(0) in VertToFrag vtf;
layout(location=0) out vec4 colorOut;
TBINDING0 uniform sampler2D tex;
void main()
{
colorOut = vtf.color * texture(tex, vtf.uv);
colorOut = MainPostFunc(vtf.color * moduColor * texture(tex, vtf.uv));
}
#vertex hlsl
@ -139,20 +179,35 @@ fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
return vtf.color * tex0.sample(samp, vtf.uv);
}
#shader CLineRendererShaderTexAlphaAWrite : CLineRendererShaderTexAlpha
#alphawrite true
#shader CLineRendererShaderTexAdditive : CLineRendererShaderTexAlpha
#srcfac srcalpha
#dstfac one
#depthtest none
#alphawrite false
#shader CLineRendererShaderTexAdditiveAWrite : CLineRendererShaderTexAdditive
#alphawrite true
#shader CLineRendererShaderTexAlphaZ : CLineRendererShaderTexAlpha
#srcfac srcalpha
#dstfac invsrcalpha
#depthtest lequal
#alphawrite false
#shader CLineRendererShaderTexAlphaZAWrite : CLineRendererShaderTexAlphaZ
#alphawrite true
#shader CLineRendererShaderTexAdditiveZ : CLineRendererShaderTexAlpha
#srcfac srcalpha
#dstfac one
#depthtest lequal
#alphawrite false
#shader CLineRendererShaderTexAdditiveZAWrite : CLineRendererShaderTexAdditiveZ
#alphawrite true
#shader CLineRendererShaderNoTexAlpha
#attribute position4
@ -162,17 +217,13 @@ fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
#primitive tristrips
#depthtest none
#depthwrite false
#alphawrite false
#culling none
#vertex glsl
layout(location=0) in vec4 posIn;
layout(location=1) in vec4 colorIn;
UBINDING0 uniform LineUniform
{
vec4 moduColor;
};
struct VertToFrag
{
vec4 color;
@ -181,21 +232,65 @@ struct VertToFrag
SBINDING(0) out VertToFrag vtf;
void main()
{
vtf.color = colorIn * moduColor;
vtf.color = colorIn;
gl_Position = posIn;
}
#fragment glsl
struct Fog
{
int mode;
vec4 color;
float A;
float B;
float C;
};
UBINDING0 uniform LineUniform
{
vec4 moduColor;
Fog fog;
};
struct VertToFrag
{
vec4 color;
};
vec4 MainPostFunc(vec4 colorIn)
{
float fogZ;
float fogF = clamp((fog.A / (fog.B - gl_FragCoord.z)) - fog.C, 0.0, 1.0);
switch (fog.mode)
{
case 2:
fogZ = fogF;
break;
case 4:
fogZ = 1.0 - exp2(-8.0 * fogF);
break;
case 5:
fogZ = 1.0 - exp2(-8.0 * fogF * fogF);
break;
case 6:
fogZ = exp2(-8.0 * (1.0 - fogF));
break;
case 7:
fogF = 1.0 - fogF;
fogZ = exp2(-8.0 * fogF * fogF);
break;
default:
fogZ = 0.0;
break;
}
return vec4(mix(colorIn, vec4(0.0), clamp(fogZ, 0.0, 1.0)).rgb, colorIn.a);
}
SBINDING(0) in VertToFrag vtf;
layout(location=0) out vec4 colorOut;
void main()
{
colorOut = vtf.color;
colorOut = MainPostFunc(vtf.color * moduColor);
}
#vertex hlsl
@ -205,11 +300,6 @@ struct VertData
float4 colorIn : COLOR;
};
cbuffer LineUniform : register(b0)
{
float4 moduColor;
};
struct VertToFrag
{
float4 position : SV_Position;
@ -219,21 +309,65 @@ struct VertToFrag
VertToFrag main(in VertData v)
{
VertToFrag vtf;
vtf.color = v.colorIn * moduColor;
vtf.color = v.colorIn;
vtf.position = v.posIn;
return vtf;
}
#fragment hlsl
struct Fog
{
int mode;
float4 color;
float A;
float B;
float C;
};
cbuffer LineUniform : register(b0)
{
float4 moduColor;
Fog fog;
};
struct VertToFrag
{
float4 position : SV_Position;
float4 color : COLOR;
};
static float4 MainPostFunc(float4 colorIn, float4 FragCoord)
{
float fogZ;
float fogF = saturate((fog.A / (fog.B - FragCoord.z)) - fog.C);
switch (fog.mode)
{
case 2:
fogZ = fogF;
break;
case 4:
fogZ = 1.0 - exp2(-8.0 * fogF);
break;
case 5:
fogZ = 1.0 - exp2(-8.0 * fogF * fogF);
break;
case 6:
fogZ = exp2(-8.0 * (1.0 - fogF));
break;
case 7:
fogF = 1.0 - fogF;
fogZ = exp2(-8.0 * fogF * fogF);
break;
default:
fogZ = 0.0;
break;
}
return float4(lerp(colorIn, float4(0.0,0.0,0.0,0.0), saturate(fogZ)).rgb, colorIn.a);
}
float4 main(in VertToFrag vtf) : SV_Target0
{
return vtf.color;
return MainPostFunc(vtf.color * moduColor, vtf.position);
}
#vertex metal
@ -243,11 +377,6 @@ struct VertData
float4 colorIn;
};
struct LineUniform
{
float4 moduColor;
};
struct VertToFrag
{
float4 position [[ position ]];
@ -255,44 +384,107 @@ struct VertToFrag
};
vertex VertToFrag vmain(constant VertData* va [[ buffer(0) ]],
uint vertId [[ vertex_id ]],
constant LineUniform& line [[ buffer(2) ]])
uint vertId [[ vertex_id ]])
{
VertToFrag vtf;
constant VertData& v = va[vertId];
vtf.color = v.colorIn * line.moduColor;
vtf.color = v.colorIn;
vtf.position = v.posIn;
return vtf;
}
#fragment metal
struct Fog
{
int mode;
float4 color;
float A;
float B;
float C;
};
struct LineUniform
{
float4 moduColor;
Fog fog;
};
struct VertToFrag
{
float4 position [[ position ]];
float4 color;
};
fragment float4 fmain(VertToFrag vtf [[ stage_in ]])
static float4 MainPostFunc(float4 colorIn, constant LineUniform& line, float FragCoord)
{
return vtf.color;
float fogZ;
float fogF = saturate((line.fog.A / (line.fog.B - FragCoord.z)) - line.fog.C);
switch (line.fog.mode)
{
case 2:
fogZ = fogF;
break;
case 4:
fogZ = 1.0 - exp2(-8.0 * fogF);
break;
case 5:
fogZ = 1.0 - exp2(-8.0 * fogF * fogF);
break;
case 6:
fogZ = exp2(-8.0 * (1.0 - fogF));
break;
case 7:
fogF = 1.0 - fogF;
fogZ = exp2(-8.0 * fogF * fogF);
break;
default:
fogZ = 0.0;
break;
}
return float4(mix(colorIn, float4(0.0), saturate(fogZ)).rgb, colorIn.a);
}
fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
constant LineUniform& line [[ buffer(2) ]])
{
return MainPostFunc(vtf.color * line.moduColor, line, vtf.position);
}
#shader CLineRendererShaderNoTexAlphaAWrite : CLineRendererShaderNoTexAlpha
#alphawrite true
#shader CLineRendererShaderNoTexAdditive : CLineRendererShaderNoTexAlpha
#srcfac srcalpha
#dstfac one
#depthtest none
#alphawrite false
#shader CLineRendererShaderNoTexAdditiveAWrite : CLineRendererShaderNoTexAdditive
#alphawrite true
#shader CLineRendererShaderNoTexAlphaZ : CLineRendererShaderNoTexAlpha
#srcfac srcalpha
#dstfac invsrcalpha
#depthtest lequal
#alphawrite false
#shader CLineRendererShaderNoTexAlphaZAWrite : CLineRendererShaderNoTexAlphaZ
#alphawrite true
#shader CLineRendererShaderNoTexAdditiveZ : CLineRendererShaderNoTexAlpha
#srcfac srcalpha
#dstfac one
#depthtest lequal
#alphawrite false
#shader CLineRendererShaderNoTexAdditiveZAWrite : CLineRendererShaderNoTexAdditiveZ
#alphawrite true
#shader CLineRendererShaderNoTexAlphaZGEqual : CLineRendererShaderNoTexAlpha
#srcfac srcalpha
#dstfac invsrcalpha
#depthtest gequal
#alphawrite false
#shader CLineRendererShaderNoTexAlphaZGEqualAWrite : CLineRendererShaderNoTexAlphaZGEqual
#alphawrite true

View File

@ -7,6 +7,7 @@
#primitive tristrips
#depthtest lequal
#depthwrite true
#alphawrite false
#culling none
#vertex glsl
@ -136,27 +137,42 @@ fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
return vtf.color * tex.sample(samp, vtf.uv);
}
#shader CParticleSwooshShaderTexZWriteAWrite : CParticleSwooshShaderTexZWrite
#alphawrite true
#shader CParticleSwooshShaderTexNoZWrite : CParticleSwooshShaderTexZWrite
#srcfac srcalpha
#dstfac invsrcalpha
#depthwrite false
#alphawrite false
#shader CParticleSwooshShaderTexNoZWriteAWrite : CParticleSwooshShaderTexNoZWrite
#alphawrite true
#shader CParticleSwooshShaderTexAdditiveZWrite : CParticleSwooshShaderTexZWrite
#srcfac srcalpha
#dstfac one
#depthwrite true
#alphawrite false
#shader CParticleSwooshShaderTexAdditiveZWriteAWrite : CParticleSwooshShaderTexAdditiveZWrite
#alphawrite true
#shader CParticleSwooshShaderTexAdditiveNoZWrite : CParticleSwooshShaderTexZWrite
#srcfac srcalpha
#dstfac one
#depthwrite false
#alphawrite false
#shader CParticleSwooshShaderTexAdditiveNoZWriteAWrite : CParticleSwooshShaderTexAdditiveNoZWrite
#alphawrite true
#shader CParticleSwooshShaderNoTexZWrite : CParticleSwooshShaderTexZWrite
#srcfac srcalpha
#dstfac invsrcalpha
#depthtest lequal
#depthwrite true
#alphawrite false
#fragment glsl
struct VertToFrag
@ -198,19 +214,32 @@ fragment float4 fmain(VertToFrag vtf [[ stage_in ]])
return vtf.color;
}
#shader CParticleSwooshShaderNoTexZWriteAWrite : CParticleSwooshShaderNoTexZWrite
#alphawrite true
#shader CParticleSwooshShaderNoTexNoZWrite : CParticleSwooshShaderNoTexZWrite
#srcfac srcalpha
#dstfac invsrcalpha
#depthwrite false
#alphawrite false
#shader CParticleSwooshShaderNoTexNoZWriteAWrite : CParticleSwooshShaderNoTexNoZWrite
#alphawrite true
#shader CParticleSwooshShaderNoTexAdditiveZWrite : CParticleSwooshShaderNoTexZWrite
#srcfac srcalpha
#dstfac one
#depthwrite true
#alphawrite false
#shader CParticleSwooshShaderNoTexAdditiveZWriteAWrite : CParticleSwooshShaderNoTexAdditiveZWrite
#alphawrite true
#shader CParticleSwooshShaderNoTexAdditiveNoZWrite : CParticleSwooshShaderNoTexZWrite
#srcfac srcalpha
#dstfac one
#depthwrite false
#alphawrite false
#shader CParticleSwooshShaderNoTexAdditiveNoZWriteAWrite : CParticleSwooshShaderNoTexAdditiveNoZWrite
#alphawrite true

View File

@ -74,12 +74,12 @@ SBINDING(0) in VertToFrag vtf;
layout(location=0) out vec4 colorOut;
TBINDING0 uniform sampler2D sceneTex;
TBINDING1 uniform sampler2D noiseTex;
const vec4 kRGBToYPrime = vec4(0.299, 0.587, 0.114, 0.0);
const vec4 kRGBToYPrime = vec4(0.257, 0.504, 0.098, 0.0);
void main()
{
vec4 noiseTexel = texelFetch(noiseTex, Lookup8BPP(vtf.noiseUv, vtf.randOff), 0);
vec2 indCoord = (vtf.indMtx * vec3(noiseTexel.r - 0.5, noiseTexel.a - 0.5, 1.0)).xy;
float indScene = dot(texture(sceneTex, vtf.sceneUv + indCoord), kRGBToYPrime);
float indScene = dot(texture(sceneTex, vtf.sceneUv + indCoord), kRGBToYPrime) + 16.0 / 255.0;
colorOut = vtf.colorReg0 * indScene + vtf.colorReg2 - vtf.colorReg1 * noiseTexel.r;
colorOut.a = vtf.colorReg1.a + vtf.colorReg1.a * noiseTexel.r + vtf.colorReg2.a;
}
@ -154,12 +154,12 @@ static int3 Lookup8BPP(float2 uv, float randOff)
return int3(addr & 0x3ff, addr >> 10, 0);
}
static const float4 kRGBToYPrime = {0.299, 0.587, 0.114, 0.0};
static const float4 kRGBToYPrime = {0.257, 0.504, 0.098, 0.0};
float4 main(in VertToFrag vtf) : SV_Target0
{
float4 noiseTexel = noiseTex.Load(Lookup8BPP(vtf.noiseUv, vtf.randOff));
float2 indCoord = mul(vtf.indMtx, float3(noiseTexel.r - 0.5, noiseTexel.a - 0.5, 1.0)).xy;
float indScene = dot(sceneTex.Sample(samp, vtf.sceneUv + indCoord), kRGBToYPrime);
float indScene = dot(sceneTex.Sample(samp, vtf.sceneUv + indCoord), kRGBToYPrime) + 16.0 / 255.0;
float4 colorOut = vtf.colorReg0 * indScene + vtf.colorReg2 - vtf.colorReg1 * noiseTexel.r;
colorOut.a = vtf.colorReg1.a + vtf.colorReg1.a * noiseTexel.r + vtf.colorReg2.a;
return colorOut;
@ -238,7 +238,7 @@ static uint2 Lookup8BPP(float2 uv, float randOff)
return uint2(addr & 0x3ff, addr >> 10);
}
constant float4 kRGBToYPrime = {0.299, 0.587, 0.114, 0.0};
constant float4 kRGBToYPrime = {0.257, 0.504, 0.098, 0.0};
fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
sampler samp [[ sampler(3) ]],
texture2d<float> sceneTex [[ texture(0) ]],
@ -246,7 +246,7 @@ fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
{
float4 noiseTexel = noiseTex.read(Lookup8BPP(vtf.noiseUv, vtf.randOff));
float2 indCoord = (vtf.indMtx * float3(noiseTexel.r - 0.5, noiseTexel.a - 0.5, 1.0)).xy;
float indScene = dot(sceneTex.sample(samp, vtf.sceneUv + indCoord), kRGBToYPrime);
float indScene = dot(sceneTex.sample(samp, vtf.sceneUv + indCoord), kRGBToYPrime) + 16.0 / 255.0;
float4 colorOut = vtf.colorReg0 * indScene + vtf.colorReg2 - vtf.colorReg1 * noiseTexel.r;
colorOut.a = vtf.colorReg1.a + vtf.colorReg1.a * noiseTexel.r + vtf.colorReg2.a;
}

View File

@ -41,11 +41,11 @@ SBINDING(0) in VertToFrag vtf;
layout(location=0) out vec4 colorOut;
TBINDING0 uniform sampler2D sceneTex;
TBINDING1 uniform sampler2D paletteTex;
const vec4 kRGBToYPrime = vec4(0.299, 0.587, 0.114, 0.0);
const vec4 kRGBToYPrime = vec4(0.257, 0.504, 0.098, 0.0);
void main()
{
float sceneSample = dot(texture(sceneTex, vtf.sceneUv), kRGBToYPrime);
vec4 colorSample = texture(paletteTex, vec2(sceneSample / 17.0, 0.5));
float sceneSample = dot(texture(sceneTex, vtf.sceneUv), kRGBToYPrime) + 16.0 / 255.0;
vec4 colorSample = texture(paletteTex, vec2(sceneSample / 16.0, 0.5));
colorOut = vec4(colorSample.rgb, 0.0);
}
@ -88,11 +88,11 @@ struct VertToFrag
float2 sceneUv : UV;
};
static const float4 kRGBToYPrime = float4(0.299, 0.587, 0.114, 0.0);
static const float4 kRGBToYPrime = float4(0.257, 0.504, 0.098, 0.0);
float4 main(in VertToFrag vtf) : SV_Target0
{
float sceneSample = dot(sceneTex.Sample(samp, vtf.sceneUv), kRGBToYPrime);
float4 colorSample = paletteTex.Sample(samp, float2(sceneSample / 17.0, 0.5));
float sceneSample = dot(sceneTex.Sample(samp, vtf.sceneUv), kRGBToYPrime) + 16.0 / 255.0;
float4 colorSample = paletteTex.Sample(samp, float2(sceneSample / 16.0, 0.5));
return float4(colorSample.rgb, 0.0);
}
@ -132,13 +132,13 @@ struct VertToFrag
float2 sceneUv;
};
constant float4 kRGBToYPrime = float4(0.299, 0.587, 0.114, 0.0);
constant float4 kRGBToYPrime = float4(0.257, 0.504, 0.098, 0.0);
fragment float4 fmain(VertToFrag vtf [[ stage_in ]],
sampler samp [[ sampler(0) ]],
texture2d<float> sceneTex [[ texture(0) ]],
texture2d<float> paletteTex [[ texture(1) ]])
{
float sceneSample = dot(sceneTex.sample(samp, vtf.sceneUv), kRGBToYPrime);
float4 colorSample = paletteTex.sample(samp, float2(sceneSample / 17.0, 0.5));
float sceneSample = dot(sceneTex.sample(samp, vtf.sceneUv), kRGBToYPrime) + 16.0 / 255.0;
float4 colorSample = paletteTex.sample(samp, float2(sceneSample / 16.0, 0.5));
return float4(colorSample.rgb, 0.0);
}

View File

@ -1,5 +1,50 @@
#include "shader_CFluidPlaneShader.hpp"
#define FOG_STRUCT_GLSL \
"struct Fog\n" \
"{\n" \
" int mode;\n" \
" vec4 color;\n" \
" float A;\n" \
" float B;\n" \
" float C;\n" \
" float indScale;\n" \
"};\n"
#define FOG_ALGORITHM_GLSL \
"vec4 MainPostFunc(vec4 colorIn)\n" \
"{\n" \
" 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" \
"#if %d\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" \
"}\n"
static const char* VS =
"layout(location=0) in vec4 posIn;\n"
"layout(location=1) in vec4 normalIn;\n"
@ -175,14 +220,7 @@ static const char* FS =
" vec4 linAtt;\n"
" vec4 angAtt;\n"
"};\n"
"struct Fog\n" // Reappropriated for indirect texture scaling
"{\n"
" int mode;\n"
" vec4 color;\n"
" float rangeScale;\n"
" float start;\n"
" float indScale;\n"
"};\n"
FOG_STRUCT_GLSL
"\n"
"UBINDING2 uniform LightingUniform\n"
"{\n"
@ -229,38 +267,7 @@ static const char* FS =
"};\n"
"\n"
"SBINDING(0) in VertToFrag vtf;\n"
"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"
"#if %d\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"
"}\n"
FOG_ALGORITHM_GLSL
"\n"
"layout(location=0) out vec4 colorOut;\n"
"%s" // Textures here
@ -281,14 +288,7 @@ static const char* FSDoor =
" vec4 linAtt;\n"
" vec4 angAtt;\n"
"};\n"
"struct Fog\n" // Reappropriated for indirect texture scaling
"{\n"
" int mode;\n"
" vec4 color;\n"
" float rangeScale;\n"
" float start;\n"
" float indScale;\n"
"};\n"
FOG_STRUCT_GLSL
"\n"
"UBINDING2 uniform LightingUniform\n"
"{\n"
@ -311,6 +311,7 @@ static const char* FSDoor =
" vec4 color;\n"
" vec2 uvs[7];\n"
"};\n"
FOG_ALGORITHM_GLSL
"\n"
"SBINDING(0) in VertToFrag vtf;\n"
"layout(location=0) out vec4 colorOut;\n"
@ -318,6 +319,7 @@ static const char* FSDoor =
"void main()\n"
"{\n"
"%s" // Combiner expression here
" colorOut = MainPostFunc(colorOut);\n"
"}\n";
static std::string _BuildFS(const SFluidPlaneShaderInfo& info) {
@ -766,7 +768,7 @@ static std::string _BuildFS(const SFluidPlaneDoorShaderInfo& info) {
combiner += " colorOut.a = kColor0.a;\n";
char* finalFSs;
asprintf(&finalFSs, FSDoor, textures.c_str(), combiner.c_str());
asprintf(&finalFSs, FSDoor, 0, textures.c_str(), combiner.c_str());
std::string ret(finalFSs);
free(finalFSs);
return ret;

View File

@ -1,5 +1,50 @@
#include "shader_CFluidPlaneShader.hpp"
#define FOG_STRUCT_HLSL \
"struct Fog\n" \
"{\n" \
" int mode;\n" \
" float4 color;\n" \
" float A;\n" \
" float B;\n" \
" float C;\n" \
" float indScale;\n" \
"};\n"
#define FOG_ALGORITHM_HLSL \
"static float4 MainPostFunc(in VertToFrag vtf, float4 colorIn)\n" \
"{\n" \
" float fogZ;\n" \
" float fogF = saturate((fog.A / (fog.B - vtf.pos.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" \
"#if %d\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" \
"}\n"
static const char* VS =
"struct VertData\n"
"{\n"
@ -211,14 +256,7 @@ static const char* FS =
" float4 linAtt;\n"
" float4 angAtt;\n"
"};\n"
"struct Fog\n" // Reappropriated for indirect texture scaling
"{\n"
" int mode;\n"
" float4 color;\n"
" float rangeScale;\n"
" float start;\n"
" float indScale;\n"
"};\n"
FOG_STRUCT_HLSL
"\n"
"cbuffer LightingUniform : register(b2)\n"
"{\n"
@ -264,38 +302,7 @@ static const char* FS =
" float2 uvs[7] : UV;\n"
"};\n"
"\n"
"static float4 MainPostFunc(in VertToFrag vtf, float4 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"
"#if %d\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"
"}\n"
FOG_ALGORITHM_HLSL
"\n"
"SamplerState samp : register(s0);\n"
"%s" // Textures here
@ -316,14 +323,7 @@ static const char* FSDoor =
" float4 linAtt;\n"
" float4 angAtt;\n"
"};\n"
"struct Fog\n" // Reappropriated for indirect texture scaling
"{\n"
" int mode;\n"
" float4 color;\n"
" float rangeScale;\n"
" float start;\n"
" float indScale;\n"
"};\n"
FOG_STRUCT_HLSL
"\n"
"cbuffer LightingUniform : register(b2)\n"
"{\n"
@ -346,6 +346,7 @@ static const char* FSDoor =
" float4 color : COLOR;\n"
" float2 uvs[7] : UV;\n"
"};\n"
FOG_ALGORITHM_HLSL
"\n"
"SamplerState samp : register(s0);\n"
"%s" // Textures here
@ -353,7 +354,7 @@ static const char* FSDoor =
"{\n"
" float4 colorOut;\n"
"%s" // Combiner expression here
" return colorOut;\n"
" return MainPostFunc(vtf, colorOut);\n"
"}\n";
static std::string _BuildFS(const SFluidPlaneShaderInfo& info) {
@ -761,7 +762,7 @@ static std::string _BuildFS(const SFluidPlaneDoorShaderInfo& info) {
combiner += " colorOut.a = kColor0.a;\n";
char* finalFSs;
asprintf(&finalFSs, FSDoor, textures.c_str(), combiner.c_str());
asprintf(&finalFSs, FSDoor, 0, textures.c_str(), combiner.c_str());
std::string ret(finalFSs);
free(finalFSs);
return ret;

View File

@ -1,5 +1,50 @@
#include "shader_CFluidPlaneShader.hpp"
#define FOG_STRUCT_METAL \
"struct Fog\n" \
"{\n" \
" int mode;\n" \
" float4 color;\n" \
" float A;\n" \
" float B;\n" \
" float C;\n" \
" float indScale;\n" \
"};\n"
#define FOG_ALGORITHM_METAL \
"static float4 MainPostFunc(thread VertToFrag& vtf, constant LightingUniform& lu, float4 colorIn)\n" \
"{\n" \
" float fogZ;\n" \
" float fogF = saturate((lu.fog.A / (lu.fog.B - vtf.pos.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" \
"#if %d\n" \
" return float4(mix(colorIn, float4(0.0), saturate(fogZ)).rgb, colorIn.a);\n" \
"#else\n" \
" return float4(mix(colorIn, fog.color, saturate(fogZ)).rgb, colorIn.a);\n" \
"#endif\n" \
"}\n"
static const char* VS =
"struct VertData\n"
"{\n"
@ -195,14 +240,7 @@ static const char* FS =
" float4 linAtt;\n"
" float4 angAtt;\n"
"};\n"
"struct Fog\n" // Reappropriated for indirect texture scaling
"{\n"
" int mode;\n"
" float4 color;\n"
" float rangeScale;\n"
" float start;\n"
" float indScale;\n"
"};\n"
FOG_STRUCT_METAL
"\n"
"struct LightingUniform\n"
"{\n"
@ -254,38 +292,7 @@ static const char* FS =
" float2 uv6;\n"
"};\n"
"\n"
"float4 MainPostFunc(thread VertToFrag& vtf, constant LightingUniform& lu, float4 colorIn)\n"
"{\n"
" float fogZ, temp;\n"
" switch (lu.fog.mode)\n"
" {\n"
" case 2:\n"
" fogZ = (-vtf.mvPos.z - lu.fog.start) * lu.fog.rangeScale;\n"
" break;\n"
" case 4:\n"
" fogZ = 1.0 - exp2(-8.0 * (-vtf.mvPos.z - lu.fog.start) * lu.fog.rangeScale);\n"
" break;\n"
" case 5:\n"
" temp = (-vtf.mvPos.z - lu.fog.start) * lu.fog.rangeScale;\n"
" fogZ = 1.0 - exp2(-8.0 * temp * temp);\n"
" break;\n"
" case 6:\n"
" fogZ = exp2(-8.0 * (lu.fog.start + vtf.mvPos.z) * lu.fog.rangeScale);\n"
" break;\n"
" case 7:\n"
" temp = (lu.fog.start + vtf.mvPos.z) * lu.fog.rangeScale;\n"
" fogZ = exp2(-8.0 * temp * temp);\n"
" break;\n"
" default:\n"
" fogZ = 0.0;\n"
" break;\n"
" }\n"
"#if %d\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"
"}\n"
FOG_ALGORITHM_METAL
"\n"
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n"
" sampler samp [[ sampler(0) ]],\n"
@ -306,14 +313,7 @@ static const char* FSDoor =
" float4 linAtt;\n"
" float4 angAtt;\n"
"};\n"
"struct Fog\n" // Reappropriated for indirect texture scaling
"{\n"
" int mode;\n"
" float4 color;\n"
" float rangeScale;\n"
" float start;\n"
" float indScale;\n"
"};\n"
FOG_STRUCT_METAL
"\n"
"struct LightingUniform\n"
"{\n"
@ -343,6 +343,7 @@ static const char* FSDoor =
" float2 uv5;\n"
" float2 uv6;\n"
"};\n"
FOG_ALGORITHM_METAL
"\n"
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n"
" sampler samp [[ sampler(0) ]],\n"
@ -350,7 +351,7 @@ static const char* FSDoor =
"{\n"
" float4 colorOut;\n"
"%s" // Combiner expression here
" return colorOut;\n"
" return MainPostFunc(vtf, lu, colorOut);\n"
"}\n";
static std::string _BuildFS(const SFluidPlaneShaderInfo& info) {
@ -748,7 +749,7 @@ static std::string _BuildFS(const SFluidPlaneDoorShaderInfo& info) {
combiner += " colorOut.a = lu.kColor0.a;\n";
char* finalFSs;
asprintf(&finalFSs, FSDoor, textures.c_str(), combiner.c_str());
asprintf(&finalFSs, FSDoor, 0, textures.c_str(), combiner.c_str());
std::string ret(finalFSs);
free(finalFSs);
return ret;

2
hecl

@ -1 +1 @@
Subproject commit 6e15025d2b8ed64191ebdf50a815a302368944ef
Subproject commit bfd649cd9f2b9d4382d83d5b0971f97e0ac98d84