#include <rendertotexturecomponent.h>
Public Member Functions | |
RenderToTextureComponentInstance (EntityInstance &entity, Component &resource) | |
virtual bool | init (utility::ErrorState &errorState) override |
IRenderTarget & | getTarget () |
Texture2D & | getOutputTexture () |
void | draw () |
virtual bool | isSupported (nap::CameraComponentInstance &camera) const override |
MaterialInstance & | getMaterialInstance () |
void | setPreserveAspect (bool preserveAspect) |
![]() | |
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 |
![]() | |
ComponentInstance (EntityInstance &entity, Component &resource) | |
virtual void | update (double deltaTime) |
nap::EntityInstance * | getEntityInstance () const |
nap::Component * | getComponent () const |
template<typename T > | |
T * | getComponent () const |
![]() | |
Object () | |
virtual | ~Object () |
virtual void | onDestroy () |
Object (Object &)=delete | |
Object & | operator= (const Object &)=delete |
Object (Object &&)=delete | |
Object & | operator= (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 bool | isIDProperty (rtti::Instance &object, const rtti::Property &property) |
![]() | |
std::string | mID |
Property: 'mID' unique name of the object. Used as an identifier by the system. More... | |
Renders an effect directly to a texture using a custom material without having to define a render target or mesh. Use this component as a post process render step. 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.
Simply declare the component in json and call RenderToTextureComponentInstance::draw() in the render part of your application, in between nap::RenderService::beginHeadlessRecording() and nap::RenderService::endHeadlessRecording(). It is still possible to render this component through the render service, although only orthographic cameras are supported.
This component expects a material with a shader that contains both a model and projection matrix uniform. The view matrix uniform is optional. It will be set if found, otherwise bypassed. If you don't care about view space (camera) transformation, don't declare it in the shader. for example:
RenderToTextureComponentInstance | ( | EntityInstance & | entity, |
Component & | resource | ||
) |
void draw | ( | ) |
Renders the effect directly to texture using a custom material, without having to define a render target or mesh. Call this in your application render() call, in between nap::RenderService::beginHeadlessRecording() and nap::RenderService::endHeadlessRecording(). Do not call this function outside of a headless recording pass, ie: when rendering to a window. The result is rendered into the given output texture. Alternatively, you can use the render service to render this component, see onDraw()
MaterialInstance& getMaterialInstance | ( | ) |
Texture2D& getOutputTexture | ( | ) |
IRenderTarget& getTarget | ( | ) |
|
overridevirtual |
Initialize RenderToTextureComponentInstance based on the RenderToTextureComponent resource
errorState | should hold the error message when initialization fails |
Reimplemented from RenderableComponentInstance.
|
overridevirtual |
Called by the Render Service. Only orthographic cameras are supported.
Reimplemented from RenderableComponentInstance.
|
overrideprotectedvirtual |
Draws the effect full screen to the currently active render target, when the view matrix = identity.
renderTarget | the target to render to. |
commandBuffer | the currently active command buffer. |
viewMatrix | often the camera world space location |
projectionMatrix | often the camera projection matrix |
Implements RenderableComponentInstance.
void setPreserveAspect | ( | bool | preserveAspect | ) |
Sets whether to preserve the texture aspect ratio when rendering to the target