Skip to content
Merged
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
27 changes: 27 additions & 0 deletions src/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,31 @@ namespace Hooks
static inline REL::Relocation<decltype(thunk)> func;
};

// kNORMAL_TAAMASK_SSRMASK and its swap need UAV bind because DeferredCompositeCS
// writes vanilla-encoded normals through UAV1 (`normals.UAV` in Deferred::DeferredPasses),
// which feeds the post-pass vanilla SSAO chain (ISSAORawAO -> ISSAOComposite). Without
// these hooks the UAV is null, the CS write is silently dropped, and vanilla SSAO reads
// uninitialized data and produces hard wedge-shaped shadow artifacts.
struct CreateRenderTarget_Normals
{
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_NormalsSwap
{
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 @@ -952,6 +977,8 @@ namespace Hooks

logger::info("Hooking BSShaderRenderTargets::Create::CreateRenderTarget(s)");
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_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
Loading