36 auto random01 = bind(std::uniform_real_distribution<SLfloat>(0.0, 1.0),
37 std::mt19937((
SLuint)time(
nullptr)));
108 SLRay* rayFromHitPoint)
126 x = rayFromHitPoint->
x;
127 y = rayFromHitPoint->
y;
129 sv = rayFromHitPoint->
sv;
141 SL_LOG(
"Ray: O(%.2f, %.2f, %.2f), D(%.2f, %.2f, %.2f), L: %.2f",
169 reflected->
length = FLT_MAX;
199 assert(
hitMesh &&
"hitMesh is null");
205 SLbool hitFrontSide = c1 > 0.0f;
262 SLfloat c2 = 1.0f + (w - eta) * (w + eta);
293 refracted->
length = FLT_MAX;
341 SLfloat f1 = sqrt(1.0f - pow(eta1, 2.0f / (shininess + 1.0f)));
344 randVec.
set(f1 * cos(eta2),
346 pow(eta1, 1.0f / (shininess + 1.0f)));
351 reflected->
length = FLT_MAX;
359 reflected->
setDir(rotMat * randVec);
393 SLfloat f1 = sqrt(1.0f - pow(eta1, 2.0f / (translucency + 1.0f)));
396 randVec.
set(f1 * cos(eta2),
398 pow(eta1, 1.0f / (translucency + 1.0f)));
403 refracted->
length = FLT_MAX;
411 refracted->
setDir(rotMat * randVec);
453 eta1sqrt = sqrt(1 - eta1);
456 randVec.
set(eta1sqrt * cos(eta2),
457 eta1sqrt * sin(eta2),
461 scattered->
setDir(rotMat * randVec);
SLVec3< SLfloat > SLVec3f
void rotation(const T angleDEG, const SLVec3< T > &axis)
Sets the rotation components
Defines a standard CG material with textures and a shader program.
void translucency(SLfloat transl)
void shininess(SLfloat shin)
SLMaterial * matOut() const
void name(const SLstring &Name)
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.
static SLuint primaryRays
NO. of primary rays shot.
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.
SLint srcTriangle
Points to the triangle at ray origin.
SLCol4f backgroundColor
Background color at pixel x,y.
static SLuint tests
NO. of intersection tests.
SLMesh * hitMesh
Points to the intersected mesh.
SLbool isOutside
Flag if ray is inside of a material.
static SLuint reflectedRays
NO. of reflected rays.
SLint depth
Recursion depth for ray tracing.
SLfloat hitAO
Ambient occlusion factor at intersection point.
SLMaterial * hitMat
Points to material of intersected node.
SLVec3f dir
Direction vector of ray in WS.
SLMesh * srcMesh
Points to the mesh at ray origin.
void refract(SLRay *refracted)
static SLint maxDepthReached
max. depth reached for all rays
static SLuint refractedRays
NO. of refracted rays.
SLfloat length
length from origin to an intersection
SLNode * hitNode
Points to the intersected node.
static SLuint ignoredRays
NO. of ignore refraction rays.
SLfloat contrib
Current contribution of ray to color.
static SLuint subsampledPixels
NO. of of subsampled pixels.
SLbool isInsideVolume
Flag if ray is in Volume.
SLVec3f hitPoint
Point of intersection.
void diffuseMC(SLRay *scattered) const
SLNode * srcNode
Points to the node at ray origin.
void setDir(const SLVec3f &Dir)
Setter for the rays direction in world space also setting the inverse direction.
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.
SLCol4f hitTexColor
Color at intersection for texture or color attributes.
SLfloat y
Pixel position for primary rays.
void refractMC(SLRay *refracted, const SLMat3f &rotMat) const
static SLuint shadowRays
NO. of shadow rays.
SLVec3f hitNormal
Surface normal at intersection point.
SLSceneView * sv
Pointer to the sceneview.
static SLint maxDepth
Max. recursion depth.
void skybox(SLSkybox *skybox)
SceneView class represents a dynamic real time 3D view onto the scene.
SLstring toString(SLstring delimiter=", ", int decimals=2)
Conversion to string.
void set(const T X, const T Y, const T Z)
T dot(const SLVec3 &v) const
static const float ONEOVERPI
string toString(float f, int roundedDecimals)
Returns a string from a float with max. one trailing zero.