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 
232 };
233 
235 {
236  BRAY_PLANE_FILTER, // Pixel filter
237  BRAY_PLANE_SAMPLING, // Sample filtering (0 = average etc.)
238  BRAY_PLANE_EXCLUDE_DCM, // Exclude from deep camera images
239  BRAY_PLANE_DISABLE, // Disable the image plane
240  BRAY_PLANE_SEPARATE_FILE, // Filename to write image to
241  BRAY_PLANE_DITHER, // Dither for quantizing to integer values
242  BRAY_PLANE_DEFAULT_VALUE, // Default value for 1-channel planes
243 
246 };
247 
248 /// Properties interpreted by the command line renderer
250 {
251  BRAY_COMMAND_FRAME, // Start frame
252  BRAY_COMMAND_FRAME_COUNT, // Number of frames to render
253  BRAY_COMMAND_FRAME_INC, // Frame increment
254  BRAY_COMMAND_CHECKPOINT, // Seconds between checkpoint writes
255  BRAY_COMMAND_TIMELIMIT, // Time limit for rendering
256  BRAY_COMMAND_TIMELIMIT_IMAGE, // Time limit is specified per image
257  BRAY_COMMAND_TIMELIMIT_NOSAVE_PARTIAL, // Don't save WIP after timelimit
258 
261 };
262 
264 {
271 
274 };
275 
276 /// Return the name of the renderer
278 
279 /// Look up the enum given a name.
281  BRAY_PropertyType ty, int id);
283  const char *name);
286 
287 inline bool
289 {
290  return GT_STORE_INVALID
291  != BRAYpropertyStorage(ty, id);
292 }
293 
294 inline bool
295 BRAYisValid(const std::pair<BRAY_PropertyType, int> &prop)
296 {
297  return BRAYisValid(prop.first, prop.second);
298 }
299 
300 #define PROPERTY_LOOKUP(NAME, STYLE, ENUM) \
301  inline ENUM BRAY##NAME(const char *name) \
302  { return ENUM(BRAYproperty(STYLE, name)); } \
303  inline const UT_StringHolder &BRAY##NAME(ENUM token) \
304  { return BRAYproperty(STYLE, token); } \
305  inline exint BRAY##NAME##Size(ENUM token) \
306  { return BRAYpropertySize(STYLE, token); } \
307  inline GT_Storage BRAY##NAME##Storage(ENUM token) \
308  { return BRAYpropertyStorage(STYLE, token); } \
309  /* end of macro */
316 #undef PROPERTY_LOOKUP
317 
318 /// Lookup a property type by name
319 BRAY_API extern BRAY_PropertyType BRAYpropertyType(const char *name);
320 /// Look up the name of a property type by the id
322 
323 /// This function will resolve generic names to the appropriate property type
324 /// and property identifier. For example:
325 /// "plane:filter" -> {BRAY_PLANE_PROPERTY, BRAY_PLANE_FILTER}
326 /// "camera:focal" -> {BRAY_CAMERA_PROPERTY, BRAY_CAMERA_FOCAL}
327 /// "global:tilesize" -> {BRAY_SCENE_PROPERTY, BRAY_OPT_TILESIZE}
328 /// If the token doesn't map to a property, the function will return an invalid
329 /// pair (i.e. BRAYisValid(result) == false).
330 ///
331 /// If the token isn't prefixed with a property type, the @c default_style will
332 /// be used. For example, with the default of BRAY_SCENE_PROPERTY:
333 /// "tilesize" -> { BRAY_SCENE_PROPERTY, BRAY_OPT_TILESIZE }
334 /// "focal" -> {invalid_property_pair} (error - not a scene property)
335 BRAY_API extern std::pair<BRAY_PropertyType, int>
336  BRAYproperty(const char *token,
338 
339 /// Given a property type, this will compose a name string that fully qualifies
340 /// the property. This is a string that would be suitable for @c
341 /// BRAYlookupProperty(). This may return a @c nullptr.
342 BRAY_API extern const char *BRAYproperty(UT_WorkBuffer &storage,
344  int property_id,
345  const char *prefix = "");
346 
347 /// @{
348 /// Generic method to return the number of options given an enum
349 template <typename T> static inline constexpr size_t BRAYmaxOptions()
350 { SYS_UNIMPLEMENTED_TEMPLATE(T); return 0; }
351 
352 template <> inline constexpr size_t
354 template <> inline constexpr size_t
356 template <> inline constexpr size_t
358 template <> inline constexpr size_t
360 template <> inline constexpr size_t
362 template <> inline constexpr size_t
364 /// @}
365 
366 /// @{
367 /// Generic method to find the valud of the property type enum given the enum
368 template <typename T> static inline constexpr BRAY_PropertyType BRAYpropertyType()
370 
371 template <> inline constexpr BRAY_PropertyType
373 template <> inline constexpr BRAY_PropertyType
375 template <> inline constexpr BRAY_PropertyType
377 template <> inline constexpr BRAY_PropertyType
379 template <> inline constexpr BRAY_PropertyType
381 template <> inline constexpr BRAY_PropertyType
383 /// @}
384 
385 
387 {
397 
400 };
401 BRAY_API extern BRAY_LightType BRAYlightType(const char *name);
403 
404 // Different types of user interaction in IPR
406 {
413 
415 };
419 
420 /// Consistent representation of time type within BRAY
421 using BRAYtime = float;
422 
423 /// Consistent representation for material ids
425 
426 /// Invalid material id
427 static constexpr BRAYmaterialId BRAY_INVALID_MATERIAL_ID = 0;
428 
429 /// List of known LPE prefixes
431 {
434 };
435 static inline BRAY_LPEPrefix
436 operator|(BRAY_LPEPrefix a, BRAY_LPEPrefix b)
437 {
438  return BRAY_LPEPrefix(uint(a)|uint(b));
439 }
440 
442 {
449 
452 
455 };
456 
457 #define ENUM_TO_MASK(TOKEN) TOKEN = (1 << TOKEN##_ENUM)
458 /// Ray visibility flags
460 {
462 
463  ENUM_TO_MASK(BRAY_RAY_CAMERA),
464  ENUM_TO_MASK(BRAY_RAY_DIFFUSE),
465  ENUM_TO_MASK(BRAY_RAY_REFLECT),
466  ENUM_TO_MASK(BRAY_RAY_REFRACT),
467  ENUM_TO_MASK(BRAY_RAY_VOLUME),
468  ENUM_TO_MASK(BRAY_RAY_SHADOW),
469 
470  ENUM_TO_MASK(BRAY_PROXY_CAMERA),
471  ENUM_TO_MASK(BRAY_PROXY_SHADOW),
472 
473  ENUM_TO_MASK(BRAY_GUIDE_CAMERA),
474  ENUM_TO_MASK(BRAY_GUIDE_SHADOW),
475 
476  BRAY_ANY_CAMERA = (BRAY_RAY_CAMERA | BRAY_PROXY_CAMERA | BRAY_GUIDE_CAMERA),
477  BRAY_ANY_SHADOW = (BRAY_RAY_SHADOW | BRAY_PROXY_SHADOW | BRAY_GUIDE_SHADOW),
478 
479  BRAY_RAY_ALL = 0xFFFF,
480 
481  BRAY_RAY_PROXY_MASK = (BRAY_PROXY_CAMERA|BRAY_PROXY_SHADOW),
482  BRAY_RAY_GUIDE_MASK = (BRAY_GUIDE_CAMERA|BRAY_GUIDE_SHADOW),
485 };
486 #undef ENUM_TO_MASK
487 
488 static inline BRAY_RayVisibility
490 {
491  return BRAY_RayVisibility(uint(a)|uint(b));
492 }
493 static inline BRAY_RayVisibility
495 {
496  return BRAY_RayVisibility(uint(a)&uint(b));
497 }
498 static inline BRAY_RayVisibility
499 operator~(BRAY_RayVisibility a)
500 {
501  return BRAY_RayVisibility(~uint(a));
502 }
503 
505 
506 /// Material evaluation flags
508 {
510 };
511 
513 {
514  BRAY_RAYIMPORT_P, // vector: ray origin
515  BRAY_RAYIMPORT_D, // vector: ray direction
516  BRAY_RAYIMPORT_TIME, // float: shutter time
517  BRAY_RAYIMPORT_NEAR, // float: near bias
518  BRAY_RAYIMPORT_FAR, // float: max distance
519  BRAY_RAYIMPORT_MASK, // int: intersection mask
520  BRAY_RAYIMPORT_CONTRIB, // vector: contribution
521  BRAY_RAYIMPORT_HIT_P, // vector: Hit position (in world space)
522  BRAY_RAYIMPORT_HIT_Pz, // float: Pz (in space of camera)
523  BRAY_RAYIMPORT_HIT_STACK, // int[]: Hit stack
524  BRAY_RAYIMPORT_HIT_ELEM, // int: Hit element (raw id)
525  BRAY_RAYIMPORT_HIT_PRIMID, // int: Hit primitive id
526  BRAY_RAYIMPORT_HIT_COORD, // vector: raw parametric coords {u,v,w}
527  BRAY_RAYIMPORT_HIT_DIST, // float: Hit distance
528  BRAY_RAYIMPORT_HIT_DPDZ, // float: dPdz
529  BRAY_RAYIMPORT_HIT_N, // vector: smooth normal
530  BRAY_RAYIMPORT_HIT_Ng, // vector: geometric normal
531  BRAY_RAYIMPORT_HIT_FLAGS, // int: hit flags
532  BRAY_RAYIMPORT_LEVEL, // int: ray level
533  BRAY_RAYIMPORT_HD_PRIM, // int: hydra rprim id for selection
534  BRAY_RAYIMPORT_HD_INST, // int: hydra inst idx (0th level) for selection
535 
536  BRAY_RAYIMPORT_INVALID // Not a valid ray import
537 };
539 BRAY_API extern const char *BRAYrayImport(BRAY_VexRayImport t);
540 
541 /// Generic method to return the number of components for a given import
542 /// Note that arrays types return 0 (see BRAYrayImportArray())
543 template <BRAY_VexRayImport T> static inline constexpr size_t BRAYrayImportSize()
544 {
545 #if !defined(__clang__)
547 #endif
548  return 0;
549 }
550 /// Generic method to return whether the import variable is array valued
551 template <BRAY_VexRayImport T> static inline constexpr bool BRAYrayImportIsArray()
552 {
553 #if !defined(__clang__)
555 #endif
556  return false;
557 }
558 
559 #define INSTANTIATE(VAR, SIZE, IS_ARRAY) \
560  template <> inline constexpr size_t \
561  BRAYrayImportSize<VAR>() { return SIZE; } \
562  template <> inline constexpr bool \
563  BRAYrayImportIsArray<VAR>() { return IS_ARRAY; } \
564  /* end of macro */
565 
566 INSTANTIATE(BRAY_RAYIMPORT_P, 3, false)
567 INSTANTIATE(BRAY_RAYIMPORT_D, 3, false)
585 
586 #undef INSTANTIATE
587 
588 #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:457
GLuint const GLchar * name
Definition: glew.h:1814
constexpr BRAY_PropertyType BRAYpropertyType< BRAY_LightProperty >()
Definition: BRAY_Types.h:376
float BRAYtime
Consistent representation of time type within BRAY.
Definition: BRAY_Types.h:421
BRAY_API GT_Storage BRAYpropertyStorage(BRAY_PropertyType ty, int id)
BRAY_RayVisibility
Ray visibility flags.
Definition: BRAY_Types.h:459
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:512
#define INSTANTIATE(VAR, SIZE, IS_ARRAY)
Definition: BRAY_Types.h:559
BRAY_RayVisibilityEnum
Definition: BRAY_Types.h:441
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:359
constexpr BRAY_PropertyType BRAYpropertyType< BRAY_CameraProperty >()
Definition: BRAY_Types.h:378
BRAY_API exint BRAYpropertySize(BRAY_PropertyType ty, int id)
constexpr BRAY_PropertyType BRAYpropertyType< BRAY_PlaneProperty >()
Definition: BRAY_Types.h:380
constexpr size_t BRAYmaxOptions< BRAY_ObjectProperty >()
Definition: BRAY_Types.h:355
constexpr BRAY_PropertyType BRAYpropertyType< BRAY_CommandProperty >()
Definition: BRAY_Types.h:382
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:363
constexpr size_t BRAYmaxOptions< BRAY_LightProperty >()
Definition: BRAY_Types.h:357
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:300
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
BRAY_LightProperty
Definition: BRAY_Types.h:210
BRAY_PlaneProperty
Definition: BRAY_Types.h:234
#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:249
constexpr size_t BRAYmaxOptions< BRAY_SceneOption >()
Definition: BRAY_Types.h:353
BRAY_InteractionType
Definition: BRAY_Types.h:405
BRAY_LightType
Definition: BRAY_Types.h:386
GLdouble GLdouble GLdouble b
Definition: glew.h:9122
BRAY_SceneOption
Definition: BRAY_Types.h:66
BRAY_API BRAY_InteractionType BRAYinteractionType(const char *name)
BRAY_MaterialMask
Material evaluation flags.
Definition: BRAY_Types.h:507
#define BRAY_API
Definition: BRAY_API.h:12
#define SYS_UNIMPLEMENTED_TEMPLATE(T)
BRAY_PropertyType
Definition: BRAY_Types.h:263
int BRAYmaterialId
Consistent representation for material ids.
Definition: BRAY_Types.h:424
getOption("OpenEXR.storage") storage
Definition: HDK_Image.dox:276
constexpr size_t BRAYmaxOptions< BRAY_PlaneProperty >()
Definition: BRAY_Types.h:361
bool BRAYisValid(BRAY_PropertyType ty, int id)
Definition: BRAY_Types.h:288
constexpr BRAY_PropertyType BRAYpropertyType< BRAY_ObjectProperty >()
Definition: BRAY_Types.h:374
BRAY_LPEPrefix
List of known LPE prefixes.
Definition: BRAY_Types.h:430
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:372
GLdouble GLdouble t
Definition: glew.h:1398