@@ -149,7 +149,6 @@ std::string ComputeFileHash(const std::string& filepath)
149149 return md5Hash;
150150}
151151
152- #ifndef __EMSCRIPTEN__
153152// ----------------------------------------------------------------------------
154153// Download texture from the GPU to a vtkImageData
155154vtkSmartPointer<vtkImageData> SaveTextureToImage (
@@ -174,7 +173,6 @@ vtkSmartPointer<vtkImageData> SaveTextureToImage(
174173
175174 return img;
176175}
177- #endif
178176
179177// ----------------------------------------------------------------------------
180178// TODO : add this function in a utils file for rendering in VTK directly
@@ -1312,16 +1310,17 @@ void vtkF3DRenderer::ConfigureHDRILUT()
13121310 }
13131311 assert (lut->GetTextureObject ());
13141312
1315- #ifndef __EMSCRIPTEN__
1316- vtkSmartPointer<vtkImageData> img = ::SaveTextureToImage (
1317- lut->GetTextureObject (), GL_TEXTURE_2D, 0 , lut->GetLUTSize (), VTK_UNSIGNED_SHORT);
1318- assert (img);
1313+ if (!this ->CachePath .empty ())
1314+ {
1315+ vtkSmartPointer<vtkImageData> img = ::SaveTextureToImage (
1316+ lut->GetTextureObject (), GL_TEXTURE_2D, 0 , lut->GetLUTSize (), VTK_UNSIGNED_SHORT);
1317+ assert (img);
13191318
1320- vtkNew<vtkXMLImageDataWriter> writer;
1321- writer->SetFileName (lutCachePath.c_str ());
1322- writer->SetInputData (img);
1323- writer->Write ();
1324- # endif
1319+ vtkNew<vtkXMLImageDataWriter> writer;
1320+ writer->SetFileName (lutCachePath.c_str ());
1321+ writer->SetInputData (img);
1322+ writer->Write ();
1323+ }
13251324 }
13261325 this ->HasValidHDRILUT = true ;
13271326 }
@@ -1356,16 +1355,17 @@ void vtkF3DRenderer::ConfigureHDRISphericalHarmonics()
13561355 vtkTable::SafeDownCast (sh->GetOutputDataObject (0 ))->GetColumn (0 ));
13571356 }
13581357
1359- #ifndef __EMSCRIPTEN__
1360- // Create spherical harmonics cache file
1361- vtkNew<vtkTable> table;
1362- table->AddColumn (this ->SphericalHarmonics );
1363-
1364- vtkNew<vtkXMLTableWriter> writer;
1365- writer->SetInputData (table);
1366- writer->SetFileName (shCachePath.c_str ());
1367- writer->Write ();
1368- #endif
1358+ if (!this ->CachePath .empty ())
1359+ {
1360+ // Create spherical harmonics cache file
1361+ vtkNew<vtkTable> table;
1362+ table->AddColumn (this ->SphericalHarmonics );
1363+
1364+ vtkNew<vtkXMLTableWriter> writer;
1365+ writer->SetInputData (table);
1366+ writer->SetFileName (shCachePath.c_str ());
1367+ writer->Write ();
1368+ }
13691369 }
13701370 this ->HasValidHDRISH = true ;
13711371 }
@@ -1398,30 +1398,31 @@ void vtkF3DRenderer::ConfigureHDRISpecular()
13981398 }
13991399 assert (spec->GetTextureObject ());
14001400
1401- #ifndef __EMSCRIPTEN__
1402- unsigned int nbLevels = spec->GetPrefilterLevels ();
1403- unsigned int size = spec->GetPrefilterSize ();
1401+ if (!this ->CachePath .empty ())
1402+ {
1403+ unsigned int nbLevels = spec->GetPrefilterLevels ();
1404+ unsigned int size = spec->GetPrefilterSize ();
14041405
1405- vtkNew<vtkMultiBlockDataSet> mb;
1406- mb->SetNumberOfBlocks (nbLevels);
1406+ vtkNew<vtkMultiBlockDataSet> mb;
1407+ mb->SetNumberOfBlocks (nbLevels);
14071408
1408- for (unsigned int i = 0 ; i < nbLevels; i++)
1409- {
1410- vtkSmartPointer<vtkImageData> img = ::SaveTextureToImage (
1411- spec->GetTextureObject (), GL_TEXTURE_CUBE_MAP_POSITIVE_X, i, size >> i, VTK_FLOAT);
1412- assert (img);
1413- mb->SetBlock (i, img);
1414- }
1409+ for (unsigned int i = 0 ; i < nbLevels; i++)
1410+ {
1411+ vtkSmartPointer<vtkImageData> img = ::SaveTextureToImage (
1412+ spec->GetTextureObject (), GL_TEXTURE_CUBE_MAP_POSITIVE_X, i, size >> i, VTK_FLOAT);
1413+ assert (img);
1414+ mb->SetBlock (i, img);
1415+ }
14151416
1416- vtkNew<vtkXMLMultiBlockDataWriter> writer;
1417- writer->SetCompressorTypeToNone ();
1418- writer->SetDataModeToAppended ();
1419- writer->EncodeAppendedDataOff ();
1420- writer->SetHeaderTypeToUInt64 ();
1421- writer->SetFileName (specCachePath.c_str ());
1422- writer->SetInputData (mb);
1423- writer->Write ();
1424- # endif
1417+ vtkNew<vtkXMLMultiBlockDataWriter> writer;
1418+ writer->SetCompressorTypeToNone ();
1419+ writer->SetDataModeToAppended ();
1420+ writer->EncodeAppendedDataOff ();
1421+ writer->SetHeaderTypeToUInt64 ();
1422+ writer->SetFileName (specCachePath.c_str ());
1423+ writer->SetInputData (mb);
1424+ writer->Write ();
1425+ }
14251426 }
14261427 this ->HasValidHDRISpec = true ;
14271428 }
@@ -2071,11 +2072,14 @@ void vtkF3DRenderer::CreateCacheDirectory()
20712072{
20722073 assert (this ->HasValidHDRIHash );
20732074
2074- // Cache folder for this HDRI
2075- std::string currentCachePath = this ->CachePath + " /" + this ->HDRIHash ;
2075+ if (!this ->CachePath .empty ())
2076+ {
2077+ // Cache folder for this HDRI
2078+ std::string currentCachePath = this ->CachePath + " /" + this ->HDRIHash ;
20762079
2077- // Create the folder if it does not exists
2078- vtksys::SystemTools::MakeDirectory (currentCachePath);
2080+ // Create the folder if it does not exists
2081+ vtksys::SystemTools::MakeDirectory (currentCachePath);
2082+ }
20792083}
20802084
20812085// ----------------------------------------------------------------------------
0 commit comments