65     SL_LOG(
"\nCurrent Sample:       ");
 
   66     for (
int currentSample = 1; currentSample <= 
_aaSamples; currentSample++)
 
   68         vector<thread> threads; 
 
   78         for (
auto& thread : threads)
 
  120         for (
SLint x = minX; x < minX + 4; ++x)
 
  133                 color += 
trace(&primaryRay, 
false);
 
  138                 if (currentSample > 1)
 
  141                     oldColor.
set(c4f[0], c4f[1], c4f[2], c4f[3]);
 
  144                     oldColor /= (
SLfloat)currentSample;
 
  145                     oldColor *= (
SLfloat)(currentSample - 1);
 
  148                     color /= (
SLfloat)currentSample;
 
  202     if (root) root->
hitRec(ray);
 
  229             return mat->
emissive() * absorption;
 
  231             return mat->
emissive() * absorption * em;
 
  235     objectColor = objectColor * absorption;
 
  247             finalColor += 
shade(ray, &objectColor) * scaleBy;
 
  255             finalColor += (
trace(&scatter, 
false) & objectColor) * scaleBy;
 
  277                        (
trace(&reflected, 
true) & objectColor)) *
 
  309         nbig            = n > nt ? n : nt;
 
  310         nsmall          = n < nt ? n : nt;
 
  311         SLfloat R0      = ((nbig - nsmall) / (nbig + nsmall));
 
  313         SLbool  into    = (rayDir * hitNormal) < 0;
 
  314         SLfloat c       = 1.0f - (into ? (-rayDir * hitNormal) : (refrDir * hitNormal));
 
  315         SLfloat schlick = R0 + (1 - R0) * c * c * c * c * c;
 
  317         SLfloat P                     = 0.25f + 0.5f * schlick; 
 
  318         SLfloat reflectionProbability = schlick / P;
 
  319         SLfloat refractionProbability = (1.0f - schlick) / (1.0f - P);
 
  333         if (
rnd01() > (0.25f + 0.5f * schlick))
 
  337                            (
trace(&refracted, 
true) & objectColor) *
 
  338                            refractionProbability) *
 
  347             finalColor += ((mat->
shininess() + 2.0f) /
 
  349                            (
trace(&scattered, 
true) & objectColor) *
 
  350                            reflectionProbability) *
 
  366     SLfloat lightDist, LdN, df, spotEffect, lighted;
 
  371         if (light && light->isOn())
 
  380             lighted = (
SLfloat)((LdN > 0) ? light->shadowTestMC(ray,
 
  387             if (lighted > 0.0f && light->spotCutOffDEG() < 180.0f)
 
  389                 SLfloat LdS = std::max(-L.
dot(light->spotDirWS()), 0.0f);
 
  392                 if (LdS > light->spotCosCut())
 
  394                     spotEffect = pow(LdS, (
SLfloat)light->spotExponent());
 
  407                 df = std::max(LdN, 0.0f); 
 
  410                 diffuseColor = (*mat & (light->diffuse() * df) * 
Utils::ONEOVERPI * lighted);
 
  413             color += light->attenuation(lightDist) * spotEffect * diffuseColor;
 
  427              "Pathtraced_%d_%d.png",
 
#define PROFILE_FUNCTION()
 
#define PROFILE_THREAD(name)
 
SLVec3< SLfloat > SLVec3f
 
OpenCV image class with the same interface as the former SLImage class.
 
CVVImage _images
Vector of CVImage pointers.
 
std::mutex _mutex
Mutex to protect parallel access (used in ray tracing)
 
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)
 
static SLfloat PERFECT
PM: shininess/translucency limit.
 
void specular(const SLCol4f &spec)
 
void diffuse(const SLCol4f &diff)
 
void shininess(SLfloat shin)
 
void transmissive(const SLCol4f &transm)
 
void emissive(const SLCol4f &emis)
 
virtual void preShade(SLRay *ray)
 
SLNode represents a node in a hierarchical scene graph.
 
virtual bool hitRec(SLRay *ray)
 
const SLstring & name() const
 
SLbool _calcIndirect
flag to calculate indirect illumination
 
SLCol4f shade(SLRay *ray, SLCol4f *mat)
 
SLbool render(SLSceneView *sv)
 
SLbool _calcDirect
flag to calculate direct illumination
 
void renderSlices(bool isMainThread, SLint currentSample, SLuint threadNum)
 
void saveImage()
Saves the current PT image as PNG image.
 
function< void(bool, int, SLuint)> renderSlicesPTAsync
 
SLCol4f trace(SLRay *ray, SLbool em)
 
Ray class with ray and intersection properties.
 
SLbool hitMatIsTransparent() const
Returns true if the hit material transmission color is not black.
 
bool reflectMC(SLRay *reflected, const SLMat3f &rotMat) const
 
SLCol4f backgroundColor
Background color at pixel x,y.
 
SLMesh * hitMesh
Points to the intersected mesh.
 
SLbool isOutside
Flag if ray is inside of a material.
 
SLint depth
Recursion depth for ray tracing.
 
SLVec3f dir
Direction vector of ray in WS.
 
void refract(SLRay *refracted)
 
SLbool hitMatIsReflective() const
Returns true if the hit material specular color is not black.
 
SLfloat length
length from origin to an intersection
 
SLVec3f hitPoint
Point of intersection.
 
void diffuseMC(SLRay *scattered) const
 
static SLuint totalNumRays()
Total NO. of rays shot during RT.
 
void reflect(SLRay *reflected) const
 
SLCol4f hitTexColor
Color at intersection for texture or color attributes.
 
void refractMC(SLRay *refracted, const SLMat3f &rotMat) const
 
SLVec3f hitNormal
Surface normal at intersection point.
 
SLbool hitMatIsDiffuse() const
Returns true if the hit material diffuse color is not black.
 
SLfloat _oneOverGamma
one over gamma correction value
 
virtual void prepareImage()
 
SLSceneView * _sv
Parent sceneview.
 
SLint _nextLine
next line index to render RT in a thread
 
SLRTState _state
RT state;.
 
SLfloat _renderSec
Rendering time in seconds.
 
SLint _aaSamples
SQRT of uneven num. of AA samples.
 
void renderUIBeforeUpdate()
Must be called before an inbetween frame updateRec.
 
void setPrimaryRay(SLfloat x, SLfloat y, SLRay *primaryRay)
Set the parameters of a primary ray for a pixel position at x, y.
 
virtual void initStats(SLint depth)
 
SLint _progressPC
progress in %
 
AvgFloat _raysPerMS
Averaged rays per ms.
 
void root3D(SLNode *root3D)
 
SceneView class represents a dynamic real time 3D view onto the scene.
 
cbOnWndUpdate onWndUpdate
C-Callback for app for intermediate window repaint.
 
void set(const T X, const T Y, const T Z)
 
T dot(const SLVec3 &v) const
 
void sub(const SLVec3 &a, const SLVec3 &b)
 
void set(const T X, const T Y, const T Z, const T W=1)
 
void gammaCorrect(T oneOverGamma)
Gamma correction.
 
void clampMinMax(const T min, const T max)
 
void set(T value)
Sets the current value in the value array and builds the average.
 
static const float ONEOVERPI
 
unsigned int maxThreads()
Returns in release config the max. NO. of threads otherwise 1.