feat(WebGPU): add WebGPU support to VolumePassFSQ#3526
Conversation
|
Draft to get some initial feedback |
97852ee to
cfbfc19
Compare
cfbfc19 to
2c55dfe
Compare
|
@sankhesh mind doing an initial review ? |
|
@sankhesh any chance to get an initial review ? |
sankhesh
left a comment
There was a problem hiding this comment.
This is a big change. Took me a while to go through it. I've left some questions but overall, needs more documentation and testing.
| let dims = textureDimensions(vTex, 0); | ||
| let maxCoord = vec3<i32>(dims) - vec3<i32>(1); | ||
| let nearestCoord = clamp( | ||
| vec3<i32>(floor(tpos.xyz * vec3<f32>(dims))), | ||
| vec3<i32>(0), | ||
| maxCoord | ||
| ); | ||
| let nearestValue = textureLoad(vTex, nearestCoord, 0); | ||
|
|
||
| if ((forceNearestMask & 1) != 0) { value.x = nearestValue.x; } | ||
| if ((forceNearestMask & 2) != 0) { value.y = nearestValue.y; } | ||
| if ((forceNearestMask & 4) != 0) { value.z = nearestValue.z; } | ||
| if ((forceNearestMask & 8) != 0) { value.w = nearestValue.w; } | ||
|
|
||
| return value; |
There was a problem hiding this comment.
Why does getTextureValue need to perform filtering as well now?
| let nearestCoord = clamp( | ||
| vec3<i32>(floor(tpos.xyz * vec3<f32>(dims))), | ||
| vec3<i32>(0), | ||
| maxCoord |
There was a problem hiding this comment.
This does not match the exact texel-center convention used by filter sampling, especially near boundaries.
| { | ||
| if (numComp == 1u) { return sample.x; } | ||
| if (numComp == 2u) { return sample.y; } | ||
| if (numComp == 3u) { return length(sample.xyz); } |
There was a problem hiding this comment.
Why is opacity the length(sample.xyz) here? Was this intentional?
| result.x = getComponentValue(vTex, tpos + vec4<f32>(tstep.x, 0.0, 0.0, 1.0), vNum, component) - scalar; | ||
| result.y = getComponentValue(vTex, tpos + vec4<f32>(0.0, tstep.y, 0.0, 1.0), vNum, component) - scalar; | ||
| result.z = getComponentValue(vTex, tpos + vec4<f32>(0.0, 0.0, tstep.z, 1.0), vNum, component) - scalar; |
There was a problem hiding this comment.
I know the webgl mapper uses forward differences only. Did you try central differences here? I think that would produce better results.
| var visibility = 1.0; | ||
|
|
||
| var j: i32 = 0; | ||
| loop |
There was a problem hiding this comment.
This is a nested sampling loop that is known to have quite an overhead. Have you profiled this?
| traverseVals[vNum] = getSimpleColor(sumVal, rowIdx, tfunRows); | ||
| } | ||
|
|
||
| fn traverseRadon(vTex: texture_3d<f32>, vNum: i32, rowIdx: i32, rayLengthSC: f32, minPosSC: vec4<f32>, rayStepSC: vec4<f32>) |
There was a problem hiding this comment.
This seems different than the opengl mapper. Could you please explain/document this function?
| const tmp3Mat4 = new Float64Array(16); | ||
| const tmp4Mat4 = new Float64Array(16); | ||
|
|
||
| function transformPoint(mat, x, y, z) { |
There was a problem hiding this comment.
IMHO, there are math functions already that do this.
| forceNearestMask |= 1 << component; | ||
| } | ||
| } | ||
| componentInfoArray[vidx * 4 + 3] = forceNearestMask; |
There was a problem hiding this comment.
I don't follow this. Could you please explain?
| const cRange = cfun.getRange(); | ||
| colorScaleArray[vidx * 4 + component] = | ||
| sscale / (cRange[1] - cRange[0]); | ||
| colorShiftArray[vidx * 4 + component] = | ||
| -cRange[0] / (cRange[1] - cRange[0]); | ||
|
|
||
| const ofun = vprop.getScalarOpacity( | ||
| vprop.getIndependentComponents() ? component : 0 | ||
| ); | ||
| const oRange = ofun.getRange(); | ||
| opacityScaleArray[vidx * 4 + component] = | ||
| sscale / (oRange[1] - oRange[0]); | ||
| opacityShiftArray[vidx * 4 + component] = | ||
| -oRange[0] / (oRange[1] - oRange[0]); | ||
| } |
There was a problem hiding this comment.
Maybe add a check to ensure the ranges are valid before dividing by them
| for (let i = 0; i < jitterArray.length; i++) { | ||
| jitterArray[i] = Math.random(); | ||
| } |
There was a problem hiding this comment.
I thought we used a perlin noise texture in the opengl mapper. This works too, but this buffer will be computed for each volume in the window.
Context
Results
Changes
PR and Code Checklist
npm run reformatto have correctly formatted codeTesting