From 4c64369453e701a37cf5e0cea4d43e6a4a1ca5e3 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Wed, 21 Oct 2020 01:37:53 -0400 Subject: [PATCH] CPhazonSuitFilter: Separate tex and notex shaders --- .../Graphics/Shaders/CPhazonSuitFilter.cpp | 46 +++++++++++-------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/Runtime/Graphics/Shaders/CPhazonSuitFilter.cpp b/Runtime/Graphics/Shaders/CPhazonSuitFilter.cpp index 8aa78c796..61d047b08 100644 --- a/Runtime/Graphics/Shaders/CPhazonSuitFilter.cpp +++ b/Runtime/Graphics/Shaders/CPhazonSuitFilter.cpp @@ -10,33 +10,43 @@ namespace urde { using namespace hsh::pipeline; -template struct CPhazonSuitFilterPipeline : pipeline, AdditiveAttachment<>, depth_write> { CPhazonSuitFilterPipeline(hsh::vertex_buffer vbo, hsh::uniform_buffer ubo, hsh::render_texture2d screenTex, - hsh::texture2d indTex, hsh::render_texture2d maskTex, hsh::render_texture2d maskTexBlur) { + hsh::render_texture2d maskTex, hsh::render_texture2d maskTexBlur) { this->position = hsh::float4(vbo->pos, 1.f); hsh::float2 maskUv = vbo->maskUv; maskUv.y = 1.f - maskUv.y; hsh::float2 screenUv = vbo->screenUv; screenUv.y = 1.f - screenUv.y; float maskBlurAlpha = hsh::saturate((maskTexBlur.sample(maskUv).w - maskTex.sample(maskUv).w) * 2.f); - if constexpr (NoIndTex) { - this->color_out[0] = - hsh::float4((ubo->color * screenTex.sample(screenUv) * maskBlurAlpha).xyz(), ubo->color.w); - } else { - hsh::float2 indUv = - (indTex.sample(vbo->indUv).xy() - hsh::float2(0.5f)) * ubo->indScaleOff.xy() + ubo->indScaleOff.zw(); - this->color_out[0] = - hsh::float4((ubo->color * screenTex.sample(indUv + screenUv) * maskBlurAlpha).xyz(), ubo->color.w); - } + this->color_out[0] = + hsh::float4((ubo->color * screenTex.sample(screenUv) * maskBlurAlpha).xyz(), ubo->color.w); + } +}; + +struct CPhazonSuitFilterIndTexPipeline +: pipeline, AdditiveAttachment<>, depth_write> { + CPhazonSuitFilterIndTexPipeline(hsh::vertex_buffer vbo, + hsh::uniform_buffer ubo, hsh::render_texture2d screenTex, + hsh::texture2d indTex, hsh::render_texture2d maskTex, + hsh::render_texture2d maskTexBlur) { + this->position = hsh::float4(vbo->pos, 1.f); + hsh::float2 maskUv = vbo->maskUv; + maskUv.y = 1.f - maskUv.y; + hsh::float2 screenUv = vbo->screenUv; + screenUv.y = 1.f - screenUv.y; + float maskBlurAlpha = hsh::saturate((maskTexBlur.sample(maskUv).w - maskTex.sample(maskUv).w) * 2.f); + hsh::float2 indUv = + (indTex.sample(vbo->indUv).xy() - hsh::float2(0.5f)) * ubo->indScaleOff.xy() + ubo->indScaleOff.zw(); + this->color_out[0] = + hsh::float4((ubo->color * screenTex.sample(indUv + screenUv) * maskBlurAlpha).xyz(), ubo->color.w); } }; -template struct CPhazonSuitFilterPipeline; -template struct CPhazonSuitFilterPipeline; struct CPhazonSuitFilterBlurPipeline -: pipeline, +: pipeline, + color_attachment, depth_write> { CPhazonSuitFilterBlurPipeline(hsh::vertex_buffer vbo, hsh::uniform_buffer ubo, @@ -111,13 +121,13 @@ void CPhazonSuitFilter::drawBlurPasses(float radius, const CTexture* indTex) { bool hasIndTex = m_indTex != nullptr; if (hasIndTex) { hsh::texture2d tex = m_indTex->GetBooTexture(); - m_dataBind.hsh_ind_bind(CPhazonSuitFilterPipeline( + m_dataBind.hsh_ind_bind(CPhazonSuitFilterIndTexPipeline( m_vbo.get(), m_uniBuf.get(), CGraphics::g_SpareTexture.get_color(0), tex, CGraphics::g_SpareTexture.get_color(1), CGraphics::g_SpareTexture.get_color(2))); } else { - m_dataBind.hsh_noind_bind(CPhazonSuitFilterPipeline( - m_vbo.get(), m_uniBuf.get(), CGraphics::g_SpareTexture.get_color(0), hsh::texture2d{}, - CGraphics::g_SpareTexture.get_color(1), CGraphics::g_SpareTexture.get_color(2))); + m_dataBind.hsh_noind_bind( + CPhazonSuitFilterPipeline(m_vbo.get(), m_uniBuf.get(), CGraphics::g_SpareTexture.get_color(0), + CGraphics::g_SpareTexture.get_color(1), CGraphics::g_SpareTexture.get_color(2))); } }