Skip to content

feat(ISL): added light size control#1342

Merged
alandtse merged 3 commits into
community-shaders:devfrom
sicsix:isl-lightsize
Jul 31, 2025
Merged

feat(ISL): added light size control#1342
alandtse merged 3 commits into
community-shaders:devfrom
sicsix:isl-lightsize

Conversation

@sicsix
Copy link
Copy Markdown
Collaborator

@sicsix sicsix commented Jul 31, 2025

Summary by CodeRabbit

  • New Features

    • Added a new "Size" parameter for inverse square lights, allowing users to adjust light falloff based on field of view.
    • Updated the light editor UI with new sliders for "Size" and "Cutoff" for inverse square lights.
  • Improvements

    • Enhanced attenuation and radius calculations to incorporate the new "Size" parameter, resulting in more accurate and customizable lighting effects.
    • Improved handling and assignment of light properties such as fade and radius for better consistency.
  • Bug Fixes

    • Addressed synchronization issues in light data assignment for both inverse square and standard lights.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jul 31, 2025

Walkthrough

This change introduces and propagates a new "size" parameter for lights, derived from the field of view (FOV), into both C++ and shader code. It updates attenuation and radius calculations, modifies struct layouts to include the size field, and adjusts the light editor UI to support editing this new parameter for inverse square lights.

Changes

Cohort / File(s) Change Summary
Shader Attenuation Update
features/Inverse Square Lighting/Shaders/InverseSquareLighting/InverseSquareLighting.hlsli
Modified attenuation calculation in GetAttenuation to include light size squared, altering the attenuation falloff behavior based on the new size parameter.
Shader Light Struct Layout
features/Light Limit Fix/Shaders/LightLimitFix/Common.hlsli
Reordered and added float members (fade, invRadius, fadeZone, size) after color and radius; moved invRadius and fadeZone from end; added two uint paddings (pad0, pad1) at the end of the Light struct.
Core Attenuation & Radius Logic
src/Features/InverseSquareLighting.cpp, src/Features/InverseSquareLighting.h
Incorporated the size parameter throughout the inverse square lighting calculations, updated function signatures, and ensured size is stored and propagated in runtime data and processing functions.
Runtime Light Data Struct
src/Features/InverseSquareLighting/Common.h
Changed radius from a vector to a float, added pad1C and size float members to RuntimeLightDataExt struct.
Light Editor UI/Logic
src/Features/InverseSquareLighting/LightEditor.cpp
Updated UI and logic to support editing the new size parameter for inverse square lights, adjusted radius assignment, and improved cutoff override handling.
Light Limit Fix Shader & Struct
src/Features/LightLimitFix.cpp, src/Features/LightLimitFix.h
Added fade assignment in the light setup logic; updated LightData struct to add fade, invRadius, fadeZone, and size fields, with padding at the end.
Configuration Update
features/Inverse Square Lighting/Shaders/Features/InverseSquareLighting.ini
Updated version number from 1-0-0 to 1-1-0.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant LightEditor
    participant RuntimeLightData
    participant Shader

    User->>LightEditor: Adjusts light FOV/size in UI
    LightEditor->>RuntimeLightData: Updates size and radius fields
    RuntimeLightData->>Shader: Passes size and radius to shader
    Shader->>Shader: Calculates attenuation using size in denominator
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~18 minutes

Possibly related PRs

Suggested reviewers

  • alandtse

Poem

A rabbit hopped with coding delight,
As lights grew smarter, shining bright.
With size and fade, the beams now play,
Attenuation falls the modern way.
From code to shader, changes flow—
Illuminating scenes with a radiant glow!
🐇💡✨

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 3a8ef8c and 2b8cb60.

📒 Files selected for processing (1)
  • package/Shaders/Common/PBR.hlsli (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
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: alandtse
PR: doodlum/skyrim-community-shaders#577
File: features/Wetness Effects/Shaders/WetnessEffects/WetnessEffects.hlsli:57-61
Timestamp: 2025-06-17T05:40:22.785Z
Learning: Default parameter values are supported in the HLSL compiler used by the skyrim-community-shaders project, contrary to standard HLSL (FXC/DXC) limitations.
Learnt from: alandtse
PR: doodlum/skyrim-community-shaders#577
File: src/Features/WetnessEffects.h:36-36
Timestamp: 2025-06-08T11:25:14.536Z
Learning: In the skyrim-community-shaders project, boolean flags in C++ structs that interface with HLSL shaders use `uint` type instead of `bool` for compatibility reasons. This ensures consistent 4-byte size, proper 16-byte alignment in constant buffers, and cross-platform compatibility when passing data between C++ and HLSL shaders.
Learnt from: davo0411
PR: doodlum/skyrim-community-shaders#1070
File: src/State.cpp:79-83
Timestamp: 2025-05-30T11:44:15.542Z
Learning: In the Skyrim Community Shaders project, the `smoothDrawCalls` array in the `State` class is declared as type `double` in `src/State.h`, which is the correct floating-point type for performing exponential moving average smoothing calculations.
🔇 Additional comments (1)
package/Shaders/Common/PBR.hlsli (1)

150-150: Mathematical correctness fix for power function.

The addition of abs() ensures the base of the power function is non-negative, preventing undefined behavior when NdotV + ao becomes negative. This is mathematically necessary since pow(x, y) with negative x and non-integer y is undefined in real numbers. The exponent exp2(-16.0 * roughness - 1.0) is typically non-integer, making this protection essential for stable shader execution.

✨ Finishing Touches
🧪 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.
    • @coderabbitai modularize this function.
  • 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.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

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

Using provided base ref: 58ab563
Using base ref: 58ab563
Base commit date: 2025-07-30T20:11:53-07:00 (Wednesday, July 30, 2025 08:11 PM)
No actionable suggestions for changed features.

@github-actions
Copy link
Copy Markdown

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

@alandtse alandtse merged commit 93c4fef into community-shaders:dev Jul 31, 2025
13 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Sep 15, 2025
@coderabbitai coderabbitai Bot mentioned this pull request May 8, 2026
4 tasks
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