ai_volume.h
Go to the documentation of this file.
1 // Copyright 2020 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
21 struct AtNode;
22 struct 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 {
54  void* private_info;
57 };
58 
59 struct AtVolumeIntersectionInfo;
60 
61 AI_API void AiVolumeAddIntersection(const AtVolumeIntersectionInfo* info, float t0, float t1);
62 AI_API void AiVolumeMergeIntersection(const AtVolumeIntersectionInfo* info, float t0, float t1, uint32_t prim_id);
63 
64 /*
65  * Volume file querying.
66  */
67 AI_API AtArray* AiVolumeFileGetChannels(const char* filename);
68 AI_API AtBBox AiVolumeFileGetBBox(const char* filename, const AtArray* channels);
69 
79 typedef bool (*AtVolumeCreate)(const AtNode* node,
80  AtVolumeData* data);
81 
93 typedef bool (*AtVolumeUpdate)(const AtNode* node,
94  AtVolumeData* data);
95 
105 typedef bool (*AtVolumeCleanup)(const AtNode* node,
106  AtVolumeData* data);
107 
123 typedef bool (*AtVolumeSample)(const AtVolumeData* data,
124  const AtString channel,
125  const AtShaderGlobals* sg,
126  int interp,
127  AtParamValue *value,
128  uint8_t *type);
129 
147 typedef bool (*AtVolumeGradient)(const AtVolumeData* data,
148  const AtString channel,
149  const AtShaderGlobals* sg,
150  int interp,
151  AtVector* gradient);
152 
178 typedef 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) \
199 AI_INSTANCE_COMMON_SHAPE_METHODS \
200 volume_create; \
201 volume_update; \
202 volume_cleanup; \
203 volume_ray_extents; \
204 volume_sample; \
205 volume_gradient; \
206 static AtVolumeNodeMethods ai_vol_mtds = { \
207  VolumeCreate, \
208  VolumeUpdate, \
209  VolumeCleanup, \
210  VolumeRayExtents, \
211  VolumeSample, \
212  VolumeGradient \
213 }; \
214 static AtNodeMethods ai_node_mtds = { \
215  &ai_common_mtds, \
216  &ai_vol_mtds \
217 }; \
218 const AtNodeMethods* tag = &ai_node_mtds;
219 
220 #define volume_create \
221 static bool VolumeCreate(const AtNode* node, \
222  AtVolumeData* data)
223 
224 #define volume_update \
225 static bool VolumeUpdate(const AtNode* node, \
226  AtVolumeData* data)
227 
228 #define volume_cleanup \
229 static bool VolumeCleanup(const AtNode* node, \
230  AtVolumeData* data)
231 
232 #define volume_ray_extents \
233 static 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 \
243 static 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 \
251 static bool VolumeGradient(const AtVolumeData* data, \
252  const AtString channel, \
253  const AtShaderGlobals* sg, \
254  int interp, \
255  AtVector* gradient)
256 
257 /*\}*/
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
bool(* AtVolumeGradient)(const AtVolumeData *data, const AtString channel, const AtShaderGlobals *sg, int interp, AtVector *gradient)
Volume plugin gradient method.
Definition: ai_volume.h:147
bool(* AtVolumeCreate)(const AtNode *node, AtVolumeData *data)
Volume plugin volume creation.
Definition: ai_volume.h:79
This represents a node in Arnold.
Axis-aligned bounding box types and utilities.
Arnold String allows for fast string comparisons.
Definition: ai_string.h:46
3D point (single precision)
Definition: ai_vector.h:29
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
Color types and utilities.
AtVolumeCreate Create
This method is called to load/create a volume.
Definition: ai_volume.h:189
Version number information and checking of backwards-compatibility.
AtVolumeSample Sample
This method is called to sample a volume's named channel using a given point and interpolation.
Definition: ai_volume.h:193
Definition: ai_volume.h:187
Shader globals data structure.
Definition: ai_shaderglobals.h:45
AtBBox bbox
Bounding box for this volume, plugin is responsible for also including volume_padding from the node...
Definition: ai_volume.h:55
void * private_info
Volume plugin private data, used how the plugin likes.
Definition: ai_volume.h:54
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
Actual parameter value for each supported type.
Definition: ai_params.h:105
float auto_step_size
Recommended step size for ray marching through this data.
Definition: ai_volume.h:56
AtVolumeUpdate Update
This method is called to update a volume before render passes or on scene changes.
Definition: ai_volume.h:190
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 AiVolumeAddIntersection(const AtVolumeIntersectionInfo *info, float t0, float t1)
Submit a ray interval/extent for volume integration.
Definition: ai_shader_volume.cpp:43
Volume data, as returned by AtVolumeCreate.
Definition: ai_volume.h:52
Node parameters.
3D axis-aligned bounding box (uses single-precision)
Definition: ai_bbox.h:32
AI_API AtArray * AiVolumeFileGetChannels(const char *filename)
Get list of channel names in a volume file.
Definition: ai_shader_volume.cpp:93
AtVolumeCleanup Cleanup
This method is called to clean up a volume when it's no longer needed.
Definition: ai_volume.h:191
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
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
bool(* AtVolumeCleanup)(const AtNode *node, AtVolumeData *data)
Volume plugin volume cleanup method.
Definition: ai_volume.h:105
bool(* AtVolumeUpdate)(const AtNode *node, AtVolumeData *data)
Volume plugin volume update.
Definition: ai_volume.h:93
AtString class for fast comparisons.

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