diff --git a/Runtime/AutoMapper/CMappableObject.cpp b/Runtime/AutoMapper/CMappableObject.cpp index 23b4d99ab..ab4ad79de 100644 --- a/Runtime/AutoMapper/CMappableObject.cpp +++ b/Runtime/AutoMapper/CMappableObject.cpp @@ -16,7 +16,7 @@ zeus::CTransform CMappableObject::AdjustTransformForType() zeus::CTransform scale; scale.scaleBy(1.5); zeus::CTransform orientation; - orientation.origin = {-1.4*doorCenterX, 0.0f, 0.0f}; + orientation.origin = {-1.4f*doorCenterX, 0.0f, 0.0f}; zeus::CTransform tmp3 = x10_ * orientation; orientation.rotateLocalZ(zeus::degToRad(90.0f)); return tmp3 * scale; diff --git a/Runtime/Graphics/CModelBoo.cpp b/Runtime/Graphics/CModelBoo.cpp index 3d092ce10..345dfa3b0 100644 --- a/Runtime/Graphics/CModelBoo.cpp +++ b/Runtime/Graphics/CModelBoo.cpp @@ -1,3 +1,6 @@ +#if _WIN32 +#include +#endif #include "Graphics/CModel.hpp" #include "Graphics/CTexture.hpp" #include "Graphics/CGraphics.hpp" diff --git a/Runtime/Graphics/Shaders/CModelShadersHLSL.cpp b/Runtime/Graphics/Shaders/CModelShadersHLSL.cpp index 3e7a6f5fc..1dad9d3d7 100644 --- a/Runtime/Graphics/Shaders/CModelShadersHLSL.cpp +++ b/Runtime/Graphics/Shaders/CModelShadersHLSL.cpp @@ -43,11 +43,31 @@ static const char* LightingHLSL = " return saturate(ret);\n" "}\n"; +static const char* ThermalPostHLSL = +"cbuffer ThermalUniform : register(b2)\n" +"{\n" +" float4 mulColor;\n" +" float4 addColor;\n" +"};\n" +"float4 ThermalPostFunc(in VertToFrag vtf, float4 colorIn)\n" +"{\n" +" return extTex7.Sample(samp, vtf.extTcgs[0]).rrrr * mulColor + addColor;\n" +"}\n" +"\n"; + hecl::Runtime::ShaderCacheExtensions CModelShaders::GetShaderExtensionsHLSL(boo::IGraphicsDataFactory::Platform plat) { hecl::Runtime::ShaderCacheExtensions ext(plat); - ext.registerExtensionSlot({LightingHLSL, "LightingFunc"}, {}, 0, nullptr); + + /* Normal lit shading */ + ext.registerExtensionSlot({LightingHLSL, "LightingFunc"}, {}, 0, nullptr, 0, nullptr, + hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original); + + /* Thermal Visor shading */ + ext.registerExtensionSlot({}, {ThermalPostHLSL, "ThermalPostFunc"}, 0, nullptr, 1, ThermalTextures, + hecl::Backend::BlendFactor::One, hecl::Backend::BlendFactor::One); + return ext; } diff --git a/Runtime/Graphics/Shaders/CSpaceWarpFilter.cpp b/Runtime/Graphics/Shaders/CSpaceWarpFilter.cpp index f000a6059..946133946 100644 --- a/Runtime/Graphics/Shaders/CSpaceWarpFilter.cpp +++ b/Runtime/Graphics/Shaders/CSpaceWarpFilter.cpp @@ -113,7 +113,7 @@ void CSpaceWarpFilter::draw(const zeus::CVector3f& pt) } /* Transform UV coordinates of rectangle within viewport and sampled scene texels (clamped to viewport bounds) */ - zeus::CVector2f vp{CGraphics::g_ViewportResolution.x, CGraphics::g_ViewportResolution.y}; + zeus::CVector2f vp{float(CGraphics::g_ViewportResolution.x), float(CGraphics::g_ViewportResolution.y)}; m_uniform.m_matrix[0][0] = clipRect.xc_width / vp.x; m_uniform.m_matrix[1][1] = clipRect.x10_height / vp.y; m_uniform.m_matrix[3][0] = pt.x + (1.f / vp.x); diff --git a/Runtime/Graphics/Shaders/CSpaceWarpFilter.hpp b/Runtime/Graphics/Shaders/CSpaceWarpFilter.hpp index c10685e5e..4300e0626 100644 --- a/Runtime/Graphics/Shaders/CSpaceWarpFilter.hpp +++ b/Runtime/Graphics/Shaders/CSpaceWarpFilter.hpp @@ -13,6 +13,7 @@ class CSpaceWarpFilter friend struct CSpaceWarpFilterGLDataBindingFactory; friend struct CSpaceWarpFilterVulkanDataBindingFactory; friend struct CSpaceWarpFilterMetalDataBindingFactory; + friend struct CSpaceWarpFilterD3DDataBindingFactory; struct Uniform { diff --git a/Runtime/Graphics/Shaders/CSpaceWarpFilterHLSL.cpp b/Runtime/Graphics/Shaders/CSpaceWarpFilterHLSL.cpp index e69de29bb..3886955bd 100644 --- a/Runtime/Graphics/Shaders/CSpaceWarpFilterHLSL.cpp +++ b/Runtime/Graphics/Shaders/CSpaceWarpFilterHLSL.cpp @@ -0,0 +1,89 @@ +#include "CSpaceWarpFilter.hpp" + +namespace urde +{ + +static const char* VS = +"struct VertData\n" +"{\n" +" float4 posIn : POSITION;\n" +" float4 uvIn : UV;\n" +"};\n" +"cbuffer SpaceWarpUniform : register(b0)\n" +"{\n" +" float4x4 mainMtx;\n" +" float4x4 indMtx;\n" +" float4 strength;\n" +"};\n" +"\n" +"struct VertToFrag\n" +"{\n" +" float4 position : SV_Position;\n" +" float2 sceneUv : SCENEUV;\n" +" float2 indUv : INDV;\n" +" float2 strength : STRENGTH;\n" +"};\n" +"\n" +"VertToFrag main(in VertData v)\n" +"{\n" +" VertToFrag vtf;\n" +" vtf.position = mul(mainMtx, float4(v.posIn.xy, 0.0, 1.0));\n" +" vtf.sceneUv = vtf.position.xy * float2(0.5, 0.5) + float2(0.5, 0.5);\n" +" vtf.sceneUv.y = -vtf.sceneUv.y;\n" +" vtf.indUv = mul(float3x3(indMtx[0].xyz, indMtx[1].xyz, indMtx[2].xyz), float3(v.uvIn.xy, 1.0)).xy;\n" +" vtf.indUv.y = -vtf.indUv.y;\n" +" vtf.strength = strength.xy;\n" +" return vtf;\n" +"}\n"; + +static const char* FS = +"Texture2D sceneTex : register(t0);\n" +"Texture2D indTex : register(t1);\n" +"SamplerState samp : register(s0);\n" +"struct VertToFrag\n" +"{\n" +" float4 position : SV_Position;\n" +" float2 sceneUv : SCENEUV;\n" +" float2 indUv : INDV;\n" +" float2 strength : STRENGTH;\n" +"};\n" +"\n" +"float4 main(in VertToFrag vtf) : SV_Target0\n" +"{\n" +" return sceneTex.Sample(samp, vtf.sceneUv + (indTex.Sample(samp, vtf.indUv).xy * float2(2.0, 2.0) - float2(1.0 - 1.0 / 256.0, 1.0 - 1.0 / 256.0)) * vtf.strength.xy);\n" +"}\n"; + +URDE_DECL_SPECIALIZE_SHADER(CSpaceWarpFilter) + +struct CSpaceWarpFilterD3DDataBindingFactory : TShader::IDataBindingFactory +{ + boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CSpaceWarpFilter& filter) + { + boo::ID3DDataFactory::Context& cctx = static_cast(ctx); + + boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; + boo::ITexture* texs[] = {CGraphics::g_SpareTexture, filter.m_warpTex}; + return cctx.newShaderDataBinding(TShader::m_pipeline, + TShader::m_vtxFmt, + filter.m_vbo, nullptr, nullptr, 1, bufs, + nullptr, nullptr, nullptr, 2, texs); + } +}; + +TShader::IDataBindingFactory* CSpaceWarpFilter::Initialize(boo::ID3DDataFactory::Context& ctx, + boo::IShaderPipeline*& pipeOut, + boo::IVertexFormat*& vtxFmtOut) +{ + const boo::VertexElementDescriptor VtxVmt[] = + { + {nullptr, nullptr, boo::VertexSemantic::Position4}, + {nullptr, nullptr, boo::VertexSemantic::UV4} + }; + vtxFmtOut = ctx.newVertexFormat(2, VtxVmt); + pipeOut = ctx.newShaderPipeline(VS, FS, ComPtr(), ComPtr(), ComPtr(), + vtxFmtOut, boo::BlendFactor::One, + boo::BlendFactor::Zero, boo::Primitive::TriStrips, false, false, false); + return new CSpaceWarpFilterD3DDataBindingFactory; +} + +} diff --git a/Runtime/Graphics/Shaders/CThermalColdFilter.hpp b/Runtime/Graphics/Shaders/CThermalColdFilter.hpp index 39afa0457..e49de8a4f 100644 --- a/Runtime/Graphics/Shaders/CThermalColdFilter.hpp +++ b/Runtime/Graphics/Shaders/CThermalColdFilter.hpp @@ -13,6 +13,7 @@ class CThermalColdFilter friend struct CThermalColdFilterGLDataBindingFactory; friend struct CThermalColdFilterVulkanDataBindingFactory; friend struct CThemalColdFilterMetalDataBindingFactory; + friend struct CThemalColdFilterD3DDataBindingFactory; struct Uniform { diff --git a/Runtime/Graphics/Shaders/CThermalColdFilterHLSL.cpp b/Runtime/Graphics/Shaders/CThermalColdFilterHLSL.cpp index e93febdcd..17f393361 100644 --- a/Runtime/Graphics/Shaders/CThermalColdFilterHLSL.cpp +++ b/Runtime/Graphics/Shaders/CThermalColdFilterHLSL.cpp @@ -3,11 +3,108 @@ namespace urde { -TShader::IDataBindingFactory* CThermalColdFilter::Initialize(boo::ID3DDataFactory::Context& ctx, - boo::IShaderPipeline*& pipeOut, - boo::IVertexFormat*& vtxFmtOut) +static const char* VS = +"struct VertData\n" +"{\n" +" float4 posIn : POSITION;\n" +" float4 uvIn : UV;\n" +"};\n" +"\n" +"cbuffer ThermalColdUniform : register(b0)\n" +"{\n" +" float4x4 shiftMtx;\n" +" float4x4 indMtx;\n" +" float4 shiftScale;\n" +" float4 colorReg0;\n" +" float4 colorReg1;\n" +" float4 colorReg2;\n" +"};\n" +"\n" +"struct VertToFrag\n" +"{\n" +" float4 position : SV_Position;\n" +" float3x3 indMtx : INDMTX;\n" +" float4 colorReg0 : COLORREG0;\n" +" float4 colorReg1 : COLORREG1;\n" +" float4 colorReg2 : COLORREG2;\n" +" float2 sceneUv : SCENEUV;\n" +" float2 shiftUv : SHIFTUV;\n" +" float2 shiftScale : SHIFTSCALE;\n" +"};\n" +"\n" +"VertToFrag main(in VertData v)\n" +"{\n" +" VertToFrag vtf;\n" +" vtf.indMtx = float3x3(indMtx[0].xyz, indMtx[1].xyz, indMtx[2].xyz);\n" +" vtf.colorReg0 = colorReg0;\n" +" vtf.colorReg1 = colorReg1;\n" +" vtf.colorReg2 = colorReg2;\n" +" vtf.sceneUv = v.uvIn.xy;\n" +" vtf.shiftUv = (mul(float3x3(shiftMtx[0].xyz, shiftMtx[1].xyz, shiftMtx[2].xyz), v.uvIn.xyz)).xy;\n" +" vtf.shiftScale = shiftScale.xy;\n" +" vtf.position = float4(v.posIn.xyz, 1.0);\n" +" return vtf;\n" +"}\n"; + +static const char* FS = +"Texture2D sceneTex : register(t0);\n" +"Texture2D shiftTex : register(t1);\n" +"SamplerState samp : register(s0);\n" +"struct VertToFrag\n" +"{\n" +" float4 position : SV_Position;\n" +" float3x3 indMtx : INDMTX;\n" +" float4 colorReg0 : COLORREG0;\n" +" float4 colorReg1 : COLORREG1;\n" +" float4 colorReg2 : COLORREG2;\n" +" float2 sceneUv : SCENEUV;\n" +" float2 shiftUv : SHIFTUV;\n" +" float2 shiftScale : SHIFTSCALE;\n" +"};\n" +"\n" +"static const float4 kRGBToYPrime = {0.299, 0.587, 0.114, 0.0};\n" +"float4 main(in VertToFrag vtf) : SV_Target0\n" +"{\n" +" float2 shiftCoordTexel = shiftTex.Sample(samp, vtf.shiftUv).xy;\n" +" float2 shiftCoord = vtf.sceneUv + shiftCoordTexel * vtf.shiftScale;\n" +" float shiftScene0 = dot(sceneTex.Sample(samp, shiftCoord), kRGBToYPrime);\n" +" float shiftScene1 = dot(sceneTex.Sample(samp, shiftCoord + float2(vtf.shiftScale.x / 8.0, 0.0)), kRGBToYPrime);\n" +" float2 indCoord = (mul(vtf.indMtx, float3(shiftScene0 - 0.5, shiftScene1 - 0.5, 1.0))).xy;\n" +" float indScene = dot(sceneTex.Sample(samp, vtf.sceneUv + indCoord), kRGBToYPrime);\n" +" return vtf.colorReg0 * indScene + vtf.colorReg1 * shiftScene0 + vtf.colorReg2;\n" +"}\n"; + +URDE_DECL_SPECIALIZE_SHADER(CThermalColdFilter) + +struct CThemalColdFilterD3DDataBindingFactory : TShader::IDataBindingFactory { - return nullptr; + boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CThermalColdFilter& filter) + { + boo::ID3DDataFactory::Context& cctx = static_cast(ctx); + + boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; + boo::ITexture* texs[] = {CGraphics::g_SpareTexture, filter.m_shiftTex}; + return cctx.newShaderDataBinding(TShader::m_pipeline, + TShader::m_vtxFmt, + filter.m_vbo, nullptr, nullptr, 1, bufs, + nullptr, nullptr, nullptr, 2, texs); + } +}; + +TShader::IDataBindingFactory* CThermalColdFilter::Initialize(boo::ID3DDataFactory::Context& ctx, + boo::IShaderPipeline*& pipeOut, + boo::IVertexFormat*& vtxFmtOut) +{ + const boo::VertexElementDescriptor VtxVmt[] = + { + {nullptr, nullptr, boo::VertexSemantic::Position4}, + {nullptr, nullptr, boo::VertexSemantic::UV4} + }; + vtxFmtOut = ctx.newVertexFormat(2, VtxVmt); + pipeOut = ctx.newShaderPipeline(VS, FS, ComPtr(), ComPtr(), ComPtr(), + vtxFmtOut, boo::BlendFactor::One, + boo::BlendFactor::Zero, boo::Primitive::TriStrips, false, false, false); + return new CThemalColdFilterD3DDataBindingFactory; } } diff --git a/Runtime/World/CGameArea.cpp b/Runtime/World/CGameArea.cpp index 886c52b3c..595f129d0 100644 --- a/Runtime/World/CGameArea.cpp +++ b/Runtime/World/CGameArea.cpp @@ -1,3 +1,6 @@ +#if _WIN32 +#include +#endif #include "CGameArea.hpp" #include "GameGlobalObjects.hpp" #include "Graphics/CBooRenderer.hpp" diff --git a/Runtime/World/CWorld.cpp b/Runtime/World/CWorld.cpp index ab5aa7882..81924c7af 100644 --- a/Runtime/World/CWorld.cpp +++ b/Runtime/World/CWorld.cpp @@ -4,6 +4,7 @@ #include "CSimplePool.hpp" #include "CStateManager.hpp" #include "CInGameTweakManagerBase.hpp" +#include "Audio/CAudioGroupSet.hpp" namespace urde { diff --git a/hecl b/hecl index cc98390bd..883076358 160000 --- a/hecl +++ b/hecl @@ -1 +1 @@ -Subproject commit cc98390bdb08dd2a83c6b2a6b7c92dc6c4e20fac +Subproject commit 8830763583627a50b755d1e9ef4a02ec76c91c6f diff --git a/kabufuda b/kabufuda index d242e2deb..d0791ebd2 160000 --- a/kabufuda +++ b/kabufuda @@ -1 +1 @@ -Subproject commit d242e2deb63b2fc6da526e7245d4dfa487731af4 +Subproject commit d0791ebd2172d2adb85ab5bc32bbbb3a6d40f29f