From c6521b0cb12c22d2e9d8001950645c818f7b6ed9 Mon Sep 17 00:00:00 2001 From: powerof3 Date: Sat, 28 Dec 2024 19:17:16 +0530 Subject: [PATCH] RE shadow stuff --- cmake/sourcelist.cmake | 2 + include/RE/B/BSCullingProcess.h | 3 +- include/RE/B/BSLight.h | 66 ++++++++++---------- include/RE/B/BSShadowFrustumLight.h | 30 +++++++++ include/RE/B/BSShadowLight.h | 89 +++++++++++++-------------- include/RE/B/BSShadowParabolicLight.h | 27 ++++++++ include/RE/Skyrim.h | 2 + 7 files changed, 138 insertions(+), 81 deletions(-) create mode 100644 include/RE/B/BSShadowFrustumLight.h create mode 100644 include/RE/B/BSShadowParabolicLight.h diff --git a/cmake/sourcelist.cmake b/cmake/sourcelist.cmake index dd40ba122..8c16df98c 100644 --- a/cmake/sourcelist.cmake +++ b/cmake/sourcelist.cmake @@ -342,7 +342,9 @@ set(SOURCES include/RE/B/BSShaderPropertyLightData.h include/RE/B/BSShaderRenderTargets.h include/RE/B/BSShaderTextureSet.h + include/RE/B/BSShadowFrustumLight.h include/RE/B/BSShadowLight.h + include/RE/B/BSShadowParabolicLight.h include/RE/B/BSSimpleScaleController.h include/RE/B/BSSkyShaderProperty.h include/RE/B/BSSmallBlockAllocator.h diff --git a/include/RE/B/BSCullingProcess.h b/include/RE/B/BSCullingProcess.h index 8ed7fda88..9c8a64e9b 100644 --- a/include/RE/B/BSCullingProcess.h +++ b/include/RE/B/BSCullingProcess.h @@ -10,6 +10,7 @@ namespace RE class BSCompoundFrustum; class BSMultiBound; class BSOcclusionPlane; + class BSPortalGraphEntry; class NiAVObject; class NiBound; @@ -60,7 +61,7 @@ namespace RE std::uint64_t unk30178; // 30178 std::uint64_t unk30180; // 30180 std::uint64_t unk30188; // 30188 - void* unk30190; // 30190 + BSPortalGraphEntry* portalGraphEntry; // 30190 std::int32_t cullMode; // 30198 BSCompoundFrustum* compoundFrustum; // 301A0 std::uint64_t unk301A8; // 301A8 diff --git a/include/RE/B/BSLight.h b/include/RE/B/BSLight.h index 1236890ee..62f6dd0f4 100644 --- a/include/RE/B/BSLight.h +++ b/include/RE/B/BSLight.h @@ -25,12 +25,12 @@ namespace RE inline static constexpr auto VTABLE = VTABLE_BSLight; template - class FadeNodeListT : public NiTPointerList + class NodeListT : public NiTPointerList { public: - NiTListItem>* fence; // 18 + NiTListItem* fence; // 18 }; - static_assert(sizeof(FadeNodeListT) == 0x20); + static_assert(sizeof(NodeListT) == 0x20); ~BSLight() override; // 00 @@ -39,36 +39,36 @@ namespace RE virtual bool IsShadowLight(); // 03 // members - float luminance; // 010 - float lodDimmer; // 014 - FadeNodeListT> geomListFence; // 018 - std::uint64_t unk038; // 038 - std::uint32_t unk040; // 040 - bool pointLight; // 044 - bool ambientLight; // 045 - bool dynamic; // 046 - bool portalStrict; // 047 - NiPointer light; // 048 - NiPoint3 worldTranslate; // 050 - std::uint32_t frustrumCull; // 05C - std::uint8_t unk060; // 060 - bool affectLand; // 061 - bool affectWater; // 062 - bool neverFades; // 063 - std::uint32_t unk064; // 064 - NiTListItem>* fenceShape; // 068 - std::uint8_t unk070[96]; // 070 - std::uint8_t unk0D0; // 0D0 - std::uint8_t pad0D1; // 0D1 - std::uint16_t pad0D2; // 0D2 - std::uint32_t pad0D4; // 0D4 - BSTArray rooms; // 0D8 - BSTArray portals; // 0F0 - BSTArray portalSharedNodes; // 108 - BSPortalGraph* portalGraph; // 120 - BSCullingProcess* cullingProcess; // 128 - NiPointer objectNode; // 130 - BSLensFlareRenderData* lensFlareData; // 138 + float luminance; // 010 + float lodDimmer; // 014 + NodeListT> geomList; // 018 + std::uint64_t unk038; // 038 + std::uint32_t unk040; // 040 + bool pointLight; // 044 + bool ambientLight; // 045 + bool dynamic; // 046 + bool portalStrict; // 047 + NiPointer light; // 048 + NiPoint3 worldTranslate; // 050 + std::uint32_t frustrumCull; // 05C + std::uint8_t unk060; // 060 + bool affectLand; // 061 + bool affectWater; // 062 + bool neverFades; // 063 + std::uint32_t unk064; // 064 + NiTListItem>* geomListFence; // 068 + std::uint8_t unk070[96]; // 070 + std::uint8_t unk0D0; // 0D0 + std::uint8_t pad0D1; // 0D1 + std::uint16_t pad0D2; // 0D2 + std::uint32_t pad0D4; // 0D4 + BSTArray rooms; // 0D8 + BSTArray portals; // 0F0 + BSTArray portalSharedNodes; // 108 + BSPortalGraph* portalGraph; // 120 + BSCullingProcess* cullingProcess; // 128 + NiPointer objectNode; // 130 + BSLensFlareRenderData* lensFlareData; // 138 }; static_assert(sizeof(BSLight) == 0x140); } diff --git a/include/RE/B/BSShadowFrustumLight.h b/include/RE/B/BSShadowFrustumLight.h new file mode 100644 index 000000000..5726aaa21 --- /dev/null +++ b/include/RE/B/BSShadowFrustumLight.h @@ -0,0 +1,30 @@ +#pragma once + +#include "RE/B/BSShadowLight.h" + +namespace RE +{ + class BSShadowFrustumLight : public BSShadowLight + { + public: + inline static constexpr auto RTTI = RTTI_BSShadowFrustumLight; + inline static constexpr auto VTABLE = VTABLE_BSShadowFrustumLight; + + ~BSShadowFrustumLight() override; // 00 + + // override (BSShadowLight) + void Unk_04() override; // 04 + bool GetIsFrustumLight() override; // 05 + void Accumulate(std::uint32_t& a_globalShadowLightCount, std::uint32_t& a_shadowMaskChannel, NiPointer a_cullingScene) override; // 09 + void Render() override; // 0A + bool UpdateCamera(const NiCamera* a_viewCamera) override; // 10 + + // members + float xFOV; // 560 + float yFOV; // 564 + float falloff; // 568 + float nearDistance; // 56C + float farDistance; // 570 + }; + static_assert(sizeof(BSShadowFrustumLight) == 0x578); +} diff --git a/include/RE/B/BSShadowLight.h b/include/RE/B/BSShadowLight.h index 725abf849..cb2081c38 100644 --- a/include/RE/B/BSShadowLight.h +++ b/include/RE/B/BSShadowLight.h @@ -1,7 +1,8 @@ #pragma once #include "RE/B/BSLight.h" -#include "RE/N/NiPlane.h" +#include "RE/N/NiFrustumPlanes.h" +#include "RE/N/NiRect.h" namespace RE { @@ -11,60 +12,54 @@ namespace RE inline static constexpr auto RTTI = RTTI_BSShadowLight; inline static constexpr auto VTABLE = VTABLE_BSShadowLight; - struct Data + struct ShadowMapData { - std::uint8_t unk0[64]; // 00 - std::uint64_t unk40; // 40 - std::uint64_t unk48; // 48 - std::uint64_t unk50; // 50 - std::uint32_t unk58; // 58 - NiPlane planes[6]; // 5C - std::uint32_t unkBC; // BC - std::uint32_t unkC0; // C0 - std::uint32_t unkC4; // C4 - std::uint32_t unkCC; // CC - std::uint64_t unkD0; // D4 - std::uint32_t unkDC; // DC - std::uint64_t unkE0; // E0 - std::uint16_t unkE8; // E8 + REX::W32::XMFLOAT4X4 projection; // 00 + NiPointer camera; // 40 + NiPointer shaderAccumulator; // 48 + std::uint32_t unk50; // 50 + RENDER_TARGET_DEPTHSTENCIL renderTarget; // 54 + std::uint32_t shadowMapIndex; // 58 + NiFrustumPlanes clipPlanes; // 5C + std::uint32_t unitsPerTexel; // CC + NiRect shadowMapRect; // D0 + BSCullingProcess* cullingProcess; // E0 + bool clearRenderTarget; // E8 }; - static_assert(sizeof(Data) == 0xF0); + static_assert(sizeof(ShadowMapData) == 0xF0); ~BSShadowLight() override; // 00 // add - virtual void Unk_04(); // 04 - virtual void Unk_05(); // 05 - virtual void Unk_06(); // 06 - virtual void Unk_07(); // 07 - virtual void Unk_08(); // 08 - virtual void Unk_09() = 0; // 09 - virtual void Unk_0A() = 0; // 0A - virtual void Unk_0B(); // 0B - virtual void Unk_0C(); // 0C - virtual void Unk_0D(); // 0D - virtual void Unk_0E(); // 0E - virtual void Unk_0F(); // 0F - virtual void Unk_10() = 0; // 10 + virtual void Unk_04(); // 04 + virtual bool GetIsFrustumLight(); // 05 + virtual void GetIsDirectionalLight(); // 06 + virtual bool GetIsParabolicLight(); // 07 + virtual bool GetIsOmniLight(); // 08 + virtual void Accumulate(std::uint32_t& a_globalShadowLightCount, std::uint32_t& a_shadowMaskChannel, NiPointer a_cullingScene) = 0; // 09 + virtual void Render() = 0; // 0A + virtual void SetShadowMapCount(std::uint32_t a_count); // 0B + virtual void ClearShadowMapData(); // 0C + virtual void Unk_0D(); // 0D + virtual void Unk_0E(); // 0E + virtual void Unk_0F(); // 0F + virtual bool UpdateCamera(const NiCamera* a_viewCamera) = 0; // 10 // members - std::uint32_t unk140; // 140 - std::uint32_t unk144; // 144 - BSTArray unk148; // 148 - Data unk160[4]; // 161 - std::uint32_t maskIndex; // 520 - std::uint32_t unk524; // 524 - BSTArray unk528; // 528 - float shadowBiasScale; // 540 - std::uint32_t sceneGraphIndex; // 544 - std::uint32_t unk548; // 548 - std::uint32_t unk54C; // 54C - std::uint32_t unk550; // 550 - std::uint32_t unk554; // 554 - std::uint8_t unk558; // 558 - std::uint8_t pad559; // 559 - std::uint8_t pad55A; // 55A - std::uint32_t pad55B; // 55B + std::uint32_t shadowMapIndex; // 140 + std::uint32_t unk144; // 144 + BSTArray shadowMapDataList; // 148 + ShadowMapData shadowMapData[4]; // 161 + std::uint32_t maskIndex; // 520 + std::uint32_t accumulatedIndex; // 524 + BSTArray> sceneAccumArray; // 528 + float shadowBiasScale; // 540 + NiRect projectedBoundingBox; // 544 + std::uint32_t sceneGraphIndex; // 554 + std::uint8_t unk558; // 558 + std::uint8_t pad559; // 559 + std::uint8_t pad55A; // 55A + std::uint32_t pad55B; // 55B }; static_assert(sizeof(BSShadowLight) == 0x560); } diff --git a/include/RE/B/BSShadowParabolicLight.h b/include/RE/B/BSShadowParabolicLight.h new file mode 100644 index 000000000..3d117908b --- /dev/null +++ b/include/RE/B/BSShadowParabolicLight.h @@ -0,0 +1,27 @@ +#pragma once + +#include "RE/B/BSShadowLight.h" + +namespace RE +{ + class BSShadowParabolicLight : public BSShadowLight + { + public: + inline static constexpr auto RTTI = RTTI_BSShadowParabolicLight; + inline static constexpr auto VTABLE = VTABLE_BSShadowParabolicLight; + + ~BSShadowParabolicLight() override; // 00 + + // override (BSShadowLight) + bool GetIsParabolicLight() override; // 07 + bool GetIsOmniLight() override; // 08 + void Accumulate(std::uint32_t& a_globalShadowLightCount, std::uint32_t& a_shadowMaskChannel, NiPointer a_cullingScene) override; // 09 + void Render() override; // 0A + void SetShadowMapCount(std::uint32_t a_count) override; // 0B + void ClearShadowMapData() override; // 0C + void Unk_0D() override; // 0D + void Unk_0E() override; // 0E + bool UpdateCamera(const NiCamera* a_viewCamera) override; // 10 + }; + static_assert(sizeof(BSShadowParabolicLight) == 0x560); +} diff --git a/include/RE/Skyrim.h b/include/RE/Skyrim.h index ae0c52019..481488007 100644 --- a/include/RE/Skyrim.h +++ b/include/RE/Skyrim.h @@ -344,7 +344,9 @@ #include "RE/B/BSShaderPropertyLightData.h" #include "RE/B/BSShaderRenderTargets.h" #include "RE/B/BSShaderTextureSet.h" +#include "RE/B/BSShadowFrustumLight.h" #include "RE/B/BSShadowLight.h" +#include "RE/B/BSShadowParabolicLight.h" #include "RE/B/BSSimpleScaleController.h" #include "RE/B/BSSkyShaderProperty.h" #include "RE/B/BSSmallBlockAllocator.h"