# Octahedral Impostor system

This system is based on the idea presented by Ryan Brucks

Conceptually, the system has 2 parts:
1. Baking. This is where we take the source mesh, and prepare assets for impostor. These assets are mainly textures, copied from materials of the source meshes as well as depth fields.
2. Drawing. Assets prepared during "Baking" part are being rendered, using a simple geometry (6 triangles), and performing ray marching as well as shading inside the pixel shader. 

This is inherently a deferred rendering technique, where an impostor asset is represented as a collection of pre-rendered G-Buffers from different view angles, those "frames" are looked up at runtime in the shader to create the best approximation of a G-Buffer for the given projection transform, and the shading is performed. Depth is written out as well, this allows impostors to not only exist in color space, but also in depth space. The fact that impostors write depth gives them ability to be used for shadow mapping as well.

## Limitations
* Materials. Currently only PBR rendering is supported with the following attributes recorded
  * Albedo (vertex colors are included as well)
  * Normal
  * Metalness
  * Roughness
  * Ambient Occlusion
* Animations are not supported, neither vertex, nor pixel-shader based ones. The whole impostor can move around and be transformed, but the contents are static and pre-baked.
* When camera moves too close to the impostor, or an extreme projection is applied - artefacts will become visible. In case of camera getting too close - parts of the mesh that are occluded by outer shell will not become visible in the impostor, as that information is simply not captured. In cases of extreme projection - certain parts of the captured G-Buffer may undergo warping and stretching converting a handful of baked pixel to a larger number of on-screen pixels, creating pixelation and smearing. Note that impostors are not a replacement for your meshes, so use them sensibly.

## Drawing
### reconstruction of image from multiple perspectives
- based on MO95 and TSK07

---
references:

- [2021] [Rendering a Sphere on a Quad](https://bgolus.medium.com/rendering-a-sphere-on-a-quad-13c92025570c) by Ben Golus
- [2018] [Octahedral Impostors](https://shaderbits.com/blog/octahedral-impostors) by Ryan Brucks
- [2018] https://github.com/xraxra/IMP
- [2018] https://github.com/wojtekpil/Godot-Octahedral-Impostors
- [2011] BN11 : "Real-time Realistic Rendering and Lighting of Forests" by Eric Bruneton, Fabrice Neyret
- [2007] TSK07: "Fast (Spherical) Light Field Rendering with Per-Pixel Depth." by Severin Todt, Christof Rezk-Salama and Andreas Kolb
- [1995] MO95: Nelson Max and Keiichi Ohsaki. Rendering trees from precomputed z-buffer views. In Eurographics Rendering Workshop, pages 45–54, 1995
