MobileRT
1.0
A multi platform C++ CPU progressive Ray Tracer.
|
#include <Shader.hpp>
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 |
Shader & | operator= (const Shader &shader)=delete |
Shader & | operator= (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< Plane > | naivePlanes_ {} |
Naive< Sphere > | naiveSpheres_ {} |
Naive< Triangle > | naiveTriangles_ {} |
RegularGrid< Plane > | gridPlanes_ {} |
RegularGrid< Sphere > | gridSpheres_ {} |
RegularGrid< Triangle > | gridTriangles_ {} |
BVH< Plane > | bvhPlanes_ {} |
BVH< Sphere > | bvhSpheres_ {} |
BVH< Triangle > | bvhTriangles_ {} |
::std::vector< Material > | materials_ {} |
const Accelerator | accelerator_ {} |
A class which contains the scene geometry into an acceleration structure and takes care of casting rays into the scene.
|
explicitdelete |
|
explicit |
|
delete |
|
defaultnoexcept |
|
virtualdefault |
|
staticprotected |
Helper method which generates a random 3D direction in a hemisphere in world coordinates.
normal | The normal of the hemisphere. |
|
protected |
Calculates the index of a random chosen light in the scene.
const ::std::vector<::std::unique_ptr< Light > > & Shader::getLights | ( | ) | const |
Gets the lights in the scene.
const ::std::vector< Material > & Shader::getMaterials | ( | ) | const |
Gets the materials in the scene.
const ::std::vector< Plane > & Shader::getPlanes | ( | ) | const |
Gets the planes in the scene.
const ::std::vector< Sphere > & Shader::getSpheres | ( | ) | const |
Gets the spheres in the scene.
const ::std::vector< Triangle > & Shader::getTriangles | ( | ) | const |
Gets the triangles in the scene.
void Shader::initializeAccelerators | ( | Scene | scene | ) |
Puts all the primitives of the scene into an acceleration structure.
scene | The scene geometry. |
bool Shader::rayTrace | ( | ::glm::vec3 * | rgb, |
Ray && | ray | ||
) |
Determines if a casted ray intersects a light source in the scene or not.
rgb | A pointer where the color value of the pixel should be put. |
ray | The casted ray into the scene. |
|
virtual |
Resets the sampling process of all the lights in the scene.
Reimplemented in Components::PathTracer.
|
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.
rgb | A pointer to store the color of the intersection. |
intersection | The intersection data, like point, normal, material, etc. |
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.
distance | The distance from the origin of the ray to the light source. |
ray | The casted ray. |
|
private |
Helper method which calculates the nearest intersection point of a casted ray and the light sources.
intersection | The current intersection of the ray with previous primitives. |
|
private |
|
private |
|
private |
|
private |
|
protected |
|
private |
|
protected |