Skip to content

fix(iss): fix interior light level calcs with interior sun#1366

Merged
alandtse merged 1 commit into
community-shaders:devfrom
sicsix:iss-lightlevels
Aug 5, 2025
Merged

fix(iss): fix interior light level calcs with interior sun#1366
alandtse merged 1 commit into
community-shaders:devfrom
sicsix:iss-lightlevels

Conversation

@sicsix
Copy link
Copy Markdown
Collaborator

@sicsix sicsix commented Aug 5, 2025

  • currently CPU side interior light level calcs always add suncolor * sunlightScale without performing raycast checks, this leads to light levels always being high in interiors during the day
  • this PR patches the light level calculations to perform raycast checks to the sun with sun enabled interiors

Summary by CodeRabbit

  • New Features

    • Improved lighting calculations for interiors with directional lights, enhancing realism in affected areas.
  • Bug Fixes

    • Addressed issues related to AI light value calculations in interior locations, resulting in more accurate lighting behavior.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Aug 5, 2025

Walkthrough

The changes update the PostPostLoad function in InteriorSunShadows.cpp, replacing a hardcoded byte value with a symbolic constant for NOP operations. The patch also adds new hooks and patches to the AIProcess::CalculateLightValue function, introducing conditional logic and thunk calls to affect AI light calculations in interiors with directional lighting.

Changes

Cohort / File(s) Change Summary
InteriorSunShadows logic and patching
src/Features/InteriorSunShadows.cpp
Replaced hardcoded NOP value with symbolic constant; added hooks and patches to AIProcess::CalculateLightValue for raycast checks and conditional logic related to interior directional lighting.

Sequence Diagram(s)

sequenceDiagram
    participant GameEngine
    participant InteriorSunShadows
    participant AIProcess

    GameEngine->>InteriorSunShadows: Call PostPostLoad()
    InteriorSunShadows->>AIProcess: Patch CalculateLightValue
    AIProcess-->>InteriorSunShadows: Invoke raycast/interior logic (via hook)
    InteriorSunShadows->>AIProcess: Call GetWorldSpace thunk if conditions met
    AIProcess-->>GameEngine: Return adjusted light value
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Suggested reviewers

  • alandtse

Poem

In the shadows of interiors, code hops anew,
With NOPs now named, and logic that grew.
AI ponders light, with thunks in the night,
Directional rays make the darkness less tight.
A rabbit approves, with a whiskery cheer—
Bright patches for code, and a sunbeam here!
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3f1ec27 and a276f92.

📒 Files selected for processing (1)
  • src/Features/InteriorSunShadows.cpp (1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: jiayev
PR: doodlum/skyrim-community-shaders#0
File: :0-0
Timestamp: 2025-08-03T18:37:19.690Z
Learning: ISReflectionsRayTracing.hlsl and ISWorldMap.hlsl in the skyrim-community-shaders repository are image-space post-processing shaders that perform color sampling and blending operations that need proper linear color space handling for the linear lighting system. ISReflectionsRayTracing handles screen-space reflections and should use conditional Color::IrradianceToLinear/Gamma conversions similar to ISCompositeLensFlareVolumetricLighting.hlsl. ISWorldMap performs 7x7 color accumulation that should be done in linear space similar to the pattern used in ISSAOComposite.hlsl.
Learnt from: alandtse
PR: doodlum/skyrim-community-shaders#0
File: :0-0
Timestamp: 2025-07-05T05:20:45.823Z
Learning: In the skyrim-community-shaders repository, file deletion error handling improvements that replace existence checks and try-catch blocks with std::filesystem::remove error-code-based approaches are considered bug fixes rather than refactoring, as they address inadequate error handling and misleading log messages.
Learnt from: alandtse
PR: doodlum/skyrim-community-shaders#0
File: :0-0
Timestamp: 2025-06-24T07:17:36.604Z
Learning: When reviewing PRs, always clarify the scope if there are multiple related features or dependencies. WeatherPicker was a separate PR that was already merged, while this PR focuses specifically on WetnessEffects climate preset system enhancements.
Learnt from: jiayev
PR: doodlum/skyrim-community-shaders#0
File: :0-0
Timestamp: 2025-07-18T15:21:03.641Z
Learning: In the skyrim-community-shaders rendering pipeline, materials with alpha < 1 or alpha blending enabled are rendered in non-deferred mode rather than deferred mode. This means issues with dynamic cubemaps on transparent materials are actually non-deferred rendering issues.
📚 Learning: isreflectionsraytracing.hlsl and isworldmap.hlsl in the skyrim-community-shaders repository are imag...
Learnt from: jiayev
PR: doodlum/skyrim-community-shaders#0
File: :0-0
Timestamp: 2025-08-03T18:37:19.690Z
Learning: ISReflectionsRayTracing.hlsl and ISWorldMap.hlsl in the skyrim-community-shaders repository are image-space post-processing shaders that perform color sampling and blending operations that need proper linear color space handling for the linear lighting system. ISReflectionsRayTracing handles screen-space reflections and should use conditional Color::IrradianceToLinear/Gamma conversions similar to ISCompositeLensFlareVolumetricLighting.hlsl. ISWorldMap performs 7x7 color accumulation that should be done in linear space similar to the pattern used in ISSAOComposite.hlsl.

Applied to files:

  • src/Features/InteriorSunShadows.cpp
📚 Learning: in the skyrim-community-shaders repository, file deletion error handling improvements that replace e...
Learnt from: alandtse
PR: doodlum/skyrim-community-shaders#0
File: :0-0
Timestamp: 2025-07-05T05:20:45.823Z
Learning: In the skyrim-community-shaders repository, file deletion error handling improvements that replace existence checks and try-catch blocks with std::filesystem::remove error-code-based approaches are considered bug fixes rather than refactoring, as they address inadequate error handling and misleading log messages.

Applied to files:

  • src/Features/InteriorSunShadows.cpp
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build plugin and addons
🔇 Additional comments (2)
src/Features/InteriorSunShadows.cpp (2)

40-40: Good use of symbolic constant instead of magic number

Replacing the hardcoded 0x90 with REL::NOP improves code clarity and maintainability.


45-48: Core fix for interior light level calculations

These patches correctly address the PR objective by forcing raycast checks in AIProcess::CalculateLightValue for interior cells with directional lights. The conditional NOP fills accommodate different instruction layouts between Anniversary Edition and other versions.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Aug 5, 2025

Using provided base ref: 3f1ec27
Using base ref: 3f1ec27
Base commit date: 2025-08-04T10:19:03-07:00 (Monday, August 04, 2025 10:19 AM)
No actionable suggestions for changed features.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Aug 5, 2025

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

@alandtse alandtse merged commit 9b81247 into community-shaders:dev Aug 5, 2025
15 checks passed
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