Midterm: Team Cyber
 All Classes Files Functions Variables Typedefs Pages
Classes | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
RayTracer Class Reference

#include <RayTracer.h>

Inheritance diagram for RayTracer:

Classes

class  Photon
 The abstraction of a Photon class that stores the origin, direction and power of a photon three methods implemented to use the PointKDTree data structre. More...
 
class  Settings
 
class  Stats
 

Public Member Functions

shared_ptr< Image > render (const Settings &settings, const Array< shared_ptr< Surface > > &surfaceArray, const shared_ptr< LightingEnvironment > &lighting, const shared_ptr< Camera > &camera, Stats &stats)
 Render the specified image. More...
 

Static Public Member Functions

static shared_ptr< RayTracercreate ()
 

Protected Types

typedef PointKDTree< Photon,
Photon, Photon, Photon
PhotonTree
 

Protected Member Functions

shared_ptr< Surfel > castRay (const Ray &ray, float maxDistance=finf(), bool anyHit=false) const
 
void createPhotonMap ()
 Creates a photon map from the settings specified in m_settings. More...
 
Radiance3 L_i (const Point3 P, const Vector3 &wi, int bouncesLeft, Random &rnd) const
 Find the intersection of the incoming ray, from eye to source and thus computes the radiance of the ray Used in backward raytracing. More...
 
Radiance3 L_o (const shared_ptr< Surfel > &surfel, const Vector3 &wo, int bouncesLeft, Random &rnd) const
 Computes the radiance of a surfel to return that to L_i. More...
 
Radiance3 L_scatteredDirect (const shared_ptr< Surfel > &surfel, const Vector3 &wo, Random &rnd) const
 Computes the direct illumination of a surface. More...
 
Radiance3 L_scatteredIndirect (const shared_ptr< Surfel > &surfel, const Vector3 &wo, Random &rnd) const
 Computes the radiance contribtued by indirect illumination, excluding the impulses. More...
 
Radiance3 L_scatteredSpecularIndirect (const shared_ptr< Surfel > &surfel, const Vector3 &wo, int bouncesLeft, Random &rnd) const
 Computes the radiance contributed by specular indirect illumination (impulses) More...
 
 RayTracer ()
 
void traceAllPixels (int numThreads)
 Called from render(). More...
 
void traceOnePixel (int x, int y, int threadID)
 Called from GThread::runConcurrently2D(), which is invoked in traceAllPixels() More...
 
void tracePhotons (Photon p, int bouncesLeft)
 Trace each photons created to store them in the photon map named photons. More...
 
Color3 visiblePercentage (Ray ray, const shared_ptr< Light > &light, float distance) const
 Computes the partial coverage between a certain light source and the surfel When shadowcasting is disabled or the light is non shadow-casting, always return 1 When partial coverage is disabled, return 1 if visible and 0 if not visible. More...
 

Protected Attributes

shared_ptr< Camera > m_camera
 
shared_ptr< Image > m_image
 
shared_ptr< LightingEnvironment > m_lighting
 
Array< shared_ptr< Random > > m_rnd
 Array of random number generators so that each threadID may have its own without using locks. More...
 
Settings m_settings
 
Statsm_stats
 
int m_testInt
 
TriTree m_triTree
 
PhotonTree photons
 

Member Typedef Documentation

typedef PointKDTree<Photon, Photon, Photon, Photon> RayTracer::PhotonTree
protected

Constructor & Destructor Documentation

RayTracer::RayTracer ( )
protected

Member Function Documentation

shared_ptr< Surfel > RayTracer::castRay ( const Ray &  ray,
float  maxDistance = finf(),
bool  anyHit = false 
) const
protected
Parameters
rayThe ray in world space
maxDistanceDon’t trace farther than this
anyHitIf true, return any surface hit, even if it is not the first
Returns
The surfel hit, or NULL if none was hit
shared_ptr< RayTracer > RayTracer::create ( )
static
void RayTracer::createPhotonMap ( )
protected

Creates a photon map from the settings specified in m_settings.

Radiance3 RayTracer::L_i ( const Point3  P,
const Vector3 &  wi,
int  bouncesLeft,
Random &  rnd 
) const
protected

Find the intersection of the incoming ray, from eye to source and thus computes the radiance of the ray Used in backward raytracing.

Parameters
Porigin of ray
widirection of ray
bouncesLeftmaximum number of recursions before we stop
rndpassed random generator to enable multithreading
Radiance3 RayTracer::L_o ( const shared_ptr< Surfel > &  surfel,
const Vector3 &  wo,
int  bouncesLeft,
Random &  rnd 
) const
protected

Computes the radiance of a surfel to return that to L_i.

Considers direct, specular, emitted and indirect illuminations Used in backward raytracing

Parameters
surfelsurfel we want to evaluate
wodirection of outgoing ray(eye to source)
bouncesLeftmaximum number of recursions before we stop
rndpassed random generator to enable multithreading
Radiance3 RayTracer::L_scatteredDirect ( const shared_ptr< Surfel > &  surfel,
const Vector3 &  wo,
Random &  rnd 
) const
protected

Computes the direct illumination of a surface.

Parameters
surfelthe surfel we want to evalutate
wooutgoing ray direction (towards eye)
rndpassed random generator to enable multithreading
Radiance3 RayTracer::L_scatteredIndirect ( const shared_ptr< Surfel > &  surfel,
const Vector3 &  wo,
Random &  rnd 
) const
protected

Computes the radiance contribtued by indirect illumination, excluding the impulses.

Currently only called when photon mapping is enabled, and is also taking care of the direct illumination

Parameters
surfelsurfel we want to evaluate
wooutgoing ray direction (towards eye)
rndpassed random generator to enable multithreading
Radiance3 RayTracer::L_scatteredSpecularIndirect ( const shared_ptr< Surfel > &  surfel,
const Vector3 &  wo,
int  bouncesLeft,
Random &  rnd 
) const
protected

Computes the radiance contributed by specular indirect illumination (impulses)

Parameters
surfelsurfel we want to evaluate
wooutgoing ray direction (towards eye)
bouncesLeftmaximum number of recursions before we stop
rndpassed random generator to enable multithreading
shared_ptr< Image > RayTracer::render ( const Settings settings,
const Array< shared_ptr< Surface > > &  surfaceArray,
const shared_ptr< LightingEnvironment > &  lighting,
const shared_ptr< Camera > &  camera,
Stats stats 
)

Render the specified image.

void RayTracer::traceAllPixels ( int  numThreads)
protected

Called from render().

Writes to m_image.

void RayTracer::traceOnePixel ( int  x,
int  y,
int  threadID 
)
protected

Called from GThread::runConcurrently2D(), which is invoked in traceAllPixels()

void RayTracer::tracePhotons ( Photon  p,
int  bouncesLeft 
)
protected

Trace each photons created to store them in the photon map named photons.

Parameters
pthe photon to trace
bouncesLeftmaximum number of forward bounces left
Color3 RayTracer::visiblePercentage ( Ray  ray,
const shared_ptr< Light > &  light,
float  distance 
) const
protected

Computes the partial coverage between a certain light source and the surfel When shadowcasting is disabled or the light is non shadow-casting, always return 1 When partial coverage is disabled, return 1 if visible and 0 if not visible.

Member Data Documentation

shared_ptr<Camera> RayTracer::m_camera
protected
shared_ptr<Image> RayTracer::m_image
protected
shared_ptr<LightingEnvironment> RayTracer::m_lighting
protected
Array< shared_ptr<Random> > RayTracer::m_rnd
protected

Array of random number generators so that each threadID may have its own without using locks.

Settings RayTracer::m_settings
protected
Stats* RayTracer::m_stats
protected
int RayTracer::m_testInt
protected
TriTree RayTracer::m_triTree
protected
PhotonTree RayTracer::photons
protected

The documentation for this class was generated from the following files: