mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-09 21:07:42 +00:00
Camera filter refactor
This commit is contained in:
@@ -948,18 +948,19 @@ void CBooRenderer::SetPerspective(float fovy, float aspect, float znear, float z
|
||||
CGraphics::SetPerspective(fovy, aspect, znear, zfar);
|
||||
}
|
||||
|
||||
zeus::CRectangle CBooRenderer::SetViewportOrtho(bool centered, float znear, float zfar)
|
||||
std::pair<zeus::CVector2f, zeus::CVector2f>
|
||||
CBooRenderer::SetViewportOrtho(bool centered, float znear, float zfar)
|
||||
{
|
||||
float left = centered ? g_Viewport.x10_halfWidth : 0;
|
||||
float bottom = centered ? g_Viewport.x14_halfHeight : 0;
|
||||
float top = centered ? g_Viewport.x14_halfHeight : g_Viewport.xc_height;
|
||||
float right = centered ? g_Viewport.x10_halfWidth : g_Viewport.x8_width;
|
||||
float left = centered ? g_Viewport.x0_left - g_Viewport.x10_halfWidth : 0.f;
|
||||
float bottom = centered ? g_Viewport.x4_top - g_Viewport.x14_halfHeight : 0.f;
|
||||
float top = centered ? g_Viewport.x0_left + g_Viewport.x14_halfHeight : g_Viewport.xc_height;
|
||||
float right = centered ? g_Viewport.x4_top + g_Viewport.x10_halfWidth : g_Viewport.x8_width;
|
||||
|
||||
CGraphics::SetOrtho(left, right, top, bottom, znear, zfar);
|
||||
CGraphics::SetViewPointMatrix(zeus::CTransform::Identity());
|
||||
CGraphics::SetModelMatrix(zeus::CTransform::Identity());
|
||||
|
||||
return zeus::CRectangle(left, bottom, right, top);
|
||||
return {{left, bottom}, {right, top}};
|
||||
}
|
||||
|
||||
void CBooRenderer::SetClippingPlanes(const zeus::CFrustum& frustum)
|
||||
|
||||
@@ -216,7 +216,7 @@ public:
|
||||
void SetWorldViewpoint(const zeus::CTransform&);
|
||||
void SetPerspective(float, float, float, float, float);
|
||||
void SetPerspective(float, float, float, float);
|
||||
zeus::CRectangle SetViewportOrtho(bool, float, float);
|
||||
std::pair<zeus::CVector2f, zeus::CVector2f> SetViewportOrtho(bool, float, float);
|
||||
void SetClippingPlanes(const zeus::CFrustum& frustum);
|
||||
void SetViewport(int, int, int, int);
|
||||
//void SetDepthReadWrite(bool, bool);
|
||||
|
||||
@@ -15,7 +15,9 @@ if(WIN32)
|
||||
Shaders/CEnergyBarShaderHLSL.cpp
|
||||
Shaders/CRadarPaintShaderHLSL.cpp
|
||||
Shaders/CMapSurfaceShaderHLSL.cpp
|
||||
Shaders/CPhazonSuitFilterHLSL.cpp)
|
||||
Shaders/CPhazonSuitFilterHLSL.cpp
|
||||
Shaders/CScanLinesFilterHLSL.cpp
|
||||
Shaders/CRandomStaticFilterHLSL.cpp)
|
||||
elseif(BOO_HAS_METAL)
|
||||
set(PLAT_SRCS
|
||||
Shaders/CLineRendererShadersMetal.cpp
|
||||
@@ -33,7 +35,9 @@ elseif(BOO_HAS_METAL)
|
||||
Shaders/CEnergyBarShaderMetal.cpp
|
||||
Shaders/CRadarPaintShaderMetal.cpp
|
||||
Shaders/CMapSurfaceShaderMetal.cpp
|
||||
Shaders/CPhazonSuitFilterMetal.cpp)
|
||||
Shaders/CPhazonSuitFilterMetal.cpp
|
||||
Shaders/CScanLinesFilterMetal.cpp
|
||||
Shaders/CRandomStaticFilterMetal.cpp)
|
||||
endif()
|
||||
|
||||
set(GRAPHICS_SOURCES
|
||||
@@ -73,6 +77,8 @@ set(GRAPHICS_SOURCES
|
||||
Shaders/CRadarPaintShader.hpp Shaders/CRadarPaintShader.cpp Shaders/CRadarPaintShaderGLSL.cpp
|
||||
Shaders/CMapSurfaceShader.hpp Shaders/CMapSurfaceShader.cpp Shaders/CMapSurfaceShaderGLSL.cpp
|
||||
Shaders/CPhazonSuitFilter.hpp Shaders/CPhazonSuitFilter.cpp Shaders/CPhazonSuitFilterGLSL.cpp
|
||||
Shaders/CScanLinesFilter.hpp Shaders/CScanLinesFilter.cpp Shaders/CScanLinesFilterGLSL.cpp
|
||||
Shaders/CRandomStaticFilter.hpp Shaders/CRandomStaticFilter.cpp Shaders/CRandomStaticFilterGLSL.cpp
|
||||
${PLAT_SRCS})
|
||||
|
||||
runtime_add_list(Graphics GRAPHICS_SOURCES)
|
||||
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
virtual void SetWorldViewpoint(const zeus::CTransform&)=0;
|
||||
virtual void SetPerspective(float, float, float, float, float)=0;
|
||||
virtual void SetPerspective(float, float, float, float)=0;
|
||||
virtual zeus::CRectangle SetViewportOrtho(bool, float, float)=0;
|
||||
virtual std::pair<zeus::CVector2f, zeus::CVector2f> SetViewportOrtho(bool, float, float)=0;
|
||||
virtual void SetClippingPlanes(const zeus::CFrustum&)=0;
|
||||
virtual void SetViewport(int, int, int, int)=0;
|
||||
//virtual void SetDepthReadWrite(bool, bool)=0;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace urde
|
||||
{
|
||||
|
||||
CColoredQuadFilter::CColoredQuadFilter(CCameraFilterPass::EFilterType type)
|
||||
CColoredQuadFilter::CColoredQuadFilter(EFilterType type)
|
||||
{
|
||||
m_token = CGraphics::g_BooFactory->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
|
||||
{
|
||||
@@ -37,6 +37,11 @@ void CColoredQuadFilter::draw(const zeus::CColor& color, const zeus::CRectangle&
|
||||
CGraphics::g_BooMainCommandQueue->draw(0, 4);
|
||||
}
|
||||
|
||||
void CColoredQuadFilter::DrawFilter(EFilterShape shape, const zeus::CColor& color, float t)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CWideScreenFilter::draw(const zeus::CColor& color, float t)
|
||||
{
|
||||
float aspect = g_Viewport.x8_width / float(g_Viewport.xc_height);
|
||||
@@ -51,6 +56,11 @@ void CWideScreenFilter::draw(const zeus::CColor& color, float t)
|
||||
m_top.draw(color, rect);
|
||||
}
|
||||
}
|
||||
|
||||
void CWideScreenFilter::DrawFilter(EFilterShape shape, const zeus::CColor& color, float t)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
float CWideScreenFilter::SetViewportToMatch(float t)
|
||||
{
|
||||
|
||||
@@ -30,8 +30,11 @@ class CColoredQuadFilter
|
||||
|
||||
public:
|
||||
static const zeus::CRectangle DefaultRect;
|
||||
CColoredQuadFilter(CCameraFilterPass::EFilterType type);
|
||||
CColoredQuadFilter(EFilterType type);
|
||||
CColoredQuadFilter(EFilterType type, const TLockedToken<CTexture>&)
|
||||
: CColoredQuadFilter(type) {}
|
||||
void draw(const zeus::CColor& color, const zeus::CRectangle& rect=DefaultRect);
|
||||
void DrawFilter(EFilterShape shape, const zeus::CColor& color, float t);
|
||||
|
||||
using _CLS = CColoredQuadFilter;
|
||||
#include "TMultiBlendShaderDecl.hpp"
|
||||
@@ -42,9 +45,13 @@ class CWideScreenFilter
|
||||
CColoredQuadFilter m_top;
|
||||
CColoredQuadFilter m_bottom;
|
||||
public:
|
||||
CWideScreenFilter(CCameraFilterPass::EFilterType type)
|
||||
CWideScreenFilter(EFilterType type)
|
||||
: m_top(type), m_bottom(type) {}
|
||||
CWideScreenFilter(EFilterType type, const TLockedToken<CTexture>&)
|
||||
: CWideScreenFilter(type) {}
|
||||
void draw(const zeus::CColor& color, float t);
|
||||
void DrawFilter(EFilterShape shape, const zeus::CColor& color, float t);
|
||||
|
||||
static float SetViewportToMatch(float t);
|
||||
static void SetViewportToFull();
|
||||
};
|
||||
|
||||
@@ -50,15 +50,15 @@ static boo::IShaderPipeline* s_AlphaPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_AddPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_MultPipeline = nullptr;
|
||||
|
||||
static boo::IShaderPipeline* SelectPipeline(CCameraFilterPass::EFilterType type)
|
||||
static boo::IShaderPipeline* SelectPipeline(EFilterType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case CCameraFilterPass::EFilterType::Blend:
|
||||
case EFilterType::Blend:
|
||||
return s_AlphaPipeline;
|
||||
case CCameraFilterPass::EFilterType::Add:
|
||||
case EFilterType::Add:
|
||||
return s_AddPipeline;
|
||||
case CCameraFilterPass::EFilterType::Multiply:
|
||||
case EFilterType::Multiply:
|
||||
return s_MultPipeline;
|
||||
default:
|
||||
return nullptr;
|
||||
@@ -68,7 +68,7 @@ static boo::IShaderPipeline* SelectPipeline(CCameraFilterPass::EFilterType type)
|
||||
struct CColoredQuadFilterGLDataBindingFactory : TMultiBlendShader<CColoredQuadFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CCameraFilterPass::EFilterType type,
|
||||
EFilterType type,
|
||||
CColoredQuadFilter& filter)
|
||||
{
|
||||
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
|
||||
@@ -89,7 +89,7 @@ struct CColoredQuadFilterGLDataBindingFactory : TMultiBlendShader<CColoredQuadFi
|
||||
struct CColoredQuadFilterVulkanDataBindingFactory : TMultiBlendShader<CColoredQuadFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CCameraFilterPass::EFilterType type,
|
||||
EFilterType type,
|
||||
CColoredQuadFilter& filter)
|
||||
{
|
||||
boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx);
|
||||
|
||||
@@ -50,15 +50,15 @@ static boo::IShaderPipeline* s_AlphaPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_AddPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_MultPipeline = nullptr;
|
||||
|
||||
static boo::IShaderPipeline* SelectPipeline(CCameraFilterPass::EFilterType type)
|
||||
static boo::IShaderPipeline* SelectPipeline(EFilterType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case CCameraFilterPass::EFilterType::Blend:
|
||||
case EFilterType::Blend:
|
||||
return s_AlphaPipeline;
|
||||
case CCameraFilterPass::EFilterType::Add:
|
||||
case EFilterType::Add:
|
||||
return s_AddPipeline;
|
||||
case CCameraFilterPass::EFilterType::Multiply:
|
||||
case EFilterType::Multiply:
|
||||
return s_MultPipeline;
|
||||
default:
|
||||
return nullptr;
|
||||
@@ -68,7 +68,7 @@ static boo::IShaderPipeline* SelectPipeline(CCameraFilterPass::EFilterType type)
|
||||
struct CColoredQuadFilterD3DDataBindingFactory : TMultiBlendShader<CColoredQuadFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CCameraFilterPass::EFilterType type,
|
||||
EFilterType type,
|
||||
CColoredQuadFilter& filter)
|
||||
{
|
||||
boo::ID3DDataFactory::Context& cctx = static_cast<boo::ID3DDataFactory::Context&>(ctx);
|
||||
|
||||
@@ -54,15 +54,15 @@ static boo::IShaderPipeline* s_AlphaPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_AddPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_MultPipeline = nullptr;
|
||||
|
||||
static boo::IShaderPipeline* SelectPipeline(CCameraFilterPass::EFilterType type)
|
||||
static boo::IShaderPipeline* SelectPipeline(EFilterType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case CCameraFilterPass::EFilterType::Blend:
|
||||
case EFilterType::Blend:
|
||||
return s_AlphaPipeline;
|
||||
case CCameraFilterPass::EFilterType::Add:
|
||||
case EFilterType::Add:
|
||||
return s_AddPipeline;
|
||||
case CCameraFilterPass::EFilterType::Multiply:
|
||||
case EFilterType::Multiply:
|
||||
return s_MultPipeline;
|
||||
default:
|
||||
return nullptr;
|
||||
@@ -72,7 +72,7 @@ static boo::IShaderPipeline* SelectPipeline(CCameraFilterPass::EFilterType type)
|
||||
struct CColoredQuadFilterMetalDataBindingFactory : TMultiBlendShader<CColoredQuadFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CCameraFilterPass::EFilterType type,
|
||||
EFilterType type,
|
||||
CColoredQuadFilter& filter)
|
||||
{
|
||||
boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx);
|
||||
|
||||
39
Runtime/Graphics/Shaders/CRandomStaticFilter.cpp
Normal file
39
Runtime/Graphics/Shaders/CRandomStaticFilter.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#include "CRandomStaticFilter.hpp"
|
||||
#include "Graphics/CBooRenderer.hpp"
|
||||
#include "GameGlobalObjects.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
CRandomStaticFilter::CRandomStaticFilter(EFilterType type, bool cookieCutter)
|
||||
: m_cookieCutter(cookieCutter)
|
||||
{
|
||||
m_token = CGraphics::g_BooFactory->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
|
||||
{
|
||||
struct Vert
|
||||
{
|
||||
zeus::CVector2f m_pos;
|
||||
} verts[4] =
|
||||
{
|
||||
{{0.0, 0.0}},
|
||||
{{0.0, 1.0}},
|
||||
{{1.0, 0.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<CRandomStaticFilter>::BuildShaderDataBinding(ctx, type, *this);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
void CRandomStaticFilter::draw(const zeus::CColor& color, float t)
|
||||
{
|
||||
std::pair<zeus::CVector2f, zeus::CVector2f> rect = g_Renderer->SetViewportOrtho(true, 0.f, 1.f);
|
||||
}
|
||||
|
||||
void CRandomStaticFilter::Shutdown() {}
|
||||
|
||||
URDE_SPECIALIZE_MULTI_BLEND_SHADER(CRandomStaticFilter)
|
||||
|
||||
}
|
||||
54
Runtime/Graphics/Shaders/CRandomStaticFilter.hpp
Normal file
54
Runtime/Graphics/Shaders/CRandomStaticFilter.hpp
Normal file
@@ -0,0 +1,54 @@
|
||||
#ifndef __URDE_CRANDOMSTATICFILTER_HPP__
|
||||
#define __URDE_CRANDOMSTATICFILTER_HPP__
|
||||
|
||||
#include "TMultiBlendShader.hpp"
|
||||
#include "zeus/CMatrix4f.hpp"
|
||||
#include "zeus/CColor.hpp"
|
||||
#include "zeus/CRectangle.hpp"
|
||||
#include "Camera/CCameraFilter.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
class CRandomStaticFilter
|
||||
{
|
||||
friend struct CRandomStaticFilterGLDataBindingFactory;
|
||||
friend struct CRandomStaticFilterVulkanDataBindingFactory;
|
||||
friend struct CRandomStaticFilterMetalDataBindingFactory;
|
||||
friend struct CRandomStaticFilterD3DDataBindingFactory;
|
||||
|
||||
struct Uniform
|
||||
{
|
||||
zeus::CMatrix4f m_matrix;
|
||||
zeus::CColor m_color;
|
||||
};
|
||||
boo::GraphicsDataToken m_token;
|
||||
boo::IGraphicsBufferS* m_vbo;
|
||||
boo::IGraphicsBufferD* m_uniBuf;
|
||||
boo::IShaderDataBinding* m_dataBind = nullptr;
|
||||
Uniform m_uniform;
|
||||
bool m_cookieCutter;
|
||||
|
||||
public:
|
||||
CRandomStaticFilter(EFilterType type, bool cookieCutter=false);
|
||||
CRandomStaticFilter(EFilterType type, const TLockedToken<CTexture>&)
|
||||
: CRandomStaticFilter(type) {}
|
||||
void draw(const zeus::CColor& color, float t);
|
||||
void DrawFilter(EFilterShape, const zeus::CColor& color, float t) { draw(color, t); }
|
||||
|
||||
using _CLS = CRandomStaticFilter;
|
||||
#include "TMultiBlendShaderDecl.hpp"
|
||||
};
|
||||
|
||||
class CCookieCutterDepthRandomStaticFilter : public CRandomStaticFilter
|
||||
{
|
||||
public:
|
||||
CCookieCutterDepthRandomStaticFilter(EFilterType type) :
|
||||
CRandomStaticFilter(type, true) {}
|
||||
CCookieCutterDepthRandomStaticFilter(EFilterType type, const TLockedToken<CTexture>&)
|
||||
: CCookieCutterDepthRandomStaticFilter(type) {}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __URDE_CRANDOMSTATICFILTER_HPP__
|
||||
143
Runtime/Graphics/Shaders/CRandomStaticFilterGLSL.cpp
Normal file
143
Runtime/Graphics/Shaders/CRandomStaticFilterGLSL.cpp
Normal file
@@ -0,0 +1,143 @@
|
||||
#include "CRandomStaticFilter.hpp"
|
||||
#include "TMultiBlendShader.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"
|
||||
" mat4 xf;\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 = xf * 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(CRandomStaticFilter)
|
||||
|
||||
static boo::IVertexFormat* s_VtxFmt = nullptr;
|
||||
static boo::IShaderPipeline* s_AlphaPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_AddPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_MultPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_CookieCutterPipeline = nullptr;
|
||||
|
||||
static boo::IShaderPipeline* SelectPipeline(EFilterType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case EFilterType::Blend:
|
||||
return s_AlphaPipeline;
|
||||
case EFilterType::Add:
|
||||
return s_AddPipeline;
|
||||
case EFilterType::Multiply:
|
||||
return s_MultPipeline;
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
struct CRandomStaticFilterGLDataBindingFactory : TMultiBlendShader<CRandomStaticFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
EFilterType type,
|
||||
CRandomStaticFilter& 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(filter.m_cookieCutter ? s_CookieCutterPipeline : SelectPipeline(type),
|
||||
ctx.newVertexFormat(1, VtxVmt), filter.m_vbo, nullptr, nullptr,
|
||||
1, bufs, stages, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
#if BOO_HAS_VULKAN
|
||||
struct CRandomStaticFilterVulkanDataBindingFactory : TMultiBlendShader<CScanLinesFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
EFilterType type,
|
||||
CRandomStaticFilter& filter)
|
||||
{
|
||||
boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx);
|
||||
|
||||
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
|
||||
return cctx.newShaderDataBinding(filter.m_cookieCutter ? s_CookieCutterPipeline : SelectPipeline(type),
|
||||
s_VtxFmt, filter.m_vbo, nullptr, nullptr, 1, bufs,
|
||||
nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
TMultiBlendShader<CRandomStaticFilter>::IDataBindingFactory*
|
||||
CRandomStaticFilter::Initialize(boo::GLDataFactory::Context& ctx)
|
||||
{
|
||||
const char* uniNames[] = {"ColoredQuadUniform"};
|
||||
s_AlphaPipeline = ctx.newShaderPipeline(VS, FS, 0, nullptr, 1, uniNames, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
s_AddPipeline = ctx.newShaderPipeline(VS, FS, 0, nullptr, 1, uniNames, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::One, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
s_MultPipeline = ctx.newShaderPipeline(VS, FS, 0, nullptr, 1, uniNames, boo::BlendFactor::SrcColor,
|
||||
boo::BlendFactor::DstColor, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
return new CRandomStaticFilterGLDataBindingFactory;
|
||||
}
|
||||
|
||||
#if BOO_HAS_VULKAN
|
||||
TMultiBlendShader<CRandomStaticFilter>::IDataBindingFactory*
|
||||
CRandomStaticFilter::Initialize(boo::VulkanDataFactory::Context& ctx)
|
||||
{
|
||||
const boo::VertexElementDescriptor VtxVmt[] =
|
||||
{
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4}
|
||||
};
|
||||
s_VtxFmt = ctx.newVertexFormat(1, VtxVmt);
|
||||
s_AlphaPipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
s_AddPipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::One, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
s_MultPipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, boo::BlendFactor::SrcColor,
|
||||
boo::BlendFactor::DstColor, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
return new CRandomStaticFilterVulkanDataBindingFactory;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
107
Runtime/Graphics/Shaders/CRandomStaticFilterMetal.cpp
Normal file
107
Runtime/Graphics/Shaders/CRandomStaticFilterMetal.cpp
Normal file
@@ -0,0 +1,107 @@
|
||||
#include "CRandomStaticFilter.hpp"
|
||||
#include "TMultiBlendShader.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
static const char* VS =
|
||||
"#include <metal_stdlib>\n"
|
||||
"using namespace metal;\n"
|
||||
"struct VertData\n"
|
||||
"{\n"
|
||||
" float4 posIn [[ attribute(0) ]];\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct ColoredQuadUniform\n"
|
||||
"{\n"
|
||||
" float4x4 xf;\n"
|
||||
" float4 color;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position [[ position ]];\n"
|
||||
" float4 color;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"vertex VertToFrag vmain(VertData v [[ stage_in ]], constant ColoredQuadUniform& cqu [[ buffer(2) ]])\n"
|
||||
"{\n"
|
||||
" VertToFrag vtf;\n"
|
||||
" vtf.color = cqu.color;\n"
|
||||
" vtf.position = cqu.xf * float4(v.posIn.xyz, 1.0);\n"
|
||||
" return vtf;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS =
|
||||
"#include <metal_stdlib>\n"
|
||||
"using namespace metal;\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position [[ position ]];\n"
|
||||
" float4 color;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]])\n"
|
||||
"{\n"
|
||||
" return vtf.color;\n"
|
||||
"}\n";
|
||||
|
||||
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CRandomStaticFilter)
|
||||
|
||||
static boo::IVertexFormat* s_VtxFmt = nullptr;
|
||||
static boo::IShaderPipeline* s_AlphaPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_AddPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_MultPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_CookieCutterPipeline = nullptr;
|
||||
|
||||
static boo::IShaderPipeline* SelectPipeline(EFilterType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case EFilterType::Blend:
|
||||
return s_AlphaPipeline;
|
||||
case EFilterType::Add:
|
||||
return s_AddPipeline;
|
||||
case EFilterType::Multiply:
|
||||
return s_MultPipeline;
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
struct CRandomStaticFilterMetalDataBindingFactory : TMultiBlendShader<CRandomStaticFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
EFilterType type,
|
||||
CRandomStaticFilter& filter)
|
||||
{
|
||||
boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx);
|
||||
|
||||
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
|
||||
return cctx.newShaderDataBinding(filter.m_cookieCutter ? s_CookieCutterPipeline : SelectPipeline(type),
|
||||
s_VtxFmt, filter.m_vbo, nullptr, nullptr, 1, bufs,
|
||||
nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
TMultiBlendShader<CRandomStaticFilter>::IDataBindingFactory*
|
||||
CRandomStaticFilter::Initialize(boo::MetalDataFactory::Context& ctx)
|
||||
{
|
||||
const boo::VertexElementDescriptor VtxVmt[] =
|
||||
{
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4}
|
||||
};
|
||||
s_VtxFmt = ctx.newVertexFormat(1, VtxVmt);
|
||||
s_AlphaPipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, true, boo::CullMode::None);
|
||||
s_AddPipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::One, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, true, boo::CullMode::None);
|
||||
s_MultPipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcColor,
|
||||
boo::BlendFactor::DstColor, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, true, boo::CullMode::None);
|
||||
return new CRandomStaticFilterMetalDataBindingFactory;
|
||||
}
|
||||
|
||||
}
|
||||
36
Runtime/Graphics/Shaders/CScanLinesFilter.cpp
Normal file
36
Runtime/Graphics/Shaders/CScanLinesFilter.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#include "CScanLinesFilter.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
CScanLinesFilter::CScanLinesFilter(EFilterType type)
|
||||
{
|
||||
m_token = CGraphics::g_BooFactory->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
|
||||
{
|
||||
struct Vert
|
||||
{
|
||||
zeus::CVector2f m_pos;
|
||||
} verts[4] =
|
||||
{
|
||||
{{0.0, 0.0}},
|
||||
{{0.0, 1.0}},
|
||||
{{1.0, 0.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<CScanLinesFilter>::BuildShaderDataBinding(ctx, type, *this);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
void CScanLinesFilter::DrawFilter(EFilterShape shape, const zeus::CColor& color, float t)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CScanLinesFilter::Shutdown() {}
|
||||
|
||||
URDE_SPECIALIZE_MULTI_BLEND_SHADER(CScanLinesFilter)
|
||||
|
||||
}
|
||||
43
Runtime/Graphics/Shaders/CScanLinesFilter.hpp
Normal file
43
Runtime/Graphics/Shaders/CScanLinesFilter.hpp
Normal file
@@ -0,0 +1,43 @@
|
||||
#ifndef __URDE_CSCANLINESFILTER_HPP__
|
||||
#define __URDE_CSCANLINESFILTER_HPP__
|
||||
|
||||
#include "TMultiBlendShader.hpp"
|
||||
#include "zeus/CMatrix4f.hpp"
|
||||
#include "zeus/CColor.hpp"
|
||||
#include "zeus/CRectangle.hpp"
|
||||
#include "Camera/CCameraFilter.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
class CScanLinesFilter
|
||||
{
|
||||
friend struct CScanLinesFilterGLDataBindingFactory;
|
||||
friend struct CScanLinesFilterVulkanDataBindingFactory;
|
||||
friend struct CScanLinesFilterMetalDataBindingFactory;
|
||||
friend struct CScanLinesFilterD3DDataBindingFactory;
|
||||
|
||||
struct Uniform
|
||||
{
|
||||
zeus::CMatrix4f m_matrix;
|
||||
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:
|
||||
CScanLinesFilter(EFilterType type);
|
||||
CScanLinesFilter(EFilterType type, const TLockedToken<CTexture>&)
|
||||
: CScanLinesFilter(type) {}
|
||||
void DrawFilter(EFilterShape shape, const zeus::CColor& color, float t);
|
||||
|
||||
using _CLS = CScanLinesFilter;
|
||||
#include "TMultiBlendShaderDecl.hpp"
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __URDE_CSCANLINESFILTER_HPP__
|
||||
142
Runtime/Graphics/Shaders/CScanLinesFilterGLSL.cpp
Normal file
142
Runtime/Graphics/Shaders/CScanLinesFilterGLSL.cpp
Normal file
@@ -0,0 +1,142 @@
|
||||
#include "CScanLinesFilter.hpp"
|
||||
#include "TMultiBlendShader.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"
|
||||
" mat4 xf;\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 = xf * 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(CScanLinesFilter)
|
||||
|
||||
static boo::IVertexFormat* s_VtxFmt = nullptr;
|
||||
static boo::IShaderPipeline* s_AlphaPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_AddPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_MultPipeline = nullptr;
|
||||
|
||||
static boo::IShaderPipeline* SelectPipeline(EFilterType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case EFilterType::Blend:
|
||||
return s_AlphaPipeline;
|
||||
case EFilterType::Add:
|
||||
return s_AddPipeline;
|
||||
case EFilterType::Multiply:
|
||||
return s_MultPipeline;
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
struct CScanLinesFilterGLDataBindingFactory : TMultiBlendShader<CScanLinesFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
EFilterType type,
|
||||
CScanLinesFilter& 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(SelectPipeline(type),
|
||||
ctx.newVertexFormat(1, VtxVmt), filter.m_vbo, nullptr, nullptr,
|
||||
1, bufs, stages, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
#if BOO_HAS_VULKAN
|
||||
struct CScanLinesFilterVulkanDataBindingFactory : TMultiBlendShader<CScanLinesFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
EFilterType type,
|
||||
CScanLinesFilter& filter)
|
||||
{
|
||||
boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx);
|
||||
|
||||
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
|
||||
return cctx.newShaderDataBinding(SelectPipeline(type), s_VtxFmt,
|
||||
filter.m_vbo, nullptr, nullptr, 1, bufs,
|
||||
nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
TMultiBlendShader<CScanLinesFilter>::IDataBindingFactory*
|
||||
CScanLinesFilter::Initialize(boo::GLDataFactory::Context& ctx)
|
||||
{
|
||||
const char* uniNames[] = {"ColoredQuadUniform"};
|
||||
s_AlphaPipeline = ctx.newShaderPipeline(VS, FS, 0, nullptr, 1, uniNames, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
s_AddPipeline = ctx.newShaderPipeline(VS, FS, 0, nullptr, 1, uniNames, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::One, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
s_MultPipeline = ctx.newShaderPipeline(VS, FS, 0, nullptr, 1, uniNames, boo::BlendFactor::SrcColor,
|
||||
boo::BlendFactor::DstColor, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
return new CScanLinesFilterGLDataBindingFactory;
|
||||
}
|
||||
|
||||
#if BOO_HAS_VULKAN
|
||||
TMultiBlendShader<CScanLinesFilter>::IDataBindingFactory*
|
||||
CScanLinesFilter::Initialize(boo::VulkanDataFactory::Context& ctx)
|
||||
{
|
||||
const boo::VertexElementDescriptor VtxVmt[] =
|
||||
{
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4}
|
||||
};
|
||||
s_VtxFmt = ctx.newVertexFormat(1, VtxVmt);
|
||||
s_AlphaPipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
s_AddPipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::One, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
s_MultPipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, boo::BlendFactor::SrcColor,
|
||||
boo::BlendFactor::DstColor, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
return new CScanLinesFilterVulkanDataBindingFactory;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
0
Runtime/Graphics/Shaders/CScanLinesFilterHLSL.cpp
Normal file
0
Runtime/Graphics/Shaders/CScanLinesFilterHLSL.cpp
Normal file
106
Runtime/Graphics/Shaders/CScanLinesFilterMetal.cpp
Normal file
106
Runtime/Graphics/Shaders/CScanLinesFilterMetal.cpp
Normal file
@@ -0,0 +1,106 @@
|
||||
#include "CScanLinesFilter.hpp"
|
||||
#include "TMultiBlendShader.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
static const char* VS =
|
||||
"#include <metal_stdlib>\n"
|
||||
"using namespace metal;\n"
|
||||
"struct VertData\n"
|
||||
"{\n"
|
||||
" float4 posIn [[ attribute(0) ]];\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct ColoredQuadUniform\n"
|
||||
"{\n"
|
||||
" float4x4 xf;\n"
|
||||
" float4 color;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position [[ position ]];\n"
|
||||
" float4 color;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"vertex VertToFrag vmain(VertData v [[ stage_in ]], constant ColoredQuadUniform& cqu [[ buffer(2) ]])\n"
|
||||
"{\n"
|
||||
" VertToFrag vtf;\n"
|
||||
" vtf.color = cqu.color;\n"
|
||||
" vtf.position = cqu.xf * float4(v.posIn.xyz, 1.0);\n"
|
||||
" return vtf;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS =
|
||||
"#include <metal_stdlib>\n"
|
||||
"using namespace metal;\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position [[ position ]];\n"
|
||||
" float4 color;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]])\n"
|
||||
"{\n"
|
||||
" return vtf.color;\n"
|
||||
"}\n";
|
||||
|
||||
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CScanLinesFilter)
|
||||
|
||||
static boo::IVertexFormat* s_VtxFmt = nullptr;
|
||||
static boo::IShaderPipeline* s_AlphaPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_AddPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_MultPipeline = nullptr;
|
||||
|
||||
static boo::IShaderPipeline* SelectPipeline(EFilterType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case EFilterType::Blend:
|
||||
return s_AlphaPipeline;
|
||||
case EFilterType::Add:
|
||||
return s_AddPipeline;
|
||||
case EFilterType::Multiply:
|
||||
return s_MultPipeline;
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
struct CScanLinesFilterMetalDataBindingFactory : TMultiBlendShader<CScanLinesFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
EFilterType type,
|
||||
CScanLinesFilter& filter)
|
||||
{
|
||||
boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx);
|
||||
|
||||
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
|
||||
return cctx.newShaderDataBinding(SelectPipeline(type), s_VtxFmt,
|
||||
filter.m_vbo, nullptr, nullptr, 1, bufs,
|
||||
nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
TMultiBlendShader<CScanLinesFilter>::IDataBindingFactory*
|
||||
CScanLinesFilter::Initialize(boo::MetalDataFactory::Context& ctx)
|
||||
{
|
||||
const boo::VertexElementDescriptor VtxVmt[] =
|
||||
{
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4}
|
||||
};
|
||||
s_VtxFmt = ctx.newVertexFormat(1, VtxVmt);
|
||||
s_AlphaPipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, true, boo::CullMode::None);
|
||||
s_AddPipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::One, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, true, boo::CullMode::None);
|
||||
s_MultPipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcColor,
|
||||
boo::BlendFactor::DstColor, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, true, boo::CullMode::None);
|
||||
return new CScanLinesFilterMetalDataBindingFactory;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,7 +9,7 @@ CTexturedQuadFilter::CTexturedQuadFilter(boo::ITexture* tex)
|
||||
{
|
||||
}
|
||||
|
||||
CTexturedQuadFilter::CTexturedQuadFilter(CCameraFilterPass::EFilterType type, boo::ITexture* tex)
|
||||
CTexturedQuadFilter::CTexturedQuadFilter(EFilterType type, boo::ITexture* tex)
|
||||
: m_booTex(tex)
|
||||
{
|
||||
m_token = CGraphics::g_BooFactory->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
|
||||
@@ -21,7 +21,7 @@ CTexturedQuadFilter::CTexturedQuadFilter(CCameraFilterPass::EFilterType type, bo
|
||||
});
|
||||
}
|
||||
|
||||
CTexturedQuadFilter::CTexturedQuadFilter(CCameraFilterPass::EFilterType type,
|
||||
CTexturedQuadFilter::CTexturedQuadFilter(EFilterType type,
|
||||
TLockedToken<CTexture> tex)
|
||||
: CTexturedQuadFilter(type, (tex ? tex->GetBooTexture() : nullptr))
|
||||
{
|
||||
@@ -86,13 +86,18 @@ void CTexturedQuadFilter::drawVerts(const zeus::CColor& color, const Vert verts[
|
||||
CGraphics::g_BooMainCommandQueue->draw(0, 4);
|
||||
}
|
||||
|
||||
void CTexturedQuadFilter::DrawFilter(EFilterShape shape, const zeus::CColor& color, float t)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
const zeus::CRectangle CTexturedQuadFilter::DefaultRect = {0.f, 0.f, 1.f, 1.f};
|
||||
|
||||
void CTexturedQuadFilter::Shutdown() {}
|
||||
|
||||
URDE_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilter)
|
||||
|
||||
CTexturedQuadFilterAlpha::CTexturedQuadFilterAlpha(CCameraFilterPass::EFilterType type, boo::ITexture* tex)
|
||||
CTexturedQuadFilterAlpha::CTexturedQuadFilterAlpha(EFilterType type, boo::ITexture* tex)
|
||||
: CTexturedQuadFilter(tex)
|
||||
{
|
||||
m_token = CGraphics::g_BooFactory->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
|
||||
@@ -104,7 +109,7 @@ CTexturedQuadFilterAlpha::CTexturedQuadFilterAlpha(CCameraFilterPass::EFilterTyp
|
||||
});
|
||||
}
|
||||
|
||||
CTexturedQuadFilterAlpha::CTexturedQuadFilterAlpha(CCameraFilterPass::EFilterType type,
|
||||
CTexturedQuadFilterAlpha::CTexturedQuadFilterAlpha(EFilterType type,
|
||||
TLockedToken<CTexture> tex)
|
||||
: CTexturedQuadFilterAlpha(type, (tex ? tex->GetBooTexture() : nullptr))
|
||||
{
|
||||
|
||||
@@ -43,8 +43,8 @@ public:
|
||||
};
|
||||
|
||||
static const zeus::CRectangle DefaultRect;
|
||||
CTexturedQuadFilter(CCameraFilterPass::EFilterType type, TLockedToken<CTexture> tex);
|
||||
CTexturedQuadFilter(CCameraFilterPass::EFilterType type, boo::ITexture* tex);
|
||||
CTexturedQuadFilter(EFilterType type, TLockedToken<CTexture> tex);
|
||||
CTexturedQuadFilter(EFilterType type, boo::ITexture* tex);
|
||||
CTexturedQuadFilter(const CTexturedQuadFilter&) = delete;
|
||||
CTexturedQuadFilter& operator=(const CTexturedQuadFilter&) = delete;
|
||||
CTexturedQuadFilter(CTexturedQuadFilter&&) = default;
|
||||
@@ -52,6 +52,7 @@ public:
|
||||
void draw(const zeus::CColor& color, float uvScale, const zeus::CRectangle& rect=DefaultRect);
|
||||
void drawCropped(const zeus::CColor& color, float uvScale);
|
||||
void drawVerts(const zeus::CColor& color, const Vert verts[4], float lod=0.f);
|
||||
void DrawFilter(EFilterShape shape, const zeus::CColor& color, float t);
|
||||
const TLockedToken<CTexture>& GetTex() const { return m_tex; }
|
||||
|
||||
using _CLS = CTexturedQuadFilter;
|
||||
@@ -66,8 +67,8 @@ class CTexturedQuadFilterAlpha : public CTexturedQuadFilter
|
||||
friend struct CTexturedQuadFilterAlphaD3DDataBindingFactory;
|
||||
|
||||
public:
|
||||
CTexturedQuadFilterAlpha(CCameraFilterPass::EFilterType type, TLockedToken<CTexture> tex);
|
||||
CTexturedQuadFilterAlpha(CCameraFilterPass::EFilterType type, boo::ITexture* tex);
|
||||
CTexturedQuadFilterAlpha(EFilterType type, TLockedToken<CTexture> tex);
|
||||
CTexturedQuadFilterAlpha(EFilterType type, boo::ITexture* tex);
|
||||
using _CLS = CTexturedQuadFilterAlpha;
|
||||
#include "TMultiBlendShaderDecl.hpp"
|
||||
};
|
||||
|
||||
@@ -108,15 +108,15 @@ static boo::IShaderPipeline* s_AlphaPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_AddPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_MultPipeline = nullptr;
|
||||
|
||||
static boo::IShaderPipeline* SelectPipeline(CCameraFilterPass::EFilterType type)
|
||||
static boo::IShaderPipeline* SelectPipeline(EFilterType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case CCameraFilterPass::EFilterType::Blend:
|
||||
case EFilterType::Blend:
|
||||
return s_AlphaPipeline;
|
||||
case CCameraFilterPass::EFilterType::Add:
|
||||
case EFilterType::Add:
|
||||
return s_AddPipeline;
|
||||
case CCameraFilterPass::EFilterType::Multiply:
|
||||
case EFilterType::Multiply:
|
||||
return s_MultPipeline;
|
||||
default:
|
||||
return nullptr;
|
||||
@@ -128,15 +128,15 @@ static boo::IShaderPipeline* s_AAlphaPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_AAddPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_AMultPipeline = nullptr;
|
||||
|
||||
static boo::IShaderPipeline* SelectAlphaPipeline(CCameraFilterPass::EFilterType type)
|
||||
static boo::IShaderPipeline* SelectAlphaPipeline(EFilterType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case CCameraFilterPass::EFilterType::Blend:
|
||||
case EFilterType::Blend:
|
||||
return s_AAlphaPipeline;
|
||||
case CCameraFilterPass::EFilterType::Add:
|
||||
case EFilterType::Add:
|
||||
return s_AAddPipeline;
|
||||
case CCameraFilterPass::EFilterType::Multiply:
|
||||
case EFilterType::Multiply:
|
||||
return s_AMultPipeline;
|
||||
default:
|
||||
return nullptr;
|
||||
@@ -146,7 +146,7 @@ static boo::IShaderPipeline* SelectAlphaPipeline(CCameraFilterPass::EFilterType
|
||||
struct CTexturedQuadFilterGLDataBindingFactory : TMultiBlendShader<CTexturedQuadFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CCameraFilterPass::EFilterType type,
|
||||
EFilterType type,
|
||||
CTexturedQuadFilter& filter)
|
||||
{
|
||||
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
|
||||
@@ -169,7 +169,7 @@ struct CTexturedQuadFilterGLDataBindingFactory : TMultiBlendShader<CTexturedQuad
|
||||
struct CTexturedQuadFilterVulkanDataBindingFactory : TMultiBlendShader<CTexturedQuadFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CCameraFilterPass::EFilterType type,
|
||||
EFilterType type,
|
||||
CTexturedQuadFilter& filter)
|
||||
{
|
||||
boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx);
|
||||
@@ -228,7 +228,7 @@ URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilterAlpha)
|
||||
struct CTexturedQuadFilterAlphaGLDataBindingFactory : TMultiBlendShader<CTexturedQuadFilterAlpha>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CCameraFilterPass::EFilterType type,
|
||||
EFilterType type,
|
||||
CTexturedQuadFilterAlpha& filter)
|
||||
{
|
||||
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
|
||||
@@ -251,7 +251,7 @@ struct CTexturedQuadFilterAlphaGLDataBindingFactory : TMultiBlendShader<CTexture
|
||||
struct CTexturedQuadFilterAlphaVulkanDataBindingFactory : TMultiBlendShader<CTexturedQuadFilterAlpha>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CCameraFilterPass::EFilterType type,
|
||||
EFilterType type,
|
||||
CTexturedQuadFilterAlpha& filter)
|
||||
{
|
||||
boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx);
|
||||
|
||||
@@ -111,15 +111,15 @@ static boo::IShaderPipeline* s_AlphaPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_AddPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_MultPipeline = nullptr;
|
||||
|
||||
static boo::IShaderPipeline* SelectPipeline(CCameraFilterPass::EFilterType type)
|
||||
static boo::IShaderPipeline* SelectPipeline(EFilterType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case CCameraFilterPass::EFilterType::Blend:
|
||||
case EFilterType::Blend:
|
||||
return s_AlphaPipeline;
|
||||
case CCameraFilterPass::EFilterType::Add:
|
||||
case EFilterType::Add:
|
||||
return s_AddPipeline;
|
||||
case CCameraFilterPass::EFilterType::Multiply:
|
||||
case EFilterType::Multiply:
|
||||
return s_MultPipeline;
|
||||
default:
|
||||
return nullptr;
|
||||
@@ -129,7 +129,7 @@ static boo::IShaderPipeline* SelectPipeline(CCameraFilterPass::EFilterType type)
|
||||
struct CTexturedQuadFilterD3DDataBindingFactory : TMultiBlendShader<CTexturedQuadFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CCameraFilterPass::EFilterType type,
|
||||
EFilterType type,
|
||||
CTexturedQuadFilter& filter)
|
||||
{
|
||||
boo::ID3DDataFactory::Context& cctx = static_cast<boo::ID3DDataFactory::Context&>(ctx);
|
||||
@@ -171,15 +171,15 @@ static boo::IShaderPipeline* s_AAlphaPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_AAddPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_AMultPipeline = nullptr;
|
||||
|
||||
static boo::IShaderPipeline* SelectAlphaPipeline(CCameraFilterPass::EFilterType type)
|
||||
static boo::IShaderPipeline* SelectAlphaPipeline(EFilterType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case CCameraFilterPass::EFilterType::Blend:
|
||||
case EFilterType::Blend:
|
||||
return s_AAlphaPipeline;
|
||||
case CCameraFilterPass::EFilterType::Add:
|
||||
case EFilterType::Add:
|
||||
return s_AAddPipeline;
|
||||
case CCameraFilterPass::EFilterType::Multiply:
|
||||
case EFilterType::Multiply:
|
||||
return s_AMultPipeline;
|
||||
default:
|
||||
return nullptr;
|
||||
@@ -189,7 +189,7 @@ static boo::IShaderPipeline* SelectAlphaPipeline(CCameraFilterPass::EFilterType
|
||||
struct CTexturedQuadFilterAlphaD3DDataBindingFactory : TMultiBlendShader<CTexturedQuadFilterAlpha>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CCameraFilterPass::EFilterType type,
|
||||
EFilterType type,
|
||||
CTexturedQuadFilterAlpha& filter)
|
||||
{
|
||||
boo::ID3DDataFactory::Context& cctx = static_cast<boo::ID3DDataFactory::Context&>(ctx);
|
||||
|
||||
@@ -116,15 +116,15 @@ static boo::IShaderPipeline* s_AlphaPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_AddPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_MultPipeline = nullptr;
|
||||
|
||||
static boo::IShaderPipeline* SelectPipeline(CCameraFilterPass::EFilterType type)
|
||||
static boo::IShaderPipeline* SelectPipeline(EFilterType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case CCameraFilterPass::EFilterType::Blend:
|
||||
case EFilterType::Blend:
|
||||
return s_AlphaPipeline;
|
||||
case CCameraFilterPass::EFilterType::Add:
|
||||
case EFilterType::Add:
|
||||
return s_AddPipeline;
|
||||
case CCameraFilterPass::EFilterType::Multiply:
|
||||
case EFilterType::Multiply:
|
||||
return s_MultPipeline;
|
||||
default:
|
||||
return nullptr;
|
||||
@@ -134,7 +134,7 @@ static boo::IShaderPipeline* SelectPipeline(CCameraFilterPass::EFilterType type)
|
||||
struct CTexturedQuadFilterMetalDataBindingFactory : TMultiBlendShader<CTexturedQuadFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CCameraFilterPass::EFilterType type,
|
||||
EFilterType type,
|
||||
CTexturedQuadFilter& filter)
|
||||
{
|
||||
boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx);
|
||||
@@ -171,7 +171,7 @@ CTexturedQuadFilter::Initialize(boo::MetalDataFactory::Context& ctx)
|
||||
struct CTexturedQuadFilterAlphaMetalDataBindingFactory : TMultiBlendShader<CTexturedQuadFilterAlpha>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CCameraFilterPass::EFilterType type,
|
||||
EFilterType type,
|
||||
CTexturedQuadFilterAlpha& filter)
|
||||
{
|
||||
boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx);
|
||||
|
||||
@@ -18,8 +18,7 @@ public:
|
||||
struct IDataBindingFactory
|
||||
{
|
||||
virtual boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CCameraFilterPass::EFilterType type,
|
||||
ShaderImp& filter)=0;
|
||||
EFilterType type, ShaderImp& filter)=0;
|
||||
};
|
||||
|
||||
static std::unique_ptr<IDataBindingFactory> m_bindFactory;
|
||||
@@ -67,8 +66,7 @@ public:
|
||||
}
|
||||
|
||||
static boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CCameraFilterPass::EFilterType type,
|
||||
ShaderImp& filter)
|
||||
EFilterType type, ShaderImp& filter)
|
||||
{
|
||||
return m_bindFactory->BuildShaderDataBinding(ctx, type, filter);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user