esp::gfx::RenderTarget class

Holds a framebuffer and encapsulates the logic of retrieving rendering results of various types (RGB, Depth, ObjectID) from the framebuffer.

Reads the rendering results into either CPU or GPU, if compiled with CUDA, memory

Public types

enum class Flag { RgbaAttachment = 1 << 0, ObjectIdAttachment = 1 << 1, DepthTextureAttachment = 1 << 2, HorizonBasedAmbientOcclusion = 1 << 3 }
using Flags = Corrade::Containers::EnumSet<Flag>

Constructors, destructors, conversion operators

RenderTarget(const Magnum::Vector2i& size, const Magnum::Vector2& depthUnprojection, gfx_batch::DepthShader* depthShader, Flags flags = {Flag::RgbaAttachment|Flag::ObjectIdAttachment|Flag::DepthTextureAttachment}, const sensor::VisualSensor* visualSensor = nullptr)
Constructor.
RenderTarget(const Magnum::Vector2i& size, const Magnum::Vector2& depthUnprojection, const sensor::VisualSensor* visualSensor = nullptr)
Constructor.
~RenderTarget() defaulted
RenderTarget(const RenderTarget&) deleted

Public functions

void renderEnter()
Called before any draw calls that target this RenderTarget Clears the framebuffer to the color specified by the VisualSensorSpec and binds it.
void renderReEnter()
Prepare for another render pass (e.g., to bind the framebuffer). Compared to @renderEnter, it will NOT clear the framebuffer.
void renderExit()
Called after any draw calls that target this RenderTarget.
auto framebufferSize() const -> Magnum::Vector2i
The size of the framebuffer in WxH.
void readFrameRgba(const Magnum::MutableImageView2D& view)
Retrieve the RGBA rendering results.
void readFrameDepth(const Magnum::MutableImageView2D& view)
Retrieve the depth rendering results.
void readFrameObjectId(const Magnum::MutableImageView2D& view)
Reads the ObjectID rendering results into the memory specified by view.
void blitRgbaTo(Magnum::GL::AbstractFramebuffer& target, const Magnum::Range2Di& targetRectangle)
Blits the rgba buffer from internal FBO to given framebuffer rectangle.
void blitRgbaToDefault()
Blits the rgba buffer from internal FBO to default frame buffer which in case of EmscriptenApplication will be a canvas element.
auto getDepthTexture() -> Magnum::GL::Texture2D&
get the depth texture
auto getObjectIdTexture() -> Magnum::GL::Texture2D&
get the object id texture
void tryDrawHbao()
draw HBAO effect if enabled for this render target
auto operator=(const RenderTarget&) -> RenderTarget& deleted

Enum documentation

enum class esp::gfx::RenderTarget::Flag

Enumerators
RgbaAttachment

create a color attachment for the rgba render buffer No need to set it for depth sensor, semantic sensor etc. as it makes the rendering slower

ObjectIdAttachment

create a color attachment for the objectId texture No need to set it for color sensor, depth sensor etc. as it makes the rendering slower

DepthTextureAttachment

create a depth attachment for the depth texture, it MUST be set for the depth sensor. No need to set it for color sensor, objectId sensor etc. as it makes the rendering slower (default depth buffer will be used in this case.)

HorizonBasedAmbientOcclusion

Enable HBAO visual effect that adds soft shadows to corners and crevices.

Function documentation

esp::gfx::RenderTarget::RenderTarget(const Magnum::Vector2i& size, const Magnum::Vector2& depthUnprojection, gfx_batch::DepthShader* depthShader, Flags flags = {Flag::RgbaAttachment|Flag::ObjectIdAttachment|Flag::DepthTextureAttachment}, const sensor::VisualSensor* visualSensor = nullptr)

Constructor.

Parameters
size The size of the underlying framebuffers in WxH
depthUnprojection Depth unprojection parameters. See calculateDepthUnprojection()
depthShader A DepthShader used to unproject depth on the GPU. Unprojects the depth on the CPU if nullptr. Must be not nullptr to use readFrameDepthGPU()
flags The flags of the renderer target
visualSensor (optional) The visual sensor for this render target

esp::gfx::RenderTarget::RenderTarget(const Magnum::Vector2i& size, const Magnum::Vector2& depthUnprojection, const sensor::VisualSensor* visualSensor = nullptr)

Constructor.

Parameters
size The size of the underlying framebuffers in WxH
depthUnprojection Depth unprojection parameters. See calculateDepthUnprojection()
visualSensor (optional) The visual sensor for this render target

Equivalent to calling RenderTarget(size, depthUnprojection, nullptr, {})

void esp::gfx::RenderTarget::readFrameRgba(const Magnum::MutableImageView2D& view)

Retrieve the RGBA rendering results.

Parameters
view in/out Preallocated memory that will be populated with the result. The result will be read as the pixel format of this view.

void esp::gfx::RenderTarget::readFrameDepth(const Magnum::MutableImageView2D& view)

Retrieve the depth rendering results.

Parameters
view in/out Preallocated memory that will be populated with the result. The PixelFormat of the image must only specify the R channel, generally Magnum::PixelFormat::R32F

void esp::gfx::RenderTarget::readFrameObjectId(const Magnum::MutableImageView2D& view)

Reads the ObjectID rendering results into the memory specified by view.

Parameters
view in/out Preallocated memory that will be populated with the result. The PixelFormat of the image must only specify the R channel and be a format which a uint16_t can be interpreted as, generally Magnum::PixelFormat::R32UI, Magnum::PixelFormat::R32I, or Magnum::PixelFormat::R16UI