MobileRT  1.0
A multi platform C++ CPU progressive Ray Tracer.
MobileRT::Shader Class Referenceabstract

#include <Shader.hpp>

Inheritance diagram for MobileRT::Shader:
Inheritance graph
Collaboration diagram for MobileRT::Shader:
Collaboration graph

Public Types

enum  Accelerator { ACC_NAIVE = 1, ACC_REGULAR_GRID, ACC_BVH }
 

Public Member Functions

void initializeAccelerators (Scene scene)
 
 Shader ()=delete
 
 Shader (Scene scene, ::std::int32_t samplesLight, Accelerator accelerator)
 
 Shader (const Shader &shader)=delete
 
 Shader (Shader &&shader) noexcept=default
 
virtual ~Shader ()=default
 
Shaderoperator= (const Shader &shader)=delete
 
Shaderoperator= (Shader &&shader) noexcept=delete
 
bool rayTrace (::glm::vec3 *rgb, Ray &&ray)
 
bool shadowTrace (float distance, Ray &&ray)
 
virtual void resetSampling ()
 
const ::std::vector< Plane > & getPlanes () const
 
const ::std::vector< Sphere > & getSpheres () const
 
const ::std::vector< Triangle > & getTriangles () const
 
const ::std::vector< Material > & getMaterials () const
 
const ::std::vector<::std::unique_ptr< Light > > & getLights () const
 

Protected Member Functions

virtual bool shade (::glm::vec3 *rgb, const Intersection &intersection)=0
 
::std::uint32_t getLightIndex ()
 

Static Protected Member Functions

::glm::vec3 getCosineSampleHemisphere (const ::glm::vec3 &normal)
 

Protected Attributes

const ::std::int32_t samplesLight_ {}
 
::std::vector<::std::unique_ptr< Light > > lights_ {}
 

Private Member Functions

Intersection traceLights (Intersection intersection) const
 

Private Attributes

Naive< PlanenaivePlanes_ {}
 
Naive< SpherenaiveSpheres_ {}
 
Naive< TrianglenaiveTriangles_ {}
 
RegularGrid< PlanegridPlanes_ {}
 
RegularGrid< SpheregridSpheres_ {}
 
RegularGrid< TrianglegridTriangles_ {}
 
BVH< PlanebvhPlanes_ {}
 
BVH< SpherebvhSpheres_ {}
 
BVH< TrianglebvhTriangles_ {}
 
::std::vector< Materialmaterials_ {}
 
const Accelerator accelerator_ {}
 

Detailed Description

A class which contains the scene geometry into an acceleration structure and takes care of casting rays into the scene.

Member Enumeration Documentation

◆ Accelerator

Enumerator
ACC_NAIVE 
ACC_REGULAR_GRID 
ACC_BVH 

Constructor & Destructor Documentation

◆ Shader() [1/4]

MobileRT::Shader::Shader ( )
explicitdelete

◆ Shader() [2/4]

MobileRT::Shader::Shader ( Scene  scene,
::std::int32_t  samplesLight,
Accelerator  accelerator 
)
explicit

◆ Shader() [3/4]

MobileRT::Shader::Shader ( const Shader shader)
delete

◆ Shader() [4/4]

MobileRT::Shader::Shader ( Shader &&  shader)
defaultnoexcept

◆ ~Shader()

virtual MobileRT::Shader::~Shader ( )
virtualdefault

Member Function Documentation

◆ getCosineSampleHemisphere()

glm::vec3 Shader::getCosineSampleHemisphere ( const ::glm::vec3 &  normal)
staticprotected

Helper method which generates a random 3D direction in a hemisphere in world coordinates.

Parameters
normalThe normal of the hemisphere.
Returns
A random direction in a hemisphere.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getLightIndex()

std::uint32_t Shader::getLightIndex ( )
protected

Calculates the index of a random chosen light in the scene.

Returns
The index of a random chosen light.
Here is the caller graph for this function:

◆ getLights()

const ::std::vector<::std::unique_ptr< Light > > & Shader::getLights ( ) const

Gets the lights in the scene.

Returns
The lights in the scene.

◆ getMaterials()

const ::std::vector< Material > & Shader::getMaterials ( ) const

Gets the materials in the scene.

Returns
The materials in the scene.

◆ getPlanes()

const ::std::vector< Plane > & Shader::getPlanes ( ) const

Gets the planes in the scene.

Returns
The planes in the scene.

◆ getSpheres()

const ::std::vector< Sphere > & Shader::getSpheres ( ) const

Gets the spheres in the scene.

Returns
The spheres in the scene.

◆ getTriangles()

const ::std::vector< Triangle > & Shader::getTriangles ( ) const

Gets the triangles in the scene.

Returns
The triangles in the scene.

◆ initializeAccelerators()

void Shader::initializeAccelerators ( Scene  scene)

Puts all the primitives of the scene into an acceleration structure.

Parameters
sceneThe scene geometry.
Here is the call graph for this function:

◆ operator=() [1/2]

Shader& MobileRT::Shader::operator= ( const Shader shader)
delete

◆ operator=() [2/2]

Shader& MobileRT::Shader::operator= ( Shader &&  shader)
deletenoexcept

◆ rayTrace()

bool Shader::rayTrace ( ::glm::vec3 *  rgb,
Ray &&  ray 
)

Determines if a casted ray intersects a light source in the scene or not.

Parameters
rgbA pointer where the color value of the pixel should be put.
rayThe casted ray into the scene.
Returns
Whether the casted ray intersects a light source in the scene or not.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ resetSampling()

void Shader::resetSampling ( )
virtual

Resets the sampling process of all the lights in the scene.

Reimplemented in Components::PathTracer.

◆ shade()

virtual bool MobileRT::Shader::shade ( ::glm::vec3 *  rgb,
const Intersection intersection 
)
protectedpure virtual

Calculates the color of an intersection in the scene.
This method should be implemented with the desired algorithm, like Path Tracing, Whitted, etc.

Parameters
rgbA pointer to store the color of the intersection.
intersectionThe intersection data, like point, normal, material, etc.
Returns
Whether the ray intersected a light or not.

◆ shadowTrace()

bool Shader::shadowTrace ( float  distance,
Ray &&  ray 
)

Determines if a casted ray intersects a primitive in the scene between the origin of the ray and a light source.

Parameters
distanceThe distance from the origin of the ray to the light source.
rayThe casted ray.
Returns
Whether the casted ray intersects a primitive in the scene or not.
Here is the caller graph for this function:

◆ traceLights()

Intersection Shader::traceLights ( Intersection  intersection) const
private

Helper method which calculates the nearest intersection point of a casted ray and the light sources.

Parameters
intersectionThe current intersection of the ray with previous primitives.
Returns
The intersection of the casted ray and the light sources.

Member Data Documentation

◆ accelerator_

const Accelerator MobileRT::Shader::accelerator_ {}
private

◆ bvhPlanes_

BVH<Plane> MobileRT::Shader::bvhPlanes_ {}
private

◆ bvhSpheres_

BVH<Sphere> MobileRT::Shader::bvhSpheres_ {}
private

◆ bvhTriangles_

BVH<Triangle> MobileRT::Shader::bvhTriangles_ {}
private

◆ gridPlanes_

RegularGrid<Plane> MobileRT::Shader::gridPlanes_ {}
private

◆ gridSpheres_

RegularGrid<Sphere> MobileRT::Shader::gridSpheres_ {}
private

◆ gridTriangles_

RegularGrid<Triangle> MobileRT::Shader::gridTriangles_ {}
private

◆ lights_

::std::vector<::std::unique_ptr<Light> > MobileRT::Shader::lights_ {}
protected

◆ materials_

::std::vector<Material> MobileRT::Shader::materials_ {}
private

◆ naivePlanes_

Naive<Plane> MobileRT::Shader::naivePlanes_ {}
private

◆ naiveSpheres_

Naive<Sphere> MobileRT::Shader::naiveSpheres_ {}
private

◆ naiveTriangles_

Naive<Triangle> MobileRT::Shader::naiveTriangles_ {}
private

◆ samplesLight_

const ::std::int32_t MobileRT::Shader::samplesLight_ {}
protected

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