Add CPlayerGun holo effect rendering

This commit is contained in:
Jack Andersen 2017-09-02 19:53:38 -10:00
parent 35ab6e4803
commit 91600c31bf
21 changed files with 522 additions and 43 deletions

View File

@ -28,7 +28,7 @@ zeus::CVector3f CGraphics::g_ViewPoint;
zeus::CTransform CGraphics::g_GXViewPointMatrix;
zeus::CTransform CGraphics::g_CameraMatrix;
SClipScreenRect CGraphics::g_CroppedViewport;
int CGraphics::g_ViewportSamples = 1;
unsigned int CGraphics::g_ViewportSamples = 1;
bool CGraphics::g_IsGXModelMatrixIdentity = true;
SViewport g_Viewport = {0, 0, 640, 480, 640 / 2.f, 480 / 2.f};
u32 CGraphics::g_FrameCounter = 0;

View File

@ -247,7 +247,7 @@ public:
static zeus::CTransform g_GXViewPointMatrix;
static zeus::CTransform g_CameraMatrix;
static SClipScreenRect g_CroppedViewport;
static int g_ViewportSamples;
static unsigned int g_ViewportSamples;
static bool g_IsGXModelMatrixIdentity;
static void DisableAllLights();

View File

@ -20,7 +20,8 @@ if(WIN32)
Shaders/CRandomStaticFilterHLSL.cpp
Shaders/CElementGenShadersHLSL.cpp
Shaders/CParticleSwooshShadersHLSL.cpp
Shaders/CFluidPlaneShaderHLSL.cpp)
Shaders/CFluidPlaneShaderHLSL.cpp
Shaders/CAABoxShaderHLSL.cpp)
elseif(BOO_HAS_METAL)
set(PLAT_SRCS
Shaders/CLineRendererShadersMetal.cpp
@ -43,7 +44,8 @@ elseif(BOO_HAS_METAL)
Shaders/CRandomStaticFilterMetal.cpp
Shaders/CElementGenShadersMetal.cpp
Shaders/CParticleSwooshShadersMetal.cpp
Shaders/CFluidPlaneShaderMetal.cpp)
Shaders/CFluidPlaneShaderMetal.cpp
Shaders/CAABoxShaderMetal.cpp)
endif()
set(GRAPHICS_SOURCES
@ -89,6 +91,7 @@ set(GRAPHICS_SOURCES
Shaders/CElementGenShaders.hpp Shaders/CElementGenShaders.cpp Shaders/CElementGenShadersGLSL.cpp
Shaders/CParticleSwooshShaders.hpp Shaders/CParticleSwooshShaders.cpp Shaders/CParticleSwooshShadersGLSL.cpp
Shaders/CFluidPlaneShader.hpp Shaders/CFluidPlaneShader.cpp Shaders/CFluidPlaneShaderGLSL.cpp
Shaders/CAABoxShader.hpp Shaders/CAABoxShader.cpp Shaders/CAABoxShaderGLSL.cpp
${PLAT_SRCS})
runtime_add_list(Graphics GRAPHICS_SOURCES)

View File

@ -0,0 +1,80 @@
#include "CAABoxShader.hpp"
namespace urde
{
CAABoxShader::CAABoxShader(bool zOnly)
: m_zOnly(zOnly)
{
m_token = CGraphics::g_BooFactory->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx)
{
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(zeus::CVector3f), 34);
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
m_dataBind = TShader<CAABoxShader>::BuildShaderDataBinding(ctx, *this);
return true;
});
}
void CAABoxShader::setAABB(const zeus::CAABox& aabb)
{
zeus::CVector3f vboData[] =
{
{aabb.max.x, aabb.max.y, aabb.min.z},
{aabb.max.x, aabb.min.y, aabb.min.z},
{aabb.max.x, aabb.max.y, aabb.max.z},
{aabb.max.x, aabb.min.y, aabb.max.z},
{aabb.max.x, aabb.min.y, aabb.max.z},
{aabb.min.x, aabb.max.y, aabb.min.z},
{aabb.min.x, aabb.max.y, aabb.min.z},
{aabb.max.x, aabb.max.y, aabb.min.z},
{aabb.min.x, aabb.max.y, aabb.max.z},
{aabb.max.x, aabb.max.y, aabb.max.z},
{aabb.max.x, aabb.max.y, aabb.max.z},
{aabb.min.x, aabb.max.y, aabb.min.z},
{aabb.min.x, aabb.max.y, aabb.min.z},
{aabb.min.x, aabb.min.y, aabb.min.z},
{aabb.min.x, aabb.max.y, aabb.max.z},
{aabb.min.x, aabb.min.y, aabb.max.z},
{aabb.min.x, aabb.min.y, aabb.max.z},
{aabb.min.x, aabb.min.y, aabb.min.z},
{aabb.min.x, aabb.min.y, aabb.min.z},
{aabb.max.x, aabb.min.y, aabb.min.z},
{aabb.min.x, aabb.min.y, aabb.max.z},
{aabb.max.x, aabb.min.y, aabb.max.z},
{aabb.max.x, aabb.min.y, aabb.max.z},
{aabb.min.x, aabb.min.y, aabb.max.z},
{aabb.min.x, aabb.min.y, aabb.max.z},
{aabb.max.x, aabb.min.y, aabb.max.z},
{aabb.min.x, aabb.max.y, aabb.max.z},
{aabb.max.x, aabb.max.y, aabb.max.z},
{aabb.max.x, aabb.max.y, aabb.max.z},
{aabb.min.x, aabb.min.y, aabb.min.z},
{aabb.min.x, aabb.min.y, aabb.min.z},
{aabb.max.x, aabb.min.y, aabb.min.z},
{aabb.min.x, aabb.max.y, aabb.min.z},
{aabb.max.x, aabb.max.y, aabb.min.z},
};
m_vbo->load(vboData, sizeof(zeus::CVector3f) * 34);
}
void CAABoxShader::draw(const zeus::CColor& color)
{
m_uniform.m_xf = CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f();
m_uniform.m_color = color;
m_uniBuf->load(&m_uniform, sizeof(Uniform));
CGraphics::g_BooMainCommandQueue->setShaderDataBinding(m_dataBind);
CGraphics::g_BooMainCommandQueue->draw(0, 34);
}
void CAABoxShader::Shutdown() {}
URDE_SPECIALIZE_SHADER(CAABoxShader)
}

View File

@ -0,0 +1,42 @@
#ifndef __URDE_CAABOXSHADER_HPP__
#define __URDE_CAABOXSHADER_HPP__
#include "TShader.hpp"
#include "zeus/CMatrix4f.hpp"
#include "zeus/CColor.hpp"
#include "zeus/CAABox.hpp"
namespace urde
{
class CAABoxShader
{
friend struct CAABoxShaderGLDataBindingFactory;
friend struct CAABoxShaderVulkanDataBindingFactory;
friend struct CAABoxShaderMetalDataBindingFactory;
friend struct CAABoxShaderD3DDataBindingFactory;
struct Uniform
{
zeus::CMatrix4f m_xf;
zeus::CColor m_color;
};
boo::GraphicsDataToken m_token;
boo::IGraphicsBufferD* m_vbo;
boo::IGraphicsBufferD* m_uniBuf;
boo::IShaderDataBinding* m_dataBind = nullptr;
Uniform m_uniform;
bool m_zOnly;
public:
CAABoxShader(bool zOnly);
void setAABB(const zeus::CAABox& aabb);
void draw(const zeus::CColor& color);
using _CLS = CAABoxShader;
#include "TShaderDecl.hpp"
};
}
#endif // __URDE_CAABOXSHADER_HPP__

View File

@ -0,0 +1,116 @@
#include "CAABoxShader.hpp"
#include "Graphics/CBooRenderer.hpp"
namespace urde
{
static const char* VS =
"#version 330\n"
BOO_GLSL_BINDING_HEAD
"layout(location=0) in vec4 posIn;\n"
"\n"
"UBINDING0 uniform CAABoxUniform\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_SHADER(CAABoxShader)
static boo::IVertexFormat* s_VtxFmt = nullptr;
static boo::IShaderPipeline* s_Pipeline = nullptr;
static boo::IShaderPipeline* s_zOnlyPipeline = nullptr;
struct CAABoxShaderGLDataBindingFactory : TShader<CAABoxShader>::IDataBindingFactory
{
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CAABoxShader& 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_zOnly ? s_zOnlyPipeline : s_Pipeline,
ctx.newVertexFormat(1, VtxVmt), filter.m_vbo, nullptr, nullptr,
1, bufs, stages, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
}
};
#if BOO_HAS_VULKAN
struct CAABoxShaderVulkanDataBindingFactory : TShader<CAABoxShader>::IDataBindingFactory
{
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CAABoxShader& filter)
{
boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
return cctx.newShaderDataBinding(filter.m_zOnly ? s_zOnlyPipeline : s_Pipeline, s_VtxFmt,
filter.m_vbo, nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
}
};
#endif
TShader<CAABoxShader>::IDataBindingFactory* CAABoxShader::Initialize(boo::GLDataFactory::Context& ctx)
{
const char* uniNames[] = {"CAABoxUniform"};
s_Pipeline = ctx.newShaderPipeline(VS, FS, 0, nullptr, 1, uniNames, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::LEqual, true, true, false, boo::CullMode::None);
s_zOnlyPipeline = ctx.newShaderPipeline(VS, FS, 0, nullptr, 1, uniNames, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::LEqual, true, false, false, boo::CullMode::None);
return new CAABoxShaderGLDataBindingFactory;
}
#if BOO_HAS_VULKAN
TShader<CAABoxShader>::IDataBindingFactory* CAABoxShader::Initialize(boo::VulkanDataFactory::Context& ctx)
{
const boo::VertexElementDescriptor VtxVmt[] =
{
{nullptr, nullptr, boo::VertexSemantic::Position4},
};
s_VtxFmt = ctx.newVertexFormat(1, VtxVmt);
s_Pipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::LEqual, true, true, false, boo::CullMode::None);
s_zOnlyPipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::LEqual, true, false, false, boo::CullMode::None);
return new CAABoxShaderVulkanDataBindingFactory;
}
#endif
}

View File

@ -0,0 +1,83 @@
#include "CAABoxShader.hpp"
#include "Graphics/CBooRenderer.hpp"
namespace urde
{
static const char* VS =
"struct VertData\n"
"{\n"
" float4 posIn : POSITION;\n"
"};\n"
"\n"
"cbuffer CAABoxUniform : register(b0)\n"
"{\n"
" float4x4 xf;\n"
" float4 color;\n"
"};\n"
"\n"
"struct VertToFrag\n"
"{\n"
" float4 pos : SV_Position;\n"
" float4 color : COLOR;\n"
"};\n"
"\n"
"VertToFrag main(in VertData v)\n"
"{\n"
" VertToFrag vtf;\n"
" vtf.color = bu.color;\n"
" vtf.pos = bu.xf * vec4(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 pos : SV_Position;\n"
" float4 color : COLOR;\n"
"};\n"
"\n"
"float4 main(in VertToFrag vtf) : SV_Target0\n"
"{\n"
" return vtf.color;\n"
"}\n";
URDE_DECL_SPECIALIZE_SHADER(CAABoxShader)
static boo::IVertexFormat* s_VtxFmt = nullptr;
static boo::IShaderPipeline* s_Pipeline = nullptr;
static boo::IShaderPipeline* s_zOnlyPipeline = nullptr;
struct CAABoxShaderD3DDataBindingFactory : TShader<CAABoxShader>::IDataBindingFactory
{
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CAABoxShader& filter)
{
boo::ID3DDataFactory::Context& cctx = static_cast<boo::ID3DDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
return cctx.newShaderDataBinding(filter.m_zOnly ? s_zOnlyPipeline : s_Pipeline, s_VtxFmt,
filter.m_vbo, nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
}
};
TShader<CAABoxShader>::IDataBindingFactory* CAABoxShader::Initialize(boo::ID3DDataFactory::Context& ctx)
{
const boo::VertexElementDescriptor VtxVmt[] =
{
{nullptr, nullptr, boo::VertexSemantic::Position4},
};
s_VtxFmt = ctx.newVertexFormat(1, VtxVmt);
s_Pipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr, nullptr, s_VtxFmt, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::LEqual, true, true, false, boo::CullMode::None);
s_zOnlyPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr, nullptr, s_VtxFmt, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::LEqual, true, false, false, boo::CullMode::None);
return new CAABoxShaderD3DDataBindingFactory;
}
}

View File

@ -0,0 +1,85 @@
#include "CAABoxShader.hpp"
#include "Graphics/CBooRenderer.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 CAABoxUniform\n"
"{\n"
" float4x4 xf;\n"
" float4 color;\n"
"};\n"
"\n"
"struct VertToFrag\n"
"{\n"
" float4 pos [[ position ]];\n"
" float4 color;\n"
"};\n"
"\n"
"vertex VertToFrag vmain(VertData v [[ stage_in ]], constant CAABoxUniform& bu [[ buffer(2) ]])\n"
"{\n"
" VertToFrag vtf;\n"
" vtf.color = bu.color;\n"
" vtf.pos = bu.xf * vec4(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 pos [[ position ]];\n"
" float4 color;\n"
"};\n"
"\n"
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]])\n"
"{\n"
" return vtf.color;\n"
"}\n";
URDE_DECL_SPECIALIZE_SHADER(CAABoxShader)
static boo::IVertexFormat* s_VtxFmt = nullptr;
static boo::IShaderPipeline* s_Pipeline = nullptr;
static boo::IShaderPipeline* s_zOnlyPipeline = nullptr;
struct CAABoxShaderMetalDataBindingFactory : TShader<CAABoxShader>::IDataBindingFactory
{
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CAABoxShader& filter)
{
boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
return cctx.newShaderDataBinding(filter.m_zOnly ? s_zOnlyPipeline : s_Pipeline, s_VtxFmt,
filter.m_vbo, nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
}
};
TShader<CAABoxShader>::IDataBindingFactory* CAABoxShader::Initialize(boo::MetalDataFactory::Context& ctx)
{
const boo::VertexElementDescriptor VtxVmt[] =
{
{nullptr, nullptr, boo::VertexSemantic::Position4},
};
s_VtxFmt = ctx.newVertexFormat(1, VtxVmt);
s_Pipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::LEqual, true, true, false, boo::CullMode::None);
s_zOnlyPipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::LEqual, true, false, false, boo::CullMode::None);
return new CAABoxShaderMetalDataBindingFactory;
}
}

View File

@ -1,5 +1,4 @@
#include "CCameraBlurFilter.hpp"
#include "Graphics/CGraphics.hpp"
namespace urde
{

View File

@ -1,6 +1,5 @@
#include "CCameraBlurFilter.hpp"
#include "Graphics/CBooRenderer.hpp"
#include "GameGlobalObjects.hpp"
namespace urde
{
@ -127,7 +126,7 @@ TShader<CCameraBlurFilter>::IDataBindingFactory* CCameraBlurFilter::Initialize(b
const char* uniNames[] = {"CameraBlurUniform"};
s_Pipeline = ctx.newShaderPipeline(VS, FS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, true, boo::CullMode::None);
boo::ZTest::None, false, true, false, boo::CullMode::None);
return new CCameraBlurFilterGLDataBindingFactory;
}

View File

@ -1,6 +1,5 @@
#include "CCameraBlurFilter.hpp"
#include "Graphics/CBooRenderer.hpp"
#include "GameGlobalObjects.hpp"
namespace urde
{

View File

@ -1,6 +1,5 @@
#include "CCameraBlurFilter.hpp"
#include "Graphics/CBooRenderer.hpp"
#include "GameGlobalObjects.hpp"
namespace urde
{

View File

@ -9,8 +9,8 @@ CTexturedQuadFilter::CTexturedQuadFilter(boo::ITexture* tex)
{
}
CTexturedQuadFilter::CTexturedQuadFilter(EFilterType type, boo::ITexture* tex)
: m_booTex(tex)
CTexturedQuadFilter::CTexturedQuadFilter(EFilterType type, boo::ITexture* tex, bool gequal)
: m_booTex(tex), m_gequal(gequal)
{
m_token = CGraphics::g_BooFactory->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
@ -28,14 +28,14 @@ CTexturedQuadFilter::CTexturedQuadFilter(EFilterType type,
m_tex = tex;
}
void CTexturedQuadFilter::draw(const zeus::CColor& color, float uvScale, const zeus::CRectangle& rect)
void CTexturedQuadFilter::draw(const zeus::CColor& color, float uvScale, const zeus::CRectangle& rect, float z)
{
Vert verts[4] =
{
{{0.f, 0.f, 0.f}, {0.f, 0.f}},
{{0.f, 1.f, 0.f}, {0.f, uvScale}},
{{1.f, 0.f, 0.f}, {uvScale, 0.f}},
{{1.f, 1.f, 0.f}, {uvScale, uvScale}},
{{0.f, 0.f, z}, {0.f, 0.f}},
{{0.f, 1.f, z}, {0.f, uvScale}},
{{1.f, 0.f, z}, {uvScale, 0.f}},
{{1.f, 1.f, z}, {uvScale, uvScale}},
};
m_vbo->load(verts, sizeof(verts));

View File

@ -32,6 +32,7 @@ protected:
boo::IGraphicsBufferD* m_uniBuf;
boo::IShaderDataBinding* m_dataBind = nullptr;
Uniform m_uniform;
bool m_gequal;
CTexturedQuadFilter(boo::ITexture* tex);
@ -44,12 +45,12 @@ public:
static const zeus::CRectangle DefaultRect;
CTexturedQuadFilter(EFilterType type, TLockedToken<CTexture> tex);
CTexturedQuadFilter(EFilterType type, boo::ITexture* tex);
CTexturedQuadFilter(EFilterType type, boo::ITexture* tex, bool gequal = false);
CTexturedQuadFilter(const CTexturedQuadFilter&) = delete;
CTexturedQuadFilter& operator=(const CTexturedQuadFilter&) = delete;
CTexturedQuadFilter(CTexturedQuadFilter&&) = default;
CTexturedQuadFilter& operator=(CTexturedQuadFilter&&) = default;
void draw(const zeus::CColor& color, float uvScale, const zeus::CRectangle& rect=DefaultRect);
void draw(const zeus::CColor& color, float uvScale, const zeus::CRectangle& rect=DefaultRect, float z=0.f);
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);

View File

@ -105,11 +105,14 @@ URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilter)
static boo::IVertexFormat* s_VtxFmt = nullptr;
static boo::IShaderPipeline* s_AlphaPipeline = nullptr;
static boo::IShaderPipeline* s_AlphaGEqualPipeline = nullptr;
static boo::IShaderPipeline* s_AddPipeline = nullptr;
static boo::IShaderPipeline* s_MultPipeline = nullptr;
static boo::IShaderPipeline* SelectPipeline(EFilterType type)
static boo::IShaderPipeline* SelectPipeline(EFilterType type, bool gequal)
{
if (gequal)
return s_AlphaGEqualPipeline;
switch (type)
{
case EFilterType::Blend:
@ -159,7 +162,7 @@ struct CTexturedQuadFilterGLDataBindingFactory : TMultiBlendShader<CTexturedQuad
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
boo::ITexture* texs[] = {filter.m_booTex};
return cctx.newShaderDataBinding(SelectPipeline(type),
return cctx.newShaderDataBinding(SelectPipeline(type, filter.m_gequal),
ctx.newVertexFormat(2, VtxVmt), filter.m_vbo, nullptr, nullptr,
1, bufs, stages, nullptr, nullptr, 1, texs, nullptr, nullptr);
}
@ -176,7 +179,7 @@ struct CTexturedQuadFilterVulkanDataBindingFactory : TMultiBlendShader<CTextured
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
boo::ITexture* texs[] = {filter.m_booTex};
return cctx.newShaderDataBinding(SelectPipeline(type), s_VtxFmt,
return cctx.newShaderDataBinding(SelectPipeline(type, filter.m_gequal), s_VtxFmt,
filter.m_vbo, nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr);
}
@ -191,6 +194,9 @@ CTexturedQuadFilter::Initialize(boo::GLDataFactory::Context& ctx)
s_AlphaPipeline = ctx.newShaderPipeline(VSNoFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None);
s_AlphaGEqualPipeline = ctx.newShaderPipeline(VSNoFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::GEqual, true, true, false, boo::CullMode::None);
s_AddPipeline = ctx.newShaderPipeline(VSNoFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None);
@ -213,6 +219,9 @@ CTexturedQuadFilter::Initialize(boo::VulkanDataFactory::Context& ctx)
s_AlphaPipeline = ctx.newShaderPipeline(VSNoFlip, FS, s_VtxFmt, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None);
s_AlphaGEqualPipeline = ctx.newShaderPipeline(VSNoFlip, FS, s_VtxFmt, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::GEqual, true, true, false, boo::CullMode::None);
s_AddPipeline = ctx.newShaderPipeline(VSNoFlip, FS, s_VtxFmt, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None);

View File

@ -108,11 +108,14 @@ URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilter)
static boo::IVertexFormat* s_VtxFmt = nullptr;
static boo::IShaderPipeline* s_AlphaPipeline = nullptr;
static boo::IShaderPipeline* s_AlphaGEqualPipeline = nullptr;
static boo::IShaderPipeline* s_AddPipeline = nullptr;
static boo::IShaderPipeline* s_MultPipeline = nullptr;
static boo::IShaderPipeline* SelectPipeline(EFilterType type)
static boo::IShaderPipeline* SelectPipeline(EFilterType type, bool gequal)
{
if (gequal)
return s_AlphaGEqualPipeline;
switch (type)
{
case EFilterType::Blend:
@ -136,7 +139,7 @@ struct CTexturedQuadFilterD3DDataBindingFactory : TMultiBlendShader<CTexturedQua
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
boo::ITexture* texs[] = {filter.m_booTex};
return cctx.newShaderDataBinding(SelectPipeline(type), s_VtxFmt,
return cctx.newShaderDataBinding(SelectPipeline(type, filter.m_gequal), s_VtxFmt,
filter.m_vbo, nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr);
}
@ -155,6 +158,10 @@ CTexturedQuadFilter::Initialize(boo::ID3DDataFactory::Context& ctx)
s_VtxFmt, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None);
s_AlphaGEqualPipeline = ctx.newShaderPipeline(VSNoFlip, FS, nullptr, nullptr, nullptr,
s_VtxFmt, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::GEqual, true, true, false, boo::CullMode::None);
s_AddPipeline = ctx.newShaderPipeline(VSNoFlip, FS, nullptr, nullptr, nullptr,
s_VtxFmt, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips,

View File

@ -113,11 +113,14 @@ URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilter)
static boo::IVertexFormat* s_VtxFmt = nullptr;
static boo::IShaderPipeline* s_AlphaPipeline = nullptr;
static boo::IShaderPipeline* s_AlphaGEqualPipeline = nullptr;
static boo::IShaderPipeline* s_AddPipeline = nullptr;
static boo::IShaderPipeline* s_MultPipeline = nullptr;
static boo::IShaderPipeline* SelectPipeline(EFilterType type)
static boo::IShaderPipeline* SelectPipeline(EFilterType type, bool gequal)
{
if (gequal)
return s_AlphaGEqualPipeline;
switch (type)
{
case EFilterType::Blend:
@ -141,7 +144,7 @@ struct CTexturedQuadFilterMetalDataBindingFactory : TMultiBlendShader<CTexturedQ
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
boo::ITexture* texs[] = {filter.m_booTex};
return cctx.newShaderDataBinding(SelectPipeline(type), s_VtxFmt,
return cctx.newShaderDataBinding(SelectPipeline(type, filter.m_gequal), s_VtxFmt,
filter.m_vbo, nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr);
}
@ -158,16 +161,39 @@ CTexturedQuadFilter::Initialize(boo::MetalDataFactory::Context& ctx)
s_VtxFmt = ctx.newVertexFormat(2, VtxVmt);
s_AlphaPipeline = ctx.newShaderPipeline(VSNoFlip, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, boo::ZTest::None, false,
true, true, boo::CullMode::None);
true, false, boo::CullMode::None);
s_AlphaGEqualPipeline = ctx.newShaderPipeline(VSNoFlip, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, boo::ZTest::GEqual, true,
true, false, boo::CullMode::None);
s_AddPipeline = ctx.newShaderPipeline(VSNoFlip, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, boo::ZTest::None, false,
true, true, boo::CullMode::None);
true, false, boo::CullMode::None);
s_MultPipeline = ctx.newShaderPipeline(VSNoFlip, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcColor,
boo::BlendFactor::DstColor, boo::Primitive::TriStrips, boo::ZTest::None, false,
true, true, boo::CullMode::None);
true, false, boo::CullMode::None);
return new CTexturedQuadFilterMetalDataBindingFactory;
}
static boo::IVertexFormat* s_AVtxFmt = nullptr;
static boo::IShaderPipeline* s_AAlphaPipeline = nullptr;
static boo::IShaderPipeline* s_AAddPipeline = nullptr;
static boo::IShaderPipeline* s_AMultPipeline = nullptr;
static boo::IShaderPipeline* SelectAlphaPipeline(EFilterType type)
{
switch (type)
{
case EFilterType::Blend:
return s_AAlphaPipeline;
case EFilterType::Add:
return s_AAddPipeline;
case EFilterType::Multiply:
return s_AMultPipeline;
default:
return nullptr;
}
}
struct CTexturedQuadFilterAlphaMetalDataBindingFactory : TMultiBlendShader<CTexturedQuadFilterAlpha>::IDataBindingFactory
{
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
@ -178,7 +204,7 @@ struct CTexturedQuadFilterAlphaMetalDataBindingFactory : TMultiBlendShader<CText
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
boo::ITexture* texs[] = {filter.m_booTex};
return cctx.newShaderDataBinding(SelectPipeline(type), s_VtxFmt,
return cctx.newShaderDataBinding(SelectAlphaPipeline(type), s_AVtxFmt,
filter.m_vbo, nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr);
}
@ -192,16 +218,16 @@ CTexturedQuadFilterAlpha::Initialize(boo::MetalDataFactory::Context& ctx)
{nullptr, nullptr, boo::VertexSemantic::Position4},
{nullptr, nullptr, boo::VertexSemantic::UV4}
};
s_VtxFmt = ctx.newVertexFormat(2, VtxVmt);
s_AlphaPipeline = ctx.newShaderPipeline(VSFlip, FSAlpha, 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(VSFlip, FSAlpha, 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(VSFlip, FSAlpha, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcColor,
boo::BlendFactor::DstColor, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, true, boo::CullMode::None);
s_AVtxFmt = ctx.newVertexFormat(2, VtxVmt);
s_AAlphaPipeline = ctx.newShaderPipeline(VSFlip, FSAlpha, s_AVtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None);
s_AAddPipeline = ctx.newShaderPipeline(VSFlip, FSAlpha, s_AVtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None);
s_AMultPipeline = ctx.newShaderPipeline(VSFlip, FSAlpha, s_AVtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcColor,
boo::BlendFactor::DstColor, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None);
return new CTexturedQuadFilterAlphaMetalDataBindingFactory;
}

View File

@ -15,6 +15,7 @@
#include "Graphics/Shaders/CScanLinesFilter.hpp"
#include "Graphics/Shaders/CRandomStaticFilter.hpp"
#include "Graphics/Shaders/CFluidPlaneShader.hpp"
#include "Graphics/Shaders/CAABoxShader.hpp"
#include "Character/CCharLayoutInfo.hpp"
#include "Audio/CStreamAudioManager.hpp"
#include "CGBASupport.hpp"
@ -34,6 +35,7 @@ URDE_DECL_SPECIALIZE_SHADER(CEnergyBarShader)
URDE_DECL_SPECIALIZE_SHADER(CRadarPaintShader)
URDE_DECL_SPECIALIZE_SHADER(CMapSurfaceShader)
URDE_DECL_SPECIALIZE_SHADER(CPhazonSuitFilter)
URDE_DECL_SPECIALIZE_SHADER(CAABoxShader)
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CColoredQuadFilter)
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilter)
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilterAlpha)
@ -230,6 +232,7 @@ CMain::BooSetter::BooSetter(boo::IGraphicsDataFactory* factory,
TShader<CRadarPaintShader>::Initialize();
TShader<CMapSurfaceShader>::Initialize();
TShader<CPhazonSuitFilter>::Initialize();
TShader<CAABoxShader>::Initialize();
TMultiBlendShader<CColoredQuadFilter>::Initialize();
TMultiBlendShader<CTexturedQuadFilter>::Initialize();
TMultiBlendShader<CTexturedQuadFilterAlpha>::Initialize();
@ -364,6 +367,7 @@ void CMain::Shutdown()
TShader<CRadarPaintShader>::Shutdown();
TShader<CMapSurfaceShader>::Shutdown();
TShader<CPhazonSuitFilter>::Shutdown();
TShader<CAABoxShader>::Shutdown();
TMultiBlendShader<CColoredQuadFilter>::Shutdown();
TMultiBlendShader<CTexturedQuadFilter>::Shutdown();
TMultiBlendShader<CTexturedQuadFilterAlpha>::Shutdown();

View File

@ -80,6 +80,8 @@ CPlayerGun::CPlayerGun(TUniqueId playerId)
x550_camBob.SetPlayerVelocity(zeus::CVector3f::skZero);
x550_camBob.SetBobMagnitude(0.f);
x550_camBob.SetBobTimeScale(0.f);
m_aaboxShader.setAABB(x6c8_hologramClipCube);
}
void CPlayerGun::InitBeamData()
@ -2455,9 +2457,26 @@ zeus::CVector3f CPlayerGun::ConvertToScreenSpace(const zeus::CVector3f& pos, con
return {-1.f, -1.f, 1.f};
}
static void CopyScreenTex() {}
static void DrawScreenTex(float f1) {}
static void DrawClipCube(const zeus::CAABox& aabb) {}
void CPlayerGun::CopyScreenTex()
{
// Copy lower right quadrant to gpCopyTexBuf as RGBA8
CGraphics::ResolveSpareTexture(g_Viewport);
}
void CPlayerGun::DrawScreenTex(float z) const
{
// Use CopyScreenTex rendering to draw over framebuffer pixels in front of `z`
// This is accomplished using orthographic projection quad with sweeping `y` coordinates
// Depth is set to GEQUAL to obscure pixels in front rather than behind
m_screenQuad.draw(zeus::CColor::skWhite, 1.f, CTexturedQuadFilter::DefaultRect, z);
}
void CPlayerGun::DrawClipCube(const zeus::CAABox& aabb) const
{
// Render AABB as completely transparent object, only modifying Z-buffer
// AABB has already been set in constructor (since it's constant)
m_aaboxShader.draw(zeus::CColor::skClear);
}
static const CModelFlags kHandThermalFlag = {7, 0, 3, zeus::CColor::skWhite};
static const CModelFlags kHandHoloFlag = {1, 0, 3, zeus::CColor(0.75f, 0.5f, 0.f, 1.f)};

View File

@ -20,6 +20,8 @@
#include "World/CWorldShadow.hpp"
#include "World/ScriptObjectSupport.hpp"
#include "Graphics/CRainSplashGenerator.hpp"
#include "Graphics/Shaders/CTexturedQuadFilter.hpp"
#include "Graphics/Shaders/CAABoxShader.hpp"
namespace urde
{
@ -311,6 +313,9 @@ private:
u32 _dummy = 0;
};
mutable CTexturedQuadFilter m_screenQuad = {EFilterType::Blend, CGraphics::g_SpareTexture, true};
mutable CAABoxShader m_aaboxShader = {true};
void InitBeamData();
void InitBombData();
void InitMuzzleData();
@ -363,6 +368,9 @@ private:
void RenderEnergyDrainEffects(const CStateManager& mgr) const;
void DrawArm(const CStateManager& mgr, const zeus::CVector3f& pos, const CModelFlags& flags) const;
zeus::CVector3f ConvertToScreenSpace(const zeus::CVector3f& pos, const CGameCamera& cam) const;
static void CopyScreenTex();
void DrawScreenTex(float z) const;
void DrawClipCube(const zeus::CAABox& aabb) const;
public:
explicit CPlayerGun(TUniqueId playerId);

2
hecl

@ -1 +1 @@
Subproject commit 2466f4f0e37974b37709f1f4447d1adf185343b3
Subproject commit af4857cfae81cb2ca03526bdbb76335d913a6e24