38 TRanrotBGenerator*
SLRay::random =
new TRanrotBGenerator((
unsigned)time(NULL));
94 SLRay* rayFromHitPoint)
110 x = rayFromHitPoint->
x;
111 y = rayFromHitPoint->
y;
120 SLShape* originShape,
150 SL_LOG(
"Ray: O(%.2f, %.2f, %.2f), D(%.2f, %.2f, %.2f), L: %.2f\n",
167 if (nLenSqr > 1.0f + SL_EPSILON || nLenSqr < 1.0f - SL_EPSILON)
186 reflected->
length = SL_FLOAT_MAX;
230 SLfloat c2 = 1.0f + (w - eta) * (w + eta);
252 refracted->
length = SL_FLOAT_MAX;
279 SLfloat f1 = sqrt(1.0f - pow(eta1, 2.0f / (shininess + 1.0f)));
282 randVec.
set(f1 * cos(eta2),
284 pow(eta1, 1.0f / (shininess + 1.0f)));
289 reflected->
length = SL_FLOAT_MAX;
296 reflected->
setDir(rotMat * randVec);
321 SLfloat f1 = sqrt(1.0f - pow(eta1, 2.0f / (translucency + 1.0f)));
324 randVec.
set(f1 * cos(eta2),
326 pow(eta1, 1.0f / (translucency + 1.0f)));
331 refracted->
length = SL_FLOAT_MAX;
337 refracted->
setDir(rotMat * randVec);
365 rotMat.
rotation(rotAngle * 180.0f / Utils::ONEPI, rotAxis);
370 eta1sqrt = sqrt(1 - eta1);
372 randVec.
set(eta1sqrt * cos(eta2),
373 eta1sqrt * sin(eta2),
376 scattered->
setDir(rotMat * randVec);
SLRayType
SLRayType enumeration for specifying ray type in ray tracing.
SLVec3< SLfloat > SLVec3f
void rotation(const T angleDEG, const SLVec3< T > &axis)
Sets the rotation components
void translucency(SLfloat transl)
void shininess(SLfloat shin)
Ray class with ray and intersection properties.
SLint hitTriangle
Points to the intersected triangle.
SLVec3f origin
Vector to the origin of ray in WS.
static SLint depthReached
depth reached for a primary ray
static SLuint intersections
NO. of intersection.
bool reflectMC(SLRay *reflected, const SLMat3f &rotMat) const
SLfloat lightDist
Distance to light for shadow rays.
static SLuint tirRays
NO. of TIR refraction rays.
SLRayType type
PRIMARY, REFLECTED, REFRACTED, SHADOW.
SLCol4f hitTexCol
Texture color at intersection point.
static SLuint tests
NO. of intersection tests.
SLbool isOutside
Flag if ray is inside of a material.
SLFace * originTria
Points to the triangle at ray origin.
static SLuint reflectedRays
NO. of reflected rays.
SLint depth
Recursion depth for ray tracing.
SLMaterial * hitMat
Points to material of intersected node.
SLVec3f dir
Direction vector of ray in WS.
SLShape * originShape
Points to the shape at ray origin.
void refract(SLRay *refracted)
SLShape * hitShape
Points to the intersected shape.
static SLint maxDepthReached
max. depth reached for all rays
static SLuint refractedRays
NO. of refracted rays.
static SLlong emittedPhotons
NO. of emitted photons from all lightsources.
SLfloat length
length from origin to an intersection
SLfloat contrib
Current contribution of ray to color.
static SLuint subsampledPixels
NO. of of subsampled pixels.
SLVec3f hitPoint
Point of intersection.
void diffuseMC(SLRay *scattered) const
static SLlong diffusePhotons
NO. of diffusely scattered photons on surfaces.
void setDir(const SLVec3f &Dir)
Setter for the rays direction in world space also setting the inverse direction.
static SLlong tirPhotons
NO. of total internal refraction photons.
static SLlong refractedPhotons
NO. of refracted photons;.
static SLfloat avgDepth
average depth reached
static SLfloat minContrib
Min. contibution to color (1/256)
void reflect(SLRay *reflected) const
static SLuint subsampledRays
NO. of of subsampled rays.
static SLbool ignoreLights
flag for gloss sampling
SLfloat y
Pixel position for primary rays.
static TRanrotBGenerator * random
Random generator.
SLMaterial * originMat
Points to appearance at ray origin.
void refractMC(SLRay *refracted, const SLMat3f &rotMat) const
static SLuint shadowRays
NO. of shadow rays.
SLVec3f hitNormal
Surface normal at intersection point.
static SLlong reflectedPhotons
NO. of reflected photons;.
static SLint maxDepth
Max. recursion depth.
void set(const T X, const T Y, const T Z)