Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
be74c80
perf: RTTI optimisation
doodlum Jul 12, 2025
0de2cca
refactor: cleanup
doodlum Jul 12, 2025
470971f
refactor: rename var
doodlum Jul 12, 2025
b07b979
style: 🎨 apply pre-commit.ci formatting
pre-commit-ci[bot] Jul 12, 2025
794c640
Merge branch 'netimmerse-perf' of https://github.com/doodlum/skyrim-c…
doodlum Jul 12, 2025
252ffc6
chore: random opt stuff
doodlum Jul 21, 2025
4780ee1
fix: compile error
doodlum Jul 21, 2025
a040562
perf: optimise flags
doodlum Jul 21, 2025
4944f03
fix: why was this removed
doodlum Jul 21, 2025
fb0c575
perf: optimise shader setting
doodlum Jul 21, 2025
0085432
chore: more optimisation for hopefully better vectorisation
doodlum Jul 21, 2025
791c900
perf: vibe code truepbr opt
doodlum Jul 21, 2025
bf98ca6
perf: vibe code terrain helper
doodlum Jul 21, 2025
997db84
perf: no new frame in setdirtystates
doodlum Jul 21, 2025
1627728
fix: comparison
doodlum Jul 21, 2025
4cd8f8c
style: 🎨 apply pre-commit.ci formatting
pre-commit-ci[bot] Jul 21, 2025
ec6f6c2
Merge branch 'messy-opts' of https://github.com/doodlum/skyrim-commun…
doodlum Jul 21, 2025
1b93e2e
chore: merge fixes (#1292)
doodlum Jul 21, 2025
6ad82d2
refactor: separate into debug function
doodlum Jul 21, 2025
92d98f8
style: 🎨 apply pre-commit.ci formatting
pre-commit-ci[bot] Jul 21, 2025
a24f23c
perf: remove asm hooks
doodlum Jul 22, 2025
bb2066c
fix: directional ambient
doodlum Jul 22, 2025
605105e
style: 🎨 apply pre-commit.ci formatting
pre-commit-ci[bot] Jul 22, 2025
cf39d9e
Merge branch 'messy-opts' of https://github.com/doodlum/skyrim-commun…
doodlum Jul 22, 2025
808e23f
fix: dir light direction
doodlum Jul 22, 2025
793bc08
fix: vanilla rendering
doodlum Jul 22, 2025
4b613b3
perf: more optimisations
doodlum Jul 23, 2025
bba1334
fix: fix compile error
doodlum Jul 23, 2025
9f2c4ad
Merge branch 'messy-opts' into netimmerse-perf
doodlum Jul 23, 2025
5498000
chore: merge netimmerse-perf (#1295)
doodlum Jul 23, 2025
f88ea98
chore: more things
doodlum Jul 23, 2025
d054ed3
style: 🎨 apply pre-commit.ci formatting
pre-commit-ci[bot] Jul 23, 2025
095ad4e
Merge branch 'messy-opts' of https://github.com/doodlum/skyrim-commun…
doodlum Jul 23, 2025
25a05ce
chore: vr offset
doodlum Jul 23, 2025
40b859a
chore: leave in asm patch
doodlum Jul 23, 2025
c9a90aa
chore: remove drawdebug
doodlum Jul 23, 2025
f4ca6af
chore: bump addresslib
doodlum Jul 23, 2025
9e1b7b2
style: 🎨 apply pre-commit.ci formatting
pre-commit-ci[bot] Jul 23, 2025
566dfdf
Merge branch 'messy-opts' of https://github.com/doodlum/skyrim-commun…
doodlum Jul 23, 2025
500a993
refactor: use std::countr_zero/countr_one
doodlum Jul 23, 2025
3688789
refactor: update truepbr
doodlum Jul 23, 2025
f42b2f6
chore: use cpp cast
doodlum Jul 23, 2025
208264f
chore: revert direct light changes
doodlum Jul 23, 2025
763ade0
style: 🎨 apply pre-commit.ci formatting
pre-commit-ci[bot] Jul 23, 2025
82e7729
Merge branch 'messy-opts' of https://github.com/doodlum/skyrim-commun…
doodlum Jul 23, 2025
bb04a8a
chore: revert dalc
doodlum Jul 23, 2025
3bf1399
chore: revert dir light xyz change
doodlum Jul 23, 2025
94febe6
style: 🎨 apply pre-commit.ci formatting
pre-commit-ci[bot] Jul 23, 2025
1a318e6
Merge branch 'messy-opts' of https://github.com/doodlum/skyrim-commun…
doodlum Jul 23, 2025
655f5a5
perf: only use debug when overlay enabled
doodlum Jul 23, 2025
22341ba
style: 🎨 apply pre-commit.ci formatting
pre-commit-ci[bot] Jul 23, 2025
5bd236f
chore: cleanup hook
doodlum Jul 23, 2025
33a6145
fix: dir light direction xyz
doodlum Jul 23, 2025
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
3 changes: 1 addition & 2 deletions package/Shaders/Common/Permutation.hlsli
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ namespace Permutation
static const uint InReflection = (1 << 1);
static const uint IsBeastRace = (1 << 2);
static const uint EffectShadows = (1 << 3);
static const uint IsDecal = (1 << 4);
static const uint IsTree = (1 << 5);
static const uint IsTree = (1 << 4);
}

namespace ExtraFeatureFlags
Expand Down
2 changes: 1 addition & 1 deletion package/Shaders/Lighting.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -2344,7 +2344,7 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace : SV_IsFrontFace)
# if defined(DEFERRED)
bool useScreenSpaceShadows = true;
# else
bool useScreenSpaceShadows = inWorld && !SharedData::InInterior && Permutation::ExtraShaderDescriptor & Permutation::ExtraFlags::IsDecal;
bool useScreenSpaceShadows = inWorld && !SharedData::InInterior;
# endif

if (useScreenSpaceShadows)
Expand Down
40 changes: 32 additions & 8 deletions src/Deferred.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,7 @@ void Deferred::StartDeferred()
{
auto context = globals::d3d::context;

static REL::Relocation<ID3D11Buffer**> perFrame{ REL::RelocationID(524768, 411384) };
ID3D11Buffer* buffers[1] = { *perFrame.get() };
ID3D11Buffer* buffers[1] = { *globals::game::perFrame.get() };

ID3D11Buffer* vrBuffer = nullptr;

Expand Down Expand Up @@ -768,9 +767,12 @@ void Deferred::Hooks::Main_RenderShadowMaps::thunk()

void Deferred::Hooks::Main_RenderWorld::thunk(bool a1)
{
globals::state->inWorld = true;
auto* const state = globals::state;
state->permutationData.ExtraShaderDescriptor |= static_cast<uint32_t>(State::ExtraShaderDescriptors::InWorld);
state->inWorld = true;
func(a1);
globals::state->inWorld = false;
state->inWorld = false;
state->permutationData.ExtraShaderDescriptor &= ~static_cast<uint32_t>(State::ExtraShaderDescriptors::InWorld);
};

void Deferred::Hooks::Main_RenderWorld_Start::thunk(RE::BSBatchRenderer* This, uint32_t StartRange, uint32_t EndRanges, uint32_t RenderFlags, int GeometryGroup)
Expand All @@ -796,9 +798,7 @@ void Deferred::Hooks::Main_RenderWorld_BlendedDecals::thunk(RE::BSShaderAccumula

// Deferred blended decals

deferred->inDecals = true;
func(This, RenderFlags);
deferred->inDecals = false;

deferred->EndDeferred();

Expand All @@ -808,9 +808,33 @@ void Deferred::Hooks::Main_RenderWorld_BlendedDecals::thunk(RE::BSShaderAccumula
void Deferred::Hooks::BSCubeMapCamera_RenderCubemap::thunk(RE::NiAVObject* camera, int a2, bool a3, bool a4, bool a5)
{
auto deferred = globals::deferred;
auto state = globals::state;

deferred->inReflections = true;
deferred->ReflectionsPrepasses();
state->permutationData.ExtraShaderDescriptor |= static_cast<uint32_t>(State::ExtraShaderDescriptors::IsReflections);
func(camera, a2, a3, a4, a5);
deferred->inReflections = false;
state->permutationData.ExtraShaderDescriptor &= ~static_cast<uint32_t>(State::ExtraShaderDescriptors::IsReflections);
}

void Deferred::Hooks::Main_RenderFirstPersonView::thunk(bool a1, bool a2)
{
auto* const state = globals::state;
state->permutationData.ExtraShaderDescriptor |= static_cast<uint32_t>(State::ExtraShaderDescriptors::InWorld);
func(a1, a2);
state->permutationData.ExtraShaderDescriptor &= ~static_cast<uint32_t>(State::ExtraShaderDescriptors::InWorld);
}

void Deferred::Hooks::Renderer_ResetState::thunk(void* This)
{
func(This);

auto* const state = globals::state;
auto* const context = globals::d3d::context;

ID3D11Buffer* buffers[3] = { state->permutationCB->CB(), state->sharedDataCB->CB(), state->featureDataCB->CB() };
context->PSSetConstantBuffers(4, 3, buffers);
context->CSSetConstantBuffers(5, 2, buffers + 1);

auto* singleton = globals::truePBR;
singleton->SetupFrame();
}
19 changes: 17 additions & 2 deletions src/Deferred.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ class Deferred
ID3D11ComputeShader* mainCompositeCS = nullptr;
ID3D11ComputeShader* mainCompositeInteriorCS = nullptr;

bool inDecals = false;
bool inReflections = false;
bool deferredPass = false;

Texture2D* prevDiffuseAmbientTexture = nullptr;
Expand Down Expand Up @@ -130,6 +128,18 @@ class Deferred
static inline REL::Relocation<decltype(thunk)> func;
};

struct Main_RenderFirstPersonView
{
static void thunk(bool a1, bool a2);
static inline REL::Relocation<decltype(thunk)> func;
};

struct Renderer_ResetState
{
static void thunk(void* This);
static inline REL::Relocation<decltype(thunk)> func;
};

static void Install()
{
stl::write_vfunc<0x35, BSCubeMapCamera_RenderCubemap>(RE::VTABLE_BSCubeMapCamera[0]);
Expand All @@ -140,6 +150,11 @@ class Deferred
stl::write_thunk_call<Main_RenderWorld_Start>(REL::RelocationID(99938, 106583).address() + REL::Relocate(0x8E, 0x84));
stl::write_thunk_call<Main_RenderWorld_BlendedDecals>(REL::RelocationID(99938, 106583).address() + REL::Relocate(0x319, 0x308, 0x321));

if (!REL::Module::IsVR())
stl::write_thunk_call<Main_RenderFirstPersonView>(REL::RelocationID(35560, 36559).address() + REL::Relocate(0x944, 0x954));

stl::detour_thunk<Renderer_ResetState>(REL::RelocationID(75570, 77371));

stl::write_vfunc<0x2, BSImagespaceShaderHDRTonemapBlendCinematic_SetupTechnique>(RE::VTABLE_BSImagespaceShaderHDRTonemapBlendCinematic[0]);
stl::write_vfunc<0x2, BSImagespaceShaderHDRTonemapBlendCinematicFade_SetupTechnique>(RE::VTABLE_BSImagespaceShaderHDRTonemapBlendCinematicFade[0]);

Expand Down
12 changes: 5 additions & 7 deletions src/Features/ExtendedTranslucency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,30 @@ ExtendedTranslucency* ExtendedTranslucency::GetSingleton()

void ExtendedTranslucency::BSLightingShader_SetupGeometry(RE::BSRenderPass* pass)
{
globals::state->currentExtraFeatureDescriptor &= ~(ExtraFeatureDescriptorMask << ExtraFeatureDescriptorShift);
globals::state->permutationData.ExtraFeatureDescriptor &= ~(ExtraFeatureDescriptorMask << ExtraFeatureDescriptorShift);
// TODO: PERFORMANCE: Caching the feature descriptor in map<RE::BSGeometry*, uint> if this get more complex
auto& unknownProperty = pass->geometry->GetGeometryRuntimeData().properties[RE::BSGeometry::States::kProperty];
static const REL::Relocation<const RE::NiRTTI*> NiAlphaPropertyRTTI{ RE::NiAlphaProperty::Ni_RTTI };
auto alphaProperty = unknownProperty && unknownProperty->GetRTTI() == NiAlphaPropertyRTTI.get() ? static_cast<RE::NiAlphaProperty*>(unknownProperty.get()) : nullptr;
auto alphaProperty = unknownProperty && unknownProperty->GetRTTI() == globals::rtti::NiAlphaPropertyRTTI.get() ? static_cast<RE::NiAlphaProperty*>(unknownProperty.get()) : nullptr;
// Check alpha property exists and blending is enabled
if (alphaProperty && alphaProperty->GetAlphaBlending()) {
if (auto* data = pass->geometry->GetExtraData(NiExtraDataName_AnisotropicAlphaMaterial)) {
static const REL::Relocation<const RE::NiRTTI*> NiIntegerExtraDataRTTI{ RE::NiIntegerExtraData::Ni_RTTI };
if (data->GetRTTI() == NiIntegerExtraDataRTTI.get()) {
if (data->GetRTTI() == globals::rtti::NiIntegerExtraDataRTTI.get()) {
uint32_t material = static_cast<uint32_t>(static_cast<RE::NiIntegerExtraData*>(data)->value) & ExtraFeatureDescriptorMask;
if (material == MaterialModel::Disabled) {
// MaterialModel::Disabled (0) is the flag when this extra does not exist
// And it will let the effect use default settings instead of force disable it
// Ensure this is disabled by using the ForceDisabled flag
material = MaterialModel::ForceDisabled;
}
globals::state->currentExtraFeatureDescriptor |= (material << ExtraFeatureDescriptorShift);
globals::state->permutationData.ExtraFeatureDescriptor |= (material << ExtraFeatureDescriptorShift);

// TODO: Per-material settings from Nif
// Mods supporting this feature should adjust their alpha value in texture already
// And the texture should be adjusted based on full strength param
}
}
} else {
globals::state->currentExtraFeatureDescriptor |= ((MaterialModel::ForceDisabled) << ExtraFeatureDescriptorShift);
globals::state->permutationData.ExtraFeatureDescriptor |= ((MaterialModel::ForceDisabled) << ExtraFeatureDescriptorShift);
}
}

Expand Down
24 changes: 7 additions & 17 deletions src/Features/LightLimitFix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,15 +301,11 @@ void LightLimitFix::BSLightingShader_SetupGeometry_Before(RE::BSRenderPass* a_pa
}
}

void LightLimitFix::BSLightingShader_SetupGeometry_GeometrySetupConstantPointLights(RE::BSRenderPass* a_pass, DirectX::XMMATRIX&, uint32_t, uint32_t, float, Space)
void LightLimitFix::BSLightingShader_SetupGeometry_GeometrySetupConstantPointLights(RE::BSRenderPass* a_pass)
{
auto shaderCache = globals::shaderCache;
auto isl = globals::features::inverseSquareLighting;

if (!shaderCache->IsEnabled())
return;

auto accumulator = RE::BSGraphics::BSShaderAccumulator::GetCurrentAccumulator();
auto accumulator = *globals::game::currentAccumulator.get();
bool inWorld = accumulator->GetRuntimeData().activeShadowSceneNode == globals::game::smState->shadowSceneNode[0];

strictLightDataTemp.NumStrictLights = inWorld ? 0 : (a_pass->numLights - 1);
Expand All @@ -335,7 +331,7 @@ void LightLimitFix::BSLightingShader_SetupGeometry_GeometrySetupConstantPointLig

SetLightPosition(light, niLight->world.translate, inWorld);

if (bsLight->IsShadowLight()) {
if (i < a_pass->numShadowLights) {
auto* shadowLight = static_cast<RE::BSShadowLight*>(bsLight);
GET_INSTANCE_MEMBER(shadowLightIndex, shadowLight);
light.shadowMaskIndex = shadowLightIndex;
Expand All @@ -362,7 +358,7 @@ void LightLimitFix::BSLightingShader_SetupGeometry_After(RE::BSRenderPass*)
if (!shaderCache->IsEnabled())
return;

auto accumulator = RE::BSGraphics::BSShaderAccumulator::GetCurrentAccumulator();
auto accumulator = *globals::game::currentAccumulator.get();

auto shadowSceneNode = smState->shadowSceneNode[0];

Expand Down Expand Up @@ -497,14 +493,14 @@ LightLimitFix::ParticleLightReference LightLimitFix::GetParticleLightConfigs(RE:

// see https://www.nexusmods.com/skyrimspecialedition/articles/1391
if (settings.EnableParticleLights) {
if (auto shaderProperty = netimmerse_cast<RE::BSEffectShaderProperty*>(a_pass->shaderProperty)) {
if (auto shaderProperty = a_pass->shaderProperty->GetRTTI() == globals::rtti::BSEffectShaderPropertyRTTI.get() ? static_cast<RE::BSEffectShaderProperty*>(a_pass->shaderProperty) : nullptr) {
if (!shaderProperty->lightData) {
if (auto material = shaderProperty->GetMaterial()) {
// Check if it's a valid particle light
bool billboard = false;
if (!netimmerse_cast<RE::NiParticleSystem*>(a_pass->geometry)) {
if (a_pass->geometry->GetRTTI() != globals::rtti::NiParticleSystemRTTI.get()) {
if (auto parent = a_pass->geometry->parent) {
if (auto billboardNode = netimmerse_cast<RE::NiBillboardNode*>(parent)) {
if (auto billboardNode = parent->GetRTTI() == globals::rtti::NiBillboardNodeRTTI.get() ? static_cast<RE::NiBillboardNode*>(parent) : nullptr) {
billboard = true;
} else {
return { false };
Expand Down Expand Up @@ -1069,12 +1065,6 @@ float LightLimitFix::Hooks::AIProcess_CalculateLightValue_GetLuminance::thunk(RE
return ret;
}

void LightLimitFix::Hooks::BSLightingShader_SetupGeometry_GeometrySetupConstantPointLights::thunk(RE::BSGraphics::PixelShader* PixelShader, RE::BSRenderPass* Pass, DirectX::XMMATRIX& Transform, uint32_t LightCount, uint32_t ShadowLightCount, float WorldScale, Space RenderSpace)
{
globals::features::lightLimitFix->BSLightingShader_SetupGeometry_GeometrySetupConstantPointLights(Pass, Transform, LightCount, ShadowLightCount, WorldScale, RenderSpace);
func(PixelShader, Pass, Transform, LightCount, ShadowLightCount, WorldScale, RenderSpace);
}

void LightLimitFix::Hooks::NiNode_Destroy::thunk(RE::NiNode* This)
{
globals::features::lightLimitFix->CleanupParticleLights(This);
Expand Down
16 changes: 1 addition & 15 deletions src/Features/LightLimitFix.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,7 @@ struct LightLimitFix : Feature

void BSLightingShader_SetupGeometry_Before(RE::BSRenderPass* a_pass);

enum class Space
{
World = 0,
Model = 1,
};

void BSLightingShader_SetupGeometry_GeometrySetupConstantPointLights(RE::BSRenderPass* a_pass, DirectX::XMMATRIX& Transform, uint32_t, uint32_t, float WorldScale, Space RenderSpace);
void BSLightingShader_SetupGeometry_GeometrySetupConstantPointLights(RE::BSRenderPass* a_pass);

void BSLightingShader_SetupGeometry_After(RE::BSRenderPass* a_pass);

Expand Down Expand Up @@ -269,12 +263,6 @@ struct LightLimitFix : Feature
static inline REL::Relocation<decltype(thunk)> func;
};

struct BSLightingShader_SetupGeometry_GeometrySetupConstantPointLights
{
static void thunk(RE::BSGraphics::PixelShader* PixelShader, RE::BSRenderPass* Pass, DirectX::XMMATRIX& Transform, uint32_t LightCount, uint32_t ShadowLightCount, float WorldScale, Space RenderSpace);
static inline REL::Relocation<decltype(thunk)> func;
};

struct NiNode_Destroy
{
static void thunk(RE::NiNode* This);
Expand Down Expand Up @@ -303,8 +291,6 @@ struct LightLimitFix : Feature
stl::write_vfunc<0x6, BSEffectShader_SetupGeometry>(RE::VTABLE_BSEffectShader[0]);
stl::write_vfunc<0x6, BSWaterShader_SetupGeometry>(RE::VTABLE_BSWaterShader[0]);

stl::write_thunk_call<BSLightingShader_SetupGeometry_GeometrySetupConstantPointLights>(REL::RelocationID(100565, 107300).address() + REL::Relocate(0x523, 0xB0E, 0x5fe));

stl::detour_thunk<NiNode_Destroy>(REL::RelocationID(68937, 70288));

stl::write_thunk_call<ValidLight1>(REL::RelocationID(100994, 107781).address() + 0x92);
Expand Down
2 changes: 1 addition & 1 deletion src/Features/ScreenSpaceShadows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void ScreenSpaceShadows::DrawShadows()
auto renderer = globals::game::renderer;
auto context = globals::d3d::context;

auto accumulator = RE::BSGraphics::BSShaderAccumulator::GetCurrentAccumulator();
auto accumulator = *globals::game::currentAccumulator.get();
auto dirLight = skyrim_cast<RE::NiDirectionalLight*>(accumulator->GetRuntimeData().activeShadowSceneNode->GetRuntimeData().sunLight->light.get());

auto& directionNi = dirLight->GetWorldDirection();
Expand Down
4 changes: 3 additions & 1 deletion src/Features/SubsurfaceScattering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,9 @@ void SubsurfaceScattering::BSLightingShader_SetupSkin(RE::BSRenderPass* a_pass)
validMaterials = true;

if (isBeastRace)
state->currentExtraDescriptor |= (uint)State::ExtraShaderDescriptors::IsBeastRace;
state->permutationData.ExtraShaderDescriptor |= (uint)State::ExtraShaderDescriptors::IsBeastRace;
else
state->permutationData.ExtraShaderDescriptor &= ~(uint)State::ExtraShaderDescriptors::IsBeastRace;
}
}
}
Expand Down
34 changes: 28 additions & 6 deletions src/Features/TerrainHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,33 @@ struct THExtendedRendererState

void TerrainHelper::SetShaderResouces(ID3D11DeviceContext* a_context)
{
for (uint32_t textureIndex = 0; textureIndex < THExtendedRendererState::NumPSTextures; ++textureIndex) {
if (thExtendedRendererState.PSResourceModifiedBits & (1 << textureIndex)) {
a_context->PSSetShaderResources(THExtendedRendererState::FirstPSTexture + textureIndex, 1, &thExtendedRendererState.PSTexture[textureIndex]);
}
uint32_t mask = thExtendedRendererState.PSResourceModifiedBits;

if (mask == 0) [[likely]] {
return; // Nothing to update
}

constexpr uint32_t firstTexture = THExtendedRendererState::FirstPSTexture;
auto& textures = thExtendedRendererState.PSTexture;

while (mask) {
// Find the position of the first set bit
uint32_t batchStart = std::countr_zero(mask);

// Count consecutive 1s starting from batchStart
uint32_t shiftedMask = mask >> batchStart;
uint32_t batchCount = std::countr_one(shiftedMask);

a_context->PSSetShaderResources(
firstTexture + batchStart,
batchCount,
&textures[batchStart]);

// Clear the processed bits
uint32_t clearMask = ((1u << batchCount) - 1u) << batchStart;
mask &= ~clearMask;
}

thExtendedRendererState.PSResourceModifiedBits = 0;
}

Expand Down Expand Up @@ -160,10 +182,10 @@ void TerrainHelper::BSLightingShader_SetupMaterial(RE::BSLightingShaderMaterialB
for (uint32_t textureI = 0; textureI < 6; ++textureI) {
if (materialBase.parallax[textureI] != nullptr && materialBase.parallax[textureI] != stateData.defaultTextureNormalMap) {
thExtendedRendererState.SetPSTexture(textureI, materialBase.parallax[textureI]->rendererTexture);
state->currentExtraFeatureDescriptor |= 1 << textureI;
state->permutationData.ExtraFeatureDescriptor |= 1 << textureI;
} else {
thExtendedRendererState.SetPSTexture(textureI, nullptr);
state->currentExtraFeatureDescriptor &= ~(1 << textureI);
state->permutationData.ExtraFeatureDescriptor &= ~(1 << textureI);
}
}
}
2 changes: 1 addition & 1 deletion src/Features/TerrainShadows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ void TerrainShadows::UpdateShadow()
context->CSSetShaderResources(60, (uint)srvs.size(), srvs.data());
}

auto accumulator = RE::BSGraphics::BSShaderAccumulator::GetCurrentAccumulator();
auto accumulator = *globals::game::currentAccumulator.get();
auto sunLight = skyrim_cast<RE::NiDirectionalLight*>(accumulator->GetRuntimeData().activeShadowSceneNode->GetRuntimeData().sunLight->light.get());
if (!sunLight)
return;
Expand Down
23 changes: 23 additions & 0 deletions src/Globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,17 @@ namespace globals
RE::Setting* shadowMaskQuarter = nullptr;

REL::Relocation<ID3D11Buffer**> perFrame;
REL::Relocation<RE::BSGraphics::BSShaderAccumulator**> currentAccumulator;
}

namespace rtti
{
REL::Relocation<const RE::NiRTTI*> NiIntegerExtraDataRTTI;
REL::Relocation<const RE::NiRTTI*> BSLightingShaderPropertyRTTI;
REL::Relocation<const RE::NiRTTI*> BSEffectShaderPropertyRTTI;
REL::Relocation<const RE::NiRTTI*> NiParticleSystemRTTI;
REL::Relocation<const RE::NiRTTI*> NiBillboardNodeRTTI;
REL::Relocation<const RE::NiRTTI*> NiAlphaPropertyRTTI;
}

State* state = nullptr;
Expand Down Expand Up @@ -195,6 +206,18 @@ namespace globals

ui = RE::UI::GetSingleton();
perFrame = { REL::RelocationID(524768, 411384) };

currentAccumulator = { REL::RelocationID(527650, 414600) };
}

{
using namespace rtti;
NiIntegerExtraDataRTTI = { RE::NiIntegerExtraData::Ni_RTTI };
BSLightingShaderPropertyRTTI = { RE::BSLightingShaderProperty::Ni_RTTI };
BSEffectShaderPropertyRTTI = { RE::BSEffectShaderProperty::Ni_RTTI };
NiParticleSystemRTTI = { RE::NiParticleSystem::Ni_RTTI };
NiBillboardNodeRTTI = { RE::NiBillboardNode::Ni_RTTI };
NiAlphaPropertyRTTI = { RE::NiAlphaProperty::Ni_RTTI };
}

d3d::device = reinterpret_cast<ID3D11Device*>(game::renderer->GetRuntimeData().forwarder);
Expand Down
Loading