Skip to content

Commit a9fa419

Browse files
committed
Rectilinear grid support
NvdbRectilinear has not been really tested.
1 parent f046f8c commit a9fa419

27 files changed

+1854
-139
lines changed

devices/rtx/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,40 @@ box; omitting either leaves the bound open.
9999
**Parameters:**
100100
- `roi` (`FLOAT32_BOX3`): the restriction box to apply (default: unbounded).
101101

102+
103+
#### VISRTX_SPATIAL_FIELD_STRUCTURED_RECTILINEAR
104+
105+
The `structuredRectilinear` spatial field type provides efficient sampling of structured grids with
106+
rectilinear (non-uniform) spacing. Unlike `structuredRegular` which assumes uniform spacing, this type
107+
requires explicit 1D coordinate arrays for each axis.
108+
109+
**Parameters:**
110+
- `data` (ARRAY3D): The 3D voxel data
111+
- `coordsX` (ARRAY1D): X-axis coordinates (required)
112+
- `coordsY` (ARRAY1D): Y-axis coordinates (required)
113+
- `coordsZ` (ARRAY1D): Z-axis coordinates (required)
114+
- `filter`: Filtering method (same as structuredRegular)
115+
- `dataCentering`: Cell vs node centering (same as structuredRegular)
116+
117+
The axis coordinate arrays define the actual position of each voxel along that axis, enabling
118+
support for non-uniform grid spacing commonly found in scientific simulations.
119+
120+
#### VISRTX_SPATIAL_FIELD_NANOVDB_RECTILINEAR
121+
122+
The `nanovdbRectilinear` spatial field type extends NanoVDB support to rectilinear grids.
123+
It supports all NanoVDB grid types (Fp4, Fp8, Fp16, FpN, Float) with rectilinear coordinate transforms.
124+
125+
**Parameters:**
126+
- `gridData` (ARRAY1D): Serialized NanoVDB grid data
127+
- `coordsX` (ARRAY1D): X-axis coordinates (required)
128+
- `coordsY` (ARRAY1D): Y-axis coordinates (required)
129+
- `coordsZ` (ARRAY1D): Z-axis coordinates (required)
130+
- `filter`: Filtering method
131+
- `dataCentering`: Cell vs node centering
132+
133+
This type automatically detects the grid type from the NanoVDB metadata and routes to the
134+
appropriate sampler implementation.
135+
102136
## Additional ANARI Parameter and Property Extensions
103137

104138
The following section describes what additional parameters and properties can be
@@ -178,6 +212,8 @@ The following extensions are either partially or fully implemented by VisRTX:
178212
- `VISRTX_TRIANGLE_BACK_FACE_CULLING`
179213
- `VISRTX_SPATIAL_FIELD_DATA_CENTERING`
180214
- `VISRTX_SPATIAL_FIELD_REGION_OF_INTEREST`
215+
- `VISRTX_SPATIAL_FIELD_STRUCTURED_RECTILINEAR`
216+
- `VISRTX_SPATIAL_FIELD_NANOVDB_RECTILINEAR`
181217

182218
For any found bugs in extensions that are implemented, please [open an
183219
issue](https://github.com/NVIDIA/VisRTX/issues/new)!

devices/rtx/device/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2019-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
# Copyright (c) 2019-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
# SPDX-License-Identifier: BSD-3-Clause
33
#
44
# Redistribution and use in source and binary forms, with or without
@@ -180,10 +180,14 @@ set(SOURCES
180180
sampler/UnknownSampler.cpp
181181

182182
spatial_field/SpatialField.cpp
183+
spatial_field/NvdbRectilinearField.cpp
183184
spatial_field/NvdbRegularField.cpp
185+
spatial_field/StructuredRectilinearField.cpp
184186
spatial_field/StructuredRegularField.cpp
185187
spatial_field/UnknownSpatialField.cpp
188+
spatial_field/NvdbRectilinearSampler.cpp
186189
spatial_field/NvdbRegularSampler.cpp
190+
spatial_field/StructuredRectilinearSampler.cpp
187191
spatial_field/StructuredRegularSampler.cpp
188192
spatial_field/space_skipping/UniformGrid.cu
189193

@@ -363,7 +367,9 @@ GenerateEmbeddedPTX(geometry Intersectors)
363367
GenerateEmbeddedPTX(material/shaders MatteShader ENTRIES __direct__callable__evalSurfaceMaterial)
364368
GenerateEmbeddedPTX(material/shaders PhysicallyBasedShader ENTRIES __direct__callable__evalSurfaceMaterial)
365369
GenerateEmbeddedPTX(spatial_field NvdbRegularSampler)
370+
GenerateEmbeddedPTX(spatial_field NvdbRectilinearSampler)
366371
GenerateEmbeddedPTX(spatial_field StructuredRegularSampler)
372+
GenerateEmbeddedPTX(spatial_field StructuredRectilinearSampler)
367373
if(VISRTX_ENABLE_MDL_SUPPORT)
368374
GenerateEmbeddedPTX(material/shaders MDLShader ENTRIES __direct__callable__evalSurfaceMaterial)
369375
GenerateEmbeddedPTX(material/shaders MDLTexture)

devices/rtx/device/VisRTXDevice.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
* Copyright (c) 2019-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
33
* SPDX-License-Identifier: BSD-3-Clause
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -67,8 +67,10 @@
6767
#include "material/shaders/PhysicallyBasedShader.h"
6868

6969
// spatial field samplers
70-
#include "spatial_field/StructuredRegularSampler.h"
70+
#include "spatial_field/NvdbRectilinearSampler.h"
7171
#include "spatial_field/NvdbRegularSampler.h"
72+
#include "spatial_field/StructuredRectilinearSampler.h"
73+
#include "spatial_field/StructuredRegularSampler.h"
7274

7375
// MDL
7476
#ifdef USE_MDL
@@ -786,6 +788,12 @@ DeviceInitStatus VisRTXDevice::initOptix()
786788
init_module(&state.fieldSamplers.nvdb,
787789
NvdbRegularSampler::ptx(),
788790
"'nvdb' field sampler"),
791+
init_module(&state.fieldSamplers.structuredRectilinear,
792+
StructuredRectilinearSampler::ptx(),
793+
"'structuredRectilinear' field sampler"),
794+
init_module(&state.fieldSamplers.nvdbRectilinear,
795+
NvdbRectilinearSampler::ptx(),
796+
"'nanovdbRectilinear' field sampler"),
789797
};
790798

791799
for (auto &f : compileTasks)

devices/rtx/device/gpu/gpu_objects.h

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
* Copyright (c) 2019-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
33
* SPDX-License-Identifier: BSD-3-Clause
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -425,13 +425,37 @@ struct NVdbRegularData
425425
NVdbRegularData() = default;
426426
};
427427

428+
struct StructuredRectilinearData
429+
{
430+
cudaTextureObject_t texObj;
431+
vec3 dims;
432+
bool cellCentered;
433+
cudaTextureObject_t axisLUT[3];
434+
vec3 axisBoundsMin;
435+
vec3 axisBoundsMax;
436+
437+
StructuredRectilinearData() = default;
438+
};
439+
440+
struct NVdbRectilinearData
441+
{
442+
nanovdb::GridType gridType;
443+
const void *gridData;
444+
bool cellCentered;
445+
cudaTextureObject_t axisLUT[3];
446+
447+
NVdbRectilinearData() = default;
448+
};
449+
428450
struct SpatialFieldGPUData
429451
{
430452
SbtCallableEntryPoints samplerCallableIndex{SbtCallableEntryPoints::Invalid};
431453
union
432454
{
433455
StructuredRegularData structuredRegular;
434456
NVdbRegularData nvdbRegular;
457+
StructuredRectilinearData structuredRectilinear;
458+
NVdbRectilinearData nvdbRectilinear;
435459
} data;
436460
UniformGridData grid;
437461
box3 roi;
@@ -507,9 +531,10 @@ struct RectLightGPUData
507531
vec3 edge1;
508532
vec3 edge2;
509533
float intensity;
510-
struct {
511-
unsigned int front: 1;
512-
unsigned int back: 1;
534+
struct
535+
{
536+
unsigned int front : 1;
537+
unsigned int back : 1;
513538
} side;
514539
float oneOverArea;
515540
};

devices/rtx/device/gpu/sbt.h

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
* Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
33
* SPDX-License-Identifier: BSD-3-Clause
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -61,12 +61,31 @@ enum class SbtCallableEntryPoints : uint32_t
6161
Matte = 0,
6262
PBR = Matte + int(SurfaceShaderEntryPoints::Count),
6363
SpatialFieldSamplerRegular = PBR + int(SurfaceShaderEntryPoints::Count),
64-
SpatialFieldSamplerNvdbFp4 = SpatialFieldSamplerRegular + int(SpatialFieldSamplerEntryPoints::Count),
65-
SpatialFieldSamplerNvdbFp8 = SpatialFieldSamplerNvdbFp4 + int(SpatialFieldSamplerEntryPoints::Count),
66-
SpatialFieldSamplerNvdbFp16 = SpatialFieldSamplerNvdbFp8 + int(SpatialFieldSamplerEntryPoints::Count),
67-
SpatialFieldSamplerNvdbFpN = SpatialFieldSamplerNvdbFp16 + int(SpatialFieldSamplerEntryPoints::Count),
68-
SpatialFieldSamplerNvdbFloat = SpatialFieldSamplerNvdbFpN + int(SpatialFieldSamplerEntryPoints::Count),
69-
Last = SpatialFieldSamplerNvdbFloat + int(SpatialFieldSamplerEntryPoints::Count),
64+
SpatialFieldSamplerNvdbFp4 =
65+
SpatialFieldSamplerRegular + int(SpatialFieldSamplerEntryPoints::Count),
66+
SpatialFieldSamplerNvdbFp8 =
67+
SpatialFieldSamplerNvdbFp4 + int(SpatialFieldSamplerEntryPoints::Count),
68+
SpatialFieldSamplerNvdbFp16 =
69+
SpatialFieldSamplerNvdbFp8 + int(SpatialFieldSamplerEntryPoints::Count),
70+
SpatialFieldSamplerNvdbFpN =
71+
SpatialFieldSamplerNvdbFp16 + int(SpatialFieldSamplerEntryPoints::Count),
72+
SpatialFieldSamplerNvdbFloat =
73+
SpatialFieldSamplerNvdbFpN + int(SpatialFieldSamplerEntryPoints::Count),
74+
SpatialFieldSamplerRectilinear =
75+
SpatialFieldSamplerNvdbFloat + int(SpatialFieldSamplerEntryPoints::Count),
76+
SpatialFieldSamplerNvdbRectilinearFp4 = SpatialFieldSamplerRectilinear
77+
+ int(SpatialFieldSamplerEntryPoints::Count),
78+
SpatialFieldSamplerNvdbRectilinearFp8 = SpatialFieldSamplerNvdbRectilinearFp4
79+
+ int(SpatialFieldSamplerEntryPoints::Count),
80+
SpatialFieldSamplerNvdbRectilinearFp16 = SpatialFieldSamplerNvdbRectilinearFp8
81+
+ int(SpatialFieldSamplerEntryPoints::Count),
82+
SpatialFieldSamplerNvdbRectilinearFpN = SpatialFieldSamplerNvdbRectilinearFp16
83+
+ int(SpatialFieldSamplerEntryPoints::Count),
84+
SpatialFieldSamplerNvdbRectilinearFloat =
85+
SpatialFieldSamplerNvdbRectilinearFpN
86+
+ int(SpatialFieldSamplerEntryPoints::Count),
87+
Last = SpatialFieldSamplerNvdbRectilinearFloat
88+
+ int(SpatialFieldSamplerEntryPoints::Count),
7089
};
7190

7291
} // namespace visrtx

devices/rtx/device/gpu/shadingState.h

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
* Copyright (c) 2019-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
33
* SPDX-License-Identifier: BSD-3-Clause
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -91,9 +91,9 @@ struct TextureHandler : mi::neuraylib::Texture_handler_base
9191
using ShadingStateMaterial = mi::neuraylib::Shading_state_material;
9292
using ResourceData = mi::neuraylib::Resource_data;
9393

94-
struct alignas(8) MDLShadingState
94+
struct alignas(8) MDLShadingState
9595
{
96-
const char * argBlock;
96+
const char *argBlock;
9797

9898
ShadingStateMaterial state;
9999
TextureHandler textureHandler;
@@ -139,6 +139,17 @@ struct StructuredRegularSamplerState
139139
vec3 offset;
140140
};
141141

142+
// Structured Rectilinear Sampler State
143+
struct StructuredRectilinearSamplerState
144+
{
145+
cudaTextureObject_t texObj;
146+
vec3 dims;
147+
vec3 offset;
148+
cudaTextureObject_t axisLUT[3];
149+
vec3 axisBoundsMin;
150+
vec3 axisBoundsMax;
151+
};
152+
142153
// NanoVDB Sampler States
143154
template <typename T>
144155
struct NvdbRegularSamplerState
@@ -156,6 +167,24 @@ struct NvdbRegularSamplerState
156167
nanovdb::Vec3f indexMax;
157168
};
158169

170+
// NanoVDB Rectilinear Sampler States
171+
template <typename T>
172+
struct NvdbRectilinearSamplerState
173+
{
174+
using GridType = nanovdb::Grid<nanovdb::NanoTree<T>>;
175+
using AccessorType = typename GridType::AccessorType;
176+
using SamplerType = nanovdb::math::SampleFromVoxels<AccessorType, 1>;
177+
178+
const GridType *grid;
179+
AccessorType accessor;
180+
SamplerType sampler;
181+
nanovdb::Vec3f offset;
182+
nanovdb::Vec3f scale;
183+
nanovdb::Vec3f indexMin;
184+
nanovdb::Vec3f indexMax;
185+
cudaTextureObject_t axisLUT[3];
186+
};
187+
159188
struct VolumeSamplingState
160189
{
161190
VISRTX_DEVICE VolumeSamplingState() {};
@@ -168,6 +197,12 @@ struct VolumeSamplingState
168197
NvdbRegularSamplerState<nanovdb::Fp16> nvdbFp16;
169198
NvdbRegularSamplerState<nanovdb::FpN> nvdbFpN;
170199
NvdbRegularSamplerState<float> nvdbFloat;
200+
StructuredRectilinearSamplerState structuredRectilinear;
201+
NvdbRectilinearSamplerState<nanovdb::Fp4> nvdbRectilinearFp4;
202+
NvdbRectilinearSamplerState<nanovdb::Fp8> nvdbRectilinearFp8;
203+
NvdbRectilinearSamplerState<nanovdb::Fp16> nvdbRectilinearFp16;
204+
NvdbRectilinearSamplerState<nanovdb::FpN> nvdbRectilinearFpN;
205+
NvdbRectilinearSamplerState<float> nvdbRectilinearFloat;
171206
};
172207
};
173208

devices/rtx/device/include/anari/ext/visrtx/visrtx_extensions.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
* Copyright (c) 2019-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
33
* SPDX-License-Identifier: BSD-3-Clause
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -48,6 +48,8 @@ struct VisRTXExtensions
4848
int VISRTX_SPATIAL_FIELD_NANOVDB;
4949
int VISRTX_SPATIAL_FIELD_DATA_CENTERING;
5050
int VISRTX_SPATIAL_FIELD_REGION_OF_INTEREST;
51+
int VISRTX_SPATIAL_FIELD_STRUCTURED_RECTILINEAR;
52+
int VISRTX_SPATIAL_FIELD_NANOVDB_RECTILINEAR;
5153
int VISRTX_TRIANGLE_BACK_FACE_CULLING;
5254
int VISRTX_TRIANGLE_FACE_VARYING_ATTRIBUTES;
5355
};
@@ -114,6 +116,10 @@ inline void fillExtensionStruct(
114116
extensions->VISRTX_SPATIAL_FIELD_REGION_OF_INTEREST = 1;
115117
else if (feature == "ANARI_VISRTX_SPATIAL_FIELD_NANOVDB")
116118
extensions->VISRTX_SPATIAL_FIELD_NANOVDB = 1;
119+
else if (feature == "ANARI_VISRTX_SPATIAL_FIELD_STRUCTURED_RECTILINEAR")
120+
extensions->VISRTX_SPATIAL_FIELD_STRUCTURED_RECTILINEAR = 1;
121+
else if (feature == "ANARI_VISRTX_SPATIAL_FIELD_NANOVDB_RECTILINEAR")
122+
extensions->VISRTX_SPATIAL_FIELD_NANOVDB_RECTILINEAR = 1;
117123
else if (feature == "ANARI_VISRTX_TRIANGLE_BACK_FACE_CULLING")
118124
extensions->VISRTX_TRIANGLE_BACK_FACE_CULLING = 1;
119125
else if (feature == "ANARI_VISRTX_TRIANGLE_FACE_VARYING_ATTRIBUTES")

devices/rtx/device/optix_visrtx.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
* Copyright (c) 2019-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
33
* SPDX-License-Identifier: BSD-3-Clause
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -199,6 +199,8 @@ struct DeviceGlobalState : public helium::BaseGlobalDeviceState
199199
{
200200
OptixModule structuredRegular{nullptr};
201201
OptixModule nvdb{nullptr};
202+
OptixModule structuredRectilinear{nullptr};
203+
OptixModule nvdbRectilinear{nullptr};
202204
} fieldSamplers;
203205

204206
struct ObjectUpdates

0 commit comments

Comments
 (0)