TMultiBlendShader and quad filters

This commit is contained in:
Jack Andersen 2016-08-16 15:58:53 -10:00
parent d2fca93a8e
commit d234bffe2a
22 changed files with 691 additions and 38 deletions

View File

@ -0,0 +1,32 @@
#include "CCameraFilter.hpp"
#include "GameGlobalObjects.hpp"
#include "Graphics/CBooRenderer.hpp"
namespace urde
{
void CCameraFilterPass::DrawFilter(EFilterType type, EFilterShape shape, const zeus::CColor& color,
const CTexture* tex, float uvScale)
{
switch (type)
{
case EFilterType::ColorMultiply:
case EFilterType::InvertDst:
case EFilterType::AdditiveAlpha:
case EFilterType::Subtractive:
case EFilterType::AlphaBlended:
case EFilterType::AdditiveDestColor:
case EFilterType::NoColorWrite:
case EFilterType::None:
case EFilterType::None2:
default: return;
}
DrawFilterShape(shape, color, tex, uvScale);
}
void CCameraFilterPass::DrawFilterShape(EFilterShape shape, const zeus::CColor& color,
const CTexture* tex, float uvScale)
{
}
}

View File

@ -6,24 +6,43 @@
namespace urde namespace urde
{ {
class CTexture;
class CCameraFilterPass class CCameraFilterPass
{ {
public: public:
enum class EFilterType enum class EFilterType
{ {
Zero, None,
One ColorMultiply,
InvertDst,
AdditiveAlpha,
Subtractive,
AlphaBlended,
None2,
AdditiveDestColor,
NoColorWrite
}; };
enum class EFilterShape enum class EFilterShape
{ {
Zero, QuadA,
One QuadB,
QuadC,
QuadQuarters,
WideScreen,
ScanLinesA,
ScanLinesB,
RandomStaticA,
RandomStaticB
}; };
private: private:
public: public:
void SetFilter(EFilterType type, EFilterShape shape, float, const zeus::CColor& color, u32) {} void SetFilter(EFilterType type, EFilterShape shape, float, const zeus::CColor& color, u32) {}
void DisableFilter(float) {} void DisableFilter(float) {}
static void DrawFilter(EFilterType type, EFilterShape shape, const zeus::CColor& color,
const CTexture* tex, float uvScale);
static void DrawFilterShape(EFilterShape shape, const zeus::CColor& color,
const CTexture* tex, float uvScale);
}; };
class CCameraBlurPass class CCameraBlurPass

View File

@ -109,8 +109,8 @@ void CCameraManager::Update(float dt, CStateManager& stateMgr)
zeus::CColor tmpColor; // Get from water zeus::CColor tmpColor; // Get from water
zeus::CVector2f tmpVector; // Get from camera zeus::CVector2f tmpVector; // Get from camera
x3c_fog.SetFogExplicit(ERglFogMode::PerspExp, tmpColor, tmpVector); x3c_fog.SetFogExplicit(ERglFogMode::PerspExp, tmpColor, tmpVector);
stateMgr.GetCameraFilterPass(4).SetFilter(CCameraFilterPass::EFilterType::One, stateMgr.GetCameraFilterPass(4).SetFilter(CCameraFilterPass::EFilterType::ColorMultiply,
CCameraFilterPass::EFilterShape::Zero, CCameraFilterPass::EFilterShape::QuadA,
0.f, tmpColor, -1); 0.f, tmpColor, -1);
} }
x86_26_inWater = true; x86_26_inWater = true;

View File

@ -1,12 +1,17 @@
if(WIN32) if(WIN32)
set(PLAT_SRCS set(PLAT_SRCS
Shaders/CLineRendererShadersHLSL.cpp Shaders/CLineRendererShaderHLSL.cpp
Shaders/CTexturedQuadFilterHLSL.cpp
Shaders/CColoredQuadFilterHLSL.cpp
Shaders/CModelShadersHLSL.cpp Shaders/CModelShadersHLSL.cpp
Shaders/CThermalColdFilterHLSL.cpp Shaders/CThermalColdFilterHLSL.cpp
Shaders/CThermalHotFilterHLSL.cpp Shaders/CThermalHotFilterHLSL.cpp
Shaders/CSpaceWarpFilterHLSL.cpp) Shaders/CSpaceWarpFilterHLSL.cpp)
elseif(APPLE) elseif(APPLE)
set(PLAT_SRCS Shaders/CLineRendererShadersMetal.cpp set(PLAT_SRCS
Shaders/CLineRendererShadersMetal.cpp
Shaders/CTexturedQuadFilterMetal.cpp
Shaders/CColoredQuadFilterMetal.cpp
Shaders/CModelShadersMetal.cpp Shaders/CModelShadersMetal.cpp
Shaders/CThermalColdFilterMetal.cpp Shaders/CThermalColdFilterMetal.cpp
Shaders/CThermalHotFilterMetal.cpp Shaders/CThermalHotFilterMetal.cpp
@ -34,8 +39,10 @@ set(GRAPHICS_SOURCES
CPVSBounds.hpp CPVSBounds.cpp CPVSBounds.hpp CPVSBounds.cpp
CPVSAreaSet.hpp CPVSAreaSet.cpp CPVSAreaSet.hpp CPVSAreaSet.cpp
CGraphics.hpp CGraphics.cpp CGraphics.hpp CGraphics.cpp
Shaders/TShader.hpp Shaders/TShaderDecl.hpp Shaders/TShader.hpp Shaders/TMultiBlendShader.hpp Shaders/TShaderDecl.hpp Shaders/TMultiBlendShaderDecl.hpp
Shaders/CLineRendererShaders.hpp Shaders/CLineRendererShaders.cpp Shaders/CLineRendererShadersGLSL.cpp Shaders/CLineRendererShaders.hpp Shaders/CLineRendererShaders.cpp Shaders/CLineRendererShadersGLSL.cpp
Shaders/CTexturedQuadFilter.hpp Shaders/CTexturedQuadFilter.cpp Shaders/CTexturedQuadFilterGLSL.cpp
Shaders/CColoredQuadFilter.hpp Shaders/CColoredQuadFilter.cpp Shaders/CColoredQuadFilterGLSL.cpp
Shaders/CModelShaders.hpp Shaders/CModelShaders.cpp Shaders/CModelShadersGLSL.cpp Shaders/CModelShaders.hpp Shaders/CModelShaders.cpp Shaders/CModelShadersGLSL.cpp
Shaders/CXrayOutlineFilter.hpp Shaders/CXrayOutlineFilter.cpp Shaders/CXrayOutlineFilterGLSL.cpp Shaders/CXrayOutlineFilter.hpp Shaders/CXrayOutlineFilter.cpp Shaders/CXrayOutlineFilterGLSL.cpp
Shaders/CThermalColdFilter.hpp Shaders/CThermalColdFilter.cpp Shaders/CThermalColdFilterGLSL.cpp Shaders/CThermalColdFilter.hpp Shaders/CThermalColdFilter.cpp Shaders/CThermalColdFilterGLSL.cpp

View File

@ -0,0 +1,38 @@
#include "CColoredQuadFilter.hpp"
namespace urde
{
CColoredQuadFilter::CColoredQuadFilter(CCameraFilterPass::EFilterType type)
{
m_token = CGraphics::g_BooFactory->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
struct Vert
{
zeus::CVector2f m_pos;
} verts[4] =
{
{{-1.0, -1.0}},
{{-1.0, 1.0}},
{{ 1.0, -1.0}},
{{ 1.0, 1.0}},
};
m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts, 16, 4);
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
m_dataBind = TMultiBlendShader<CColoredQuadFilter>::BuildShaderDataBinding(ctx, type, *this);
return true;
});
}
void CColoredQuadFilter::draw(const zeus::CColor& color)
{
m_uniform.m_color = color;
m_uniBuf->load(&m_uniform, sizeof(m_uniform));
CGraphics::g_BooMainCommandQueue->setShaderDataBinding(m_dataBind);
CGraphics::g_BooMainCommandQueue->draw(0, 4);
}
URDE_SPECIALIZE_MULTI_BLEND_SHADER(CColoredQuadFilter)
}

View File

@ -0,0 +1,39 @@
#ifndef __URDE_CCOLOREDQUADFILTER_HPP__
#define __URDE_CCOLOREDQUADFILTER_HPP__
#include "TMultiBlendShader.hpp"
#include "zeus/CMatrix4f.hpp"
#include "zeus/CColor.hpp"
#include "Camera/CCameraFilter.hpp"
namespace urde
{
class CColoredQuadFilter
{
friend struct CColoredQuadFilterGLDataBindingFactory;
friend struct CColoredQuadFilterVulkanDataBindingFactory;
friend struct CColoredQuadFilterMetalDataBindingFactory;
friend struct CColoredQuadFilterD3DDataBindingFactory;
struct Uniform
{
zeus::CColor m_color;
};
boo::GraphicsDataToken m_token;
boo::IGraphicsBufferS* m_vbo;
boo::IGraphicsBufferD* m_uniBuf;
boo::IShaderDataBinding* m_dataBind = nullptr;
Uniform m_uniform;
public:
CColoredQuadFilter(CCameraFilterPass::EFilterType type);
void draw(const zeus::CColor& color);
using _CLS = CColoredQuadFilter;
#include "TMultiBlendShaderDecl.hpp"
};
}
#endif // __URDE_CCOLOREDQUADFILTER_HPP__

View File

@ -0,0 +1,125 @@
#include "CColoredQuadFilter.hpp"
#include "TMultiBlendShader.hpp"
#include "Graphics/CTexture.hpp"
namespace urde
{
static const char* VS =
"#version 330\n"
BOO_GLSL_BINDING_HEAD
"layout(location=0) in vec4 posIn;\n"
"\n"
"UBINDING0 uniform ColoredQuadUniform\n"
"{\n"
" vec4 color;\n"
"};\n"
"\n"
"struct VertToFrag\n"
"{\n"
" vec4 color;\n"
"};\n"
"\n"
"SBINDING(0) out VertToFrag vtf;\n"
"void main()\n"
"{\n"
" vtf.color = color;\n"
" gl_Position = vec4(posIn.xyz, 1.0);\n"
"}\n";
static const char* FS =
"#version 330\n"
BOO_GLSL_BINDING_HEAD
"struct VertToFrag\n"
"{\n"
" vec4 color;\n"
"};\n"
"\n"
"SBINDING(0) in VertToFrag vtf;\n"
"layout(location=0) out vec4 colorOut;\n"
"void main()\n"
"{\n"
" colorOut = vtf.color;\n"
"}\n";
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CColoredQuadFilter)
struct CColoredQuadFilterGLDataBindingFactory : TMultiBlendShader<CColoredQuadFilter>::IDataBindingFactory
{
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline* pipeline,
boo::IVertexFormat*,
CColoredQuadFilter& filter)
{
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
const boo::VertexElementDescriptor VtxVmt[] =
{
{filter.m_vbo, nullptr, boo::VertexSemantic::Position4}
};
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
return cctx.newShaderDataBinding(pipeline,
ctx.newVertexFormat(1, VtxVmt), filter.m_vbo, nullptr, nullptr,
1, bufs, stages, nullptr, nullptr, 0, nullptr);
}
};
#if BOO_HAS_VULKAN
struct CColoredQuadFilterVulkanDataBindingFactory : TMultiBlendShader<CColoredQuadFilter>::IDataBindingFactory
{
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline* pipeline,
boo::IVertexFormat* vtxFmt,
CColoredQuadFilter& filter)
{
boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
return cctx.newShaderDataBinding(pipeline, vtxFmt,
filter.m_vbo, nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 0, nullptr);
}
};
#endif
TMultiBlendShader<CColoredQuadFilter>::IDataBindingFactory*
CColoredQuadFilter::Initialize(boo::GLDataFactory::Context& ctx,
boo::IShaderPipeline*& alphaPipeOut,
boo::IShaderPipeline*& additivePipeOut,
boo::IShaderPipeline*& colorMultiplyPipeOut)
{
const char* uniNames[] = {"ColoredQuadUniform"};
alphaPipeOut = ctx.newShaderPipeline(VS, FS, 0, nullptr, 1, uniNames, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false);
additivePipeOut = ctx.newShaderPipeline(VS, FS, 0, nullptr, 1, uniNames, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false);
colorMultiplyPipeOut = ctx.newShaderPipeline(VS, FS, 0, nullptr, 1, uniNames, boo::BlendFactor::SrcColor,
boo::BlendFactor::DstColor, boo::Primitive::TriStrips, false, false, false);
return new CColoredQuadFilterGLDataBindingFactory;
}
#if BOO_HAS_VULKAN
TMultiBlendShader<CColoredQuadFilter>::IDataBindingFactory*
CColoredQuadFilter::Initialize(boo::VulkanDataFactory::Context& ctx,
boo::IShaderPipeline*& alphaPipeOut,
boo::IShaderPipeline*& additivePipeOut,
boo::IShaderPipeline*& colorMultiplyPipeOut,
boo::IVertexFormat*& vtxFmtOut)
{
const boo::VertexElementDescriptor VtxVmt[] =
{
{nullptr, nullptr, boo::VertexSemantic::Position4}
};
vtxFmtOut = ctx.newVertexFormat(1, VtxVmt);
alphaPipeOut = ctx.newShaderPipeline(VS, FS, vtxFmtOut, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false);
additivePipeOut = ctx.newShaderPipeline(VS, FS, vtxFmtOut, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false);
colorMultiplyPipeOut = ctx.newShaderPipeline(VS, FS, vtxFmtOut, boo::BlendFactor::SrcColor,
boo::BlendFactor::DstColor, boo::Primitive::TriStrips, false, false, false);
return new CColoredQuadFilterVulkanDataBindingFactory;
}
#endif
}

View File

@ -55,7 +55,10 @@ URDE_DECL_SPECIALIZE_SHADER(CSpaceWarpFilter)
struct CSpaceWarpFilterGLDataBindingFactory : TShader<CSpaceWarpFilter>::IDataBindingFactory struct CSpaceWarpFilterGLDataBindingFactory : TShader<CSpaceWarpFilter>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CSpaceWarpFilter& filter) boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline* pipeline,
boo::IVertexFormat*,
CSpaceWarpFilter& filter)
{ {
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx); boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
@ -67,7 +70,7 @@ struct CSpaceWarpFilterGLDataBindingFactory : TShader<CSpaceWarpFilter>::IDataBi
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex}; boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
boo::ITexture* texs[] = {CGraphics::g_SpareTexture, filter.m_warpTex}; boo::ITexture* texs[] = {CGraphics::g_SpareTexture, filter.m_warpTex};
return cctx.newShaderDataBinding(TShader<CSpaceWarpFilter>::m_pipeline, return cctx.newShaderDataBinding(pipeline,
ctx.newVertexFormat(2, VtxVmt), filter.m_vbo, nullptr, nullptr, ctx.newVertexFormat(2, VtxVmt), filter.m_vbo, nullptr, nullptr,
1, bufs, stages, nullptr, nullptr, 2, texs); 1, bufs, stages, nullptr, nullptr, 2, texs);
} }
@ -76,14 +79,16 @@ struct CSpaceWarpFilterGLDataBindingFactory : TShader<CSpaceWarpFilter>::IDataBi
#if BOO_HAS_VULKAN #if BOO_HAS_VULKAN
struct CSpaceWarpFilterVulkanDataBindingFactory : TShader<CSpaceWarpFilter>::IDataBindingFactory struct CSpaceWarpFilterVulkanDataBindingFactory : TShader<CSpaceWarpFilter>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CSpaceWarpFilter& filter) boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline* pipeline,
boo::IVertexFormat* vtxFmt,
CSpaceWarpFilter& filter)
{ {
boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx); boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
boo::ITexture* texs[] = {CGraphics::g_SpareTexture, filter.m_warpTex}; boo::ITexture* texs[] = {CGraphics::g_SpareTexture, filter.m_warpTex};
return cctx.newShaderDataBinding(TShader<CSpaceWarpFilter>::m_pipeline, return cctx.newShaderDataBinding(pipeline, vtxFmt,
TShader<CSpaceWarpFilter>::m_vtxFmt,
filter.m_vbo, nullptr, nullptr, 1, bufs, filter.m_vbo, nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 2, texs); nullptr, nullptr, nullptr, 2, texs);
} }

View File

@ -0,0 +1,41 @@
#include "CTexturedQuadFilter.hpp"
namespace urde
{
CTexturedQuadFilter::CTexturedQuadFilter(CCameraFilterPass::EFilterType type, const TToken<CTexture>& tex)
: m_tex(tex)
{
m_token = CGraphics::g_BooFactory->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
struct Vert
{
zeus::CVector2f m_pos;
zeus::CVector2f m_uv;
} verts[4] =
{
{{-1.0, -1.0}, {0.0, 0.0}},
{{-1.0, 1.0}, {0.0, 1.0}},
{{ 1.0, -1.0}, {1.0, 0.0}},
{{ 1.0, 1.0}, {1.0, 1.0}},
};
m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts, 32, 4);
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
m_dataBind = TMultiBlendShader<CTexturedQuadFilter>::BuildShaderDataBinding(ctx, type, *this);
return true;
});
}
void CTexturedQuadFilter::draw(const zeus::CColor& color, float uvScale)
{
m_uniform.m_color = color;
m_uniform.m_uvScale = uvScale;
m_uniBuf->load(&m_uniform, sizeof(m_uniform));
CGraphics::g_BooMainCommandQueue->setShaderDataBinding(m_dataBind);
CGraphics::g_BooMainCommandQueue->draw(0, 4);
}
URDE_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilter)
}

View File

@ -0,0 +1,42 @@
#ifndef __URDE_CTEXTUREDQUADFILTER_HPP__
#define __URDE_CTEXTUREDQUADFILTER_HPP__
#include "TMultiBlendShader.hpp"
#include "zeus/CMatrix4f.hpp"
#include "zeus/CColor.hpp"
#include "Camera/CCameraFilter.hpp"
#include "CToken.hpp"
namespace urde
{
class CTexturedQuadFilter
{
friend struct CTexturedQuadFilterGLDataBindingFactory;
friend struct CTexturedQuadFilterVulkanDataBindingFactory;
friend struct CTexturedQuadFilterMetalDataBindingFactory;
friend struct CTexturedQuadFilterD3DDataBindingFactory;
struct Uniform
{
zeus::CColor m_color;
float m_uvScale;
};
TLockedToken<CTexture> m_tex;
boo::GraphicsDataToken m_token;
boo::IGraphicsBufferS* m_vbo;
boo::IGraphicsBufferD* m_uniBuf;
boo::IShaderDataBinding* m_dataBind = nullptr;
Uniform m_uniform;
public:
CTexturedQuadFilter(CCameraFilterPass::EFilterType type, const TToken<CTexture>& tex);
void draw(const zeus::CColor& color, float uvScale);
using _CLS = CTexturedQuadFilter;
#include "TMultiBlendShaderDecl.hpp"
};
}
#endif // __URDE_CTEXTUREDQUADFILTER_HPP__

View File

@ -0,0 +1,135 @@
#include "CTexturedQuadFilter.hpp"
#include "TMultiBlendShader.hpp"
#include "Graphics/CTexture.hpp"
namespace urde
{
static const char* VS =
"#version 330\n"
BOO_GLSL_BINDING_HEAD
"layout(location=0) in vec4 posIn;\n"
"layout(location=1) in vec4 uvIn;\n"
"\n"
"UBINDING0 uniform TexuredQuadUniform\n"
"{\n"
" vec4 color;\n"
"};\n"
"\n"
"struct VertToFrag\n"
"{\n"
" vec4 color;\n"
" vec2 uv;\n"
"};\n"
"\n"
"SBINDING(0) out VertToFrag vtf;\n"
"void main()\n"
"{\n"
" vtf.color = color;\n"
" vtf.uv = uvIn.xy;\n"
" gl_Position = vec4(posIn.xyz, 1.0);\n"
"}\n";
static const char* FS =
"#version 330\n"
BOO_GLSL_BINDING_HEAD
"struct VertToFrag\n"
"{\n"
" vec4 color;\n"
" vec2 uv;\n"
"};\n"
"\n"
"SBINDING(0) in VertToFrag vtf;\n"
"layout(location=0) out vec4 colorOut;\n"
"TBINDING0 uniform sampler2D tex;\n"
"void main()\n"
"{\n"
" colorOut = vtf.color * texture(tex, vtf.uv);\n"
"}\n";
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilter)
struct CTexturedQuadFilterGLDataBindingFactory : TMultiBlendShader<CTexturedQuadFilter>::IDataBindingFactory
{
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline* pipeline,
boo::IVertexFormat*,
CTexturedQuadFilter& filter)
{
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
const boo::VertexElementDescriptor VtxVmt[] =
{
{filter.m_vbo, nullptr, boo::VertexSemantic::Position4},
{filter.m_vbo, nullptr, boo::VertexSemantic::UV4}
};
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
boo::ITexture* texs[] = {filter.m_tex->GetBooTexture()};
return cctx.newShaderDataBinding(pipeline,
ctx.newVertexFormat(2, VtxVmt), filter.m_vbo, nullptr, nullptr,
1, bufs, stages, nullptr, nullptr, 1, texs);
}
};
#if BOO_HAS_VULKAN
struct CTexturedQuadFilterVulkanDataBindingFactory : TMultiBlendShader<CTexturedQuadFilter>::IDataBindingFactory
{
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline* pipeline,
boo::IVertexFormat* vtxFmt,
CTexturedQuadFilter& filter)
{
boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
boo::ITexture* texs[] = {filter.m_tex->GetBooTexture()};
return cctx.newShaderDataBinding(pipeline, vtxFmt,
filter.m_vbo, nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 1, texs);
}
};
#endif
TMultiBlendShader<CTexturedQuadFilter>::IDataBindingFactory*
CTexturedQuadFilter::Initialize(boo::GLDataFactory::Context& ctx,
boo::IShaderPipeline*& alphaPipeOut,
boo::IShaderPipeline*& additivePipeOut,
boo::IShaderPipeline*& colorMultiplyPipeOut)
{
const char* texNames[] = {"tex"};
const char* uniNames[] = {"TexuredQuadUniform"};
alphaPipeOut = ctx.newShaderPipeline(VS, FS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false);
additivePipeOut = ctx.newShaderPipeline(VS, FS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false);
colorMultiplyPipeOut = ctx.newShaderPipeline(VS, FS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcColor,
boo::BlendFactor::DstColor, boo::Primitive::TriStrips, false, false, false);
return new CTexturedQuadFilterGLDataBindingFactory;
}
#if BOO_HAS_VULKAN
TMultiBlendShader<CTexturedQuadFilter>::IDataBindingFactory*
CTexturedQuadFilter::Initialize(boo::VulkanDataFactory::Context& ctx,
boo::IShaderPipeline*& alphaPipeOut,
boo::IShaderPipeline*& additivePipeOut,
boo::IShaderPipeline*& colorMultiplyPipeOut,
boo::IVertexFormat*& vtxFmtOut)
{
const boo::VertexElementDescriptor VtxVmt[] =
{
{nullptr, nullptr, boo::VertexSemantic::Position4},
{nullptr, nullptr, boo::VertexSemantic::UV4}
};
vtxFmtOut = ctx.newVertexFormat(2, VtxVmt);
alphaPipeOut = ctx.newShaderPipeline(VS, FS, vtxFmtOut, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false);
additivePipeOut = ctx.newShaderPipeline(VS, FS, vtxFmtOut, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false);
colorMultiplyPipeOut = ctx.newShaderPipeline(VS, FS, vtxFmtOut, boo::BlendFactor::SrcColor,
boo::BlendFactor::DstColor, boo::Primitive::TriStrips, false, false, false);
return new CTexturedQuadFilterVulkanDataBindingFactory;
}
#endif
}

View File

@ -77,7 +77,10 @@ URDE_DECL_SPECIALIZE_SHADER(CThermalColdFilter)
struct CThermalColdFilterGLDataBindingFactory : TShader<CThermalColdFilter>::IDataBindingFactory struct CThermalColdFilterGLDataBindingFactory : TShader<CThermalColdFilter>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CThermalColdFilter& filter) boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline* pipeline,
boo::IVertexFormat*,
CThermalColdFilter& filter)
{ {
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx); boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
@ -89,7 +92,7 @@ struct CThermalColdFilterGLDataBindingFactory : TShader<CThermalColdFilter>::IDa
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex}; boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
boo::ITexture* texs[] = {CGraphics::g_SpareTexture, filter.m_shiftTex}; boo::ITexture* texs[] = {CGraphics::g_SpareTexture, filter.m_shiftTex};
return cctx.newShaderDataBinding(TShader<CThermalColdFilter>::m_pipeline, return cctx.newShaderDataBinding(pipeline,
ctx.newVertexFormat(2, VtxVmt), filter.m_vbo, nullptr, nullptr, ctx.newVertexFormat(2, VtxVmt), filter.m_vbo, nullptr, nullptr,
1, bufs, stages, nullptr, nullptr, 2, texs); 1, bufs, stages, nullptr, nullptr, 2, texs);
} }
@ -98,14 +101,16 @@ struct CThermalColdFilterGLDataBindingFactory : TShader<CThermalColdFilter>::IDa
#if BOO_HAS_VULKAN #if BOO_HAS_VULKAN
struct CThermalColdFilterVulkanDataBindingFactory : TShader<CThermalColdFilter>::IDataBindingFactory struct CThermalColdFilterVulkanDataBindingFactory : TShader<CThermalColdFilter>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CThermalColdFilter& filter) boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline* pipeline,
boo::IVertexFormat* vtxFmt,
CThermalColdFilter& filter)
{ {
boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx); boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
boo::ITexture* texs[] = {CGraphics::g_SpareTexture, filter.m_shiftTex}; boo::ITexture* texs[] = {CGraphics::g_SpareTexture, filter.m_shiftTex};
return cctx.newShaderDataBinding(TShader<CThermalColdFilter>::m_pipeline, return cctx.newShaderDataBinding(pipeline, vtxFmt,
TShader<CThermalColdFilter>::m_vtxFmt,
filter.m_vbo, nullptr, nullptr, 1, bufs, filter.m_vbo, nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 2, texs); nullptr, nullptr, nullptr, 2, texs);
} }

View File

@ -54,7 +54,10 @@ URDE_DECL_SPECIALIZE_SHADER(CThermalHotFilter)
struct CThermalHotFilterGLDataBindingFactory : TShader<CThermalHotFilter>::IDataBindingFactory struct CThermalHotFilterGLDataBindingFactory : TShader<CThermalHotFilter>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CThermalHotFilter& filter) boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline* pipeline,
boo::IVertexFormat*,
CThermalHotFilter& filter)
{ {
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx); boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
@ -66,7 +69,7 @@ struct CThermalHotFilterGLDataBindingFactory : TShader<CThermalHotFilter>::IData
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex}; boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
boo::ITexture* texs[] = {CGraphics::g_SpareTexture, g_Renderer->GetThermoPalette()}; boo::ITexture* texs[] = {CGraphics::g_SpareTexture, g_Renderer->GetThermoPalette()};
return cctx.newShaderDataBinding(TShader<CThermalHotFilter>::m_pipeline, return cctx.newShaderDataBinding(pipeline,
ctx.newVertexFormat(2, VtxVmt), filter.m_vbo, nullptr, nullptr, ctx.newVertexFormat(2, VtxVmt), filter.m_vbo, nullptr, nullptr,
1, bufs, stages, nullptr, nullptr, 2, texs); 1, bufs, stages, nullptr, nullptr, 2, texs);
} }
@ -75,14 +78,16 @@ struct CThermalHotFilterGLDataBindingFactory : TShader<CThermalHotFilter>::IData
#if BOO_HAS_VULKAN #if BOO_HAS_VULKAN
struct CThermalHotFilterVulkanDataBindingFactory : TShader<CThermalHotFilter>::IDataBindingFactory struct CThermalHotFilterVulkanDataBindingFactory : TShader<CThermalHotFilter>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CThermalHotFilter& filter) boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline* pipeline,
boo::IVertexFormat* vtxFmt,
CThermalHotFilter& filter)
{ {
boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx); boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
boo::ITexture* texs[] = {CGraphics::g_SpareTexture, g_Renderer->GetThermoPalette()}; boo::ITexture* texs[] = {CGraphics::g_SpareTexture, g_Renderer->GetThermoPalette()};
return cctx.newShaderDataBinding(TShader<CThermalHotFilter>::m_pipeline, return cctx.newShaderDataBinding(pipeline, vtxFmt,
TShader<CThermalHotFilter>::m_vtxFmt,
filter.m_vbo, nullptr, nullptr, 1, bufs, filter.m_vbo, nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 2, texs); nullptr, nullptr, nullptr, 2, texs);
} }

View File

@ -0,0 +1,128 @@
#ifndef __URDE_TMULTIBLENDSHADER_HPP__
#define __URDE_TMULTIBLENDSHADER_HPP__
#include "Graphics/CGraphics.hpp"
#include "boo/graphicsdev/GL.hpp"
#include "boo/graphicsdev/D3D.hpp"
#include "boo/graphicsdev/Metal.hpp"
#include "boo/graphicsdev/Vulkan.hpp"
#include "Camera/CCameraFilter.hpp"
namespace urde
{
template <class FilterImp>
class TMultiBlendShader
{
public:
struct IDataBindingFactory
{
virtual boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline* pipeline,
boo::IVertexFormat* vtxFmt,
FilterImp& filter)=0;
};
static boo::IShaderPipeline* m_alphaBlendPipeline;
static boo::IShaderPipeline* m_additiveAlphaPipeline;
static boo::IShaderPipeline* m_colorMultiplyPipeline;
static boo::IVertexFormat* m_vtxFmt; /* No OpenGL */
static std::unique_ptr<IDataBindingFactory> m_bindFactory;
static boo::GraphicsDataToken m_gfxToken;
static void Initialize()
{
if (!CGraphics::g_BooFactory)
return;
m_gfxToken = CGraphics::CommitResources(
[&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
switch (ctx.platform())
{
case boo::IGraphicsDataFactory::Platform::OGL:
m_bindFactory.reset(FilterImp::Initialize(static_cast<boo::GLDataFactory::Context&>(ctx),
m_alphaBlendPipeline, m_additiveAlphaPipeline, m_colorMultiplyPipeline));
break;
#if _WIN32
case boo::IGraphicsDataFactory::Platform::D3D11:
case boo::IGraphicsDataFactory::Platform::D3D12:
m_bindFactory.reset(FilterImp::Initialize(static_cast<boo::ID3DDataFactory::Context&>(ctx),
m_alphaBlendPipeline, m_additiveAlphaPipeline,
m_colorMultiplyPipeline, m_vtxFmt));
break;
#endif
#if BOO_HAS_METAL
case boo::IGraphicsDataFactory::Platform::Metal:
m_bindFactory.reset(FilterImp::Initialize(static_cast<boo::MetalDataFactory::Context&>(ctx),
m_alphaBlendPipeline, m_additiveAlphaPipeline,
m_colorMultiplyPipeline, m_vtxFmt));
break;
#endif
#if BOO_HAS_VULKAN
case boo::IGraphicsDataFactory::Platform::Vulkan:
m_bindFactory.reset(FilterImp::Initialize(static_cast<boo::VulkanDataFactory::Context&>(ctx),
m_alphaBlendPipeline, m_additiveAlphaPipeline,
m_colorMultiplyPipeline, m_vtxFmt));
break;
#endif
default: break;
}
return true;
});
}
static void Shutdown()
{
m_gfxToken.doDestroy();
}
static boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CCameraFilterPass::EFilterType type,
FilterImp& filter)
{
if (type == CCameraFilterPass::EFilterType::AdditiveAlpha)
return m_bindFactory->BuildShaderDataBinding(ctx, m_additiveAlphaPipeline, m_vtxFmt, filter);
else if (type == CCameraFilterPass::EFilterType::ColorMultiply)
return m_bindFactory->BuildShaderDataBinding(ctx, m_colorMultiplyPipeline, m_vtxFmt, filter);
else
return m_bindFactory->BuildShaderDataBinding(ctx, m_alphaBlendPipeline, m_vtxFmt, filter);
}
};
#define URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(cls) \
template <> boo::IShaderPipeline* \
TMultiBlendShader<cls>::m_alphaBlendPipeline; \
template <> boo::IShaderPipeline* \
TMultiBlendShader<cls>::m_additiveAlphaPipeline; \
template <> boo::IShaderPipeline* \
TMultiBlendShader<cls>::m_colorMultiplyPipeline; \
template <> boo::IVertexFormat* \
TMultiBlendShader<cls>::m_vtxFmt; \
\
template <> std::unique_ptr<TMultiBlendShader<cls>::IDataBindingFactory> \
TMultiBlendShader<cls>::m_bindFactory; \
template <> boo::GraphicsDataToken \
TMultiBlendShader<cls>::m_gfxToken; \
#define URDE_SPECIALIZE_MULTI_BLEND_SHADER(cls) \
template <> boo::IShaderPipeline* \
TMultiBlendShader<cls>::m_alphaBlendPipeline = nullptr; \
template <> boo::IShaderPipeline* \
TMultiBlendShader<cls>::m_additiveAlphaPipeline = nullptr; \
template <> boo::IShaderPipeline* \
TMultiBlendShader<cls>::m_colorMultiplyPipeline = nullptr; \
template <> boo::IVertexFormat* \
TMultiBlendShader<cls>::m_vtxFmt = nullptr; \
\
template <> std::unique_ptr<TMultiBlendShader<cls>::IDataBindingFactory> \
TMultiBlendShader<cls>::m_bindFactory = {}; \
template <> boo::GraphicsDataToken \
TMultiBlendShader<cls>::m_gfxToken = {}; \
\
template class TMultiBlendShader<cls>;
}
#endif // __URDE_TMULTIBLENDSHADER_HPP__

View File

@ -0,0 +1,25 @@
static TMultiBlendShader<_CLS>::IDataBindingFactory* Initialize(boo::GLDataFactory::Context& ctx,
boo::IShaderPipeline*& alphaPipeOut,
boo::IShaderPipeline*& additivePipeOut,
boo::IShaderPipeline*& colorMultiplyPipeOut);
#if _WIN32
static TMultiBlendShader<_CLS>::IDataBindingFactory* Initialize(boo::ID3DDataFactory::Context& ctx,
boo::IShaderPipeline*& alphaPipeOut,
boo::IShaderPipeline*& additivePipeOut,
boo::IShaderPipeline*& colorMultiplyPipeOut,
boo::IVertexFormat*& vtxFmtOut);
#endif
#if BOO_HAS_METAL
static TMultiBlendShader<_CLS>::IDataBindingFactory* Initialize(boo::MetalDataFactory::Context& ctx,
boo::IShaderPipeline*& alphaPipeOut,
boo::IShaderPipeline*& additivePipeOut,
boo::IShaderPipeline*& colorMultiplyPipeOut,
boo::IVertexFormat*& vtxFmtOut);
#endif
#if BOO_HAS_VULKAN
static TMultiBlendShader<_CLS>::IDataBindingFactory* Initialize(boo::VulkanDataFactory::Context& ctx,
boo::IShaderPipeline*& alphaPipeOut,
boo::IShaderPipeline*& additivePipeOut,
boo::IShaderPipeline*& colorMultiplyPipeOut,
boo::IVertexFormat*& vtxFmtOut);
#endif

View File

@ -16,7 +16,10 @@ class TShader
public: public:
struct IDataBindingFactory struct IDataBindingFactory
{ {
virtual boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, FilterImp& filter)=0; virtual boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline* pipeline,
boo::IVertexFormat* vtxFmt,
FilterImp& filter)=0;
}; };
static boo::IShaderPipeline* m_pipeline; static boo::IShaderPipeline* m_pipeline;
@ -71,7 +74,7 @@ public:
static boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, FilterImp& filter) static boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, FilterImp& filter)
{ {
return m_bindFactory->BuildShaderDataBinding(ctx, filter); return m_bindFactory->BuildShaderDataBinding(ctx, m_pipeline, m_vtxFmt, filter);
} }
}; };

View File

@ -144,15 +144,21 @@ void CWorldTransManager::Update(float dt)
} }
} }
void CWorldTransManager::DrawEnabled() const void CWorldTransManager::DrawEnabled()
{ {
} }
void CWorldTransManager::DrawDisabled() const void CWorldTransManager::DrawDisabled()
{ {
m_fadeToBlack.draw(zeus::CColor{0.f, 0.f, 0.f, 0.01});
} }
void CWorldTransManager::Draw() const void CWorldTransManager::DrawText()
{
}
void CWorldTransManager::Draw()
{ {
if (x30_type == ETransType::Disabled) if (x30_type == ETransType::Disabled)
DrawDisabled(); DrawDisabled();
@ -291,9 +297,4 @@ void CWorldTransManager::EndTransition()
DisableTransition(); DisableTransition();
} }
void CWorldTransManager::DrawText() const
{
}
} }

View File

@ -6,6 +6,7 @@
#include "Character/CModelData.hpp" #include "Character/CModelData.hpp"
#include "GuiSys/CGuiTextSupport.hpp" #include "GuiSys/CGuiTextSupport.hpp"
#include "Graphics/CLight.hpp" #include "Graphics/CLight.hpp"
#include "Graphics/Shaders/CColoredQuadFilter.hpp"
namespace urde namespace urde
{ {
@ -77,6 +78,8 @@ private:
u8 dummy = 0; u8 dummy = 0;
}; };
CColoredQuadFilter m_fadeToBlack = { CCameraFilterPass::EFilterType::AlphaBlended };
static int GetSuitCharSet(); static int GetSuitCharSet();
public: public:
@ -90,10 +93,10 @@ public:
void UpdateDisabled(float); void UpdateDisabled(float);
void UpdateText(float); void UpdateText(float);
void Update(float); void Update(float);
void DrawEnabled() const; void DrawEnabled();
void DrawDisabled() const; void DrawDisabled();
void DrawText() const; void DrawText();
void Draw() const; void Draw();
void EnableTransition(const CAnimRes& samusRes, void EnableTransition(const CAnimRes& samusRes,
ResId platRes, const zeus::CVector3f& platScale, ResId platRes, const zeus::CVector3f& platScale,