fix(vtkVolumeFS): fix samples weighting in average blending - #3631
Open
Jo-Byr wants to merge 1 commit into
Open
Conversation
Collaborator
|
@Jo-Byr Can you apply the same to WebGPU diff --git a/Sources/Rendering/WebGPU/VolumePassFSQ/index.js b/Sources/Rendering/WebGPU/VolumePassFSQ/index.js
index 172a346510..0fbda7b240 100644
--- a/Sources/Rendering/WebGPU/VolumePassFSQ/index.js
+++ b/Sources/Rendering/WebGPU/VolumePassFSQ/index.js
@@ -1400,13 +1400,9 @@ fn traverseAverage(vTex: texture_3d<f32>, vNum: i32, rowIdx: i32, rayLengthSC: f
let firstValue = getTextureValue(vTex, tpos, vNum);
if (raySpan <= 1.0)
{
- // Match the OpenGL mapper's effective coverage for a subsample projection
- // ray. Its rasterized entry/exit interval is 5/4 of the analytic interval
- // used by this fullscreen WebGPU pass.
- let thinRayWeight = raySpan * 1.25;
traverseVals[vNum] = processVolumeSample(
vTex, fragPos, vNum, rowIdx,
- minPosSC + rayStepSC * rayBounds.x, tpos, firstValue * thinRayWeight, tfunRows, false);
+ minPosSC + rayStepSC * rayBounds.x, tpos, firstValue, tfunRows, false);
return;
}
@@ -1438,7 +1434,7 @@ fn traverseAverage(vTex: texture_3d<f32>, vNum: i32, rowIdx: i32, rayLengthSC: f
let endValue = getTextureValue(vTex, endTpos, vNum);
if (valueWithinIPRange(endValue, vNum))
{
- sum = sum + endValue;
+ sum = sum + endValue * (rayBounds.y - curDist);
totalWeight = totalWeight + rayBounds.y - curDist;
}
@@ -1486,7 +1482,7 @@ fn traverseAdditive(vTex: texture_3d<f32>, vNum: i32, rowIdx: i32, rayLengthSC:
{
traverseVals[vNum] = processVolumeSample(
vTex, fragPos, vNum, rowIdx,
- minPosSC + rayStepSC * rayBounds.x, tpos, firstValue * raySpan, tfunRows, false);
+ minPosSC + rayStepSC * rayBounds.x, tpos, firstValue, tfunRows, false);
return;
}
@@ -1514,7 +1510,7 @@ fn traverseAdditive(vTex: texture_3d<f32>, vNum: i32, rowIdx: i32, rayLengthSC:
let endValue = getTextureValue(vTex, endTpos, vNum);
if (valueWithinIPRange(endValue, vNum))
{
- sum = sum + endValue;
+ sum = sum + endValue * (rayBounds.y - curDist);
}
traverseVals[vNum] = processVolumeSample(
vTex, fragPos, vNum, rowIdx,
|
Remove weighting of unique samples Add missing weight to numerator of last sample in average and additive blending
Jo-Byr
force-pushed
the
fix-average-blending-sample-weighting
branch
from
September 7, 2026 07:27
aeb1dbd to
34d5fa2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Average blend mode has some weighting errors resulting in a noise texture being applied on the volume.
This is mostly visible if the number of samples on the volume is low, as the last sample is weighted more than it should, which is less visible if it's averaged with more samples.
Results
Said errors are fixed
Changes
Remove weighting of unique samples
Add missing weight to numerator of last sample in average and additive blending
PR and Code Checklist
npm run reformatto have correctly formatted code