Skip to content

[vmm] Using a single lobe for the isotropic HG phase function - #49

Open
wantonsushi wants to merge 1 commit into
OpenPathGuidingLibrary:develfrom
wantonsushi:perf-isotropic-phase-lobe
Open

wantonsushi wants to merge 1 commit into
OpenPathGuidingLibrary:develfrom
wantonsushi:perf-isotropic-phase-lobe

Conversation

@wantonsushi

Copy link
Copy Markdown
Contributor

This change is a small performance improvement suggestion.

The isotropic entry of the HG phase function table (representations[0], used for $\lvert g \rvert \approx 0$) holds three identical uniform lobes. So ApplySingleLobeHenyeyGreensteinProduct computes the same product three times, and SamplePDF and PDF evaluate the same mixture three times.

This unnecessarily slows down guiding in isotropic media. The same distribution can be represented with one uniform lobe of weight 1.

On my PC a guided scatter at g = 0 takes 430 ns, vs 262 ns after this proposed change.

representations[0].weights[2] = 0.0f;
representations[0].meanCosines[2] = 0.0f;
representations[0].kappas[2] = 0.0f;
representations[0].normalizations[2] = 0.07957747154594767f;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The normalization factor should still be the one for a kappa of zero VMF lobe to be valid.
Only the weights of the other components need to be set to 0.0.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed. For the record, I did it that way because all the slot [3] entries do $\kappa=0$ with normalization 0.

Signed-off-by: Euan Hughes <realeuanhughes@gmail.com>
@wantonsushi
wantonsushi force-pushed the perf-isotropic-phase-lobe branch from 84ff895 to c2b52fd Compare November 9, 2026 20:10
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