Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions docs/pages/api_overview.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# API overview {#api_overview}

<!-- Strona do uzupełnienia. Każdy plik *.md w docs/pages trafia do dokumentacji (cmake --build build --target docs). -->

| Header | Contents |
|---|---|
| `tinypbrt/tinypbrt.h` | everything (include this one) |
| `tinypbrt/detail/scene.h` | `tpbrt_scene_t`, `tpbrt_scene_load_from_file`, `tpbrt_scene_load_from_memory`, `tpbrt_scene_free` |
| `tinypbrt/detail/error.h` | `tpbrt_error_t`, `tpbrt_get_error_message` |
| `tinypbrt/detail/material.h` | materials, `tpbrt_get_material_by_name`, `tpbrt_get_material_by_handle` |
| `tinypbrt/detail/texture.h` | textures and texture handles |
| `tinypbrt/detail/transform.h` | the shared matrix pool, `tpbrt_get_transform` |
| Header | Contents |
|-------------------------------|---------------------------------------------------------------------------------------------------|
| `tinypbrt/tinypbrt.h` | everything (include this one) |
| `tinypbrt/detail/scene.h` | `tpbrt_scene_t`, `tpbrt_scene_load_from_file`, `tpbrt_scene_load_from_memory`, `tpbrt_scene_free` |
| `tinypbrt/detail/error.h` | `tpbrt_error_t`, `tpbrt_get_error_message` |
| `tinypbrt/detail/material.h` | materials, `tpbrt_get_material_by_name`, `tpbrt_get_material_by_handle` |
| `tinypbrt/detail/texture.h` | textures and texture handles |
| `tinypbrt/detail/transform.h` | the shared matrix pool, `tpbrt_get_transform` |

## Examples

Expand Down
44 changes: 44 additions & 0 deletions src/include/tinypbrt/detail/accelerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,83 @@
extern "C" {
#endif

/**
* @defgroup accelerator-public Accelerator
* @ingroup tinypbrt-public
*/

/**
* @brief Used to declare accelerator type.
* @ingroup accelerator-public
*/
typedef enum tpbrt_accelerator_type_t {
/// @brief BVH acceleration.
TPBRT_ACCELERATOR_TYPE_BVH = 0,
/// @brief KD Tree acceleration.
TPBRT_ACCELERATOR_TYPE_KD_TREE = 1,
/// @brief Count of available accelerator types.
TPBRT_ACCELERATOR_TYPE_MAX_NUM = 2,
} tpbrt_accelerator_type_t;

/**
* @brief Used to declare BVH split method.
* @ingroup accelerator-public
*/
typedef enum tpbrt_accelerator_bvh_split_method_t {
/// @brief SAH split method. Denotes the surface area heuristic.
TPBRT_ACCELERATOR_BVH_SPLIT_METHOD_SAH = 0,
/// @brief Middle split method. Splits each node at its midpoint along the split axis.
TPBRT_ACCELERATOR_BVH_SPLIT_METHOD_MIDDLE = 1,
/// @brief Equal split method. Splits the current group of primitives into two equal-sized sets.
TPBRT_ACCELERATOR_BVH_SPLIT_METHOD_EQUAL = 2,
/// @brief HLBVH split method. Selects the HLBVH algorithm, which parallelizes well.
TPBRT_ACCELERATOR_BVH_SPLIT_METHOD_HLBVH = 3,
/// @brief Count of available BVH split methods.
TPBRT_ACCELERATOR_BVH_SPLIT_METHOD_MAX_NUM = 4,
} tpbrt_accelerator_bvh_split_method_t;

/**
* @brief BVH accelerator parameters.
* @ingroup accelerator-public
*/
typedef struct tpbrt_accelerator_bvh_params_t {
/// @brief Maximum number of primitives to allow in a node in the tree.
tpbrt_uint_t max_node_prims;
/// @brief Method to use to partition the primitives when building the tree.
tpbrt_accelerator_bvh_split_method_t split_method : 4;
} tpbrt_accelerator_bvh_params_t;

/**
* @brief KD Tree accelerator parameters.
* @ingroup accelerator-public
*/
typedef struct tpbrt_accelerator_kd_tree_params_t {
/// @brief The value of the cost function that estimates the expected cost of performing a ray-object intersection, for use in building the kd-tree.
tpbrt_uint_t intersect_cost;
/// @brief Estimated cost for traversing a ray through a kd-tree node.
tpbrt_uint_t traversal_cost;
/// @brief "Bonus" factor for kd-tree nodes that represent empty space.
tpbrt_float_t empty_bonus;
/// @brief Maximum number of primitives to store in kd-tree node. (Not a hard limit; more may be stored if the kd-tree can't find splitting planes that reduce the number of primitives when refining a node.)
tpbrt_uint_t max_prims;
/// @brief Maximum depth of the kd-tree. If negative, the kd-tree chooses a maximum depth based on the number of primitives to be stored in it.
tpbrt_int_t max_depth;
} tpbrt_accelerator_kd_tree_params_t;

/**
* @brief PBRT Accelerator representation.
* @ingroup accelerator-public
*/
typedef struct tpbrt_accelerator_t {
/// @brief Initialized value dependent on current type.
union {
/// @brief BVH accelerator parameters.
tpbrt_accelerator_bvh_params_t bvh;
/// @brief KD Tree accelerator parameters.
tpbrt_accelerator_kd_tree_params_t kd_tree;
} as;

/// @brief Accelerator type.
tpbrt_accelerator_type_t type : 3;
} tpbrt_accelerator_t;

Expand Down
91 changes: 91 additions & 0 deletions src/include/tinypbrt/detail/camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,84 +12,175 @@
extern "C" {
#endif

/**
* @defgroup camera-public Camera
* @ingroup tinypbrt-public
*/

/**
* @brief Used to declare camera type.
* @ingroup camera-public
*/
typedef enum tpbrt_camera_type_t {
/// @brief Orthographic camera.
TPBRT_CAMERA_TYPE_ORTHOGRAPHIC = 0,
/// @brief Perspective camera.
TPBRT_CAMERA_TYPE_PERSPECTIVE = 1,
/// @brief Realistic camera.
TPBRT_CAMERA_TYPE_REALISTIC = 2,
/// @brief Spherical camera.
TPBRT_CAMERA_TYPE_SPHERICAL = 3,
/// @brief Count of available camera types.
TPBRT_CAMERA_TYPE_MAX_NUM = 4,
} tpbrt_camera_type_t;

/**
* @brief Orthographic camera parameters.
* @ingroup camera-public
*/
typedef struct tpbrt_camera_orthographic_params_t {
/// @brief The aspect ratio of the film.
tpbrt_float_t frame_aspect_ratio;
/// @brief The bounds of the film plane in screen space.
tpbrt_float_t screen_window[4];
/// @brief The radius of the lens.
tpbrt_float_t lens_radius;
/// @brief The focal distance of the lens. If "lensradius" is zero, this has no effect. Otherwise, it specifies the distance from the camera origin to the focal plane.
tpbrt_float_t focal_distance;
} tpbrt_camera_orthographic_params_t;

/**
* @brief Perspective camera parameters.
* @ingroup camera-public
*/
typedef struct tpbrt_camera_perspective_params_t {
/// @brief The aspect ratio of the film.
tpbrt_float_t frame_aspect_ratio;
/// @brief The bounds of the film plane in screen space.
tpbrt_float_t screen_window[4];
/// @brief The radius of the lens.
tpbrt_float_t lens_radius;
/// @brief The focal distance of the lens. If "lensradius" is zero, this has no effect. Otherwise, it specifies the distance from the camera origin to the focal plane.
tpbrt_float_t focal_distance;
/// @brief Specifies the field of view for the perspective camera. This is the spread angle of the viewing frustum along the narrower of the image's width and height.
tpbrt_float_t fov;
} tpbrt_camera_perspective_params_t;

/**
* @brief Spherical camera mapping.
* @ingroup camera-public
*/
typedef enum tpbrt_camera_spherical_mapping_t {
/// @brief An area-preserving mapping based on an octahedral encoding of the unit sphere is used.
TPBRT_CAMERA_SPHERICAL_MAPPING_EQUAL_AREA = 0,
/// @brief An equirectangular mapping.
TPBRT_CAMERA_SPHERICAL_MAPPING_EQUI_RECTANGULAR = 1,
/// @brief Count of available spherical camera mappings.
TPBRT_CAMERA_SPHERICAL_MAPPING_MAX_NUM = 2,
} tpbrt_camera_spherical_mapping_t;

/**
* @brief Spherical camera parameters.
* @ingroup camera-public
*/
typedef struct tpbrt_camera_spherical_params_t {
/// @brief mapping type.
tpbrt_camera_spherical_mapping_t mapping : 3;
} tpbrt_camera_spherical_params_t;

/**
* @brief Realistic camera aperture value type.
* @ingroup camera-public
*/
typedef enum tpbrt_camera_realistic_aperture_type_t {
/// @brief Aperture will be read from given file specifying an image to be used to specify the shape.
TPBRT_CAMERA_REALISTIC_APERTURE_TYPE_FILE_NAME = 0,
/// @brief Aperture value is a builtin aperture.
TPBRT_CAMERA_REALISTIC_APERTURE_TYPE_BUILTIN = 1,
/// @brief Count of available realistic camera apertures.
TPBRT_CAMERA_REALISTIC_APERTURE_TYPE_MAX_NUM = 2,
} tpbrt_camera_realistic_aperture_type_t;

/**
* @brief Realistic camera aperture builtin type.
* @ingroup camera-public
*/
typedef enum tpbrt_camera_realistic_aperture_builtin_t {
/// @brief Circular aperture shape.
TPBRT_CAMERA_REALISTIC_APERTURE_BUILTIN_CIRCULAR = 0,
/// @brief Gaussian aperture shape.
TPBRT_CAMERA_REALISTIC_APERTURE_BUILTIN_GAUSSIAN = 1,
/// @brief Square aperture shape.
TPBRT_CAMERA_REALISTIC_APERTURE_BUILTIN_SQUARE = 2,
/// @brief Pentagon aperture shape.
TPBRT_CAMERA_REALISTIC_APERTURE_BUILTIN_PENTAGON = 3,
/// @brief Star aperture shape.
TPBRT_CAMERA_REALISTIC_APERTURE_BUILTIN_STAR = 4,
/// @brief Count of available realistic camera builtin apertures.
TPBRT_CAMERA_REALISTIC_APERTURE_BUILTIN_MAX_NUM = 5,
} tpbrt_camera_realistic_aperture_builtin_t;

/**
* @brief Realistic camera aperture. Allows specifying the shape of the camera aperture.
* @ingroup camera-public
*/
typedef struct tpbrt_camera_realistic_aperture_t {
/// @brief Initialized value depends on type value.
union {
/// @brief Aperture builtin type.
tpbrt_camera_realistic_aperture_builtin_t builtin : 4;
/// @brief File specifying an image to be used to specify the shape.
tpbrt_string_t file_name;
} as;

/// @brief Aperture value type.
tpbrt_camera_realistic_aperture_type_t type : 3;
} tpbrt_camera_realistic_aperture_t;

/**
* @brief Realistic camera parameters.
* @ingroup camera-public
*/
typedef struct tpbrt_camera_realistic_params_t {
/// @brief Specifies the name of a lens description file that gives the collection of lens elements in the lens system. A number of such lenses are available in the lenses directory in the pbrt-v4 scenes distribution.
tpbrt_string_t lens_file;
/// @brief Diameter of the lens system's aperture, specified in mm. The smaller the aperture, the less light reaches the film plane, but the greater the range of distances that are in focus.
tpbrt_float_t aperture_diameter;
/// @brief Distance in meters at which the lens system is focused.
tpbrt_float_t focus_distance;
/// @brief Allows specifying the shape of the camera aperture.
tpbrt_camera_realistic_aperture_t aperture;
} tpbrt_camera_realistic_params_t;

/**
* @brief PBRT Camera representation.
* @ingroup camera-public
*/
typedef struct tpbrt_camera_t {
/// @brief The time at which the virtual camera shutter opens.
tpbrt_float_t shutter_open;
/// @brief The time at which the virtual camera shutter closes.
tpbrt_float_t shutter_close;
/// @brief Transform handle.
tpbrt_transform_animated_t transform;
/// @brief Interior media handle.
tpbrt_media_handle_t interior_media_handle;
/// @brief Exterior media handle.
tpbrt_media_handle_t exterior_media_handle;

/// @brief Initialized value depends on current type value.
union {
/// @brief Orthographic camera parameters.
tpbrt_camera_orthographic_params_t orthographic;
/// @brief Perspective camera parameters.
tpbrt_camera_perspective_params_t perspective;
/// @brief Spherical camera parameters.
tpbrt_camera_spherical_params_t spherical;
/// @brief Realistic camera parameters.
tpbrt_camera_realistic_params_t realistic;
} as;

/// @brief Camera type.
tpbrt_camera_type_t type : 4;
} tpbrt_camera_t;

Expand Down
Loading