NAP
Public Member Functions | Public Attributes | List of all members
CubeDepthRenderTarget Class Reference

#include <cubedepthrendertarget.h>

Public Member Functions

 CubeDepthRenderTarget (Core &core)
 
 ~CubeDepthRenderTarget ()
 
virtual bool init (utility::ErrorState &errorState) override
 
virtual void beginRendering () override
 
virtual void endRendering () override
 
virtual const glm::ivec2 getBufferSize () const override
 
virtual void setClearColor (const RGBAColorFloat &color) override
 
virtual const RGBAColorFloatgetClearColor () const override
 
virtual ECullWindingOrder getWindingOrder () const override
 
virtual VkRenderPass getRenderPass () const override
 
virtual VkFormat getColorFormat () const override
 
virtual VkFormat getDepthFormat () const override
 
virtual VkSampleCountFlagBits getSampleCount () const override
 
virtual bool getSampleShadingEnabled () const override
 
glm::ivec2 getSize () const
 
void render (CubeDepthRenderTargetCallback renderCallback)
 
void render (PerspCameraComponentInstance &camera, CubeDepthRenderTargetCallback renderCallback)
 
- Public Member Functions inherited from Resource
 Resource ()
 
- Public Member Functions inherited from Object
 Object ()
 
virtual ~Object ()
 
virtual void onDestroy ()
 
 Object (Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&)=delete
 
Objectoperator= (Object &&)=delete
 

Public Attributes

bool mSampleShading = true
 Property: 'SampleShading' Reduces texture aliasing when enabled, at higher computational cost. More...
 
float mClearValue = 1.0f
 Property: 'ClearValue' value selection used for clearing the render target. More...
 
ERasterizationSamples mRequestedSamples = ERasterizationSamples::One
 Property: 'Samples' The number of samples used during Rasterization. For better results turn on 'SampleShading'. More...
 
DepthRenderTextureCube::EDepthFormat mDepthFormat = DepthRenderTextureCube::EDepthFormat::D32
 Property: 'DepthFormat' the cube texture depth format. More...
 
ResourcePtr< DepthRenderTextureCubemCubeDepthTexture
 Property: 'CubeDepthTexture' Cube depth texture to render to. More...
 
- Public Attributes inherited from Object
std::string mID
 Property: 'mID' unique name of the object. Used as an identifier by the system. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Object
static bool isIDProperty (rtti::Instance &object, const rtti::Property &property)
 

Description

CubeDepthRenderTarget

A specialized version of nap::RenderTarget that renders a cube depth texture. As a cube texture comprises six views of the scene, the render function carries out six render passes, each from a different point of view by means of particular view and projection transformations. The result of these render passes is stored in a multi-layer Vulkan image, each layer representing one view through the side of a unit cube.

Inheritance diagram for CubeDepthRenderTarget:
[legend]
Collaboration diagram for CubeDepthRenderTarget:
[legend]

Constructor & Destructor Documentation

◆ CubeDepthRenderTarget()

Every cube depth render target requires a reference to core.

Parameters
corelink to a nap core instance

◆ ~CubeDepthRenderTarget()

Destroys allocated render resources

Member Function Documentation

◆ beginRendering()

virtual void beginRendering ( )
overridevirtual

Starts a render pass for the current layer index. Called by CubeDepthRenderTarget::renderInternal.

Implements IRenderTarget.

◆ endRendering()

virtual void endRendering ( )
overridevirtual

Ends a render pass for the current layer index. Called by CubeDepthRenderTarget::renderInternal.

Implements IRenderTarget.

◆ getBufferSize()

virtual const glm::ivec2 getBufferSize ( ) const
overridevirtual
Returns
the size of the buffer in pixels

Implements IRenderTarget.

◆ getClearColor()

virtual const RGBAColorFloat& getClearColor ( ) const
overridevirtual
Returns
the currently used render target clear color.

Implements IRenderTarget.

◆ getColorFormat()

virtual VkFormat getColorFormat ( ) const
overridevirtual
Returns
render target color format.

Implements IRenderTarget.

◆ getDepthFormat()

virtual VkFormat getDepthFormat ( ) const
overridevirtual
Returns
render target depth format

Implements IRenderTarget.

◆ getRenderPass()

virtual VkRenderPass getRenderPass ( ) const
overridevirtual
Returns
the render pass

Implements IRenderTarget.

◆ getSampleCount()

virtual VkSampleCountFlagBits getSampleCount ( ) const
overridevirtual

Cube textures currently only support single sample render pass. Therefore, this function always returns VK_SAMPLE_COUNT_1_BIT.

Returns
used number of samples when rendering to the target.

Implements IRenderTarget.

◆ getSampleShadingEnabled()

virtual bool getSampleShadingEnabled ( ) const
overridevirtual
Returns
if sample based shading is enabled when rendering to the target.

Implements IRenderTarget.

◆ getSize()

glm::ivec2 getSize ( ) const
Returns
the absolute size of a single cube face in pixels.

◆ getWindingOrder()

virtual ECullWindingOrder getWindingOrder ( ) const
overridevirtual

Geometry winding order, defaults to clockwise.

Implements IRenderTarget.

◆ init()

virtual bool init ( utility::ErrorState errorState)
overridevirtual

Initializes the render target, including all the required resources.

Parameters
errorStatecontains the error if initialization failed.
Returns
if initialization succeeded.

Reimplemented from Object.

◆ render() [1/2]

void render ( CubeDepthRenderTargetCallback  renderCallback)

Renders objects to nap::DepthRenderTextureCube using the specified nap::CubeRenderTarget. Use 'renderCallback' to group the rendering work of a single render pass. This pass is repeated six times to create the resulting cube texture. The view and projection transformations are computed by nap::CubeRenderTarget and passed as arguments to a callback function. The following example demonstrates this using a lambda function:

if (mRenderService->beginHeadlessRecording())
{
cube_target->render([rs = mRenderService, comps = render_comps](CubeDepthRenderTarget& target, const glm::mat4& projection, const glm::mat4& view)
{
rs->renderObjects(target, projection, view, comps, std::bind(&sorter::sortObjectsByDepth, std::placeholders::_1, std::placeholders::_2));
});
mRenderService->endHeadlessRecording();
}

◆ render() [2/2]

void render ( PerspCameraComponentInstance camera,
CubeDepthRenderTargetCallback  renderCallback 
)

Renders objects to nap::DepthRenderTextureCube using the specified nap::CubeRenderTarget. Use 'renderCallback' to group the rendering work of a single render pass. This pass is repeated six times to create the resulting cube texture. The view and projection transformations are computed by nap::CubeRenderTarget and passed as arguments to a callback function. The following example demonstrates this using a lambda function:

if (mRenderService->beginHeadlessRecording())
{
cube_target->render(*persp_camera, [rs = mRenderService, comps = render_comps](CubeDepthRenderTarget& target, const glm::mat4& projection, const glm::mat4& view)
{
rs->renderObjects(target, projection, view, comps, std::bind(&sorter::sortObjectsByDepth, std::placeholders::_1, std::placeholders::_2));
});
mRenderService->endHeadlessRecording();
}

◆ setClearColor()

virtual void setClearColor ( const RGBAColorFloat color)
overridevirtual

Updates the render target clear color.

Parameters
colorthe new clear color to use.

Implements IRenderTarget.

Member Data Documentation

◆ mClearValue

float mClearValue = 1.0f

Property: 'ClearValue' value selection used for clearing the render target.

◆ mCubeDepthTexture

ResourcePtr<DepthRenderTextureCube> mCubeDepthTexture

Property: 'CubeDepthTexture' Cube depth texture to render to.

◆ mDepthFormat

Property: 'DepthFormat' the cube texture depth format.

◆ mRequestedSamples

Property: 'Samples' The number of samples used during Rasterization. For better results turn on 'SampleShading'.

◆ mSampleShading

bool mSampleShading = true

Property: 'SampleShading' Reduces texture aliasing when enabled, at higher computational cost.

nap::RenderService::beginHeadlessRecording
bool beginHeadlessRecording()
nap::RenderService::endHeadlessRecording
void endHeadlessRecording()
nap::sorter::sortObjectsByDepth
void NAPAPI sortObjectsByDepth(std::vector< RenderableComponentInstance * > &comps, const glm::mat4 &viewMatrix)
nap::CubeDepthRenderTarget::CubeDepthRenderTarget
CubeDepthRenderTarget(Core &core)