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
36 changes: 26 additions & 10 deletions src/Features/InteriorSunShadows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,26 @@ void InteriorSunShadows::DrawSettings()
ImGui::Checkbox("Force Double-Sided Rendering", &settings.ForceDoubleSidedRendering);
if (auto _tt = Util::HoverTooltipWrapper()) {
ImGui::Text(
"Forces double-sided vertices during sun shadowmap rendering on interiors. "
"Disables backface culling during sun shadowmap rendering in interiors. "
"Will prevent most light leaking through unmasked/unprepared interiors at a small performance cost. ");
}
}

void InteriorSunShadows::LoadSettings(json& o_json)
{
settings = o_json;
}

void InteriorSunShadows::SaveSettings(json& o_json)
{
o_json = settings;
}

void InteriorSunShadows::RestoreDefaultSettings()
{
settings = {};
}

void InteriorSunShadows::PostPostLoad()
{
// Hooks and patch to enable directional lighting for interiors
Expand Down Expand Up @@ -74,24 +89,25 @@ void InteriorSunShadows::DirShadowLightCulling::thunk(RE::BSShadowDirectionalLig
const auto cell = globals::game::tes->interiorCell;
auto* passedJobArrays = &jobArrays;

if (!cell) {
singleton->ClearArrays();
} else {
const auto portalGraph = cell->GetRuntimeData().loadedData->portalGraph;
if (singleton->isInteriorWithSun && portalGraph) {
if (cell && singleton->isInteriorWithSun) {
const auto* loadedData = cell->GetRuntimeData().loadedData;
const auto portalGraph = loadedData ? loadedData->portalGraph : nullptr;
if (portalGraph) {
singleton->PopulateReplacementJobArrays(cell, portalGraph, dirLight, jobArrays);
passedJobArrays = &singleton->replacementJobArrays;
}
} else
singleton->currentCell = nullptr;
} else {
if (!singleton->arraysCleared)
singleton->ClearArrays();
singleton->currentCell = nullptr;
}

func(dirLight, *passedJobArrays, nodes);
}

void InteriorSunShadows::ClearArrays()
{
if (arraysCleared)
return;

currentCellRoomsAndPortals.clear();

for (auto& jobArray : replacementJobArrays)
Expand Down
6 changes: 5 additions & 1 deletion src/Features/InteriorSunShadows.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ struct InteriorSunShadows : Feature
virtual inline std::string GetName() override { return "Interior Sun Shadows"; }
virtual inline std::string GetShortName() override { return "InteriorSunShadows"; }
virtual void DrawSettings() override;
virtual void LoadSettings(json& o_json) override;
virtual void SaveSettings(json& o_json) override;
virtual void RestoreDefaultSettings() override;
virtual bool SupportsVR() override { return true; }
virtual void PostPostLoad() override;
virtual void EarlyPrepass() override;
Expand Down Expand Up @@ -40,7 +43,8 @@ struct InteriorSunShadows : Feature
void UpdateRasterStateCullMode(const RE::BSRenderPass* pass, const uint32_t technique) const
{
if (isInteriorWithSun && settings.ForceDoubleSidedRendering && technique & static_cast<uint32_t>(SIE::ShaderCache::UtilityShaderFlags::RenderShadowmap)) {
const auto renderTwoSided = pass->shaderProperty->flags.none(RE::BSShaderProperty::EShaderPropertyFlag::kAssumeShadowmask);
const auto flags = pass->shaderProperty->flags;
const auto renderTwoSided = flags.all(RE::BSShaderProperty::EShaderPropertyFlag::kTwoSided) || flags.none(RE::BSShaderProperty::EShaderPropertyFlag::kAssumeShadowmask, RE::BSShaderProperty::EShaderPropertyFlag::kSkinned);
if (renderTwoSided && *rasterStateCullMode != 0) {
*rasterStateCullMode = 0;
globals::game::stateUpdateFlags->set(RE::BSGraphics::DIRTY_RASTER_CULL_MODE);
Expand Down