#include "Runtime/Graphics/Shaders/CDecalShaders.hpp" #include #include "Runtime/Particle/CDecal.hpp" #include "CDecalShaders.cpp.hshhead" namespace urde { using namespace hsh::pipeline; template struct CDecalShaderTexPipeline : pipeline, std::conditional_t, AdditiveAttachment<>>, BlendAttachment<>>, depth_compare, depth_write> { CDecalShaderTexPipeline(hsh::vertex_buffer vbo, hsh::uniform_buffer uniBuf, hsh::texture2d tex) { this->position = uniBuf->mvp * vbo->pos[this->vertex_id]; this->color_out[0] = vbo->color * uniBuf->moduColor * tex.sample(vbo->uvs[this->vertex_id]); if constexpr (RedToAlpha) { this->color_out[0].w = this->color_out[0].x; } } }; template struct CDecalShaderTexPipeline; template struct CDecalShaderTexPipeline; template struct CDecalShaderTexPipeline; template struct CDecalShaderNoTexPipeline : pipeline, BlendAttachment<>>, depth_compare, depth_write> { CDecalShaderNoTexPipeline(hsh::vertex_buffer vbo, hsh::uniform_buffer uniBuf) { this->position = uniBuf->mvp * vbo->pos[this->vertex_id]; this->color_out[0] = vbo->color * uniBuf->moduColor; } }; template struct CDecalShaderNoTexPipeline; template struct CDecalShaderNoTexPipeline; hsh::binding& CDecalShaders::BuildShaderDataBinding(CQuadDecal& decal, hsh::texture2d tex) { bool additive = decal.m_desc->x18_ADD; if (decal.m_desc->x14_TEX) { bool redToAlpha = additive && CDecal::GetMoveRedToAlphaBuffer(); m_dataBind.hsh_tex_bind( CDecalShaderTexPipeline(decal.m_instBuf.get(), decal.m_uniformBuf.get(), tex)); } else { m_dataBind.hsh_notex_bind(CDecalShaderNoTexPipeline(decal.m_instBuf.get(), decal.m_uniformBuf.get())); } return m_dataBind; } } // namespace urde