metaforce/Runtime/Graphics/Shaders/CParticleSwooshShaders.cpp

90 lines
3.3 KiB
C++
Raw Normal View History

#include "CParticleSwooshShaders.hpp"
#include "Particle/CParticleSwoosh.hpp"
#include "Particle/CSwooshDescription.hpp"
2018-10-07 02:59:17 +00:00
#include "hecl/Pipeline.hpp"
2018-12-08 05:30:43 +00:00
namespace urde {
boo::ObjToken<boo::IShaderPipeline> CParticleSwooshShaders::m_texZWrite;
boo::ObjToken<boo::IShaderPipeline> CParticleSwooshShaders::m_texNoZWrite;
boo::ObjToken<boo::IShaderPipeline> CParticleSwooshShaders::m_texAdditiveZWrite;
boo::ObjToken<boo::IShaderPipeline> CParticleSwooshShaders::m_texAdditiveNoZWrite;
boo::ObjToken<boo::IShaderPipeline> CParticleSwooshShaders::m_noTexZWrite;
boo::ObjToken<boo::IShaderPipeline> CParticleSwooshShaders::m_noTexNoZWrite;
boo::ObjToken<boo::IShaderPipeline> CParticleSwooshShaders::m_noTexAdditiveZWrite;
boo::ObjToken<boo::IShaderPipeline> CParticleSwooshShaders::m_noTexAdditiveNoZWrite;
2018-10-07 02:59:17 +00:00
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
2018-12-08 05:30:43 +00:00
void CParticleSwooshShaders::Initialize() {
m_texZWrite = hecl::conv->convert(Shader_CParticleSwooshShaderTexZWrite{});
m_texNoZWrite = hecl::conv->convert(Shader_CParticleSwooshShaderTexNoZWrite{});
m_texAdditiveZWrite = hecl::conv->convert(Shader_CParticleSwooshShaderTexAdditiveZWrite{});
m_texAdditiveNoZWrite = hecl::conv->convert(Shader_CParticleSwooshShaderTexAdditiveNoZWrite{});
m_noTexZWrite = hecl::conv->convert(Shader_CParticleSwooshShaderNoTexZWrite{});
m_noTexNoZWrite = hecl::conv->convert(Shader_CParticleSwooshShaderNoTexNoZWrite{});
m_noTexAdditiveZWrite = hecl::conv->convert(Shader_CParticleSwooshShaderNoTexAdditiveZWrite{});
m_noTexAdditiveNoZWrite = hecl::conv->convert(Shader_CParticleSwooshShaderNoTexAdditiveNoZWrite{});
2018-10-07 02:59:17 +00:00
}
2018-12-08 05:30:43 +00:00
void CParticleSwooshShaders::Shutdown() {
m_texZWrite.reset();
m_texNoZWrite.reset();
m_texAdditiveZWrite.reset();
m_texAdditiveNoZWrite.reset();
m_noTexZWrite.reset();
m_noTexNoZWrite.reset();
m_noTexAdditiveZWrite.reset();
m_noTexAdditiveNoZWrite.reset();
2018-10-07 02:59:17 +00:00
}
2018-12-08 05:30:43 +00:00
CParticleSwooshShaders::EShaderClass CParticleSwooshShaders::GetShaderClass(CParticleSwoosh& gen) {
CSwooshDescription* desc = gen.GetDesc();
2018-12-08 05:30:43 +00:00
if (desc->x3c_TEXR)
return EShaderClass::Tex;
else
return EShaderClass::NoTex;
}
2018-12-08 05:30:43 +00:00
void CParticleSwooshShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CParticleSwoosh& gen) {
CSwooshDescription* desc = gen.GetDesc();
boo::ObjToken<boo::IShaderPipeline> pipeline;
2018-12-08 05:30:43 +00:00
if (desc->x3c_TEXR) {
if (desc->x44_31_AALP) {
if (desc->x45_24_ZBUF)
pipeline = m_texAdditiveZWrite;
else
pipeline = m_texAdditiveNoZWrite;
} else {
if (desc->x45_24_ZBUF)
pipeline = m_texZWrite;
else
pipeline = m_texNoZWrite;
}
2018-12-08 05:30:43 +00:00
} else {
if (desc->x44_31_AALP) {
if (desc->x45_24_ZBUF)
pipeline = m_noTexAdditiveZWrite;
else
pipeline = m_noTexAdditiveNoZWrite;
} else {
if (desc->x45_24_ZBUF)
pipeline = m_noTexZWrite;
else
pipeline = m_noTexNoZWrite;
}
2018-12-08 05:30:43 +00:00
}
2018-12-08 05:30:43 +00:00
CUVElement* texr = desc->x3c_TEXR.get();
boo::ObjToken<boo::ITexture> textures[] = {texr ? texr->GetValueTexture(0).GetObj()->GetBooTexture() : nullptr};
2018-12-08 05:30:43 +00:00
boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {gen.m_uniformBuf.get()};
gen.m_dataBind = ctx.newShaderDataBinding(pipeline, gen.m_vertBuf.get(), nullptr, nullptr, 1, uniforms, nullptr,
texr ? 1 : 0, textures, nullptr, nullptr);
2018-10-07 02:59:17 +00:00
}
2018-12-08 05:30:43 +00:00
} // namespace urde