Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split Pbrt IO into its own file #1321

Merged
merged 4 commits into from
Jan 2, 2022
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
4 changes: 3 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ Here is a list of the main libraries.
scattering, multiple importance sampling
- [Yocto/SceneIO](yocto/yocto_sceneio.md): image, shape and scene serialization
- [Yocto/ModelIO](yocto/yocto_modelio.md): low-level parsing and writing for
Ply, Obj, Stl, Pbrt formats
Ply, Obj, Stl formats
- [Yocto/PbrtIO](yocto/yocto_pbrtio.md): low-level parsing and writing for
Pbrt format
- [Yocto/Cli](yocto/yocto_cli.md): printing utilities and command line parsing
- [Yocto/Parallel](yocto/yocto_parallel.md): concurrency utilities (deprecated)

Expand Down
70 changes: 4 additions & 66 deletions docs/yocto/yocto_modelio.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Yocto/ModelIO: Serialization for Obj, Ply and Pbrt models
# Yocto/ModelIO: Serialization for Obj, Ply and Stl models

Yocto/ModelIO is a collection of utilities for loading and saving scenes
and meshes in Ply, Obj, Stl and Pbrt formats.
Yocto/ModelIO is implemented in `yocto_modelio.h` and `yocto_modelio.cpp`.
and meshes in Ply, Obj, and Stl formats.
Yocto/ModelIO is implemented in `yocto_modelio.h` and `yocto_modelio.cpp`,
and depends on `fast_float.h`.

## Ply models

Expand Down Expand Up @@ -506,66 +507,3 @@ shape.triangles = vector<vec3i>{...};
stl.shapes.push_back(shape); // add shape
load_obj(filename, stl); // save stl
```

## Pbrt models

The Pbrt file format is a scene representation suitable for realistic rendering
and implemented by the Pbrt renderer.
To use this library is helpful to understand the basic of the Pbrt
file format for example from the
[Pbrt format documentatioon](https://www.pbrt.org/fileformat-v3.html).

The Pbrt file format is an extensible file format for a plugin-based system.
Representing the format directly allows for best fidelity but pushed the burden
of interpreting standard plugins to the use. Yocto/ModelIO takes a different
approach and translates camera, shapes, materials, textures and lights from
Pbrt plugins to a common representation that presents users a simpler and
more uniform scene representation.

Yocto/ModelIO represents Pbrt data with the `pbrt_scene` struct.
Pbrt models are defined as collections of cameras, instanced shapes, materials,
texture and environments. Pbrt cameras are translate into a thin-len
approximations. Pbrt materials are translated to a material representation
similar to the Disney BSDF. Pbrt textures are either interpreted ion the fly or
defined by a image file. Pbrt area lights are translated to either emissive
materials and environments.

The Pbrt model is defined as an array of objects of the types defined above.
Pbrt objects are pointers owned by the main `pbrt_scene`.
Objects properties can be read and written directly from the model data,
and are documented in the header file for now.
Yocto/ModelIO does not currently provide functions to read and write Pbrt
shapes with a simpler interface than accessing data directly.

In general, Pbrt support is still experimental even if the library can
parse most Pbrt files. The objects properties documentations are for now
stored in the header file.

```cpp
auto pbrt = new pbrt_scene{...}; // obj model buffer
for(auto shape : pbrt.shapes) // access shapes
print_info(shape.name); // access shape properties
for(auto material : pbrt.material) // access materials
print_info(material.diffuse); // access material properties
for(auto material : pbrt.material) // access materials
print_info(material.color_tex); // access material textures
for(auto camera : pbrt.cameras) // access cameras [extension]
print_info(camera.frame); // access camera properties
for(auto environment : pbrt.environments) // access environments [extension]
print_info(environment.emission); // access environment properties
```

Use `ok = load_pbrt(filename, pbrt, error)` to load Pbrt
files and `ok = save_pbrt(filename, pbrt, error)` to save them.
Both loading and saving take a filename, a reference to a model,
and an error string, and returns a boolean that indicated whether the
operation is successful.

```cpp
auto pbrt = pbrt_model{}; // pbrt model
auto error = string{}; // error string
if (!load_pbrt(filename, pbrt, error)) // load pbrt
handle_error(error);
if (!save_pbrt(filename, pbrt, error)) // save pbrt
handle_error(error);
```
69 changes: 69 additions & 0 deletions docs/yocto/yocto_pbrtio.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Yocto/PbrtIO: Serialization for Pbrt models

Yocto/ModelIO is a collection of utilities for loading and saving scenes
in the Pbrt format.
Yocto/PbrtIO is implemented in `yocto_pbrtio.h` and `yocto_pbrtio.cpp`,
and depends on `fast_float.h`.

## Pbrt models

The Pbrt file format is a scene representation suitable for realistic rendering
and implemented by the Pbrt renderer.
To use this library is helpful to understand the basic of the Pbrt
file format for example from the
[Pbrt format documentatioon](https://www.pbrt.org/fileformat-v3.html).

The Pbrt file format is an extensible file format for a plugin-based system.
Representing the format directly allows for best fidelity but pushed the burden
of interpreting standard plugins to the use. Yocto/ModelIO takes a different
approach and translates camera, shapes, materials, textures and lights from
Pbrt plugins to a common representation that presents users a simpler and
more uniform scene representation.

Yocto/ModelIO represents Pbrt data with the `pbrt_scene` struct.
Pbrt models are defined as collections of cameras, instanced shapes, materials,
texture and environments. Pbrt cameras are translate into a thin-len
approximations. Pbrt materials are translated to a material representation
similar to the Disney BSDF. Pbrt textures are either interpreted ion the fly or
defined by a image file. Pbrt area lights are translated to either emissive
materials and environments.

The Pbrt model is defined as an array of objects of the types defined above.
Pbrt objects are pointers owned by the main `pbrt_scene`.
Objects properties can be read and written directly from the model data,
and are documented in the header file for now.
Yocto/ModelIO does not currently provide functions to read and write Pbrt
shapes with a simpler interface than accessing data directly.

In general, Pbrt support is still experimental even if the library can
parse most Pbrt files. The objects properties documentations are for now
stored in the header file.

```cpp
auto pbrt = new pbrt_scene{...}; // obj model buffer
for(auto shape : pbrt.shapes) // access shapes
print_info(shape.name); // access shape properties
for(auto material : pbrt.material) // access materials
print_info(material.diffuse); // access material properties
for(auto material : pbrt.material) // access materials
print_info(material.color_tex); // access material textures
for(auto camera : pbrt.cameras) // access cameras [extension]
print_info(camera.frame); // access camera properties
for(auto environment : pbrt.environments) // access environments [extension]
print_info(environment.emission); // access environment properties
```

Use `ok = load_pbrt(filename, pbrt, error)` to load Pbrt
files and `ok = save_pbrt(filename, pbrt, error)` to save them.
Both loading and saving take a filename, a reference to a model,
and an error string, and returns a boolean that indicated whether the
operation is successful.

```cpp
auto pbrt = pbrt_model{}; // pbrt model
auto error = string{}; // error string
if (!load_pbrt(filename, pbrt, error)) // load pbrt
handle_error(error);
if (!save_pbrt(filename, pbrt, error)) // save pbrt
handle_error(error);
```
3 changes: 2 additions & 1 deletion libs/yocto/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
add_library(yocto STATIC
yocto_math.h yocto_color.h yocto_geometry.h
yocto_noise.h yocto_sampling.h yocto_shading.h
yocto_modelio.h yocto_modelio.cpp
yocto_bvh.h yocto_bvh.cpp
yocto_shape.h yocto_shape.cpp
yocto_mesh.h yocto_mesh.cpp
yocto_image.h yocto_image.cpp
yocto_scene.h yocto_scene.cpp
yocto_trace.h yocto_trace.cpp
yocto_modelio.h yocto_modelio.cpp
yocto_pbrtio.h yocto_pbrtio.cpp
yocto_sceneio.h yocto_sceneio.cpp
yocto_gui.h yocto_gui.cpp
yocto_parallel.h yocto_cli.h
Expand Down
Loading