NAP
Public Attributes | List of all members
RenderToTextureComponent Class Reference

#include <rendertotexturecomponent.h>

Public Attributes

ResourcePtr< RenderTexture2DmOutputTexture = nullptr
 Property: 'OutputTexture' the target of the render step. More...
 
MaterialInstanceResource mMaterialInstanceResource
 Property: 'MaterialInstance' instance of the material, used to override uniforms for this instance. More...
 
ERasterizationSamples mRequestedSamples = ERasterizationSamples::One
 Property: 'Samples' The number of samples used during Rasterization. For better results enable 'SampleShading'. More...
 
RGBAColor8 mClearColor = { 255, 255, 255, 255 }
 Property: 'ClearColor' the color that is used to clear the render target. More...
 
bool mSampleShading = true
 Property: 'SampleShading' Reduces texture aliasing when enabled, at higher computational cost. More...
 
bool mPreserveAspect = false
 Property: 'PreserveAspect' Whether to preserve the texture aspect ratio. More...
 
- Public Attributes inherited from RenderableComponent
bool mVisible = true
 Property: 'Visible' if this object is rendered to target by the render service. More...
 
ResourcePtr< RenderLayermLayer
 Property: 'Layer' the render layer assigned to this component. More...
 
std::vector< ResourcePtr< RenderTag > > mTags
 Property: 'Tags' List of tags specifying the category this render component belongs 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

- Public Member Functions inherited from Component
virtual void getDependentComponents (std::vector< rtti::TypeInfo > &components) const
 
virtual const rtti::TypeInfo getInstanceType () const =0
 
- Public Member Functions inherited from Resource
 Resource ()
 
- Public Member Functions inherited from Object
 Object ()
 
virtual ~Object ()
 
virtual bool init (utility::ErrorState &errorState)
 
virtual void onDestroy ()
 
 Object (Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&)=delete
 
Objectoperator= (Object &&)=delete
 
- Static Public Member Functions inherited from Object
static bool isIDProperty (rtti::Instance &object, const rtti::Property &property)
 

Description

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().

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.

uniform nap
{
uniform mat4 projectionMatrix;
uniform mat4 modelMatrix;
} mvp;
...
void main(void)
{
gl_Position = mvp.projectionMatrix * mvp.modelMatrix;
}
Inheritance diagram for RenderToTextureComponent:
[legend]
Collaboration diagram for RenderToTextureComponent:
[legend]

Member Data Documentation

◆ mClearColor

RGBAColor8 mClearColor = { 255, 255, 255, 255 }

Property: 'ClearColor' the color that is used to clear the render target.

◆ mMaterialInstanceResource

MaterialInstanceResource mMaterialInstanceResource

Property: 'MaterialInstance' instance of the material, used to override uniforms for this instance.

◆ mOutputTexture

ResourcePtr<RenderTexture2D> mOutputTexture = nullptr

Property: 'OutputTexture' the target of the render step.

◆ mPreserveAspect

bool mPreserveAspect = false

Property: 'PreserveAspect' Whether to preserve the texture aspect ratio.

◆ mRequestedSamples

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

◆ mSampleShading

bool mSampleShading = true

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

nap::shader::main
constexpr const char * main
Definition: renderglobals.h:29
nap::uniform::modelMatrix
constexpr const char * modelMatrix
uniform model matrix name
Definition: renderglobals.h:56
nap
Definition: templateapp.h:17
nap::uniform::projectionMatrix
constexpr const char * projectionMatrix
uniform projection matrix name
Definition: renderglobals.h:58