Skip to content

feat(truepbr): add vertex ambient occlusion slider#2329

Merged
alandtse merged 9 commits into
devfrom
disablevao
May 15, 2026
Merged

feat(truepbr): add vertex ambient occlusion slider#2329
alandtse merged 9 commits into
devfrom
disablevao

Conversation

@jiayev
Copy link
Copy Markdown
Collaborator

@jiayev jiayev commented May 12, 2026

This pull request introduces a configurable Vertex Ambient Occlusion (AO) strength parameter for the TruePBR rendering system, making AO blending more flexible and user-tunable. The main changes include adding a new VertexAOStrength setting, updating the shader and UI to use this parameter, and implementing serialization for the new setting.

TruePBR Settings Enhancements:

  • Added a new VertexAOStrength parameter to TruePBR::Settings, exposed in the UI via an ImGui slider, allowing users to control the influence of vertex AO in the shader. [1] [2]
  • Implemented serialization and deserialization methods (SaveSettings, LoadSettings, RestoreDefaultSettings) for TruePBR::Settings to support saving/loading user preferences. [1] [2]
  • Registered the new setting with the feature buffer and JSON serialization system, ensuring it is included in configuration files and GPU constant buffers. [1] [2] [3]

Shader Integration:

  • Defined a new TruePBRSettings struct in SharedData.hlsli and added it to the FeatureData constant buffer, making VertexAOStrength available to shaders. [1] [2]
  • Updated the skylighting code path in Lighting.hlsl to blend vertex AO using the new VertexAOStrength parameter, providing finer control over AO application in TruePBR mode.

Summary by CodeRabbit

  • New Features

    • Added a global "Vertex AO Strength" slider with save/load/restore defaults in the UI.
  • Visual / Lighting

    • Vertex ambient occlusion now respects the Vertex AO Strength, affecting vertex-color remapping, skylighting diffuse response, and emissive scaling for more controllable vertex-based shading.

Review Change Stack

@github-actions
Copy link
Copy Markdown

No actionable suggestions for changed features.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 12, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a float VertexAOStrength setting to TruePBR (UI slider + JSON persistence), packs it into the feature buffer, exposes it in SharedData::FeatureData, and uses it in Lighting.hlsl to remap vertexAO and adjust vertex-color/emissive handling in TRUE_PBR paths.

Changes

TruePBR Vertex AO Strength

Layer / File(s) Summary
Settings struct definition and persistence
src/TruePBR.h, src/TruePBR.cpp
TruePBR::Settings (alignas(16)) now contains float VertexAOStrength with padding; SaveSettings, LoadSettings, RestoreDefaultSettings methods added; NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT extended to serialize VertexAOStrength; ImGui exposes VertexAOStrength via a slider.
Shader constant buffer definitions
package/Shaders/Common/SharedData.hlsli
Defines SharedData::TruePBRSettings { float VertexAOStrength; uint3 pad; } and adds TruePBRSettings truePBRSettings to SharedData::FeatureData.
Shader vertexAO remapping and skylighting
package/Shaders/Lighting.hlsl
In TRUE_PBR vertex/AO/emissive/skylighting handling, the shader derives pbrVertexAO from the max vertex-color channel, remaps pbrVertexColor/emitVertexColor using SharedData::truePBRSettings.VertexAOStrength, forces vertexColor where noted, and renormalizes skylighting diffuse using the remapped AO.
Feature buffer C++ integration
src/FeatureBuffer.cpp
TruePBR.h included and GetFeatureBufferData packs globals::features::truePBR.settings into the feature-buffer payload so the GPU constant buffer receives the new setting.

Sequence Diagram(s)

sequenceDiagram
  participant ImGui as ImGui DrawSettings
  participant Settings as globals::features::truePBR.settings
  participant FB as GetFeatureBufferData
  participant CB as Shader FeatureData cbuffer
  participant PS as Lighting pixel shader
  ImGui->>Settings: adjust VertexAOStrength (slider)
  Settings->>FB: read settings for packing
  FB->>CB: pack/send FeatureData.truePBRSettings to GPU
  CB->>PS: pixel shader reads VertexAOStrength
  PS->>PS: remap vertexAO = lerp(1, vertexAO, VertexAOStrength)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • doodlum
  • SkrubbySkrubInAShrub

Poem

A rabbit tweaks a slider bright and keen,
Vertex AO now mixes: soft and clean,
From ImGui to JSON, slid into the stream,
Buffers whisper values to the shader dream,
Hoppity hop—pixels glow serene! 🐇✨

🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title accurately summarizes the main change: adding a vertex ambient occlusion strength slider to the TruePBR feature.

✏️ 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 disablevao

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.

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

50-54: ⚡ Quick win

Consider zero-initializing the padding array.

The pad[3] array lacks a default member initializer. While RestoreDefaultSettings() does zero-initialize the entire struct via aggregate initialization ({}), a new Settings instance created without explicit initialization will have uninitialized padding bytes. This won't affect shader functionality (padding is not read), but could lead to non-deterministic behavior when copying or comparing structs.

♻️ Suggested initialization
 struct alignas(16) Settings
 {
 	uint DisableVertexAO = false;
-	uint pad[3];
+	uint pad[3] = {};
 };
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/TruePBR.h` around lines 50 - 54, The Settings struct's padding array
pad[3] is not default-initialized which can leave those bytes indeterminate;
update the struct definition (struct Settings) to provide a default initializer
for pad (e.g. pad[3] = {} ) so any new Settings() has deterministically zeroed
padding; this keeps RestoreDefaultSettings() behavior but prevents
non-deterministic copies or comparisons.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/TruePBR.h`:
- Around line 50-54: The Settings struct's padding array pad[3] is not
default-initialized which can leave those bytes indeterminate; update the struct
definition (struct Settings) to provide a default initializer for pad (e.g.
pad[3] = {} ) so any new Settings() has deterministically zeroed padding; this
keeps RestoreDefaultSettings() behavior but prevents non-deterministic copies or
comparisons.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b141c1f0-5413-4c7c-b645-2d3ad2cc0989

📥 Commits

Reviewing files that changed from the base of the PR and between 9a3e7b5 and f0313c1.

📒 Files selected for processing (5)
  • package/Shaders/Common/SharedData.hlsli
  • package/Shaders/Lighting.hlsl
  • src/FeatureBuffer.cpp
  • src/TruePBR.cpp
  • src/TruePBR.h

@SkrubbySkrubInAShrub
Copy link
Copy Markdown
Collaborator

wouldn't a slider be better for this? no vetex AO can also look bad

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 12, 2026

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

@jiayev jiayev changed the title feat(TruePBR): add settings to disable vertex AO feat(TruePBR): add slider for vertex AO May 13, 2026
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/TruePBR.cpp (1)

43-45: PR metadata suggestion: align title/body with the current implementation.

Since the feature now exposes strength control (not only disable), a clearer title would be: feat(truepbr): add vertex ao strength setting. If tracked by an issue, consider adding Implements #<id> or Addresses #<id> in the PR description.

As per coding guidelines **/*: "When reviewing PRs, please provide suggestions for Conventional Commit Titles ... and Issue References".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/TruePBR.cpp` around lines 43 - 45, The PR title/body should be updated to
reflect the new feature exposing vertex AO strength: change the commit/PR title
to something like "feat(truepbr): add vertex ao strength setting" and update the
description to mention TruePBR::Settings and the VertexAOStrength field; if this
change implements or addresses an issue, add "Implements #<id>" or "Addresses
#<id>" in the PR body to satisfy the Conventional Commit / PR metadata
guideline.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/TruePBR.cpp`:
- Around line 317-320: LoadSettings currently copies user JSON blindly into
settings which can propagate malformed or out-of-range VertexAOStrength into
shaders; change LoadSettings to explicitly read VertexAOStrength from o_json
(e.g. check for key, ensure it's a number), convert to a float, clamp it to a
safe range (e.g. 0.0f–1.0f) and assign that value into
settings["VertexAOStrength"] (or the struct member you use), falling back to a
known default if missing or invalid; reference the LoadSettings function and the
VertexAOStrength setting when making this change.

---

Nitpick comments:
In `@src/TruePBR.cpp`:
- Around line 43-45: The PR title/body should be updated to reflect the new
feature exposing vertex AO strength: change the commit/PR title to something
like "feat(truepbr): add vertex ao strength setting" and update the description
to mention TruePBR::Settings and the VertexAOStrength field; if this change
implements or addresses an issue, add "Implements #<id>" or "Addresses #<id>" in
the PR body to satisfy the Conventional Commit / PR metadata guideline.
🪄 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 Plus

Run ID: 056d0bdc-efb5-4936-877c-ac1dfd620b85

📥 Commits

Reviewing files that changed from the base of the PR and between f0313c1 and 3c36845.

📒 Files selected for processing (4)
  • package/Shaders/Common/SharedData.hlsli
  • package/Shaders/Lighting.hlsl
  • src/TruePBR.cpp
  • src/TruePBR.h

Comment thread src/TruePBR.cpp
@doodlum
Copy link
Copy Markdown
Collaborator

doodlum commented May 13, 2026

This does almost nothing? But at least this way it doesn't change the color of trees etc.

@jiayev
Copy link
Copy Markdown
Collaborator Author

jiayev commented May 13, 2026

This does almost nothing? But at least this way it doesn't change the color of trees etc.

fixed

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

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@package/Shaders/Lighting.hlsl`:
- Around line 2158-2159: Clamp SharedData::truePBRSettings.VertexAOStrength to
[0,1] before using it in any lerp/extrapolation so the shader cannot over- or
under-apply AO; specifically, compute a local float (e.g.,
clampedVertexAOStrength) = clamp(SharedData::truePBRSettings.VertexAOStrength,
0.0, 1.0) and use that variable in the lerp that modifies pbrVertexColor (the
expression around pbrVertexAO / pbrVertexColor), and apply the same fix to the
other similar uses referenced in this review (the uses around the other
VertexAOStrength sites).
🪄 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 Plus

Run ID: e3c0ca50-cf95-48b7-b678-58e4b4228357

📥 Commits

Reviewing files that changed from the base of the PR and between dc5aaa2 and 2ca4ea7.

📒 Files selected for processing (1)
  • package/Shaders/Lighting.hlsl

Comment thread package/Shaders/Lighting.hlsl
@alandtse alandtse changed the title feat(TruePBR): add slider for vertex AO feat(PBR): add vertex ambient occlusion slider May 15, 2026
@alandtse
Copy link
Copy Markdown
Collaborator

@coderabbitai what's the standard scope we use for pbr?

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 15, 2026

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check git log for recent commits related to PBR/TruePBR to find standard scope
git log --oneline -50 | grep -i -E "pbr|truepbr"

# Check CONTRIBUTING or similar docs
fd -i "CONTRIBUTING" --exec cat {}

# Also check for any commit message conventions or PR title conventions
git log --oneline -100 | grep -i "feat\|fix\|chore" | head -40

Length of output: 2933


@alandtse There's some inconsistency in the repo's history, but the predominant pattern based on recent commits is:

  • Feature commits use TruePBR (PascalCase) — e.g. feat(TruePBR): add settings to disable vertex AO, feat(TruePBR): replace DisableVertexAO with VertexAOStrength
  • Fix commits use truepbr (all-lowercase) — e.g. fix(truepbr): remove EnvmapData breaking MATOs, fix(truepbr): apply MATO rbg scalars through cbuffer
  • A smaller number of commits use the shorter pbr scope — e.g. refactor(pbr): use feature boundary, feat(PBR): enhance vertex color application

So the current PR title feat(TruePBR): add slider for vertex AO follows the established convention for feature commits. If the repo were to standardize, the choice would be between TruePBR and truepbr (conventional commits spec recommends lowercase scopes), but the current usage seems intentional with PascalCase for features.

@alandtse alandtse changed the title feat(PBR): add vertex ambient occlusion slider feat(truepbr): add vertex ambient occlusion slider May 15, 2026
@alandtse alandtse merged commit cefdcde into dev May 15, 2026
15 of 16 checks passed
@alandtse alandtse deleted the disablevao branch May 15, 2026 08:33
ParticleTroned pushed a commit to ParticleTroned/skyrim-community-shaders that referenced this pull request May 16, 2026
…#2329)

Co-authored-by: Skrubby Skrub In A Shrub <87662196+SkrubbySkrubInAShrub@users.noreply.github.com>
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.

4 participants