HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BRAY_Types.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: BRAY_Types.h (BRAY Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __BRAY_Types__
12 #define __BRAY_Types__
13 
14 #include "BRAY_API.h"
15 #include <UT/UT_StringHolder.h>
16 #include <GT/GT_Types.h>
17 
18 class UT_WorkBuffer;
19 
20 enum
21 {
22  // Note - when adding event types, make sure to update ::eventType()
23  BRAY_EVENT_NEW_FLAG, // Added a new object
24  BRAY_EVENT_DEL_FLAG, // Object is being deleted
25  BRAY_EVENT_ATTRIB_P_FLAG, // P attribute changed
26  BRAY_EVENT_ATTRIB_FLAG, // Generic attribute changed
27  BRAY_EVENT_TOPOLOGY_FLAG, // Topology changed
28  BRAY_EVENT_XFORM_FLAG, // Transforms changed
29  BRAY_EVENT_CONTENTS_FLAG, // Contents changed (add/delete objects)
30  BRAY_EVENT_PROPERTIES_FLAG, // Instance properties changed
31  BRAY_EVENT_MATERIAL_FLAG, // Material has changed
32  BRAY_EVENT_TRACESET_FLAG, // Traceset has changed
33 
35 };
37 #define ENUM_FLAG(TOKEN) BRAY_EVENT_##TOKEN = (1 << BRAY_EVENT_##TOKEN##_FLAG)
38 /// Types of events that can be sent as updates to the renderer
40 {
42  ENUM_FLAG(NEW),
43  ENUM_FLAG(DEL),
44  ENUM_FLAG(ATTRIB_P),
46  ENUM_FLAG(TOPOLOGY),
47  ENUM_FLAG(XFORM),
48  ENUM_FLAG(CONTENTS),
49  ENUM_FLAG(PROPERTIES),
50  ENUM_FLAG(MATERIAL),
51  ENUM_FLAG(TRACESET),
52 };
53 #undef ENUM_FLAG
54 
55 static inline BRAY_EventType
56 operator|(BRAY_EventType a, BRAY_EventType b)
57 {
58  return BRAY_EventType(uint(a)|uint(b));
59 }
60 
61 /// Create a nice string for the event type mask
63 
64 /// Option tokens used at the "global" (scene) level
65 /// @note If you add an scene option, please update BRAY_HdUtil.C
67 {
68  BRAY_OPT_RENDERER = 0, // Name of the renderer (read-only)
69  BRAY_OPT_VERSION, // Houdini version (read-only)
70  BRAY_OPT_ACCELERATOR, // Accelerator
71 
72  // Controls for general rendering
77 
78  BRAY_OPT_HD_FOREGROUND, // Hydra renders in foreground (not background)
79  BRAY_OPT_IPR_INC_RANDOM, // Random seed modified each IPR render
80  BRAY_OPT_IPR_CONVERGENCE, // Use IPR style integration convergence
83  BRAY_OPT_IPR_INTERACTION, // Interaction mode (see enum)
84  BRAY_OPT_IPR_TILES_FOR_IMAGEFILTER, // Tiles rendered before image filters
85  BRAY_OPT_IPR_TIME_FOR_IMAGEFILTER, // Timeout before image filters run
86  BRAY_OPT_IPR_PROXY_FOR_IMAGEFILTER, // Proxy step before running filters
87 
88  // Controls for off-line rendering cache
89  BRAY_OPT_USECACHERATIO, // Whether to use the cache ratio
90  BRAY_OPT_CACHERATIO, // Amount of memory to use as cache
91  BRAY_OPT_CACHESIZE, // Absolute cache ratio
92 
93  // Control for disabled lighting
94  BRAY_OPT_DISABLE_LIGHTING, // Disable all lighting (headlight)
95  BRAY_OPT_AO_SAMPLES, // Ambient occlusion samples for headlight
96  BRAY_OPT_AO_DISTANCE, // Ambient occlusion max distance for headlight
97  BRAY_OPT_AO_COLORLIMIT, // Ambient occlusion color limit threshold
98  BRAY_OPT_DEPTHCUE_COLOR, // Color for depthcue fog
99  BRAY_OPT_DEPTHCUE_ALPHA, // Alpha for depthcue fog
100  BRAY_OPT_DEPTHCUE_Z, // Distance range for depth cue fog (near,far)
101 
102  // Controls for lighting modes
103  BRAY_OPT_LIGHT_SAMPLING_MODE, // (0[Uniform], 1[Light Tree])
106 
110  BRAY_OPT_ENABLE_DOF, // Enable DOF
111 
112  BRAY_OPT_RESOLUTION, // Should match the data window size
114  BRAY_OPT_IMAGEFILTER, // Image filter plugins (JSON string)
115  BRAY_OPT_SAMPLEFILTER, // Sample filter plugins (JSON string)
116  BRAY_OPT_PIXELORACLE, // Pixel oracle
117 
126 
127  // Image properties
128  BRAY_OPT_DATAWINDOW, // Window size should match resolution
130 
133 };
134 
135 /// @note If you add an object property, please update BRAY_HdUtil.C
137 {
139  BRAY_OBJ_GEO_VELBLUR, // (0[no blur], 1[vel blur], 2[accel blur])
142 
143  BRAY_OBJ_DICING_QUALITY, // <= 0[no dicing], 1[on m-p per pixel]
144 
145  /// @{
146  /// @note: The order must match theBsdfBounceTypes in PBR_Types.h
152 
158  /// @}
159 
160  BRAY_OBJ_VOLUME_SAMPLING, // (0[raymarch], 1[woodcock/delta])
165 
167 
172 
174 
175  BRAY_OBJ_POINT_STYLE, // Point rendering style
176  BRAY_OBJ_CURVE_STYLE, // Curve style
177  BRAY_OBJ_CURVE_BASIS, // Curve basis override
178 
179  BRAY_OBJ_TREAT_AS_LIGHTSOURCE, // (0[no], 1[yes], 2[auto])
180  BRAY_OBJ_IS_LIGHTSOURCE, // invisible, set by BRAY under the hood
181 
183 
185 
187  BRAY_OBJ_RENDER_MASK, // invisible, used only by karma delegate
188 
191 };
192 
194 {
200  BRAY_CAMERA_CLIP, // real[2] (near and far)
201  BRAY_CAMERA_SHUTTER, // real[2] (open and close)
204  BRAY_CAMERA_WINDOW, // real[4] (NDC mapping window)
205 
208 };
209 
211 {
213  BRAY_LIGHT_AREA_SHAPE, // int (see BRAY_LightType)
217  BRAY_LIGHT_AREA_MAP, // string: environment map for sampling
220  BRAY_LIGHT_MIS_BIAS, // real [-1,1]
224  BRAY_LIGHT_CATEGORY, // string: category name
225  BRAY_LIGHT_HDRI_MAX_ISIZE, // int (max size for importance sampling tables)
226  BRAY_LIGHT_DISTANT_BLUR, // float (softness for distant lights)
227  BRAY_LIGHT_DIFFUSE_SCALE, // float multiplier for diffuse/sss/volume
228  BRAY_LIGHT_SPECULAR_SCALE, // float multiplier for refl/refr
229  BRAY_LIGHT_SINGLE_SIDED, // bool, single or double sided
230 
233 };
234 
236 {
237  BRAY_PLANE_FILTER, // Pixel filter
238  BRAY_PLANE_SAMPLING, // Sample filtering (0 = average etc.)
239  BRAY_PLANE_EXCLUDE_DCM, // Exclude from deep camera images
240  BRAY_PLANE_DISABLE, // Disable the image plane
241  BRAY_PLANE_SEPARATE_FILE, // Filename to write image to
242  BRAY_PLANE_DITHER, // Dither for quantizing to integer values
243  BRAY_PLANE_DEFAULT_VALUE, // Default value for 1-channel planes
244 
247 };
248 
249 /// Properties interpreted by the command line renderer
251 {
252  BRAY_COMMAND_FRAME, // Start frame
253  BRAY_COMMAND_FRAME_COUNT, // Number of frames to render
254  BRAY_COMMAND_FRAME_INC, // Frame increment
255  BRAY_COMMAND_CHECKPOINT, // Seconds between checkpoint writes
256  BRAY_COMMAND_TIMELIMIT, // Time limit for rendering
257  BRAY_COMMAND_TIMELIMIT_IMAGE, // Time limit is specified per image
258  BRAY_COMMAND_TIMELIMIT_NOSAVE_PARTIAL, // Don't save WIP after timelimit
259 
262 };
263 
265 {
272 
275 };
276 
277 /// Return the name of the renderer
279 
280 /// Look up the enum given a name.
282  BRAY_PropertyType ty, int id);
284  const char *name);
287 
288 inline bool
290 {
291  return GT_STORE_INVALID
292  != BRAYpropertyStorage(ty, id);
293 }
294 
295 inline bool
296 BRAYisValid(const std::pair<BRAY_PropertyType, int> &prop)
297 {
298  return BRAYisValid(prop.first, prop.second);
299 }
300 
301 #define PROPERTY_LOOKUP(NAME, STYLE, ENUM) \
302  inline ENUM BRAY##NAME(const char *name) \
303  { return ENUM(BRAYproperty(STYLE, name)); } \
304  inline const UT_StringHolder &BRAY##NAME(ENUM token) \
305  { return BRAYproperty(STYLE, token); } \
306  inline exint BRAY##NAME##Size(ENUM token) \
307  { return BRAYpropertySize(STYLE, token); } \
308  inline GT_Storage BRAY##NAME##Storage(ENUM token) \
309  { return BRAYpropertyStorage(STYLE, token); } \
310  /* end of macro */
317 #undef PROPERTY_LOOKUP
318 
319 /// Lookup a property type by name
320 BRAY_API extern BRAY_PropertyType BRAYpropertyType(const char *name);
321 /// Look up the name of a property type by the id
323 
324 /// This function will resolve generic names to the appropriate property type
325 /// and property identifier. For example:
326 /// "plane:filter" -> {BRAY_PLANE_PROPERTY, BRAY_PLANE_FILTER}
327 /// "camera:focal" -> {BRAY_CAMERA_PROPERTY, BRAY_CAMERA_FOCAL}
328 /// "global:tilesize" -> {BRAY_SCENE_PROPERTY, BRAY_OPT_TILESIZE}
329 /// If the token doesn't map to a property, the function will return an invalid
330 /// pair (i.e. BRAYisValid(result) == false).
331 ///
332 /// If the token isn't prefixed with a property type, the @c default_style will
333 /// be used. For example, with the default of BRAY_SCENE_PROPERTY:
334 /// "tilesize" -> { BRAY_SCENE_PROPERTY, BRAY_OPT_TILESIZE }
335 /// "focal" -> {invalid_property_pair} (error - not a scene property)
336 BRAY_API extern std::pair<BRAY_PropertyType, int>
337  BRAYproperty(const char *token,
339 
340 /// Given a property type, this will compose a name string that fully qualifies
341 /// the property. This is a string that would be suitable for @c
342 /// BRAYlookupProperty(). This may return a @c nullptr.
343 BRAY_API extern const char *BRAYproperty(UT_WorkBuffer &storage,
345  int property_id,
346  const char *prefix = "");
347 
348 /// @{
349 /// Generic method to return the number of options given an enum
350 template <typename T> static inline constexpr size_t BRAYmaxOptions()
351 { SYS_UNIMPLEMENTED_TEMPLATE(T); return 0; }
352 
353 template <> inline constexpr size_t
355 template <> inline constexpr size_t
357 template <> inline constexpr size_t
359 template <> inline constexpr size_t
361 template <> inline constexpr size_t
363 template <> inline constexpr size_t
365 /// @}
366 
367 /// @{
368 /// Generic method to find the valud of the property type enum given the enum
369 template <typename T> static inline constexpr BRAY_PropertyType BRAYpropertyType()
371 
372 template <> inline constexpr BRAY_PropertyType
374 template <> inline constexpr BRAY_PropertyType
376 template <> inline constexpr BRAY_PropertyType
378 template <> inline constexpr BRAY_PropertyType
380 template <> inline constexpr BRAY_PropertyType
382 template <> inline constexpr BRAY_PropertyType
384 /// @}
385 
386 
388 {
398 
401 };
402 BRAY_API extern BRAY_LightType BRAYlightType(const char *name);
404 
405 // Different types of user interaction in IPR
407 {
414 
416 };
420 
421 /// Consistent representation of time type within BRAY
422 using BRAYtime = float;
423 
424 /// Consistent representation for material ids
426 
427 /// Invalid material id
428 static constexpr BRAYmaterialId BRAY_INVALID_MATERIAL_ID = 0;
429 
430 /// List of known LPE prefixes
432 {
435 };
436 static inline BRAY_LPEPrefix
437 operator|(BRAY_LPEPrefix a, BRAY_LPEPrefix b)
438 {
439  return BRAY_LPEPrefix(uint(a)|uint(b));
440 }
441 
443 {
450 
453 
456 };
457 
458 #define ENUM_TO_MASK(TOKEN) TOKEN = (1 << TOKEN##_ENUM)
459 /// Ray visibility flags
461 {
463 
464  ENUM_TO_MASK(BRAY_RAY_CAMERA),
465  ENUM_TO_MASK(BRAY_RAY_DIFFUSE),
466  ENUM_TO_MASK(BRAY_RAY_REFLECT),
467  ENUM_TO_MASK(BRAY_RAY_REFRACT),
468  ENUM_TO_MASK(BRAY_RAY_VOLUME),
469  ENUM_TO_MASK(BRAY_RAY_SHADOW),
470 
471  ENUM_TO_MASK(BRAY_PROXY_CAMERA),
472  ENUM_TO_MASK(BRAY_PROXY_SHADOW),
473 
474  ENUM_TO_MASK(BRAY_GUIDE_CAMERA),
475  ENUM_TO_MASK(BRAY_GUIDE_SHADOW),
476 
477  BRAY_ANY_CAMERA = (BRAY_RAY_CAMERA | BRAY_PROXY_CAMERA | BRAY_GUIDE_CAMERA),
478  BRAY_ANY_SHADOW = (BRAY_RAY_SHADOW | BRAY_PROXY_SHADOW | BRAY_GUIDE_SHADOW),
479 
480  BRAY_RAY_ALL = 0xFFFF,
481 
482  BRAY_RAY_PROXY_MASK = (BRAY_PROXY_CAMERA|BRAY_PROXY_SHADOW),
483  BRAY_RAY_GUIDE_MASK = (BRAY_GUIDE_CAMERA|BRAY_GUIDE_SHADOW),
486 };
487 #undef ENUM_TO_MASK
488 
489 static inline BRAY_RayVisibility
491 {
492  return BRAY_RayVisibility(uint(a)|uint(b));
493 }
494 static inline BRAY_RayVisibility
496 {
497  return BRAY_RayVisibility(uint(a)&uint(b));
498 }
499 static inline BRAY_RayVisibility
500 operator~(BRAY_RayVisibility a)
501 {
502  return BRAY_RayVisibility(~uint(a));
503 }
504 
506 
507 /// Material evaluation flags
509 {
511 };
512 
513 /// Projection modes for rendering
515 {
516  BRAY_PROJ_ORTHOGRAPHIC, // orthographic projection mode
517  BRAY_PROJ_PERSPECTIVE, // perspective projection mode
518  BRAY_PROJ_CVEX_SHADER, // run a CVEX lens shader
519 
521 };
523 BRAY_API extern const char *BRAYprojection(BRAY_Projection t);
524 
526 {
527  BRAY_RAYIMPORT_P, // vector: ray origin
528  BRAY_RAYIMPORT_D, // vector: ray direction
529  BRAY_RAYIMPORT_TIME, // float: shutter time
530  BRAY_RAYIMPORT_NEAR, // float: near bias
531  BRAY_RAYIMPORT_FAR, // float: max distance
532  BRAY_RAYIMPORT_MASK, // int: intersection mask
533  BRAY_RAYIMPORT_CONTRIB, // vector: contribution
534 
535  BRAY_RAYIMPORT_HIT_ISHIT, // bool: Hit or miss
536  BRAY_RAYIMPORT_HIT_P, // vector: Hit position (in world space)
537  BRAY_RAYIMPORT_HIT_Pz, // float: Pz (in space of camera)
538  BRAY_RAYIMPORT_HIT_STACK, // int[]: Hit stack
539  BRAY_RAYIMPORT_HIT_ELEM, // int: Hit element (raw id)
540  BRAY_RAYIMPORT_HIT_PRIMID, // int: Hit primitive id
541  BRAY_RAYIMPORT_HIT_COORD, // vector: raw parametric coords {u,v,w}
542  BRAY_RAYIMPORT_HIT_DIST, // float: Hit distance
543  BRAY_RAYIMPORT_HIT_DPDZ, // float: dPdz
544  BRAY_RAYIMPORT_HIT_N, // vector: smooth normal
545  BRAY_RAYIMPORT_HIT_Ng, // vector: geometric normal
546  BRAY_RAYIMPORT_HIT_FLAGS, // int: hit flags
547  BRAY_RAYIMPORT_LEVEL, // int: ray level
548  BRAY_RAYIMPORT_HD_PRIM, // int: hydra rprim id for selection
549  BRAY_RAYIMPORT_HD_INST, // int: hydra inst idx (0th level) for selection
550 
551  BRAY_RAYIMPORT_INVALID // Not a valid ray import
552 };
554 BRAY_API extern const char *BRAYrayImport(BRAY_VexRayImport t);
555 
556 /// Generic method to return the number of components for a given import
557 /// Note that arrays types return 0 (see BRAYrayImportArray())
558 template <BRAY_VexRayImport T> static inline constexpr size_t BRAYrayImportSize()
559 {
560 #if !defined(__clang__)
562 #endif
563  return 0;
564 }
565 /// Generic method to return whether the import variable is array valued
566 template <BRAY_VexRayImport T> static inline constexpr bool BRAYrayImportIsArray()
567 {
568 #if !defined(__clang__)
570 #endif
571  return false;
572 }
573 
574 #define INSTANTIATE(VAR, SIZE, IS_ARRAY) \
575  template <> inline constexpr size_t \
576  BRAYrayImportSize<VAR>() { return SIZE; } \
577  template <> inline constexpr bool \
578  BRAYrayImportIsArray<VAR>() { return IS_ARRAY; } \
579  /* end of macro */
580 
581 INSTANTIATE(BRAY_RAYIMPORT_P, 3, false)
582 INSTANTIATE(BRAY_RAYIMPORT_D, 3, false)
600 
601 #undef INSTANTIATE
602 
603 #endif
BRAY_EventType
Types of events that can be sent as updates to the renderer.
Definition: BRAY_Types.h:39
GT_Storage
Definition: GT_Types.h:18
UT_ASSERT_COMPILETIME(BRAY_EVENT_MAXFLAGS<=32)
#define ENUM_TO_MASK(TOKEN)
Definition: BRAY_Types.h:458
GLuint const GLchar * name
Definition: glew.h:1814
constexpr BRAY_PropertyType BRAYpropertyType< BRAY_LightProperty >()
Definition: BRAY_Types.h:377
float BRAYtime
Consistent representation of time type within BRAY.
Definition: BRAY_Types.h:422
BRAY_API GT_Storage BRAYpropertyStorage(BRAY_PropertyType ty, int id)
BRAY_RayVisibility
Ray visibility flags.
Definition: BRAY_Types.h:460
GLboolean GLboolean GLboolean GLboolean a
Definition: glew.h:9477
BRAY_API const UT_StringHolder & BRAYrendererName()
Return the name of the renderer.
BRAY_VexRayImport
Definition: BRAY_Types.h:525
#define INSTANTIATE(VAR, SIZE, IS_ARRAY)
Definition: BRAY_Types.h:574
BRAY_RayVisibilityEnum
Definition: BRAY_Types.h:442
BRAY_Projection
Projection modes for rendering.
Definition: BRAY_Types.h:514
BRAY_CameraProperty
Definition: BRAY_Types.h:193
BRAY_API BRAY_PropertyType BRAYpropertyType(const char *name)
Lookup a property type by name.
GLenum GLint GLuint mask
Definition: glew.h:1845
constexpr size_t BRAYmaxOptions< BRAY_CameraProperty >()
Definition: BRAY_Types.h:360
constexpr BRAY_PropertyType BRAYpropertyType< BRAY_CameraProperty >()
Definition: BRAY_Types.h:379
BRAY_API exint BRAYpropertySize(BRAY_PropertyType ty, int id)
constexpr BRAY_PropertyType BRAYpropertyType< BRAY_PlaneProperty >()
Definition: BRAY_Types.h:381
constexpr size_t BRAYmaxOptions< BRAY_ObjectProperty >()
Definition: BRAY_Types.h:356
constexpr BRAY_PropertyType BRAYpropertyType< BRAY_CommandProperty >()
Definition: BRAY_Types.h:383
BRAY_ObjectProperty
Definition: BRAY_Types.h:136
BRAY_API UT_StringHolder BRAYrayVisibility(BRAY_RayVisibility mask)
int64 exint
Definition: SYS_Types.h:120
constexpr size_t BRAYmaxOptions< BRAY_CommandProperty >()
Definition: BRAY_Types.h:364
constexpr size_t BRAYmaxOptions< BRAY_LightProperty >()
Definition: BRAY_Types.h:358
GLsizei n
Definition: glew.h:4040
BRAY_API BRAY_LightType BRAYlightType(const char *name)
BRAY_API BRAY_VexRayImport BRAYrayImport(const UT_StringRef &n)
#define PROPERTY_LOOKUP(NAME, STYLE, ENUM)
Definition: BRAY_Types.h:301
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
BRAY_LightProperty
Definition: BRAY_Types.h:210
BRAY_PlaneProperty
Definition: BRAY_Types.h:235
#define ENUM_FLAG(TOKEN)
Definition: BRAY_Types.h:37
GLuint GLuint GLsizei GLenum type
Definition: glew.h:1253
unsigned int uint
Definition: SYS_Types.h:44
BRAY_CommandProperty
Properties interpreted by the command line renderer.
Definition: BRAY_Types.h:250
constexpr size_t BRAYmaxOptions< BRAY_SceneOption >()
Definition: BRAY_Types.h:354
BRAY_InteractionType
Definition: BRAY_Types.h:406
BRAY_LightType
Definition: BRAY_Types.h:387
GLdouble GLdouble GLdouble b
Definition: glew.h:9122
BRAY_API BRAY_Projection BRAYprojection(const UT_StringRef &n)
BRAY_SceneOption
Definition: BRAY_Types.h:66
BRAY_API BRAY_InteractionType BRAYinteractionType(const char *name)
BRAY_MaterialMask
Material evaluation flags.
Definition: BRAY_Types.h:508
#define BRAY_API
Definition: BRAY_API.h:12
#define SYS_UNIMPLEMENTED_TEMPLATE(T)
BRAY_PropertyType
Definition: BRAY_Types.h:264
int BRAYmaterialId
Consistent representation for material ids.
Definition: BRAY_Types.h:425
getOption("OpenEXR.storage") storage
Definition: HDK_Image.dox:276
constexpr size_t BRAYmaxOptions< BRAY_PlaneProperty >()
Definition: BRAY_Types.h:362
bool BRAYisValid(BRAY_PropertyType ty, int id)
Definition: BRAY_Types.h:289
constexpr BRAY_PropertyType BRAYpropertyType< BRAY_ObjectProperty >()
Definition: BRAY_Types.h:375
BRAY_LPEPrefix
List of known LPE prefixes.
Definition: BRAY_Types.h:431
BRAY_API const UT_StringHolder & BRAYproperty(BRAY_PropertyType ty, int id)
Look up the enum given a name.
BRAY_API UT_StringHolder BRAYeventType(BRAY_EventType type)
Create a nice string for the event type mask.
constexpr BRAY_PropertyType BRAYpropertyType< BRAY_SceneOption >()
Definition: BRAY_Types.h:373
GLdouble GLdouble t
Definition: glew.h:1398