esp::gfx_batch namespace

Batch renderer.

Classes

class DepthShader
Depth-only shader.
class Hbao
class HbaoConfiguration
class Renderer
Batch renderer.
struct RendererConfiguration
Global renderer configuration.
class RendererStandalone
Standalone batch renderer.
struct RendererStandaloneConfiguration
Global standalone renderer configuration.
struct SceneStats
Statistics for a single renderer scene.

Enums

enum class HbaoFlag { NoBlur = 1 << 0, UseAoSpecialBlur = 1 << 1, LayeredImageLoadStore = 1 << 2, LayeredGeometryShader = 1 << 3 }
enum class HbaoType { Classic, CacheAware }
enum class RendererFlag { NoTextures = 1 << 0 }
Global batch renderer flag.
enum class RendererFileFlag { Whole = 1 << 0, GenerateMipmap = 1 << 1 }
Batch renderer file treatment flag.
enum class RendererLightType { Directional = 0, Point = 1 }
Renderer light type.
enum class RendererStandaloneFlag { QuietLog = 1 << 0 }
Global standalone batch renderer flag.

Typedefs

using HbaoFlags = Corrade::Containers::EnumSet<HbaoFlag>
using RendererFlags = Corrade::Containers::EnumSet<RendererFlag>
Global batch renderer flags.
using RendererFileFlags = Corrade::Containers::EnumSet<RendererFileFlag>
Batch renderer file treatment flags.
using RendererStandaloneFlags = Corrade::Containers::EnumSet<RendererStandaloneFlag>
Global standalone batch renderer flags.

Functions

auto calculateDepthUnprojection(const Magnum::Matrix4& projectionMatrix) -> Magnum::Vector2
Calculate depth unprojection coefficients for unprojectDepth()
void unprojectDepth(const Magnum::Vector2& unprojection, const Corrade::Containers::StridedArrayView2D<Magnum::Float>& depth)
Unproject depth values.

Enum documentation

enum class esp::gfx_batch::HbaoFlag

Enumerators
NoBlur

Default should be blur, since without blur there are artifacts. No blur capability given for debugging.

UseAoSpecialBlur

LayeredImageLoadStore

LayeredGeometryShader

enum class esp::gfx_batch::HbaoType

enum class esp::gfx_batch::RendererFlag

Global batch renderer flag.

Enumerators
NoTextures

Render without textures.

Causes textures to not even get loaded, potentially saving significant amount of memory. Only material and vertex colors are used for rendering.

enum class esp::gfx_batch::RendererFileFlag

Batch renderer file treatment flag.

Enumerators
Whole

Treat the file as a whole.

By default a file is treated as a so-called composite — a collection of node hierarchy templates — which you then add with Renderer::addNodeHierarchy() using a name corresponding to one of the root nodes. With this flag set, the whole file is treated as a single hierarchy instead, with the filename (or name, if present) argument of Renderer::addFile() used as a name.

GenerateMipmap

Generate a mipmap out of single-level uncompressed textures.

By default, no renderer-side processing of imported textures is done — if the image contains multiple levels, they're imported as well, otherwise just a single level is uploaded, regardless of whether the texture has a filtering across mip levels set up.

With this option enabled, if the input image is uncompressed and there's just a single level, the texture is created with a full mip pyramid and the lower levels get generated on the fly, leading to a smoother look with large textures. On-the-fly mip level generation is impossible for compressed formats, there this option is ignored.

enum class esp::gfx_batch::RendererLightType

Renderer light type.

Enumerators
Directional

Directional

Point

Point

enum class esp::gfx_batch::RendererStandaloneFlag

Global standalone batch renderer flag.

Enumerators
QuietLog

Suppress Magnum startup log.

Useful for testing scenarios where the renderer instance is created several times in a row and the output would cause too much noise in the output.

Typedef documentation

typedef Corrade::Containers::EnumSet<RendererFlag> esp::gfx_batch::RendererFlags

Global batch renderer flags.

typedef Corrade::Containers::EnumSet<RendererFileFlag> esp::gfx_batch::RendererFileFlags

Batch renderer file treatment flags.

Function documentation

Magnum::Vector2 esp::gfx_batch::calculateDepthUnprojection(const Magnum::Matrix4& projectionMatrix)

Calculate depth unprojection coefficients for unprojectDepth()

Given a projection transformation of vector $ \boldsymbol{v} $ using a matrix $ \boldsymbol{P} $ where $ x $ and $ y $ are arbitrary, the transformation can be reduced to a 2x2 matrix multiplication:

\[ \begin{array}{rcl} \boldsymbol{P} \boldsymbol{v} & = & \begin{pmatrix} p & 0 & 0 & 0 \\ 0 & q & 0 & 0 \\ 0 & 0 & a & b \\ 0 & 0 & -1 & 0 \end{pmatrix} \begin{pmatrix} x \\ y \\ z \\ 1 \end{pmatrix} \\[2.5em] \boldsymbol{P'} \boldsymbol{v} & = & \begin{pmatrix} a & b \\ -1 & 0 \end{pmatrix} \begin{pmatrix} z \\ 1 \end{pmatrix} = \begin{pmatrix} az + b \\ -z \end{pmatrix} \end{array} \]

In the OpenGL depth buffer, the depth values $ d $ are in range $ [ 0 ; 1 ] $ and the final depth value is after a perspective divide. The output has Z going forward, not backward, so we're looking for the value of $ -z $ :

\[ \begin{array}{rcl} 2d - 1 & = & \cfrac{az + b}{-z} \\[1.25em] -z & = & \cfrac{b}{2d + a - 1} \end{array} \]

Finally, to reduce the amount of operations in unprojectDepth(), we integrate the constants into $ a $ and $ b $ , returning $ a' $ and $ b' $ :

\[ \begin{array}{rcl} -z & = & \cfrac{b}{2d + (a - 1)} \\[1.25em] -z & = & \cfrac{\frac{1}{2}b}{d + \frac{1}{2}(a - 1)} \\[1.25em] -z & = & \cfrac{b'}{d + a'} ; ~~~~ a' = \frac{1}{2}(a - 1), ~~~~ b' = \frac{1}{2}b \end{array} \]

void esp::gfx_batch::unprojectDepth(const Magnum::Vector2& unprojection, const Corrade::Containers::StridedArrayView2D<Magnum::Float>& depth)

Unproject depth values.

Parameters
unprojection in Unprojection coefficients from calculateDepthUnprojection()
depth in/out Depth values in range $ [ 0 ; 1 ] $

See calculateDepthUnprojection() for the full algorithm explanation. Additionally to applying that calculation, if the input depth is at the far plane (of value 1.0f), it's set to 0.0f on output as consumers expect zeros for things that are too far.