NAP
Public Member Functions | Protected Member Functions | List of all members
RenderBloomComponentInstance Class Reference

#include <renderbloomcomponent.h>

Public Member Functions

 RenderBloomComponentInstance (EntityInstance &entity, Component &resource)
 
virtual bool init (utility::ErrorState &errorState) override
 
void draw ()
 
Texture2DgetOutputTexture ()
 
- Public Member Functions inherited from RenderableComponentInstance
 RenderableComponentInstance (EntityInstance &entity, Component &resource)
 
void draw (IRenderTarget &renderTarget, VkCommandBuffer commandBuffer, const glm::mat4 &viewMatrix, const glm::mat4 &projectionMatrix)
 
void setVisible (bool visible)
 
bool isVisible () const
 
const std::vector< ResourcePtr< RenderTag > > & getTags () const
 
RenderMask getMask () const
 
bool includesMask (RenderMask otherMask)
 
int getRank () const
 
const RenderLayergetLayer () const
 
virtual bool isSupported (nap::CameraComponentInstance &camera) const
 
- Public Member Functions inherited from ComponentInstance
 ComponentInstance (EntityInstance &entity, Component &resource)
 
virtual void update (double deltaTime)
 
nap::EntityInstancegetEntityInstance () const
 
nap::ComponentgetComponent () const
 
template<typename T >
T * getComponent () const
 
virtual bool init (utility::ErrorState &errorState)
 
- 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
 

Protected Member Functions

virtual void onDraw (IRenderTarget &renderTarget, VkCommandBuffer commandBuffer, const glm::mat4 &viewMatrix, const glm::mat4 &projectionMatrix) override
 

Additional Inherited Members

- Static Public Member Functions inherited from Object
static bool isIDProperty (rtti::Instance &object, const rtti::Property &property)
 
- Public Attributes inherited from Object
std::string mID
 Property: 'mID' unique name of the object. Used as an identifier by the system. More...
 
- Protected Attributes inherited from RenderableComponentInstance
RenderServicemRenderService = nullptr
 

Description

Pre- or post-processing effect that blurs the input texture at a downsampled resolution into internally managed rendertargets.

This component manages its own render target and plane to render to. The plane is automatically scaled to fit the bounds of the render target.

InputTexture is blitted to an internally managed render target, and then blurred based on the specified pass count. Each blur 'pass' then comprises two passes; horizontal and vertical. The gaussian sampling kernel size can be specified with the 'Kernel' property. Each subsequent pass performs a horizontal and vertical blur at half the resolution of the former pass, with the first being at half the resolution of InputTexture.

When the bloom passes have been completed, the result is blitted to OutputTexture. InputTexture and OutputTexture are allowed to refer to the same nap::RenderTexture.

Simply declare the component in json and call RenderBloomComponentInstance::draw() in the render part of your application, in between nap::RenderService::beginHeadlessRecording() and nap::RenderService::endHeadlessRecording().

This component uses the default naprender blur shader and automatically sets its shader variables based on this component's properties configuration.

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

Constructor & Destructor Documentation

◆ RenderBloomComponentInstance()

RenderBloomComponentInstance ( EntityInstance entity,
Component resource 
)

Member Function Documentation

◆ draw()

void draw ( )

Renders the effect to the output texture, without having to define a render target or mesh. Call this in your application render() call inbetween nap::RenderService::beginHeadlessRecording() and nap::RenderService::endHeadlessRecording(). Do not call this function outside of a headless recording pass i.e. when rendering to a window. The result is rendered into a dynamically created output texture, which is accessible through RenderBloomComponentInstance::getOutputTexture(). Alternatively, you can use the render service to render this component, see onDraw().

◆ getOutputTexture()

Texture2D& getOutputTexture ( )

Returns the output texture with the bloom effect applied. The size of this texture equals { input_width/2^PassCount, input_height/2^PassCount }

Returns
the bloom texture created from the specified input texture

◆ init()

virtual bool init ( utility::ErrorState errorState)
overridevirtual

Initialize RenderBloomComponentInstance based on the RenderBloomComponent resource.

Parameters
errorStateshould hold the error message when initialization fails
Returns
if the RenderBloomComponentInstance initialized successfully

Reimplemented from RenderableComponentInstance.

◆ onDraw()

virtual void onDraw ( IRenderTarget renderTarget,
VkCommandBuffer  commandBuffer,
const glm::mat4 &  viewMatrix,
const glm::mat4 &  projectionMatrix 
)
overrideprotectedvirtual

Draws the effect full screen to the currently active render target, when the view matrix = identity.

Parameters
renderTargetthe target to render to.
commandBufferthe currently active command buffer.
viewMatrixoften the camera world space location
projectionMatrixoften the camera projection matrix

Implements RenderableComponentInstance.