SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLOptixDefinitions.h
Go to the documentation of this file.
1 /**
2  * \file SLOptixDefinitions.h
3  * \authors Nic Dorner
4  * \date October 2019
5  * \authors Nic Dorner
6  * \copyright http://opensource.org/licenses/GPL-3.0
7  * \remarks Please use clangformat to format the code. See more code style on
8  * https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style
9 */
10 
11 #ifdef SL_HAS_OPTIX
12 # ifndef SLOPTIXDEFINITIONS_H
13 # define SLOPTIXDEFINITIONS_H
14 # include <vector_types.h>
15 # include <optix_types.h>
16 # include <cuda.h>
17 # include <curand_kernel.h>
18 
19 //------------------------------------------------------------------------------
20 //! Optix ray tracing sample struct
21 struct ortSamples
22 {
23  unsigned int samplesX;
24  unsigned int samplesY;
25 };
26 //------------------------------------------------------------------------------
27 //! Optix ray tracing material information struct
28 struct ortMaterial
29 {
30  float4 diffuse_color;
31  float4 ambient_color;
32  float4 specular_color;
33  float4 transmissiv_color;
34  float4 emissive_color;
35  float shininess;
36  float kr;
37  float kt;
38  float kn;
39 };
40 //------------------------------------------------------------------------------
41 //! Optix ray tracing light information struct
42 struct ortLight
43 {
44  float4 diffuse_color;
45  float4 ambient_color;
46  float4 specular_color;
47  float3 position;
48  float spotCutOffDEG;
49  float spotExponent;
50  float spotCosCut;
51  float3 spotDirWS;
52  float kc;
53  float kl;
54  float kq;
55  ortSamples samples;
56  float radius;
57 };
58 //------------------------------------------------------------------------------
59 struct ortParams
60 {
61  float4* image;
62  unsigned int width;
63  unsigned int height;
64 
65  int max_depth;
66  float scene_epsilon;
67 
68  OptixTraversableHandle handle;
69 
70  union
71  {
72  struct
73  {
74  ortLight* lights;
75  unsigned int numLights;
76  float4 globalAmbientColor;
77  };
78 
79  struct
80  {
81  unsigned int samples;
82  unsigned int seed;
83  curandState* states;
84  };
85  };
86 };
87 //------------------------------------------------------------------------------
88 //! Optix ray tracing ray type enumeration
89 enum ortRayType
90 {
91  RAY_TYPE_RADIANCE = 0,
92  RAY_TYPE_OCCLUSION = 1,
93  RAY_TYPE_COUNT
94 };
95 //------------------------------------------------------------------------------
96 //! Optix ray tracing camera info for pinhole camera
97 struct ortCamera
98 {
99  float3 eye;
100  float3 U;
101  float3 V;
102  float3 W;
103 };
104 //------------------------------------------------------------------------------
105 //! Optix ray tracing camera info for lens camera
106 struct ortLensCamera
107 {
108  ortCamera camera;
109  ortSamples samples;
110  float lensDiameter;
111 };
112 //------------------------------------------------------------------------------
113 //! Optix ray tracing intersection miss data
114 struct ortMissData
115 {
116  float4 bg_color;
117 };
118 //------------------------------------------------------------------------------
119 //! Optix ray tracing intersection hit data
120 struct ortHitData
121 {
122  ortMaterial material;
123  CUtexObject textureObject;
124  int sbtIndex;
125  float3* normals;
126  short3* indices;
127  float2* texCords;
128 };
129 //------------------------------------------------------------------------------
130 template<typename T>
131 struct SbtRecord
132 {
133  __align__(OPTIX_SBT_RECORD_ALIGNMENT) char header[OPTIX_SBT_RECORD_HEADER_SIZE];
134  T data;
135 };
136 //------------------------------------------------------------------------------
137 typedef SbtRecord<ortCamera> RayGenClassicSbtRecord;
138 typedef SbtRecord<ortLensCamera> RayGenDistributedSbtRecord;
139 typedef SbtRecord<ortMissData> MissSbtRecord;
140 typedef SbtRecord<ortHitData> HitSbtRecord;
141 //------------------------------------------------------------------------------
142 # endif // SLOPTIXDEFINITIONS_H
143 #endif // SL_HAS_OPTIX