Unidirectional path tracer. Generates renderings of a scene by emitting rays from the user viewpoint and letting them bounce in the scene, forming paths. Lighting and materials contributions are accumulated along each path to compute the color of the associated sample.
More...
#include <PathTracer.hpp>
|
bool | checkVisibility (const glm::vec3 &startPos, const glm::vec3 &rayDir, float maxDist) const |
|
glm::vec3 | evalBackground (const glm::vec3 &rayDir, const glm::vec3 &rayPos, const glm::vec2 &ndcPos, bool directHit) const |
|
|
Raycaster | _raycaster |
| The internal raycaster.
|
|
std::shared_ptr< Scene > | _scene |
| The scene.
|
|
Unidirectional path tracer. Generates renderings of a scene by emitting rays from the user viewpoint and letting them bounce in the scene, forming paths. Lighting and materials contributions are accumulated along each path to compute the color of the associated sample.
◆ PathTracer() [1/2]
PathTracer::PathTracer |
( |
| ) |
|
|
default |
◆ PathTracer() [2/2]
PathTracer::PathTracer |
( |
const std::shared_ptr< Scene > & |
scene | ) |
|
|
explicit |
Constructor. Initializes the internal raycaster with the scene data.
- Parameters
-
scene | the scene to path trace against |
◆ buildLocalFrame()
glm::mat3 PathTracer::buildLocalFrame |
( |
const Object & |
obj, |
|
|
const Raycaster::Hit & |
hit, |
|
|
const glm::vec3 & |
rayDir, |
|
|
const glm::vec2 & |
uv |
|
) |
| |
|
staticprivate |
Build the local frame at an intersection on an object surface.
- Parameters
-
obj | the intersected object |
hit | the intersection record |
rayDir | the direction of the ray that intersected |
uv | the local texture coordinates (if valid) |
- Returns
- the local tangent space frame. \
◆ checkVisibility()
bool PathTracer::checkVisibility |
( |
const glm::vec3 & |
startPos, |
|
|
const glm::vec3 & |
rayDir, |
|
|
float |
maxDist |
|
) |
| const |
|
private |
Check visibility from a point along a ray in the scene, taking into account object opacity masks.
- Parameters
-
startPos | the point to test visibility for |
rayDir | the ray direction to follow |
maxDist | the maximum distance to travel along the ray |
- Returns
- true if the point has clear visibility along the ray
◆ evalBackground()
glm::vec3 PathTracer::evalBackground |
( |
const glm::vec3 & |
rayDir, |
|
|
const glm::vec3 & |
rayPos, |
|
|
const glm::vec2 & |
ndcPos, |
|
|
bool |
directHit |
|
) |
| const |
|
private |
Evalutation the contribution from the scene background.
- Parameters
-
rayDir | the direction of the ray that intersected |
rayPos | the ray world space position |
ndcPos | the current pixel in the final image |
directHit | was it a direct hit or a hit after bounces |
- Returns
- the background contribution
◆ getSampleGrid()
glm::ivec2 PathTracer::getSampleGrid |
( |
size_t |
samples | ) |
|
|
staticprivate |
Compute the dimensions of a grid that contains a given number of samples.
- Parameters
-
samples | the number of samples to place on a regular grid |
- Returns
- the number of samples on each axis
◆ getSamplePosition()
glm::vec2 PathTracer::getSamplePosition |
( |
size_t |
sid, |
|
|
const glm::ivec2 & |
cellCount, |
|
|
const glm::vec2 & |
cellSize |
|
) |
| |
|
staticprivate |
Get the local location of a sample in a pixel.
- Parameters
-
sid | the sample ID for the pixel |
cellCount | the number of samples on each grid axis |
cellSize | the spacing between two samples on an axis |
- Returns
- the local sample location in [0,1]
- Note
- The sample will be randomly jittered.
◆ raycaster()
const Raycaster & PathTracer::raycaster |
( |
| ) |
const |
|
inline |
- Returns
- the internal raycaster.
◆ render()
void PathTracer::render |
( |
const Camera & |
camera, |
|
|
size_t |
samples, |
|
|
size_t |
depth, |
|
|
Image & |
render |
|
) |
| |
Performs a rendering of the scene.
- Parameters
-
camera | the viewpoint to use |
samples | the number of samples per-pixel |
depth | the maximum number of bounces for each path |
render | the image, will be filled with the (gamma-corrected) result |
- Todo:
- Support dieletric specular on top.
- Todo:
- Support all materials from the PBR demo.
The documentation for this class was generated from the following files: