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

#include <depthrendertarget.h>

Public Member Functions

 DepthRenderTarget (Core &core)
 
 ~DepthRenderTarget ()
 
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 VkSampleCountFlagBits getSampleCount () const override
 
virtual bool getSampleShadingEnabled () const override
 
virtual VkFormat getColorFormat () const override
 
virtual VkFormat getDepthFormat () const override
 
DepthRenderTexture2DgetDepthTexture ()
 
- 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

float mClearValue = 1.0f
 Property: 'ClearValue' value selection used for clearing the render target. More...
 
bool mSampleShading = true
 Property: 'SampleShading' Reduces texture aliasing when enabled, at higher computational cost. More...
 
ERasterizationSamples mRequestedSamples = ERasterizationSamples::One
 Property: 'Samples' The number of samples used during Rasterization. For better results turn on 'SampleShading'. More...
 
ResourcePtr< DepthRenderTexture2DmDepthTexture
 Property: 'DepthTexture' 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

A resource that is used to render one or multiple objects to nap::DepthRenderTexture2D exclusively. Usage of this target creates a graphics pipeline that skips the fragment shader stage of all material instances.

This objects requires a link to a nap::DepthRenderTexture2D to store the result of the render pass. Only render to a render target within a headless recording pass, failure to do so will result in undefined behavior. Make sure to call beginRendering() to start the render pass and endRendering() to end the render pass. Always call RenderService::endHeadlessRecording after having recorded all off-screen render operations.

mRenderService->beginFrame();
if (mRenderService->beginHeadlessRecording())
{
...
mTargetOne->beginRendering();
mRenderService->renderObjects(*mTargetOne, ortho_cam, objects_one);
mTargetOne->endRendering();
...
mTargetTwo->beginRendering();
mRenderService->renderObjects(*mTargetTwo, ortho_cam, objects_two);
mTargetTwo->endRendering();
...
mRenderService->endHeadlessRecording();
}
mRenderService->endFrame();
Inheritance diagram for DepthRenderTarget:
[legend]
Collaboration diagram for DepthRenderTarget:
[legend]

Constructor & Destructor Documentation

◆ DepthRenderTarget()

DepthRenderTarget ( Core core)

Every render target requires a reference to core.

Parameters
corelink to a nap core instance

◆ ~DepthRenderTarget()

Destroys allocated render resources

Member Function Documentation

◆ beginRendering()

virtual void beginRendering ( )
overridevirtual

Starts the render pass. Only start the render pass after a successful call to RenderService::beginHeadlessRecording().

mRenderService->beginFrame();
if (mRenderService->beginHeadlessRecording())
{
...
mTarget->beginRendering();
mRenderService->renderObjects(*mTarget, ortho_cam, objects_one);
mTarget->endRendering();
...
mRenderService->endHeadlessRecording();
}
mRenderService->endFrame();

Implements IRenderTarget.

◆ endRendering()

virtual void endRendering ( )
overridevirtual

Ends the render pass. Always call this after beginRendering().

mRenderService->beginFrame();
if (mRenderService->beginHeadlessRecording())
{
...
mTarget->beginRendering();
mTarget->renderObjects(*mTarget, ortho_cam, objects_one);
mTarget->endRendering();
...
mRenderService->endHeadlessRecording();
}
mRenderService->endFrame();

Implements IRenderTarget.

◆ getBufferSize()

virtual const glm::ivec2 getBufferSize ( ) const
overridevirtual
Returns
size in pixels of the render target.

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
VK_FORMAT_UNDEFINED as the depth render target has no color attachment.

Implements IRenderTarget.

◆ getDepthFormat()

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

Implements IRenderTarget.

◆ getDepthTexture()

DepthRenderTexture2D& getDepthTexture ( )
Returns
the texture that holds the result of the render pass.

◆ getRenderPass()

virtual VkRenderPass getRenderPass ( ) const
overridevirtual
Returns
the render pass

Implements IRenderTarget.

◆ getSampleCount()

virtual VkSampleCountFlagBits getSampleCount ( ) const
overridevirtual
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.

◆ 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.

◆ setClearColor()

virtual void setClearColor ( const RGBAColorFloat color)
overridevirtual

Updates the render target clear value. Stores the red component of color as the clear value.

Parameters
colorthe new clear value to use.

Implements IRenderTarget.

Member Data Documentation

◆ mClearValue

float mClearValue = 1.0f

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

◆ mDepthTexture

Property: 'DepthTexture' depth texture to render to.

◆ 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::renderObjects
void renderObjects(IRenderTarget &renderTarget, CameraComponentInstance &camera, RenderMask renderMask=mask::all)
nap::RenderService::beginHeadlessRecording
bool beginHeadlessRecording()
nap::RenderService::beginFrame
void beginFrame()
nap::RenderService::endHeadlessRecording
void endHeadlessRecording()
nap::RenderService::endFrame
void endFrame()