This repo contains a simplest implementation of volume rendering including
- heterogeneous(homogeneous) volume rendering
- SGGX volume rendering, please refer to The SGGX Microflake Distribution
As it's for validation use only, only necessary components are included:
- perspective camera, with simple box reconstruction filter
- environment map
- voxel based volume representation
- transform could be applied on above components
- single scattering model, path tracing
To run this repo, installing taichi
and numpy
will be sufficient. Use
python main.py
to render.
We follow the OpenGL camera convention that the camera space is right-handed and the z-axis faces backwards. For convenience, we consider a image plane at focus and don't consider near and far clip. Please refer to OpenGL Transformation
We use an hdr image as environment map. The environment is considered placed so far away that rays with the same direction result in the same color. For more details, please refer to PBR book.
BoundingBox | Homogeneous | Heterogeneous |
---|---|---|
We consider scattering, absorptive and non-emissive volume. For basics of volume rendering, please refer to PBR book.
For simplicity, the volume is confined in an AABB and the data is stored in voxels. Each voxel stores 2 3D vectors, standing for extinction coefficient and albedo. Trilinear interpolation is applied for points sampled in the volume. Also we consider uniform phase function, as we don't focus on heterogeneous volume.
With path tracing, we have
BoundingBox | Homogeneous | Heterogeneous |
---|---|---|
The SGGX microflake model is implemented as in the supplement material of originial paper.
BoundingBox | SGGX |
---|---|
The overall rendering equation is
The radiance at point
The second term is the accumulated scattering radiance.