NAP
depthrendertarget.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 "irendertarget.h"
9 #include "texturelink.h"
10 
11 // External Includes
12 #include <nap/resource.h>
13 #include <nap/resourceptr.h>
14 #include <vulkan/vulkan_core.h>
15 
16 namespace nap
17 {
18  // Forward Declares
19  class DepthRenderTexture2D;
20  class RenderService;
21 
50  class NAPAPI DepthRenderTarget : public Resource, public IRenderTarget
51  {
52  RTTI_ENABLE(Resource)
53  public:
58  DepthRenderTarget(Core& core);
59 
64 
70  virtual bool init(utility::ErrorState& errorState) override;
71 
90  virtual void beginRendering() override;
91 
109  virtual void endRendering() override;
110 
114  virtual const glm::ivec2 getBufferSize() const override;
115 
120  virtual void setClearColor(const RGBAColorFloat& color) override { mClearValue = color.getRed(); }
121 
125  virtual const RGBAColorFloat& getClearColor() const override { return mClearColor; }
126 
131 
135  virtual VkRenderPass getRenderPass() const override { return mRenderPass; }
136 
140  virtual VkSampleCountFlagBits getSampleCount() const override { return mRasterizationSamples; }
141 
145  virtual bool getSampleShadingEnabled() const override { return false; };
146 
150  virtual VkFormat getColorFormat() const override { return VK_FORMAT_UNDEFINED; }
151 
155  virtual VkFormat getDepthFormat() const override;
156 
160  virtual VkImageLayout getFinalLayout() const override { return VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; }
161 
165  DepthRenderTexture2D& getDepthTexture();
166 
167  public:
168  float mClearValue = 1.0f;
169  bool mSampleShading = true;
172 
173  private:
174  RenderService* mRenderService;
175  VkFramebuffer mFramebuffer = VK_NULL_HANDLE;
176  VkRenderPass mRenderPass = VK_NULL_HANDLE;
177  VkSampleCountFlagBits mRasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
178  ImageData mDepthImage;
179  RGBAColorFloat mClearColor = { 1.0f, 1.0f, 1.0f, 1.0f };
180  Texture2DTargetLink mTextureTargetLink;
181  };
182 }
nap::ECullWindingOrder::Clockwise
@ Clockwise
nap::IRenderTarget
Definition: irendertarget.h:21
nap::DepthRenderTarget::getRenderPass
virtual VkRenderPass getRenderPass() const override
Definition: depthrendertarget.h:135
nap::DepthRenderTarget::getSampleShadingEnabled
virtual bool getSampleShadingEnabled() const override
Definition: depthrendertarget.h:145
nap::DepthRenderTexture2D
Definition: rendertexture2d.h:67
nap::ERasterizationSamples::One
@ One
nap::ERasterizationSamples
ERasterizationSamples
Definition: renderutils.h:25
nap::RGBAColor< float >
nap::rtti::ObjectPtr
Definition: objectptr.h:150
nap::ECullWindingOrder
ECullWindingOrder
Definition: materialcommon.h:30
nap::utility::ErrorState
Definition: errorstate.h:19
nap::DepthRenderTarget::getSampleCount
virtual VkSampleCountFlagBits getSampleCount() const override
Definition: depthrendertarget.h:140
nap::DepthRenderTarget::mDepthTexture
ResourcePtr< DepthRenderTexture2D > mDepthTexture
Property: 'DepthTexture' depth texture to render to.
Definition: depthrendertarget.h:171
nap::DepthRenderTarget
Definition: depthrendertarget.h:50
nap::DepthRenderTarget::getWindingOrder
virtual ECullWindingOrder getWindingOrder() const override
Definition: depthrendertarget.h:130
nap::DepthRenderTarget::getClearColor
virtual const RGBAColorFloat & getClearColor() const override
Definition: depthrendertarget.h:125
nap::ImageData
Definition: imagedata.h:23
nap::DepthRenderTarget::setClearColor
virtual void setClearColor(const RGBAColorFloat &color) override
Definition: depthrendertarget.h:120
nap::RenderService
Definition: renderservice.h:198
nap::Core
Definition: core.h:82
nap::DepthRenderTarget::getColorFormat
virtual VkFormat getColorFormat() const override
Definition: depthrendertarget.h:150
nap
Definition: templateapp.h:17
nap::Resource
Definition: resource.h:19
nap::DepthRenderTarget::getFinalLayout
virtual VkImageLayout getFinalLayout() const override
Definition: depthrendertarget.h:160