SLProject 4.0.000
|
Ray class with ray and intersection properties. More...
#include <SLRayMC.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
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
ctor for shadow rays
SLRay::SLRay constructor for shadow rays
SLRay::SLRay | ( | ) |
default ctor
SLRay::SLRay default constructor
ctor for primary rays
SLRay::SLRay constructor for primary rays
ctor for shadow rays
SLRay::SLRay constructor for shadow rays
SLRay::SLRay | ( | SLVec3f | origin, |
SLVec3f | dir, | ||
SLRayType | type, | ||
SLShape * | originShape, | ||
SLfloat | length = SL_FLOAT_MAX , |
||
SLint | depth = 1 |
||
) |
ctor for all parameters
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
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
|
inline |
Returns true if the hit material diffuse color is not black.
|
inline |
Returns true if the hit material specular color is not black.
|
inline |
Returns true if the hit material transmission color is not black.
|
inline |
|
inline |
Returns true if a shadow ray hits an object on the ray to the light.
|
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.
void SLRay::normalizeNormal | ( | ) |
void SLRay::print | ( | ) |
SLRay::prints prints the rays origin (O), direction (D) and the length to the intersection (L)
void SLRay::print | ( | ) | const |
SLRay::prints prints the rays origin (O), direction (D) and the length to the intersection (L)
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
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
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)
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)
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)
void SLRay::refract | ( | SLRay * | refracted | ) |
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)
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)
|
inline |
Setter for the rays direction in world space also setting the inverse direction.
|
inline |
|
inline |
Setter for the rays direction in object space also setting the inverse direction.
|
inline |
|
inlinestatic |
Total NO. of rays shot during RT.
|
static |
average depth reached
SLCol4f SLRay::backgroundColor |
Background color at pixel x,y.
SLfloat SLRay::contrib |
Current contribution of ray to color.
Current contibution of ray to color.
SLint SLRay::depth |
Recursion depth for ray tracing.
|
static |
depth reached for a primary ray
|
static |
NO. of diffusely scattered photons on surfaces.
SLVec3f SLRay::dir |
Direction vector of ray in WS.
SLVec3f SLRay::dirOS |
Direction vector of ray in OS.
|
static |
NO. of emitted photons from all lightsources.
SLfloat SLRay::hitAO |
Ambient occlusion factor at intersection point.
SLMaterial* SLRay::hitMat |
Points to material of intersected node.
SLMesh* SLRay::hitMesh |
Points to the intersected mesh.
SLNode* SLRay::hitNode |
Points to the intersected node.
SLVec3f SLRay::hitNormal |
Surface normal at intersection point.
SLVec3f SLRay::hitPoint |
Point of intersection.
SLShape* SLRay::hitShape |
Points to the intersected shape.
SLCol4f SLRay::hitTexCol |
Texture color at intersection point.
SLCol4f SLRay::hitTexColor |
Color at intersection for texture or color attributes.
SLint SLRay::hitTriangle |
Points to the intersected triangle.
SLFace* SLRay::hitTriangle |
Points to the intersected triangle.
SLfloat SLRay::hitU |
SLfloat SLRay::hitV |
barycentric coords in hit triangle
|
static |
NO. of ignore refraction rays.
|
static |
flag for gloss sampling
|
static |
NO. of intersection.
SLVec3f SLRay::invDir |
Inverse ray dir for fast AABB hit in WS.
SLVec3f SLRay::invDirOS |
Inverse ray dir for fast AABB hit in OS.
SLbool SLRay::isInsideVolume |
Flag if ray is in Volume.
SLbool SLRay::isOutside |
Flag if ray is inside of a material.
SLfloat SLRay::length |
length from origin to an intersection
SLfloat SLRay::lightDist |
Distance to light for shadow rays.
|
static |
Max. recursion depth.
|
static |
max. depth reached for all rays
|
static |
Min. contibution to color (1/256)
SLVec3f SLRay::origin |
Vector to the origin of ray in WS.
SLMaterial* SLRay::originMat |
Points to appearance at ray origin.
SLVec3f SLRay::originOS |
Vector to the origin of ray in OS.
SLShape* SLRay::originShape |
Points to the shape at ray origin.
SLFace* SLRay::originTria |
Points to the triangle at ray origin.
|
static |
NO. of primary rays shot.
|
static |
Random generator.
|
static |
NO. of reflected photons;.
|
static |
NO. of reflected rays.
|
static |
NO. of refracted photons;.
|
static |
NO. of refracted rays.
NO. of transmitted rays.
|
static |
NO. of shadow rays.
SLint SLRay::sign |
Sign of invDir for fast AABB hit in WS.
SLint SLRay::signOS |
Sign of invDir for fast AABB hit in OS.
SLMesh* SLRay::srcMesh |
Points to the mesh at ray origin.
SLNode* SLRay::srcNode |
Points to the node at ray origin.
SLint SLRay::srcTriangle |
Points to the triangle at ray origin.
|
static |
NO. of of subsampled pixels.
|
static |
NO. of of subsampled rays.
SLSceneView* SLRay::sv |
Pointer to the sceneview.
|
static |
NO. of intersection tests.
|
static |
NO. of total internal refraction photons.
|
static |
NO. of TIR refraction rays.
SLfloat SLRay::tmax |
max. dist. of last AABB intersection
SLfloat SLRay::tmin |
min. dist. of last AABB intersection
SLRayType SLRay::type |
PRIMARY, REFLECTED, REFRACTED, SHADOW.
PRIMARY, REFLECTED, TRANSMITTED, SHADOW.
SLfloat SLRay::x |
SLfloat SLRay::y |
Pixel position for primary rays.