SLProject
4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
|
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... | |
SLNode * | srcNode |
Points to the node at ray origin. More... | |
SLMesh * | srcMesh |
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... | |
SLSceneView * | sv |
Pointer to the sceneview. More... | |
SLfloat | hitU |
SLfloat | hitV |
barycentric coords in hit triangle More... | |
SLNode * | hitNode |
Points to the intersected node. More... | |
SLMesh * | hitMesh |
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... | |
SLMaterial * | originMat |
Points to appearance at ray origin. More... | |
SLShape * | hitShape |
Points to the intersected shape. More... | |
SLFace * | hitTriangle |
Points to the intersected triangle. More... | |
SLMaterial * | hitMat |
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... | |
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.
|
explicit |
default ctor
SLRay::SLRay default constructor
Definition at line 44 of file SLRay.cpp.
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.
ctor for shadow rays
SLRay::SLRay constructor for shadow rays
Definition at line 106 of file SLRay.cpp.
SLRay::SLRay | ( | ) |
ctor for primary rays
SLRay::SLRay constructor for primary rays
Definition at line 68 of file SLRayMC.cpp.
ctor for shadow rays
SLRay::SLRay constructor for shadow rays
Definition at line 92 of file SLRayMC.cpp.
SLRay::SLRay | ( | SLVec3f | origin, |
SLVec3f | dir, | ||
SLRayType | type, | ||
SLShape * | originShape, | ||
SLfloat | length = SL_FLOAT_MAX , |
||
SLint | depth = 1 |
||
) |
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.
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.
|
inline |
Returns true if the hit material diffuse color is not black.
Definition at line 216 of file SLRay.h.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
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.
void SLRay::normalizeNormal | ( | ) |
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.
void SLRay::print | ( | ) | const |
SLRay::prints prints the rays origin (O), direction (D) and the length to the intersection (L)
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.
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.
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.
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.
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.
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.
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.
|
inlinestatic |
|
static |
SLCol4f SLRay::backgroundColor |
SLfloat SLRay::contrib |
|
static |
|
static |
|
static |
SLfloat SLRay::hitAO |
SLMaterial* SLRay::hitMat |
SLVec3f SLRay::hitNormal |
SLCol4f SLRay::hitTexCol |
SLCol4f SLRay::hitTexColor |
SLint SLRay::hitTriangle |
SLFace* SLRay::hitTriangle |
|
static |
|
static |
|
static |
SLVec3f SLRay::invDir |
SLVec3f SLRay::invDirOS |
|
static |
|
static |
|
static |
SLMaterial* SLRay::originMat |
SLShape* SLRay::originShape |
SLFace* SLRay::originTria |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
SLint SLRay::srcTriangle |
|
static |
|
static |
SLSceneView* SLRay::sv |
|
static |
|
static |
|
static |
SLRayType SLRay::type |