mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-09 13:47:43 +00:00
Huge shader refactor
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "CDecalShaders.hpp"
|
||||
#include "Particle/CDecal.hpp"
|
||||
#include "hecl/Pipeline.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
@@ -11,8 +12,23 @@ boo::ObjToken<boo::IShaderPipeline> CDecalShaders::m_texRedToAlphaZTest;
|
||||
boo::ObjToken<boo::IShaderPipeline> CDecalShaders::m_noTexZTestNoZWrite;
|
||||
boo::ObjToken<boo::IShaderPipeline> CDecalShaders::m_noTexAdditiveZTest;
|
||||
|
||||
boo::ObjToken<boo::IVertexFormat> CDecalShaders::m_vtxFormatTex;
|
||||
boo::ObjToken<boo::IVertexFormat> CDecalShaders::m_vtxFormatNoTex;
|
||||
void CDecalShaders::Initialize()
|
||||
{
|
||||
m_texZTestNoZWrite = hecl::conv->convert(Shader_CDecalShaderTexZTest{});
|
||||
m_texAdditiveZTest = hecl::conv->convert(Shader_CDecalShaderTexAdditiveZTest{});
|
||||
m_texRedToAlphaZTest = hecl::conv->convert(Shader_CDecalShaderTexRedToAlphaZTest{});
|
||||
m_noTexZTestNoZWrite = hecl::conv->convert(Shader_CDecalShaderNoTexZTest{});
|
||||
m_noTexAdditiveZTest = hecl::conv->convert(Shader_CDecalShaderNoTexAdditiveZTest{});
|
||||
}
|
||||
|
||||
void CDecalShaders::Shutdown()
|
||||
{
|
||||
m_texZTestNoZWrite.reset();
|
||||
m_texAdditiveZTest.reset();
|
||||
m_texRedToAlphaZTest.reset();
|
||||
m_noTexZTestNoZWrite.reset();
|
||||
m_noTexAdditiveZTest.reset();
|
||||
}
|
||||
|
||||
void CDecalShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CQuadDecal& decal)
|
||||
{
|
||||
@@ -35,10 +51,31 @@ void CDecalShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& c
|
||||
regPipeline = m_noTexZTestNoZWrite;
|
||||
}
|
||||
|
||||
CDecalShaders shad(decal, regPipeline, redToAlphaPipeline);
|
||||
TShader<CDecalShaders>::BuildShaderDataBinding(ctx, shad);
|
||||
const SQuadDescr* desc = decal.m_desc;
|
||||
|
||||
CUVElement* texr = desc->x14_TEX.get();
|
||||
int texCount = 0;
|
||||
boo::ObjToken<boo::ITexture> textures[1];
|
||||
|
||||
if (texr)
|
||||
{
|
||||
textures[0] = texr->GetValueTexture(0).GetObj()->GetBooTexture();
|
||||
texCount = 1;
|
||||
}
|
||||
|
||||
if (decal.m_instBuf)
|
||||
{
|
||||
boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {decal.m_uniformBuf.get()};
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
URDE_SPECIALIZE_SHADER(CDecalShaders)
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user