Skip to content

fix(Volumetric Shadows): Interior Sun Compatibility #1935

Closed
Dlizzio wants to merge 7 commits into
community-shaders:devfrom
Dlizzio:interior-sun-volumetric-shadows
Closed

fix(Volumetric Shadows): Interior Sun Compatibility #1935
Dlizzio wants to merge 7 commits into
community-shaders:devfrom
Dlizzio:interior-sun-volumetric-shadows

Conversation

@Dlizzio
Copy link
Copy Markdown
Contributor

@Dlizzio Dlizzio commented Feb 23, 2026

Removes IsInterior checks when appropriate for Interior Sun. Volumetric Shadows only works for directional lighting so it makes sense to remove interior checks instead of adding an interior sun check.

Added effect mesh sun influence slider for effect meshes.

Summary by CodeRabbit

  • New Features

    • Added "Effect Mesh Sun Influence" slider (0–100%) to control how sunlight affects interior effect meshes.
    • Interior sun settings are now exposed to the renderer so meshes can respect the new influence parameter.
  • Bug Fixes / Visual Improvements

    • Improved interior lighting and shadow blending, including volumetric and world-shadow paths, for more consistent interior visuals.

Removes IsInterior checks when appropriate for Interior Sun. Volumetric Shadows only works for directional lighting so it makes sense to remove interior checks instead of adding an interior sun check.

Added effect mesh sun influence slider for effect meshes.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 23, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: a37f6fa7-a3bf-4952-844d-aecd594ac774

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds interior-sun shader data and runtime plumbing: new SharedData::InteriorSunSettings, shader logic updated to honor IsInteriorWithSun and EffectMeshSunInfluence, Feature-side GetShaderSettings() + UI/serialization, and feature buffer upload of the new settings.

Changes

Cohort / File(s) Summary
Shader Shared Data
package/Shaders/Common/SharedData.hlsli
Added InteriorSunSettings struct (EffectMeshSunInfluence, IsInteriorWithSun, padding) and appended it to the FeatureData cbuffer.
Shader Lighting & Shadows
package/Shaders/Effect.hlsl, package/Shaders/Lighting.hlsl, package/Shaders/RunGrass.hlsl, package/Shaders/ISVolumetricLightingGenerateCS.hlsl
Integrated interior-sun flag into shadow/lighting code: removed some interior-only guards, added conditional sampling/paths to honor IsInteriorWithSun, and applied EffectMeshSunInfluence when blending sun influence on final color.
Feature Implementation
src/Features/InteriorSun.h, src/Features/InteriorSun.cpp
Added ShaderSettings (aligned) with EffectMeshSunInfluence and IsInteriorWithSun, added Settings::EffectMeshSunInfluence, UI slider, serialization update, and GetShaderSettings() accessor that returns shader-ready values.
Feature Integration
src/FeatureBuffer.cpp
Included InteriorsSun.h and appended interiorSun.GetShaderSettings() to the feature buffer data passed to _GetFeatureBufferData.

Sequence Diagram(s)

sequenceDiagram
    participant Runtime as Runtime (InteriorSun feature)
    participant FeatureBuf as FeatureBuffer
    participant GPU as GPU Shader (SharedData / Effect)
    participant Shadow as ShadowSystem

    Runtime->>FeatureBuf: GetShaderSettings() (EffectMeshSunInfluence, IsInteriorWithSun)
    FeatureBuf->>GPU: Upload FeatureData.cbuffer (includes InteriorSunSettings)
    GPU->>Shadow: Request shadow sample (shadowMap / compute3DFilteredShadow)
    Shadow-->>GPU: ShadowValue
    GPU->>GPU: Apply lighting path (dirColor + ambient)
    note right of GPU: if IsInteriorWithSun -> lerp using EffectMeshSunInfluence\nelse -> standard shadow * dirColor
    GPU-->>Runtime: Rendered output (final color)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • doodlum
  • SkrubbySkrubInAShrub
  • alandtse

Poem

🐰 I nibble code at break of day,
I tuck bright sun where shadows play,
Meshes gleam with gentle sway,
Interiors catch the solar ray,
Hop—now rooms can bask and stay.

🚥 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 'fix(Volumetric Shadows): Interior Sun Compatibility' is clear, specific, and directly reflects the main objective: enabling volumetric shadows to work with the Interior Sun feature by removing interior guards.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Automated formatting by clang-format, prettier, and other hooks.
See https://pre-commit.ci for details.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 23, 2026

Actionable Suggestions

  • Interior Sun (Dlizzio): Needs version bump to 1-0-1

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/InteriorSun.h (1)

40-52: Add compile-time layout checks for ShaderSettings.
Since this struct is copied into the feature buffer and mirrored in HLSL, a size/alignment static_assert will catch accidental layout drift.

♻️ Proposed refactor
 struct alignas(16) ShaderSettings
 {
 	float EffectMeshSunInfluence = 1.0f;
 	uint32_t IsInteriorWithSun = 0;
 	float pad[2] = {};
 };
+
+static_assert(sizeof(ShaderSettings) == 16, "ShaderSettings must match HLSL InteriorSunSettings size");
+static_assert(alignof(ShaderSettings) == 16, "ShaderSettings must match HLSL InteriorSunSettings alignment");
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Features/InteriorSun.h` around lines 40 - 52, Add compile-time layout
checks for ShaderSettings to prevent layout drift between C++ and HLSL: inside
the same header (after struct ShaderSettings declaration) add static_asserts
that validate sizeof(ShaderSettings) matches the expected byte size and that
alignof(ShaderSettings) is 16, and optionally check offsetof(ShaderSettings,
IsInteriorWithSun) (and other fields) against expected byte offsets; keep the
checks near ShaderSettings/GetShaderSettings so failures point to the right type
and update the expected constants if the HLSL layout changes.
🤖 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/InteriorSun.cpp`:
- Around line 227-233: GetShaderSettings currently writes
settings.EffectMeshSunInfluence directly into ShaderSettings after multiplying
by 0.01f, which can produce out-of-range lerp values if LoadSettings
deserialized bad data; clamp settings.EffectMeshSunInfluence to [0,100] (or
clamp the resulting data.EffectMeshSunInfluence to [0.0f,1.0f]) inside
InteriorSun::GetShaderSettings before scaling/assigning so
ShaderSettings.EffectMeshSunInfluence is guaranteed within [0,1]; update
GetShaderSettings (referencing EffectMeshSunInfluence, ShaderSettings, and
GetShaderSettings) to perform the clamp and then return the sanitized value.

---

Nitpick comments:
In `@src/Features/InteriorSun.h`:
- Around line 40-52: Add compile-time layout checks for ShaderSettings to
prevent layout drift between C++ and HLSL: inside the same header (after struct
ShaderSettings declaration) add static_asserts that validate
sizeof(ShaderSettings) matches the expected byte size and that
alignof(ShaderSettings) is 16, and optionally check offsetof(ShaderSettings,
IsInteriorWithSun) (and other fields) against expected byte offsets; keep the
checks near ShaderSettings/GetShaderSettings so failures point to the right type
and update the expected constants if the HLSL layout changes.

Comment thread src/Features/InteriorSun.cpp
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.

🧹 Nitpick comments (1)
src/Features/InteriorSun.cpp (1)

1-1: PR title: scope should be lowercase per conventional commits guideline.

fix(Volumetric Shadows): uses a capitalized, multi-word scope. Per the coding guidelines, scopes should be lowercase (e.g., fix(volumetric-shadows): compatibility with interior sun). The current title is also one character over the 50-character limit.

📝 Suggested title
fix(volumetric-shadows): compatibility with interior sun

As per coding guidelines: "Format: type(scope): description … Style: lowercase description … Examples: fix(water): resolve flowmap bug".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Features/InteriorSun.cpp` at line 1, The PR title uses a capitalized
multi-word scope "Volumetric Shadows" and exceeds the 50-character limit; update
the commit/PR title to use a lowercase, hyphenated scope and shorten the
description (e.g., change from `fix(Volumetric Shadows): ...` to
`fix(volumetric-shadows): compatibility with interior sun`) so it follows the
conventional commits style and stays within 50 characters.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@src/Features/InteriorSun.cpp`:
- Around line 227-233: Ensure EffectMeshSunInfluence is clamped before scaling
so GPU value stays in [0,1]: inside InteriorSun::GetShaderSettings() clamp
settings.EffectMeshSunInfluence with std::clamp(..., 0.0f, 100.0f) and then
multiply by 0.01f to assign to ShaderSettings::EffectMeshSunInfluence; keep the
method const and set ShaderSettings::IsInteriorWithSun using isInteriorWithSun ?
1u : 0u so deserialized out-of-range inputs from LoadSettings() cannot produce
invalid GPU values.

---

Nitpick comments:
In `@src/Features/InteriorSun.cpp`:
- Line 1: The PR title uses a capitalized multi-word scope "Volumetric Shadows"
and exceeds the 50-character limit; update the commit/PR title to use a
lowercase, hyphenated scope and shorten the description (e.g., change from
`fix(Volumetric Shadows): ...` to `fix(volumetric-shadows): compatibility with
interior sun`) so it follows the conventional commits style and stays within 50
characters.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 23, 2026

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

Comment thread package/Shaders/ISVolumetricLightingGenerateCS.hlsl Outdated
Comment thread src/Features/InteriorSun.h
Copy link
Copy Markdown
Collaborator

@alandtse alandtse left a comment

Choose a reason for hiding this comment

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

Is the old inInterior flag deprecated now? Should it be removed?

@alandtse alandtse changed the title fix(Volumetric Shadows): Compatibility with Interior Sun fix(Volumetric Shadows): Interior Sun Compatibility Feb 23, 2026
@Dlizzio
Copy link
Copy Markdown
Contributor Author

Dlizzio commented Feb 23, 2026

Is the old inInterior flag deprecated now? Should it be removed?

It is used broadly with other 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.

🧹 Nitpick comments (1)
package/Shaders/ISVolumetricLightingGenerateCS.hlsl (1)

89-89: PR title doesn't follow the conventional commits style.

The title fix(Volumetric Shadows): Interior Sun Compatibility has a Title-Case scope and description, and is one character over the 50-character limit. A conforming title would be:

fix(volumetric shadows): interior sun compatibility

As per coding guidelines, the scope and description should be lowercase with no ending period, and the title should stay within 50 characters.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package/Shaders/ISVolumetricLightingGenerateCS.hlsl` at line 89, Update the
PR title to follow conventional commits: change it to "fix(volumetric shadows):
interior sun compatibility" (lowercase scope and description, no trailing
period) and ensure it is <=50 characters; this relates to the change touching
ISVolumetricLightingGenerateCS.hlsl (e.g., the noShadow / SharedData::InInterior
logic) so update the pull request title accordingly before merging.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@package/Shaders/ISVolumetricLightingGenerateCS.hlsl`:
- Line 89: Update the PR title to follow conventional commits: change it to
"fix(volumetric shadows): interior sun compatibility" (lowercase scope and
description, no trailing period) and ensure it is <=50 characters; this relates
to the change touching ISVolumetricLightingGenerateCS.hlsl (e.g., the noShadow /
SharedData::InInterior logic) so update the pull request title accordingly
before merging.
ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 46aeed9 and eff951d.

📒 Files selected for processing (2)
  • package/Shaders/ISVolumetricLightingGenerateCS.hlsl
  • src/Features/InteriorSun.h
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/Features/InteriorSun.h

@Dlizzio Dlizzio marked this pull request as draft February 23, 2026 11:21
@Dlizzio
Copy link
Copy Markdown
Contributor Author

Dlizzio commented Feb 24, 2026

Drafting this until I look at effect meshes problem with Volumetric Shadows.

@Dlizzio Dlizzio closed this May 11, 2026
@Dlizzio Dlizzio deleted the interior-sun-volumetric-shadows branch May 11, 2026 15:19
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