esp::gfx namespace

GFX library.

Namespaces

namespace CubeMapShaderBaseTexUnitSpace
namespace pbrTextureUnitSpace
namespace replay

Classes

class CubeMap
class CubeMapCamera
class CubeMapShaderBase
class DebugLineRender
Singleton utility class for on-the-fly rendering of lines (e.g. every frame). This is intended for debugging or simple UX for prototype apps. The API prioritizes ease-of-use over maximum runtime performance.
class DepthMapDrawableBase
class DepthShader
Depth-only shader.
class DoubleSphereCameraShader
class Drawable
Drawable for use with DrawableGroup.
class DrawableGroup
Group of drawables, and shared group parameters.
class EquirectangularShader
class GaussianFilterShader
A shader to visualize the depth buffer information.
class GenericDrawable
struct LightInfo
Contains a single light's information.
struct MaterialData
class MeshVisualizerDrawable
class PbrDrawable
class PbrEquiRectangularToCubeMapShader
a shader to convert a HDRi image (the environment map in equirectangular form) to a cubemap
class PbrImageBasedLighting
struct PbrMaterialData
class PbrPrecomputedMapShader
A shader to output the irradiance map, applied in the IBL diffuse part, or the prefiltered environment map, applied in the IBL specular part, based on the user setting.
class PbrShader
struct PhongMaterialData
class PTexMeshDrawable
class PTexMeshShader
class RenderCamera
class Renderer
class RenderTarget
class TextureVisualizerShader
A shader to visualize the depth buffer information.
class VarianceShadowMapDrawable
class VarianceShadowMapShader
class WindowlessContext

Enums

enum class DrawableType: uint8_t { None = 0, Generic = 1, Pbr = 2, PTexMesh = 3, MeshVisualizer = 4, VarianceShadowMap = 6 }
enum class LightPositionModel { Camera = 0, Global = 1, Object = 2 }
enum class LightType { Point = 0, Directional = 1, Spot = 2 }
enum class MaterialDataType { None = 0, Phong = 1, Pbr = 2 }

Typedefs

using LightSetup = std::vector<LightInfo>
A set of LightInfos.
using ShaderManager = Magnum::ResourceManager<Magnum::GL::AbstractShaderProgram, gfx::LightSetup, gfx::MaterialData>
using ShadowMapManager = Magnum::ResourceManager<CubeMap>
using ShadowMapKeys = std::vector<Magnum::ResourceKey>

Functions

void initGfxBindings(pybind11::module& m)
auto espLoggingSubsystem() -> logging::Subsystem
auto calculateDepthUnprojection(const Magnum::Matrix4& projectionMatrix) -> Magnum::Vector2
Calculate depth unprojection coefficients for unprojectDepth()
void unprojectDepth(const Magnum::Vector2& unprojection, Corrade::Containers::ArrayView<Magnum::Float> depth)
Unproject depth values.
auto operator==(const LightInfo& a, const LightInfo& b) -> bool
auto operator!=(const LightInfo& a, const LightInfo& b) -> bool
auto getLightPositionRelativeToCamera(const LightInfo& light, const Magnum::Matrix4& transformationMatrix, const Magnum::Matrix4& cameraMatrix) -> Magnum::Vector4
Get position relative to a camera for a LightInfo and a rendered object. light.position and the return value are Vector4, with w == 1 for positions and w == 0 for directions.
auto getLightPositionRelativeToWorld(const LightInfo& light, const Magnum::Matrix4& transformationMatrix, const Magnum::Matrix4& cameraMatrix) -> Magnum::Vector4
Get light position in world space for a LightInfo and a rendered object. light.position and the return value are Vector4, with w == 1 for positions and w == 0 for directions.
auto getLightsAtBoxCorners(const Magnum::Range3D& box, const Magnum::Color3& lightColor = Magnum::Color3{10.0f}) -> LightSetup
Get a LightSetup with lights at the corners of a box.
auto getDefaultLights() -> LightSetup
Get a LightSetup with some directional lights approximating daylight.
auto getAmbientLightColor(const LightSetup& lightSetup) -> Magnum::Color3
Get get a single, combined ambient light color for use with the Phong lighting model.
auto createUniversalMaterial(const Mn::Trade::MaterialData& origMaterialData) -> Mn::Trade::MaterialData
This function will take an existing Mn::Trade::MaterialData and add the missing attributes for the types it does not support, so that it will have attributes for all habitat-supported types. This should only be called if the user has specified a desired shader type that the material does not natively support.
void setLightSetupForSubTree(scene::SceneNode& root, const Magnum::ResourceKey& lightSetup)
Set the light setup for a subtree.

Enum documentation

enum class esp::gfx::DrawableType: uint8_t

enum class esp::gfx::LightPositionModel

Enumerators
Camera

Light position is relative to the camera.

Global

Light position is relative to scene.

Object

Light position is relative to the object being rendered.

enum class esp::gfx::LightType

Enumerators
Point

The type of light described by a light info.

Directional

Spot

enum class esp::gfx::MaterialDataType

Enumerators
None

default, does not represent any material

Phong

phong material data

Pbr

Physically based rendering (PBR) material data.

Typedef documentation

using esp::gfx::LightSetup = std::vector<LightInfo>

A set of LightInfos.

Function documentation

void esp::gfx::initGfxBindings(pybind11::module& m)

Magnum::Vector2 esp::gfx::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::unprojectDepth(const Magnum::Vector2& unprojection, Corrade::Containers::ArrayView<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.

bool esp::gfx::operator==(const LightInfo& a, const LightInfo& b)

bool esp::gfx::operator!=(const LightInfo& a, const LightInfo& b)

Magnum::Vector4 esp::gfx::getLightPositionRelativeToCamera(const LightInfo& light, const Magnum::Matrix4& transformationMatrix, const Magnum::Matrix4& cameraMatrix)

Get position relative to a camera for a LightInfo and a rendered object. light.position and the return value are Vector4, with w == 1 for positions and w == 0 for directions.

Parameters
light
transformationMatrix Describes object position relative to camera
cameraMatrix Describes world position relative to camera
Returns Magnum::Vector4 Light position relative to camera

Magnum::Vector4 esp::gfx::getLightPositionRelativeToWorld(const LightInfo& light, const Magnum::Matrix4& transformationMatrix, const Magnum::Matrix4& cameraMatrix)

Get light position in world space for a LightInfo and a rendered object. light.position and the return value are Vector4, with w == 1 for positions and w == 0 for directions.

Parameters
light
transformationMatrix Describes object position relative to camera
cameraMatrix Describes world position relative
Returns Magnum::Vector4 Light position in world space

LightSetup esp::gfx::getLightsAtBoxCorners(const Magnum::Range3D& box, const Magnum::Color3& lightColor = Magnum::Color3{10.0f})

Get a LightSetup with lights at the corners of a box.

LightSetup esp::gfx::getDefaultLights()

Get a LightSetup with some directional lights approximating daylight.

Magnum::Color3 esp::gfx::getAmbientLightColor(const LightSetup& lightSetup)

Get get a single, combined ambient light color for use with the Phong lighting model.

Mn::Trade::MaterialData esp::gfx::createUniversalMaterial(const Mn::Trade::MaterialData& origMaterialData)

This function will take an existing Mn::Trade::MaterialData and add the missing attributes for the types it does not support, so that it will have attributes for all habitat-supported types. This should only be called if the user has specified a desired shader type that the material does not natively support.

Parameters
origMaterialData The original material from the importer
Returns The new material with attribute support for all supported shader types.

void esp::gfx::setLightSetupForSubTree(scene::SceneNode& root, const Magnum::ResourceKey& lightSetup)

Set the light setup for a subtree.

Parameters
root Subtree root
lightSetup LightSetup key in the ShaderManager

All drawables in the subtree starting at root will have the new lightSetup