ai_volume.h
Go to the documentation of this file.
1 /*
2  * Arnold API header file
3  * Copyright (c) 1998-2009 Marcos Fajardo, (c) 2009-2018 Solid Angle SL
4  */
5 
11 #pragma once
12 
13 #include "ai_bbox.h"
14 #include "ai_color.h"
15 #include "ai_params.h"
16 #include "ai_string.h"
17 #include "ai_version.h"
18 
19 // forward declaration
20 struct AtNode;
21 struct AtShaderGlobals;
22 
41 #define AI_VOLUME_INTERP_CLOSEST 0
42 #define AI_VOLUME_INTERP_TRILINEAR 1
43 #define AI_VOLUME_INTERP_TRICUBIC 2
44 /* \} */
45 
50 {
51  void* private_info;
54 };
55 
56 struct AtVolumeIntersectionInfo;
57 
58 AI_API void AiVolumeAddIntersection(const AtVolumeIntersectionInfo* info, float t0, float t1);
59 AI_API void AiVolumeMergeIntersection(const AtVolumeIntersectionInfo* info, float t0, float t1, uint32_t prim_id);
60 
61 /*
62  * Volume file querying.
63  */
64 AI_API AtArray* AiVolumeFileGetChannels(const char* filename);
65 AI_API AtBBox AiVolumeFileGetBBox(const char* filename, const AtArray* channels);
66 
76 typedef bool (*AtVolumeCreate)(const AtNode* node,
77  AtVolumeData* data);
78 
90 typedef bool (*AtVolumeUpdate)(const AtNode* node,
91  AtVolumeData* data);
92 
102 typedef bool (*AtVolumeCleanup)(const AtNode* node,
103  AtVolumeData* data);
104 
120 typedef bool (*AtVolumeSample)(const AtVolumeData* data,
121  const AtString channel,
122  const AtShaderGlobals* sg,
123  int interp,
124  AtParamValue *value,
125  uint8_t *type);
126 
144 typedef bool (*AtVolumeGradient)(const AtVolumeData* data,
145  const AtString channel,
146  const AtShaderGlobals* sg,
147  int interp,
148  AtVector* gradient);
149 
175 typedef void (*AtVolumeRayExtents)(const AtVolumeData* data,
176  const AtVolumeIntersectionInfo* info,
177  uint16_t tid,
178  float time,
179  const AtVector* origin,
180  const AtVector* direction,
181  float t0,
182  float t1);
183 
185 {
192 };
193 
195 #define AI_VOLUME_NODE_EXPORT_METHODS(tag) \
196 AI_INSTANCE_COMMON_SHAPE_METHODS \
197 volume_create; \
198 volume_update; \
199 volume_cleanup; \
200 volume_ray_extents; \
201 volume_sample; \
202 volume_gradient; \
203 static AtVolumeNodeMethods ai_vol_mtds = { \
204  VolumeCreate, \
205  VolumeUpdate, \
206  VolumeCleanup, \
207  VolumeRayExtents, \
208  VolumeSample, \
209  VolumeGradient \
210 }; \
211 static AtNodeMethods ai_node_mtds = { \
212  &ai_common_mtds, \
213  &ai_vol_mtds \
214 }; \
215 const AtNodeMethods* tag = &ai_node_mtds;
216 
217 #define volume_create \
218 static bool VolumeCreate(const AtNode* node, \
219  AtVolumeData* data)
220 
221 #define volume_update \
222 static bool VolumeUpdate(const AtNode* node, \
223  AtVolumeData* data)
224 
225 #define volume_cleanup \
226 static bool VolumeCleanup(const AtNode* node, \
227  AtVolumeData* data)
228 
229 #define volume_ray_extents \
230 static void VolumeRayExtents(const AtVolumeData* data, \
231  const AtVolumeIntersectionInfo* info, \
232  uint16_t tid, \
233  float time, \
234  const AtVector* origin, \
235  const AtVector* direction, \
236  float t0, \
237  float t1)
238 
239 #define volume_sample \
240 static bool VolumeSample(const AtVolumeData* data, \
241  const AtString channel, \
242  const AtShaderGlobals* sg, \
243  int interp, \
244  AtParamValue *value, \
245  uint8_t *type)
246 
247 #define volume_gradient \
248 static bool VolumeGradient(const AtVolumeData* data, \
249  const AtString channel, \
250  const AtShaderGlobals* sg, \
251  int interp, \
252  AtVector* gradient)
253 
254 /*\}*/
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:58
bool(* AtVolumeGradient)(const AtVolumeData *data, const AtString channel, const AtShaderGlobals *sg, int interp, AtVector *gradient)
Volume plugin gradient method.
Definition: ai_volume.h:144
bool(* AtVolumeCreate)(const AtNode *node, AtVolumeData *data)
Volume plugin volume creation.
Definition: ai_volume.h:76
This represents a node in Arnold.
Axis-aligned bounding box types and utilities.
Arnold String allows for fast string comparisons.
Definition: ai_string.h:45
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:120
Color types and utilities.
AtVolumeCreate Create
This method is called to load/create a volume.
Definition: ai_volume.h:186
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:190
Definition: ai_volume.h:184
Shader globals data structure.
Definition: ai_shaderglobals.h:41
AtBBox bbox
Bounding box for this volume, plugin is responsible for also including volume_padding from the node...
Definition: ai_volume.h:52
void * private_info
Volume plugin private data, used how the plugin likes.
Definition: ai_volume.h:51
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:175
Actual parameter value for each supported type.
Definition: ai_params.h:102
float auto_step_size
Recommended step size for ray marching through this data.
Definition: ai_volume.h:53
AtVolumeUpdate Update
This method is called to update a volume before render passes or on scene changes.
Definition: ai_volume.h:187
AtVolumeRayExtents RayExtents
This method is called to get all tightly-bounded extents along a ray where the volume exists...
Definition: ai_volume.h:189
AI_API void AiVolumeAddIntersection(const AtVolumeIntersectionInfo *info, float t0, float t1)
Submit a ray interval/extent for volume integration.
Definition: ai_shader_volume.cpp:27
Volume data, as returned by AtVolumeCreate.
Definition: ai_volume.h:49
Node parameters.
3D axis-aligned bounding box (uses single-precision)
Definition: ai_bbox.h:24
AI_API AtArray * AiVolumeFileGetChannels(const char *filename)
Get list of channel names in a volume file.
Definition: ai_shader_volume.cpp:77
AtVolumeCleanup Cleanup
This method is called to clean up a volume when it's no longer needed.
Definition: ai_volume.h:188
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:191
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:91
bool(* AtVolumeCleanup)(const AtNode *node, AtVolumeData *data)
Volume plugin volume cleanup method.
Definition: ai_volume.h:102
bool(* AtVolumeUpdate)(const AtNode *node, AtVolumeData *data)
Volume plugin volume update.
Definition: ai_volume.h:90
AtString class for fast comparisons.

© 2009-2018 Solid Angle SL · all rights reserved · www.solidangle.com