ai_volume.h
Go to the documentation of this file.
1// Copyright 2021 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
79typedef bool (*AtVolumeCreate)(const AtNode* node,
80 AtVolumeData* data);
81
93typedef bool (*AtVolumeUpdate)(const AtNode* node,
94 AtVolumeData* data);
95
105typedef bool (*AtVolumeCleanup)(const AtNode* node,
106 AtVolumeData* data);
107
123typedef bool (*AtVolumeSample)(const AtVolumeData* data,
124 const AtString channel,
125 const AtShaderGlobals* sg,
126 int interp,
127 AtParamValue *value,
128 uint8_t *type);
129
147typedef bool (*AtVolumeGradient)(const AtVolumeData* data,
148 const AtString channel,
149 const AtShaderGlobals* sg,
150 int interp,
151 AtVector* gradient);
152
178typedef void (*AtVolumeRayExtents)(const AtVolumeData* data,
179 const AtVolumeIntersectionInfo* info,
180 uint16_t tid,
181 float time,
182 const AtVector* origin,
183 const AtVector* direction,
184 float t0,
185 float t1);
186
188{
195};
196
198#define AI_VOLUME_NODE_EXPORT_METHODS(tag) \
199AI_INSTANCE_COMMON_SHAPE_METHODS \
200volume_create; \
201volume_update; \
202volume_cleanup; \
203volume_ray_extents; \
204volume_sample; \
205volume_gradient; \
206static AtVolumeNodeMethods ai_vol_mtds = { \
207 VolumeCreate, \
208 VolumeUpdate, \
209 VolumeCleanup, \
210 VolumeRayExtents, \
211 VolumeSample, \
212 VolumeGradient \
213}; \
214static AtNodeMethods ai_node_mtds = { \
215 &ai_common_mtds, \
216 &ai_vol_mtds \
217}; \
218const AtNodeMethods* tag = &ai_node_mtds;
219
220#define volume_create \
221static bool VolumeCreate(const AtNode* node, \
222 AtVolumeData* data)
223
224#define volume_update \
225static bool VolumeUpdate(const AtNode* node, \
226 AtVolumeData* data)
227
228#define volume_cleanup \
229static bool VolumeCleanup(const AtNode* node, \
230 AtVolumeData* data)
231
232#define volume_ray_extents \
233static void VolumeRayExtents(const AtVolumeData* data, \
234 const AtVolumeIntersectionInfo* info, \
235 uint16_t tid, \
236 float time, \
237 const AtVector* origin, \
238 const AtVector* direction, \
239 float t0, \
240 float t1)
241
242#define volume_sample \
243static bool VolumeSample(const AtVolumeData* data, \
244 const AtString channel, \
245 const AtShaderGlobals* sg, \
246 int interp, \
247 AtParamValue *value, \
248 uint8_t *type)
249
250#define volume_gradient \
251static bool VolumeGradient(const AtVolumeData* data, \
252 const AtString channel, \
253 const AtShaderGlobals* sg, \
254 int interp, \
255 AtVector* gradient)
256
257/*\}*/
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:106
Arnold String allows for fast string comparisons.
Definition: ai_string.h:46
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:189
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:178
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:123
AI_API AtArray * AiVolumeFileGetChannels(const char *filename)
Get list of channel names in a volume file.
Definition: ai_shader_volume.cpp:93
AtVolumeSample Sample
This method is called to sample a volume's named channel using a given point and interpolation.
Definition: ai_volume.h:193
AtVolumeCleanup Cleanup
This method is called to clean up a volume when it's no longer needed.
Definition: ai_volume.h:191
AI_API void AiVolumeAddIntersection(const AtVolumeIntersectionInfo *info, float t0, float t1)
Submit a ray interval/extent for volume integration.
Definition: ai_shader_volume.cpp:43
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:192
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:74
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:107
AtVolumeUpdate Update
This method is called to update a volume before render passes or on scene changes.
Definition: ai_volume.h:190
bool(* AtVolumeCreate)(const AtNode *node, AtVolumeData *data)
Volume plugin volume creation.
Definition: ai_volume.h:79
bool(* AtVolumeCleanup)(const AtNode *node, AtVolumeData *data)
Volume plugin volume cleanup method.
Definition: ai_volume.h:105
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:93
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:194
bool(* AtVolumeGradient)(const AtVolumeData *data, const AtString channel, const AtShaderGlobals *sg, int interp, AtVector *gradient)
Volume plugin gradient method.
Definition: ai_volume.h:147
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:188

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