Skip to content

Commit 5bf0814

Browse files
AnastaZIukCrisspl
authored andcommitted
use pitch, move derivative map creation to utilities
1 parent e23c674 commit 5bf0814

File tree

3 files changed

+35
-17
lines changed

3 files changed

+35
-17
lines changed

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,9 @@
9999
[submodule "3rdparty/volk"]
100100
path = 3rdparty/volk
101101
url = https://github.com/zeux/volk.git
102+
[submodule "3rdparty/simdjson"]
103+
path = 3rdparty/simdjson
104+
url = https://github.com/simdjson/simdjson
105+
[submodule "3rdparty/glTFSampleModels"]
106+
path = 3rdparty/glTFSampleModels
107+
url = https://github.com/KhronosGroup/glTF-Sample-Models

include/nbl/asset/utils/CDerivativeMapCreator.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include "nbl/asset/ICPUImage.h"
55
#include "nbl/asset/ICPUImageView.h"
6+
#include "nbl/asset/filters/CNormalMapToDerivativeFilter.h"
67

78
namespace nbl {
89
namespace asset
@@ -16,6 +17,30 @@ class CDerivativeMapCreator
1617

1718
static core::smart_refctd_ptr<asset::ICPUImage> createDerivativeMapFromHeightMap(asset::ICPUImage* _inImg, asset::ISampler::E_TEXTURE_CLAMP _uwrap, asset::ISampler::E_TEXTURE_CLAMP _vwrap, asset::ISampler::E_TEXTURE_BORDER_COLOR _borderColor);
1819
static core::smart_refctd_ptr<asset::ICPUImageView> createDerivativeMapViewFromHeightMap(asset::ICPUImage* _inImg, asset::ISampler::E_TEXTURE_CLAMP _uwrap, asset::ISampler::E_TEXTURE_CLAMP _vwrap, asset::ISampler::E_TEXTURE_BORDER_COLOR _borderColor);
20+
21+
static core::smart_refctd_ptr<asset::ICPUImage> createDerivativeMapFromNormalMap(asset::ICPUImage* _inImg);
22+
static core::smart_refctd_ptr<asset::ICPUImageView> createDerivativeMapViewFromNormalMap(asset::ICPUImage* _inImg);
23+
24+
private:
25+
26+
static inline asset::E_FORMAT getRGformat(asset::E_FORMAT f)
27+
{
28+
const uint32_t bytesPerChannel = (getBytesPerPixel(f) * core::rational(1, getFormatChannelCount(f))).getIntegerApprox();
29+
30+
switch (bytesPerChannel)
31+
{
32+
case 1u:
33+
return asset::EF_R8G8_SNORM;
34+
case 2u:
35+
return asset::EF_R16G16_SNORM;
36+
case 4u:
37+
return asset::EF_R32G32_SFLOAT;
38+
case 8u:
39+
return asset::EF_R64G64_SFLOAT;
40+
default:
41+
return asset::EF_UNKNOWN;
42+
}
43+
};
1944
};
2045

2146
}

src/nbl/asset/utils/CDerivativeMapCreator.cpp

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -124,23 +124,6 @@ core::smart_refctd_ptr<asset::ICPUImage> nbl::asset::CDerivativeMapCreator::crea
124124
{
125125
using namespace asset;
126126

127-
auto getRGformat = [](asset::E_FORMAT f) -> asset::E_FORMAT {
128-
const uint32_t bytesPerChannel = (getBytesPerPixel(f) * core::rational(1, getFormatChannelCount(f))).getIntegerApprox();
129-
switch (bytesPerChannel)
130-
{
131-
case 1u:
132-
return asset::EF_R8G8_SNORM;
133-
case 2u:
134-
return asset::EF_R16G16_SNORM;
135-
case 4u:
136-
return asset::EF_R32G32_SFLOAT;
137-
case 8u:
138-
return asset::EF_R64G64_SFLOAT;
139-
default:
140-
return asset::EF_UNKNOWN;
141-
}
142-
};
143-
144127
using ReconstructionKernel = CGaussianImageFilterKernel<>; // or Mitchell
145128
using DerivKernel_ = CDerivativeImageFilterKernel<ReconstructionKernel>;
146129
using DerivKernel = MyKernel<DerivKernel_>;
@@ -262,7 +245,11 @@ core::smart_refctd_ptr<asset::ICPUImage> nbl::asset::CDerivativeMapCreator::crea
262245
newDerivativeNormalMapImage = ICPUImage::create(std::move(newImageParams));
263246
newDerivativeNormalMapImage->setBufferAndRegions(std::move(newCpuBuffer), core::make_refctd_dynamic_array<core::smart_refctd_dynamic_array<IImage::SBufferCopy>>(1ull, region));
264247

248+
<<<<<<< HEAD
265249
using DerivativeNormalMapFilter = CNormalMapToDerivativeFilter<asset::DefaultSwizzle, asset::IdentityDither>;
250+
=======
251+
using DerivativeNormalMapFilter = CNormalMapToDerivativeFilter<asset::DefaultSwizzle>;
252+
>>>>>>> 8a7153aa... use pitch, move derivative map creation to utilities
266253
DerivativeNormalMapFilter derivativeNormalFilter;
267254
DerivativeNormalMapFilter::state_type state;
268255

0 commit comments

Comments
 (0)