diff --git a/Editor/ViewManager.cpp b/Editor/ViewManager.cpp index 4817373c4..65f34ac04 100644 --- a/Editor/ViewManager.cpp +++ b/Editor/ViewManager.cpp @@ -89,6 +89,27 @@ void ViewManager::ParticleView::draw(boo::IGraphicsCommandQueue *gfxQ) //lights = {CLight::BuildLocalAmbient({}, {0.0f, 0.0f, 0.0f, 1.f})}; m_vm.m_modelTest->GetInstance().ActivateLights(lights); m_vm.m_modelTest->Draw(flags); + + zeus::CColor ctrlCol{1.f, 0.f, 0.f, 1.f}; + float fac = 0.5f; + zeus::CColor a = zeus::CColor::lerp(ctrlCol, zeus::CColor::skWhite, fac); + m_thermColdFilter.setColorA(a); + float bFac = 0.f; + float bAlpha = 1.f; + if (fac < 0.5f) + { + bAlpha = fac * 2.f; + bFac = (1.f - bAlpha) / 8.f; + } + zeus::CColor b{bFac, bFac, bFac, bAlpha}; + m_thermColdFilter.setColorB(b); + zeus::CColor c = zeus::CColor::lerp(zeus::CColor::skBlack, zeus::CColor::skWhite, fac * 0.75f + 0.25f); + m_thermColdFilter.setColorC(c); + + m_thermColdFilter.setScale(std::sin(m_theta) * 0.5f + 0.5f); + + m_thermColdFilter.setShift(m_random.Next() % 32); + m_thermColdFilter.draw(); } if (m_vm.m_partGen) { diff --git a/Editor/ViewManager.hpp b/Editor/ViewManager.hpp index e4c58bba4..f1386fef7 100644 --- a/Editor/ViewManager.hpp +++ b/Editor/ViewManager.hpp @@ -46,10 +46,12 @@ class ViewManager : public specter::IViewManager class ParticleView : public specter::View { ViewManager& m_vm; + CThermalColdFilter m_thermColdFilter; + CRandom16 m_random; float m_theta = 0.f; public: ParticleView(ViewManager& vm, specter::ViewResources& res, specter::View& parent) - : View(res, parent), m_vm(vm) {} + : View(res, parent), m_vm(vm), m_random(20) {} void resized(const boo::SWindowRect& root, const boo::SWindowRect& sub); void draw(boo::IGraphicsCommandQueue* gfxQ); }; diff --git a/Runtime/CStateManager.cpp b/Runtime/CStateManager.cpp index fb30337ea..9bd5f785b 100644 --- a/Runtime/CStateManager.cpp +++ b/Runtime/CStateManager.cpp @@ -11,6 +11,9 @@ #include "Graphics/CLight.hpp" #include "GameGlobalObjects.hpp" #include "CSimplePool.hpp" +#include "CPlayerState.hpp" +#include "World/CPlayer.hpp" +#include "World/CMorphBall.hpp" namespace urde { @@ -166,6 +169,20 @@ CStateManager::CStateManager(const std::weak_ptr&, x8ec_shadowTex = g_SimplePool->GetObj("DefaultShadow"); } +void CStateManager::UpdateVisors() +{ + xf28_thermColdScale2 = 0.f; + xf24_thermColdScale1 = 0.f; + CPlayerState::EPlayerVisor visor = x8b8_playerState->GetActiveVisor(*this); + if (visor == CPlayerState::EPlayerVisor::Thermal && x8cc_nextAreaId != kInvalidAreaId) + { + std::unique_ptr& area = x850_world->GetGameAreas()[x8cc_nextAreaId]; + const zeus::CTransform& playerXf = x84c_player->GetTransform(); + float f30 = playerXf.origin.x; + float f29 = playerXf.origin.y; + } +} + void CStateManager::RenderLast(TUniqueId) { } diff --git a/Runtime/CStateManager.hpp b/Runtime/CStateManager.hpp index 10d3216ee..091f672b2 100644 --- a/Runtime/CStateManager.hpp +++ b/Runtime/CStateManager.hpp @@ -33,6 +33,7 @@ class CLight; class CDamageInfo; class CMaterialFilter; class CFinalInput; +class CPlayer; class CWorld; class CTexture; @@ -57,6 +58,7 @@ class CStateManager std::unique_ptr x83c_aiWaypointObjs; std::unique_ptr x844_platformAndDoorObjs; + std::unique_ptr x84c_player; std::unique_ptr x850_world; /* Used to be a list of 32-element reserved_vectors */ @@ -125,6 +127,13 @@ class CStateManager u16 _dummy = 0; }; + float xf24_thermColdScale1 = 0.f; + float xf28_thermColdScale2 = 0.f; + float xf2c_ = 1.f; + float xf30_ = 1.f; + + void UpdateVisors(); + public: enum class EScriptPersistence { diff --git a/Runtime/Graphics/CBooRenderer.cpp b/Runtime/Graphics/CBooRenderer.cpp index 1b056b5fd..954c43e14 100644 --- a/Runtime/Graphics/CBooRenderer.cpp +++ b/Runtime/Graphics/CBooRenderer.cpp @@ -216,6 +216,12 @@ void CBooRenderer::SetThermal(bool, float, const zeus::CColor&) { } +void CBooRenderer::SetThermalColdScale(float scale) +{ + x2f8_thermColdScale = zeus::clamp(0.f, scale, 1.f); + m_thermColdFilter.setScale(x2f8_thermColdScale); +} + void CBooRenderer::DoThermalBlendCold() { } diff --git a/Runtime/Graphics/CBooRenderer.hpp b/Runtime/Graphics/CBooRenderer.hpp index fe91d60c6..935ce7b56 100644 --- a/Runtime/Graphics/CBooRenderer.hpp +++ b/Runtime/Graphics/CBooRenderer.hpp @@ -3,6 +3,7 @@ #include "IRenderer.hpp" #include "CDrawable.hpp" +#include "Shaders/CThermalColdFilter.hpp" namespace urde { @@ -31,6 +32,11 @@ class CBooRenderer : public IRenderer u32 x18_ = 0; std::list x1c_; zeus::CFrustum x44_frustumPlanes; + + float x2f8_thermColdScale = 0.f; + + CThermalColdFilter m_thermColdFilter; + public: CBooRenderer(IObjectStore& store, IFactory& resFac); @@ -86,6 +92,7 @@ public: void SetWorldFog(ERglFogMode, float, float, const zeus::CColor&); void RenderFogVolume(const zeus::CColor&, const zeus::CAABox&, const TLockedToken*, const CSkinnedModel*); void SetThermal(bool, float, const zeus::CColor&); + void SetThermalColdScale(float scale); void DoThermalBlendCold(); void DoThermalBlendHot(); u32 GetStaticWorldDataSize(); diff --git a/Runtime/Graphics/CMakeLists.txt b/Runtime/Graphics/CMakeLists.txt index 34d5e4286..9e47c4ce3 100644 --- a/Runtime/Graphics/CMakeLists.txt +++ b/Runtime/Graphics/CMakeLists.txt @@ -21,7 +21,7 @@ set(GRAPHICS_SOURCES CFrustumPlanes.hpp CFrustumPlanes.cpp CGraphicsPalette.hpp CGraphicsPalette.cpp CGraphics.hpp CGraphics.cpp - Shaders/TFilterShader.hpp Shaders/TFilterDecl.hpp + Shaders/TShader.hpp Shaders/TShaderDecl.hpp Shaders/CLineRendererShaders.hpp Shaders/CLineRendererShaders.cpp Shaders/CLineRendererShadersGLSL.cpp Shaders/CModelShaders.hpp Shaders/CModelShaders.cpp Shaders/CModelShadersGLSL.cpp Shaders/CXrayOutlineFilter.hpp Shaders/CXrayOutlineFilter.cpp Shaders/CXrayOutlineFilterGLSL.cpp diff --git a/Runtime/Graphics/IRenderer.hpp b/Runtime/Graphics/IRenderer.hpp index 99ac403c5..aa579faaa 100644 --- a/Runtime/Graphics/IRenderer.hpp +++ b/Runtime/Graphics/IRenderer.hpp @@ -90,6 +90,7 @@ public: virtual void SetWorldFog(ERglFogMode, float, float, const zeus::CColor&)=0; virtual void RenderFogVolume(const zeus::CColor&, const zeus::CAABox&, const TLockedToken*, const CSkinnedModel*)=0; virtual void SetThermal(bool, float, const zeus::CColor&)=0; + virtual void SetThermalColdScale(float scale)=0; virtual void DoThermalBlendCold()=0; virtual void DoThermalBlendHot()=0; virtual u32 GetStaticWorldDataSize()=0; diff --git a/Runtime/Graphics/Shaders/CThermalColdFilter.cpp b/Runtime/Graphics/Shaders/CThermalColdFilter.cpp index 1c3d7a34d..a9e64f020 100644 --- a/Runtime/Graphics/Shaders/CThermalColdFilter.cpp +++ b/Runtime/Graphics/Shaders/CThermalColdFilter.cpp @@ -8,10 +8,10 @@ CThermalColdFilter::CThermalColdFilter() { m_token = CGraphics::g_BooFactory->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool { - m_shiftTex = ctx.newDynamicTexture(8, 8, boo::TextureFormat::RGBA8); - m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, 32, 1); + m_shiftTex = ctx.newDynamicTexture(8, 4, boo::TextureFormat::RGBA8); + m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, 32, 4); m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1); - m_dataBind = TFilterShader::BuildShaderDataBinding(ctx, *this); + m_dataBind = TShader::BuildShaderDataBinding(ctx, *this); return true; }); @@ -23,12 +23,13 @@ CThermalColdFilter::CThermalColdFilter() { {{-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}}, - {{ 1.0, -1.0}, {1.0, 0.0}} }; m_vbo->load(verts, sizeof(verts)); setShift(0); + setScale(0.f); } void CThermalColdFilter::setShift(unsigned shift) @@ -45,8 +46,8 @@ void CThermalColdFilter::setShift(unsigned shift) if (ny > 3) ny = 3; unsigned nx = spx % 8; - m_shiftTexture[y][x][0] = nx / 7.f; - m_shiftTexture[y][x][1] = ny / 3.f; + m_shiftTexture[y][x][0] = nx * 255 / 7; + m_shiftTexture[y][x][1] = ny * 255 / 3; } } m_shiftTex->load(m_shiftTexture[0][0], sizeof(m_shiftTexture)); @@ -54,13 +55,21 @@ void CThermalColdFilter::setShift(unsigned shift) void CThermalColdFilter::draw() { - m_uniform.m_shiftTexMtx[0][0] = 80.f * CGraphics::g_ProjAspect; + SClipScreenRect clipRect = {}; + clipRect.xc_width = CGraphics::g_ViewportResolution.x; + clipRect.x10_height = CGraphics::g_ViewportResolution.y; + CGraphics::ResolveSpareTexture(clipRect); + + m_uniform.m_shiftTexMtx[0][0] = 80.f * (CGraphics::g_ProjAspect / 1.33f); m_uniform.m_shiftTexMtx[1][1] = 120.f; + m_uniform.m_shiftTexScale[0] = 1.f / m_uniform.m_shiftTexMtx[0][0]; + m_uniform.m_shiftTexScale[1] = 1.f / m_uniform.m_shiftTexMtx[1][1]; m_uniBuf->load(&m_uniform, sizeof(m_uniform)); + CGraphics::g_BooMainCommandQueue->setShaderDataBinding(m_dataBind); CGraphics::g_BooMainCommandQueue->draw(0, 4); } -URDE_SPECIALIZE_FILTER(CThermalColdFilter) +URDE_SPECIALIZE_SHADER(CThermalColdFilter) } diff --git a/Runtime/Graphics/Shaders/CThermalColdFilter.hpp b/Runtime/Graphics/Shaders/CThermalColdFilter.hpp index 64ae00243..ecea61f3d 100644 --- a/Runtime/Graphics/Shaders/CThermalColdFilter.hpp +++ b/Runtime/Graphics/Shaders/CThermalColdFilter.hpp @@ -1,7 +1,7 @@ #ifndef __URDE_CTHERMALCOLDFILTER_HPP__ #define __URDE_CTHERMALCOLDFILTER_HPP__ -#include "TFilterShader.hpp" +#include "TShader.hpp" #include "zeus/CMatrix4f.hpp" #include "zeus/CColor.hpp" @@ -17,6 +17,7 @@ class CThermalColdFilter { zeus::CMatrix4f m_shiftTexMtx; zeus::CMatrix4f m_indMtx; + zeus::CVector2f m_shiftTexScale; zeus::CColor m_colorRegs[3]; }; u8 m_shiftTexture[4][8][4] = {}; @@ -42,7 +43,7 @@ public: void draw(); using _CLS = CThermalColdFilter; -#include "TFilterDecl.hpp" +#include "TShaderDecl.hpp" }; } diff --git a/Runtime/Graphics/Shaders/CThermalColdFilterGLSL.cpp b/Runtime/Graphics/Shaders/CThermalColdFilterGLSL.cpp index d5ac4abe8..e70dba664 100644 --- a/Runtime/Graphics/Shaders/CThermalColdFilterGLSL.cpp +++ b/Runtime/Graphics/Shaders/CThermalColdFilterGLSL.cpp @@ -3,7 +3,7 @@ namespace urde { -static const char* VS_GLSL_TEX = +static const char* VS = "#version 330\n" BOO_GLSL_BINDING_HEAD "layout(location=0) in vec4 posIn;\n" @@ -13,6 +13,7 @@ BOO_GLSL_BINDING_HEAD "{\n" " mat4 shiftMtx;\n" " mat4 indMtx;\n" +" vec4 shiftScale;\n" " vec4 colorReg0;\n" " vec4 colorReg1;\n" " vec4 colorReg2;\n" @@ -26,6 +27,7 @@ BOO_GLSL_BINDING_HEAD " vec4 colorReg2;\n" " vec2 sceneUv;\n" " vec2 shiftUv;\n" +" vec2 shiftScale;\n" "};\n" "\n" "SBINDING(0) out VertToFrag vtf;\n" @@ -36,11 +38,12 @@ BOO_GLSL_BINDING_HEAD " vtf.colorReg1 = colorReg1;\n" " vtf.colorReg2 = colorReg2;\n" " vtf.sceneUv = uvIn.xy;\n" -" vtf.shiftUv = shiftMtx * uvIn;\n" -" gl_Position = FLIPFROMGL(posIn);\n" +" vtf.shiftUv = (mat3(shiftMtx) * uvIn.xyz).xy;\n" +" vtf.shiftScale = shiftScale.xy;\n" +" gl_Position = FLIPFROMGL(vec4(posIn.xyz, 1.0));\n" "}\n"; -static const char* FS_GLSL_TEX = +static const char* FS = "#version 330\n" BOO_GLSL_BINDING_HEAD "struct VertToFrag\n" @@ -51,7 +54,7 @@ BOO_GLSL_BINDING_HEAD " vec4 colorReg2;\n" " vec2 sceneUv;\n" " vec2 shiftUv;\n" -" vec2 shiftDelta;\n" +" vec2 shiftScale;\n" "};\n" "\n" "SBINDING(0) in VertToFrag vtf;\n" @@ -61,17 +64,23 @@ BOO_GLSL_BINDING_HEAD "const vec4 kRGBToYPrime = vec4(0.299, 0.587, 0.114, 0.0);\n" "void main()\n" "{\n" -" vec2 shiftCoord = vtf.sceneUv + texture(shiftTex, vtf.shiftUv).xy;\n" -" float shiftScene0 = dot(texture(sceneTex, shiftCoord - vec2(0.5)), kRGBToYPrime);\n" -" float shiftScene1 = dot(texture(sceneTex, shiftCoord - vec2(0.5, 0.4984375)), kRGBToYPrime);\n" -" vec2 indCoord = (indMtx * vec3(shiftScene0, shiftScene1, 1.0)).xy;\n" +" vec2 shiftCoordTexel = texture(shiftTex, vtf.shiftUv).xy;\n" +" vec2 shiftCoord = vtf.sceneUv + shiftCoordTexel * vtf.shiftScale;\n" +" float shiftScene0 = dot(texture(sceneTex, shiftCoord), kRGBToYPrime);\n" +" float shiftScene1 = dot(texture(sceneTex, shiftCoord + vec2(vtf.shiftScale.x / 8.0, 0.0)), kRGBToYPrime);\n" +" vec2 indCoord = (vtf.indMtx * vec3(shiftScene0 - 0.5, shiftScene1 - 0.5, 1.0)).xy;\n" " float indScene = dot(texture(sceneTex, vtf.sceneUv + indCoord), kRGBToYPrime);\n" -" colorOut = vtf.colorReg0 * indScene + vtf.colorReg1 * shiftScene0 + vtf.colorReg2;\n" +" colorOut = vtf.colorReg0 * indScene * vec4(0.00001) + vtf.colorReg1 * shiftScene0 * vec4(0.00001) + vtf.colorReg2 * vec4(0.00001);\n" +" float blue = 0.0;\n" +" float green = 0.0;\n" +" if (indCoord.y < 0.0) blue = -indCoord.y * 10.0;\n" +" else green = indCoord.y * 10.0;\n" +" colorOut += vec4(0.0, green, blue, 1.0);\n" "}\n"; -URDE_DECL_SPECIALIZE_FILTER(CThermalColdFilter) +URDE_DECL_SPECIALIZE_SHADER(CThermalColdFilter) -struct CThermalColdFilterGLDataBindingFactory : TFilterShader::IDataBindingFactory +struct CThermalColdFilterGLDataBindingFactory : TShader::IDataBindingFactory { boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CThermalColdFilter& filter) { @@ -85,14 +94,14 @@ struct CThermalColdFilterGLDataBindingFactory : TFilterShader::m_pipeline, + return cctx.newShaderDataBinding(TShader::m_pipeline, ctx.newVertexFormat(3, VtxVmt), filter.m_vbo, nullptr, nullptr, 1, bufs, stages, nullptr, nullptr, 2, texs); } }; #if BOO_HAS_VULKAN -struct CThermalColdFilterVulkanDataBindingFactory : TFilterShader::IDataBindingFactory +struct CThermalColdFilterVulkanDataBindingFactory : TShader::IDataBindingFactory { boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CThermalColdFilter& filter) { @@ -100,28 +109,28 @@ struct CThermalColdFilterVulkanDataBindingFactory : TFilterShader::m_pipeline, - TFilterShader::m_vtxFmt, + return cctx.newShaderDataBinding(TShader::m_pipeline, + TShader::m_vtxFmt, filter.m_vbo, nullptr, nullptr, 1, bufs, nullptr, nullptr, nullptr, 2, texs); } }; #endif -TFilterShader::IDataBindingFactory* CThermalColdFilter::Initialize(boo::GLDataFactory::Context& ctx, - boo::IShaderPipeline*& pipeOut) +TShader::IDataBindingFactory* CThermalColdFilter::Initialize(boo::GLDataFactory::Context& ctx, + boo::IShaderPipeline*& pipeOut) { const char* texNames[] = {"sceneTex", "shiftTex"}; const char* uniNames[] = {"ThermalColdUniform"}; - pipeOut = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, 2, texNames, 1, uniNames, boo::BlendFactor::One, + pipeOut = ctx.newShaderPipeline(VS, FS, 2, texNames, 1, uniNames, boo::BlendFactor::One, boo::BlendFactor::Zero, boo::Primitive::TriStrips, false, false, false); return new CThermalColdFilterGLDataBindingFactory; } #if BOO_HAS_VULKAN -TFilterShader::IDataBindingFactory* CThermalColdFilter::Initialize(boo::VulkanDataFactory::Context& ctx, - boo::IShaderPipeline*& pipeOut, - boo::IVertexFormat*& vtxFmtOut) +TShader::IDataBindingFactory* CThermalColdFilter::Initialize(boo::VulkanDataFactory::Context& ctx, + boo::IShaderPipeline*& pipeOut, + boo::IVertexFormat*& vtxFmtOut) { const boo::VertexElementDescriptor VtxVmt[] = { @@ -129,7 +138,7 @@ TFilterShader::IDataBindingFactory* CThermalColdFilter::Init {nullptr, nullptr, boo::VertexSemantic::UV4} }; vtxFmtOut = ctx.newVertexFormat(2, VtxVmt); - pipeOut = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, vtxFmtOut, boo::BlendFactor::One, + pipeOut = ctx.newShaderPipeline(VS, FS, vtxFmtOut, boo::BlendFactor::One, boo::BlendFactor::Zero, boo::Primitive::TriStrips, false, false, false); return new CThermalColdFilterVulkanDataBindingFactory; } diff --git a/Runtime/Graphics/Shaders/TFilterDecl.hpp b/Runtime/Graphics/Shaders/TFilterDecl.hpp deleted file mode 100644 index eec4c3042..000000000 --- a/Runtime/Graphics/Shaders/TFilterDecl.hpp +++ /dev/null @@ -1,17 +0,0 @@ - static TFilterShader<_CLS>::IDataBindingFactory* Initialize(boo::GLDataFactory::Context& ctx, - boo::IShaderPipeline*& pipeOut); -#if _WIN32 - static TFilterShader<_CLS>::IDataBindingFactory* Initialize(boo::ID3DDataFactory::Context& ctx, - boo::IShaderPipeline*& pipeOut, - boo::IVertexFormat*& vtxFmtOut); -#endif -#if BOO_HAS_METAL - static TFilterShader<_CLS>::IDataBindingFactory* Initialize(boo::MetalDataFactory::Context& ctx, - boo::IShaderPipeline*& pipeOut, - boo::IVertexFormat*& vtxFmtOut); -#endif -#if BOO_HAS_VULKAN - static TFilterShader<_CLS>::IDataBindingFactory* Initialize(boo::VulkanDataFactory::Context& ctx, - boo::IShaderPipeline*& pipeOut, - boo::IVertexFormat*& vtxFmtOut); -#endif diff --git a/Runtime/Graphics/Shaders/TFilterShader.hpp b/Runtime/Graphics/Shaders/TShader.hpp similarity index 80% rename from Runtime/Graphics/Shaders/TFilterShader.hpp rename to Runtime/Graphics/Shaders/TShader.hpp index e735d9cba..f6f759e6a 100644 --- a/Runtime/Graphics/Shaders/TFilterShader.hpp +++ b/Runtime/Graphics/Shaders/TShader.hpp @@ -1,5 +1,5 @@ -#ifndef __URDE_TFILTERSHADER_HPP__ -#define __URDE_TFILTERSHADER_HPP__ +#ifndef __URDE_TSHADER_HPP__ +#define __URDE_TSHADER_HPP__ #include "Graphics/CGraphics.hpp" #include "boo/graphicsdev/GL.hpp" @@ -11,7 +11,7 @@ namespace urde { template -class TFilterShader +class TShader { public: struct IDataBindingFactory @@ -75,25 +75,30 @@ public: } }; -#define URDE_DECL_SPECIALIZE_FILTER(cls) \ +#define URDE_DECL_SPECIALIZE_SHADER(cls) \ template <> boo::IShaderPipeline* \ -TFilterShader::m_pipeline; \ +TShader::m_pipeline; \ template <> boo::IVertexFormat* \ -TFilterShader::m_vtxFmt; - -#define URDE_SPECIALIZE_FILTER(cls) \ -template <> boo::IShaderPipeline* \ -TFilterShader::m_pipeline = nullptr; \ -template <> boo::IVertexFormat* \ -TFilterShader::m_vtxFmt = nullptr; \ +TShader::m_vtxFmt; \ \ -template <> std::unique_ptr::IDataBindingFactory> \ -TFilterShader::m_bindFactory; \ +template <> std::unique_ptr::IDataBindingFactory> \ +TShader::m_bindFactory; \ template <> boo::GraphicsDataToken \ -TFilterShader::m_gfxToken; \ +TShader::m_gfxToken; \ + +#define URDE_SPECIALIZE_SHADER(cls) \ +template <> boo::IShaderPipeline* \ +TShader::m_pipeline = nullptr; \ +template <> boo::IVertexFormat* \ +TShader::m_vtxFmt = nullptr; \ \ -template class TFilterShader; +template <> std::unique_ptr::IDataBindingFactory> \ +TShader::m_bindFactory = {}; \ +template <> boo::GraphicsDataToken \ +TShader::m_gfxToken = {}; \ +\ +template class TShader; } -#endif // __URDE_TFILTERSHADER_HPP__ +#endif // __URDE_TSHADER_HPP__ diff --git a/Runtime/Graphics/Shaders/TShaderDecl.hpp b/Runtime/Graphics/Shaders/TShaderDecl.hpp new file mode 100644 index 000000000..4e83c3730 --- /dev/null +++ b/Runtime/Graphics/Shaders/TShaderDecl.hpp @@ -0,0 +1,17 @@ + static TShader<_CLS>::IDataBindingFactory* Initialize(boo::GLDataFactory::Context& ctx, + boo::IShaderPipeline*& pipeOut); +#if _WIN32 + static TShader<_CLS>::IDataBindingFactory* Initialize(boo::ID3DDataFactory::Context& ctx, + boo::IShaderPipeline*& pipeOut, + boo::IVertexFormat*& vtxFmtOut); +#endif +#if BOO_HAS_METAL + static TShader<_CLS>::IDataBindingFactory* Initialize(boo::MetalDataFactory::Context& ctx, + boo::IShaderPipeline*& pipeOut, + boo::IVertexFormat*& vtxFmtOut); +#endif +#if BOO_HAS_VULKAN + static TShader<_CLS>::IDataBindingFactory* Initialize(boo::VulkanDataFactory::Context& ctx, + boo::IShaderPipeline*& pipeOut, + boo::IVertexFormat*& vtxFmtOut); +#endif diff --git a/Runtime/MP1/MP1.cpp b/Runtime/MP1/MP1.cpp index 62a288bc5..e542efd44 100644 --- a/Runtime/MP1/MP1.cpp +++ b/Runtime/MP1/MP1.cpp @@ -1,8 +1,10 @@ #include "MP1.hpp" #include "Graphics/Shaders/CModelShaders.hpp" +#include "Graphics/Shaders/CThermalColdFilter.hpp" namespace urde { +URDE_DECL_SPECIALIZE_SHADER(CThermalColdFilter) namespace MP1 { @@ -30,6 +32,7 @@ void CMain::InitializeSubsystems(boo::IGraphicsDataFactory* factory, { CGraphics::InitializeBoo(factory, cc, renderTex); CModelShaders::Initialize(storeMgr, factory); + TShader::Initialize(); CMoviePlayer::Initialize(); CLineRenderer::Initialize(); CElementGen::Initialize(); diff --git a/Runtime/World/CActor.hpp b/Runtime/World/CActor.hpp index 126f19ade..0ead184c1 100644 --- a/Runtime/World/CActor.hpp +++ b/Runtime/World/CActor.hpp @@ -82,6 +82,8 @@ public: const zeus::CTransform&, CModelData&&, const CMaterialList&, const CActorParameters&, TUniqueId); + const zeus::CTransform& GetTransform() const {return x34_transform;} + virtual void AddToRenderer(const zeus::CFrustum&, CStateManager&) {} virtual void Render(CStateManager&) {} virtual void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&); diff --git a/Runtime/World/CMakeLists.txt b/Runtime/World/CMakeLists.txt index eadd6fcd3..4b3e04777 100644 --- a/Runtime/World/CMakeLists.txt +++ b/Runtime/World/CMakeLists.txt @@ -3,6 +3,8 @@ set(WORLD_SOURCES CWorldLight.hpp CWorldLight.cpp IGameArea.hpp IGameArea.cpp CGameArea.hpp CGameArea.cpp + CPlayer.hpp CPlayer.cpp + CMorphBall.hpp CMorphBall.cpp CActor.hpp CActor.cpp CAi.hpp CAi.cpp CAiFuncMap.hpp CAiFuncMap.cpp diff --git a/Runtime/World/CMorphBall.cpp b/Runtime/World/CMorphBall.cpp new file mode 100644 index 000000000..b53e769e9 --- /dev/null +++ b/Runtime/World/CMorphBall.cpp @@ -0,0 +1,11 @@ +#include "CMorphBall.hpp" + +namespace urde +{ + +CMorphBall::CMorphBall(CPlayer& player, float) +: x0_player(player) +{ +} + +} diff --git a/Runtime/World/CMorphBall.hpp b/Runtime/World/CMorphBall.hpp new file mode 100644 index 000000000..7e08812f9 --- /dev/null +++ b/Runtime/World/CMorphBall.hpp @@ -0,0 +1,17 @@ +#ifndef __URDE_CMORPHBALL_HPP__ +#define __URDE_CMORPHBALL_HPP__ + +namespace urde +{ +class CPlayer; + +class CMorphBall +{ + CPlayer& x0_player; +public: + CMorphBall(CPlayer& player, float); +}; + +} + +#endif // __URDE_CMORPHBALL_HPP__ diff --git a/Runtime/World/CPlayer.cpp b/Runtime/World/CPlayer.cpp new file mode 100644 index 000000000..3f1fc80ef --- /dev/null +++ b/Runtime/World/CPlayer.cpp @@ -0,0 +1,21 @@ +#include "CPlayer.hpp" +#include "CActorParameters.hpp" +#include "CMorphBall.hpp" + +namespace urde +{ + +static CModelData MakePlayerAnimRes(ResId resId, const zeus::CVector3f& scale) +{ + return CAnimRes(resId, 0, scale, 0, true); +} + +CPlayer::CPlayer(TUniqueId uid, const zeus::CTransform& xf, const zeus::CAABox& aabb, unsigned int resId, + const zeus::CVector3f& playerScale, float f1, float f2, float f3, float f4, const CMaterialList& ml) +: CPhysicsActor(uid, true, "CPlayer", CEntityInfo(kInvalidAreaId, CEntity::NullConnectionList, kInvalidEditorId), + xf, MakePlayerAnimRes(resId, playerScale), ml, aabb, SMoverData(f1), CActorParameters::None(), f2, f3) +{ + x768_morphball.reset(new CMorphBall(*this, f4)); +} + +} diff --git a/Runtime/World/CPlayer.hpp b/Runtime/World/CPlayer.hpp new file mode 100644 index 000000000..eb17aa992 --- /dev/null +++ b/Runtime/World/CPlayer.hpp @@ -0,0 +1,24 @@ +#ifndef __URDE_CPLAYER_HPP__ +#define __URDE_CPLAYER_HPP__ + +#include "CPhysicsActor.hpp" +#include "zeus/CAABox.hpp" +#include "zeus/CTransform.hpp" + +namespace urde +{ +class CMaterialList; +class CMorphBall; + +class CPlayer : public CPhysicsActor +{ + std::unique_ptr x768_morphball; + +public: + CPlayer(TUniqueId, const zeus::CTransform&, const zeus::CAABox&, unsigned int, + const zeus::CVector3f&, float, float, float, float, const CMaterialList&); +}; + +} + +#endif // __URDE_CPLAYER_HPP__