2019-09-29 00:30:53 +00:00
|
|
|
#include "Runtime/Graphics/Shaders/CParticleSwooshShaders.hpp"
|
|
|
|
|
2019-09-29 02:22:12 +00:00
|
|
|
#include <iterator>
|
|
|
|
|
2019-09-29 00:30:53 +00:00
|
|
|
#include "Runtime/Particle/CParticleSwoosh.hpp"
|
|
|
|
#include "Runtime/Particle/CSwooshDescription.hpp"
|
|
|
|
|
|
|
|
#include <hecl/Pipeline.hpp>
|
2017-06-10 05:34:39 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
namespace urde {
|
2017-06-10 05:34:39 +00:00
|
|
|
|
2019-03-03 06:19:42 +00:00
|
|
|
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CParticleSwooshShaders::m_texZWrite;
|
|
|
|
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CParticleSwooshShaders::m_texNoZWrite;
|
|
|
|
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CParticleSwooshShaders::m_texAdditiveZWrite;
|
|
|
|
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CParticleSwooshShaders::m_texAdditiveNoZWrite;
|
2017-06-10 05:34:39 +00:00
|
|
|
|
2019-03-03 06:19:42 +00:00
|
|
|
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CParticleSwooshShaders::m_noTexZWrite;
|
|
|
|
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CParticleSwooshShaders::m_noTexNoZWrite;
|
|
|
|
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CParticleSwooshShaders::m_noTexAdditiveZWrite;
|
|
|
|
std::array<boo::ObjToken<boo::IShaderPipeline>, 2> CParticleSwooshShaders::m_noTexAdditiveNoZWrite;
|
2017-06-10 05:34:39 +00:00
|
|
|
|
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() {
|
2019-03-03 06:19:42 +00:00
|
|
|
m_texZWrite = {hecl::conv->convert(Shader_CParticleSwooshShaderTexZWrite{}),
|
|
|
|
hecl::conv->convert(Shader_CParticleSwooshShaderTexZWriteAWrite{})};
|
|
|
|
m_texNoZWrite = {hecl::conv->convert(Shader_CParticleSwooshShaderTexNoZWrite{}),
|
|
|
|
hecl::conv->convert(Shader_CParticleSwooshShaderTexNoZWriteAWrite{})};
|
|
|
|
m_texAdditiveZWrite = {hecl::conv->convert(Shader_CParticleSwooshShaderTexAdditiveZWrite{}),
|
|
|
|
hecl::conv->convert(Shader_CParticleSwooshShaderTexAdditiveZWriteAWrite{})};
|
|
|
|
m_texAdditiveNoZWrite = {hecl::conv->convert(Shader_CParticleSwooshShaderTexAdditiveNoZWrite{}),
|
|
|
|
hecl::conv->convert(Shader_CParticleSwooshShaderTexAdditiveNoZWriteAWrite{})};
|
|
|
|
m_noTexZWrite = {hecl::conv->convert(Shader_CParticleSwooshShaderNoTexZWrite{}),
|
|
|
|
hecl::conv->convert(Shader_CParticleSwooshShaderNoTexZWriteAWrite{})};
|
|
|
|
m_noTexNoZWrite = {hecl::conv->convert(Shader_CParticleSwooshShaderNoTexNoZWrite{}),
|
|
|
|
hecl::conv->convert(Shader_CParticleSwooshShaderNoTexNoZWriteAWrite{})};
|
|
|
|
m_noTexAdditiveZWrite = {hecl::conv->convert(Shader_CParticleSwooshShaderNoTexAdditiveZWrite{}),
|
|
|
|
hecl::conv->convert(Shader_CParticleSwooshShaderNoTexAdditiveZWriteAWrite{})};
|
|
|
|
m_noTexAdditiveNoZWrite = {hecl::conv->convert(Shader_CParticleSwooshShaderNoTexAdditiveNoZWrite{}),
|
|
|
|
hecl::conv->convert(Shader_CParticleSwooshShaderNoTexAdditiveNoZWriteAWrite{})};
|
2018-10-07 02:59:17 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CParticleSwooshShaders::Shutdown() {
|
2019-03-03 06:19:42 +00:00
|
|
|
for (auto& s : m_texZWrite) s.reset();
|
|
|
|
for (auto& s : m_texNoZWrite) s.reset();
|
|
|
|
for (auto& s : m_texAdditiveZWrite) s.reset();
|
|
|
|
for (auto& s : m_texAdditiveNoZWrite) s.reset();
|
|
|
|
for (auto& s : m_noTexZWrite) s.reset();
|
|
|
|
for (auto& s : m_noTexNoZWrite) s.reset();
|
|
|
|
for (auto& s : m_noTexAdditiveZWrite) s.reset();
|
|
|
|
for (auto& s : m_noTexAdditiveNoZWrite) s.reset();
|
2018-10-07 02:59:17 +00:00
|
|
|
}
|
2017-06-10 05:34:39 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CParticleSwooshShaders::EShaderClass CParticleSwooshShaders::GetShaderClass(CParticleSwoosh& gen) {
|
|
|
|
CSwooshDescription* desc = gen.GetDesc();
|
2017-06-10 05:34:39 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (desc->x3c_TEXR)
|
|
|
|
return EShaderClass::Tex;
|
|
|
|
else
|
|
|
|
return EShaderClass::NoTex;
|
2017-06-10 05:34:39 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CParticleSwooshShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CParticleSwoosh& gen) {
|
|
|
|
CSwooshDescription* desc = gen.GetDesc();
|
2019-03-03 06:19:42 +00:00
|
|
|
std::array<boo::ObjToken<boo::IShaderPipeline>, 2>* pipeline = nullptr;
|
2017-06-10 05:34:39 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (desc->x3c_TEXR) {
|
|
|
|
if (desc->x44_31_AALP) {
|
|
|
|
if (desc->x45_24_ZBUF)
|
2019-03-03 06:19:42 +00:00
|
|
|
pipeline = &m_texAdditiveZWrite;
|
2018-12-08 05:30:43 +00:00
|
|
|
else
|
2019-03-03 06:19:42 +00:00
|
|
|
pipeline = &m_texAdditiveNoZWrite;
|
2018-12-08 05:30:43 +00:00
|
|
|
} else {
|
|
|
|
if (desc->x45_24_ZBUF)
|
2019-03-03 06:19:42 +00:00
|
|
|
pipeline = &m_texZWrite;
|
2018-12-08 05:30:43 +00:00
|
|
|
else
|
2019-03-03 06:19:42 +00:00
|
|
|
pipeline = &m_texNoZWrite;
|
2017-06-10 05:34:39 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
} else {
|
|
|
|
if (desc->x44_31_AALP) {
|
|
|
|
if (desc->x45_24_ZBUF)
|
2019-03-03 06:19:42 +00:00
|
|
|
pipeline = &m_noTexAdditiveZWrite;
|
2018-12-08 05:30:43 +00:00
|
|
|
else
|
2019-03-03 06:19:42 +00:00
|
|
|
pipeline = &m_noTexAdditiveNoZWrite;
|
2018-12-08 05:30:43 +00:00
|
|
|
} else {
|
|
|
|
if (desc->x45_24_ZBUF)
|
2019-03-03 06:19:42 +00:00
|
|
|
pipeline = &m_noTexZWrite;
|
2018-12-08 05:30:43 +00:00
|
|
|
else
|
2019-03-03 06:19:42 +00:00
|
|
|
pipeline = &m_noTexNoZWrite;
|
2017-06-10 05:34:39 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2017-06-10 05:34:39 +00:00
|
|
|
|
2019-09-29 02:22:12 +00:00
|
|
|
const CUVElement* const texr = desc->x3c_TEXR.get();
|
|
|
|
const std::array<boo::ObjToken<boo::ITexture>, 1> textures{
|
|
|
|
texr ? texr->GetValueTexture(0).GetObj()->GetBooTexture() : nullptr,
|
|
|
|
};
|
2017-06-10 05:34:39 +00:00
|
|
|
|
2019-09-29 02:22:12 +00:00
|
|
|
const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> uniforms{gen.m_uniformBuf.get()};
|
2020-04-12 00:20:45 +00:00
|
|
|
for (size_t i = 0; i < gen.m_dataBind.size(); ++i) {
|
2019-09-29 02:22:12 +00:00
|
|
|
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);
|
|
|
|
}
|
2018-10-07 02:59:17 +00:00
|
|
|
}
|
2017-06-10 05:34:39 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
} // namespace urde
|