Skip to content

feat(grass lighting): add wrapped lighting toggle#1721

Merged
doodlum merged 12 commits into
community-shaders:devfrom
BigBullmoose:BigBullmoose-wrappedgrasslighting
Jan 19, 2026
Merged

feat(grass lighting): add wrapped lighting toggle#1721
doodlum merged 12 commits into
community-shaders:devfrom
BigBullmoose:BigBullmoose-wrappedgrasslighting

Conversation

@BigBullmoose
Copy link
Copy Markdown
Contributor

@BigBullmoose BigBullmoose commented Jan 16, 2026

Adds the option to enable a wrapped lighting model on grass, a function taken from a CS v1.3. Prevents certain grass mods from looking too dark when sunlight is directly overhead.

Summary by CodeRabbit

  • New Features

    • Added an "Enable Wrapped Lighting" toggle for grass lighting; renderer now supports both wrapped and standard diffuse lighting modes and the setting is persisted.
  • UI

    • Lighting settings include a new checkbox with a hover tooltip explaining wrapped lighting, plus adjusted spacing for clarity.

✏️ Tip: You can customize this high-level summary in your review settings.

toggles the use of a wrapped lighting model on grass from an older version of CS. Prevents certain grass mods from being too dark when sunlight is directly overhead.
Add toggle checkbox under lighting tree section of grass lighting UI
default value is disabled
adds toggleable wrapped light function if setting is enabled
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 16, 2026

📝 Walkthrough

Walkthrough

Adds a toggleable EnableWrappedLighting flag in shader shared data, engine settings/serialization, and UI, and conditions the grass shader to choose between wrapped-lighting math and the original diffuse lighting path.

Changes

Cohort / File(s) Summary
Shader Shared Data
package/Shaders/Common/SharedData.hlsli
Replaced float3 pad0 with bool EnableWrappedLighting and float2 pad0 in GrassLightingSettings, changing struct layout.
Grass Shader Logic
package/Shaders/RunGrass.hlsl
Added conditional branch using SharedData::grassLightingSettings.EnableWrappedLighting to select wrapped-lighting math (compute wrapAmountwrappedDirLight) or the original saturate(dirLightAngle) diffuse accumulation; minor preprocessor formatting changes.
Settings Struct
src/Features/GrassLighting.h
Replaced pad[3] with EnableWrappedLighting and pad[2] in GrassLighting::Settings (default false), changing public struct layout and padding.
UI & Serialization
src/Features/GrassLighting.cpp
Added EnableWrappedLighting to settings serialization and a checkbox "Enable Wrapped Lighting" in the Grass Lighting UI with tooltip and spacing adjustments.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant UI
  participant EngineSettings
  participant Shader
  participant GPU

  User->>UI: Toggle "Enable Wrapped Lighting"
  UI->>EngineSettings: Update EnableWrappedLighting
  EngineSettings->>Shader: Supply SharedData (EnableWrappedLighting)
  Shader->>GPU: Execute grass shader per-pixel
  alt EnableWrappedLighting == true
    Shader->>GPU: compute wrapAmount\ncompute wrappedDirLight\naccumulate wrapped diffuse
  else
    Shader->>GPU: compute saturate(dirLightAngle)\naccumulate standard diffuse
  end
  GPU-->>Shader: lighting result
  Shader-->>EngineSettings: render output
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • jiayev
  • doodlum

Poem

🐰
I flipped a switch and watched the blades align,
Wrapped glow or straight — each blade can shine,
A hop, a nibble, a shader's tiny grin,
Green fields shimmer as the day begins. 🌿

🚥 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 'feat(grass lighting): add wrapped lighting toggle' directly and clearly summarizes the main change: adding a wrapped lighting toggle feature for grass lighting.

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


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

Using provided base ref: 7ee4c02
Using base ref: 7ee4c02
Base commit date: 2026-01-15T15:11:03Z (Thursday, January 15, 2026 03:11 PM)
No actionable suggestions for changed features.

Automated formatting by clang-format, prettier, and other hooks.
See https://pre-commit.ci for details.
@BigBullmoose BigBullmoose marked this pull request as ready for review January 16, 2026 20:31
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

🤖 Fix all issues with AI agents
In `@package/Shaders/RunGrass.hlsl`:
- Around line 632-643: The wrapped lighting branch in RunGrass.hlsl (guarded by
SharedData::grassLightingSettings.EnableWrappedLighting) double-applies
dirDetailShadow and omits the grass diffuse multiplier: adjust the
lightsDiffuseColor assignment so it does not multiply by dirDetailShadow again
if dirLightColor already includes it, and add Color::GrassDiffuseMult() just
like the standard branch; specifically, replace the current lightsDiffuseColor
+= dirLightColor * saturate(wrappedDirLight) * dirDetailShadow; with a single
multiplication that uses dirLightColor (no extra dirDetailShadow) times
saturate(wrappedDirLight) times Color::GrassDiffuseMult() to match the standard
model.

Comment thread package/Shaders/RunGrass.hlsl
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 16, 2026

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

BigBullmoose and others added 2 commits January 16, 2026 13:35
Listened to rabbit, replaced dirdetailshadow with grassdiffusemultiplier on line 637, farther away grass looks better now.
Automated formatting by clang-format, prettier, and other hooks.
See https://pre-commit.ci for details.
Copy link
Copy Markdown
Collaborator

@doodlum doodlum left a comment

Choose a reason for hiding this comment

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

"Old wrapped lighting model from CS 1.3" is not an explanation of what the toggle actually does.

update tootltip description explanation
Copy link
Copy Markdown
Collaborator

@doodlum doodlum left a comment

Choose a reason for hiding this comment

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

Point lights do not get the new model

BigBullmoose and others added 2 commits January 18, 2026 11:43
add wrapped model to point lights when enabled
Automated formatting by clang-format, prettier, and other hooks.
See https://pre-commit.ci for details.
Copy link
Copy Markdown
Collaborator

@doodlum doodlum left a comment

Choose a reason for hiding this comment

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

wrapAmount is duplicated

BigBullmoose and others added 2 commits January 18, 2026 15:16
remove duplicate wrapamount float, moved first wrapamount float outside of the "if" function so it could be read further down
Automated formatting by clang-format, prettier, and other hooks.
See https://pre-commit.ci for details.
@BigBullmoose BigBullmoose requested a review from doodlum January 19, 2026 23:03
@doodlum doodlum merged commit 44eb788 into community-shaders:dev Jan 19, 2026
16 checks passed
@BigBullmoose BigBullmoose deleted the BigBullmoose-wrappedgrasslighting branch January 20, 2026 01:09
@coderabbitai coderabbitai Bot mentioned this pull request May 9, 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