@@ -51,7 +51,7 @@ static const size_t DFG_LUT_DEFAULT_SIZE = 128;
51
51
static const size_t IBL_DEFAULT_SIZE = 256 ;
52
52
53
53
enum class OutputType {
54
- FACES, KTX, EQUIRECT
54
+ FACES, KTX, EQUIRECT, OCTAHEDRON
55
55
};
56
56
57
57
static image::ImageEncoder::Format g_format = image::ImageEncoder::Format::PNG;
@@ -140,7 +140,7 @@ static void printUsage(char* name) {
140
140
" Print copyright and license information\n\n "
141
141
" --quiet, -q\n "
142
142
" Quiet mode. Suppress all non-error output\n\n "
143
- " --type=[faces|equirect|ktx], -t [cubemap|equirect|ktx]\n "
143
+ " --type=[faces|equirect|octahedron| ktx], -t [cubemap|equirect|octahedron |ktx]\n "
144
144
" Specify output type (default: cubemap)\n\n "
145
145
" --format=[exr|hdr|psd|rgbm|png|dds|ktx], -f [exr|hdr|psd|rgbm|png|dds|ktx]\n "
146
146
" Specify output file format. ktx implies -type=ktx.\n\n "
@@ -261,6 +261,10 @@ static int handleCommandLineArgments(int argc, char* argv[]) {
261
261
g_type = OutputType::EQUIRECT;
262
262
type_specified = true ;
263
263
}
264
+ if (arg == " octahedron" ) {
265
+ g_type = OutputType::OCTAHEDRON;
266
+ type_specified = true ;
267
+ }
264
268
break ;
265
269
case ' f' :
266
270
if (arg == " png" ) {
@@ -758,6 +762,16 @@ void iblMipmapPrefilter(const utils::Path& iname,
758
762
continue ;
759
763
}
760
764
765
+ if (g_type == OutputType::OCTAHEDRON) {
766
+ size_t dim = dst.getDimensions ();
767
+ std::unique_ptr<uint8_t []> buf (new uint8_t [dim * dim * sizeof (float3)]);
768
+ Image image (std::move (buf), dim, dim, dim * sizeof (float3), sizeof (float3));
769
+ CubemapUtils::cubemapToOctahedron (image, dst);
770
+ std::string filename = outputDir + (" is_m" + std::to_string (level) + ext);
771
+ saveImage (filename, g_format, image, g_compression);
772
+ continue ;
773
+ }
774
+
761
775
for (size_t i = 0 ; i < 6 ; i++) {
762
776
Cubemap::Face face = (Cubemap::Face)i;
763
777
std::string filename = outputDir
@@ -850,6 +864,15 @@ void iblRoughnessPrefilter(const utils::Path& iname,
850
864
continue ;
851
865
}
852
866
867
+ if (g_type == OutputType::OCTAHEDRON) {
868
+ std::unique_ptr<uint8_t []> buf (new uint8_t [dim * dim * sizeof (float3)]);
869
+ Image image (std::move (buf), dim, dim, dim * sizeof (float3), sizeof (float3));
870
+ CubemapUtils::cubemapToOctahedron (image, dst);
871
+ std::string filename = outputDir + (" m" + std::to_string (level) + ext);
872
+ saveImage (filename, g_format, image, g_compression);
873
+ continue ;
874
+ }
875
+
853
876
for (size_t j = 0 ; j < 6 ; j++) {
854
877
Cubemap::Face face = (Cubemap::Face) j;
855
878
std::string filename = outputDir
@@ -1017,6 +1040,16 @@ void extractCubemapFaces(const utils::Path& iname, const Cubemap& cm, const util
1017
1040
return ;
1018
1041
}
1019
1042
1043
+ if (g_type == OutputType::OCTAHEDRON) {
1044
+ size_t dim = cm.getDimensions ();
1045
+ std::unique_ptr<uint8_t []> buf (new uint8_t [dim * dim * sizeof (float3)]);
1046
+ Image image (std::move (buf), dim, dim, dim * sizeof (float3), sizeof (float3));
1047
+ CubemapUtils::cubemapToOctahedron (image, cm);
1048
+ std::string filename = outputDir + (" skybox" + ext);
1049
+ saveImage (filename, g_format, image, g_compression);
1050
+ return ;
1051
+ }
1052
+
1020
1053
for (size_t i = 0 ; i < 6 ; i++) {
1021
1054
Cubemap::Face face = (Cubemap::Face) i;
1022
1055
std::string filename (outputDir + (CubemapUtils::getFaceName (face) + ext));
0 commit comments