Skip to content

Commit b5ea241

Browse files
committed
Fix artifacts when sampling AMR volume, closes #34
1 parent 1195b28 commit b5ea241

4 files changed

Lines changed: 14 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
Version History
22
---------------
33

4+
### Open VKL 2.0.3
5+
6+
- Fix artifacts when sampling AMR volume
7+
48
### Open VKL 2.0.2
59

610
- Fix used element size in copyDeviceBufferToHost

openvkl/devices/cpu/volume/amr/AMRData.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ namespace openvkl {
2525
this->cellWidth = info.cellWidth;
2626
this->value = *ispc(data);
2727
this->dims = this->box.size() + vec3i(1);
28-
// make it an ULP smaller such that floor(relBrickPos*f_dims) yields
29-
// correct index even for relBrickPos=1.0f
30-
this->f_dims = nextafter(this->dims, -1);
28+
this->f_dims = vec3f(this->dims);
3129

3230
this->worldBounds =
3331
box3f(vec3f(this->box.lower) * this->cellWidth,

openvkl/devices/cpu/volume/amr/CellRef.ispc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ extern CellRef findCell(const AMR *uniform self,
2828
for (uniform int i=0;any(true);i++) {
2929
const AMRBrick *uniform brick = leaf->brickList[i];
3030
if (brick->cellWidth >= minWidth) {
31-
const vec3f relBrickPos
31+
vec3f relBrickPosMayBe1
3232
= (worldSpacePos - brick->bounds.lower) * brick->bounds_scale;
33+
// clamp to 1ULP-less-1 for f_bc stay in valid index range
34+
const vec3f relBrickPos = min(relBrickPosMayBe1, 0x1.fffffep-1f);
3335
// brick coords: integer cell coordinates inside brick
3436
// OPT: the same calculations as below, just in
3537
// floats. this works as long as all values we calculate
@@ -75,8 +77,10 @@ extern CellRef findLeafCell(const AMR *uniform self,
7577
if (isLeaf(node)) {
7678
const AMRLeaf *uniform leaf = &self->leaf[getOfs(node)];
7779
const AMRBrick *uniform brick = leaf->brickList[0];
78-
const vec3f relBrickPos
80+
const vec3f relBrickPosMayBe1
7981
= (worldSpacePos - brick->bounds.lower) * brick->bounds_scale;
82+
// clamp to 1ULP-less-1 for f_bc stay in valid index range
83+
const vec3f relBrickPos = min(relBrickPosMayBe1, 0x1.fffffep-1f);
8084
// brick coords: integer cell coordinates inside brick
8185
// OPT: the same calculations as below, just in
8286
// floats. this works as long as all values we calculate

openvkl/devices/gpu/compute/amr/CellRef.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ namespace ispc {
5555
if (isLeaf(node)) {
5656
const AMRLeaf *leaf = &self->leaf[getOfs(node)];
5757
const AMRBrick *brick = leaf->brickList[0];
58-
const vec3f relBrickPos =
58+
const vec3f relBrickPosMayBe1 =
5959
(worldSpacePos - brick->bounds.lower) * brick->bounds_scale;
60+
// clamp to 1ULP-less-1 for f_bc stay in valid index range
61+
const vec3f relBrickPos = min(relBrickPosMayBe1, 0x1.fffffep-1f);
6062
// brick coords: integer cell coordinates inside brick
6163
// OPT: the same calculations as below, just in
6264
// floats. this works as long as all values we calculate

0 commit comments

Comments
 (0)