ai_volume.h
Go to the documentation of this file.
1// Copyright 2026 Autodesk, Inc. All rights reserved.
2//
3// Use of this software is subject to the terms of the Autodesk license
4// agreement provided at the time of installation or download, or which
5// otherwise accompanies this software in either electronic or hard copy form.
6
12#pragma once
13
14#include "ai_bbox.h"
15#include "ai_color.h"
16#include "ai_params.h"
17#include "ai_string.h"
18#include "ai_version.h"
19
20// forward declaration
21struct AtNode;
22struct AtShaderGlobals;
23
44#define AI_VOLUME_INTERP_CLOSEST 0
45#define AI_VOLUME_INTERP_TRILINEAR 1
46#define AI_VOLUME_INTERP_TRICUBIC 2
47/* \} */
48
53{
57};
58
59struct AtVolumeIntersectionInfo;
60
61AI_API void AiVolumeAddIntersection(const AtVolumeIntersectionInfo* info, float t0, float t1);
62AI_API void AiVolumeMergeIntersection(const AtVolumeIntersectionInfo* info, float t0, float t1, uint32_t prim_id);
63
64/*
65 * Volume file querying.
66 */
67AI_API AtArray* AiVolumeFileGetChannels(const char* filename);
68AI_API AtBBox AiVolumeFileGetBBox(const char* filename, const AtArray* channels);
69
82AI_API bool AiVolumeFileMakeLODs(const char* input_vdb, const char* output_vdb,
83 int requested_number_of_levels);
84
94typedef bool (*AtVolumeCreate)(const AtNode* node,
95 AtVolumeData* data);
96
108typedef bool (*AtVolumeUpdate)(const AtNode* node,
109 AtVolumeData* data);
110
120typedef bool (*AtVolumeCleanup)(const AtNode* node,
121 AtVolumeData* data);
122
138typedef bool (*AtVolumeSample)(const AtVolumeData* data,
139 const AtString channel,
140 const AtShaderGlobals* sg,
141 int interp,
142 AtParamValue *value,
143 uint8_t *type);
144
162typedef bool (*AtVolumeGradient)(const AtVolumeData* data,
163 const AtString channel,
164 const AtShaderGlobals* sg,
165 int interp,
166 AtVector* gradient);
167
193typedef void (*AtVolumeRayExtents)(const AtVolumeData* data,
194 const AtVolumeIntersectionInfo* info,
195 uint16_t tid,
196 float time,
197 const AtVector* origin,
198 const AtVector* direction,
199 float t0,
200 float t1);
201
203{
210};
211
213#define AI_VOLUME_NODE_EXPORT_METHODS(tag) \
214AI_INSTANCE_COMMON_SHAPE_METHODS \
215volume_create; \
216volume_update; \
217volume_cleanup; \
218volume_ray_extents; \
219volume_sample; \
220volume_gradient; \
221static AtVolumeNodeMethods ai_vol_mtds = { \
222 VolumeCreate, \
223 VolumeUpdate, \
224 VolumeCleanup, \
225 VolumeRayExtents, \
226 VolumeSample, \
227 VolumeGradient \
228}; \
229static AtNodeMethods ai_node_mtds = { \
230 &ai_common_mtds, \
231 &ai_vol_mtds \
232}; \
233const AtNodeMethods* tag = &ai_node_mtds;
234
235#define volume_create \
236static bool VolumeCreate(const AtNode* node, \
237 AtVolumeData* data)
238
239#define volume_update \
240static bool VolumeUpdate(const AtNode* node, \
241 AtVolumeData* data)
242
243#define volume_cleanup \
244static bool VolumeCleanup(const AtNode* node, \
245 AtVolumeData* data)
246
247#define volume_ray_extents \
248static void VolumeRayExtents(const AtVolumeData* data, \
249 const AtVolumeIntersectionInfo* info, \
250 uint16_t tid, \
251 float time, \
252 const AtVector* origin, \
253 const AtVector* direction, \
254 float t0, \
255 float t1)
256
257#define volume_sample \
258static bool VolumeSample(const AtVolumeData* data, \
259 const AtString channel, \
260 const AtShaderGlobals* sg, \
261 int interp, \
262 AtParamValue *value, \
263 uint8_t *type)
264
265#define volume_gradient \
266static bool VolumeGradient(const AtVolumeData* data, \
267 const AtString channel, \
268 const AtShaderGlobals* sg, \
269 int interp, \
270 AtVector* gradient)
271
272/*\}*/
Axis-aligned bounding box types and utilities.
Color types and utilities.
Node parameters.
AtString class for fast comparisons.
Version number information and checking of backwards-compatibility.
Actual parameter value for each supported type.
Definition: ai_params.h:107
Arnold String allows for fast string comparisons.
Definition: ai_string.h:54
void * private_info
Volume plugin private data, used how the plugin likes.
Definition: ai_volume.h:54
AtVolumeCreate Create
This method is called to load/create a volume.
Definition: ai_volume.h:204
void(* AtVolumeRayExtents)(const AtVolumeData *data, const AtVolumeIntersectionInfo *info, uint16_t tid, float time, const AtVector *origin, const AtVector *direction, float t0, float t1)
Volume plugin method for submitting extents along a ray where there is data.
Definition: ai_volume.h:193
bool(* AtVolumeSample)(const AtVolumeData *data, const AtString channel, const AtShaderGlobals *sg, int interp, AtParamValue *value, uint8_t *type)
Volume plugin sample method.
Definition: ai_volume.h:138
AI_API AtArray * AiVolumeFileGetChannels(const char *filename)
Get list of channel names in a volume file.
Definition: ai_shader_volume.cpp:84
AtVolumeSample Sample
This method is called to sample a volume's named channel using a given point and interpolation.
Definition: ai_volume.h:208
AtVolumeCleanup Cleanup
This method is called to clean up a volume when it's no longer needed.
Definition: ai_volume.h:206
AI_API void AiVolumeAddIntersection(const AtVolumeIntersectionInfo *info, float t0, float t1)
Submit a ray interval/extent for volume integration.
Definition: ai_shader_volume.cpp:34
float auto_step_size
Recommended step size for ray marching through this data.
Definition: ai_volume.h:56
AtVolumeRayExtents RayExtents
This method is called to get all tightly-bounded extents along a ray where the volume exists.
Definition: ai_volume.h:207
AI_API void AiVolumeMergeIntersection(const AtVolumeIntersectionInfo *info, float t0, float t1, uint32_t prim_id)
Submit a ray interval/extent for volume integration.
Definition: ai_shader_volume.cpp:65
AI_API AtBBox AiVolumeFileGetBBox(const char *filename, const AtArray *channels)
Get bounding box for specified channels in a volume file.
Definition: ai_shader_volume.cpp:98
AtVolumeUpdate Update
This method is called to update a volume before render passes or on scene changes.
Definition: ai_volume.h:205
bool(* AtVolumeCreate)(const AtNode *node, AtVolumeData *data)
Volume plugin volume creation.
Definition: ai_volume.h:94
bool(* AtVolumeCleanup)(const AtNode *node, AtVolumeData *data)
Volume plugin volume cleanup method.
Definition: ai_volume.h:120
AI_API bool AiVolumeFileMakeLODs(const char *input_vdb, const char *output_vdb, int requested_number_of_levels)
Generate LOD (level of detail) OpenVDB grids into a new .vdb file.
Definition: ai_shader_volume.cpp:103
AtBBox bbox
Bounding box for this volume, plugin is responsible for also including volume_padding from the node.
Definition: ai_volume.h:55
bool(* AtVolumeUpdate)(const AtNode *node, AtVolumeData *data)
Volume plugin volume update.
Definition: ai_volume.h:108
AtVolumeGradient Gradient
This method is called to sample the gradient of a volume's named channel using a given point and inte...
Definition: ai_volume.h:209
bool(* AtVolumeGradient)(const AtVolumeData *data, const AtString channel, const AtShaderGlobals *sg, int interp, AtVector *gradient)
Volume plugin gradient method.
Definition: ai_volume.h:162
3D axis-aligned bounding box (uses single-precision)
Definition: ai_bbox.h:33
This represents a node in Arnold.
Shader globals data structure.
Definition: ai_shaderglobals.h:45
3D point (single precision)
Definition: ai_vector.h:30
Volume data, as returned by AtVolumeCreate.
Definition: ai_volume.h:53
Definition: ai_volume.h:203

© 2023 Autodesk, Inc. · All rights reserved · www.arnoldrenderer.com