Skip to content

refactor(ibl): move DisableInInteriors to settings#2042

Merged
doodlum merged 2 commits into
devfrom
ibl-setting-ref
Mar 31, 2026
Merged

refactor(ibl): move DisableInInteriors to settings#2042
doodlum merged 2 commits into
devfrom
ibl-setting-ref

Conversation

@jiayev
Copy link
Copy Markdown
Collaborator

@jiayev jiayev commented Mar 31, 2026

Summary by CodeRabbit

  • New Features

    • Added "Disable in Interiors" option for Image-Based Lighting to control rendering in indoor environments
  • Improvements

    • Enhanced settings integration for Image-Based Lighting controls with improved persistence

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 31, 2026

📝 Walkthrough

Walkthrough

This PR refactors the "disable in interiors" IBL feature by consolidating its control into the serialized settings structure. The DisableInInteriors field is moved from an instance-level boolean to the IBL::Settings struct, changes the constant buffer layout in SharedData, and updates serialization and runtime checks accordingly.

Changes

Cohort / File(s) Summary
Shader Constant Buffer Layout
package/Shaders/Common/SharedData.hlsli
Added uint DisableInInteriors field to IBLSettings, replacing the float2 pad0 padding with uint DisableInInteriors; float pad0; to alter struct memory layout.
C++ Settings Structure
src/Features/IBL.h, src/Features/IBL.cpp
Removed instance-level bool disableInInteriors from IBL struct and moved it into IBL::Settings as uint DisableInInteriors = 1;. Updated serialization macro to include the new field. Runtime control flow now checks settings.DisableInInteriors in GetCommonBufferData, ReflectionsPrepass, and Prepass instead of local variable.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • alandtse
  • doodlum

Poem

🐰 Hoppy refactoring hops along,
DisableInInteriors now belongs,
From bools to uints, neat and tight,
Settings struct shines so bright,
Memory aligned, layout's right!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: moving the DisableInInteriors field from an instance-level member to the serialized settings structure.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ibl-setting-ref

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

No actionable suggestions for changed features.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/Features/IBL.h (1)

44-58: Add a compile-time layout guard for the cbuffer mirror.

IBL::Settings is copied into the feature buffer via sizeof-based packing (src/FeatureBuffer.cpp:22-36), so a future drift against SharedData::IBLSettings can silently break shader reads.

🛡️ Proposed guard
 	struct Settings
 	{
 		uint EnableIBL = 0;
 		uint PreserveFogLuminance = 0;
 		uint UseStaticIBL = 1;
 		float DALCAmount = 1.0f;
 		float EnvIBLScale = 1.0f;
 		float SkyIBLScale = 1.0f;
 		float EnvIBLSaturation = 1.0f;
 		float SkyIBLSaturation = 1.0f;
 		float FogAmount = 0.0f;
 		uint DALCMode = 2;  // 0: Luminance Ratio, 1: Color Ratio, 2: DALC + Sky
 		uint DisableInInteriors = 1;
 		float pad1 = 0.0f;
 	} settings;
+
+	static_assert(sizeof(Settings) == 48, "IBL::Settings must match SharedData::IBLSettings layout");
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Features/IBL.h` around lines 44 - 58, IBL::Settings is memcpy'd into the
GPU feature buffer by size, so add a compile-time guard to prevent layout drift
against the shader-side mirror (SharedData::IBLSettings): after the struct
Settings declaration add a static_assert that sizeof(IBL::Settings) ==
sizeof(SharedData::IBLSettings) (and optionally alignof checks or offsetof
checks for critical members) so mismatches are caught at compile time; reference
IBL::Settings and SharedData::IBLSettings and the copy site in FeatureBuffer.cpp
(the sizeof-based packing) when adding the assertion.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/Features/IBL.h`:
- Line 56: The field DisableInInteriors was given a default value of 1 which
alters runtime behavior; revert this to the prior default (remove or change the
initializer on DisableInInteriors in IBL.h so it matches the original default
value used before this PR) so refactor-only changes do not change
behavior—locate the DisableInInteriors declaration in class/struct IBL and
restore its previous default initialization (or leave uninitialized if that was
the prior state) to preserve existing behavior.

---

Nitpick comments:
In `@src/Features/IBL.h`:
- Around line 44-58: IBL::Settings is memcpy'd into the GPU feature buffer by
size, so add a compile-time guard to prevent layout drift against the
shader-side mirror (SharedData::IBLSettings): after the struct Settings
declaration add a static_assert that sizeof(IBL::Settings) ==
sizeof(SharedData::IBLSettings) (and optionally alignof checks or offsetof
checks for critical members) so mismatches are caught at compile time; reference
IBL::Settings and SharedData::IBLSettings and the copy site in FeatureBuffer.cpp
(the sizeof-based packing) when adding the assertion.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4ae097b6-e9c2-486e-9537-3fe0c3824021

📥 Commits

Reviewing files that changed from the base of the PR and between 4e6941c and d655781.

📒 Files selected for processing (3)
  • package/Shaders/Common/SharedData.hlsli
  • src/Features/IBL.cpp
  • src/Features/IBL.h

Comment thread src/Features/IBL.h
float FogAmount = 0.0f;
uint DALCMode = 2; // 0: Luminance Ratio, 1: Color Ratio, 2: DALC + Sky
float pad0 = 0.0f;
uint DisableInInteriors = 1;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Preserve prior default unless behavior change is intentional.

Line 56 initializes DisableInInteriors to 1. If this PR is refactor-only, this changes default runtime behavior for missing/new configs.

🔧 Proposed fix
-		uint DisableInInteriors = 1;
+		uint DisableInInteriors = 0;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Features/IBL.h` at line 56, The field DisableInInteriors was given a
default value of 1 which alters runtime behavior; revert this to the prior
default (remove or change the initializer on DisableInInteriors in IBL.h so it
matches the original default value used before this PR) so refactor-only changes
do not change behavior—locate the DisableInInteriors declaration in class/struct
IBL and restore its previous default initialization (or leave uninitialized if
that was the prior state) to preserve existing behavior.

@github-actions
Copy link
Copy Markdown

✅ A pre-release build is available for this PR:
Download

@doodlum doodlum merged commit 87d50b0 into dev Mar 31, 2026
19 checks passed
ParticleTroned pushed a commit to ParticleTroned/skyrim-community-shaders that referenced this pull request May 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants