NAP
nap
system_modules
naprender
src
renderbloomcomponent.h
1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
* License, v. 2.0. If a copy of the MPL was not distributed with this
3
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
5
#pragma once
6
7
// Local Includes
8
#include "rendertotexturecomponent.h"
9
#include "blurshader.h"
10
11
namespace
nap
12
{
13
// Forward Declares
14
class
RenderBloomComponentInstance;
15
22
class
NAPAPI
RenderBloomComponent
:
public
RenderableComponent
23
{
24
RTTI_ENABLE(
RenderableComponent
)
25
DECLARE_COMPONENT(
RenderBloomComponent
,
RenderBloomComponentInstance
)
26
public
:
27
ResourcePtr<RenderTexture2D>
mInputTexture =
nullptr
;
28
ResourcePtr<RenderTexture2D>
mOutputTexture =
nullptr
;
29
EBlurSamples
mKernel =
EBlurSamples::X5
;
30
uint
mPassCount = 1;
31
};
32
33
55
class
NAPAPI
RenderBloomComponentInstance
:
public
RenderableComponentInstance
56
{
57
RTTI_ENABLE(
RenderableComponentInstance
)
58
public
:
59
RenderBloomComponentInstance
(
EntityInstance
& entity,
Component
& resource);
60
66
virtual
bool
init(
utility::ErrorState
& errorState)
override
;
67
77
void
draw();
78
84
Texture2D
&
getOutputTexture
() {
return
*mOutputTexture; }
85
86
protected
:
95
virtual
void
onDraw(
IRenderTarget
& renderTarget, VkCommandBuffer commandBuffer,
const
glm::mat4& viewMatrix,
const
glm::mat4& projectionMatrix)
override
;
96
97
private
:
98
using
DoubleBufferedRenderTexture2D = std::array<std::unique_ptr<RenderTexture2D>, 2>;
99
using
DoubleBufferedRenderTarget = std::array<std::unique_ptr<RenderTarget>, 2>;
100
101
RenderService
* mRenderService =
nullptr
;
102
RenderTexture2D
* mInputTexture =
nullptr
;
103
RenderTexture2D
* mOutputTexture =
nullptr
;
104
105
std::vector<DoubleBufferedRenderTexture2D> mBloomTextures;
106
std::vector<DoubleBufferedRenderTarget> mBloomRTs;
107
108
MaterialInstanceResource
mMaterialInstanceResource;
109
MaterialInstance
mMaterialInstance;
110
111
RenderableMesh
mRenderableMesh;
112
nap::PlaneMesh
mPlane;
113
114
glm::mat4x4 mModelMatrix;
115
116
UniformMat4Instance
* mModelMatrixUniform =
nullptr
;
117
UniformMat4Instance
* mProjectMatrixUniform =
nullptr
;
118
UniformMat4Instance
* mViewMatrixUniform =
nullptr
;
119
UniformStructInstance
* mMVPStruct =
nullptr
;
120
121
Sampler2DInstance
* mColorTextureSampler =
nullptr
;
122
UniformVec2Instance
* mDirectionUniform =
nullptr
;
123
UniformVec2Instance
* mTextureSizeUniform =
nullptr
;
124
129
UniformMat4Instance
* ensureUniform(
const
std::string& uniformName,
nap::UniformStructInstance
& mvpStruct,
utility::ErrorState
& error);
130
};
131
}
nap::uint
unsigned int uint
Definition:
numeric.h:23
nap::RenderableComponentInstance
Definition:
rendercomponent.h:46
nap::IRenderTarget
Definition:
irendertarget.h:21
nap::RenderBloomComponent
Definition:
renderbloomcomponent.h:22
nap::RenderBloomComponentInstance::getOutputTexture
Texture2D & getOutputTexture()
Definition:
renderbloomcomponent.h:84
nap::rtti::ObjectPtr
Definition:
objectptr.h:154
nap::utility::ErrorState
Definition:
errorstate.h:19
nap::Texture2D
Definition:
texture.h:128
nap::RenderService
Definition:
renderservice.h:275
nap::EntityInstance
Definition:
entity.h:34
nap::RenderableComponent
Definition:
rendercomponent.h:29
nap::RenderBloomComponentInstance
Definition:
renderbloomcomponent.h:55
nap::Component
Definition:
component.h:151
nap::RenderableMesh
Definition:
renderablemesh.h:22
nap::MaterialInstance
Definition:
materialinstance.h:297
nap::EBlurSamples
EBlurSamples
Definition:
blurshader.h:17
nap
Definition:
templateapp.h:17
nap::UniformStructInstance
Definition:
uniforminstance.h:53
nap::TypedUniformValueInstance
Definition:
uniforminstance.h:243
nap::Sampler2DInstance
Definition:
samplerinstance.h:93
nap::EBlurSamples::X5
@ X5
5x5 kernel, linear sampling
nap::PlaneMesh
Definition:
planemesh.h:26
nap::MaterialInstanceResource
Definition:
materialinstance.h:68
nap::RenderTexture2D
Definition:
rendertexture2d.h:24
Generated by doxygen