NAP
sampler.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 "samplerdeclaration.h"
9 
10 // External Includes
11 #include <rtti/objectptr.h>
12 #include <utility/dllexport.h>
13 #include <nap/resource.h>
14 #include <nap/numeric.h>
15 
16 namespace nap
17 {
18  // Forward Declares
19  class Texture2D;
20  class SamplerInstance;
21  class RenderService;
22 
26  enum class EFilterMode : uint32
27  {
28  Nearest = 0,
29  Linear
30  };
31 
35  enum class EAddressMode : uint32
36  {
37  Repeat = 0,
39  ClampToEdge,
41  };
42 
43 
48  {
49  Default = 0,
50  Four = 4,
51  Eight = 8,
52  Sixteen = 16
53  };
54 
55 
57  // Sampler
59 
63  class NAPAPI Sampler : public Resource
64  {
65  RTTI_ENABLE(Resource)
66  public:
67  Sampler() = default;
68 
69  std::string mName;
73  EAddressMode mAddressModeVertical = EAddressMode::ClampToEdge;
74  EAddressMode mAddressModeHorizontal = EAddressMode::ClampToEdge;
76  uint32 mMaxLodLevel = 1000;
77  };
78 
79 
81  // Sampler2D
83 
93  class NAPAPI Sampler2D : public Sampler
94  {
95  RTTI_ENABLE(Sampler)
96  public:
97  Sampler2D() = default;
98  rtti::ObjectPtr<Texture2D> mTexture = nullptr;
99  };
100 
101 
103  // SamplerArray
105 
109  class NAPAPI SamplerArray : public Sampler
110  {
111  RTTI_ENABLE(Sampler)
112 
113  public:
118  virtual int getNumElements() const = 0;
119  };
120 
121 
131  class NAPAPI Sampler2DArray : public SamplerArray
132  {
133  RTTI_ENABLE(SamplerArray)
134  public:
135 
136  Sampler2DArray() = default;
137  Sampler2DArray(int inSize) :
138  mTextures(inSize) { }
139 
143  virtual int getNumElements() const override { return mTextures.size(); }
144 
145  std::vector<rtti::ObjectPtr<Texture2D>> mTextures;
146  };
147 }
nap::Sampler2DArray::Sampler2DArray
Sampler2DArray(int inSize)
Definition: sampler.h:137
nap::SamplerArray
Definition: sampler.h:109
nap::EFilterMode::Nearest
@ Nearest
Nearest sampling.
nap::EAnisotropicSamples::Four
@ Four
Four samples.
nap::Sampler2DArray::mTextures
std::vector< rtti::ObjectPtr< Texture2D > > mTextures
Property: 'Textures' textures to bind, must be of the same length as the shader declaration.
Definition: sampler.h:145
nap::Sampler2D
Definition: sampler.h:93
nap::rtti::ObjectPtr
Definition: objectptr.h:184
nap::EAnisotropicSamples::Sixteen
@ Sixteen
Sixteen samples.
nap::EAnisotropicSamples
EAnisotropicSamples
Definition: sampler.h:47
nap::EAddressMode::ClampToBorder
@ ClampToBorder
ClampToBorder.
nap::EAnisotropicSamples::Eight
@ Eight
Eight samples.
nap::EFilterMode
EFilterMode
Definition: sampler.h:26
nap::Sampler::mName
std::string mName
Property: 'Name' sampler shader name.
Definition: sampler.h:69
nap::Sampler
Definition: sampler.h:63
nap::uint32
uint32_t uint32
Definition: numeric.h:20
nap::Sampler2DArray
Definition: sampler.h:131
nap::Sampler2DArray::getNumElements
virtual int getNumElements() const override
Definition: sampler.h:143
nap::EAddressMode::Repeat
@ Repeat
Repeat.
nap::EAddressMode::ClampToEdge
@ ClampToEdge
ClampToEdge.
nap::EAddressMode::MirroredRepeat
@ MirroredRepeat
MirroredRepeat.
nap
Definition: assert.h:10
nap::Resource
Definition: resource.h:19
nap::EAnisotropicSamples::Default
@ Default
Pick system default, as defined by the render service configuration.
nap::EFilterMode::Linear
@ Linear
Linear sampling.
nap::EAddressMode
EAddressMode
Definition: sampler.h:35