Skip to content

rtxpt noise method#36

Open
jiayev wants to merge 7 commits into
Gistix:mainfrom
jiayev:main
Open

rtxpt noise method#36
jiayev wants to merge 7 commits into
Gistix:mainfrom
jiayev:main

Conversation

@jiayev

@jiayev jiayev commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features
    • Introduced low-discrepancy, deterministic sampling sequences to improve raytracing noise characteristics and consistency during progressive rendering.
    • Enhanced BSDF sampling by using caller-provided precomputed samples to improve stability and reduce variance.
  • Bug Fixes
    • Improved the underlying random sampling strategy to be more consistent across frames/steps.
    • Fixed stable-plane delta-lobe selection for water rendering when not inside a water volume.

@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c56a800a-e976-4d0d-885b-4a0e7c5d195a

📥 Commits

Reviewing files that changed from the base of the PR and between 02326db and a0ba28f.

⛔ Files ignored due to path filters (1)
  • shaders/raytracing/Pathtracing/RayGeneration.hlsl is excluded by !**/*.hlsl
📒 Files selected for processing (1)
  • shaders/raytracing/include/PathTracerStablePlanes.hlsli

📝 Walkthrough

Walkthrough

A new SampleGenerators.hlsli header introduces Hash32-based hashing, a Sobol quasi-random generator with Owen scrambling, UniformSampleSequenceGenerator and SampleSequenceGenerator structs, and a GenerateScatterBSDFSamples dispatch function. Common.hlsli adopts these utilities, replacing the prior PCG-style RNG and adding a SampleCosineHemisphere(float2) overload. StandardBSDF::SampleBSDF gains a pre-generated-samples overload. StablePlanesHandleHit now accepts Material and implements water surface–driven delta-lobe reordering. Renderer::InitDefaultTextures switches from the copy queue to the graphics queue.

Changes

Shader Sampling Infrastructure and Stable Planes

Layer / File(s) Summary
New SampleGenerators.hlsli: hashing, Sobol, generators, and BSDF sample dispatch
shaders/raytracing/include/SampleGenerators.hlsli
Defines effect/salt constants (kRandomFrameSalt, kRandomStepSalt, effect base/scatter/NEE/RR ids), compile-time macro toggles, Hash32/Hash32Combine/Hash32ToFloat helpers, a Sobol generator with precomputed direction table, Owen-scramble primitives using reversebits, SampleGeneratorVertexBase, UniformSampleSequenceGenerator, SampleSequenceGenerator (with optional low-discrepancy mode controlled by macros and diffuse bounce count threshold), 1D/2D/4D float-sample converters, and GenerateScatterBSDFSamples which dispatches to either low-discrepancy or uniform paths.
Common.hlsli RNG and cosine-hemisphere rewrite
shaders/raytracing/include/Common.hlsli
Adds the SampleGenerators.hlsli include; rewrites InitRandomSeed, PCGHash, and Random to use Hash32/Hash32Combine with kRandomFrameSalt/kRandomStepSalt; adds an InitRandomSeed overload taking vertexIndex and effectSeed; introduces SampleCosineHemisphere(float2) that directly maps a 2D sample to a cosine-weighted hemisphere and delegates the seed-based overload to it.
StandardBSDF::SampleBSDF pre-generated samples overload
shaders/raytracing/include/Materials/BSDF.hlsli
Adds a SampleBSDF overload taking preGeneratedSamples (float4) and extraSamples (float2); routes hair FarField h and lobeRandom from extraSamples instead of generating internally; updates the inout uint randomSeed overload to generate both sample packs then delegate to the new overload.
PathTracerStablePlanes: material-driven water delta-lobe ordering
shaders/raytracing/include/PathTracerStablePlanes.hlsli
StablePlanesHandleHit gains Material material parameter; when hitting water surfaces while above water, rescans active delta lobes and reselects firstActiveLobe to prefer non-transmission (reflected) lobes; replaces direct delta-lobe loop index with order-based iteration that remaps to lobeIdx, evaluating reflected branch first under the water/above-water condition.

Renderer Command Queue Fix

Layer / File(s) Summary
InitDefaultTextures: copy queue → graphics queue
src/Renderer.cpp
Replaces GetCopyCommandList() with GetGraphicsCommandList() and changes submission from CommandQueue::Copy to CommandQueue::Graphics in InitDefaultTextures.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~55 minutes

Possibly Related PRs

  • Gistix/CreationEngineRaytracing#33: Both PRs modify StablePlanesHandleHit in PathTracerStablePlanes.hlsli, adjusting delta-lobe selection and ordering logic—this PR adds material-driven water reflected-lobe prioritization while the related PR addresses entry detection and transmission delta handling.

Poem

🐇 A hop through dimensions, quasi-random and bright,
New Sobol spirals scrambled by Owen's delight,
Hash32 seeds the field where cosine rays fall,
Pre-generated samples arrive before the BSDF call.
Water's reflected gleam now leads the delta way,
The copy queue retires—graphics renders the day! ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

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.
Title check ❓ Inconclusive The title "rtxpt noise method" is vague and generic, failing to clearly convey what aspect of the noise method was changed or implemented. Use a more descriptive title such as "Replace PCG hashing with Hash32-based random number generation" or "Implement low-discrepancy sampling for BSDF evaluation" to better communicate the primary change.
✅ Passed checks (3 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.

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

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

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
shaders/raytracing/include/SampleGenerators.hlsli (1)

160-185: 💤 Low value

startingHash is assigned but never read.

The startingHash field is set in make() (line 172) but is never referenced anywhere in the struct's methods. This appears to be dead code. Either it's intended for future functionality or can be removed to reduce register pressure.

🔧 Remove unused field if not needed
 struct SampleSequenceGenerator
 {
-    uint startingHash;
     uint currentHash;
     uint activeIndex;
     uint dimension;

     static SampleSequenceGenerator make(SampleGeneratorVertexBase base, uint effectSeed, bool lowDiscrepancy, uint subSampleCount)
     {
         SampleSequenceGenerator ret;
         ret.activeIndex = base.sampleIndex * subSampleCount;
         ret.currentHash = Hash32Combine(base.baseHash, effectSeed);
-        ret.startingHash = ret.currentHash;

         if (lowDiscrepancy)
         {
🤖 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 `@shaders/raytracing/include/SampleGenerators.hlsli` around lines 160 - 185,
The `startingHash` field in the `SampleSequenceGenerator` struct is assigned a
value in the `make()` static method but is never read or used anywhere else in
the struct. Remove the unused field declaration from the struct definition and
remove the assignment statement (ret.startingHash = ret.currentHash) from the
`make()` method to eliminate dead code and reduce register pressure.
🤖 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 `@shaders/raytracing/include/SampleGenerators.hlsli`:
- Around line 160-185: The `startingHash` field in the `SampleSequenceGenerator`
struct is assigned a value in the `make()` static method but is never read or
used anywhere else in the struct. Remove the unused field declaration from the
struct definition and remove the assignment statement (ret.startingHash =
ret.currentHash) from the `make()` method to eliminate dead code and reduce
register pressure.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9fc33094-c2e1-44b1-b915-04e293bba520

📥 Commits

Reviewing files that changed from the base of the PR and between 04ae677 and 02326db.

⛔ Files ignored due to path filters (2)
  • shaders/raytracing/GlobalIllumination/RayGeneration.hlsl is excluded by !**/*.hlsl
  • shaders/raytracing/Pathtracing/RayGeneration.hlsl is excluded by !**/*.hlsl
📒 Files selected for processing (4)
  • shaders/raytracing/include/Common.hlsli
  • shaders/raytracing/include/Materials/BSDF.hlsli
  • shaders/raytracing/include/SampleGenerators.hlsli
  • src/Renderer.cpp

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.

1 participant