diff --git a/export/config.py b/export/config.py index c6b1cb07..52f006df 100644 --- a/export/config.py +++ b/export/config.py @@ -57,7 +57,7 @@ def convert(exporter, scene, context=None, engine=None): _convert_dlscache_settings(scene, definitions, config) if config.photongi.enabled: - _convert_photongi_settings(scene, definitions, config) + _convert_photongi_settings(context, scene, definitions, config) if config.path.use_clamping: definitions["path.clamping.variance.maxvalue"] = config.path.clamping @@ -330,7 +330,7 @@ def _convert_dlscache_settings(scene, definitions, config): }) -def _convert_photongi_settings(scene, definitions, config): +def _convert_photongi_settings(context, scene, definitions, config): photongi = config.photongi worldscale = utils.get_worldscale(scene, as_scalematrix=False) @@ -351,10 +351,21 @@ def _convert_photongi_settings(scene, definitions, config): caustic_radius = photongi.caustic_lookup_radius * worldscale caustic_merge_radius_scale = photongi.caustic_merge_radius_scale if photongi.caustic_merge_enabled else 0 - file_path = utils.get_abspath(photongi.file_path, library=scene.library) - if os.path.isfile(file_path) and photongi.save_or_overwrite: - # Overwrite the file - os.remove(file_path) + file_path_abs = utils.get_abspath(photongi.file_path, library=scene.library) + if not os.path.isfile(file_path_abs) and not photongi.save_or_overwrite: + # Do not save the cache file + file_path = "" + else: + if utils.use_filesaver(context, scene) and photongi.file_path.startswith("//"): + # It is a relative path and we are using filesaver - don't make it + # an absolute path, just strip the leading "//" + file_path = photongi.file_path[2:] + else: + file_path = file_path_abs + if os.path.isfile(file_path) and photongi.save_or_overwrite: + # To overwrite the file, we first have to delete it, otherwise + # LuxCore loads the cache from this file + os.remove(file_path) definitions.update({ "path.photongi.photon.maxcount": round(photongi.photon_maxcount * 1000000),