metaforce/Runtime/Graphics/Shaders/CEnvFxShaders.cpp

39 lines
1.9 KiB
C++
Raw Normal View History

2018-11-02 08:16:16 +00:00
#include "CEnvFxShaders.hpp"
#include "hecl/Pipeline.hpp"
#include "World/CEnvFxManager.hpp"
2018-12-08 05:30:43 +00:00
namespace urde {
2018-11-02 08:16:16 +00:00
boo::ObjToken<boo::IShaderPipeline> CEnvFxShaders::m_snowPipeline;
boo::ObjToken<boo::IShaderPipeline> CEnvFxShaders::m_underwaterPipeline;
2018-12-08 05:30:43 +00:00
void CEnvFxShaders::Initialize() {
m_snowPipeline = hecl::conv->convert(Shader_CEnvFxSnowShader{});
m_underwaterPipeline = hecl::conv->convert(Shader_CEnvFxUnderwaterShader{});
2018-11-02 08:16:16 +00:00
}
2018-12-08 05:30:43 +00:00
void CEnvFxShaders::Shutdown() {
m_snowPipeline.reset();
m_underwaterPipeline.reset();
2018-11-02 08:16:16 +00:00
}
2018-12-08 05:30:43 +00:00
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);
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);
2018-11-02 08:16:16 +00:00
}
2018-12-08 05:30:43 +00:00
} // namespace urde