Camera class
#include <darts/camera.h>
A virtual (pinhole) camera.
The camera is responsible for generating primary rays. It is positioned using a Transform and points along the -z axis of the local coordinate system. It has an image plane positioned a z = -dist with size (width, height).
We currently only support pinhole perspective cameras. This class could be made into a virtual base class to support other types of cameras (e.g. an orthographic camera, or omni-directional camera).
The camera setup looks something like this, where the up vector points out of the screen:
top view side view ^ up | ^ | | _,-' width | _,-' | +----|----+ + | _,-' | h \ | / d | e | _,-' | e \ | / i | y +'---------------+-i-----> \ | / s | e '-,_ dist | g \|/ t | '-,_ | h + + '-,_ | t eye '-,_|
Constructors, destructors, conversion operators
Public functions
- auto resolution() const -> Vec2i
- Return the camera's image resolution.
- auto world_to_camera() const -> Transform
- Returns the world-to-camera transformation.
- auto generate_ray(const Vec2f& pixel, const Vec2f& lens = Vec2f(0.5f)) const -> Ray3f
- Generate a ray going through image-plane location
pixel
.
Function documentation
Ray3f Camera:: generate_ray(const Vec2f& pixel,
const Vec2f& lens = Vec2f(0.5f)) const
Generate a ray going through image-plane location pixel
.
Parameters | |
---|---|
pixel | The pixel position within the image. Ranges from (0,0) to (m_resolution.x, m_resolution.y). |
lens | A random sample on for use when sampling the lens/aperture. |
Returns | The Ray filled with the appropriate position and direction. |