From 27ca93178a60bdfd8aa1448a93bf10a28041da1d Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Thu, 18 Oct 2018 13:55:59 -1000 Subject: [PATCH] Upside-down OpenGL reflection fix --- .appveyor.yml | 20 ++++++++++---------- Runtime/Graphics/CBooRenderer.cpp | 2 +- Runtime/Graphics/CModelBoo.cpp | 18 +++++++++++++++++- hecl | 2 +- 4 files changed, 29 insertions(+), 13 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 195ce8eab..10b8583eb 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -61,16 +61,16 @@ build_script: - C:\projects\deps\cmake\cmake-3.10.1-win64-x64\bin\cmake.exe -GNinja .. - ninja -notifications: - - provider: Slack - incoming_webhook: - secure: uoO0I0PWyCx0KLjBOG6d17aSVuEEvYztB/UiF8J0LmTb2O735mAdWcuZHTImDFUGZxeI34/qzOB2JKqF+h8dZA5yiprSTkWIookqQjUokAM= - - provider: Webhook - url: https://skyhook.glitch.me/api/webhooks/345359672326356993/M8kBYpqr1JyVNhnAHBwNN5TnZmtWy9_msxAQoeOlaa73UhPn8gLU5uYZCjU1qsAi3sGN/appveyor - method: POST - on_build_success: true - on_build_failure: true - on_build_status_changed: false +#notifications: +# - provider: Slack +# incoming_webhook: +# secure: uoO0I0PWyCx0KLjBOG6d17aSVuEEvYztB/UiF8J0LmTb2O735mAdWcuZHTImDFUGZxeI34/qzOB2JKqF+h8dZA5yiprSTkWIookqQjUokAM= +# - provider: Webhook +# url: https://skyhook.glitch.me/api/webhooks/345359672326356993/M8kBYpqr1JyVNhnAHBwNN5TnZmtWy9_msxAQoeOlaa73UhPn8gLU5uYZCjU1qsAi3sGN/appveyor +# method: POST +# on_build_success: true +# on_build_failure: true +# on_build_status_changed: false # Uncomment this to debug AppVeyor failures. #on_finish: diff --git a/Runtime/Graphics/CBooRenderer.cpp b/Runtime/Graphics/CBooRenderer.cpp index f7a48941c..400366882 100644 --- a/Runtime/Graphics/CBooRenderer.cpp +++ b/Runtime/Graphics/CBooRenderer.cpp @@ -729,7 +729,7 @@ CBooRenderer::CBooRenderer(IObjectStore& store, IFactory& resFac) GenerateFogVolumeRampTex(ctx); GenerateSphereRampTex(ctx); m_ballShadowId = ctx.newRenderTexture(m_ballShadowIdW, m_ballShadowIdH, boo::TextureClampMode::Repeat, 1, 0); - x14c_reflectionTex = ctx.newRenderTexture(256, 256, boo::TextureClampMode::Repeat, 1, 0); + x14c_reflectionTex = ctx.newRenderTexture(256, 256, boo::TextureClampMode::ClampToBlack, 1, 0); GenerateScanLinesVBO(ctx); return true; } BooTrace); diff --git a/Runtime/Graphics/CModelBoo.cpp b/Runtime/Graphics/CModelBoo.cpp index 7de24bf3f..96f3ea6e6 100644 --- a/Runtime/Graphics/CModelBoo.cpp +++ b/Runtime/Graphics/CModelBoo.cpp @@ -64,6 +64,14 @@ static const zeus::CMatrix4f ReflectBaseMtx = 0.f, 0.f, 0.f, 1.f }; +static const zeus::CMatrix4f ReflectPostGL = +{ + 1.f, 0.f, 0.f, 0.f, + 0.f, -1.f, 0.f, 1.f, + 0.f, 0.f, 1.f, 0.f, + 0.f, 0.f, 0.f, 1.f +}; + void CBooModel::EnsureViewDepStateCached(const CBooModel& model, const CBooSurface* surf, zeus::CMatrix4f* mtxsOut, float& alphaOut) { @@ -128,6 +136,14 @@ void CBooModel::EnsureViewDepStateCached(const CBooModel& model, const CBooSurfa mtxsOut[1][3][0] = -surfPos.dot(v2) * f1 + 0.5f; mtxsOut[1][2][1] = f2; mtxsOut[1][3][1] = -modelToPlayerLocal.z * f2; + switch (CGraphics::g_BooPlatform) + { + case boo::IGraphicsDataFactory::Platform::OpenGL: + mtxsOut[1] = ReflectPostGL * mtxsOut[1]; + break; + default: + break; + } } } @@ -1200,7 +1216,7 @@ SShader::BuildShader(const hecl::HMDLMeta& meta, const MaterialSet::Material& ma hecl::Backend::ReflectionType reflectionType; if (mat.flags.samusReflectionIndirectTexture()) reflectionType = hecl::Backend::ReflectionType::Indirect; - else if (mat.flags.samusReflection()) + else if (mat.flags.samusReflection() || mat.flags.samusReflectionSurfaceEye()) reflectionType = hecl::Backend::ReflectionType::Simple; else reflectionType = hecl::Backend::ReflectionType::None; diff --git a/hecl b/hecl index 2ef53263a..2ffa49b86 160000 --- a/hecl +++ b/hecl @@ -1 +1 @@ -Subproject commit 2ef53263a09a8a99ec73e86b23283d7275db23c0 +Subproject commit 2ffa49b8667479c6a5db31d41889d0452183a83b