diff --git a/include/RE/B/BSLightingShaderProperty.h b/include/RE/B/BSLightingShaderProperty.h index 6cd654d64..0a7232278 100644 --- a/include/RE/B/BSLightingShaderProperty.h +++ b/include/RE/B/BSLightingShaderProperty.h @@ -6,6 +6,9 @@ namespace RE { + class BSShader; + class BSLight; + class BSLightingShaderProperty : public BSShaderProperty { public: @@ -15,8 +18,14 @@ namespace RE struct Data { - std::uint64_t unk00; // 00 - std::uint64_t unk08; // 08 + void Clear(); + BSRenderPass* EmplacePass(BSShader* a_shader, BSShaderProperty* a_property, BSGeometry* a_geometry, + uint32_t a_technique, uint8_t a_numLights = 0, BSLight* a_light0 = nullptr, BSLight* a_light1 = nullptr, + BSLight* a_light2 = nullptr, BSLight* a_light3 = nullptr); + + // members + RE::BSRenderPass* head; // 00 + std::uint64_t unk08; // 08 }; static_assert(sizeof(Data) == 0x10); diff --git a/include/RE/B/BSRenderPass.h b/include/RE/B/BSRenderPass.h index 952305a97..1a5f05414 100644 --- a/include/RE/B/BSRenderPass.h +++ b/include/RE/B/BSRenderPass.h @@ -17,6 +17,13 @@ namespace RE }; static_assert(sizeof(LODMode) == 0x1); + void ClearRenderPass() + { + using func_t = decltype(&BSRenderPass::ClearRenderPass); + static REL::Relocation func{ RELOCATION_ID(100718, 107498) }; + func(this); + } + // members BSShader* shader; // 00 BSShaderProperty* shaderProperty; // 08 diff --git a/include/RE/B/BSShader.h b/include/RE/B/BSShader.h index e4c2d339f..8fc10845c 100644 --- a/include/RE/B/BSShader.h +++ b/include/RE/B/BSShader.h @@ -1,6 +1,7 @@ #pragma once #include "RE/B/BSReloadShaderI.h" +#include "RE/B/BSTHashMap.h" #include "RE/N/NiBoneMatrixSetterI.h" #include "RE/N/NiRefObject.h" @@ -99,6 +100,13 @@ namespace RE virtual void GetTechniqueName(std::uint32_t a_techniqueID, char* a_buffer, std::uint32_t a_bufferSize); // 08 virtual void ReloadShaders(bool a_clear); // 09 + RE::BSRenderPass* MakeRenderPass(BSShaderProperty* property, BSGeometry* geometry, uint32_t technique, uint8_t numLights, BSLight** lights) + { + using func_t = decltype(&BSShader::MakeRenderPass); + static REL::Relocation func{ RELOCATION_ID(100717, 107497) }; + return func(this, property, geometry, technique, numLights, lights); + } + // members std::int32_t shaderType; // 20 BSShaderTechniqueIDMap::MapType vertexShaders; // 28 diff --git a/include/RE/B/BSShaderProperty.h b/include/RE/B/BSShaderProperty.h index 413bcfd31..b6eab3fdc 100644 --- a/include/RE/B/BSShaderProperty.h +++ b/include/RE/B/BSShaderProperty.h @@ -12,8 +12,6 @@ namespace RE class BSShaderMaterial; class BSShaderPropertyLightData; class NiSourceTexture; - class BSShader; - class BSLight; class BSShaderProperty : public NiShadeProperty { @@ -39,13 +37,6 @@ namespace RE struct RenderPassArray { - BSRenderPass* MakeRenderPass(BSShader* a_shader, BSShaderProperty* a_property, BSGeometry* a_geometry, uint32_t a_technique, uint8_t a_numLights, BSLight** a_lights); - void ClearRenderPass(BSRenderPass* a_pass); - void Clear(); - BSRenderPass* EmplacePass(BSShader* a_shader, BSShaderProperty* a_property, BSGeometry* a_geometry, - uint32_t a_technique, uint8_t a_numLights = 0, BSLight* a_light0 = nullptr, BSLight* a_light1 = nullptr, - BSLight* a_light2 = nullptr, BSLight* a_light3 = nullptr); - BSRenderPass* head; // 00 }; static_assert(sizeof(RenderPassArray) == 0x8); diff --git a/src/RE/B/BSLightingShaderProperty.cpp b/src/RE/B/BSLightingShaderProperty.cpp index b72f19a8c..f65c25f10 100644 --- a/src/RE/B/BSLightingShaderProperty.cpp +++ b/src/RE/B/BSLightingShaderProperty.cpp @@ -1,5 +1,8 @@ #include "RE/B/BSLightingShaderProperty.h" +#include "RE/B/BSRenderPass.h" +#include "RE/B/BSShader.h" + namespace RE { void BSLightingShaderProperty::CopyMembers(BSLightingShaderProperty* a_other) @@ -19,4 +22,36 @@ namespace RE projectedUVColor = a_other->projectedUVColor; emissiveMult = a_other->emissiveMult; } + + void BSLightingShaderProperty::Data::Clear() + { + while (head != nullptr) { + BSRenderPass* next = head->next; + head->ClearRenderPass(); + head = next; + } + head = nullptr; + } + + BSRenderPass* BSLightingShaderProperty::Data::EmplacePass(BSShader* a_shader, BSShaderProperty* a_property, BSGeometry* a_geometry, + uint32_t a_technique, uint8_t a_numLights, BSLight* a_light0, BSLight* a_light1, BSLight* a_light2, BSLight* a_light3) + { + BSLight* lights[4]{ + a_light0, + a_light1, + a_light2, + a_light3 + }; + auto* newPass = a_shader->MakeRenderPass(a_property, a_geometry, a_technique, a_numLights, lights); + if (head != nullptr) { + RE::BSRenderPass* lastPass = head; + while (lastPass->next != nullptr) { + lastPass = lastPass->next; + } + lastPass->next = newPass; + } else { + head = newPass; + } + return newPass; + } } diff --git a/src/RE/B/BSShaderProperty.cpp b/src/RE/B/BSShaderProperty.cpp index 8f1605845..ad28a4e46 100644 --- a/src/RE/B/BSShaderProperty.cpp +++ b/src/RE/B/BSShaderProperty.cpp @@ -1,7 +1,5 @@ #include "RE/B/BSShaderProperty.h" -#include "RE/B/BSRenderPass.h" - namespace RE { void BSShaderProperty::SetEffectShaderData(const BSTSmartPointer& a_data) @@ -37,50 +35,4 @@ namespace RE auto baseMethod = reinterpret_cast((vtable.get()[0x18])); return baseMethod(this, a_stream); } - - BSRenderPass* BSShaderProperty::RenderPassArray::MakeRenderPass(BSShader* a_shader, BSShaderProperty* a_property, BSGeometry* a_geometry, uint32_t a_technique, uint8_t a_numLights, BSLight** a_lights) - { - using func_t = decltype(&BSShaderProperty::RenderPassArray::MakeRenderPass); - static REL::Relocation func{ RELOCATION_ID(100717, 107497) }; - return func(this, a_shader, a_property, a_geometry, a_technique, a_numLights, a_lights); - } - - void BSShaderProperty::RenderPassArray::ClearRenderPass(BSRenderPass* a_pass) - { - using func_t = decltype(&RenderPassArray::ClearRenderPass); - static REL::Relocation func{ RELOCATION_ID(100718, 107498) }; - func(this, a_pass); - } - - void BSShaderProperty::RenderPassArray::Clear() - { - while (head != nullptr) { - BSRenderPass* next = head->next; - ClearRenderPass(head); - head = next; - } - head = nullptr; - } - - BSRenderPass* BSShaderProperty::RenderPassArray::EmplacePass(BSShader* a_shader, BSShaderProperty* a_property, BSGeometry* a_geometry, - uint32_t a_technique, uint8_t a_numLights, BSLight* a_light0, BSLight* a_light1, BSLight* a_light2, BSLight* a_light3) - { - BSLight* lights[4]{ - a_light0, - a_light1, - a_light2, - a_light3 - }; - auto* newPass = MakeRenderPass(a_shader, a_property, a_geometry, a_technique, a_numLights, lights); - if (head != nullptr) { - RE::BSRenderPass* lastPass = head; - while (lastPass->next != nullptr) { - lastPass = lastPass->next; - } - lastPass->next = newPass; - } else { - head = newPass; - } - return newPass; - } }