mirror of https://github.com/AxioDL/metaforce.git
Graphics/Shaders: Use std::array where applicable
Makes the arrays strongly typed and impervious to array->pointer decay. This also allows simplifying some operations (such as being able to call fill() instead of needing to use std::fill, etc).
This commit is contained in:
parent
417506572c
commit
136a229a1a
|
@ -414,7 +414,7 @@ void CBooModel::ActivateLights(const std::vector<CLight>& lights) { m_lightingDa
|
||||||
void CBooModel::DisableAllLights() {
|
void CBooModel::DisableAllLights() {
|
||||||
m_lightingData.ambient = zeus::skBlack;
|
m_lightingData.ambient = zeus::skBlack;
|
||||||
|
|
||||||
for (size_t curLight = 0; curLight < URDE_MAX_LIGHTS; ++curLight) {
|
for (size_t curLight = 0; curLight < m_lightingData.lights.size(); ++curLight) {
|
||||||
CModelShaders::Light& lightOut = m_lightingData.lights[curLight];
|
CModelShaders::Light& lightOut = m_lightingData.lights[curLight];
|
||||||
lightOut.color = zeus::skClear;
|
lightOut.color = zeus::skClear;
|
||||||
lightOut.linAtt[0] = 1.f;
|
lightOut.linAtt[0] = 1.f;
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "Runtime/Graphics/Shaders/CAABoxShader.hpp"
|
#include "Runtime/Graphics/Shaders/CAABoxShader.hpp"
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
#include "Runtime/Graphics/CGraphics.hpp"
|
#include "Runtime/Graphics/CGraphics.hpp"
|
||||||
|
|
||||||
#include <hecl/Pipeline.hpp>
|
#include <hecl/Pipeline.hpp>
|
||||||
|
@ -24,16 +26,17 @@ CAABoxShader::CAABoxShader(bool zOnly) {
|
||||||
CGraphics::CommitResources([this, zOnly](boo::IGraphicsDataFactory::Context& ctx) {
|
CGraphics::CommitResources([this, zOnly](boo::IGraphicsDataFactory::Context& ctx) {
|
||||||
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(zeus::CVector3f), 34);
|
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(zeus::CVector3f), 34);
|
||||||
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
||||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {m_uniBuf.get()};
|
const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> bufs{m_uniBuf.get()};
|
||||||
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
|
constexpr std::array<boo::PipelineStage, 1> stages{boo::PipelineStage::Vertex};
|
||||||
m_dataBind = ctx.newShaderDataBinding(zOnly ? s_zOnlyPipeline : s_Pipeline, m_vbo.get(), nullptr, nullptr, 1, bufs,
|
m_dataBind =
|
||||||
stages, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
ctx.newShaderDataBinding(zOnly ? s_zOnlyPipeline : s_Pipeline, m_vbo.get(), nullptr, nullptr, bufs.size(),
|
||||||
|
bufs.data(), stages.data(), nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
||||||
return true;
|
return true;
|
||||||
} BooTrace);
|
} BooTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAABoxShader::setAABB(const zeus::CAABox& aabb) {
|
void CAABoxShader::setAABB(const zeus::CAABox& aabb) {
|
||||||
zeus::CVector3f vboData[] = {
|
const std::array<zeus::CVector3f, 34> vboData{{
|
||||||
{aabb.max.x(), aabb.max.y(), aabb.min.z()}, {aabb.max.x(), aabb.min.y(), aabb.min.z()},
|
{aabb.max.x(), aabb.max.y(), aabb.min.z()}, {aabb.max.x(), aabb.min.y(), aabb.min.z()},
|
||||||
{aabb.max.x(), aabb.max.y(), aabb.max.z()}, {aabb.max.x(), aabb.min.y(), aabb.max.z()},
|
{aabb.max.x(), aabb.max.y(), aabb.max.z()}, {aabb.max.x(), aabb.min.y(), aabb.max.z()},
|
||||||
{aabb.max.x(), aabb.min.y(), aabb.max.z()},
|
{aabb.max.x(), aabb.min.y(), aabb.max.z()},
|
||||||
|
@ -57,9 +60,9 @@ void CAABoxShader::setAABB(const zeus::CAABox& aabb) {
|
||||||
{aabb.min.x(), aabb.min.y(), aabb.min.z()}, {aabb.min.x(), aabb.min.y(), aabb.min.z()},
|
{aabb.min.x(), aabb.min.y(), aabb.min.z()}, {aabb.min.x(), aabb.min.y(), aabb.min.z()},
|
||||||
{aabb.max.x(), aabb.min.y(), aabb.min.z()}, {aabb.min.x(), aabb.max.y(), aabb.min.z()},
|
{aabb.max.x(), aabb.min.y(), aabb.min.z()}, {aabb.min.x(), aabb.max.y(), aabb.min.z()},
|
||||||
{aabb.max.x(), aabb.max.y(), aabb.min.z()},
|
{aabb.max.x(), aabb.max.y(), aabb.min.z()},
|
||||||
};
|
}};
|
||||||
|
|
||||||
m_vbo->load(vboData, sizeof(zeus::CVector3f) * 34);
|
m_vbo->load(vboData.data(), sizeof(vboData));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAABoxShader::draw(const zeus::CColor& color) {
|
void CAABoxShader::draw(const zeus::CColor& color) {
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "Runtime/Graphics/Shaders/CColoredQuadFilter.hpp"
|
#include "Runtime/Graphics/Shaders/CColoredQuadFilter.hpp"
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
#include "Runtime/Camera/CCameraFilter.hpp"
|
#include "Runtime/Camera/CCameraFilter.hpp"
|
||||||
#include "Runtime/Graphics/CGraphics.hpp"
|
#include "Runtime/Graphics/CGraphics.hpp"
|
||||||
|
|
||||||
|
@ -40,18 +42,22 @@ CColoredQuadFilter::CColoredQuadFilter(EFilterType type) {
|
||||||
CGraphics::CommitResources([this, type](boo::IGraphicsDataFactory::Context& ctx) {
|
CGraphics::CommitResources([this, type](boo::IGraphicsDataFactory::Context& ctx) {
|
||||||
struct Vert {
|
struct Vert {
|
||||||
zeus::CVector2f m_pos;
|
zeus::CVector2f m_pos;
|
||||||
} verts[4] = {
|
};
|
||||||
|
|
||||||
|
const std::array<Vert, 4> verts{{
|
||||||
{{0.0, 0.0}},
|
{{0.0, 0.0}},
|
||||||
{{0.0, 1.0}},
|
{{0.0, 1.0}},
|
||||||
{{1.0, 0.0}},
|
{{1.0, 0.0}},
|
||||||
{{1.0, 1.0}},
|
{{1.0, 1.0}},
|
||||||
};
|
}};
|
||||||
m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts, 16, 4);
|
|
||||||
|
m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts.data(), 16, verts.size());
|
||||||
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
||||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {m_uniBuf.get()};
|
|
||||||
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
|
const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> bufs{m_uniBuf.get()};
|
||||||
m_dataBind = ctx.newShaderDataBinding(SelectPipeline(type), m_vbo.get(), nullptr, nullptr, 1, bufs, stages, nullptr,
|
constexpr std::array<boo::PipelineStage, 1> stages{boo::PipelineStage::Vertex};
|
||||||
nullptr, 0, nullptr, nullptr, nullptr);
|
m_dataBind = ctx.newShaderDataBinding(SelectPipeline(type), m_vbo.get(), nullptr, nullptr, bufs.size(), bufs.data(),
|
||||||
|
stages.data(), nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
||||||
return true;
|
return true;
|
||||||
} BooTrace);
|
} BooTrace);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "Runtime/Graphics/Shaders/CColoredStripShader.hpp"
|
#include "Runtime/Graphics/Shaders/CColoredStripShader.hpp"
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
#include "Runtime/GameGlobalObjects.hpp"
|
#include "Runtime/GameGlobalObjects.hpp"
|
||||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||||
#include "Runtime/Graphics/CGraphics.hpp"
|
#include "Runtime/Graphics/CGraphics.hpp"
|
||||||
|
@ -45,15 +47,18 @@ void CColoredStripShader::BuildResources(boo::IGraphicsDataFactory::Context& ctx
|
||||||
boo::ObjToken<boo::ITexture> tex) {
|
boo::ObjToken<boo::ITexture> tex) {
|
||||||
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(Vert), maxVerts);
|
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(Vert), maxVerts);
|
||||||
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
||||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {m_uniBuf.get()};
|
|
||||||
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
|
const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> bufs{m_uniBuf.get()};
|
||||||
boo::ObjToken<boo::ITexture> texs[1];
|
constexpr std::array<boo::PipelineStage, 1> stages{boo::PipelineStage::Vertex};
|
||||||
if (tex)
|
std::array<boo::ObjToken<boo::ITexture>, 1> texs;
|
||||||
|
if (tex) {
|
||||||
texs[0] = tex;
|
texs[0] = tex;
|
||||||
else
|
} else {
|
||||||
texs[0] = g_Renderer->GetWhiteTexture();
|
texs[0] = g_Renderer->GetWhiteTexture();
|
||||||
m_dataBind = ctx.newShaderDataBinding(SelectPipeline(mode), m_vbo.get(), nullptr, nullptr, 1, bufs, stages, nullptr,
|
}
|
||||||
nullptr, 1, texs, nullptr, nullptr);
|
|
||||||
|
m_dataBind = ctx.newShaderDataBinding(SelectPipeline(mode), m_vbo.get(), nullptr, nullptr, bufs.size(), bufs.data(),
|
||||||
|
stages.data(), nullptr, nullptr, texs.size(), texs.data(), nullptr, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
CColoredStripShader::CColoredStripShader(size_t maxVerts, Mode mode, boo::ObjToken<boo::ITexture> tex) {
|
CColoredStripShader::CColoredStripShader(size_t maxVerts, Mode mode, boo::ObjToken<boo::ITexture> tex) {
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "Runtime/Graphics/Shaders/CDecalShaders.hpp"
|
#include "Runtime/Graphics/Shaders/CDecalShaders.hpp"
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
#include "Runtime/Particle/CDecal.hpp"
|
#include "Runtime/Particle/CDecal.hpp"
|
||||||
|
|
||||||
#include <hecl/Pipeline.hpp>
|
#include <hecl/Pipeline.hpp>
|
||||||
|
@ -46,26 +48,31 @@ void CDecalShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& c
|
||||||
regPipeline = m_noTexZTestNoZWrite;
|
regPipeline = m_noTexZTestNoZWrite;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SQuadDescr* desc = decal.m_desc;
|
const SQuadDescr* const desc = decal.m_desc;
|
||||||
|
const CUVElement* const texr = desc->x14_TEX.get();
|
||||||
|
size_t texCount = 0;
|
||||||
|
std::array<boo::ObjToken<boo::ITexture>, 1> textures;
|
||||||
|
|
||||||
CUVElement* texr = desc->x14_TEX.get();
|
if (texr != nullptr) {
|
||||||
int texCount = 0;
|
|
||||||
boo::ObjToken<boo::ITexture> textures[1];
|
|
||||||
|
|
||||||
if (texr) {
|
|
||||||
textures[0] = texr->GetValueTexture(0).GetObj()->GetBooTexture();
|
textures[0] = texr->GetValueTexture(0).GetObj()->GetBooTexture();
|
||||||
texCount = 1;
|
texCount = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (decal.m_instBuf) {
|
if (!decal.m_instBuf) {
|
||||||
boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {decal.m_uniformBuf.get()};
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (regPipeline)
|
std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> uniforms{decal.m_uniformBuf.get()};
|
||||||
decal.m_normalDataBind = ctx.newShaderDataBinding(regPipeline, nullptr, decal.m_instBuf.get(), nullptr, 1,
|
|
||||||
uniforms, nullptr, texCount, textures, nullptr, nullptr);
|
if (regPipeline) {
|
||||||
if (redToAlphaPipeline)
|
decal.m_normalDataBind =
|
||||||
decal.m_redToAlphaDataBind = ctx.newShaderDataBinding(redToAlphaPipeline, nullptr, decal.m_instBuf.get(), nullptr,
|
ctx.newShaderDataBinding(regPipeline, nullptr, decal.m_instBuf.get(), nullptr, uniforms.size(), uniforms.data(),
|
||||||
1, uniforms, nullptr, texCount, textures, nullptr, nullptr);
|
nullptr, texCount, textures.data(), nullptr, nullptr);
|
||||||
|
}
|
||||||
|
if (redToAlphaPipeline) {
|
||||||
|
decal.m_redToAlphaDataBind =
|
||||||
|
ctx.newShaderDataBinding(redToAlphaPipeline, nullptr, decal.m_instBuf.get(), nullptr, uniforms.size(),
|
||||||
|
uniforms.data(), nullptr, texCount, textures.data(), nullptr, nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "Runtime/Graphics/Shaders/CElementGenShaders.hpp"
|
#include "Runtime/Graphics/Shaders/CElementGenShaders.hpp"
|
||||||
|
|
||||||
|
#include <iterator>
|
||||||
|
|
||||||
#include "Runtime/Particle/CElementGen.hpp"
|
#include "Runtime/Particle/CElementGen.hpp"
|
||||||
|
|
||||||
#include <hecl/Pipeline.hpp>
|
#include <hecl/Pipeline.hpp>
|
||||||
|
@ -226,10 +228,10 @@ void CElementGenShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Conte
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CUVElement* texr = desc->x54_x40_TEXR.get();
|
const CUVElement* const texr = desc->x54_x40_TEXR.get();
|
||||||
CUVElement* tind = desc->x58_x44_TIND.get();
|
const CUVElement* const tind = desc->x58_x44_TIND.get();
|
||||||
int texCount = 0;
|
int texCount = 0;
|
||||||
boo::ObjToken<boo::ITexture> textures[3];
|
std::array<boo::ObjToken<boo::ITexture>, 3> textures;
|
||||||
|
|
||||||
if (texr) {
|
if (texr) {
|
||||||
textures[0] = texr->GetValueTexture(0).GetObj()->GetBooTexture();
|
textures[0] = texr->GetValueTexture(0).GetObj()->GetBooTexture();
|
||||||
|
@ -244,43 +246,56 @@ void CElementGenShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Conte
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gen.m_instBuf) {
|
if (gen.m_instBuf) {
|
||||||
boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {gen.m_uniformBuf.get()};
|
const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> uniforms{gen.m_uniformBuf.get()};
|
||||||
|
|
||||||
if (regPipeline)
|
if (regPipeline != nullptr) {
|
||||||
for (int i = 0; i < 2; ++i)
|
for (size_t i = 0; i < std::size(gen.m_normalDataBind); ++i) {
|
||||||
gen.m_normalDataBind[i] = ctx.newShaderDataBinding((*regPipeline)[i], nullptr, gen.m_instBuf.get(), nullptr, 1,
|
gen.m_normalDataBind[i] =
|
||||||
uniforms, nullptr, texCount, textures, nullptr, nullptr);
|
ctx.newShaderDataBinding((*regPipeline)[i], nullptr, gen.m_instBuf.get(), nullptr, uniforms.size(),
|
||||||
if (regPipelineSub)
|
uniforms.data(), nullptr, texCount, textures.data(), 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,
|
if (regPipelineSub != nullptr) {
|
||||||
nullptr, nullptr);
|
for (size_t i = 0; i < std::size(gen.m_normalSubDataBind); ++i) {
|
||||||
if (redToAlphaPipeline)
|
gen.m_normalSubDataBind[i] =
|
||||||
for (int i = 0; i < 2; ++i)
|
ctx.newShaderDataBinding((*regPipelineSub)[i], nullptr, gen.m_instBuf.get(), nullptr, uniforms.size(),
|
||||||
gen.m_redToAlphaDataBind[i] = ctx.newShaderDataBinding((*redToAlphaPipeline)[i], nullptr, gen.m_instBuf.get(),
|
uniforms.data(), nullptr, texCount, textures.data(), nullptr, nullptr);
|
||||||
nullptr, 1, uniforms, nullptr, texCount, textures,
|
}
|
||||||
nullptr, nullptr);
|
}
|
||||||
if (redToAlphaPipelineSub)
|
if (redToAlphaPipeline != nullptr) {
|
||||||
for (int i = 0; i < 2; ++i)
|
for (size_t i = 0; i < std::size(gen.m_redToAlphaDataBind); ++i) {
|
||||||
gen.m_redToAlphaSubDataBind[i] =
|
gen.m_redToAlphaDataBind[i] =
|
||||||
ctx.newShaderDataBinding((*redToAlphaPipelineSub)[i], nullptr, gen.m_instBuf.get(), nullptr, 1, uniforms,
|
ctx.newShaderDataBinding((*redToAlphaPipeline)[i], nullptr, gen.m_instBuf.get(), nullptr, uniforms.size(),
|
||||||
nullptr, texCount, textures, nullptr, nullptr);
|
uniforms.data(), nullptr, texCount, textures.data(), nullptr, nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (redToAlphaPipelineSub != nullptr) {
|
||||||
|
for (size_t i = 0; i < std::size(gen.m_redToAlphaSubDataBind); ++i) {
|
||||||
|
gen.m_redToAlphaSubDataBind[i] = ctx.newShaderDataBinding(
|
||||||
|
(*redToAlphaPipelineSub)[i], nullptr, gen.m_instBuf.get(), nullptr, uniforms.size(), uniforms.data(),
|
||||||
|
nullptr, texCount, textures.data(), nullptr, nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gen.m_instBufPmus) {
|
if (gen.m_instBufPmus) {
|
||||||
boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {gen.m_uniformBufPmus.get()};
|
const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> uniforms{gen.m_uniformBufPmus.get()};
|
||||||
texCount = std::min(texCount, 1);
|
texCount = std::min(texCount, 1);
|
||||||
|
|
||||||
if (regPipelinePmus)
|
if (regPipelinePmus != nullptr) {
|
||||||
for (int i = 0; i < 2; ++i)
|
for (size_t i = 0; i < std::size(gen.m_normalDataBindPmus); ++i) {
|
||||||
gen.m_normalDataBindPmus[i] = ctx.newShaderDataBinding((*regPipelinePmus)[i], nullptr, gen.m_instBufPmus.get(),
|
gen.m_normalDataBindPmus[i] =
|
||||||
nullptr, 1, uniforms, nullptr, texCount, textures,
|
ctx.newShaderDataBinding((*regPipelinePmus)[i], nullptr, gen.m_instBufPmus.get(), nullptr, uniforms.size(),
|
||||||
nullptr, nullptr);
|
uniforms.data(), nullptr, texCount, textures.data(), nullptr, nullptr);
|
||||||
if (redToAlphaPipelinePmus)
|
}
|
||||||
for (int i = 0; i < 2; ++i)
|
}
|
||||||
gen.m_redToAlphaDataBindPmus[i] =
|
if (redToAlphaPipelinePmus != nullptr) {
|
||||||
ctx.newShaderDataBinding((*redToAlphaPipelinePmus)[i], nullptr, gen.m_instBufPmus.get(), nullptr, 1, uniforms,
|
for (size_t i = 0; i < std::size(gen.m_redToAlphaDataBindPmus); ++i) {
|
||||||
nullptr, texCount, textures, nullptr, nullptr);
|
gen.m_redToAlphaDataBindPmus[i] = ctx.newShaderDataBinding(
|
||||||
|
(*redToAlphaPipelinePmus)[i], nullptr, gen.m_instBufPmus.get(), nullptr, uniforms.size(), uniforms.data(),
|
||||||
|
nullptr, texCount, textures.data(), nullptr, nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "Runtime/Graphics/Shaders/CEnergyBarShader.hpp"
|
#include "Runtime/Graphics/Shaders/CEnergyBarShader.hpp"
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
#include "Runtime/Graphics/CGraphics.hpp"
|
#include "Runtime/Graphics/CGraphics.hpp"
|
||||||
#include "Runtime/Graphics/CTexture.hpp"
|
#include "Runtime/Graphics/CTexture.hpp"
|
||||||
|
|
||||||
|
@ -31,15 +33,19 @@ void CEnergyBarShader::draw(const zeus::CColor& color0, const std::vector<Vertex
|
||||||
m_tex = tex;
|
m_tex = tex;
|
||||||
CGraphics::CommitResources([this](boo::IGraphicsDataFactory::Context& ctx) {
|
CGraphics::CommitResources([this](boo::IGraphicsDataFactory::Context& ctx) {
|
||||||
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(Vertex), m_maxVerts);
|
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(Vertex), m_maxVerts);
|
||||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[1];
|
|
||||||
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
|
std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> bufs;
|
||||||
boo::ObjToken<boo::ITexture> texs[] = {m_tex->GetBooTexture()};
|
constexpr std::array<boo::PipelineStage, 1> stages{boo::PipelineStage::Vertex};
|
||||||
for (int i = 0; i < 3; ++i) {
|
const std::array<boo::ObjToken<boo::ITexture>, 1> texs{m_tex->GetBooTexture()};
|
||||||
|
|
||||||
|
for (size_t i = 0; i < m_uniBuf.size(); ++i) {
|
||||||
m_uniBuf[i] = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
m_uniBuf[i] = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
||||||
bufs[0] = m_uniBuf[i].get();
|
bufs[0] = m_uniBuf[i].get();
|
||||||
m_dataBind[i] = ctx.newShaderDataBinding(s_Pipeline, m_vbo.get(), nullptr, nullptr, 1, bufs, stages, nullptr,
|
m_dataBind[i] =
|
||||||
nullptr, 1, texs, nullptr, nullptr);
|
ctx.newShaderDataBinding(s_Pipeline, m_vbo.get(), nullptr, nullptr, bufs.size(), bufs.data(), stages.data(),
|
||||||
|
nullptr, nullptr, texs.size(), texs.data(), nullptr, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} BooTrace);
|
} BooTrace);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||||
|
@ -25,8 +26,8 @@ private:
|
||||||
zeus::CColor m_color;
|
zeus::CColor m_color;
|
||||||
};
|
};
|
||||||
boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
|
boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
|
||||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf[3];
|
std::array<boo::ObjToken<boo::IGraphicsBufferD>, 3> m_uniBuf;
|
||||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBind[3];
|
std::array<boo::ObjToken<boo::IShaderDataBinding>, 3> m_dataBind;
|
||||||
Uniform m_uniform;
|
Uniform m_uniform;
|
||||||
const CTexture* m_tex = nullptr;
|
const CTexture* m_tex = nullptr;
|
||||||
size_t m_maxVerts = 0;
|
size_t m_maxVerts = 0;
|
||||||
|
|
|
@ -20,21 +20,38 @@ void CEnvFxShaders::Shutdown() {
|
||||||
|
|
||||||
void CEnvFxShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CEnvFxManager& fxMgr,
|
void CEnvFxShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CEnvFxManager& fxMgr,
|
||||||
CEnvFxManagerGrid& grid) {
|
CEnvFxManagerGrid& grid) {
|
||||||
auto uBufInfo = grid.m_uniformBuf.getBufferInfo();
|
const auto uBufInfo = grid.m_uniformBuf.getBufferInfo();
|
||||||
auto iBufInfo = grid.m_instBuf.getBufferInfo();
|
const auto iBufInfo = grid.m_instBuf.getBufferInfo();
|
||||||
boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {uBufInfo.first.get(), fxMgr.m_fogUniformBuf.get()};
|
|
||||||
size_t ubufOffsets[] = {size_t(uBufInfo.second), 0};
|
const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 2> uniforms{{
|
||||||
size_t ubufSizes[] = {sizeof(CEnvFxShaders::Uniform), sizeof(CGraphics::g_Fog)};
|
uBufInfo.first.get(),
|
||||||
boo::PipelineStage uniformStages[] = {boo::PipelineStage::Vertex, boo::PipelineStage::Fragment};
|
fxMgr.m_fogUniformBuf.get(),
|
||||||
boo::ObjToken<boo::ITexture> textures[] = {fxMgr.xb74_txtrSnowFlake->GetBooTexture(),
|
}};
|
||||||
fxMgr.x40_txtrEnvGradient->GetBooTexture()};
|
const std::array<size_t, 2> ubufOffsets{
|
||||||
grid.m_snowBinding =
|
size_t(uBufInfo.second),
|
||||||
ctx.newShaderDataBinding(m_snowPipeline, nullptr, iBufInfo.first.get(), nullptr, 2, uniforms, uniformStages,
|
0,
|
||||||
ubufOffsets, ubufSizes, 2, textures, nullptr, nullptr, 0, iBufInfo.second);
|
};
|
||||||
|
constexpr std::array<size_t, 2> ubufSizes{
|
||||||
|
sizeof(CEnvFxShaders::Uniform),
|
||||||
|
sizeof(CGraphics::g_Fog),
|
||||||
|
};
|
||||||
|
constexpr std::array<boo::PipelineStage, 2> uniformStages{
|
||||||
|
boo::PipelineStage::Vertex,
|
||||||
|
boo::PipelineStage::Fragment,
|
||||||
|
};
|
||||||
|
std::array<boo::ObjToken<boo::ITexture>, 2> textures{
|
||||||
|
fxMgr.xb74_txtrSnowFlake->GetBooTexture(),
|
||||||
|
fxMgr.x40_txtrEnvGradient->GetBooTexture(),
|
||||||
|
};
|
||||||
|
|
||||||
|
grid.m_snowBinding = ctx.newShaderDataBinding(
|
||||||
|
m_snowPipeline, nullptr, iBufInfo.first.get(), nullptr, uniforms.size(), uniforms.data(), uniformStages.data(),
|
||||||
|
ubufOffsets.data(), ubufSizes.data(), textures.size(), textures.data(), nullptr, nullptr, 0, iBufInfo.second);
|
||||||
textures[0] = fxMgr.xc48_underwaterFlake->GetBooTexture();
|
textures[0] = fxMgr.xc48_underwaterFlake->GetBooTexture();
|
||||||
grid.m_underwaterBinding =
|
grid.m_underwaterBinding =
|
||||||
ctx.newShaderDataBinding(m_underwaterPipeline, nullptr, iBufInfo.first.get(), nullptr, 2, uniforms, uniformStages,
|
ctx.newShaderDataBinding(m_underwaterPipeline, nullptr, iBufInfo.first.get(), nullptr, uniforms.size(),
|
||||||
ubufOffsets, ubufSizes, 2, textures, nullptr, nullptr, 0, iBufInfo.second);
|
uniforms.data(), uniformStages.data(), ubufOffsets.data(), ubufSizes.data(),
|
||||||
|
textures.size(), textures.data(), nullptr, nullptr, 0, iBufInfo.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace urde
|
} // namespace urde
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||||
|
|
||||||
#include <zeus/CColor.hpp>
|
#include <zeus/CColor.hpp>
|
||||||
|
@ -14,9 +16,9 @@ class CEnvFxManagerGrid;
|
||||||
class CEnvFxShaders {
|
class CEnvFxShaders {
|
||||||
public:
|
public:
|
||||||
struct Instance {
|
struct Instance {
|
||||||
zeus::CVector3f positions[4];
|
std::array<zeus::CVector3f, 4> positions;
|
||||||
zeus::CColor color;
|
zeus::CColor color;
|
||||||
zeus::CVector2f uvs[4];
|
std::array<zeus::CVector2f, 4> uvs;
|
||||||
};
|
};
|
||||||
struct Uniform {
|
struct Uniform {
|
||||||
zeus::CMatrix4f mv;
|
zeus::CMatrix4f mv;
|
||||||
|
|
|
@ -124,38 +124,64 @@ void CFluidPlaneShader::Cache::Clear() {
|
||||||
void CFluidPlaneShader::PrepareBinding(u32 maxVertCount) {
|
void CFluidPlaneShader::PrepareBinding(u32 maxVertCount) {
|
||||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
||||||
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(Vertex), maxVertCount);
|
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(Vertex), maxVertCount);
|
||||||
if (m_pipelines.m_tessellation)
|
if (m_pipelines.m_tessellation) {
|
||||||
m_pvbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(PatchVertex), maxVertCount);
|
m_pvbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(PatchVertex), maxVertCount);
|
||||||
|
}
|
||||||
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
||||||
|
|
||||||
boo::ObjToken<boo::IGraphicsBuffer> ubufs[] = {m_uniBuf.get(), m_uniBuf.get(), m_uniBuf.get()};
|
const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 3> ubufs{{
|
||||||
boo::PipelineStage ubufStages[] = {boo::PipelineStage::Vertex, boo::PipelineStage::Vertex,
|
m_uniBuf.get(),
|
||||||
boo::PipelineStage::Fragment};
|
m_uniBuf.get(),
|
||||||
size_t ubufOffs[] = {0, 0, 1280};
|
m_uniBuf.get(),
|
||||||
size_t ubufSizes[] = {1280, 1280, sizeof(CModelShaders::LightingUniform)};
|
}};
|
||||||
|
constexpr std::array<boo::PipelineStage, 3> ubufStages{
|
||||||
|
boo::PipelineStage::Vertex,
|
||||||
|
boo::PipelineStage::Vertex,
|
||||||
|
boo::PipelineStage::Fragment,
|
||||||
|
};
|
||||||
|
constexpr std::array<size_t, 3> ubufOffs{
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1280,
|
||||||
|
};
|
||||||
|
constexpr std::array<size_t, 3> ubufSizes{
|
||||||
|
1280,
|
||||||
|
1280,
|
||||||
|
sizeof(CModelShaders::LightingUniform),
|
||||||
|
};
|
||||||
|
|
||||||
size_t texCount = 0;
|
size_t texCount = 0;
|
||||||
boo::ObjToken<boo::ITexture> texs[8];
|
std::array<boo::ObjToken<boo::ITexture>, 8> texs;
|
||||||
if (m_patternTex1)
|
if (m_patternTex1) {
|
||||||
texs[texCount++] = m_patternTex1->GetBooTexture();
|
texs[texCount++] = m_patternTex1->GetBooTexture();
|
||||||
if (m_patternTex2)
|
}
|
||||||
|
if (m_patternTex2) {
|
||||||
texs[texCount++] = m_patternTex2->GetBooTexture();
|
texs[texCount++] = m_patternTex2->GetBooTexture();
|
||||||
if (m_colorTex)
|
}
|
||||||
|
if (m_colorTex) {
|
||||||
texs[texCount++] = m_colorTex->GetBooTexture();
|
texs[texCount++] = m_colorTex->GetBooTexture();
|
||||||
if (m_bumpMap)
|
}
|
||||||
|
if (m_bumpMap) {
|
||||||
texs[texCount++] = m_bumpMap->GetBooTexture();
|
texs[texCount++] = m_bumpMap->GetBooTexture();
|
||||||
if (m_envMap)
|
}
|
||||||
|
if (m_envMap) {
|
||||||
texs[texCount++] = m_envMap->GetBooTexture();
|
texs[texCount++] = m_envMap->GetBooTexture();
|
||||||
if (m_envBumpMap)
|
}
|
||||||
|
if (m_envBumpMap) {
|
||||||
texs[texCount++] = m_envBumpMap->GetBooTexture();
|
texs[texCount++] = m_envBumpMap->GetBooTexture();
|
||||||
if (m_lightmap)
|
}
|
||||||
|
if (m_lightmap) {
|
||||||
texs[texCount++] = m_lightmap->GetBooTexture();
|
texs[texCount++] = m_lightmap->GetBooTexture();
|
||||||
auto regular = ctx.newShaderDataBinding(m_pipelines.m_regular, m_vbo.get(), nullptr, nullptr, 3, ubufs, ubufStages,
|
}
|
||||||
ubufOffs, ubufSizes, texCount, texs, nullptr, nullptr);
|
auto regular = ctx.newShaderDataBinding(m_pipelines.m_regular, m_vbo.get(), nullptr, nullptr, ubufs.size(),
|
||||||
|
ubufs.data(), ubufStages.data(), ubufOffs.data(), ubufSizes.data(),
|
||||||
|
texCount, texs.data(), nullptr, nullptr);
|
||||||
boo::ObjToken<boo::IShaderDataBinding> tessellation;
|
boo::ObjToken<boo::IShaderDataBinding> tessellation;
|
||||||
if (m_pipelines.m_tessellation) {
|
if (m_pipelines.m_tessellation) {
|
||||||
texs[texCount++] = m_rippleMap.get();
|
texs[texCount++] = m_rippleMap.get();
|
||||||
tessellation = ctx.newShaderDataBinding(m_pipelines.m_tessellation, m_pvbo.get(), nullptr, nullptr, 3, ubufs,
|
tessellation = ctx.newShaderDataBinding(m_pipelines.m_tessellation, m_pvbo.get(), nullptr, nullptr, ubufs.size(),
|
||||||
ubufStages, ubufOffs, ubufSizes, texCount, texs, nullptr, nullptr);
|
ubufs.data(), ubufStages.data(), ubufOffs.data(), ubufSizes.data(),
|
||||||
|
texCount, texs.data(), nullptr, nullptr);
|
||||||
}
|
}
|
||||||
m_dataBind = {regular, tessellation};
|
m_dataBind = {regular, tessellation};
|
||||||
return true;
|
return true;
|
||||||
|
@ -201,11 +227,11 @@ void CFluidPlaneShader::prepareDraw(const RenderSetupInfo& info) {
|
||||||
uni.m_mv = CGraphics::g_GXModelView.toMatrix4f();
|
uni.m_mv = CGraphics::g_GXModelView.toMatrix4f();
|
||||||
uni.m_mvNorm = info.normMtx;
|
uni.m_mvNorm = info.normMtx;
|
||||||
uni.m_proj = CGraphics::GetPerspectiveProjectionMatrix(true);
|
uni.m_proj = CGraphics::GetPerspectiveProjectionMatrix(true);
|
||||||
for (int i = 0; i < 6; ++i)
|
uni.m_texMtxs = info.texMtxs;
|
||||||
uni.m_texMtxs[i] = info.texMtxs[i];
|
|
||||||
uni.m_lighting.ActivateLights(info.lights);
|
uni.m_lighting.ActivateLights(info.lights);
|
||||||
for (int i = 0; i < 3; ++i)
|
for (size_t i = 0; i < uni.m_lighting.colorRegs.size(); ++i) {
|
||||||
uni.m_lighting.colorRegs[i] = info.kColors[i];
|
uni.m_lighting.colorRegs[i] = info.kColors[i];
|
||||||
|
}
|
||||||
uni.m_lighting.mulColor = info.kColors[3];
|
uni.m_lighting.mulColor = info.kColors[3];
|
||||||
uni.m_lighting.fog = CGraphics::g_Fog;
|
uni.m_lighting.fog = CGraphics::g_Fog;
|
||||||
uni.m_pad2.x() = info.indScale;
|
uni.m_pad2.x() = info.indScale;
|
||||||
|
@ -219,11 +245,11 @@ void CFluidPlaneShader::prepareDraw(const RenderSetupInfo& info, const zeus::CVe
|
||||||
uni.m_mv = CGraphics::g_GXModelView.toMatrix4f();
|
uni.m_mv = CGraphics::g_GXModelView.toMatrix4f();
|
||||||
uni.m_mvNorm = info.normMtx;
|
uni.m_mvNorm = info.normMtx;
|
||||||
uni.m_proj = CGraphics::GetPerspectiveProjectionMatrix(true);
|
uni.m_proj = CGraphics::GetPerspectiveProjectionMatrix(true);
|
||||||
for (int i = 0; i < 6; ++i)
|
uni.m_texMtxs = info.texMtxs;
|
||||||
uni.m_texMtxs[i] = info.texMtxs[i];
|
|
||||||
int i = 0;
|
size_t i = 0;
|
||||||
for (const CRipple& ripple : rippleManager.GetRipples()) {
|
for (const CRipple& ripple : rippleManager.GetRipples()) {
|
||||||
assert(i < 20 && "Too many ripples");
|
assert(i < uni.m_ripple.size() && "Too many ripples");
|
||||||
Ripple& rOut = uni.m_ripple[i++];
|
Ripple& rOut = uni.m_ripple[i++];
|
||||||
if (ripple.GetTime() >= ripple.GetTimeFalloff()) {
|
if (ripple.GetTime() >= ripple.GetTimeFalloff()) {
|
||||||
rOut.center.zeroOut();
|
rOut.center.zeroOut();
|
||||||
|
@ -243,8 +269,9 @@ void CFluidPlaneShader::prepareDraw(const RenderSetupInfo& info, const zeus::CVe
|
||||||
uni.m_colorMul = colorMul;
|
uni.m_colorMul = colorMul;
|
||||||
uni.m_pad[0].x() = rippleNormResolution;
|
uni.m_pad[0].x() = rippleNormResolution;
|
||||||
uni.m_lighting.ActivateLights(info.lights);
|
uni.m_lighting.ActivateLights(info.lights);
|
||||||
for (i = 0; i < 3; ++i)
|
for (i = 0; i < uni.m_lighting.colorRegs.size(); ++i) {
|
||||||
uni.m_lighting.colorRegs[i] = info.kColors[i];
|
uni.m_lighting.colorRegs[i] = info.kColors[i];
|
||||||
|
}
|
||||||
uni.m_lighting.mulColor = info.kColors[3];
|
uni.m_lighting.mulColor = info.kColors[3];
|
||||||
uni.m_lighting.fog = CGraphics::g_Fog;
|
uni.m_lighting.fog = CGraphics::g_Fog;
|
||||||
uni.m_pad2.x() = info.indScale;
|
uni.m_pad2.x() = info.indScale;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "Runtime/CToken.hpp"
|
#include "Runtime/CToken.hpp"
|
||||||
|
@ -39,15 +40,15 @@ public:
|
||||||
|
|
||||||
struct PatchVertex {
|
struct PatchVertex {
|
||||||
zeus::CVector4f m_pos;
|
zeus::CVector4f m_pos;
|
||||||
float m_outerLevels[4] = {};
|
std::array<float, 4> m_outerLevels{};
|
||||||
float m_innerLevels[4] = {};
|
std::array<float, 4> m_innerLevels{};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RenderSetupInfo {
|
struct RenderSetupInfo {
|
||||||
zeus::CMatrix4f texMtxs[6];
|
std::array<zeus::CMatrix4f, 6> texMtxs;
|
||||||
zeus::CMatrix4f normMtx;
|
zeus::CMatrix4f normMtx;
|
||||||
float indScale = 1.f;
|
float indScale = 1.f;
|
||||||
zeus::CColor kColors[4];
|
std::array<zeus::CColor, 4> kColors;
|
||||||
std::vector<CLight> lights;
|
std::vector<CLight> lights;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -67,8 +68,8 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
class Cache {
|
class Cache {
|
||||||
ShaderPair m_cache[1024] = {};
|
std::array<ShaderPair, 1024> m_cache{};
|
||||||
ShaderPair m_doorCache[8] = {};
|
std::array<ShaderPair, 8> m_doorCache{};
|
||||||
ShaderPair& CacheSlot(const SFluidPlaneShaderInfo& info, int i) { return m_cache[i]; }
|
ShaderPair& CacheSlot(const SFluidPlaneShaderInfo& info, int i) { return m_cache[i]; }
|
||||||
ShaderPair& CacheSlot(const SFluidPlaneDoorShaderInfo& info, int i) { return m_doorCache[i]; }
|
ShaderPair& CacheSlot(const SFluidPlaneDoorShaderInfo& info, int i) { return m_doorCache[i]; }
|
||||||
static u16 MakeCacheKey(const SFluidPlaneShaderInfo& info);
|
static u16 MakeCacheKey(const SFluidPlaneShaderInfo& info);
|
||||||
|
@ -90,10 +91,10 @@ private:
|
||||||
zeus::CMatrix4f m_mv;
|
zeus::CMatrix4f m_mv;
|
||||||
zeus::CMatrix4f m_mvNorm;
|
zeus::CMatrix4f m_mvNorm;
|
||||||
zeus::CMatrix4f m_proj;
|
zeus::CMatrix4f m_proj;
|
||||||
zeus::CMatrix4f m_texMtxs[6];
|
std::array<zeus::CMatrix4f, 6> m_texMtxs;
|
||||||
Ripple m_ripple[20];
|
std::array<Ripple, 20> m_ripple;
|
||||||
zeus::CVector4f m_colorMul;
|
zeus::CVector4f m_colorMul;
|
||||||
zeus::CVector4f m_pad[3]; // rippleNormResolution, Pad out to 1280 bytes
|
std::array<zeus::CVector4f, 3> m_pad; // rippleNormResolution, Pad out to 1280 bytes
|
||||||
CModelShaders::LightingUniform m_lighting;
|
CModelShaders::LightingUniform m_lighting;
|
||||||
zeus::CVector3f m_pad2; // Pad out to 768 bytes, also holds ind scale
|
zeus::CVector3f m_pad2; // Pad out to 768 bytes, also holds ind scale
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
namespace urde {
|
namespace urde {
|
||||||
|
|
||||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipelines[4];
|
static std::array<boo::ObjToken<boo::IShaderPipeline>, 4> s_Pipelines;
|
||||||
|
|
||||||
void CFogVolumePlaneShader::Initialize() {
|
void CFogVolumePlaneShader::Initialize() {
|
||||||
s_Pipelines[0] = hecl::conv->convert(Shader_CFogVolumePlaneShader0{});
|
s_Pipelines[0] = hecl::conv->convert(Shader_CFogVolumePlaneShader0{});
|
||||||
|
@ -26,9 +26,10 @@ void CFogVolumePlaneShader::CommitResources(size_t capacity) {
|
||||||
m_vertCapacity = capacity;
|
m_vertCapacity = capacity;
|
||||||
CGraphics::CommitResources([this, capacity](boo::IGraphicsDataFactory::Context& ctx) {
|
CGraphics::CommitResources([this, capacity](boo::IGraphicsDataFactory::Context& ctx) {
|
||||||
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(zeus::CVector4f), capacity);
|
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(zeus::CVector4f), capacity);
|
||||||
for (int i = 0; i < 4; ++i)
|
for (size_t i = 0; i < m_dataBinds.size(); ++i) {
|
||||||
m_dataBinds[i] = ctx.newShaderDataBinding(s_Pipelines[i], m_vbo.get(), nullptr, nullptr, 0, nullptr, nullptr,
|
m_dataBinds[i] = ctx.newShaderDataBinding(s_Pipelines[i], m_vbo.get(), nullptr, nullptr, 0, nullptr, nullptr,
|
||||||
nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
} BooTrace);
|
} BooTrace);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -16,7 +17,7 @@ namespace urde {
|
||||||
|
|
||||||
class CFogVolumePlaneShader {
|
class CFogVolumePlaneShader {
|
||||||
boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
|
boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
|
||||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBinds[4];
|
std::array<boo::ObjToken<boo::IShaderDataBinding>, 4> m_dataBinds;
|
||||||
std::vector<zeus::CVector4f> m_verts;
|
std::vector<zeus::CVector4f> m_verts;
|
||||||
size_t m_vertCapacity = 0;
|
size_t m_vertCapacity = 0;
|
||||||
|
|
||||||
|
|
|
@ -91,8 +91,8 @@ void CLineRendererShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Con
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int texCount = 0;
|
size_t texCount = 0;
|
||||||
boo::ObjToken<boo::ITexture> textures[1];
|
std::array<boo::ObjToken<boo::ITexture>, 1> textures;
|
||||||
|
|
||||||
std::pair<boo::ObjToken<boo::IGraphicsBufferD>, hecl::VertexBufferPool<CLineRenderer::SDrawVertTex>::IndexTp>
|
std::pair<boo::ObjToken<boo::IGraphicsBufferD>, hecl::VertexBufferPool<CLineRenderer::SDrawVertTex>::IndexTp>
|
||||||
vbufInfo;
|
vbufInfo;
|
||||||
|
@ -106,15 +106,16 @@ void CLineRendererShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Con
|
||||||
vbufInfo = renderer.m_vertBufNoTex.getBufferInfo();
|
vbufInfo = renderer.m_vertBufNoTex.getBufferInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {ubufInfo.first.get()};
|
const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> uniforms{ubufInfo.first.get()};
|
||||||
boo::PipelineStage stages[] = {boo::PipelineStage::Fragment};
|
constexpr std::array<boo::PipelineStage, 1> stages{boo::PipelineStage::Fragment};
|
||||||
size_t ubufOffs[] = {size_t(ubufInfo.second)};
|
const std::array<size_t, 1> ubufOffs{size_t(ubufInfo.second)};
|
||||||
size_t ubufSizes[] = {sizeof(CLineRenderer::SDrawUniform)};
|
const std::array<size_t, 1> ubufSizes{sizeof(CLineRenderer::SDrawUniform)};
|
||||||
|
|
||||||
for (int i = 0; i < 2; ++i)
|
for (size_t i = 0; i < std::size(renderer.m_shaderBind); ++i) {
|
||||||
renderer.m_shaderBind[i] =
|
renderer.m_shaderBind[i] = ctx.newShaderDataBinding(
|
||||||
ctx.newShaderDataBinding((*pipeline)[i], vbufInfo.first.get(), nullptr, nullptr, 1, uniforms, stages, ubufOffs,
|
(*pipeline)[i], vbufInfo.first.get(), nullptr, nullptr, uniforms.size(), uniforms.data(), stages.data(),
|
||||||
ubufSizes, texCount, textures, nullptr, nullptr, vbufInfo.second);
|
ubufOffs.data(), ubufSizes.data(), texCount, textures.data(), nullptr, nullptr, vbufInfo.second);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace urde
|
} // namespace urde
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "Runtime/Graphics/Shaders/CMapSurfaceShader.hpp"
|
#include "Runtime/Graphics/Shaders/CMapSurfaceShader.hpp"
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
#include "Runtime/Graphics/CGraphics.hpp"
|
#include "Runtime/Graphics/CGraphics.hpp"
|
||||||
|
|
||||||
#include <hecl/Pipeline.hpp>
|
#include <hecl/Pipeline.hpp>
|
||||||
|
@ -17,10 +19,10 @@ CMapSurfaceShader::CMapSurfaceShader(boo::IGraphicsDataFactory::Context& ctx,
|
||||||
const boo::ObjToken<boo::IGraphicsBufferS>& ibo)
|
const boo::ObjToken<boo::IGraphicsBufferS>& ibo)
|
||||||
: m_vbo(vbo), m_ibo(ibo) {
|
: m_vbo(vbo), m_ibo(ibo) {
|
||||||
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
||||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {m_uniBuf.get()};
|
const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> bufs{m_uniBuf.get()};
|
||||||
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
|
constexpr std::array<boo::PipelineStage, 1> stages{boo::PipelineStage::Vertex};
|
||||||
m_dataBind = ctx.newShaderDataBinding(s_Pipeline, m_vbo.get(), nullptr, m_ibo.get(), 1, bufs, stages, nullptr,
|
m_dataBind = ctx.newShaderDataBinding(s_Pipeline, m_vbo.get(), nullptr, m_ibo.get(), bufs.size(), bufs.data(),
|
||||||
nullptr, 0, nullptr, nullptr, nullptr);
|
stages.data(), nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMapSurfaceShader::draw(const zeus::CColor& color, u32 start, u32 count) {
|
void CMapSurfaceShader::draw(const zeus::CColor& color, u32 start, u32 count) {
|
||||||
|
|
|
@ -23,8 +23,9 @@ void CModelShaders::LightingUniform::ActivateLights(const std::vector<CLight>& l
|
||||||
case ELightType::Spot:
|
case ELightType::Spot:
|
||||||
case ELightType::Custom:
|
case ELightType::Custom:
|
||||||
case ELightType::Directional: {
|
case ELightType::Directional: {
|
||||||
if (curLight >= URDE_MAX_LIGHTS)
|
if (curLight >= lights.size()) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
CModelShaders::Light& lightOut = lights[curLight++];
|
CModelShaders::Light& lightOut = lights[curLight++];
|
||||||
lightOut.pos = CGraphics::g_CameraMatrix * light.GetPosition();
|
lightOut.pos = CGraphics::g_CameraMatrix * light.GetPosition();
|
||||||
lightOut.dir = CGraphics::g_CameraMatrix.basis * light.GetDirection();
|
lightOut.dir = CGraphics::g_CameraMatrix.basis * light.GetDirection();
|
||||||
|
@ -44,7 +45,7 @@ void CModelShaders::LightingUniform::ActivateLights(const std::vector<CLight>& l
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; curLight < URDE_MAX_LIGHTS; ++curLight) {
|
for (; curLight < lights.size(); ++curLight) {
|
||||||
CModelShaders::Light& lightOut = lights[curLight];
|
CModelShaders::Light& lightOut = lights[curLight];
|
||||||
lightOut.pos = zeus::skZero3f;
|
lightOut.pos = zeus::skZero3f;
|
||||||
lightOut.dir = zeus::skDown;
|
lightOut.dir = zeus::skDown;
|
||||||
|
@ -60,93 +61,94 @@ void CModelShaders::LightingUniform::ActivateLights(const std::vector<CLight>& l
|
||||||
|
|
||||||
using TexCoordSource = hecl::Backend::TexCoordSource;
|
using TexCoordSource = hecl::Backend::TexCoordSource;
|
||||||
|
|
||||||
static const hecl::Backend::TextureInfo ThermalTextures[] = {{TexCoordSource::Normal, 7, true}};
|
constexpr std::array<hecl::Backend::TextureInfo, 1> ThermalTextures{{
|
||||||
|
{TexCoordSource::Normal, 7, true},
|
||||||
|
}};
|
||||||
|
|
||||||
static const hecl::Backend::TextureInfo BallFadeTextures[] = {
|
constexpr std::array<hecl::Backend::TextureInfo, 3> BallFadeTextures{{
|
||||||
{TexCoordSource::Position, 0, false}, // ID tex
|
{TexCoordSource::Position, 0, false}, // ID tex
|
||||||
{TexCoordSource::Position, 0, false}, // Sphere ramp
|
{TexCoordSource::Position, 0, false}, // Sphere ramp
|
||||||
{TexCoordSource::Position, 1, false} // TXTR_BallFade
|
{TexCoordSource::Position, 1, false}, // TXTR_BallFade
|
||||||
};
|
}};
|
||||||
|
|
||||||
static const hecl::Backend::TextureInfo WorldShadowTextures[] = {
|
constexpr std::array<hecl::Backend::TextureInfo, 1> WorldShadowTextures{{
|
||||||
{TexCoordSource::Position, 7, false} // Shadow tex
|
{TexCoordSource::Position, 7, false}, // Shadow tex
|
||||||
};
|
}};
|
||||||
|
|
||||||
static const hecl::Backend::TextureInfo DisintegrateTextures[] = {
|
constexpr std::array<hecl::Backend::TextureInfo, 2> DisintegrateTextures{{
|
||||||
{TexCoordSource::Position, 0, false}, // Ashy tex
|
{TexCoordSource::Position, 0, false}, // Ashy tex
|
||||||
{TexCoordSource::Position, 1, false} // Ashy tex
|
{TexCoordSource::Position, 1, false}, // Ashy tex
|
||||||
};
|
}};
|
||||||
|
|
||||||
static hecl::Backend::ExtensionSlot g_ExtensionSlots[] = {
|
static std::array<hecl::Backend::ExtensionSlot, 26> g_ExtensionSlots{{
|
||||||
/* Default solid shading */
|
/* Default solid shading */
|
||||||
{},
|
{},
|
||||||
/* Normal lit shading */
|
/* Normal lit shading */
|
||||||
{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},
|
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface, false, false, true},
|
||||||
/* Thermal Visor shading */
|
/* Thermal Visor shading */
|
||||||
{1, ThermalTextures, hecl::Backend::BlendFactor::One, hecl::Backend::BlendFactor::One,
|
{1, ThermalTextures.data(), hecl::Backend::BlendFactor::One, hecl::Backend::BlendFactor::One,
|
||||||
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface, false, false, false, true},
|
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface, false, false, false, true},
|
||||||
/* Forced alpha shading */
|
/* Forced alpha shading */
|
||||||
{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},
|
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface, false, false, true},
|
||||||
/* Forced additive shading */
|
/* Forced additive shading */
|
||||||
{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::ZTest::Original, hecl::Backend::CullMode::Backface, false, false, true},
|
hecl::Backend::CullMode::Backface, false, false, true},
|
||||||
/* Solid color */
|
/* Solid color */
|
||||||
{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::ZTest::LEqual, hecl::Backend::CullMode::Backface, false, false, false},
|
hecl::Backend::CullMode::Backface, false, false, false},
|
||||||
/* Solid color additive */
|
/* Solid color additive */
|
||||||
{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::ZTest::LEqual, hecl::Backend::CullMode::Backface, true, false, true},
|
hecl::Backend::CullMode::Backface, true, false, true},
|
||||||
/* Alpha-only Solid color frontface cull, LEqual */
|
/* Alpha-only Solid color frontface cull, LEqual */
|
||||||
{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::ZTest::LEqual, hecl::Backend::CullMode::Frontface, false, true, false},
|
hecl::Backend::CullMode::Frontface, false, true, false},
|
||||||
/* Alpha-only Solid color frontface cull, Always, No Z-write */
|
/* Alpha-only Solid color frontface cull, Always, No Z-write */
|
||||||
{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::ZTest::None, hecl::Backend::CullMode::Frontface, true, true, false},
|
hecl::Backend::CullMode::Frontface, true, true, false},
|
||||||
/* Alpha-only Solid color backface cull, LEqual */
|
/* Alpha-only Solid color backface cull, LEqual */
|
||||||
{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::ZTest::LEqual, hecl::Backend::CullMode::Backface, false, true, false},
|
hecl::Backend::CullMode::Backface, false, true, false},
|
||||||
/* Alpha-only Solid color backface cull, Greater, No Z-write */
|
/* Alpha-only Solid color backface cull, Greater, No Z-write */
|
||||||
{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::ZTest::Greater, hecl::Backend::CullMode::Backface, true, true, false},
|
hecl::Backend::CullMode::Backface, true, true, false},
|
||||||
/* MorphBall shadow shading */
|
/* MorphBall shadow shading */
|
||||||
{3, BallFadeTextures, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::InvSrcAlpha,
|
{3, BallFadeTextures.data(), hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::InvSrcAlpha,
|
||||||
hecl::Backend::ZTest::Equal, hecl::Backend::CullMode::Backface, false, false, true, false, true},
|
hecl::Backend::ZTest::Equal, hecl::Backend::CullMode::Backface, false, false, true, false, true},
|
||||||
/* World shadow shading (modified lighting) */
|
/* World shadow shading (modified lighting) */
|
||||||
{1, WorldShadowTextures, hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original,
|
{1, WorldShadowTextures.data(), hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original,
|
||||||
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface, false, false, true},
|
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface, false, false, true},
|
||||||
/* Forced alpha shading without culling */
|
/* Forced alpha shading without culling */
|
||||||
{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},
|
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::None, false, false, true},
|
||||||
/* Forced additive shading without culling */
|
/* Forced additive shading without culling */
|
||||||
{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::ZTest::Original, hecl::Backend::CullMode::None, false, false, true},
|
hecl::Backend::CullMode::None, false, false, true},
|
||||||
/* Forced alpha shading without Z-write */
|
/* Forced alpha shading without Z-write */
|
||||||
{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},
|
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Original, true, false, true},
|
||||||
/* Forced additive shading without Z-write */
|
/* Forced additive shading without Z-write */
|
||||||
{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::ZTest::Original, hecl::Backend::CullMode::Original, true, false, true},
|
hecl::Backend::CullMode::Original, true, false, true},
|
||||||
/* Forced alpha shading without culling or Z-write */
|
/* Forced alpha shading without culling or Z-write */
|
||||||
{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},
|
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::None, true, false, true},
|
||||||
/* Forced additive shading without culling or Z-write */
|
/* Forced additive shading without culling or Z-write */
|
||||||
{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::ZTest::Original, hecl::Backend::CullMode::None, true, false, true},
|
hecl::Backend::CullMode::None, true, false, true},
|
||||||
/* Depth GEqual no Z-write */
|
/* Depth GEqual no Z-write */
|
||||||
{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},
|
hecl::Backend::ZTest::GEqual, hecl::Backend::CullMode::Backface, true, false, true},
|
||||||
/* Disintegration */
|
/* Disintegration */
|
||||||
{2, DisintegrateTextures, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::InvSrcAlpha,
|
{2, DisintegrateTextures.data(), hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::InvSrcAlpha,
|
||||||
hecl::Backend::ZTest::LEqual, hecl::Backend::CullMode::Original, false, false, true, false, false, true},
|
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 */
|
/* Forced additive shading without culling or Z-write and greater depth test */
|
||||||
{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::ZTest::Greater, hecl::Backend::CullMode::None, true, false, true},
|
hecl::Backend::CullMode::None, true, false, true},
|
||||||
/* Thermal cold shading */
|
/* Thermal cold shading */
|
||||||
{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,
|
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Original, false, false, true, false, false, false, true},
|
||||||
false, false, true, false, false, false, true},
|
|
||||||
/* Normal lit shading with alpha */
|
/* Normal lit shading with alpha */
|
||||||
{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},
|
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface},
|
||||||
|
@ -154,10 +156,11 @@ static hecl::Backend::ExtensionSlot g_ExtensionSlots[] = {
|
||||||
{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},
|
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface, false, false, true},
|
||||||
/* Normal lit shading with cube reflection and world shadow */
|
/* Normal lit shading with cube reflection and world shadow */
|
||||||
{1, WorldShadowTextures, hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original,
|
{1, WorldShadowTextures.data(), hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original,
|
||||||
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface, false, false, true}};
|
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface, false, false, true},
|
||||||
|
}};
|
||||||
|
|
||||||
static const char* ShaderMacros[] = {
|
constexpr std::array<const char*, 26> ShaderMacros{
|
||||||
"URDE_LIGHTING",
|
"URDE_LIGHTING",
|
||||||
"URDE_LIGHTING",
|
"URDE_LIGHTING",
|
||||||
"URDE_THERMAL_HOT",
|
"URDE_THERMAL_HOT",
|
||||||
|
@ -187,9 +190,9 @@ static const char* ShaderMacros[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
void CModelShaders::Initialize() {
|
void CModelShaders::Initialize() {
|
||||||
const char** macro = ShaderMacros;
|
for (size_t i = 0; i < g_ExtensionSlots.size(); i++) {
|
||||||
for (auto& ext : g_ExtensionSlots)
|
g_ExtensionSlots[i].shaderMacro = ShaderMacros[i];
|
||||||
ext.shaderMacro = *macro++;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CModelShaders::Shutdown() { g_ShaderPipelines.clear(); }
|
void CModelShaders::Shutdown() { g_ShaderPipelines.clear(); }
|
||||||
|
|
|
@ -59,14 +59,14 @@ public:
|
||||||
zeus::CVector3f pos;
|
zeus::CVector3f pos;
|
||||||
zeus::CVector3f dir;
|
zeus::CVector3f dir;
|
||||||
zeus::CColor color = zeus::skClear;
|
zeus::CColor color = zeus::skClear;
|
||||||
float linAtt[4] = {1.f, 0.f, 0.f};
|
std::array<float, 4> linAtt{1.f, 0.f, 0.f};
|
||||||
float angAtt[4] = {1.f, 0.f, 0.f};
|
std::array<float, 4> angAtt{1.f, 0.f, 0.f};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LightingUniform {
|
struct LightingUniform {
|
||||||
Light lights[URDE_MAX_LIGHTS];
|
std::array<Light, URDE_MAX_LIGHTS> lights;
|
||||||
zeus::CColor ambient;
|
zeus::CColor ambient;
|
||||||
zeus::CColor colorRegs[3];
|
std::array<zeus::CColor, 3> colorRegs;
|
||||||
zeus::CColor mulColor;
|
zeus::CColor mulColor;
|
||||||
zeus::CColor addColor;
|
zeus::CColor addColor;
|
||||||
CGraphics::CFogState fog;
|
CGraphics::CFogState fog;
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "Runtime/Graphics/Shaders/CParticleSwooshShaders.hpp"
|
#include "Runtime/Graphics/Shaders/CParticleSwooshShaders.hpp"
|
||||||
|
|
||||||
|
#include <iterator>
|
||||||
|
|
||||||
#include "Runtime/Particle/CParticleSwoosh.hpp"
|
#include "Runtime/Particle/CParticleSwoosh.hpp"
|
||||||
#include "Runtime/Particle/CSwooshDescription.hpp"
|
#include "Runtime/Particle/CSwooshDescription.hpp"
|
||||||
|
|
||||||
|
@ -88,13 +90,17 @@ void CParticleSwooshShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::C
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CUVElement* texr = desc->x3c_TEXR.get();
|
const CUVElement* const texr = desc->x3c_TEXR.get();
|
||||||
boo::ObjToken<boo::ITexture> textures[] = {texr ? texr->GetValueTexture(0).GetObj()->GetBooTexture() : nullptr};
|
const std::array<boo::ObjToken<boo::ITexture>, 1> textures{
|
||||||
|
texr ? texr->GetValueTexture(0).GetObj()->GetBooTexture() : nullptr,
|
||||||
|
};
|
||||||
|
|
||||||
boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {gen.m_uniformBuf.get()};
|
const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> uniforms{gen.m_uniformBuf.get()};
|
||||||
for (int i = 0; i < 2; ++i)
|
for (size_t i = 0; i < std::size(gen.m_dataBind); ++i) {
|
||||||
gen.m_dataBind[i] = ctx.newShaderDataBinding((*pipeline)[i], gen.m_vertBuf.get(), nullptr, nullptr, 1, uniforms,
|
gen.m_dataBind[i] =
|
||||||
nullptr, texr ? 1 : 0, textures, nullptr, nullptr);
|
ctx.newShaderDataBinding((*pipeline)[i], gen.m_vertBuf.get(), nullptr, nullptr, uniforms.size(),
|
||||||
|
uniforms.data(), nullptr, texr ? 1 : 0, textures.data(), nullptr, nullptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace urde
|
} // namespace urde
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "Runtime/Graphics/Shaders/CPhazonSuitFilter.hpp"
|
#include "Runtime/Graphics/Shaders/CPhazonSuitFilter.hpp"
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
#include "Runtime/Graphics/CGraphics.hpp"
|
#include "Runtime/Graphics/CGraphics.hpp"
|
||||||
#include "Runtime/Graphics/CTexture.hpp"
|
#include "Runtime/Graphics/CTexture.hpp"
|
||||||
|
|
||||||
|
@ -42,38 +44,46 @@ void CPhazonSuitFilter::drawBlurPasses(float radius, const CTexture* indTex) {
|
||||||
struct BlurVert {
|
struct BlurVert {
|
||||||
zeus::CVector3f pos;
|
zeus::CVector3f pos;
|
||||||
zeus::CVector2f uv;
|
zeus::CVector2f uv;
|
||||||
} blurVerts[4] = {{{-1.f, 1.f, 0.f}, {0.f, 1.f}},
|
};
|
||||||
|
const std::array<BlurVert, 4> blurVerts{{
|
||||||
|
{{-1.f, 1.f, 0.f}, {0.f, 1.f}},
|
||||||
{{-1.f, -1.f, 0.f}, {0.f, 0.f}},
|
{{-1.f, -1.f, 0.f}, {0.f, 0.f}},
|
||||||
{{1.f, 1.f, 0.f}, {1.f, 1.f}},
|
{{1.f, 1.f, 0.f}, {1.f, 1.f}},
|
||||||
{{1.f, -1.f, 0.f}, {1.f, 0.f}}};
|
{{1.f, -1.f, 0.f}, {1.f, 0.f}},
|
||||||
m_blurVbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, blurVerts, sizeof(BlurVert), 4);
|
}};
|
||||||
|
m_blurVbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, blurVerts.data(), sizeof(BlurVert), blurVerts.size());
|
||||||
|
|
||||||
struct Vert {
|
struct Vert {
|
||||||
zeus::CVector3f pos;
|
zeus::CVector3f pos;
|
||||||
zeus::CVector2f screenUv;
|
zeus::CVector2f screenUv;
|
||||||
zeus::CVector2f indUv;
|
zeus::CVector2f indUv;
|
||||||
zeus::CVector2f maskUv;
|
zeus::CVector2f maskUv;
|
||||||
} verts[4] = {{{-1.f, 1.f, 0.f}, {0.01f, 0.99f}, {0.f, 4.f}, {0.f, 1.f}},
|
};
|
||||||
|
const std::array<Vert, 4> verts{{
|
||||||
|
{{-1.f, 1.f, 0.f}, {0.01f, 0.99f}, {0.f, 4.f}, {0.f, 1.f}},
|
||||||
{{-1.f, -1.f, 0.f}, {0.01f, 0.01f}, {0.f, 0.f}, {0.f, 0.f}},
|
{{-1.f, -1.f, 0.f}, {0.01f, 0.01f}, {0.f, 0.f}, {0.f, 0.f}},
|
||||||
{{1.f, 1.f, 0.f}, {0.99f, 0.99f}, {g_Viewport.aspect * 4.f, 4.f}, {1.f, 1.f}},
|
{{1.f, 1.f, 0.f}, {0.99f, 0.99f}, {g_Viewport.aspect * 4.f, 4.f}, {1.f, 1.f}},
|
||||||
{{1.f, -1.f, 0.f}, {0.99f, 0.01f}, {g_Viewport.aspect * 4.f, 0.f}, {1.f, 0.f}}};
|
{{1.f, -1.f, 0.f}, {0.99f, 0.01f}, {g_Viewport.aspect * 4.f, 0.f}, {1.f, 0.f}},
|
||||||
m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts, sizeof(Vert), 4);
|
}};
|
||||||
|
m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts.data(), sizeof(Vert), verts.size());
|
||||||
|
|
||||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {m_uniBufBlurX.get()};
|
std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> bufs{m_uniBufBlurX.get()};
|
||||||
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
|
constexpr std::array<boo::PipelineStage, 1> stages{boo::PipelineStage::Vertex};
|
||||||
boo::ObjToken<boo::ITexture> texs[4];
|
std::array<boo::ObjToken<boo::ITexture>, 4> texs;
|
||||||
int texBindIdxs[4];
|
std::array<int, 4> texBindIdxs;
|
||||||
|
|
||||||
texs[0] = CGraphics::g_SpareTexture.get();
|
texs[0] = CGraphics::g_SpareTexture.get();
|
||||||
texBindIdxs[0] = 1;
|
texBindIdxs[0] = 1;
|
||||||
m_dataBindBlurX = ctx.newShaderDataBinding(s_BlurPipeline, m_blurVbo.get(), nullptr, nullptr, 1, bufs, stages,
|
m_dataBindBlurX =
|
||||||
nullptr, nullptr, 1, texs, texBindIdxs, nullptr);
|
ctx.newShaderDataBinding(s_BlurPipeline, m_blurVbo.get(), nullptr, nullptr, bufs.size(), bufs.data(),
|
||||||
|
stages.data(), nullptr, nullptr, 1, texs.data(), texBindIdxs.data(), nullptr);
|
||||||
|
|
||||||
bufs[0] = m_uniBufBlurY.get();
|
bufs[0] = m_uniBufBlurY.get();
|
||||||
texs[0] = CGraphics::g_SpareTexture.get();
|
texs[0] = CGraphics::g_SpareTexture.get();
|
||||||
texBindIdxs[0] = 2;
|
texBindIdxs[0] = 2;
|
||||||
m_dataBindBlurY = ctx.newShaderDataBinding(s_BlurPipeline, m_blurVbo.get(), nullptr, nullptr, 1, bufs, stages,
|
m_dataBindBlurY =
|
||||||
nullptr, nullptr, 1, texs, texBindIdxs, nullptr);
|
ctx.newShaderDataBinding(s_BlurPipeline, m_blurVbo.get(), nullptr, nullptr, bufs.size(), bufs.data(),
|
||||||
|
stages.data(), nullptr, nullptr, 1, texs.data(), texBindIdxs.data(), nullptr);
|
||||||
|
|
||||||
bufs[0] = m_uniBuf.get();
|
bufs[0] = m_uniBuf.get();
|
||||||
size_t texCount;
|
size_t texCount;
|
||||||
|
@ -97,8 +107,9 @@ void CPhazonSuitFilter::drawBlurPasses(float radius, const CTexture* indTex) {
|
||||||
texCount = 3;
|
texCount = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_dataBind = ctx.newShaderDataBinding(m_indTex ? s_IndPipeline : s_Pipeline, m_vbo.get(), nullptr, nullptr, 1,
|
m_dataBind = ctx.newShaderDataBinding(m_indTex ? s_IndPipeline : s_Pipeline, m_vbo.get(), nullptr, nullptr,
|
||||||
bufs, stages, nullptr, nullptr, texCount, texs, texBindIdxs, nullptr);
|
bufs.size(), bufs.data(), stages.data(), nullptr, nullptr, texCount,
|
||||||
|
texs.data(), texBindIdxs.data(), nullptr);
|
||||||
return true;
|
return true;
|
||||||
} BooTrace);
|
} BooTrace);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,11 +26,14 @@ void CRadarPaintShader::draw(const std::vector<Instance>& instances, const CText
|
||||||
CGraphics::CommitResources([this](boo::IGraphicsDataFactory::Context& ctx) {
|
CGraphics::CommitResources([this](boo::IGraphicsDataFactory::Context& ctx) {
|
||||||
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(Instance), m_maxInsts);
|
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(Instance), m_maxInsts);
|
||||||
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(zeus::CMatrix4f), 1);
|
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(zeus::CMatrix4f), 1);
|
||||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {m_uniBuf.get()};
|
|
||||||
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
|
const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> bufs{m_uniBuf.get()};
|
||||||
boo::ObjToken<boo::ITexture> texs[] = {m_tex->GetBooTexture()};
|
constexpr std::array<boo::PipelineStage, 1> stages{boo::PipelineStage::Vertex};
|
||||||
m_dataBind = ctx.newShaderDataBinding(s_Pipeline, nullptr, m_vbo.get(), nullptr, 1, bufs, stages, nullptr,
|
const std::array<boo::ObjToken<boo::ITexture>, 1> texs{m_tex->GetBooTexture()};
|
||||||
nullptr, 1, texs, nullptr, nullptr);
|
|
||||||
|
m_dataBind =
|
||||||
|
ctx.newShaderDataBinding(s_Pipeline, nullptr, m_vbo.get(), nullptr, bufs.size(), bufs.data(), stages.data(),
|
||||||
|
nullptr, nullptr, texs.size(), texs.data(), nullptr, nullptr);
|
||||||
return true;
|
return true;
|
||||||
} BooTrace);
|
} BooTrace);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||||
|
@ -14,8 +15,8 @@ class CTexture;
|
||||||
class CRadarPaintShader {
|
class CRadarPaintShader {
|
||||||
public:
|
public:
|
||||||
struct Instance {
|
struct Instance {
|
||||||
zeus::CVector3f pos[4];
|
std::array<zeus::CVector3f, 4> pos;
|
||||||
zeus::CVector2f uv[4];
|
std::array<zeus::CVector2f, 4> uv;
|
||||||
zeus::CColor color;
|
zeus::CColor color;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "Runtime/Graphics/Shaders/CRandomStaticFilter.hpp"
|
#include "Runtime/Graphics/Shaders/CRandomStaticFilter.hpp"
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
#include "Runtime/GameGlobalObjects.hpp"
|
#include "Runtime/GameGlobalObjects.hpp"
|
||||||
#include "Runtime/Camera/CCameraFilter.hpp"
|
#include "Runtime/Camera/CCameraFilter.hpp"
|
||||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||||
|
@ -45,20 +47,22 @@ CRandomStaticFilter::CRandomStaticFilter(EFilterType type, bool cookieCutter) :
|
||||||
struct Vert {
|
struct Vert {
|
||||||
zeus::CVector2f m_pos;
|
zeus::CVector2f m_pos;
|
||||||
zeus::CVector2f m_uv;
|
zeus::CVector2f m_uv;
|
||||||
} verts[4] = {
|
};
|
||||||
|
const std::array<Vert, 4> verts{{
|
||||||
{{-1.f, -1.f}, {0.f, 0.f}},
|
{{-1.f, -1.f}, {0.f, 0.f}},
|
||||||
{{-1.f, 1.f}, {0.f, 448.f}},
|
{{-1.f, 1.f}, {0.f, 448.f}},
|
||||||
{{1.f, -1.f}, {640.f, 0.f}},
|
{{1.f, -1.f}, {640.f, 0.f}},
|
||||||
{{1.f, 1.f}, {640.f, 448.f}},
|
{{1.f, 1.f}, {640.f, 448.f}},
|
||||||
};
|
}};
|
||||||
m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts, sizeof(Vert), 4);
|
m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts.data(), sizeof(Vert), verts.size());
|
||||||
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
||||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {m_uniBuf.get()};
|
|
||||||
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
|
const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> bufs{m_uniBuf.get()};
|
||||||
boo::ObjToken<boo::ITexture> texs[] = {g_Renderer->GetRandomStaticEntropyTex()};
|
constexpr std::array<boo::PipelineStage, 1> stages{boo::PipelineStage::Vertex};
|
||||||
m_dataBind =
|
const std::array<boo::ObjToken<boo::ITexture>, 1> texs{g_Renderer->GetRandomStaticEntropyTex()};
|
||||||
ctx.newShaderDataBinding(m_cookieCutter ? s_CookieCutterPipeline : SelectPipeline(type), m_vbo.get(), nullptr,
|
m_dataBind = ctx.newShaderDataBinding(m_cookieCutter ? s_CookieCutterPipeline : SelectPipeline(type), m_vbo.get(),
|
||||||
nullptr, 1, bufs, stages, nullptr, nullptr, 1, texs, nullptr, nullptr);
|
nullptr, nullptr, bufs.size(), bufs.data(), stages.data(), nullptr, nullptr,
|
||||||
|
texs.size(), texs.data(), nullptr, nullptr);
|
||||||
return true;
|
return true;
|
||||||
} BooTrace);
|
} BooTrace);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "Runtime/Graphics/Shaders/CScanLinesFilter.hpp"
|
#include "Runtime/Graphics/Shaders/CScanLinesFilter.hpp"
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
#include "Runtime/GameGlobalObjects.hpp"
|
#include "Runtime/GameGlobalObjects.hpp"
|
||||||
#include "Runtime/Camera/CCameraFilter.hpp"
|
#include "Runtime/Camera/CCameraFilter.hpp"
|
||||||
#include "Runtime/Graphics/CBooRenderer.hpp"
|
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||||
|
@ -43,10 +45,11 @@ CScanLinesFilter::CScanLinesFilter(EFilterType type, bool even) : m_even(even) {
|
||||||
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
||||||
boo::ObjToken<boo::IGraphicsBuffer> vbo =
|
boo::ObjToken<boo::IGraphicsBuffer> vbo =
|
||||||
m_even ? g_Renderer->GetScanLinesEvenVBO().get() : g_Renderer->GetScanLinesOddVBO().get();
|
m_even ? g_Renderer->GetScanLinesEvenVBO().get() : g_Renderer->GetScanLinesOddVBO().get();
|
||||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {m_uniBuf.get()};
|
const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> bufs{m_uniBuf.get()};
|
||||||
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
|
constexpr std::array<boo::PipelineStage, 1> stages{boo::PipelineStage::Vertex};
|
||||||
m_dataBind = ctx.newShaderDataBinding(SelectPipeline(type), vbo, nullptr, nullptr, 1, bufs, stages, nullptr,
|
|
||||||
nullptr, 0, nullptr, nullptr, nullptr);
|
m_dataBind = ctx.newShaderDataBinding(SelectPipeline(type), vbo, nullptr, nullptr, bufs.size(), bufs.data(),
|
||||||
|
stages.data(), nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
||||||
return true;
|
return true;
|
||||||
} BooTrace);
|
} BooTrace);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,12 +16,12 @@ void CSpaceWarpFilter::Initialize() { s_Pipeline = hecl::conv->convert(Shader_CS
|
||||||
void CSpaceWarpFilter::Shutdown() { s_Pipeline.reset(); }
|
void CSpaceWarpFilter::Shutdown() { s_Pipeline.reset(); }
|
||||||
|
|
||||||
void CSpaceWarpFilter::GenerateWarpRampTex(boo::IGraphicsDataFactory::Context& ctx) {
|
void CSpaceWarpFilter::GenerateWarpRampTex(boo::IGraphicsDataFactory::Context& ctx) {
|
||||||
u8 data[WARP_RAMP_RES + 1][WARP_RAMP_RES + 1][4] = {};
|
std::array<std::array<std::array<u8, 4>, WARP_RAMP_RES + 1>, WARP_RAMP_RES + 1> data{};
|
||||||
float halfRes = WARP_RAMP_RES / 2.f;
|
const float halfRes = WARP_RAMP_RES / 2.f;
|
||||||
for (int y = 0; y < WARP_RAMP_RES + 1; ++y) {
|
for (int y = 0; y < WARP_RAMP_RES + 1; ++y) {
|
||||||
for (int x = 0; x < WARP_RAMP_RES + 1; ++x) {
|
for (int x = 0; x < WARP_RAMP_RES + 1; ++x) {
|
||||||
zeus::CVector2f vec((x - halfRes) / halfRes, (y - halfRes) / halfRes);
|
zeus::CVector2f vec((x - halfRes) / halfRes, (y - halfRes) / halfRes);
|
||||||
float mag = vec.magnitude();
|
const float mag = vec.magnitude();
|
||||||
if (mag < 1.f && vec.canBeNormalized()) {
|
if (mag < 1.f && vec.canBeNormalized()) {
|
||||||
vec.normalize();
|
vec.normalize();
|
||||||
vec *= zeus::CVector2f(std::sqrt(mag));
|
vec *= zeus::CVector2f(std::sqrt(mag));
|
||||||
|
@ -33,29 +33,36 @@ void CSpaceWarpFilter::GenerateWarpRampTex(boo::IGraphicsDataFactory::Context& c
|
||||||
}
|
}
|
||||||
m_warpTex =
|
m_warpTex =
|
||||||
ctx.newStaticTexture(WARP_RAMP_RES + 1, WARP_RAMP_RES + 1, 1, boo::TextureFormat::RGBA8,
|
ctx.newStaticTexture(WARP_RAMP_RES + 1, WARP_RAMP_RES + 1, 1, boo::TextureFormat::RGBA8,
|
||||||
boo::TextureClampMode::Repeat, data[0], (WARP_RAMP_RES + 1) * (WARP_RAMP_RES + 1) * 4)
|
boo::TextureClampMode::Repeat, data.data(), (WARP_RAMP_RES + 1) * (WARP_RAMP_RES + 1) * 4)
|
||||||
.get();
|
.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
CSpaceWarpFilter::CSpaceWarpFilter() {
|
CSpaceWarpFilter::CSpaceWarpFilter() {
|
||||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
||||||
GenerateWarpRampTex(ctx);
|
GenerateWarpRampTex(ctx);
|
||||||
|
|
||||||
struct Vert {
|
struct Vert {
|
||||||
zeus::CVector2f m_pos;
|
zeus::CVector2f m_pos;
|
||||||
zeus::CVector2f m_uv;
|
zeus::CVector2f m_uv;
|
||||||
} verts[4] = {
|
};
|
||||||
|
const std::array<Vert, 4> verts{{
|
||||||
{{-1.f, -1.f}, {0.f, 0.f}},
|
{{-1.f, -1.f}, {0.f, 0.f}},
|
||||||
{{-1.f, 1.f}, {0.f, 1.f}},
|
{{-1.f, 1.f}, {0.f, 1.f}},
|
||||||
{{1.f, -1.f}, {1.f, 0.f}},
|
{{1.f, -1.f}, {1.f, 0.f}},
|
||||||
{{1.f, 1.f}, {1.f, 1.f}},
|
{{1.f, 1.f}, {1.f, 1.f}},
|
||||||
};
|
}};
|
||||||
m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts, 32, 4);
|
|
||||||
|
m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts.data(), 32, verts.size());
|
||||||
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
||||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {m_uniBuf.get()};
|
|
||||||
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
|
const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> bufs{m_uniBuf.get()};
|
||||||
boo::ObjToken<boo::ITexture> texs[] = {CGraphics::g_SpareTexture.get(), m_warpTex.get()};
|
constexpr std::array<boo::PipelineStage, 1> stages{boo::PipelineStage::Vertex};
|
||||||
m_dataBind = ctx.newShaderDataBinding(s_Pipeline, m_vbo.get(), nullptr, nullptr, 1, bufs, stages, nullptr, nullptr,
|
const std::array<boo::ObjToken<boo::ITexture>, 2> texs{
|
||||||
2, texs, nullptr, nullptr);
|
CGraphics::g_SpareTexture.get(),
|
||||||
|
m_warpTex.get(),
|
||||||
|
};
|
||||||
|
m_dataBind = ctx.newShaderDataBinding(s_Pipeline, m_vbo.get(), nullptr, nullptr, bufs.size(), bufs.data(),
|
||||||
|
stages.data(), nullptr, nullptr, texs.size(), texs.data(), nullptr, nullptr);
|
||||||
return true;
|
return true;
|
||||||
} BooTrace);
|
} BooTrace);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
#include "Runtime/GCNTypes.hpp"
|
#include "Runtime/GCNTypes.hpp"
|
||||||
|
|
||||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||||
|
@ -15,7 +17,7 @@ class CSpaceWarpFilter {
|
||||||
zeus::CMatrix4f m_indXf;
|
zeus::CMatrix4f m_indXf;
|
||||||
zeus::CVector3f m_strength;
|
zeus::CVector3f m_strength;
|
||||||
};
|
};
|
||||||
u8 m_shiftTexture[4][8][4] = {};
|
std::array<std::array<std::array<u8, 4>, 8>, 4> m_shiftTexture{};
|
||||||
boo::ObjToken<boo::ITexture> m_warpTex;
|
boo::ObjToken<boo::ITexture> m_warpTex;
|
||||||
boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
|
boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
|
||||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
#include "Runtime/GuiSys/CGuiWidget.hpp"
|
#include "Runtime/GuiSys/CGuiWidget.hpp"
|
||||||
|
|
||||||
#include <hecl/UniformBufferPool.hpp>
|
#include <hecl/UniformBufferPool.hpp>
|
||||||
|
@ -33,8 +35,8 @@ class CTextSupportShader {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CharacterInstance {
|
struct CharacterInstance {
|
||||||
zeus::CVector3f m_pos[4];
|
std::array<zeus::CVector3f, 4> m_pos;
|
||||||
zeus::CVector3f m_uv[4];
|
std::array<zeus::CVector3f, 4> m_uv;
|
||||||
zeus::CColor m_fontColor;
|
zeus::CColor m_fontColor;
|
||||||
zeus::CColor m_outlineColor;
|
zeus::CColor m_outlineColor;
|
||||||
zeus::CColor m_mulColor;
|
zeus::CColor m_mulColor;
|
||||||
|
@ -42,8 +44,8 @@ class CTextSupportShader {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ImageInstance {
|
struct ImageInstance {
|
||||||
zeus::CVector3f m_pos[4];
|
std::array<zeus::CVector3f, 4> m_pos;
|
||||||
zeus::CVector2f m_uv[4];
|
std::array<zeus::CVector2f, 4> m_uv;
|
||||||
zeus::CColor m_color;
|
zeus::CColor m_color;
|
||||||
void SetMetrics(const CFontImageDef& imgDef, const zeus::CVector2i& offset);
|
void SetMetrics(const CFontImageDef& imgDef, const zeus::CVector2i& offset);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "Runtime/Graphics/Shaders/CTexturedQuadFilter.hpp"
|
#include "Runtime/Graphics/Shaders/CTexturedQuadFilter.hpp"
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
#include "Runtime/Camera/CCameraFilter.hpp"
|
#include "Runtime/Camera/CCameraFilter.hpp"
|
||||||
#include "Runtime/Graphics/CTexture.hpp"
|
#include "Runtime/Graphics/CTexture.hpp"
|
||||||
|
|
||||||
|
@ -187,11 +189,13 @@ CTexturedQuadFilter::CTexturedQuadFilter(EFilterType type, const boo::ObjToken<b
|
||||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
||||||
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, 32, 16);
|
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, 32, 16);
|
||||||
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
||||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {m_uniBuf.get()};
|
|
||||||
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
|
const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> bufs{m_uniBuf.get()};
|
||||||
boo::ObjToken<boo::ITexture> texs[] = {m_booTex.get()};
|
const std::array<boo::PipelineStage, 1> stages{boo::PipelineStage::Vertex};
|
||||||
m_dataBind = ctx.newShaderDataBinding(SelectPipeline(type, m_zTest), m_vbo.get(), nullptr, nullptr, 1, bufs, stages,
|
const std::array<boo::ObjToken<boo::ITexture>, 1> texs{m_booTex.get()};
|
||||||
nullptr, nullptr, 1, texs, nullptr, nullptr);
|
m_dataBind =
|
||||||
|
ctx.newShaderDataBinding(SelectPipeline(type, m_zTest), m_vbo.get(), nullptr, nullptr, bufs.size(), bufs.data(),
|
||||||
|
stages.data(), nullptr, nullptr, texs.size(), texs.data(), nullptr, nullptr);
|
||||||
return true;
|
return true;
|
||||||
} BooTrace);
|
} BooTrace);
|
||||||
}
|
}
|
||||||
|
@ -205,13 +209,13 @@ CTexturedQuadFilter::CTexturedQuadFilter(EFilterType type, TLockedToken<CTexture
|
||||||
void CTexturedQuadFilter::draw(const zeus::CColor& color, float uvScale, const zeus::CRectangle& rect, float z) {
|
void CTexturedQuadFilter::draw(const zeus::CColor& color, float uvScale, const zeus::CRectangle& rect, float z) {
|
||||||
SCOPED_GRAPHICS_DEBUG_GROUP("CTexturedQuadFilter::draw", zeus::skMagenta);
|
SCOPED_GRAPHICS_DEBUG_GROUP("CTexturedQuadFilter::draw", zeus::skMagenta);
|
||||||
|
|
||||||
Vert verts[4] = {
|
const std::array<Vert, 4> verts{{
|
||||||
{{0.f, 0.f, z}, {0.f, 0.f}},
|
{{0.f, 0.f, z}, {0.f, 0.f}},
|
||||||
{{0.f, 1.f, z}, {0.f, uvScale}},
|
{{0.f, 1.f, z}, {0.f, uvScale}},
|
||||||
{{1.f, 0.f, z}, {uvScale, 0.f}},
|
{{1.f, 0.f, z}, {uvScale, 0.f}},
|
||||||
{{1.f, 1.f, z}, {uvScale, uvScale}},
|
{{1.f, 1.f, z}, {uvScale, uvScale}},
|
||||||
};
|
}};
|
||||||
m_vbo->load(verts, sizeof(verts));
|
m_vbo->load(verts.data(), sizeof(verts));
|
||||||
|
|
||||||
if (!m_flipRect) {
|
if (!m_flipRect) {
|
||||||
m_uniform.m_matrix[0][0] = rect.size.x() * 2.f;
|
m_uniform.m_matrix[0][0] = rect.size.x() * 2.f;
|
||||||
|
@ -234,18 +238,18 @@ void CTexturedQuadFilter::draw(const zeus::CColor& color, float uvScale, const z
|
||||||
void CTexturedQuadFilter::drawCropped(const zeus::CColor& color, float uvScale) {
|
void CTexturedQuadFilter::drawCropped(const zeus::CColor& color, float uvScale) {
|
||||||
SCOPED_GRAPHICS_DEBUG_GROUP("CTexturedQuadFilter::drawCropped", zeus::skMagenta);
|
SCOPED_GRAPHICS_DEBUG_GROUP("CTexturedQuadFilter::drawCropped", zeus::skMagenta);
|
||||||
|
|
||||||
float xFac = CGraphics::g_CroppedViewport.xc_width / float(g_Viewport.x8_width);
|
const float xFac = CGraphics::g_CroppedViewport.xc_width / float(g_Viewport.x8_width);
|
||||||
float yFac = CGraphics::g_CroppedViewport.x10_height / float(g_Viewport.xc_height);
|
const float yFac = CGraphics::g_CroppedViewport.x10_height / float(g_Viewport.xc_height);
|
||||||
float xBias = CGraphics::g_CroppedViewport.x4_left / float(g_Viewport.x8_width);
|
const float xBias = CGraphics::g_CroppedViewport.x4_left / float(g_Viewport.x8_width);
|
||||||
float yBias = CGraphics::g_CroppedViewport.x8_top / float(g_Viewport.xc_height);
|
const float yBias = CGraphics::g_CroppedViewport.x8_top / float(g_Viewport.xc_height);
|
||||||
|
|
||||||
Vert verts[4] = {
|
const std::array<Vert, 4> verts{{
|
||||||
{{-1.f, -1.f, 0.f}, {xBias * uvScale, yBias * uvScale}},
|
{{-1.f, -1.f, 0.f}, {xBias * uvScale, yBias * uvScale}},
|
||||||
{{-1.f, 1.f, 0.f}, {xBias * uvScale, (yBias + yFac) * uvScale}},
|
{{-1.f, 1.f, 0.f}, {xBias * uvScale, (yBias + yFac) * uvScale}},
|
||||||
{{1.f, -1.f, 0.f}, {(xBias + xFac) * uvScale, yBias * uvScale}},
|
{{1.f, -1.f, 0.f}, {(xBias + xFac) * uvScale, yBias * uvScale}},
|
||||||
{{1.f, 1.f, 0.f}, {(xBias + xFac) * uvScale, (yBias + yFac) * uvScale}},
|
{{1.f, 1.f, 0.f}, {(xBias + xFac) * uvScale, (yBias + yFac) * uvScale}},
|
||||||
};
|
}};
|
||||||
m_vbo->load(verts, sizeof(verts));
|
m_vbo->load(verts.data(), sizeof(verts));
|
||||||
|
|
||||||
m_uniform.m_color = color;
|
m_uniform.m_color = color;
|
||||||
m_uniBuf->load(&m_uniform, sizeof(m_uniform));
|
m_uniBuf->load(&m_uniform, sizeof(m_uniform));
|
||||||
|
@ -279,30 +283,42 @@ void CTexturedQuadFilter::DrawFilter(EFilterShape shape, const zeus::CColor& col
|
||||||
CGraphics::SetShaderDataBinding(m_dataBind);
|
CGraphics::SetShaderDataBinding(m_dataBind);
|
||||||
|
|
||||||
if (shape == EFilterShape::FullscreenQuarters) {
|
if (shape == EFilterShape::FullscreenQuarters) {
|
||||||
Vert QuadVerts[] = {
|
const std::array<Vert, 16> QuadVerts{{
|
||||||
{{-1.f, -1.f, 0.f}, {t, t}}, // ll
|
// ll
|
||||||
{{-1.f, 0.f, 0.f}, {t, 0.f}}, {{0.f, -1.f, 0.f}, {0.f, t}}, {{0.f, 0.f, 0.f}, {0.f, 0.f}},
|
{{-1.f, -1.f, 0.f}, {t, t}},
|
||||||
{{-1.f, 1.f, 0.f}, {t, t}}, // ul
|
{{-1.f, 0.f, 0.f}, {t, 0.f}},
|
||||||
{{-1.f, 0.f, 0.f}, {t, 0.f}}, {{0.f, 1.f, 0.f}, {0.f, t}}, {{0.f, 0.f, 0.f}, {0.f, 0.f}},
|
{{0.f, -1.f, 0.f}, {0.f, t}},
|
||||||
{{1.f, -1.f, 0.f}, {t, t}}, // lr
|
{{0.f, 0.f, 0.f}, {0.f, 0.f}},
|
||||||
{{1.f, 0.f, 0.f}, {t, 0.f}}, {{0.f, -1.f, 0.f}, {0.f, t}}, {{0.f, 0.f, 0.f}, {0.f, 0.f}},
|
// ul
|
||||||
{{1.f, 1.f, 0.f}, {t, t}}, // ur
|
{{-1.f, 1.f, 0.f}, {t, t}},
|
||||||
{{1.f, 0.f, 0.f}, {t, 0.f}}, {{0.f, 1.f, 0.f}, {0.f, t}}, {{0.f, 0.f, 0.f}, {0.f, 0.f}},
|
{{-1.f, 0.f, 0.f}, {t, 0.f}},
|
||||||
};
|
{{0.f, 1.f, 0.f}, {0.f, t}},
|
||||||
m_vbo->load(QuadVerts, sizeof(Vert) * 16);
|
{{0.f, 0.f, 0.f}, {0.f, 0.f}},
|
||||||
|
// lr
|
||||||
|
{{1.f, -1.f, 0.f}, {t, t}},
|
||||||
|
{{1.f, 0.f, 0.f}, {t, 0.f}},
|
||||||
|
{{0.f, -1.f, 0.f}, {0.f, t}},
|
||||||
|
{{0.f, 0.f, 0.f}, {0.f, 0.f}},
|
||||||
|
// ur
|
||||||
|
{{1.f, 1.f, 0.f}, {t, t}},
|
||||||
|
{{1.f, 0.f, 0.f}, {t, 0.f}},
|
||||||
|
{{0.f, 1.f, 0.f}, {0.f, t}},
|
||||||
|
{{0.f, 0.f, 0.f}, {0.f, 0.f}},
|
||||||
|
}};
|
||||||
|
m_vbo->load(QuadVerts.data(), sizeof(QuadVerts));
|
||||||
CGraphics::DrawArray(0, 4);
|
CGraphics::DrawArray(0, 4);
|
||||||
CGraphics::DrawArray(4, 4);
|
CGraphics::DrawArray(4, 4);
|
||||||
CGraphics::DrawArray(8, 4);
|
CGraphics::DrawArray(8, 4);
|
||||||
CGraphics::DrawArray(12, 4);
|
CGraphics::DrawArray(12, 4);
|
||||||
} else {
|
} else {
|
||||||
Vert FullscreenVerts[] = {
|
const std::array<Vert, 4> FullscreenVerts{{
|
||||||
{{-1.f, -1.f, 0.f}, {0.f, 0.f}},
|
{{-1.f, -1.f, 0.f}, {0.f, 0.f}},
|
||||||
{{-1.f, 1.f, 0.f}, {0.f, t}},
|
{{-1.f, 1.f, 0.f}, {0.f, t}},
|
||||||
{{1.f, -1.f, 0.f}, {t, 0.f}},
|
{{1.f, -1.f, 0.f}, {t, 0.f}},
|
||||||
{{1.f, 1.f, 0.f}, {t, t}},
|
{{1.f, 1.f, 0.f}, {t, t}},
|
||||||
};
|
}};
|
||||||
m_vbo->load(FullscreenVerts, sizeof(Vert) * 4);
|
m_vbo->load(FullscreenVerts.data(), sizeof(FullscreenVerts));
|
||||||
CGraphics::DrawArray(0, 4);
|
CGraphics::DrawArray(0, FullscreenVerts.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,11 +329,13 @@ CTexturedQuadFilterAlpha::CTexturedQuadFilterAlpha(EFilterType type, const boo::
|
||||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
||||||
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, 32, 4);
|
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, 32, 4);
|
||||||
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
||||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {m_uniBuf.get()};
|
|
||||||
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
|
const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> bufs{m_uniBuf.get()};
|
||||||
boo::ObjToken<boo::ITexture> texs[] = {m_booTex.get()};
|
constexpr std::array<boo::PipelineStage, 1> stages{boo::PipelineStage::Vertex};
|
||||||
m_dataBind = ctx.newShaderDataBinding(SelectAlphaPipeline(type), m_vbo.get(), nullptr, nullptr, 1, bufs, stages,
|
const std::array<boo::ObjToken<boo::ITexture>, 1> texs{m_booTex.get()};
|
||||||
nullptr, nullptr, 1, texs, nullptr, nullptr);
|
m_dataBind =
|
||||||
|
ctx.newShaderDataBinding(SelectAlphaPipeline(type), m_vbo.get(), nullptr, nullptr, bufs.size(), bufs.data(),
|
||||||
|
stages.data(), nullptr, nullptr, texs.size(), texs.data(), nullptr, nullptr);
|
||||||
return true;
|
return true;
|
||||||
} BooTrace);
|
} BooTrace);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,20 +21,24 @@ CThermalColdFilter::CThermalColdFilter() {
|
||||||
zeus::CVector2f m_pos;
|
zeus::CVector2f m_pos;
|
||||||
zeus::CVector2f m_uv;
|
zeus::CVector2f m_uv;
|
||||||
zeus::CVector2f m_uvNoise;
|
zeus::CVector2f m_uvNoise;
|
||||||
} verts[4] = {
|
};
|
||||||
|
const std::array<Vert, 4> verts{{
|
||||||
{{-1.f, -1.f}, {0.f, 0.f}, {0.f, 0.f}},
|
{{-1.f, -1.f}, {0.f, 0.f}, {0.f, 0.f}},
|
||||||
{{-1.f, 1.f}, {0.f, 1.f}, {0.f, 448.f}},
|
{{-1.f, 1.f}, {0.f, 1.f}, {0.f, 448.f}},
|
||||||
{{1.f, -1.f}, {1.f, 0.f}, {640.f, 0.f}},
|
{{1.f, -1.f}, {1.f, 0.f}, {640.f, 0.f}},
|
||||||
{{1.f, 1.f}, {1.f, 1.f}, {640.f, 448.f}},
|
{{1.f, 1.f}, {1.f, 1.f}, {640.f, 448.f}},
|
||||||
};
|
}};
|
||||||
m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts, 48, 4);
|
m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts.data(), 48, verts.size());
|
||||||
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
||||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {m_uniBuf.get()};
|
|
||||||
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
|
const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> bufs{m_uniBuf.get()};
|
||||||
boo::ObjToken<boo::ITexture> texs[] = {CGraphics::g_SpareTexture.get(),
|
constexpr std::array<boo::PipelineStage, 1> stages{boo::PipelineStage::Vertex};
|
||||||
g_Renderer->GetRandomStaticEntropyTex()};
|
const std::array<boo::ObjToken<boo::ITexture>, 2> texs{
|
||||||
m_dataBind = ctx.newShaderDataBinding(s_Pipeline, m_vbo.get(), nullptr, nullptr, 1, bufs, stages, nullptr, nullptr,
|
CGraphics::g_SpareTexture.get(),
|
||||||
2, texs, nullptr, nullptr);
|
g_Renderer->GetRandomStaticEntropyTex(),
|
||||||
|
};
|
||||||
|
m_dataBind = ctx.newShaderDataBinding(s_Pipeline, m_vbo.get(), nullptr, nullptr, bufs.size(), bufs.data(),
|
||||||
|
stages.data(), nullptr, nullptr, texs.size(), texs.data(), nullptr, nullptr);
|
||||||
return true;
|
return true;
|
||||||
} BooTrace);
|
} BooTrace);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||||
|
|
||||||
#include <zeus/CColor.hpp>
|
#include <zeus/CColor.hpp>
|
||||||
|
@ -10,7 +12,7 @@ namespace urde {
|
||||||
class CThermalColdFilter {
|
class CThermalColdFilter {
|
||||||
struct Uniform {
|
struct Uniform {
|
||||||
zeus::CMatrix4f m_indMtx;
|
zeus::CMatrix4f m_indMtx;
|
||||||
zeus::CColor m_colorRegs[3];
|
std::array<zeus::CColor, 3> m_colorRegs;
|
||||||
float m_randOff = 0.f;
|
float m_randOff = 0.f;
|
||||||
};
|
};
|
||||||
boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
|
boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
|
||||||
|
|
|
@ -20,19 +20,24 @@ CThermalHotFilter::CThermalHotFilter() {
|
||||||
struct Vert {
|
struct Vert {
|
||||||
zeus::CVector2f m_pos;
|
zeus::CVector2f m_pos;
|
||||||
zeus::CVector2f m_uv;
|
zeus::CVector2f m_uv;
|
||||||
} verts[4] = {
|
};
|
||||||
|
const std::array<Vert, 4> verts{{
|
||||||
{{-1.0, -1.0}, {0.0, 0.0}},
|
{{-1.0, -1.0}, {0.0, 0.0}},
|
||||||
{{-1.0, 1.0}, {0.0, 1.0}},
|
{{-1.0, 1.0}, {0.0, 1.0}},
|
||||||
{{1.0, -1.0}, {1.0, 0.0}},
|
{{1.0, -1.0}, {1.0, 0.0}},
|
||||||
{{1.0, 1.0}, {1.0, 1.0}},
|
{{1.0, 1.0}, {1.0, 1.0}},
|
||||||
};
|
}};
|
||||||
m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts, 32, 4);
|
m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts.data(), 32, verts.size());
|
||||||
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
||||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {m_uniBuf.get()};
|
|
||||||
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
|
const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> bufs{m_uniBuf.get()};
|
||||||
boo::ObjToken<boo::ITexture> texs[] = {CGraphics::g_SpareTexture.get(), g_Renderer->GetThermoPalette()};
|
constexpr std::array<boo::PipelineStage, 1> stages{boo::PipelineStage::Vertex};
|
||||||
m_dataBind = ctx.newShaderDataBinding(s_Pipeline, m_vbo.get(), nullptr, nullptr, 1, bufs, stages, nullptr, nullptr,
|
const std::array<boo::ObjToken<boo::ITexture>, 2> texs{
|
||||||
2, texs, nullptr, nullptr);
|
CGraphics::g_SpareTexture.get(),
|
||||||
|
g_Renderer->GetThermoPalette(),
|
||||||
|
};
|
||||||
|
m_dataBind = ctx.newShaderDataBinding(s_Pipeline, m_vbo.get(), nullptr, nullptr, bufs.size(), bufs.data(),
|
||||||
|
stages.data(), nullptr, nullptr, texs.size(), texs.data(), nullptr, nullptr);
|
||||||
return true;
|
return true;
|
||||||
} BooTrace);
|
} BooTrace);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||||
|
|
||||||
#include <zeus/CColor.hpp>
|
#include <zeus/CColor.hpp>
|
||||||
|
@ -8,7 +10,7 @@ namespace urde {
|
||||||
|
|
||||||
class CThermalHotFilter {
|
class CThermalHotFilter {
|
||||||
struct Uniform {
|
struct Uniform {
|
||||||
zeus::CColor m_colorRegs[3];
|
std::array<zeus::CColor, 3> m_colorRegs;
|
||||||
};
|
};
|
||||||
boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
|
boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
|
||||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "Runtime/Graphics/Shaders/CWorldShadowShader.hpp"
|
#include "Runtime/Graphics/Shaders/CWorldShadowShader.hpp"
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
#include "Runtime/Camera/CCameraFilter.hpp"
|
#include "Runtime/Camera/CCameraFilter.hpp"
|
||||||
#include "Runtime/Graphics/CGraphics.hpp"
|
#include "Runtime/Graphics/CGraphics.hpp"
|
||||||
|
|
||||||
|
@ -25,12 +27,14 @@ CWorldShadowShader::CWorldShadowShader(u32 w, u32 h) : m_w(w), m_h(h) {
|
||||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
||||||
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, 16, 4);
|
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, 16, 4);
|
||||||
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
||||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {m_uniBuf.get()};
|
|
||||||
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
|
const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> bufs{m_uniBuf.get()};
|
||||||
m_dataBind = ctx.newShaderDataBinding(s_Pipeline, m_vbo.get(), nullptr, nullptr, 1, bufs, stages, nullptr, nullptr,
|
constexpr std::array<boo::PipelineStage, 1> stages{boo::PipelineStage::Vertex};
|
||||||
0, nullptr, nullptr, nullptr);
|
m_dataBind = ctx.newShaderDataBinding(s_Pipeline, m_vbo.get(), nullptr, nullptr, bufs.size(), bufs.data(),
|
||||||
m_zDataBind = ctx.newShaderDataBinding(s_ZPipeline, m_vbo.get(), nullptr, nullptr, 1, bufs, stages, nullptr,
|
stages.data(), nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
||||||
nullptr, 0, nullptr, nullptr, nullptr);
|
m_zDataBind = ctx.newShaderDataBinding(s_ZPipeline, m_vbo.get(), nullptr, nullptr, bufs.size(), bufs.data(),
|
||||||
|
stages.data(), nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
||||||
|
|
||||||
m_tex = ctx.newRenderTexture(m_w, m_h, boo::TextureClampMode::ClampToWhite, 1, 0);
|
m_tex = ctx.newRenderTexture(m_w, m_h, boo::TextureClampMode::ClampToWhite, 1, 0);
|
||||||
return true;
|
return true;
|
||||||
} BooTrace);
|
} BooTrace);
|
||||||
|
@ -41,9 +45,13 @@ void CWorldShadowShader::bindRenderTarget() { CGraphics::g_BooMainCommandQueue->
|
||||||
void CWorldShadowShader::drawBase(float extent) {
|
void CWorldShadowShader::drawBase(float extent) {
|
||||||
SCOPED_GRAPHICS_DEBUG_GROUP("CWorldShadowShader::drawBase", zeus::skMagenta);
|
SCOPED_GRAPHICS_DEBUG_GROUP("CWorldShadowShader::drawBase", zeus::skMagenta);
|
||||||
|
|
||||||
zeus::CVector3f verts[] = {
|
const std::array<zeus::CVector3f, 4> verts{{
|
||||||
{-extent, 0.f, extent}, {extent, 0.f, extent}, {-extent, 0.f, -extent}, {extent, 0.f, -extent}};
|
{-extent, 0.f, extent},
|
||||||
m_vbo->load(verts, sizeof(zeus::CVector3f) * 4);
|
{extent, 0.f, extent},
|
||||||
|
{-extent, 0.f, -extent},
|
||||||
|
{extent, 0.f, -extent},
|
||||||
|
}};
|
||||||
|
m_vbo->load(verts.data(), sizeof(verts));
|
||||||
|
|
||||||
m_uniform.m_matrix = CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f();
|
m_uniform.m_matrix = CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f();
|
||||||
m_uniform.m_color = zeus::skWhite;
|
m_uniform.m_color = zeus::skWhite;
|
||||||
|
|
|
@ -20,19 +20,24 @@ CXRayBlurFilter::CXRayBlurFilter(TLockedToken<CTexture>& tex) : m_paletteTex(tex
|
||||||
struct Vert {
|
struct Vert {
|
||||||
zeus::CVector2f m_pos;
|
zeus::CVector2f m_pos;
|
||||||
zeus::CVector2f m_uv;
|
zeus::CVector2f m_uv;
|
||||||
} verts[4] = {
|
};
|
||||||
|
const std::array<Vert, 4> verts{{
|
||||||
{{-1.f, -1.f}, {0.f, 0.f}},
|
{{-1.f, -1.f}, {0.f, 0.f}},
|
||||||
{{-1.f, 1.f}, {0.f, 1.f}},
|
{{-1.f, 1.f}, {0.f, 1.f}},
|
||||||
{{1.f, -1.f}, {1.f, 0.f}},
|
{{1.f, -1.f}, {1.f, 0.f}},
|
||||||
{{1.f, 1.f}, {1.f, 1.f}},
|
{{1.f, 1.f}, {1.f, 1.f}},
|
||||||
};
|
}};
|
||||||
m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts, 32, 4);
|
m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts.data(), 32, verts.size());
|
||||||
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
||||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {m_uniBuf.get()};
|
|
||||||
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
|
const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> bufs{m_uniBuf.get()};
|
||||||
boo::ObjToken<boo::ITexture> texs[] = {CGraphics::g_SpareTexture.get(), m_booTex};
|
constexpr std::array<boo::PipelineStage, 1> stages{boo::PipelineStage::Vertex};
|
||||||
m_dataBind = ctx.newShaderDataBinding(s_Pipeline, m_vbo.get(), nullptr, nullptr, 1, bufs, stages, nullptr, nullptr,
|
const std::array<boo::ObjToken<boo::ITexture>, 2> texs{
|
||||||
2, texs, nullptr, nullptr);
|
CGraphics::g_SpareTexture.get(),
|
||||||
|
m_booTex,
|
||||||
|
};
|
||||||
|
m_dataBind = ctx.newShaderDataBinding(s_Pipeline, m_vbo.get(), nullptr, nullptr, bufs.size(), bufs.data(),
|
||||||
|
stages.data(), nullptr, nullptr, texs.size(), texs.data(), nullptr, nullptr);
|
||||||
return true;
|
return true;
|
||||||
} BooTrace);
|
} BooTrace);
|
||||||
}
|
}
|
||||||
|
@ -42,13 +47,13 @@ void CXRayBlurFilter::draw(float amount) {
|
||||||
|
|
||||||
CGraphics::ResolveSpareTexture(CGraphics::g_CroppedViewport);
|
CGraphics::ResolveSpareTexture(CGraphics::g_CroppedViewport);
|
||||||
|
|
||||||
float blurL = amount * g_tweakGui->GetXrayBlurScaleLinear() * 0.25f;
|
const float blurL = amount * g_tweakGui->GetXrayBlurScaleLinear() * 0.25f;
|
||||||
float blurQ = amount * g_tweakGui->GetXrayBlurScaleQuadratic() * 0.25f;
|
const float blurQ = amount * g_tweakGui->GetXrayBlurScaleQuadratic() * 0.25f;
|
||||||
|
|
||||||
for (int i = 0; i < 8; ++i) {
|
for (size_t i = 0; i < m_uniform.m_uv.size(); ++i) {
|
||||||
float iflt = i / 2.f;
|
const float iflt = float(i) / 2.f;
|
||||||
float uvScale = (1.f - (blurL * iflt + blurQ * iflt * iflt));
|
const float uvScale = (1.f - (blurL * iflt + blurQ * iflt * iflt));
|
||||||
float uvOffset = uvScale * -0.5f + 0.5f;
|
const float uvOffset = uvScale * -0.5f + 0.5f;
|
||||||
m_uniform.m_uv[i][0][0] = uvScale;
|
m_uniform.m_uv[i][0][0] = uvScale;
|
||||||
m_uniform.m_uv[i][1][1] = uvScale;
|
m_uniform.m_uv[i][1][1] = uvScale;
|
||||||
m_uniform.m_uv[i][3][0] = uvOffset;
|
m_uniform.m_uv[i][3][0] = uvOffset;
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
#include "Runtime/CToken.hpp"
|
#include "Runtime/CToken.hpp"
|
||||||
|
|
||||||
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||||
|
@ -10,7 +12,7 @@ class CTexture;
|
||||||
|
|
||||||
class CXRayBlurFilter {
|
class CXRayBlurFilter {
|
||||||
struct Uniform {
|
struct Uniform {
|
||||||
zeus::CMatrix4f m_uv[8];
|
std::array<zeus::CMatrix4f, 8> m_uv;
|
||||||
};
|
};
|
||||||
TLockedToken<CTexture> m_paletteTex;
|
TLockedToken<CTexture> m_paletteTex;
|
||||||
boo::ObjToken<boo::ITexture> m_booTex;
|
boo::ObjToken<boo::ITexture> m_booTex;
|
||||||
|
|
|
@ -52,19 +52,19 @@ void CFluidPlaneGPU::RenderStripWithRipples(float curY, const CFluidPlaneRender:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::fill(std::begin(pv.m_outerLevels), std::end(pv.m_outerLevels), subdivF);
|
pv.m_outerLevels.fill(subdivF);
|
||||||
std::fill(std::begin(pv.m_innerLevels), std::end(pv.m_innerLevels), subdivF);
|
pv.m_innerLevels.fill(subdivF);
|
||||||
} else {
|
} else {
|
||||||
bool r19 = (flags[yTile + 1][xTile] & 0x2) != 0; // North
|
const bool r19 = (flags[yTile + 1][xTile] & 0x2) != 0; // North
|
||||||
bool r16 = (flags[yTile][xTile - 1] & 0x8) != 0; // West
|
const bool r16 = (flags[yTile][xTile - 1] & 0x8) != 0; // West
|
||||||
bool r18 = (flags[yTile][xTile + 1] & 0x4) != 0; // East
|
const bool r18 = (flags[yTile][xTile + 1] & 0x4) != 0; // East
|
||||||
bool r17 = (flags[yTile - 1][xTile] & 0x1) != 0; // South
|
const bool r17 = (flags[yTile - 1][xTile] & 0x1) != 0; // South
|
||||||
|
|
||||||
pv.m_outerLevels[0] = r16 ? subdivF : 1.f;
|
pv.m_outerLevels[0] = r16 ? subdivF : 1.f;
|
||||||
pv.m_outerLevels[1] = r17 ? subdivF : 1.f;
|
pv.m_outerLevels[1] = r17 ? subdivF : 1.f;
|
||||||
pv.m_outerLevels[2] = r18 ? subdivF : 1.f;
|
pv.m_outerLevels[2] = r18 ? subdivF : 1.f;
|
||||||
pv.m_outerLevels[3] = r19 ? subdivF : 1.f;
|
pv.m_outerLevels[3] = r19 ? subdivF : 1.f;
|
||||||
std::fill(std::begin(pv.m_innerLevels), std::end(pv.m_innerLevels), subdivF);
|
pv.m_innerLevels.fill(subdivF);
|
||||||
}
|
}
|
||||||
|
|
||||||
float curTileY = yMin;
|
float curTileY = yMin;
|
||||||
|
|
Loading…
Reference in New Issue