From 05a52c00be0a9fa3a51aa12a199bd83404a04b70 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Sat, 30 Jul 2016 18:46:03 -1000 Subject: [PATCH] Fixes for extended shaders --- Editor/ViewManager.cpp | 6 +++++- Runtime/Graphics/CBooRenderer.cpp | 5 +++++ Runtime/Graphics/CModel.hpp | 2 +- Runtime/Graphics/CModelBoo.cpp | 2 +- Runtime/Graphics/Shaders/CModelShadersGLSL.cpp | 11 ++++++----- hecl | 2 +- 6 files changed, 19 insertions(+), 9 deletions(-) diff --git a/Editor/ViewManager.cpp b/Editor/ViewManager.cpp index ec22a8748..32d6906de 100644 --- a/Editor/ViewManager.cpp +++ b/Editor/ViewManager.cpp @@ -75,7 +75,11 @@ void ViewManager::ParticleView::draw(boo::IGraphicsCommandQueue *gfxQ) if (m_vm.m_modelTest.IsLoaded()) { CModelFlags flags; - flags.m_extendedShaderIdx = 1; + flags.addColor.r = 0.0f; + + flags.m_extendedShaderIdx = 2; + if (std::fmod(m_theta, M_PIF) < M_PIF / 2.f) + flags.m_extendedShaderIdx = 1; m_theta += 0.01f; CGraphics::SetModelMatrix(zeus::CTransform::RotateZ(m_theta) * zeus::CTransform::Scale(10.f)); diff --git a/Runtime/Graphics/CBooRenderer.cpp b/Runtime/Graphics/CBooRenderer.cpp index 30775297e..feadaf18c 100644 --- a/Runtime/Graphics/CBooRenderer.cpp +++ b/Runtime/Graphics/CBooRenderer.cpp @@ -584,6 +584,11 @@ void CBooRenderer::DrawSpaceWarp(const zeus::CVector3f& pt, float strength) void CBooRenderer::DrawThermalModel(const CModel& model, const zeus::CColor& mulCol, const zeus::CColor& addCol) { + CModelFlags flags; + flags.m_extendedShaderIdx = 2; + flags.color = mulCol; + flags.addColor = addCol; + model.Draw(flags); } void CBooRenderer::DrawXRayOutline(const CModel&, const float*, const float*) diff --git a/Runtime/Graphics/CModel.hpp b/Runtime/Graphics/CModel.hpp index d3e2e7826..aac144322 100644 --- a/Runtime/Graphics/CModel.hpp +++ b/Runtime/Graphics/CModel.hpp @@ -25,7 +25,7 @@ struct CModelFlags u8 m_extendedShaderIdx = 0; /* 0 for shadeless, 1 for lighting, others defined in CModelShaders */ u16 m_flags = 0; /* Flags */ zeus::CColor color; /* Set into kcolor slot specified by material */ - zeus::CColor addColor; + zeus::CColor addColor = zeus::CColor::skClear; CModelFlags() = default; CModelFlags(u8 blendMode, u8 shadIdx, u16 flags, const zeus::CColor& col) diff --git a/Runtime/Graphics/CModelBoo.cpp b/Runtime/Graphics/CModelBoo.cpp index 097e4ace4..05974565d 100644 --- a/Runtime/Graphics/CModelBoo.cpp +++ b/Runtime/Graphics/CModelBoo.cpp @@ -450,7 +450,7 @@ void CBooModel::UVAnimationBuffer::Update(u8*& bufOut, const MaterialSet* matSet u8* bufOrig = bufOut; for (const UVAnimation& anim : mat.uvAnims) ProcessAnimation(bufOut, anim); - bufOut = bufOrig + sizeof(zeus::CMatrix4f) * 2; + bufOut = bufOrig + sizeof(zeus::CMatrix4f) * 2 * 8; PadOutBuffer(start, bufOut); } } diff --git a/Runtime/Graphics/Shaders/CModelShadersGLSL.cpp b/Runtime/Graphics/Shaders/CModelShadersGLSL.cpp index c5cc59d03..76de712bc 100644 --- a/Runtime/Graphics/Shaders/CModelShadersGLSL.cpp +++ b/Runtime/Graphics/Shaders/CModelShadersGLSL.cpp @@ -50,10 +50,9 @@ static const char* ThermalPostGLSL = " vec4 mulColor;\n" " vec4 addColor;\n" "};\n" -"TBINDING7 uniform sampler2D thermalLookup;\n" "vec4 ThermalPostFunc(vec4 colorIn)\n" "{\n" -" return texture(thermalLookup, vtf.extTcgs[0]).rrrr * mulColor + addColor;\n" +" return texture(tex7, vtf.extTcgs[0]).rrrr * mulColor + addColor;\n" "}\n" "\n"; @@ -67,7 +66,7 @@ static const char* ThermalBlockNames[] = {HECL_GLSL_VERT_UNIFORM_BLOCK_NAME, static const hecl::Backend::TextureInfo ThermalTextures[] = { - {hecl::Backend::TexGenSrc::Normal, 0, 7, true} + {hecl::Backend::TexGenSrc::Normal, 7, 0, 7, true} }; hecl::Runtime::ShaderCacheExtensions @@ -76,10 +75,12 @@ CModelShaders::GetShaderExtensionsGLSL(boo::IGraphicsDataFactory::Platform plat) hecl::Runtime::ShaderCacheExtensions ext(plat); /* Normal lit shading */ - ext.registerExtensionSlot({LightingGLSL, "LightingFunc"}, {}, 3, BlockNames, 0, nullptr); + ext.registerExtensionSlot({LightingGLSL, "LightingFunc"}, {}, 3, BlockNames, 0, nullptr, + hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original); /* Thermal Visor shading */ - ext.registerExtensionSlot({}, {ThermalPostGLSL, "ThermalPostFunc"}, 3, ThermalBlockNames, 1, ThermalTextures); + ext.registerExtensionSlot({}, {ThermalPostGLSL, "ThermalPostFunc"}, 3, ThermalBlockNames, 1, ThermalTextures, + hecl::Backend::BlendFactor::One, hecl::Backend::BlendFactor::One); return ext; } diff --git a/hecl b/hecl index 956e4874d..3f47a0524 160000 --- a/hecl +++ b/hecl @@ -1 +1 @@ -Subproject commit 956e4874dd95c06bf7d9ebd675774143c59db4b7 +Subproject commit 3f47a0524451e46c73915e81de85e0a926a29e12