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

#include <snapshot.h>

Public Member Functions

 Snapshot (Core &core)
 
virtual bool init (utility::ErrorState &errorState) override
 
void setClearColor (const RGBAColorFloat &color)
 
void snap (PerspCameraComponentInstance &camera, std::vector< RenderableComponentInstance * > &comps)
 
void snap (PerspCameraComponentInstance &camera, std::function< void(nap::SnapshotRenderTarget &)> renderCallback)
 
glm::u32vec2 getSize ()
 
- 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

uint32 mWidth = 1920
 Property: 'Width' width of the snapshot in texels. More...
 
uint32 mHeight = 1080
 Property: 'Height' height of the snapshot in texels. More...
 
uint32 mDivisor = 1
 Property: 'Divisor' subdivides the texture equally over multiple cells. More...
 
RGBAColorFloat mClearColor = { 0.0f, 0.0f, 0.0f, 0.0f }
 Property: 'ClearColor' color selection used for clearing the render target. More...
 
RenderTexture2D::EFormat mTextureFormat = RenderTexture2D::EFormat::RGBA8
 Property: 'Format' texture format. More...
 
ERasterizationSamples mRequestedSamples = ERasterizationSamples::Four
 Property: 'Samples' The number of samples used during Rasterization. For better results turn on 'SampleShading'. More...
 
bool mSampleShading = true
 Property: 'SampleShading' Reduces texture aliasing when enabled, at higher computational cost. More...
 
std::string mOutputDirectory = "snapshots"
 Property: 'OutputDirectory' Location of the directory where snapshots are saved to, defaults to 'data'. More...
 
BitmapFileBuffer::EImageFileFormat mImageFileFormat = BitmapFileBuffer::EImageFileFormat::PNG
 Property: 'ImageFormat' Image format of the snapshot image file. More...
 
nap::Signal onSnapshot
 
nap::Signal< std::string > onSnapshotSaved
 
- 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

RenderServicemRenderService = nullptr
 

Additional Inherited Members

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

Description

The Snapshot module renders objects at any given resolution and format and saves the result to a specified location on disk (as long as its configuration is supported by the hardware and sufficient video memory is available).

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

Constructor & Destructor Documentation

◆ Snapshot()

Snapshot ( Core core)

Member Function Documentation

◆ getSize()

glm::u32vec2 getSize ( )

Returns the size of the snapshot

Returns
the size of the snapshot

◆ init()

virtual bool init ( utility::ErrorState errorState)
overridevirtual

Initialize this object after de-serialization

Parameters
errorStatecontains the error message when initialization fails

Reimplemented from Object.

◆ setClearColor()

void setClearColor ( const RGBAColorFloat color)

Updates the render target clear color.

Parameters
colorthe new clear color to use.

◆ snap() [1/2]

void snap ( PerspCameraComponentInstance camera,
std::function< void(nap::SnapshotRenderTarget &)>  renderCallback 
)

Takes a high-res snapshot using a callback and saves the result to a location on disk. This call gives you more freedom in setting up your own render commands compared to the call above, which assumes you're rendering a fixed number of components through the render service.

Make sure begin a headless recording in the render service e.g.

{
...
mSnapShot->snap(camera, callback);
}
Parameters
cameracamera to take snapshot with
renderCallbackfunction that is called when snapshot is taken.

◆ snap() [2/2]

void snap ( PerspCameraComponentInstance camera,
std::vector< RenderableComponentInstance * > &  comps 
)

Takes a high-res snapshot and saves the result to a location on disk. Make sure to begin a headless recording in the render service e.g.

{
...
mSnapShot->snap(camera, components_to_render);
}
Parameters
cameraCamera to take snapshot with
compsComponents to render

Member Data Documentation

◆ mClearColor

RGBAColorFloat mClearColor = { 0.0f, 0.0f, 0.0f, 0.0f }

Property: 'ClearColor' color selection used for clearing the render target.

◆ mDivisor

uint32 mDivisor = 1

Property: 'Divisor' subdivides the texture equally over multiple cells.

◆ mHeight

uint32 mHeight = 1080

Property: 'Height' height of the snapshot in texels.

◆ mImageFileFormat

Property: 'ImageFormat' Image format of the snapshot image file.

◆ mOutputDirectory

std::string mOutputDirectory = "snapshots"

Property: 'OutputDirectory' Location of the directory where snapshots are saved to, defaults to 'data'.

◆ mRenderService

RenderService* mRenderService = nullptr
protected

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

◆ mTextureFormat

Property: 'Format' texture format.

◆ mWidth

uint32 mWidth = 1920

Property: 'Width' width of the snapshot in texels.

◆ onSnapshot

nap::Signal onSnapshot

◆ onSnapshotSaved

nap::Signal<std::string> onSnapshotSaved
nap::RenderService::beginHeadlessRecording
bool beginHeadlessRecording()
nap::RenderService::beginFrame
void beginFrame()
nap::Snapshot::mRenderService
RenderService * mRenderService
Definition: snapshot.h:114
nap::RenderService::endHeadlessRecording
void endHeadlessRecording()