Merge pull request #88 from lioncash/radar

Graphics/Shaders: Minor changes
This commit is contained in:
Phillip Stephens 2019-11-10 08:03:42 -08:00 committed by GitHub
commit 3b101267f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
64 changed files with 826 additions and 529 deletions

View File

@ -1,9 +1,11 @@
#include "CMappableObject.hpp" #include "Runtime/AutoMapper/CMappableObject.hpp"
#include "GameGlobalObjects.hpp"
#include "CMapWorldInfo.hpp" #include "Runtime/CSimplePool.hpp"
#include "CSimplePool.hpp" #include "Runtime/CToken.hpp"
#include "CToken.hpp" #include "Runtime/AutoMapper/CMapWorldInfo.hpp"
#include "Graphics/CTexture.hpp" #include "Runtime/Camera/CCameraFilter.hpp"
#include "Runtime/GameGlobalObjects.hpp"
#include "Runtime/Graphics/CTexture.hpp"
namespace urde { namespace urde {
zeus::CVector3f CMappableObject::skDoorVerts[8] = {}; zeus::CVector3f CMappableObject::skDoorVerts[8] = {};

View File

@ -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;

View File

@ -1,6 +1,11 @@
#include "CAABoxShader.hpp" #include "Runtime/Graphics/Shaders/CAABoxShader.hpp"
#include "hecl/Pipeline.hpp"
#include "Graphics/CGraphics.hpp" #include <array>
#include "Runtime/Graphics/CGraphics.hpp"
#include <hecl/Pipeline.hpp>
#include <zeus/CAABox.hpp>
namespace urde { namespace urde {
@ -21,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()},
@ -54,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) {

View File

@ -2,10 +2,13 @@
#include <boo/graphicsdev/IGraphicsDataFactory.hpp> #include <boo/graphicsdev/IGraphicsDataFactory.hpp>
#include <zeus/CAABox.hpp>
#include <zeus/CColor.hpp> #include <zeus/CColor.hpp>
#include <zeus/CMatrix4f.hpp> #include <zeus/CMatrix4f.hpp>
namespace zeus {
class CAABox;
}
namespace urde { namespace urde {
class CAABoxShader { class CAABoxShader {

View File

@ -1,10 +1,22 @@
#include "CCameraBlurFilter.hpp" #include "Runtime/Graphics/Shaders/CCameraBlurFilter.hpp"
#include "hecl/Pipeline.hpp"
#include "Graphics/CGraphics.hpp" #include <algorithm>
#include <cmath>
#include "Runtime/Graphics/CGraphics.hpp"
#include <hecl/Pipeline.hpp>
#include <zeus/CVector2f.hpp>
namespace urde { namespace urde {
namespace {
struct Vert {
zeus::CVector2f m_pos;
zeus::CVector2f m_uv;
};
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline; boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
} // Anonymous namespace
void CCameraBlurFilter::Initialize() { s_Pipeline = hecl::conv->convert(Shader_CCameraBlurFilter{}); } void CCameraBlurFilter::Initialize() { s_Pipeline = hecl::conv->convert(Shader_CCameraBlurFilter{}); }

View File

@ -1,24 +1,16 @@
#pragma once #pragma once
#include <boo/graphicsdev/IGraphicsDataFactory.hpp> #include <boo/graphicsdev/IGraphicsDataFactory.hpp>
#include <zeus/CColor.hpp>
#include <zeus/CMatrix4f.hpp>
#include <zeus/CVector3f.hpp>
#include <zeus/CVector4f.hpp> #include <zeus/CVector4f.hpp>
namespace urde { namespace urde {
class CCameraBlurFilter { class CCameraBlurFilter {
struct Vert {
zeus::CVector2f m_pos;
zeus::CVector2f m_uv;
};
struct Uniform { struct Uniform {
zeus::CVector4f m_uv[6]; zeus::CVector4f m_uv[6];
float m_opacity = 1.f; float m_opacity = 1.f;
}; };
boo::ObjToken<boo::IGraphicsBufferD> m_vbo; boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf; boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
boo::ObjToken<boo::IShaderDataBinding> m_dataBind; boo::ObjToken<boo::IShaderDataBinding> m_dataBind;

View File

@ -1,6 +1,11 @@
#include "CColoredQuadFilter.hpp" #include "Runtime/Graphics/Shaders/CColoredQuadFilter.hpp"
#include "Graphics/CGraphics.hpp"
#include "hecl/Pipeline.hpp" #include <array>
#include "Runtime/Camera/CCameraFilter.hpp"
#include "Runtime/Graphics/CGraphics.hpp"
#include <hecl/Pipeline.hpp>
namespace urde { namespace urde {
@ -37,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);
} }

View File

@ -1,13 +1,18 @@
#pragma once #pragma once
#include "Runtime/CToken.hpp" #include "Runtime/CToken.hpp"
#include "Runtime/Camera/CCameraFilter.hpp"
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
#include <zeus/CColor.hpp> #include <zeus/CColor.hpp>
#include <zeus/CMatrix4f.hpp> #include <zeus/CMatrix4f.hpp>
#include <zeus/CRectangle.hpp> #include <zeus/CRectangle.hpp>
namespace urde { namespace urde {
class CTexture;
enum class EFilterShape;
enum class EFilterType;
class CColoredQuadFilter { class CColoredQuadFilter {
struct Uniform { struct Uniform {

View File

@ -1,8 +1,12 @@
#include "CColoredStripShader.hpp" #include "Runtime/Graphics/Shaders/CColoredStripShader.hpp"
#include "Graphics/CGraphics.hpp"
#include "hecl/Pipeline.hpp" #include <array>
#include "GameGlobalObjects.hpp"
#include "Graphics/CBooRenderer.hpp" #include "Runtime/GameGlobalObjects.hpp"
#include "Runtime/Graphics/CBooRenderer.hpp"
#include "Runtime/Graphics/CGraphics.hpp"
#include <hecl/Pipeline.hpp>
namespace urde { namespace urde {
@ -43,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) {

View File

@ -1,6 +1,10 @@
#include "CDecalShaders.hpp" #include "Runtime/Graphics/Shaders/CDecalShaders.hpp"
#include "Particle/CDecal.hpp"
#include "hecl/Pipeline.hpp" #include <array>
#include "Runtime/Particle/CDecal.hpp"
#include <hecl/Pipeline.hpp>
namespace urde { namespace urde {
@ -44,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);
} }
} }

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "Runtime/Graphics/CGraphics.hpp" #include <boo/graphicsdev/IGraphicsDataFactory.hpp>
namespace urde { namespace urde {
struct CQuadDecal; struct CQuadDecal;

View File

@ -1,6 +1,10 @@
#include "CElementGenShaders.hpp" #include "Runtime/Graphics/Shaders/CElementGenShaders.hpp"
#include "Particle/CElementGen.hpp"
#include "hecl/Pipeline.hpp" #include <iterator>
#include "Runtime/Particle/CElementGen.hpp"
#include <hecl/Pipeline.hpp>
namespace urde { namespace urde {
@ -224,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();
@ -242,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);
}
}
} }
} }

View File

@ -2,8 +2,6 @@
#include <array> #include <array>
#include "Runtime/Graphics/CGraphics.hpp"
#include <boo/graphicsdev/IGraphicsDataFactory.hpp> #include <boo/graphicsdev/IGraphicsDataFactory.hpp>
namespace urde { namespace urde {

View File

@ -1,7 +1,11 @@
#include "CEnergyBarShader.hpp" #include "Runtime/Graphics/Shaders/CEnergyBarShader.hpp"
#include "hecl/Pipeline.hpp"
#include "Graphics/CGraphics.hpp" #include <cstring>
#include "Graphics/CTexture.hpp"
#include "Runtime/Graphics/CGraphics.hpp"
#include "Runtime/Graphics/CTexture.hpp"
#include <hecl/Pipeline.hpp>
namespace urde { namespace urde {
@ -29,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);
} }

View File

@ -1,16 +1,17 @@
#pragma once #pragma once
#include <array>
#include <vector> #include <vector>
#include "Runtime/Camera/CCameraFilter.hpp" #include <boo/graphicsdev/IGraphicsDataFactory.hpp>
#include <zeus/CColor.hpp> #include <zeus/CColor.hpp>
#include <zeus/CMatrix4f.hpp> #include <zeus/CMatrix4f.hpp>
#include <zeus/CRectangle.hpp>
#include <zeus/CVector2f.hpp> #include <zeus/CVector2f.hpp>
#include <zeus/CVector3f.hpp> #include <zeus/CVector3f.hpp>
namespace urde { namespace urde {
class CTexture;
class CEnergyBarShader { class CEnergyBarShader {
public: public:
@ -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;

View File

@ -1,6 +1,8 @@
#include "CEnvFxShaders.hpp" #include "Runtime/Graphics/Shaders/CEnvFxShaders.hpp"
#include "hecl/Pipeline.hpp"
#include "World/CEnvFxManager.hpp" #include "Runtime/World/CEnvFxManager.hpp"
#include <hecl/Pipeline.hpp>
namespace urde { namespace urde {
boo::ObjToken<boo::IShaderPipeline> CEnvFxShaders::m_snowPipeline; boo::ObjToken<boo::IShaderPipeline> CEnvFxShaders::m_snowPipeline;
@ -18,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

View File

@ -1,8 +1,9 @@
#pragma once #pragma once
#include "Runtime/Graphics/CGraphics.hpp" #include <array>
#include <boo/graphicsdev/IGraphicsDataFactory.hpp> #include <boo/graphicsdev/IGraphicsDataFactory.hpp>
#include <zeus/CColor.hpp> #include <zeus/CColor.hpp>
#include <zeus/CMatrix4f.hpp> #include <zeus/CMatrix4f.hpp>
#include <zeus/CVector2f.hpp> #include <zeus/CVector2f.hpp>
@ -15,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;

View File

@ -1,7 +1,9 @@
#include "CFluidPlaneShader.hpp" #include "Runtime/Graphics/Shaders/CFluidPlaneShader.hpp"
#include "World/CRipple.hpp"
#include "World/CRippleManager.hpp" #include "Runtime/World/CRipple.hpp"
#include "hecl/Pipeline.hpp" #include "Runtime/World/CRippleManager.hpp"
#include <hecl/Pipeline.hpp>
namespace urde { namespace urde {
@ -122,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;
@ -199,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;
@ -217,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();
@ -241,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;

View File

@ -1,9 +1,9 @@
#pragma once #pragma once
#include <array>
#include <vector> #include <vector>
#include "Runtime/CToken.hpp" #include "Runtime/CToken.hpp"
#include "Runtime/RetroTypes.hpp"
#include "Runtime/Graphics/CTexture.hpp" #include "Runtime/Graphics/CTexture.hpp"
#include "Runtime/Graphics/Shaders/CModelShaders.hpp" #include "Runtime/Graphics/Shaders/CModelShaders.hpp"
#include "Runtime/World/CFluidPlaneManager.hpp" #include "Runtime/World/CFluidPlaneManager.hpp"
@ -12,7 +12,6 @@
#include <boo/graphicsdev/IGraphicsDataFactory.hpp> #include <boo/graphicsdev/IGraphicsDataFactory.hpp>
#include <zeus/CAABox.hpp>
#include <zeus/CColor.hpp> #include <zeus/CColor.hpp>
#include <zeus/CMatrix4f.hpp> #include <zeus/CMatrix4f.hpp>
#include <zeus/CVector3f.hpp> #include <zeus/CVector3f.hpp>
@ -41,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;
}; };
@ -69,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);
@ -92,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
}; };

View File

@ -1,8 +1,12 @@
#include "CFogVolumeFilter.hpp" #include "Runtime/Graphics/Shaders/CFogVolumeFilter.hpp"
#include "hecl/Pipeline.hpp"
#include "Graphics/CGraphics.hpp" #include "Runtime/GameGlobalObjects.hpp"
#include "GameGlobalObjects.hpp" #include "Runtime/Graphics/CBooRenderer.hpp"
#include "Graphics/CBooRenderer.hpp" #include "Runtime/Graphics/CGraphics.hpp"
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
#include <hecl/Pipeline.hpp>
#include <zeus/CColor.hpp>
namespace urde { namespace urde {

View File

@ -1,10 +1,16 @@
#pragma once #pragma once
#include <boo/graphicsdev/IGraphicsDataFactory.hpp> #include <boo/BooObject.hpp>
#include <zeus/CColor.hpp> namespace boo {
#include <zeus/CMatrix4f.hpp> struct IGraphicsBufferD;
#include <zeus/CRectangle.hpp> struct IGraphicsBufferS;
struct IShaderDataBinding;
} // namespace boo
namespace zeus {
class CColor;
}
namespace urde { namespace urde {

View File

@ -1,10 +1,12 @@
#include "CFogVolumePlaneShader.hpp" #include "Runtime/Graphics/Shaders/CFogVolumePlaneShader.hpp"
#include "hecl/Pipeline.hpp"
#include "Graphics/CGraphics.hpp" #include "Runtime/Graphics/CGraphics.hpp"
#include <hecl/Pipeline.hpp>
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{});
@ -24,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);
} }

View File

@ -1,20 +1,23 @@
#pragma once #pragma once
#include <array>
#include <cstddef> #include <cstddef>
#include <vector> #include <vector>
#include <boo/graphicsdev/IGraphicsDataFactory.hpp> #include <boo/graphicsdev/IGraphicsDataFactory.hpp>
#include <zeus/CColor.hpp>
#include <zeus/CMatrix4f.hpp>
#include <zeus/CRectangle.hpp> #include <zeus/CRectangle.hpp>
#include <zeus/CVector4f.hpp> #include <zeus/CVector4f.hpp>
namespace zeus {
class CVector3f;
}
namespace urde { 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;

View File

@ -1,6 +1,10 @@
#include "CLineRendererShaders.hpp" #include "Runtime/Graphics/Shaders/CLineRendererShaders.hpp"
#include "Graphics/CLineRenderer.hpp"
#include "hecl/Pipeline.hpp" #include <utility>
#include "Runtime/Graphics/CLineRenderer.hpp"
#include <hecl/Pipeline.hpp>
namespace urde { namespace urde {
@ -87,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;
@ -102,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

View File

@ -2,8 +2,6 @@
#include <array> #include <array>
#include "Runtime/Graphics/CGraphics.hpp"
#include <boo/graphicsdev/IGraphicsDataFactory.hpp> #include <boo/graphicsdev/IGraphicsDataFactory.hpp>
namespace urde { namespace urde {

View File

@ -1,6 +1,10 @@
#include "CMapSurfaceShader.hpp" #include "Runtime/Graphics/Shaders/CMapSurfaceShader.hpp"
#include "hecl/Pipeline.hpp"
#include "Graphics/CGraphics.hpp" #include <array>
#include "Runtime/Graphics/CGraphics.hpp"
#include <hecl/Pipeline.hpp>
namespace urde { namespace urde {
@ -15,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) {

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "Runtime/RetroTypes.hpp" #include "Runtime/GCNTypes.hpp"
#include <boo/graphicsdev/IGraphicsDataFactory.hpp> #include <boo/graphicsdev/IGraphicsDataFactory.hpp>

View File

@ -1,7 +1,10 @@
#include "CModelShaders.hpp" #include "Runtime/Graphics/Shaders/CModelShaders.hpp"
#include "Graphics/CLight.hpp"
#include "hecl/Pipeline.hpp" #include "Runtime/CStopwatch.hpp"
#include "CStopwatch.hpp" #include "Runtime/Graphics/CLight.hpp"
#include <hecl/Backend.hpp>
#include <hecl/Pipeline.hpp>
namespace urde { namespace urde {
@ -20,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();
@ -41,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;
@ -57,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},
@ -151,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",
@ -184,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(); }

View File

@ -1,22 +1,25 @@
#pragma once #pragma once
#include <array> #include <array>
#include <optional> #include <cstdint>
#include <memory>
#include "DataSpec/DNAMP1/CMDLMaterials.hpp" #include "DataSpec/DNAMP1/CMDLMaterials.hpp"
#include "Runtime/Graphics/CGraphics.hpp" #include "Runtime/Graphics/CGraphics.hpp"
#include <hecl/Backend.hpp>
#include <hecl/Runtime.hpp>
#include <zeus/CColor.hpp> #include <zeus/CColor.hpp>
#include <zeus/CVector3f.hpp> #include <zeus/CVector3f.hpp>
#include <zeus/CVector4f.hpp> #include <zeus/CVector4f.hpp>
#define URDE_MAX_LIGHTS 8 #define URDE_MAX_LIGHTS 8
namespace hecl::Backend {
class ShaderTag;
}
namespace urde { namespace urde {
class CLight;
enum EExtendedShader : uint8_t { enum EExtendedShader : uint8_t {
Flat, Flat,
@ -56,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;

View File

@ -1,7 +1,11 @@
#include "CParticleSwooshShaders.hpp" #include "Runtime/Graphics/Shaders/CParticleSwooshShaders.hpp"
#include "Particle/CParticleSwoosh.hpp"
#include "Particle/CSwooshDescription.hpp" #include <iterator>
#include "hecl/Pipeline.hpp"
#include "Runtime/Particle/CParticleSwoosh.hpp"
#include "Runtime/Particle/CSwooshDescription.hpp"
#include <hecl/Pipeline.hpp>
namespace urde { namespace urde {
@ -86,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

View File

@ -2,8 +2,6 @@
#include <array> #include <array>
#include "Runtime/Graphics/CGraphics.hpp"
#include <boo/graphicsdev/IGraphicsDataFactory.hpp> #include <boo/graphicsdev/IGraphicsDataFactory.hpp>
#include <zeus/CColor.hpp> #include <zeus/CColor.hpp>

View File

@ -1,7 +1,16 @@
#include "CPhazonSuitFilter.hpp" #include "Runtime/Graphics/Shaders/CPhazonSuitFilter.hpp"
#include "hecl/Pipeline.hpp"
#include "Graphics/CGraphics.hpp" #include <array>
#include "Graphics/CTexture.hpp"
#include "Runtime/Graphics/CGraphics.hpp"
#include "Runtime/Graphics/CTexture.hpp"
#include <hecl/Pipeline.hpp>
#include <zeus/CColor.hpp>
#include <zeus/CVector2f.hpp>
#include <zeus/CVector3f.hpp>
#include <zeus/CVector4f.hpp>
namespace urde { namespace urde {
@ -35,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;
@ -90,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);
} }

View File

@ -1,7 +1,10 @@
#pragma once #pragma once
#include <boo/graphicsdev/IGraphicsDataFactory.hpp> #include <boo/graphicsdev/IGraphicsDataFactory.hpp>
#include <zeus/CColor.hpp>
namespace zeus {
class CColor;
}
namespace urde { namespace urde {
class CTexture; class CTexture;

View File

@ -1,7 +1,11 @@
#include "CRadarPaintShader.hpp" #include "Runtime/Graphics/Shaders/CRadarPaintShader.hpp"
#include "hecl/Pipeline.hpp"
#include "Graphics/CGraphics.hpp" #include <cstring>
#include "Graphics/CTexture.hpp"
#include "Runtime/Graphics/CGraphics.hpp"
#include "Runtime/Graphics/CTexture.hpp"
#include <hecl/Pipeline.hpp>
namespace urde { namespace urde {
@ -22,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);
} }

View File

@ -1,20 +1,22 @@
#pragma once #pragma once
#include <array>
#include <vector> #include <vector>
#include "Runtime/Camera/CCameraFilter.hpp" #include <boo/graphicsdev/IGraphicsDataFactory.hpp>
#include <zeus/CColor.hpp> #include <zeus/CColor.hpp>
#include <zeus/CMatrix4f.hpp> #include <zeus/CVector2f.hpp>
#include <zeus/CRectangle.hpp> #include <zeus/CVector3f.hpp>
namespace urde { namespace urde {
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;
}; };

View File

@ -1,8 +1,12 @@
#include "CRandomStaticFilter.hpp" #include "Runtime/Graphics/Shaders/CRandomStaticFilter.hpp"
#include "Graphics/CBooRenderer.hpp"
#include "GameGlobalObjects.hpp" #include <array>
#include "CSimplePool.hpp"
#include "hecl/Pipeline.hpp" #include "Runtime/GameGlobalObjects.hpp"
#include "Runtime/Camera/CCameraFilter.hpp"
#include "Runtime/Graphics/CBooRenderer.hpp"
#include <hecl/Pipeline.hpp>
namespace urde { namespace urde {
@ -43,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);
} }

View File

@ -1,12 +1,15 @@
#pragma once #pragma once
#include "Runtime/Camera/CCameraFilter.hpp" #include "Runtime/CToken.hpp"
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
#include <zeus/CColor.hpp> #include <zeus/CColor.hpp>
#include <zeus/CMatrix4f.hpp>
#include <zeus/CRectangle.hpp>
namespace urde { namespace urde {
class CTexture;
enum class EFilterShape;
enum class EFilterType;
class CRandomStaticFilter { class CRandomStaticFilter {
struct Uniform { struct Uniform {

View File

@ -1,8 +1,13 @@
#include "CScanLinesFilter.hpp" #include "Runtime/Graphics/Shaders/CScanLinesFilter.hpp"
#include "hecl/Pipeline.hpp"
#include "Graphics/CGraphics.hpp" #include <array>
#include "GameGlobalObjects.hpp"
#include "Graphics/CBooRenderer.hpp" #include "Runtime/GameGlobalObjects.hpp"
#include "Runtime/Camera/CCameraFilter.hpp"
#include "Runtime/Graphics/CBooRenderer.hpp"
#include "Runtime/Graphics/CGraphics.hpp"
#include <hecl/Pipeline.hpp>
namespace urde { namespace urde {
@ -40,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);
} }

View File

@ -1,12 +1,15 @@
#pragma once #pragma once
#include "Runtime/Camera/CCameraFilter.hpp" #include "Runtime/CToken.hpp"
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
#include <zeus/CColor.hpp> #include <zeus/CColor.hpp>
#include <zeus/CMatrix4f.hpp>
#include <zeus/CRectangle.hpp>
namespace urde { namespace urde {
class CTexture;
enum class EFilterShape;
enum class EFilterType;
class CScanLinesFilter { class CScanLinesFilter {
struct Uniform { struct Uniform {

View File

@ -1,7 +1,9 @@
#include "CSpaceWarpFilter.hpp" #include "Runtime/Graphics/Shaders/CSpaceWarpFilter.hpp"
#include "Graphics/CGraphics.hpp"
#include "Graphics/CBooRenderer.hpp" #include "Runtime/Graphics/CBooRenderer.hpp"
#include "hecl/Pipeline.hpp" #include "Runtime/Graphics/CGraphics.hpp"
#include <hecl/Pipeline.hpp>
#define WARP_RAMP_RES 32 #define WARP_RAMP_RES 32
@ -14,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));
@ -31,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);
} }

View File

@ -1,10 +1,13 @@
#pragma once #pragma once
#include "Runtime/RetroTypes.hpp" #include <array>
#include "Runtime/GCNTypes.hpp"
#include <boo/graphicsdev/IGraphicsDataFactory.hpp> #include <boo/graphicsdev/IGraphicsDataFactory.hpp>
#include <zeus/CColor.hpp>
#include <zeus/CMatrix4f.hpp> #include <zeus/CMatrix4f.hpp>
#include <zeus/CVector3f.hpp>
namespace urde { namespace urde {
@ -14,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;

View File

@ -1,6 +1,8 @@
#include "CTextSupportShader.hpp" #include "Runtime/Graphics/Shaders/CTextSupportShader.hpp"
#include "GuiSys/CRasterFont.hpp"
#include "hecl/Pipeline.hpp" #include "Runtime/GuiSys/CRasterFont.hpp"
#include <hecl/Pipeline.hpp>
namespace urde { namespace urde {

View File

@ -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>
@ -13,8 +15,8 @@
namespace urde { namespace urde {
class CGlyph; class CGlyph;
class CTextRenderBuffer;
class CFontImageDef; class CFontImageDef;
class CTextRenderBuffer;
class CTextSupportShader { class CTextSupportShader {
friend class CTextRenderBuffer; friend class CTextRenderBuffer;
@ -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);
}; };

View File

@ -1,6 +1,11 @@
#include "CTexturedQuadFilter.hpp" #include "Runtime/Graphics/Shaders/CTexturedQuadFilter.hpp"
#include "Graphics/CTexture.hpp"
#include "hecl/Pipeline.hpp" #include <array>
#include "Runtime/Camera/CCameraFilter.hpp"
#include "Runtime/Graphics/CTexture.hpp"
#include <hecl/Pipeline.hpp>
namespace urde { namespace urde {
@ -184,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);
} }
@ -202,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;
@ -231,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));
@ -276,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());
} }
} }
@ -310,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);
} }

View File

@ -1,7 +1,8 @@
#pragma once #pragma once
#include "Runtime/CToken.hpp" #include "Runtime/CToken.hpp"
#include "Runtime/Camera/CCameraFilter.hpp"
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
#include <zeus/CColor.hpp> #include <zeus/CColor.hpp>
#include <zeus/CMatrix4f.hpp> #include <zeus/CMatrix4f.hpp>
@ -10,6 +11,10 @@
#include <zeus/CVector3f.hpp> #include <zeus/CVector3f.hpp>
namespace urde { namespace urde {
class CTexture;
enum class EFilterShape;
enum class EFilterType;
class CTexturedQuadFilter { class CTexturedQuadFilter {
public: public:

View File

@ -1,8 +1,11 @@
#include "CThermalColdFilter.hpp" #include "Runtime/Graphics/Shaders/CThermalColdFilter.hpp"
#include "Graphics/CGraphics.hpp"
#include "Graphics/CBooRenderer.hpp" #include "Runtime/GameGlobalObjects.hpp"
#include "hecl/Pipeline.hpp" #include "Runtime/Graphics/CBooRenderer.hpp"
#include "GameGlobalObjects.hpp" #include "Runtime/Graphics/CGraphics.hpp"
#include <hecl/Pipeline.hpp>
#include <zeus/CVector2f.hpp>
namespace urde { namespace urde {
@ -18,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);

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "Runtime/RetroTypes.hpp" #include <array>
#include <boo/graphicsdev/IGraphicsDataFactory.hpp> #include <boo/graphicsdev/IGraphicsDataFactory.hpp>
@ -12,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;

View File

@ -1,8 +1,11 @@
#include "CThermalHotFilter.hpp" #include "Runtime/Graphics/Shaders/CThermalHotFilter.hpp"
#include "Graphics/CGraphics.hpp"
#include "hecl/Pipeline.hpp" #include "Runtime/GameGlobalObjects.hpp"
#include "GameGlobalObjects.hpp" #include "Runtime/Graphics/CBooRenderer.hpp"
#include "Graphics/CBooRenderer.hpp" #include "Runtime/Graphics/CGraphics.hpp"
#include <hecl/Pipeline.hpp>
#include <zeus/CVector2f.hpp>
namespace urde { namespace urde {
@ -17,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);
} }

View File

@ -1,15 +1,16 @@
#pragma once #pragma once
#include <array>
#include <boo/graphicsdev/IGraphicsDataFactory.hpp> #include <boo/graphicsdev/IGraphicsDataFactory.hpp>
#include <zeus/CColor.hpp> #include <zeus/CColor.hpp>
#include <zeus/CMatrix4f.hpp>
namespace urde { 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;

View File

@ -1,6 +1,12 @@
#include "CWorldShadowShader.hpp" #include "Runtime/Graphics/Shaders/CWorldShadowShader.hpp"
#include "hecl/Pipeline.hpp"
#include "Graphics/CGraphics.hpp" #include <array>
#include "Runtime/Camera/CCameraFilter.hpp"
#include "Runtime/Graphics/CGraphics.hpp"
#include <hecl/Pipeline.hpp>
#include <zeus/CVector3f.hpp>
namespace urde { namespace urde {
@ -21,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);
@ -37,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;

View File

@ -2,9 +2,11 @@
#include <optional> #include <optional>
#include "Runtime/Graphics/Shaders/CColoredQuadFilter.hpp" #include "Runtime/GCNTypes.hpp"
#include "Runtime/Graphics/Shaders/CTexturedQuadFilter.hpp" #include "Runtime/Graphics/Shaders/CTexturedQuadFilter.hpp"
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
#include <zeus/CColor.hpp> #include <zeus/CColor.hpp>
#include <zeus/CMatrix4f.hpp> #include <zeus/CMatrix4f.hpp>

View File

@ -1,8 +1,11 @@
#include "CXRayBlurFilter.hpp" #include "Runtime/Graphics/Shaders/CXRayBlurFilter.hpp"
#include "Graphics/CGraphics.hpp"
#include "Graphics/CTexture.hpp" #include "Runtime/GameGlobalObjects.hpp"
#include "GameGlobalObjects.hpp" #include "Runtime/Graphics/CGraphics.hpp"
#include "hecl/Pipeline.hpp" #include "Runtime/Graphics/CTexture.hpp"
#include <hecl/Pipeline.hpp>
#include <zeus/CVector2f.hpp>
namespace urde { namespace urde {
@ -17,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);
} }
@ -39,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;

View File

@ -1,9 +1,10 @@
#pragma once #pragma once
#include <array>
#include "Runtime/CToken.hpp" #include "Runtime/CToken.hpp"
#include <boo/graphicsdev/IGraphicsDataFactory.hpp> #include <boo/graphicsdev/IGraphicsDataFactory.hpp>
#include <zeus/CColor.hpp>
#include <zeus/CMatrix4f.hpp> #include <zeus/CMatrix4f.hpp>
namespace urde { namespace urde {
@ -11,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;

View File

@ -1,7 +1,9 @@
#include "CAuiImagePane.hpp" #include "Runtime/GuiSys/CAuiImagePane.hpp"
#include "CSimplePool.hpp"
#include "Graphics/CTexture.hpp" #include "Runtime/CSimplePool.hpp"
#include "CGuiWidgetDrawParms.hpp" #include "Runtime/Camera/CCameraFilter.hpp"
#include "Runtime/Graphics/CTexture.hpp"
#include "Runtime/GuiSys/CGuiWidgetDrawParms.hpp"
namespace urde { namespace urde {

View File

@ -6,6 +6,7 @@
#include "Runtime/CScannableObjectInfo.hpp" #include "Runtime/CScannableObjectInfo.hpp"
#include "Runtime/RetroTypes.hpp" #include "Runtime/RetroTypes.hpp"
#include "Runtime/rstl.hpp" #include "Runtime/rstl.hpp"
#include "Runtime/Camera/CCameraFilter.hpp"
#include "Runtime/Graphics/CTexture.hpp" #include "Runtime/Graphics/CTexture.hpp"
#include "Runtime/Graphics/Shaders/CTexturedQuadFilter.hpp" #include "Runtime/Graphics/Shaders/CTexturedQuadFilter.hpp"

View File

@ -1,8 +1,10 @@
#include "CSplashScreen.hpp" #include "Runtime/GuiSys/CSplashScreen.hpp"
#include "CArchitectureMessage.hpp"
#include "CArchitectureQueue.hpp" #include "Runtime/CArchitectureMessage.hpp"
#include "CSimplePool.hpp" #include "Runtime/CArchitectureQueue.hpp"
#include "GameGlobalObjects.hpp" #include "Runtime/CSimplePool.hpp"
#include "Runtime/GameGlobalObjects.hpp"
#include "Runtime/Camera/CCameraFilter.hpp"
namespace urde { namespace urde {

View File

@ -11,6 +11,7 @@
#include "Runtime/RetroTypes.hpp" #include "Runtime/RetroTypes.hpp"
#include "Runtime/Audio/CSfxManager.hpp" #include "Runtime/Audio/CSfxManager.hpp"
#include "Runtime/Audio/CStaticAudioPlayer.hpp" #include "Runtime/Audio/CStaticAudioPlayer.hpp"
#include "Runtime/Camera/CCameraFilter.hpp"
#include "Runtime/Graphics/Shaders/CColoredQuadFilter.hpp" #include "Runtime/Graphics/Shaders/CColoredQuadFilter.hpp"
#include "Runtime/Graphics/Shaders/CTexturedQuadFilter.hpp" #include "Runtime/Graphics/Shaders/CTexturedQuadFilter.hpp"
#include "Runtime/GuiSys/CGuiTextSupport.hpp" #include "Runtime/GuiSys/CGuiTextSupport.hpp"

View File

@ -4,6 +4,7 @@
#include <vector> #include <vector>
#include "Runtime/CMFGameBase.hpp" #include "Runtime/CMFGameBase.hpp"
#include "Runtime/Camera/CCameraFilter.hpp"
#include "Runtime/Graphics/Shaders/CColoredQuadFilter.hpp" #include "Runtime/Graphics/Shaders/CColoredQuadFilter.hpp"
#include "Runtime/MP1/CInGameGuiManager.hpp" #include "Runtime/MP1/CInGameGuiManager.hpp"

View File

@ -1,14 +1,16 @@
#include "CQuitGameScreen.hpp" #include "Runtime/MP1/CQuitGameScreen.hpp"
#include "Input/CFinalInput.hpp"
#include "GameGlobalObjects.hpp" #include "Runtime/GameGlobalObjects.hpp"
#include "CSimplePool.hpp" #include "Runtime/CSimplePool.hpp"
#include "GuiSys/CGuiFrame.hpp" #include "Runtime/Audio/CSfxManager.hpp"
#include "GuiSys/CGuiTableGroup.hpp" #include "Runtime/Camera/CCameraFilter.hpp"
#include "GuiSys/CGuiTextPane.hpp" #include "Runtime/Input/CFinalInput.hpp"
#include "GuiSys/CStringTable.hpp" #include "Runtime/Graphics/CGraphics.hpp"
#include "GuiSys/CGuiWidgetDrawParms.hpp" #include "Runtime/GuiSys/CGuiFrame.hpp"
#include "Audio/CSfxManager.hpp" #include "Runtime/GuiSys/CGuiTableGroup.hpp"
#include "Graphics/CGraphics.hpp" #include "Runtime/GuiSys/CGuiTextPane.hpp"
#include "Runtime/GuiSys/CGuiWidgetDrawParms.hpp"
#include "Runtime/GuiSys/CStringTable.hpp"
namespace urde::MP1 { namespace urde::MP1 {

View File

@ -6,6 +6,7 @@
#include "Runtime/CToken.hpp" #include "Runtime/CToken.hpp"
#include "Runtime/rstl.hpp" #include "Runtime/rstl.hpp"
#include "Runtime/Camera/CCameraFilter.hpp"
#include "Runtime/Graphics/Shaders/CRandomStaticFilter.hpp" #include "Runtime/Graphics/Shaders/CRandomStaticFilter.hpp"
#include "Runtime/GuiSys/CHudBallInterface.hpp" #include "Runtime/GuiSys/CHudBallInterface.hpp"
#include "Runtime/GuiSys/CHudBossEnergyInterface.hpp" #include "Runtime/GuiSys/CHudBossEnergyInterface.hpp"

View File

@ -8,6 +8,7 @@
#include "Runtime/CToken.hpp" #include "Runtime/CToken.hpp"
#include "Runtime/RetroTypes.hpp" #include "Runtime/RetroTypes.hpp"
#include "Runtime/Audio/CSfxManager.hpp" #include "Runtime/Audio/CSfxManager.hpp"
#include "Runtime/Camera/CCameraFilter.hpp"
#include "Runtime/Graphics/Shaders/CTexturedQuadFilter.hpp" #include "Runtime/Graphics/Shaders/CTexturedQuadFilter.hpp"
#include "Runtime/GuiSys/CGuiTextSupport.hpp" #include "Runtime/GuiSys/CGuiTextSupport.hpp"

View File

@ -5,6 +5,7 @@
#include "Runtime/RetroTypes.hpp" #include "Runtime/RetroTypes.hpp"
#include "Runtime/rstl.hpp" #include "Runtime/rstl.hpp"
#include "Runtime/Camera/CCameraFilter.hpp"
#include "Runtime/Character/CActorLights.hpp" #include "Runtime/Character/CActorLights.hpp"
#include "Runtime/Character/CModelData.hpp" #include "Runtime/Character/CModelData.hpp"
#include "Runtime/Graphics/CRainSplashGenerator.hpp" #include "Runtime/Graphics/CRainSplashGenerator.hpp"

View File

@ -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 north = (flags[yTile + 1][xTile] & 0x2) != 0;
bool r16 = (flags[yTile][xTile - 1] & 0x8) != 0; // West const bool west = (flags[yTile][xTile - 1] & 0x8) != 0;
bool r18 = (flags[yTile][xTile + 1] & 0x4) != 0; // East const bool east = (flags[yTile][xTile + 1] & 0x4) != 0;
bool r17 = (flags[yTile - 1][xTile] & 0x1) != 0; // South const bool south = (flags[yTile - 1][xTile] & 0x1) != 0;
pv.m_outerLevels[0] = r16 ? subdivF : 1.f; pv.m_outerLevels[0] = west ? subdivF : 1.f;
pv.m_outerLevels[1] = r17 ? subdivF : 1.f; pv.m_outerLevels[1] = south ? subdivF : 1.f;
pv.m_outerLevels[2] = r18 ? subdivF : 1.f; pv.m_outerLevels[2] = east ? subdivF : 1.f;
pv.m_outerLevels[3] = r19 ? subdivF : 1.f; pv.m_outerLevels[3] = north ? 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;

View File

@ -6,6 +6,7 @@
#include "Runtime/CRandom16.hpp" #include "Runtime/CRandom16.hpp"
#include "Runtime/RetroTypes.hpp" #include "Runtime/RetroTypes.hpp"
#include "Runtime/Audio/CSfxManager.hpp" #include "Runtime/Audio/CSfxManager.hpp"
#include "Runtime/Camera/CCameraFilter.hpp"
#include "Runtime/Character/CModelData.hpp" #include "Runtime/Character/CModelData.hpp"
#include "Runtime/Graphics/CLight.hpp" #include "Runtime/Graphics/CLight.hpp"
#include "Runtime/Graphics/Shaders/CCameraBlurFilter.hpp" #include "Runtime/Graphics/Shaders/CCameraBlurFilter.hpp"