Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/Features/InteriorSun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ void InteriorSun::RestoreDefaultSettings()

void InteriorSun::PostPostLoad()
{
stl::write_thunk_call<BSBatchRenderer_RenderPassImmediately>(REL::RelocationID(100852, 107642).address() + REL::Relocate(0x29E, 0x28F));

Comment thread
doodlum marked this conversation as resolved.
// Hooks and patch to enable directional lighting for interiors
stl::write_thunk_call<GetWorldSpace>(REL::RelocationID(35562, 36561).address() + REL::Relocate(0x399, 0x37D, 0x639));
stl::write_thunk_call<GetWorldSpace>(REL::RelocationID(35562, 36561).address() + REL::Relocate(0x3AE, 0x392, 0x64E));
Expand Down Expand Up @@ -123,6 +125,12 @@ void InteriorSun::DirShadowLightCulling::thunk(RE::BSShadowDirectionalLight* dir
func(dirLight, *passedJobArrays, nodes);
}

void InteriorSun::BSBatchRenderer_RenderPassImmediately::thunk(RE::BSRenderPass* a_pass, uint32_t a_technique, bool a_alphaTest, uint32_t a_renderFlags)
{
globals::features::interiorSun.UpdateRasterStateCullMode(a_pass, a_technique);
func(a_pass, a_technique, a_alphaTest, a_renderFlags);
}

void InteriorSun::ClearArrays()
{
currentCellRoomsAndPortals.clear();
Expand Down
6 changes: 6 additions & 0 deletions src/Features/InteriorSun.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ struct InteriorSun : Feature
static inline REL::Relocation<decltype(thunk)> func;
};

struct BSBatchRenderer_RenderPassImmediately
{
static void thunk(RE::BSRenderPass* a_pass, uint32_t a_technique, bool a_alphaTest, uint32_t a_renderFlags);
static inline REL::Relocation<decltype(thunk)> func;
};

void UpdateRasterStateCullMode(const RE::BSRenderPass* pass, const uint32_t technique) const
{
if (isInteriorWithSun && settings.ForceDoubleSidedRendering && technique & static_cast<uint32_t>(SIE::ShaderCache::UtilityShaderFlags::RenderShadowmap)) {
Expand Down
42 changes: 0 additions & 42 deletions src/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,16 +498,6 @@ namespace Hooks
static inline REL::Relocation<decltype(thunk)> func;
};

struct CreateRenderTarget_Snow
{
static void thunk(RE::BSGraphics::Renderer* This, RE::RENDER_TARGETS::RENDER_TARGET a_target, RE::BSGraphics::RenderTargetProperties* a_properties)
{
globals::state->ModifyRenderTarget(a_target, a_properties);
func(This, a_target, a_properties);
}
static inline REL::Relocation<decltype(thunk)> func;
};

struct CreateRenderTarget_MotionVectors
{
static void thunk(RE::BSGraphics::Renderer* This, RE::RENDER_TARGETS::RENDER_TARGET a_target, RE::BSGraphics::RenderTargetProperties* a_properties)
Expand Down Expand Up @@ -702,32 +692,6 @@ namespace Hooks
static inline REL::Relocation<decltype(thunk)> func;
};

void BSBatchRenderer_RenderPassImmediately1::thunk(RE::BSRenderPass* a_pass, uint32_t a_technique, bool a_alphaTest, uint32_t a_renderFlags)
{
func(a_pass, a_technique, a_alphaTest, a_renderFlags);
}

struct BSBatchRenderer_RenderPassImmediately2
{
static void thunk(RE::BSRenderPass* a_pass, uint32_t a_technique, bool a_alphaTest, uint32_t a_renderFlags)
{
if (globals::features::interiorSun.loaded)
globals::features::interiorSun.UpdateRasterStateCullMode(a_pass, a_technique);

func(a_pass, a_technique, a_alphaTest, a_renderFlags);
}
static inline REL::Relocation<decltype(thunk)> func;
};

struct BSBatchRenderer_RenderPassImmediately3
{
static void thunk(RE::BSRenderPass* a_pass, uint32_t a_technique, bool a_alphaTest, uint32_t a_renderFlags)
{
func(a_pass, a_technique, a_alphaTest, a_renderFlags);
}
static inline REL::Relocation<decltype(thunk)> func;
};

#ifdef TRACY_ENABLE
struct Main_Update
{
Expand Down Expand Up @@ -901,7 +865,6 @@ namespace Hooks
stl::write_thunk_call<CreateRenderTarget_Main>(REL::RelocationID(100458, 107175).address() + REL::Relocate(0x3F0, 0x3F3, 0x548));
stl::write_thunk_call<CreateRenderTarget_Normals>(REL::RelocationID(100458, 107175).address() + REL::Relocate(0x458, 0x45B, 0x5B0));
stl::write_thunk_call<CreateRenderTarget_NormalsSwap>(REL::RelocationID(100458, 107175).address() + REL::Relocate(0x46B, 0x46E, 0x5C3));
stl::write_thunk_call<CreateRenderTarget_Snow>(REL::RelocationID(100458, 107175).address() + REL::Relocate(0x406, 0x409, 0x55e));
stl::write_thunk_call<CreateRenderTarget_MotionVectors>(REL::RelocationID(100458, 107175).address() + REL::Relocate(0x4F0, 0x4EF, 0x64E));

stl::write_thunk_call<CreateRenderTarget_RefractionNormals>(REL::RelocationID(100458, 107175).address() + REL::Relocate(0x503, 0x502, 0x661));
Expand Down Expand Up @@ -939,11 +902,6 @@ namespace Hooks
logger::info("Hooking BSLightingShader");
stl::write_vfunc<0x4, BSLightingShader_SetupMaterial>(RE::VTABLE_BSLightingShader[0]);

logger::info("Hooking BSBatchRenderer::RenderPassImmediately");
stl::write_thunk_call<BSBatchRenderer_RenderPassImmediately1>(REL::RelocationID(100877, 107673).address() + REL::Relocate(0x1E5, 0x1EE));
stl::write_thunk_call<BSBatchRenderer_RenderPassImmediately2>(REL::RelocationID(100852, 107642).address() + REL::Relocate(0x29E, 0x28F));
stl::write_thunk_call<BSBatchRenderer_RenderPassImmediately3>(REL::RelocationID(100871, 107667).address() + REL::Relocate(0xEE, 0xED));

// Patch render space in BSLightingShader::SetupGeometry to always use world space
// The variable updateEyePosition is set to 1 when not skinned. By patching to be 0 it will always use world space
// We offset from the base address of the containing function to the start of the patch
Expand Down