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