SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLRay Class Reference

Ray class with ray and intersection properties. More...

#include <SLRay.h>

Public Member Functions

 SLRay (SLSceneView *sv=nullptr)
 default ctor More...
 
 SLRay (const SLVec3f &Origin, const SLVec3f &Dir, SLfloat X, SLfloat Y, const SLCol4f &backColor, SLSceneView *sv)
 ctor for primary rays More...
 
 SLRay (SLfloat distToLight, const SLVec3f &dirToLight, SLRay *rayFromHitPoint)
 ctor for shadow rays More...
 
void reflect (SLRay *reflected) const
 
void refract (SLRay *refracted)
 
bool reflectMC (SLRay *reflected, const SLMat3f &rotMat) const
 
void refractMC (SLRay *refracted, const SLMat3f &rotMat) const
 
void diffuseMC (SLRay *scattered) const
 
void print () const
 
void setDir (const SLVec3f &Dir)
 Setter for the rays direction in world space also setting the inverse direction. More...
 
void setDirOS (const SLVec3f &Dir)
 Setter for the rays direction in object space also setting the inverse direction. More...
 
void normalizeNormal ()
 
SLbool isShaded () const
 Returns true if a shadow ray hits an object on the ray to the light. More...
 
SLbool hitMatIsReflective () const
 Returns true if the hit material specular color is not black. More...
 
SLbool hitMatIsTransparent () const
 Returns true if the hit material transmission color is not black. More...
 
SLbool hitMatIsDiffuse () const
 Returns true if the hit material diffuse color is not black. More...
 
 SLRay ()
 default ctor More...
 
 SLRay (SLVec3f Origin, SLVec3f Dir, SLint X, SLint Y)
 ctor for primary rays More...
 
 SLRay (SLfloat distToLight, SLVec3f dirToLight, SLRay *rayFromHitPoint)
 ctor for shadow rays More...
 
 SLRay (SLVec3f origin, SLVec3f dir, SLRayType type, SLShape *originShape, SLfloat length=SL_FLOAT_MAX, SLint depth=1)
 ctor for all parameters More...
 
void reflect (SLRay *reflected)
 
void refract (SLRay *refracted)
 
bool reflectMC (SLRay *reflected, SLMat3f rotMat)
 
void refractMC (SLRay *refracted, SLMat3f rotMat)
 
void diffuseMC (SLRay *scattered)
 
void setDir (SLVec3f Dir)
 
void setDirOS (SLVec3f Dir)
 
SLbool isShaded ()
 
void print ()
 
void normalizeNormal ()
 
SLbool nodeReflectance ()
 
SLbool nodeTransparency ()
 
SLbool nodeDiffuse ()
 

Static Public Member Functions

static SLuint totalNumRays ()
 Total NO. of rays shot during RT. More...
 

Public Attributes

SLVec3f origin
 Vector to the origin of ray in WS. More...
 
SLVec3f dir
 Direction vector of ray in WS. More...
 
SLfloat length
 length from origin to an intersection More...
 
SLint depth
 Recursion depth for ray tracing. More...
 
SLfloat contrib
 Current contribution of ray to color. More...
 
SLVec3f originOS
 Vector to the origin of ray in OS. More...
 
SLVec3f dirOS
 Direction vector of ray in OS. More...
 
SLRayType type
 PRIMARY, REFLECTED, REFRACTED, SHADOW. More...
 
SLfloat lightDist
 Distance to light for shadow rays. More...
 
SLfloat x
 
SLfloat y
 Pixel position for primary rays. More...
 
SLbool isOutside
 Flag if ray is inside of a material. More...
 
SLbool isInsideVolume
 Flag if ray is in Volume. More...
 
SLNodesrcNode
 Points to the node at ray origin. More...
 
SLMeshsrcMesh
 Points to the mesh at ray origin. More...
 
SLint srcTriangle
 Points to the triangle at ray origin. More...
 
SLCol4f backgroundColor
 Background color at pixel x,y. More...
 
SLSceneViewsv
 Pointer to the sceneview. More...
 
SLfloat hitU
 
SLfloat hitV
 barycentric coords in hit triangle More...
 
SLNodehitNode
 Points to the intersected node. More...
 
SLMeshhitMesh
 Points to the intersected mesh. More...
 
SLint hitTriangle
 Points to the intersected triangle. More...
 
SLVec3f hitPoint
 Point of intersection. More...
 
SLVec3f hitNormal
 Surface normal at intersection point. More...
 
SLCol4f hitTexColor
 Color at intersection for texture or color attributes. More...
 
SLfloat hitAO
 Ambient occlusion factor at intersection point. More...
 
SLVec3f invDir
 Inverse ray dir for fast AABB hit in WS. More...
 
SLVec3f invDirOS
 Inverse ray dir for fast AABB hit in OS. More...
 
SLint sign [3]
 Sign of invDir for fast AABB hit in WS. More...
 
SLint signOS [3]
 Sign of invDir for fast AABB hit in OS. More...
 
SLfloat tmin
 min. dist. of last AABB intersection More...
 
SLfloat tmax
 max. dist. of last AABB intersection More...
 
SLShape * originShape
 Points to the shape at ray origin. More...
 
SLFace * originTria
 Points to the triangle at ray origin. More...
 
SLMaterialoriginMat
 Points to appearance at ray origin. More...
 
SLShape * hitShape
 Points to the intersected shape. More...
 
SLFace * hitTriangle
 Points to the intersected triangle. More...
 
SLMaterialhitMat
 Points to material of intersected node. More...
 
SLCol4f hitTexCol
 Texture color at intersection point. More...
 

Static Public Attributes

static SLint maxDepth = 0
 Max. recursion depth. More...
 
static SLfloat minContrib = 1.0 / 256.0
 Min. contibution to color (1/256) More...
 
static SLuint primaryRays = 0
 NO. of primary rays shot. More...
 
static SLuint reflectedRays = 0
 NO. of reflected rays. More...
 
static SLuint refractedRays = 0
 NO. of refracted rays. More...
 
static SLuint ignoredRays = 0
 NO. of ignore refraction rays. More...
 
static SLuint shadowRays = 0
 NO. of shadow rays. More...
 
static SLuint tirRays = 0
 NO. of TIR refraction rays. More...
 
static SLuint tests = 0
 NO. of intersection tests. More...
 
static SLuint intersections = 0
 NO. of intersection. More...
 
static SLint depthReached = 1
 depth reached for a primary ray More...
 
static SLint maxDepthReached = 0
 max. depth reached for all rays More...
 
static SLfloat avgDepth = 0
 average depth reached More...
 
static SLuint subsampledRays = 0
 NO. of of subsampled rays. More...
 
static SLuint subsampledPixels = 0
 NO. of of subsampled pixels. More...
 
static SLlong emittedPhotons = 0
 NO. of emitted photons from all lightsources. More...
 
static SLlong diffusePhotons = 0
 NO. of diffusely scattered photons on surfaces. More...
 
static SLlong reflectedPhotons = 0
 NO. of reflected photons;. More...
 
static SLlong refractedPhotons = 0
 NO. of refracted photons;. More...
 
static SLlong tirPhotons = 0
 NO. of total internal refraction photons. More...
 
static SLbool ignoreLights = true
 flag for gloss sampling More...
 
static TRanrotBGenerator * random = new TRanrotBGenerator((unsigned)time(NULL))
 Random generator. More...
 

Detailed Description

Ray class with ray and intersection properties.

Ray class for Ray Tracing. It not only holds informations about the ray itself but also about the node hit by the ray. With that information the method reflect calculates a reflected ray and the method transmit calculates a REFRACTED ray.

Ray class for Ray Tracing. It not only holds informations about the ray itself but also about the node hit by the ray. With that information the method reflect calculates a reflected ray and the method transmit calculates a transmitted ray.

Definition at line 39 of file SLRay.h.

Constructor & Destructor Documentation

◆ SLRay() [1/7]

SLRay::SLRay ( SLSceneView sceneView = nullptr)
explicit

default ctor

SLRay::SLRay default constructor

Definition at line 44 of file SLRay.cpp.

45 {
48  type = PRIMARY;
49  length = FLT_MAX;
50  depth = 1;
51  hitTriangle = -1;
55  hitAO = 1.0f;
56  hitNode = nullptr;
57  hitMesh = nullptr;
58  srcNode = nullptr;
59  srcMesh = nullptr;
60  srcTriangle = -1;
61  x = -1;
62  y = -1;
63  contrib = 1.0f;
64  isOutside = true;
65  isInsideVolume = false;
66  sv = sceneView;
67 }
@ PRIMARY
Definition: SLRay.h:23
SLint hitTriangle
Points to the intersected triangle.
Definition: SLRay.h:107
SLVec3f origin
Vector to the origin of ray in WS.
Definition: SLRay.h:75
SLRayType type
PRIMARY, REFLECTED, REFRACTED, SHADOW.
Definition: SLRay.h:92
SLint srcTriangle
Points to the triangle at ray origin.
Definition: SLRay.h:99
SLMesh * hitMesh
Points to the intersected mesh.
Definition: SLRay.h:106
SLbool isOutside
Flag if ray is inside of a material.
Definition: SLRay.h:95
SLint depth
Recursion depth for ray tracing.
Definition: SLRay.h:78
SLfloat hitAO
Ambient occlusion factor at intersection point.
Definition: SLRay.h:113
SLMesh * srcMesh
Points to the mesh at ray origin.
Definition: SLRay.h:98
SLfloat length
length from origin to an intersection
Definition: SLRay.h:77
SLNode * hitNode
Points to the intersected node.
Definition: SLRay.h:105
SLfloat contrib
Current contribution of ray to color.
Definition: SLRay.h:79
SLbool isInsideVolume
Flag if ray is in Volume.
Definition: SLRay.h:96
SLVec3f hitPoint
Point of intersection.
Definition: SLRay.h:110
SLNode * srcNode
Points to the node at ray origin.
Definition: SLRay.h:97
void setDir(const SLVec3f &Dir)
Setter for the rays direction in world space also setting the inverse direction.
Definition: SLRay.h:146
SLCol4f hitTexColor
Color at intersection for texture or color attributes.
Definition: SLRay.h:112
SLfloat y
Pixel position for primary rays.
Definition: SLRay.h:94
SLfloat x
Definition: SLRay.h:94
SLVec3f hitNormal
Surface normal at intersection point.
Definition: SLRay.h:111
SceneView class represents a dynamic real time 3D view onto the scene.
Definition: SLSceneView.h:69
static SLVec3 ZERO
Definition: SLVec3.h:285
static SLVec4 WHITE
Definition: SLVec4.h:215

◆ SLRay() [2/7]

SLRay::SLRay ( const SLVec3f Origin,
const SLVec3f Dir,
SLfloat  X,
SLfloat  Y,
const SLCol4f backColor,
SLSceneView sceneView 
)

ctor for primary rays

SLRay::SLRay constructor for primary rays

Definition at line 72 of file SLRay.cpp.

78 {
79  origin = Origin;
80  setDir(Dir);
81  type = PRIMARY;
82  length = FLT_MAX;
83  depth = 1;
84  hitTriangle = -1;
88  hitAO = 1.0f;
89  hitNode = nullptr;
90  hitMesh = nullptr;
91  srcNode = nullptr;
92  srcMesh = nullptr;
93  srcTriangle = -1;
94  x = (SLfloat)X;
95  y = (SLfloat)Y;
96  contrib = 1.0f;
97  isOutside = true;
98  isInsideVolume = false;
99  backgroundColor = backColor;
100  sv = sceneView;
101 }
float SLfloat
Definition: SL.h:173
SLCol4f backgroundColor
Background color at pixel x,y.
Definition: SLRay.h:100

◆ SLRay() [3/7]

SLRay::SLRay ( SLfloat  distToLight,
const SLVec3f dirToLight,
SLRay rayFromHitPoint 
)

ctor for shadow rays

SLRay::SLRay constructor for shadow rays

Definition at line 106 of file SLRay.cpp.

109 {
110  origin = rayFromHitPoint->hitPoint;
111  setDir(dirToLight);
112  type = SHADOW;
113  length = distToLight;
114  lightDist = distToLight;
115  depth = rayFromHitPoint->depth;
119  hitAO = 1.0f;
120  hitTriangle = -1;
121  hitNode = nullptr;
122  hitMesh = nullptr;
123  srcNode = rayFromHitPoint->hitNode;
124  srcMesh = rayFromHitPoint->hitMesh;
125  srcTriangle = rayFromHitPoint->hitTriangle;
126  x = rayFromHitPoint->x;
127  y = rayFromHitPoint->y;
128  backgroundColor = rayFromHitPoint->backgroundColor;
129  sv = rayFromHitPoint->sv;
130  contrib = 0.0f;
131  isOutside = rayFromHitPoint->isOutside;
132  shadowRays++;
133 }
@ SHADOW
Definition: SLRay.h:26
SLfloat lightDist
Distance to light for shadow rays.
Definition: SLRay.h:93
static SLuint shadowRays
NO. of shadow rays.
Definition: SLRay.h:130
SLSceneView * sv
Pointer to the sceneview.
Definition: SLRay.h:101

◆ SLRay() [4/7]

SLRay::SLRay ( )

default ctor

SLRay::SLRay default constructor

Definition at line 44 of file SLRayMC.cpp.

45 {
48  type = PRIMARY;
49  length = SL_FLOAT_MAX;
50  depth = 1;
51  hitTriangle = 0;
55  hitShape = 0;
56  hitMat = 0;
57  originTria = 0;
58  originMat = 0;
59  x = -1;
60  y = -1;
61  contrib = 1.0f;
62  isOutside = true;
63 }
SLCol4f hitTexCol
Texture color at intersection point.
Definition: SLRayMC.h:121
SLFace * originTria
Points to the triangle at ray origin.
Definition: SLRayMC.h:109
SLMaterial * hitMat
Points to material of intersected node.
Definition: SLRayMC.h:116
SLShape * hitShape
Points to the intersected shape.
Definition: SLRayMC.h:114
SLMaterial * originMat
Points to appearance at ray origin.
Definition: SLRayMC.h:110
static SLVec4 BLACK
Definition: SLVec4.h:213

◆ SLRay() [5/7]

SLRay::SLRay ( SLVec3f  Origin,
SLVec3f  Dir,
SLint  X,
SLint  Y 
)

ctor for primary rays

SLRay::SLRay constructor for primary rays

Definition at line 68 of file SLRayMC.cpp.

69 {
70  origin = Origin;
71  setDir(Dir);
72  type = PRIMARY;
73  length = SL_FLOAT_MAX;
74  depth = 1;
75  hitTriangle = 0;
79  hitShape = 0;
80  hitMat = 0;
81  originTria = 0;
82  originMat = 0;
83  x = (SLfloat)X;
84  y = (SLfloat)Y;
85  contrib = 1.0f;
86  isOutside = true;
87 }

◆ SLRay() [6/7]

SLRay::SLRay ( SLfloat  distToLight,
SLVec3f  dirToLight,
SLRay rayFromHitPoint 
)

ctor for shadow rays

SLRay::SLRay constructor for shadow rays

Definition at line 92 of file SLRayMC.cpp.

95 {
96  origin = rayFromHitPoint->hitPoint;
97  setDir(dirToLight);
98  type = SHADOW;
99  length = distToLight;
100  lightDist = distToLight;
101  depth = rayFromHitPoint->depth;
105  hitTriangle = 0;
106  hitShape = 0;
107  hitMat = 0;
108  originTria = rayFromHitPoint->hitTriangle;
109  originMat = rayFromHitPoint->hitMat;
110  x = rayFromHitPoint->x;
111  y = rayFromHitPoint->y;
112  contrib = 0.0f;
113  isOutside = rayFromHitPoint->isOutside;
114  shadowRays++;
115 }

◆ SLRay() [7/7]

SLRay::SLRay ( SLVec3f  origin,
SLVec3f  dir,
SLRayType  type,
SLShape *  originShape,
SLfloat  length = SL_FLOAT_MAX,
SLint  depth = 1 
)

ctor for all parameters

Definition at line 117 of file SLRayMC.cpp.

123 {
124  origin = origin;
125  setDir(dir);
126  type = type;
127  length = length;
128  depth = depth;
129  hitShape = 0;
132  hitMat = 0;
134  originMat = 0;
135  x = y = -1;
136 
137  if (type == SHADOW)
138  {
139  ++shadowRays;
140  lightDist = length;
141  }
142 }
SLVec3f dir
Direction vector of ray in WS.
Definition: SLRay.h:76
SLShape * originShape
Points to the shape at ray origin.
Definition: SLRayMC.h:108

Member Function Documentation

◆ diffuseMC() [1/2]

void SLRay::diffuseMC ( SLRay scattered)

SLRay::diffuseMC scatters a ray around hit normal (cosine distribution). This is only used for photonmapping(russian roulette). The random direction lies around z-Axis and is then transformed by a rotation matrix to lie along the normal. The direction is calculated according to MCCABE

Definition at line 346 of file SLRayMC.cpp.

347 {
348  SLVec3f randVec;
349  SLfloat eta1, eta2, eta1sqrt;
350 
351  scattered->setDir(hitNormal);
352  scattered->origin = hitPoint;
353  scattered->depth = depth + 1;
354  depthReached = scattered->depth;
355 
356  // for reflectance the start material stays the same
357  scattered->originMat = hitMat;
358  scattered->originShape = hitShape;
359  scattered->type = REFLECTED;
360 
361  // calculate rotation matrix
362  SLMat3f rotMat;
363  SLVec3f rotAxis((SLVec3f(0.0, 0.0, 1.0) ^ scattered->dir).normalize());
364  SLfloat rotAngle = acos(scattered->dir.z); // z*scattered.dir()
365  rotMat.rotation(rotAngle * 180.0f / Utils::ONEPI, rotAxis);
366 
367  // cosine distribution
368  eta1 = (SLfloat)random->Random();
369  eta2 = SL_2PI * (SLfloat)random->Random();
370  eta1sqrt = sqrt(1 - eta1);
371  // transform to cartesian
372  randVec.set(eta1sqrt * cos(eta2),
373  eta1sqrt * sin(eta2),
374  sqrt(eta1));
375 
376  scattered->setDir(rotMat * randVec);
377 }
@ REFLECTED
Definition: SLRay.h:24
SLVec3< SLfloat > SLVec3f
Definition: SLVec3.h:318
void rotation(const T angleDEG, const SLVec3< T > &axis)
Sets the rotation components
Definition: SLMat3.h:392
static SLint depthReached
depth reached for a primary ray
Definition: SLRay.h:134
static TRanrotBGenerator * random
Random generator.
Definition: SLRayMC.h:153
void set(const T X, const T Y, const T Z)
Definition: SLVec3.h:59
T z
Definition: SLVec3.h:43

◆ diffuseMC() [2/2]

void SLRay::diffuseMC ( SLRay scattered) const

SLRay::diffuseMC scatters a ray around hit normal (cosine distribution). This is only used for photonmapping(russian roulette). The random direction lies around z-Axis and is then transformed by a rotation matrix to lie along the normal. The direction is calculated according to MCCABE

Definition at line 429 of file SLRay.cpp.

430 {
431  SLVec3f randVec;
432  SLfloat eta1, eta2, eta1sqrt;
433 
434  scattered->setDir(hitNormal);
435  scattered->origin = hitPoint;
436  scattered->depth = depth + 1;
437  depthReached = scattered->depth;
438 
439  // for reflectance the start material stays the same
440  scattered->srcNode = hitNode;
441  scattered->srcMesh = hitMesh;
442  scattered->type = REFLECTED;
443 
444  // calculate rotation matrix
445  SLMat3f rotMat;
446  SLVec3f rotAxis((SLVec3f(0.0, 0.0, 1.0) ^ scattered->dir).normalize());
447  SLfloat rotAngle = acos(scattered->dir.z); // z*scattered.dir()
448  rotMat.rotation(rotAngle * 180.0f * Utils::ONEOVERPI, rotAxis);
449 
450  // cosine distribution
451  eta1 = rnd01();
452  eta2 = Utils::TWOPI * rnd01();
453  eta1sqrt = sqrt(1 - eta1);
454 
455  // transform to cartesian
456  randVec.set(eta1sqrt * cos(eta2),
457  eta1sqrt * sin(eta2),
458  sqrt(eta1));
459 
460  // Apply rotation
461  scattered->setDir(rotMat * randVec);
462 
463  // Set pixel and background
464  scattered->x = x;
465  scattered->y = y;
466  scattered->sv = sv;
467  if (sv->s()->skybox())
468  scattered->backgroundColor = sv->s()->skybox()->colorAtDir(scattered->dir);
469  else
470  scattered->backgroundColor = backgroundColor;
471 }
SLfloat rnd01()
Definition: SLRay.cpp:39
void skybox(SLSkybox *skybox)
Definition: SLScene.h:91
SLScene * s()
Definition: SLSceneView.h:167
static const float ONEOVERPI
Definition: Utils.h:241
static const float TWOPI
Definition: Utils.h:240

◆ hitMatIsDiffuse()

SLbool SLRay::hitMatIsDiffuse ( ) const
inline

Returns true if the hit material diffuse color is not black.

Definition at line 216 of file SLRay.h.

217 {
218  if (!hitMesh) return false;
219  SLMaterial* mat = hitMesh->mat();
220  return ((mat->diffuse().r > 0.0f) ||
221  (mat->diffuse().g > 0.0f) ||
222  (mat->diffuse().b > 0.0f));
223 }
Defines a standard CG material with textures and a shader program.
Definition: SLMaterial.h:56
void diffuse(const SLCol4f &diff)
Definition: SLMaterial.h:171
SLMaterial * mat() const
Definition: SLMesh.h:177

◆ hitMatIsReflective()

SLbool SLRay::hitMatIsReflective ( ) const
inline

Returns true if the hit material specular color is not black.

Definition at line 194 of file SLRay.h.

195 {
196  if (!hitMesh) return false;
197  SLMaterial* mat = hitMesh->mat();
198  return ((mat->specular().r > 0.0f) ||
199  (mat->specular().g > 0.0f) ||
200  (mat->specular().b > 0.0f));
201 }
void specular(const SLCol4f &spec)
Definition: SLMaterial.h:173

◆ hitMatIsTransparent()

SLbool SLRay::hitMatIsTransparent ( ) const
inline

Returns true if the hit material transmission color is not black.

Definition at line 205 of file SLRay.h.

206 {
207  if (!hitMesh) return false;
208  SLMaterial* mat = hitMesh->mat();
209  return ((mat->transmissive().r > 0.0f) ||
210  (mat->transmissive().g > 0.0f) ||
211  (mat->transmissive().b > 0.0f));
212 }
void transmissive(const SLCol4f &transm)
Definition: SLMaterial.h:175

◆ isShaded() [1/2]

SLbool SLRay::isShaded ( )
inline

Definition at line 90 of file SLRayMC.h.

90 { return type == SHADOW && length < lightDist; }
@ SHADOW
Definition: SLRayMC.h:26

◆ isShaded() [2/2]

SLbool SLRay::isShaded ( ) const
inline

Returns true if a shadow ray hits an object on the ray to the light.

Definition at line 187 of file SLRay.h.

188 {
189  return type == SHADOW && length < lightDist;
190 }

◆ nodeDiffuse()

SLbool SLRay::nodeDiffuse ( )
inline

Definition at line 165 of file SLRayMC.h.

165  { return ((hitMat->diffuse().r > 0.0f) ||
166  (hitMat->diffuse().g > 0.0f) ||
167  (hitMat->diffuse().b > 0.0f)); }

◆ nodeReflectance()

SLbool SLRay::nodeReflectance ( )
inline

Definition at line 159 of file SLRayMC.h.

159  { return ((hitMat->specular().r > 0.0f) ||
160  (hitMat->specular().g > 0.0f) ||
161  (hitMat->specular().b > 0.0f)); }

◆ nodeTransparency()

SLbool SLRay::nodeTransparency ( )
inline

Definition at line 162 of file SLRayMC.h.

162  { return ((hitMat->transmission().r > 0.0f) ||
163  (hitMat->transmission().g > 0.0f) ||
164  (hitMat->transmission().b > 0.0f)); }

◆ normalizeNormal() [1/2]

void SLRay::normalizeNormal ( )
inline

SLRay::normalizeNormal does a careful normalization of the normal only when the squared length is > 1.0+FLT_EPSILON or < 1.0-FLT_EPSILON.

SLRay::normalizeNormal does a careful normalization of the normal only when the squared length is > 1.0+SL_EPSILON or < 1.0-SL_EPSILON.

Definition at line 175 of file SLRay.h.

176 {
177  SLfloat nLenSqr = hitNormal.lengthSqr();
178  if (nLenSqr > 1.0f + FLT_EPSILON || nLenSqr < 1.0f - FLT_EPSILON)
179  {
180  SLfloat len = sqrt(nLenSqr);
181  hitNormal /= len;
182  }
183 }
T lengthSqr() const
Definition: SLVec3.h:123

◆ normalizeNormal() [2/2]

void SLRay::normalizeNormal ( )

◆ print() [1/2]

void SLRay::print ( )

SLRay::prints prints the rays origin (O), direction (D) and the length to the intersection (L)

Definition at line 148 of file SLRayMC.cpp.

149 {
150  SL_LOG("Ray: O(%.2f, %.2f, %.2f), D(%.2f, %.2f, %.2f), L: %.2f\n",
151  origin.x,
152  origin.y,
153  origin.z,
154  dir.x,
155  dir.y,
156  dir.z,
157  length);
158 }
#define SL_LOG(...)
Definition: SL.h:233
T y
Definition: SLVec3.h:43
T x
Definition: SLVec3.h:43

◆ print() [2/2]

void SLRay::print ( ) const

SLRay::prints prints the rays origin (O), direction (D) and the length to the intersection (L)

Definition at line 139 of file SLRay.cpp.

140 {
141  SL_LOG("Ray: O(%.2f, %.2f, %.2f), D(%.2f, %.2f, %.2f), L: %.2f",
142  origin.x,
143  origin.y,
144  origin.z,
145  dir.x,
146  dir.y,
147  dir.z,
148  length);
149 }

◆ reflect() [1/2]

void SLRay::reflect ( SLRay reflected)

SLRay::reflect calculates a secondary ray reflected at the normal, starting at the intersection point. All vectors must be normalized vectors. R = 2(-I�N) N + I

Definition at line 179 of file SLRayMC.cpp.

180 {
181  SLVec3f R(dir - 2.0f * (dir * hitNormal) * hitNormal);
182 
183  reflected->setDir(R);
184  reflected->origin.set(hitPoint);
185  reflected->depth = depth + 1;
186  reflected->length = SL_FLOAT_MAX;
187  reflected->contrib = contrib * hitMat->kr();
188  reflected->originMat = hitMat;
189  reflected->originShape = hitShape;
190  reflected->originTria = hitTriangle;
191  reflected->type = REFLECTED;
192  reflected->isOutside = isOutside;
193  reflected->x = x;
194  reflected->y = y;
195  depthReached = reflected->depth;
196  ++reflectedRays;
197 }
void kr(SLfloat kr)
Definition: SLMaterial.h:184
static SLuint reflectedRays
NO. of reflected rays.
Definition: SLRay.h:127

◆ reflect() [2/2]

void SLRay::reflect ( SLRay reflected) const

SLRay::reflect calculates a secondary ray reflected at the normal, starting at the intersection point. All vectors must be normalized vectors. R = 2(-I*N) N + I

Definition at line 156 of file SLRay.cpp.

157 {
158 #ifdef DEBUG_RAY
159  for (SLint i = 0; i < depth; ++i)
160  cout << " ";
161  cout << "Reflect: " << hitMesh->name() << endl;
162 #endif
163 
164  SLVec3f R(dir - 2.0f * (dir * hitNormal) * hitNormal);
165 
166  reflected->setDir(R);
167  reflected->origin.set(hitPoint);
168  reflected->depth = depth + 1;
169  reflected->length = FLT_MAX;
170  reflected->contrib = contrib * hitMesh->mat()->kr();
171  reflected->srcNode = hitNode;
172  reflected->srcMesh = hitMesh;
173  reflected->srcTriangle = hitTriangle;
174  reflected->type = REFLECTED;
175  reflected->isOutside = isOutside;
176  reflected->x = x;
177  reflected->y = y;
178  reflected->sv = sv;
179  if (sv->s()->skybox())
180  reflected->backgroundColor = sv->s()->skybox()->colorAtDir(reflected->dir);
181  else
182  reflected->backgroundColor = backgroundColor;
183 
184  depthReached = reflected->depth;
185  ++reflectedRays;
186 }
int SLint
Definition: SL.h:170
void name(const SLstring &Name)
Definition: SLObject.h:34

◆ reflectMC() [1/2]

bool SLRay::reflectMC ( SLRay reflected,
const SLMat3f rotMat 
) const

SLRay::reflectMC scatters a ray around perfect specular direction according to shininess (for higher shininess the ray is less scattered). This is used for path tracing and distributed ray tracing as well as for photon scattering. The direction is calculated according to MCCABE. The created direction is along z-axis and then transformed to lie along specular direction with rotationMatrix rotMat. The rotation matrix must be precalculated (stays the same for each ray sample, needs to be be calculated only once)

Definition at line 332 of file SLRay.cpp.

333 {
334  SLfloat eta1, eta2;
335  SLVec3f randVec;
336  SLfloat shininess = hitMesh->mat()->shininess();
337 
338  // scatter within specular lobe
339  eta1 = rnd01();
340  eta2 = Utils::TWOPI * rnd01();
341  SLfloat f1 = sqrt(1.0f - pow(eta1, 2.0f / (shininess + 1.0f)));
342 
343  // tranform to cartesian
344  randVec.set(f1 * cos(eta2),
345  f1 * sin(eta2),
346  pow(eta1, 1.0f / (shininess + 1.0f)));
347 
348  // ray needs to be reset if already hit a scene node
349  if (reflected->hitNode)
350  {
351  reflected->length = FLT_MAX;
352  reflected->hitNode = nullptr;
353  reflected->hitMesh = nullptr;
354  reflected->hitPoint = SLVec3f::ZERO;
355  reflected->hitNormal = SLVec3f::ZERO;
356  }
357 
358  // apply rotation
359  reflected->setDir(rotMat * randVec);
360 
361  // Set pixel and background
362  reflected->x = x;
363  reflected->y = y;
364  reflected->sv = sv;
365  if (sv->s()->skybox())
366  reflected->backgroundColor = sv->s()->skybox()->colorAtDir(reflected->dir);
367  else
368  reflected->backgroundColor = backgroundColor;
369 
370  // true if in direction of normal
371  return (hitNormal * reflected->dir >= 0.0f);
372 }
void shininess(SLfloat shin)
Definition: SLMaterial.h:177

◆ reflectMC() [2/2]

bool SLRay::reflectMC ( SLRay reflected,
SLMat3f  rotMat 
)

SLRay::reflectMC scatters a ray around perfect specular direction according to shininess (for higher shininess the ray is less scattered). This is used for path tracing and distributed ray tracing as well as for photon scattering. The direction is calculated according to MCCABE. The created direction is along z-axis and then transformed to lie along specular direction with rotationMatrix rotMat. The rotation matrix must be precalculated (stays the same for each ray sample, needs to be be calculated only once)

Definition at line 270 of file SLRayMC.cpp.

271 {
272  SLfloat eta1, eta2;
273  SLVec3f randVec;
274  SLfloat shininess = hitMat->shininess();
275 
276  // scatter within specular lobe
277  eta1 = (SLfloat)random->Random();
278  eta2 = SL_2PI * (SLfloat)random->Random();
279  SLfloat f1 = sqrt(1.0f - pow(eta1, 2.0f / (shininess + 1.0f)));
280 
281  // tranform to cartesian
282  randVec.set(f1 * cos(eta2),
283  f1 * sin(eta2),
284  pow(eta1, 1.0f / (shininess + 1.0f)));
285 
286  // ray needs to be reset if already hit a shape
287  if (reflected->hitShape)
288  {
289  reflected->length = SL_FLOAT_MAX;
290  reflected->hitShape = 0;
291  reflected->hitPoint = SLVec3f::ZERO;
292  reflected->hitNormal = SLVec3f::ZERO;
293  }
294 
295  // apply rotation
296  reflected->setDir(rotMat * randVec);
297 
298  // true if in direction of normal
299  return (hitNormal * reflected->dir >= 0.0f);
300 }

◆ refract() [1/2]

void SLRay::refract ( SLRay refracted)

SLRay::refract calculates a secondary refracted ray, starting at the intersection point. All vectors must be normalized vectors, so the refracted vector T will be a unit vector too. If total internal refraction occurs a reflected ray is calculated instead. Index of refraction eta = Kn_Source/Kn_Destination (Kn_Air = 1.0) We are using a formula by Xavier Bec that is a little faster: http://www.realtimerendering.com/resources/RTNews/html/rtnv10n1.html#art3

SLRay::refract calculates a secondary refracted ray, starting at the intersection point. All vectors must be normalized vectors, so the refracted vector T will be a unit vector too. If total internal refraction occurs a reflected ray is calculated instead. Index of refraction eta = Kn_Source/Kn_Destination (Kn_Air = 1.0)

Definition at line 197 of file SLRay.cpp.

198 {
199  assert(hitMesh && "hitMesh is null");
200 
201  SLVec3f T; // refracted direction
202  SLfloat eta; // refraction coefficient
203 
204  SLfloat c1 = hitNormal.dot(-dir);
205  SLbool hitFrontSide = c1 > 0.0f;
206 
207  SLMaterial* srcMat = srcMesh ? srcMesh->mat() : nullptr;
208  SLMaterial* hitMat = hitMesh ? hitMesh->mat() : nullptr;
209  SLMaterial* hitMatOut = hitMesh ? hitMesh->matOut() : nullptr;
210 
211 #ifdef DEBUG_RAY
212  for (SLint i = 0; i < depth; ++i)
213  cout << " ";
214  cout << "Refract: ";
215 #endif
216 
217  // Calculate index of refraction eta = Kn_Source/Kn_Destination
218  // Case 1: From air into a mesh
219  if (isOutside)
220  {
221  eta = 1.0f / hitMat->kn();
222  }
223  else
224  { // Case 2: From inside the same mesh
225  if (hitMesh == srcMesh)
226  {
227  if (hitMatOut) // Case 2a: into another material
228  eta = hitMat->kn() / hitMatOut->kn();
229  else // Case 2b: into air
230  eta = hitMat->kn(); // = hitMat / 1.0
231  }
232  else
233  { // Case 3: We hit inside another material from the front
234  if (hitFrontSide)
235  {
236  if (hitMatOut)
237  eta = hitMatOut->kn() / hitMat->kn();
238  else
239  { // Mesh hit without outside material before leaving another mesh.
240  // This should not happen, but can due to float inaccuracies
241  eta = srcMat->kn() / hitMat->kn();
242  }
243  }
244  else // Case 4: We hit inside another material from behind
245  {
246  if (hitMatOut) // Case 4a: into another material
247  eta = hitMat->kn() / hitMatOut->kn();
248  else // Case 4b: into air
249  eta = hitMat->kn(); // = hitMat / 1.0
250  }
251  }
252  }
253 
254  // Invert the hit normal if ray hit backside for correct refraction
255  if (!hitFrontSide)
256  {
257  c1 *= -1.0f;
258  hitNormal *= -1.0f;
259  }
260 
261  SLfloat w = eta * c1;
262  SLfloat c2 = 1.0f + (w - eta) * (w + eta);
263 
264  if (c2 >= 0.0f)
265  {
266  T = eta * dir + (w - sqrt(c2)) * hitNormal;
267  refracted->contrib = contrib * hitMat->kt();
268  refracted->type = REFRACTED;
269 
270  if (isOutside)
271  refracted->isOutside = false;
272  else // inside
273  {
274  if (srcMesh == hitMesh)
275  refracted->isOutside = !hitMatOut;
276  else
277  refracted->isOutside = !hitFrontSide;
278  }
279 
280  ++refractedRays;
281  }
282  else // total internal refraction results in a internal reflected ray
283  {
284  T = 2.0f * (-dir * hitNormal) * hitNormal + dir;
285  refracted->contrib = 1.0f;
286  refracted->type = REFLECTED;
287  refracted->isOutside = isOutside; // remain inside
288  ++tirRays;
289  }
290 
291  refracted->setDir(T);
292  refracted->origin.set(hitPoint);
293  refracted->length = FLT_MAX;
294  refracted->srcNode = hitNode;
295  refracted->srcMesh = hitMesh;
296  refracted->srcTriangle = hitTriangle;
297  refracted->depth = depth + 1;
298  refracted->x = x;
299  refracted->y = y;
300  refracted->sv = sv;
301  if (sv->s()->skybox())
302  refracted->backgroundColor = sv->s()->skybox()->colorAtDir(refracted->dir);
303  else
304  refracted->backgroundColor = backgroundColor;
305  depthReached = refracted->depth;
306 
307 #ifdef DEBUG_RAY
308  cout << hitMesh->name();
309  if (isOutside)
310  cout << ",out";
311  else
312  cout << ",in";
313  if (refracted->isOutside)
314  cout << ">out";
315  else
316  cout << ">in";
317  cout << ", dir: " << refracted->dir.toString();
318  cout << ", contrib: " << Utils::toString(refracted->contrib, 2);
319  cout << endl;
320 #endif
321 }
bool SLbool
Definition: SL.h:175
@ REFRACTED
Definition: SLRay.h:25
void kt(SLfloat kt)
Definition: SLMaterial.h:190
void kn(SLfloat kn)
Definition: SLMaterial.h:199
SLMaterial * matOut() const
Definition: SLMesh.h:178
static SLuint tirRays
NO. of TIR refraction rays.
Definition: SLRay.h:131
static SLuint refractedRays
NO. of refracted rays.
Definition: SLRay.h:128
SLstring toString(SLstring delimiter=", ", int decimals=2)
Conversion to string.
Definition: SLVec3.h:199
T dot(const SLVec3 &v) const
Definition: SLVec3.h:117
string toString(float f, int roundedDecimals)
Returns a string from a float with max. one trailing zero.
Definition: Utils.cpp:92

◆ refract() [2/2]

void SLRay::refract ( SLRay refracted)

◆ refractMC() [1/2]

void SLRay::refractMC ( SLRay refracted,
const SLMat3f rotMat 
) const

SLRay::refractMC scatters a ray around perfect transmissive direction according to translucency (for higher translucency the ray is less scattered). This is used for path tracing and distributed ray tracing as well as for photon scattering. The direction is calculated the same as with specular scattering (see reflectMC). The created direction is along z-axis and then transformed to lie along transmissive direction with rotationMatrix rotMat. The rotation matrix must be precalculated (stays the same for each ray sample, needs to be be calculated only once)

Definition at line 384 of file SLRay.cpp.

385 {
386  SLfloat eta1, eta2;
387  SLVec3f randVec;
388  SLfloat translucency = hitMesh->mat()->translucency();
389 
390  // scatter within transmissive lobe
391  eta1 = rnd01();
392  eta2 = Utils::TWOPI * rnd01();
393  SLfloat f1 = sqrt(1.0f - pow(eta1, 2.0f / (translucency + 1.0f)));
394 
395  // transform to cartesian
396  randVec.set(f1 * cos(eta2),
397  f1 * sin(eta2),
398  pow(eta1, 1.0f / (translucency + 1.0f)));
399 
400  // ray needs to be reset if already hit a scene node
401  if (refracted->hitNode)
402  {
403  refracted->length = FLT_MAX;
404  refracted->hitNode = nullptr;
405  refracted->hitMesh = nullptr;
406  refracted->hitPoint = SLVec3f::ZERO;
407  refracted->hitNormal = SLVec3f::ZERO;
408  }
409 
410  // Apply rotation
411  refracted->setDir(rotMat * randVec);
412 
413  // Set pixel and background
414  refracted->x = x;
415  refracted->y = y;
416  refracted->sv = sv;
417  if (sv->s()->skybox())
418  refracted->backgroundColor = sv->s()->skybox()->colorAtDir(refracted->dir);
419  else
420  refracted->backgroundColor = backgroundColor;
421 }
void translucency(SLfloat transl)
Definition: SLMaterial.h:176

◆ refractMC() [2/2]

void SLRay::refractMC ( SLRay refracted,
SLMat3f  rotMat 
)

SLRay::refractMC scatters a ray around perfect transmissive direction according to translucency (for higher translucency the ray is less scattered). This is used for path tracing and distributed ray tracing as well as for photon scattering. The direction is calculated the same as with specular scattering (see reflectMC). The created direction is along z-axis and then transformed to lie along transmissive direction with rotationMatrix rotMat. The rotation matrix must be precalculated (stays the same for each ray sample, needs to be be calculated only once)

Definition at line 312 of file SLRayMC.cpp.

313 {
314  SLfloat eta1, eta2;
315  SLVec3f randVec;
316  SLfloat translucency = hitMat->translucency();
317 
318  // scatter within transmissive lobe
319  eta1 = (SLfloat)random->Random();
320  eta2 = SL_2PI * (SLfloat)random->Random();
321  SLfloat f1 = sqrt(1.0f - pow(eta1, 2.0f / (translucency + 1.0f)));
322 
323  // transform to cartesian
324  randVec.set(f1 * cos(eta2),
325  f1 * sin(eta2),
326  pow(eta1, 1.0f / (translucency + 1.0f)));
327 
328  // ray needs to be reset if already hit a shape
329  if (refracted->hitShape)
330  {
331  refracted->length = SL_FLOAT_MAX;
332  refracted->hitShape = 0;
333  refracted->hitPoint = SLVec3f::ZERO;
334  refracted->hitNormal = SLVec3f::ZERO;
335  }
336 
337  refracted->setDir(rotMat * randVec);
338 }

◆ setDir() [1/2]

void SLRay::setDir ( const SLVec3f Dir)
inline

Setter for the rays direction in world space also setting the inverse direction.

Definition at line 146 of file SLRay.h.

147 {
148  dir = Dir;
149  invDir.x = (SLfloat)(1 / dir.x);
150  invDir.y = (SLfloat)(1 / dir.y);
151  invDir.z = (SLfloat)(1 / dir.z);
152  sign[0] = (invDir.x < 0);
153  sign[1] = (invDir.y < 0);
154  sign[2] = (invDir.z < 0);
155 }
SLint sign[3]
Sign of invDir for fast AABB hit in WS.
Definition: SLRay.h:118
SLVec3f invDir
Inverse ray dir for fast AABB hit in WS.
Definition: SLRay.h:116

◆ setDir() [2/2]

void SLRay::setDir ( SLVec3f  Dir)
inline

Definition at line 70 of file SLRayMC.h.

71  {
72  dir = Dir;
73  invDir.x = (SLfloat)(1 / dir.x);
74  invDir.y = (SLfloat)(1 / dir.y);
75  invDir.z = (SLfloat)(1 / dir.z);
76  sign[0] = (invDir.x < 0);
77  sign[1] = (invDir.y < 0);
78  sign[2] = (invDir.z < 0);
79  }

◆ setDirOS() [1/2]

void SLRay::setDirOS ( const SLVec3f Dir)
inline

Setter for the rays direction in object space also setting the inverse direction.

Definition at line 159 of file SLRay.h.

160 {
161  dirOS = Dir;
162  invDirOS.x = (SLfloat)(1 / dirOS.x);
163  invDirOS.y = (SLfloat)(1 / dirOS.y);
164  invDirOS.z = (SLfloat)(1 / dirOS.z);
165  signOS[0] = (invDirOS.x < 0);
166  signOS[1] = (invDirOS.y < 0);
167  signOS[2] = (invDirOS.z < 0);
168 }
SLVec3f invDirOS
Inverse ray dir for fast AABB hit in OS.
Definition: SLRay.h:117
SLVec3f dirOS
Direction vector of ray in OS.
Definition: SLRay.h:81
SLint signOS[3]
Sign of invDir for fast AABB hit in OS.
Definition: SLRay.h:119

◆ setDirOS() [2/2]

void SLRay::setDirOS ( SLVec3f  Dir)
inline

Definition at line 80 of file SLRayMC.h.

81  {
82  dirOS = Dir;
83  invDirOS.x = (SLfloat)(1 / dirOS.x);
84  invDirOS.y = (SLfloat)(1 / dirOS.y);
85  invDirOS.z = (SLfloat)(1 / dirOS.z);
86  signOS[0] = (invDirOS.x < 0);
87  signOS[1] = (invDirOS.y < 0);
88  signOS[2] = (invDirOS.z < 0);
89  }

◆ totalNumRays()

static SLuint SLRay::totalNumRays ( )
inlinestatic

Total NO. of rays shot during RT.

Definition at line 84 of file SLRay.h.

84  { return SLRay::primaryRays +
static SLuint primaryRays
NO. of primary rays shot.
Definition: SLRay.h:126
static SLuint subsampledRays
NO. of of subsampled rays.
Definition: SLRay.h:137

Member Data Documentation

◆ avgDepth

static SLfloat SLRay::avgDepth = 0
static

average depth reached

Definition at line 136 of file SLRay.h.

◆ backgroundColor

SLCol4f SLRay::backgroundColor

Background color at pixel x,y.

Definition at line 100 of file SLRay.h.

◆ contrib

SLfloat SLRay::contrib

Current contribution of ray to color.

Current contibution of ray to color.

Definition at line 79 of file SLRay.h.

◆ depth

SLint SLRay::depth

Recursion depth for ray tracing.

Definition at line 78 of file SLRay.h.

◆ depthReached

static SLint SLRay::depthReached = 1
static

depth reached for a primary ray

Definition at line 134 of file SLRay.h.

◆ diffusePhotons

SLlong SLRay::diffusePhotons = 0
static

NO. of diffusely scattered photons on surfaces.

Definition at line 148 of file SLRayMC.h.

◆ dir

SLVec3f SLRay::dir

Direction vector of ray in WS.

Definition at line 76 of file SLRay.h.

◆ dirOS

SLVec3f SLRay::dirOS

Direction vector of ray in OS.

Definition at line 81 of file SLRay.h.

◆ emittedPhotons

SLlong SLRay::emittedPhotons = 0
static

NO. of emitted photons from all lightsources.

Definition at line 147 of file SLRayMC.h.

◆ hitAO

SLfloat SLRay::hitAO

Ambient occlusion factor at intersection point.

Definition at line 113 of file SLRay.h.

◆ hitMat

SLMaterial* SLRay::hitMat

Points to material of intersected node.

Definition at line 116 of file SLRayMC.h.

◆ hitMesh

SLMesh* SLRay::hitMesh

Points to the intersected mesh.

Definition at line 106 of file SLRay.h.

◆ hitNode

SLNode* SLRay::hitNode

Points to the intersected node.

Definition at line 105 of file SLRay.h.

◆ hitNormal

SLVec3f SLRay::hitNormal

Surface normal at intersection point.

Definition at line 111 of file SLRay.h.

◆ hitPoint

SLVec3f SLRay::hitPoint

Point of intersection.

Definition at line 110 of file SLRay.h.

◆ hitShape

SLShape* SLRay::hitShape

Points to the intersected shape.

Definition at line 114 of file SLRayMC.h.

◆ hitTexCol

SLCol4f SLRay::hitTexCol

Texture color at intersection point.

Definition at line 121 of file SLRayMC.h.

◆ hitTexColor

SLCol4f SLRay::hitTexColor

Color at intersection for texture or color attributes.

Definition at line 112 of file SLRay.h.

◆ hitTriangle [1/2]

SLint SLRay::hitTriangle

Points to the intersected triangle.

Definition at line 107 of file SLRay.h.

◆ hitTriangle [2/2]

SLFace* SLRay::hitTriangle

Points to the intersected triangle.

Definition at line 115 of file SLRayMC.h.

◆ hitU

SLfloat SLRay::hitU

Definition at line 104 of file SLRay.h.

◆ hitV

SLfloat SLRay::hitV

barycentric coords in hit triangle

Definition at line 104 of file SLRay.h.

◆ ignoredRays

SLuint SLRay::ignoredRays = 0
static

NO. of ignore refraction rays.

Definition at line 129 of file SLRay.h.

◆ ignoreLights

SLbool SLRay::ignoreLights = true
static

flag for gloss sampling

Definition at line 152 of file SLRayMC.h.

◆ intersections

static SLuint SLRay::intersections = 0
static

NO. of intersection.

Definition at line 133 of file SLRay.h.

◆ invDir

SLVec3f SLRay::invDir

Inverse ray dir for fast AABB hit in WS.

Definition at line 116 of file SLRay.h.

◆ invDirOS

SLVec3f SLRay::invDirOS

Inverse ray dir for fast AABB hit in OS.

Definition at line 117 of file SLRay.h.

◆ isInsideVolume

SLbool SLRay::isInsideVolume

Flag if ray is in Volume.

Definition at line 96 of file SLRay.h.

◆ isOutside

SLbool SLRay::isOutside

Flag if ray is inside of a material.

Definition at line 95 of file SLRay.h.

◆ length

SLfloat SLRay::length

length from origin to an intersection

Definition at line 77 of file SLRay.h.

◆ lightDist

SLfloat SLRay::lightDist

Distance to light for shadow rays.

Definition at line 93 of file SLRay.h.

◆ maxDepth

static SLint SLRay::maxDepth = 0
static

Max. recursion depth.

Definition at line 124 of file SLRay.h.

◆ maxDepthReached

static SLint SLRay::maxDepthReached = 0
static

max. depth reached for all rays

Definition at line 135 of file SLRay.h.

◆ minContrib

static SLfloat SLRay::minContrib = 1.0 / 256.0
static

Min. contibution to color (1/256)

Definition at line 125 of file SLRay.h.

◆ origin

SLVec3f SLRay::origin

Vector to the origin of ray in WS.

Definition at line 75 of file SLRay.h.

◆ originMat

SLMaterial* SLRay::originMat

Points to appearance at ray origin.

Definition at line 110 of file SLRayMC.h.

◆ originOS

SLVec3f SLRay::originOS

Vector to the origin of ray in OS.

Definition at line 80 of file SLRay.h.

◆ originShape

SLShape* SLRay::originShape

Points to the shape at ray origin.

Definition at line 108 of file SLRayMC.h.

◆ originTria

SLFace* SLRay::originTria

Points to the triangle at ray origin.

Definition at line 109 of file SLRayMC.h.

◆ primaryRays

SLuint SLRay::primaryRays = 0
static

NO. of primary rays shot.

Definition at line 126 of file SLRay.h.

◆ random

TRanrotBGenerator * SLRay::random = new TRanrotBGenerator((unsigned)time(NULL))
static

Random generator.

Definition at line 153 of file SLRayMC.h.

◆ reflectedPhotons

SLlong SLRay::reflectedPhotons = 0
static

NO. of reflected photons;.

Definition at line 149 of file SLRayMC.h.

◆ reflectedRays

static SLuint SLRay::reflectedRays = 0
static

NO. of reflected rays.

Definition at line 127 of file SLRay.h.

◆ refractedPhotons

SLlong SLRay::refractedPhotons = 0
static

NO. of refracted photons;.

Definition at line 150 of file SLRayMC.h.

◆ refractedRays

static SLuint SLRay::refractedRays = 0
static

NO. of refracted rays.

NO. of transmitted rays.

Definition at line 128 of file SLRay.h.

◆ shadowRays

static SLuint SLRay::shadowRays = 0
static

NO. of shadow rays.

Definition at line 130 of file SLRay.h.

◆ sign

SLint SLRay::sign

Sign of invDir for fast AABB hit in WS.

Definition at line 118 of file SLRay.h.

◆ signOS

SLint SLRay::signOS

Sign of invDir for fast AABB hit in OS.

Definition at line 119 of file SLRay.h.

◆ srcMesh

SLMesh* SLRay::srcMesh

Points to the mesh at ray origin.

Definition at line 98 of file SLRay.h.

◆ srcNode

SLNode* SLRay::srcNode

Points to the node at ray origin.

Definition at line 97 of file SLRay.h.

◆ srcTriangle

SLint SLRay::srcTriangle

Points to the triangle at ray origin.

Definition at line 99 of file SLRay.h.

◆ subsampledPixels

static SLuint SLRay::subsampledPixels = 0
static

NO. of of subsampled pixels.

Definition at line 138 of file SLRay.h.

◆ subsampledRays

static SLuint SLRay::subsampledRays = 0
static

NO. of of subsampled rays.

Definition at line 137 of file SLRay.h.

◆ sv

SLSceneView* SLRay::sv

Pointer to the sceneview.

Definition at line 101 of file SLRay.h.

◆ tests

static SLuint SLRay::tests = 0
static

NO. of intersection tests.

Definition at line 132 of file SLRay.h.

◆ tirPhotons

SLlong SLRay::tirPhotons = 0
static

NO. of total internal refraction photons.

Definition at line 151 of file SLRayMC.h.

◆ tirRays

static SLuint SLRay::tirRays = 0
static

NO. of TIR refraction rays.

Definition at line 131 of file SLRay.h.

◆ tmax

SLfloat SLRay::tmax

max. dist. of last AABB intersection

Definition at line 121 of file SLRay.h.

◆ tmin

SLfloat SLRay::tmin

min. dist. of last AABB intersection

Definition at line 120 of file SLRay.h.

◆ type

SLRayType SLRay::type

PRIMARY, REFLECTED, REFRACTED, SHADOW.

PRIMARY, REFLECTED, TRANSMITTED, SHADOW.

Definition at line 92 of file SLRay.h.

◆ x

SLfloat SLRay::x

Definition at line 94 of file SLRay.h.

◆ y

SLfloat SLRay::y

Pixel position for primary rays.

Definition at line 94 of file SLRay.h.


The documentation for this class was generated from the following files: