From 0dab55da58af516c7e093cade9fdb986677fa993 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sat, 16 Apr 2016 11:32:10 +0100 Subject: [PATCH 001/124] Removed references to YafaRay-E and Experimental --- include/yafray_constants.h | 2 +- src/backgrounds/CMakeLists.txt | 8 +++---- src/bindings/CMakeLists.txt | 22 +++++++++---------- ..._e3_interface.i => yafaray_v3_interface.i} | 2 +- src/cameras/CMakeLists.txt | 6 ++--- src/image_handlers/CMakeLists.txt | 12 +++++----- src/integrators/CMakeLists.txt | 20 ++++++++--------- src/interface/CMakeLists.txt | 8 +++---- src/lights/CMakeLists.txt | 16 +++++++------- src/materials/CMakeLists.txt | 16 +++++++------- src/textures/CMakeLists.txt | 4 ++-- src/volumes/CMakeLists.txt | 10 ++++----- src/xml_loader/CMakeLists.txt | 2 +- src/yafraycore/CMakeLists.txt | 8 +++---- 14 files changed, 68 insertions(+), 68 deletions(-) rename src/bindings/{yafaray_e3_interface.i => yafaray_v3_interface.i} (99%) diff --git a/include/yafray_constants.h b/include/yafray_constants.h index 4eac9cd3..20de5326 100644 --- a/include/yafray_constants.h +++ b/include/yafray_constants.h @@ -5,7 +5,7 @@ #define __END_YAFRAY } #define PACKAGE "YafaRay" -#define VERSION "Experimental 3.0.0" +#define VERSION "3.0.0-beta1" #if (__GNUC__ > 3) #define GCC_HASCLASSVISIBILITY diff --git a/src/backgrounds/CMakeLists.txt b/src/backgrounds/CMakeLists.txt index 1fb8438a..aca94371 100644 --- a/src/backgrounds/CMakeLists.txt +++ b/src/backgrounds/CMakeLists.txt @@ -3,15 +3,15 @@ include_directories(${YAF_INCLUDE_DIRS}) add_definitions(-DBUILDING_YAFRAYPLUGIN) add_library(sunsky SHARED sunsky.cc sunspectrum.cc) -target_link_libraries(sunsky yafaray_e3_core) +target_link_libraries(sunsky yafaray_v3_core) add_library(textureback SHARED textureback.cc) -target_link_libraries(textureback yafaray_e3_core) +target_link_libraries(textureback yafaray_v3_core) add_library(gradientback SHARED gradientback.cc) -target_link_libraries(gradientback yafaray_e3_core) +target_link_libraries(gradientback yafaray_v3_core) add_library(SunSky2 SHARED darksky.cc) -target_link_libraries(SunSky2 yafaray_e3_core) +target_link_libraries(SunSky2 yafaray_v3_core) install (TARGETS gradientback textureback sunsky SunSky2 ${YAF_TARGET_TYPE} DESTINATION ${YAF_PLUGIN_DIR}) diff --git a/src/bindings/CMakeLists.txt b/src/bindings/CMakeLists.txt index 6b4a5593..7bbe2d7d 100644 --- a/src/bindings/CMakeLists.txt +++ b/src/bindings/CMakeLists.txt @@ -94,22 +94,22 @@ if (WITH_YAF_PY_BINDINGS) set(CMAKE_SWIG_FLAGS -c++) endif(YAF_PY_VERSION GREATER 3) - set_source_files_properties(yafaray_e3_interface.i PROPERTIES CPLUSPLUS ON) + set_source_files_properties(yafaray_v3_interface.i PROPERTIES CPLUSPLUS ON) - SWIG_ADD_MODULE(yafaray_e3_interface PYTHON yafaray_e3_interface.i) + SWIG_ADD_MODULE(yafaray_v3_interface PYTHON yafaray_v3_interface.i) if(APPLE) # use dynamic lookup for helping dlopen to find symbols properly - Jens - SET_TARGET_PROPERTIES(${SWIG_MODULE_yafaray_e3_interface_REAL_NAME} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") + SET_TARGET_PROPERTIES(${SWIG_MODULE_yafaray_v3_interface_REAL_NAME} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") endif(APPLE) - SWIG_LINK_LIBRARIES(yafaray_e3_interface yafaray_e3_core yafaray_e3_plugin ${PYTHON_LIBRARIES}) + SWIG_LINK_LIBRARIES(yafaray_v3_interface yafaray_v3_core yafaray_v3_plugin ${PYTHON_LIBRARIES}) if(APPLE) # set rpath - Jens - add_custom_command(TARGET ${SWIG_MODULE_yafaray_e3_interface_REAL_NAME} POST_BUILD COMMAND install_name_tool -add_rpath @loader_path/ _yafaray_e3_interface.so) + add_custom_command(TARGET ${SWIG_MODULE_yafaray_v3_interface_REAL_NAME} POST_BUILD COMMAND install_name_tool -add_rpath @loader_path/ _yafaray_v3_interface.so) endif(APPLE) - install(TARGETS ${SWIG_MODULE_yafaray_e3_interface_REAL_NAME} DESTINATION ${YAF_BINDINGS_PY_DIR}) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/yafaray_e3_interface.py DESTINATION ${YAF_BINDINGS_PY_DIR}) + install(TARGETS ${SWIG_MODULE_yafaray_v3_interface_REAL_NAME} DESTINATION ${YAF_BINDINGS_PY_DIR}) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/yafaray_v3_interface.py DESTINATION ${YAF_BINDINGS_PY_DIR}) endif (WITH_YAF_PY_BINDINGS) @@ -134,10 +134,10 @@ if (WITH_YAF_RUBY_BINDINGS) set(CMAKE_SWIG_FLAGS -c++ -w-801) - set_source_files_properties(yafaray_e3_interface.i PROPERTIES CPLUSPLUS ON) - SWIG_ADD_MODULE(yafaray_e3_interface RUBY yafaray_e3_interface.i) - SWIG_LINK_LIBRARIES(yafaray_e3_interface yafaray_e3_core yafaray_e3_plugin ${RUBY_LIBRARY}) - install(TARGETS ${SWIG_MODULE_yafaray_e3_interface_REAL_NAME} DESTINATION ${YAF_BINDINGS_RUBY_DIR}) + set_source_files_properties(yafaray_v3_interface.i PROPERTIES CPLUSPLUS ON) + SWIG_ADD_MODULE(yafaray_v3_interface RUBY yafaray_v3_interface.i) + SWIG_LINK_LIBRARIES(yafaray_v3_interface yafaray_v3_core yafaray_v3_plugin ${RUBY_LIBRARY}) + install(TARGETS ${SWIG_MODULE_yafaray_v3_interface_REAL_NAME} DESTINATION ${YAF_BINDINGS_RUBY_DIR}) endif (WITH_YAF_RUBY_BINDINGS) diff --git a/src/bindings/yafaray_e3_interface.i b/src/bindings/yafaray_v3_interface.i similarity index 99% rename from src/bindings/yafaray_e3_interface.i rename to src/bindings/yafaray_v3_interface.i index 1dd4f570..81e3c8bc 100755 --- a/src/bindings/yafaray_e3_interface.i +++ b/src/bindings/yafaray_v3_interface.i @@ -1,4 +1,4 @@ -%module yafaray_e3_interface +%module yafaray_v3_interface %include "cpointer.i" %pointer_functions(float, floatp); diff --git a/src/cameras/CMakeLists.txt b/src/cameras/CMakeLists.txt index 9a024d86..c3162925 100644 --- a/src/cameras/CMakeLists.txt +++ b/src/cameras/CMakeLists.txt @@ -3,12 +3,12 @@ include_directories(${YAF_INCLUDE_DIRS}) add_definitions(-DBUILDING_YAFRAYPLUGIN) add_library(perspectiveCamera SHARED perspectiveCamera.cc architectCamera.cc) -target_link_libraries(perspectiveCamera yafaray_e3_core) +target_link_libraries(perspectiveCamera yafaray_v3_core) add_library(orthographicCamera SHARED orthographicCamera.cc) -target_link_libraries(orthographicCamera yafaray_e3_core) +target_link_libraries(orthographicCamera yafaray_v3_core) add_library(angularCamera SHARED angularCamera.cc) -target_link_libraries(angularCamera yafaray_e3_core) +target_link_libraries(angularCamera yafaray_v3_core) install (TARGETS perspectiveCamera orthographicCamera angularCamera ${YAF_TARGET_TYPE} DESTINATION ${YAF_PLUGIN_DIR}) diff --git a/src/image_handlers/CMakeLists.txt b/src/image_handlers/CMakeLists.txt index 2c425265..459128e0 100644 --- a/src/image_handlers/CMakeLists.txt +++ b/src/image_handlers/CMakeLists.txt @@ -20,29 +20,29 @@ add_definitions(-DBUILDING_YAFRAYPLUGIN) if(WITH_OpenEXR) add_library(exrHandler SHARED exrHandler.cc) -target_link_libraries(exrHandler yafaray_e3_core ${OPENEXR_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(exrHandler yafaray_v3_core ${OPENEXR_LIBRARIES} ${Boost_LIBRARIES}) endif(WITH_OpenEXR) if(WITH_JPEG) add_library(jpgHandler SHARED jpgHandler.cc) -target_link_libraries(jpgHandler yafaray_e3_core ${JPEG_LIBRARY}) +target_link_libraries(jpgHandler yafaray_v3_core ${JPEG_LIBRARY}) endif(WITH_JPEG) if(WITH_PNG) add_library(pngHandler SHARED pngHandler.cc) -target_link_libraries(pngHandler yafaray_e3_core ${PNG_LIBRARIES}) +target_link_libraries(pngHandler yafaray_v3_core ${PNG_LIBRARIES}) endif(WITH_PNG) if(WITH_TIFF) add_library(tifHandler SHARED tifHandler.cc) -target_link_libraries(tifHandler yafaray_e3_core -Wl,-undefined -Wl,dynamic_lookup ${TIFF_LIBRARY}) +target_link_libraries(tifHandler yafaray_v3_core -Wl,-undefined -Wl,dynamic_lookup ${TIFF_LIBRARY}) endif(WITH_TIFF) add_library(tgaHandler SHARED tgaHandler.cc) -target_link_libraries(tgaHandler yafaray_e3_core) +target_link_libraries(tgaHandler yafaray_v3_core) add_library(hdrHandler SHARED hdrHandler.cc) -target_link_libraries(hdrHandler yafaray_e3_core) +target_link_libraries(hdrHandler yafaray_v3_core) if(WITH_OpenEXR) install (TARGETS exrHandler ${YAF_TARGET_TYPE} DESTINATION ${YAF_PLUGIN_DIR}) diff --git a/src/integrators/CMakeLists.txt b/src/integrators/CMakeLists.txt index a9bddab7..6e57e789 100644 --- a/src/integrators/CMakeLists.txt +++ b/src/integrators/CMakeLists.txt @@ -3,34 +3,34 @@ include_directories(${YAF_INCLUDE_DIRS}) add_definitions(-DBUILDING_YAFRAYPLUGIN) add_library(directlight SHARED directlight.cc) -target_link_libraries(directlight yafaray_e3_core ${Boost_LIBRARIES}) +target_link_libraries(directlight yafaray_v3_core ${Boost_LIBRARIES}) add_library(photonmap SHARED photonintegr.cc) -target_link_libraries(photonmap yafaray_e3_core ${Boost_LIBRARIES}) +target_link_libraries(photonmap yafaray_v3_core ${Boost_LIBRARIES}) add_library(pathtrace SHARED pathtracer.cc) -target_link_libraries(pathtrace yafaray_e3_core ${Boost_LIBRARIES}) +target_link_libraries(pathtrace yafaray_v3_core ${Boost_LIBRARIES}) add_library(bidirpath SHARED bidirpath.cc) -target_link_libraries(bidirpath yafaray_e3_core ${Boost_LIBRARIES}) +target_link_libraries(bidirpath yafaray_v3_core ${Boost_LIBRARIES}) add_library(EmissionIntegrator SHARED EmissionIntegrator.cc) -target_link_libraries(EmissionIntegrator yafaray_e3_core) +target_link_libraries(EmissionIntegrator yafaray_v3_core) add_library(SingleScatterIntegrator SHARED SingleScatterIntegrator.cc) -target_link_libraries(SingleScatterIntegrator yafaray_e3_core) +target_link_libraries(SingleScatterIntegrator yafaray_v3_core) add_library(EmptyVolumeIntegrator SHARED EmptyVolumeIntegrator.cc) -target_link_libraries(EmptyVolumeIntegrator yafaray_e3_core) +target_link_libraries(EmptyVolumeIntegrator yafaray_v3_core) add_library(DebugIntegrator SHARED DebugIntegrator.cc) -target_link_libraries(DebugIntegrator yafaray_e3_core) +target_link_libraries(DebugIntegrator yafaray_v3_core) add_library(SkyIntegrator SHARED SkyIntegrator.cc) -target_link_libraries(SkyIntegrator yafaray_e3_core) +target_link_libraries(SkyIntegrator yafaray_v3_core) add_library(sppm SHARED sppm.cc) -target_link_libraries(sppm yafaray_e3_core ${Boost_LIBRARIES}) +target_link_libraries(sppm yafaray_v3_core ${Boost_LIBRARIES}) install (TARGETS directlight photonmap pathtrace bidirpath sppm EmissionIntegrator SingleScatterIntegrator EmptyVolumeIntegrator DebugIntegrator SkyIntegrator diff --git a/src/interface/CMakeLists.txt b/src/interface/CMakeLists.txt index 1b5ac49c..4cb7a5b3 100644 --- a/src/interface/CMakeLists.txt +++ b/src/interface/CMakeLists.txt @@ -2,11 +2,11 @@ include_directories(${YAF_INCLUDE_DIRS} ${LIBXML2_INCLUDE_DIR}) add_definitions(-DBUILDING_YAFRAYPLUGIN) -add_library(yafaray_e3_plugin SHARED yafrayinterface.cc xmlinterface.cc) -target_link_libraries(yafaray_e3_plugin yafaray_e3_core ${LIBXML2_LIBRARY}) +add_library(yafaray_v3_plugin SHARED yafrayinterface.cc xmlinterface.cc) +target_link_libraries(yafaray_v3_plugin yafaray_v3_core ${LIBXML2_LIBRARY}) if(APPLE) # set rpath - Jens - add_custom_command(TARGET yafaray_e3_plugin POST_BUILD COMMAND install_name_tool -add_rpath @loader_path/ libyafaray_e3_plugin.dylib) + add_custom_command(TARGET yafaray_v3_plugin POST_BUILD COMMAND install_name_tool -add_rpath @loader_path/ libyafaray_v3_plugin.dylib) endif(APPLE) -install (TARGETS yafaray_e3_plugin ${YAF_TARGET_TYPE} DESTINATION ${YAF_LIB_DIR}) +install (TARGETS yafaray_v3_plugin ${YAF_TARGET_TYPE} DESTINATION ${YAF_LIB_DIR}) diff --git a/src/lights/CMakeLists.txt b/src/lights/CMakeLists.txt index 9bcab015..f9adb7d5 100644 --- a/src/lights/CMakeLists.txt +++ b/src/lights/CMakeLists.txt @@ -3,28 +3,28 @@ include_directories(${YAF_INCLUDE_DIRS}) add_definitions(-DBUILDING_YAFRAYPLUGIN) add_library(sunlight SHARED sunlight.cc) -target_link_libraries(sunlight yafaray_e3_core) +target_link_libraries(sunlight yafaray_v3_core) add_library(pointlight SHARED pointlight.cc) -target_link_libraries(pointlight yafaray_e3_core) +target_link_libraries(pointlight yafaray_v3_core) add_library(directional SHARED directional.cc) -target_link_libraries(directional yafaray_e3_core) +target_link_libraries(directional yafaray_v3_core) add_library(spotlight SHARED spotlight.cc) -target_link_libraries(spotlight yafaray_e3_core) +target_link_libraries(spotlight yafaray_v3_core) add_library(arealight SHARED arealight.cc meshlight.cc bgportallight.cc) -target_link_libraries(arealight yafaray_e3_core) +target_link_libraries(arealight yafaray_v3_core) add_library(spherelight SHARED spherelight.cc) -target_link_libraries(spherelight yafaray_e3_core) +target_link_libraries(spherelight yafaray_v3_core) add_library(ieslight SHARED iesLight.cc) -target_link_libraries(ieslight yafaray_e3_core) +target_link_libraries(ieslight yafaray_v3_core) add_library(bglight SHARED bglight.cc) -target_link_libraries(bglight yafaray_e3_core) +target_link_libraries(bglight yafaray_v3_core) install (TARGETS sunlight pointlight directional spotlight arealight spherelight ieslight bglight ${YAF_TARGET_TYPE} DESTINATION ${YAF_PLUGIN_DIR}) diff --git a/src/materials/CMakeLists.txt b/src/materials/CMakeLists.txt index 1e333824..dab32d68 100644 --- a/src/materials/CMakeLists.txt +++ b/src/materials/CMakeLists.txt @@ -3,28 +3,28 @@ include_directories(${YAF_INCLUDE_DIRS}) add_definitions(-DBUILDING_YAFRAYPLUGIN) add_library(glass SHARED glass.cc) -target_link_libraries(glass yafaray_e3_core) +target_link_libraries(glass yafaray_v3_core) add_library(roughglass SHARED roughglass.cc) -target_link_libraries(roughglass yafaray_e3_core) +target_link_libraries(roughglass yafaray_v3_core) add_library(blend SHARED blend.cc) -target_link_libraries(blend yafaray_e3_core) +target_link_libraries(blend yafaray_v3_core) add_library(glossy SHARED glossy.cc) -target_link_libraries(glossy yafaray_e3_core) +target_link_libraries(glossy yafaray_v3_core) add_library(shinydiffuse SHARED shinydiffuse.cc) -target_link_libraries(shinydiffuse yafaray_e3_core) +target_link_libraries(shinydiffuse yafaray_v3_core) add_library(coatedglossy SHARED coatedglossy.cc) -target_link_libraries(coatedglossy yafaray_e3_core) +target_link_libraries(coatedglossy yafaray_v3_core) add_library(simple SHARED simple.cc mask.cc) -target_link_libraries(simple yafaray_e3_core) +target_link_libraries(simple yafaray_v3_core) add_library(volumetric SHARED beer.cc) -target_link_libraries(volumetric yafaray_e3_core) +target_link_libraries(volumetric yafaray_v3_core) install (TARGETS glass roughglass blend glossy shinydiffuse coatedglossy simple volumetric ${YAF_TARGET_TYPE} DESTINATION ${YAF_PLUGIN_DIR}) diff --git a/src/textures/CMakeLists.txt b/src/textures/CMakeLists.txt index 58de92c3..28798ca0 100644 --- a/src/textures/CMakeLists.txt +++ b/src/textures/CMakeLists.txt @@ -4,9 +4,9 @@ add_definitions(-DBUILDING_YAFRAYPLUGIN) set(basictex_SRCS basictex.cc noise.cc imagetex.cc) add_library(basictex SHARED ${basictex_SRCS}) -target_link_libraries(basictex yafaray_e3_core) +target_link_libraries(basictex yafaray_v3_core) add_library(basicnodes SHARED basicnodes.cc layernode.cc) -target_link_libraries(basicnodes yafaray_e3_core) +target_link_libraries(basicnodes yafaray_v3_core) install (TARGETS basictex basicnodes ${YAF_TARGET_TYPE} DESTINATION ${YAF_PLUGIN_DIR}) diff --git a/src/volumes/CMakeLists.txt b/src/volumes/CMakeLists.txt index 4474cb31..5f26f991 100644 --- a/src/volumes/CMakeLists.txt +++ b/src/volumes/CMakeLists.txt @@ -3,19 +3,19 @@ include_directories(${YAF_INCLUDE_DIRS}) add_definitions(-DBUILDING_YAFRAYPLUGIN) add_library(UniformVolume SHARED UniformVolume.cc) -target_link_libraries(UniformVolume yafaray_e3_core) +target_link_libraries(UniformVolume yafaray_v3_core) add_library(ExpDensityVolume SHARED ExpDensityVolume.cc) -target_link_libraries(ExpDensityVolume yafaray_e3_core) +target_link_libraries(ExpDensityVolume yafaray_v3_core) add_library(NoiseVolume SHARED NoiseVolume.cc) -target_link_libraries(NoiseVolume yafaray_e3_core) +target_link_libraries(NoiseVolume yafaray_v3_core) add_library(GridVolume SHARED GridVolume.cc) -target_link_libraries(GridVolume yafaray_e3_core) +target_link_libraries(GridVolume yafaray_v3_core) add_library(SkyVolume SHARED SkyVolume.cc) -target_link_libraries(SkyVolume yafaray_e3_core) +target_link_libraries(SkyVolume yafaray_v3_core) install (TARGETS UniformVolume ExpDensityVolume NoiseVolume SkyVolume ${YAF_TARGET_TYPE} DESTINATION ${YAF_PLUGIN_DIR}) diff --git a/src/xml_loader/CMakeLists.txt b/src/xml_loader/CMakeLists.txt index 210ee714..8e0234aa 100644 --- a/src/xml_loader/CMakeLists.txt +++ b/src/xml_loader/CMakeLists.txt @@ -1,6 +1,6 @@ include_directories(${YAF_INCLUDE_DIRS}) add_executable(yafaray-xml xml-loader.cc) -target_link_libraries(yafaray-xml yafaray_e3_core) +target_link_libraries(yafaray-xml yafaray_v3_core) install (TARGETS yafaray-xml RUNTIME DESTINATION ${YAF_BIN_DIR}) diff --git a/src/yafraycore/CMakeLists.txt b/src/yafraycore/CMakeLists.txt index 1b1a5b06..8626cd14 100644 --- a/src/yafraycore/CMakeLists.txt +++ b/src/yafraycore/CMakeLists.txt @@ -10,7 +10,7 @@ set(YF_CORE_SOURCES bound.cc yafsystem.cc environment.cc console.cc color_consol add_definitions(-DBUILDING_YAFRAYCORE) -add_library(yafaray_e3_core SHARED ${YF_CORE_SOURCES}) +add_library(yafaray_v3_core SHARED ${YF_CORE_SOURCES}) if (UNIX) set (DLLOAD_LIB "dl" ) @@ -19,9 +19,9 @@ else (UNIX) endif (UNIX) if(APPLE) # set rpath - Jens - add_custom_command(TARGET yafaray_e3_core POST_BUILD COMMAND install_name_tool -add_rpath @loader_path/ libyafaray_e3_core.dylib) + add_custom_command(TARGET yafaray_v3_core POST_BUILD COMMAND install_name_tool -add_rpath @loader_path/ libyafaray_v3_core.dylib) endif(APPLE) -target_link_libraries(yafaray_e3_core ${CMAKE_THREAD_LIBS_INIT} ${DLLOAD_LIB} ${OPENEXR_LIBRARIES} ${LIBXML2_LIBRARIES} ${FREETYPE_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(yafaray_v3_core ${CMAKE_THREAD_LIBS_INIT} ${DLLOAD_LIB} ${OPENEXR_LIBRARIES} ${LIBXML2_LIBRARIES} ${FREETYPE_LIBRARIES} ${Boost_LIBRARIES}) -install (TARGETS yafaray_e3_core ${YAF_TARGET_TYPE} DESTINATION ${YAF_LIB_DIR}) +install (TARGETS yafaray_v3_core ${YAF_TARGET_TYPE} DESTINATION ${YAF_LIB_DIR}) From 77a07077dae6ac9f10a4acd534e76a84caccbf63 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sat, 16 Apr 2016 19:44:08 +0100 Subject: [PATCH 002/124] Show Render Badge information in log and txt/HTML files even if Badge is disabled for the image. --- include/core_api/imagefilm.h | 2 +- src/yafraycore/imagefilm.cc | 89 +++++++++++++++++++----------------- 2 files changed, 49 insertions(+), 42 deletions(-) diff --git a/include/core_api/imagefilm.h b/include/core_api/imagefilm.h index 3c6714db..bb331673 100755 --- a/include/core_api/imagefilm.h +++ b/include/core_api/imagefilm.h @@ -120,7 +120,7 @@ class YAFRAYCORE_EXPORT imageFilm_t int getTotalPixels() const { return w*h; }; void setAANoiseParams(bool detect_color_noise, float dark_threshold_factor, int variance_edge_size, int variance_pixels, float clamp_samples); /*! Methods for rendering the parameters badge; Note that FreeType lib is needed to render text */ - void drawRenderSettings(); + void drawRenderSettings(std::stringstream & ss); void reset_accumulated_image_area_flush_time() { accumulated_image_area_flush_time = 0.0; } #if HAVE_FREETYPE diff --git a/src/yafraycore/imagefilm.cc b/src/yafraycore/imagefilm.cc index ef35b4ec..44f490dc 100755 --- a/src/yafraycore/imagefilm.cc +++ b/src/yafraycore/imagefilm.cc @@ -498,10 +498,56 @@ void imageFilm_t::flush(int numView, int flags, colorOutput_t *out) colorOutput_t *colout = out ? out : output; colorOutput_t *out2 = env->getOutput2(); +#ifdef RELEASE + std::string version = std::string(VERSION); +#else + std::string version = std::string(YAF_SVN_REV); +#endif + + std::stringstream ssBadge; + + if(!yafLog.getLoggingTitle().empty()) ssBadge << yafLog.getLoggingTitle() << "\n"; + if(!yafLog.getLoggingAuthor().empty() && !yafLog.getLoggingContact().empty()) ssBadge << yafLog.getLoggingAuthor() << " | " << yafLog.getLoggingContact() << "\n"; + else if(!yafLog.getLoggingAuthor().empty() && yafLog.getLoggingContact().empty()) ssBadge << yafLog.getLoggingAuthor() << "\n"; + else if(yafLog.getLoggingAuthor().empty() && !yafLog.getLoggingContact().empty()) ssBadge << yafLog.getLoggingContact() << "\n"; + if(!yafLog.getLoggingComments().empty()) ssBadge << yafLog.getLoggingComments() << "\n"; + + ssBadge << "\nYafaRay (" << version << ")"; + + ssBadge << std::setprecision(2); + double times = gTimer.getTime("rendert"); + int timem, timeh; + gTimer.splitTime(times, ×, &timem, &timeh); + ssBadge << " | Render time:"; + if (timeh > 0) ssBadge << " " << timeh << "h"; + if (timem > 0) ssBadge << " " << timem << "m"; + ssBadge << " " << times << "s"; + + times = gTimer.getTime("rendert") + gTimer.getTime("prepassBadge"); + gTimer.splitTime(times, ×, &timem, &timeh); + ssBadge << " | Total time:"; + if (timeh > 0) ssBadge << " " << timeh << "h"; + if (timem > 0) ssBadge << " " << timem << "m"; + ssBadge << " " << times << "s"; + + std::stringstream ssLog; + ssLog << ssBadge.str(); + + if(yafLog.getDrawRenderSettings()) ssBadge << " | " << yafLog.getRenderSettings(); + if(yafLog.getDrawAANoiseSettings()) ssBadge << "\n" << yafLog.getAANoiseSettings(); + + ssLog << " | " << yafLog.getRenderSettings(); + ssLog << "\n" << yafLog.getAANoiseSettings(); + if(yafLog.getUseParamsBadge()) { - if((colout && colout->isImageOutput()) || (out2 && out2->isImageOutput())) drawRenderSettings(); + if((colout && colout->isImageOutput()) || (out2 && out2->isImageOutput())) drawRenderSettings(ssBadge); } + + Y_PARAMS << "--------------------------------------------------------------------------------" << yendl; + for (std::string line; std::getline(ssLog, line, '\n');) if(line != "" && line != "\n") Y_PARAMS << line << yendl; + Y_PARAMS << "--------------------------------------------------------------------------------" << yendl; + #ifndef HAVE_FREETYPE Y_WARNING << "imageFilm: Compiled without FreeType support." << yendl; @@ -829,7 +875,7 @@ void imageFilm_t::drawFontBitmap( FT_Bitmap* bitmap, int x, int y) #endif -void imageFilm_t::drawRenderSettings() +void imageFilm_t::drawRenderSettings(std::stringstream & ss) { if(dpimage) return; @@ -843,45 +889,6 @@ void imageFilm_t::drawRenderSettings() FT_GlyphSlot slot; FT_Vector pen; // untransformed origin -#ifdef RELEASE - std::string version = std::string(VERSION); -#else - std::string version = std::string(YAF_SVN_REV); -#endif - - std::stringstream ss; - - if(!yafLog.getLoggingTitle().empty()) ss << yafLog.getLoggingTitle() << "\n"; - if(!yafLog.getLoggingAuthor().empty() && !yafLog.getLoggingContact().empty()) ss << yafLog.getLoggingAuthor() << " | " << yafLog.getLoggingContact() << "\n"; - else if(!yafLog.getLoggingAuthor().empty() && yafLog.getLoggingContact().empty()) ss << yafLog.getLoggingAuthor() << "\n"; - else if(yafLog.getLoggingAuthor().empty() && !yafLog.getLoggingContact().empty()) ss << yafLog.getLoggingContact() << "\n"; - if(!yafLog.getLoggingComments().empty()) ss << yafLog.getLoggingComments() << "\n"; - - ss << "\nYafaRay (" << version << ")"; - - ss << std::setprecision(2); - double times = gTimer.getTime("rendert"); - int timem, timeh; - gTimer.splitTime(times, ×, &timem, &timeh); - ss << " | Render time:"; - if (timeh > 0) ss << " " << timeh << "h"; - if (timem > 0) ss << " " << timem << "m"; - ss << " " << times << "s"; - - times = gTimer.getTime("rendert") + gTimer.getTime("prepass"); - gTimer.splitTime(times, ×, &timem, &timeh); - ss << " | Total time:"; - if (timeh > 0) ss << " " << timeh << "h"; - if (timem > 0) ss << " " << timem << "m"; - ss << " " << times << "s"; - - if(yafLog.getDrawRenderSettings()) ss << " | " << yafLog.getRenderSettings(); - if(yafLog.getDrawAANoiseSettings()) ss << "\n" << yafLog.getAANoiseSettings(); - - Y_PARAMS << "--------------------------------------------------------------------------------" << yendl; - for (std::string line; std::getline(ss, line, '\n');) if(line != "" && line != "\n") Y_PARAMS << line << yendl; - Y_PARAMS << "--------------------------------------------------------------------------------" << yendl; - std::string text_utf8 = ss.str(); std::wstring_convert,char32_t> convert; std::u32string wtext_utf32 = convert.from_bytes(text_utf8); From fbb63a0c9bc13616dd2249100bb71d27df138030 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sat, 16 Apr 2016 20:09:00 +0100 Subject: [PATCH 003/124] New Log and Badge system: include resolution information --- src/yafraycore/imagefilm.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/yafraycore/imagefilm.cc b/src/yafraycore/imagefilm.cc index 44f490dc..7fe87ed7 100755 --- a/src/yafraycore/imagefilm.cc +++ b/src/yafraycore/imagefilm.cc @@ -518,6 +518,9 @@ void imageFilm_t::flush(int numView, int flags, colorOutput_t *out) double times = gTimer.getTime("rendert"); int timem, timeh; gTimer.splitTime(times, ×, &timem, &timeh); + ssBadge << " | " << w << "x" << h; + //if(cx0 != 0) ssBadge << ", xstart=" << cx0; + //if(cy0 != 0) ssBadge << ", ystart=" << cy0; ssBadge << " | Render time:"; if (timeh > 0) ssBadge << " " << timeh << "h"; if (timem > 0) ssBadge << " " << timem << "m"; From 78be4861b624299269365192faa5cf51072767c5 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sat, 16 Apr 2016 21:16:52 +0100 Subject: [PATCH 004/124] Calculate Diffuse KdTree while caustic map is being calculated to use better the cores/threads --- src/integrators/photonintegr.cc | 106 ++++++++++++++++++++------------ 1 file changed, 66 insertions(+), 40 deletions(-) diff --git a/src/integrators/photonintegr.cc b/src/integrators/photonintegr.cc index 932c4e64..ff8a488f 100644 --- a/src/integrators/photonintegr.cc +++ b/src/integrators/photonintegr.cc @@ -820,6 +820,27 @@ bool photonIntegrator_t::preprocess() Y_INFO << integratorName << ": Diffuse photon mapping disabled, skipping..." << yendl; } +#ifdef USING_THREADS + photonMapKdTreeWorker_t * diffuseMapBuildKdTree = nullptr; + + if( diffuse_enabled() && diffuseMap.nPhotons() > 0 && scene->getNumThreadsPhotons() >= 2) + { + Y_INFO << integratorName << ": Building diffuse photons kd-tree:" << yendl; + pb->setTag("Building diffuse photons kd-tree..."); + + diffuseMapBuildKdTree = new photonMapKdTreeWorker_t(diffuseMap); + + diffuseMapBuildKdTree->run(); + } + else +#endif + if( diffuse_enabled() && diffuseMap.nPhotons() > 0) + { + Y_INFO << integratorName << ": Building diffuse photons kd-tree:" << yendl; + pb->setTag("Building diffuse photons kd-tree..."); + diffuseMap.updateTree(); + Y_VERBOSE << integratorName << ": Done." << yendl; + } for(int i=0;i<(int)lights.size();++i) { @@ -1017,36 +1038,20 @@ bool photonIntegrator_t::preprocess() #ifdef USING_THREADS - if( diffuse_enabled() && diffuseMap.nPhotons() > 0 && caustics_enabled() && causticMap.nPhotons() > 0 && scene->getNumThreadsPhotons() >= 2) + photonMapKdTreeWorker_t * causticMapBuildKdTree = nullptr; + + if(caustics_enabled() && causticMap.nPhotons() > 0 && scene->getNumThreadsPhotons() >= 2) { - Y_INFO << integratorName << ": Building caustic and diffuse photons kd-trees:" << yendl; - pb->setTag("Building caustic and diffuse photons kd-trees..."); + Y_INFO << integratorName << ": Building caustic photons kd-tree:" << yendl; + pb->setTag("Building caustic photons kd-tree..."); - photonMapKdTreeWorker_t * diffuseMapBuildKdTree = new photonMapKdTreeWorker_t(diffuseMap); - photonMapKdTreeWorker_t * causticMapBuildKdTree = new photonMapKdTreeWorker_t(causticMap); + causticMapBuildKdTree = new photonMapKdTreeWorker_t(causticMap); - diffuseMapBuildKdTree->run(); causticMapBuildKdTree->run(); - - diffuseMapBuildKdTree->wait(); - causticMapBuildKdTree->wait(); - - delete diffuseMapBuildKdTree; - delete causticMapBuildKdTree; - - Y_VERBOSE << integratorName << ": Done." << yendl; } else #endif { - if( diffuse_enabled() && diffuseMap.nPhotons() > 0) - { - Y_INFO << integratorName << ": Building diffuse photons kd-tree:" << yendl; - pb->setTag("Building diffuse photons kd-tree..."); - diffuseMap.updateTree(); - Y_VERBOSE << integratorName << ": Done." << yendl; - } - if( caustics_enabled() && causticMap.nPhotons() > 0) { Y_INFO << integratorName << ": Building caustic photons kd-tree:" << yendl; @@ -1056,25 +1061,16 @@ bool photonIntegrator_t::preprocess() } } - if(photonMapProcessing == PHOTONS_GENERATE_AND_SAVE) +#ifdef USING_THREADS + if( diffuse_enabled() && diffuseMap.nPhotons() > 0 && scene->getNumThreadsPhotons() >= 2) { - if( diffuse_enabled() && diffuseMap.nPhotons() > 0) - { - std::string filename = boost::filesystem::temp_directory_path().string(); - filename += "/yafaray_diffuse_photon.map"; - Y_INFO << integratorName << ": Saving diffuse photon map to: " << filename << yendl; - if(photonMapSave(diffuseMap, filename)) Y_VERBOSE << integratorName << ": Diffuse map saved." << yendl; - } + diffuseMapBuildKdTree->wait(); - if( caustics_enabled() && causticMap.nPhotons() > 0) - { - std::string filename = boost::filesystem::temp_directory_path().string(); - filename += "/yafaray_caustics_photon.map"; - Y_INFO << integratorName << ": Saving caustics photon map to: " << filename << yendl; - if(photonMapSave(causticMap, filename)) Y_VERBOSE << integratorName << ": Caustics map saved." << yendl; - } - } + delete diffuseMapBuildKdTree; + Y_VERBOSE << integratorName << ": Diffuse photon map: done." << yendl; + } +#endif if(diffuse_enabled() && finalGather) //create radiance map: { @@ -1161,8 +1157,38 @@ bool photonIntegrator_t::preprocess() Y_VERBOSE << integratorName << ": Radiance tree built... Updating the tree..." << yendl; radianceMap.updateTree(); Y_VERBOSE << integratorName << ": Done." << yendl; + } - if(photonMapProcessing == PHOTONS_GENERATE_AND_SAVE) +#ifdef USING_THREADS + if(caustics_enabled() && causticMap.nPhotons() > 0 && scene->getNumThreadsPhotons() >= 2) + { + causticMapBuildKdTree->wait(); + + delete causticMapBuildKdTree; + + Y_VERBOSE << integratorName << ": Caustic photon map: done." << yendl; + } +#endif + + if(photonMapProcessing == PHOTONS_GENERATE_AND_SAVE) + { + if( diffuse_enabled() && diffuseMap.nPhotons() > 0) + { + std::string filename = boost::filesystem::temp_directory_path().string(); + filename += "/yafaray_diffuse_photon.map"; + Y_INFO << integratorName << ": Saving diffuse photon map to: " << filename << yendl; + if(photonMapSave(diffuseMap, filename)) Y_VERBOSE << integratorName << ": Diffuse map saved." << yendl; + } + + if( caustics_enabled() && causticMap.nPhotons() > 0) + { + std::string filename = boost::filesystem::temp_directory_path().string(); + filename += "/yafaray_caustics_photon.map"; + Y_INFO << integratorName << ": Saving caustics photon map to: " << filename << yendl; + if(photonMapSave(causticMap, filename)) Y_VERBOSE << integratorName << ": Caustics map saved." << yendl; + } + + if(diffuse_enabled() && finalGather && radianceMap.nPhotons() > 0) { std::string filename = boost::filesystem::temp_directory_path().string(); filename += "/yafaray_fg_radiance_photon.map"; @@ -1170,7 +1196,7 @@ bool photonIntegrator_t::preprocess() if(photonMapSave(radianceMap, filename)) Y_VERBOSE << integratorName << ": FG radiance map saved." << yendl; } } - + gTimer.stop("prepass"); Y_INFO << integratorName << ": Photonmap building time: " << std::fixed << std::setprecision(1) << gTimer.getTime("prepass") << "s" << " (" << scene->getNumThreadsPhotons() << " thread(s))" << yendl; From 32d42f042ecb1c3548103dea64a6e09afeaa8139 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sat, 16 Apr 2016 21:26:34 +0100 Subject: [PATCH 005/124] Fixed total time in log/badge after last changes --- src/yafraycore/imagefilm.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/yafraycore/imagefilm.cc b/src/yafraycore/imagefilm.cc index 7fe87ed7..d356a605 100755 --- a/src/yafraycore/imagefilm.cc +++ b/src/yafraycore/imagefilm.cc @@ -526,7 +526,7 @@ void imageFilm_t::flush(int numView, int flags, colorOutput_t *out) if (timem > 0) ssBadge << " " << timem << "m"; ssBadge << " " << times << "s"; - times = gTimer.getTime("rendert") + gTimer.getTime("prepassBadge"); + times = gTimer.getTime("rendert") + gTimer.getTime("prepass"); gTimer.splitTime(times, ×, &timem, &timeh); ssBadge << " | Total time:"; if (timeh > 0) ssBadge << " " << timeh << "h"; From 0c5212563b3b97a72b56d509e2cd04cf1e2a78e4 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sun, 17 Apr 2016 19:13:31 +0100 Subject: [PATCH 006/124] New Functionality: Photon Maps reuse from Memory. Also implemented new Session class for global objects persistent between renders. --- CMakeConfig/templates/yafray_config.h.cmake | 2 +- include/core_api/logging.h | 6 +- include/core_api/mcintegrator.h | 7 +- include/core_api/session.h | 54 ++++++ include/integrators/photonintegr.h | 2 - include/yafraycore/photon.h | 4 +- src/integrators/directlight.cc | 15 +- src/integrators/pathtracer.cc | 7 +- src/integrators/photonintegr.cc | 199 ++++++++++++-------- src/yafraycore/CMakeLists.txt | 2 +- src/yafraycore/logging.cc | 10 +- src/yafraycore/mcintegrator.cc | 61 +++--- src/yafraycore/photon.cc | 18 +- src/yafraycore/session.cc | 50 +++++ 14 files changed, 306 insertions(+), 131 deletions(-) create mode 100644 include/core_api/session.h create mode 100644 src/yafraycore/session.cc diff --git a/CMakeConfig/templates/yafray_config.h.cmake b/CMakeConfig/templates/yafray_config.h.cmake index 6da67e08..ebf7452b 100644 --- a/CMakeConfig/templates/yafray_config.h.cmake +++ b/CMakeConfig/templates/yafray_config.h.cmake @@ -3,7 +3,7 @@ #define Y_CONFIG_H #include "yafray_constants.h" #include -#include +#include #define MIN_RAYDIST @YAF_MIN_RAY_DIST@ #define YAF_SHADOW_BIAS @YAF_SHADOW_BIAS@ diff --git a/include/core_api/logging.h b/include/core_api/logging.h index 47ec5dd1..71a0da2f 100644 --- a/include/core_api/logging.h +++ b/include/core_api/logging.h @@ -33,6 +33,8 @@ __BEGIN_YAFRAY +class photonMap_t; + enum { VL_MUTE = 0, @@ -61,9 +63,9 @@ class YAFRAYCORE_EXPORT logEntry_t class YAFRAYCORE_EXPORT yafarayLog_t { public: - yafarayLog_t() {} + yafarayLog_t(); - ~yafarayLog_t() {} + ~yafarayLog_t(); void setConsoleMasterVerbosity(const std::string &strVLevel); void setLogMasterVerbosity(const std::string &strVLevel); diff --git a/include/core_api/mcintegrator.h b/include/core_api/mcintegrator.h index 74ef5555..d4e35374 100644 --- a/include/core_api/mcintegrator.h +++ b/include/core_api/mcintegrator.h @@ -31,11 +31,15 @@ enum photonMapProcessing_t { PHOTONS_GENERATE_ONLY, PHOTONS_GENERATE_AND_SAVE, - PHOTONS_LOAD + PHOTONS_LOAD, + PHOTONS_REUSE }; class YAFRAYCORE_EXPORT mcIntegrator_t: public tiledIntegrator_t { + public: + mcIntegrator_t() {}; + protected: /*! Estimates direct light from all sources in a mc fashion and completing MIS (Multiple Importance Sampling) for a given surface point */ virtual color_t estimateAllDirectLight(renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo, colorPasses_t &colorPasses) const; @@ -63,7 +67,6 @@ class YAFRAYCORE_EXPORT mcIntegrator_t: public tiledIntegrator_t int nCausSearch; //! Amount of caustic photons to be gathered in estimation float causRadius; //! Caustic search radius for estimation int causDepth; //! Caustic photons max path depth - photonMap_t causticMap; //! Container for the caustic photon map pdf1D_t *lightPowerD; bool useAmbientOcclusion; //! Use ambient occlusion diff --git a/include/core_api/session.h b/include/core_api/session.h new file mode 100644 index 00000000..5dbd28cd --- /dev/null +++ b/include/core_api/session.h @@ -0,0 +1,54 @@ +/**************************************************************************** + * session.h: YafaRay Session control + * This is part of the yafray package + * Copyright (C) 2016 David Bluecame + * Session control and persistent objects between renders + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef Y_SESSION_H +#define Y_SESSION_H + +#include +#include +#include +#include +#include +#include +#include + + +__BEGIN_YAFRAY + +class photonMap_t; + +class YAFRAYCORE_EXPORT session_t +{ + public: + session_t(); + + ~session_t(); + + photonMap_t * causticMap; + photonMap_t * diffuseMap; + photonMap_t * radianceMap; +}; + +extern YAFRAYCORE_EXPORT session_t session; + +__END_YAFRAY + +#endif diff --git a/include/integrators/photonintegr.h b/include/integrators/photonintegr.h index d1228e93..8f205fac 100644 --- a/include/integrators/photonintegr.h +++ b/include/integrators/photonintegr.h @@ -45,8 +45,6 @@ class YAFRAYPLUGIN_EXPORT photonIntegrator_t: public mcIntegrator_t float dsRadius; //!< diffuse search radius float lookupRad; //!< square radius to lookup radiance photons, as infinity is no such good idea ;) float gatherDist; //!< minimum distance to terminate path tracing (unless gatherBounces is reached) - photonMap_t diffuseMap; - photonMap_t radianceMap; //!< this map contains precomputed radiance "photons", not incoming photon marks friend class prepassWorker_t; }; diff --git a/include/yafraycore/photon.h b/include/yafraycore/photon.h index 4da9447a..ee7fc847 100644 --- a/include/yafraycore/photon.h +++ b/include/yafraycore/photon.h @@ -228,9 +228,9 @@ struct eliminatePhoton_t }; -YAFRAYCORE_EXPORT bool photonMapLoad(photonMap_t &map, const std::string &filename, bool debugXMLformat = false); +YAFRAYCORE_EXPORT bool photonMapLoad(photonMap_t * map, const std::string &filename, bool debugXMLformat = false); -YAFRAYCORE_EXPORT bool photonMapSave(const photonMap_t &map, const std::string &filename, bool debugXMLformat = false); +YAFRAYCORE_EXPORT bool photonMapSave(const photonMap_t * map, const std::string &filename, bool debugXMLformat = false); __END_YAFRAY diff --git a/src/integrators/directlight.cc b/src/integrators/directlight.cc index f8b048b8..d73572c9 100644 --- a/src/integrators/directlight.cc +++ b/src/integrators/directlight.cc @@ -83,12 +83,16 @@ bool directLighting_t::preprocess() success = createCausticMap(); set << "\nCaustic photons=" << nCausPhotons << " search=" << nCausSearch <<" radius=" << causRadius << " depth=" << causDepth << " "; - if(photonMapProcessing == PHOTONS_LOAD) - { - set << " (loading photon maps from file)"; - } - else if(photonMapProcessing == PHOTONS_GENERATE_AND_SAVE) set << " (saving photon maps to file)"; + if(photonMapProcessing == PHOTONS_LOAD) + { + set << " (loading photon maps from file)"; } + else if(photonMapProcessing == PHOTONS_REUSE) + { + set << " (reusing photon maps from memory)"; + } + else if(photonMapProcessing == PHOTONS_GENERATE_AND_SAVE) set << " (saving photon maps to file)"; +} gTimer.stop("prepass"); Y_INFO << integratorName << ": Photonmap building time: " << std::fixed << std::setprecision(1) << gTimer.getTime("prepass") << "s" << " (" << scene->getNumThreadsPhotons() << " thread(s))" << yendl; @@ -251,6 +255,7 @@ integrator_t* directLighting_t::factory(paraMap_t ¶ms, renderEnvironment_t & if(photon_maps_processing_str == "generate-save") inte->photonMapProcessing = PHOTONS_GENERATE_AND_SAVE; else if(photon_maps_processing_str == "load") inte->photonMapProcessing = PHOTONS_LOAD; + else if(photon_maps_processing_str == "reuse-previous") inte->photonMapProcessing = PHOTONS_REUSE; else inte->photonMapProcessing = PHOTONS_GENERATE_ONLY; return inte; diff --git a/src/integrators/pathtracer.cc b/src/integrators/pathtracer.cc index 9fdd4b63..06b33c99 100644 --- a/src/integrators/pathtracer.cc +++ b/src/integrators/pathtracer.cc @@ -114,7 +114,11 @@ bool pathIntegrator_t::preprocess() { set << " (loading photon maps from file)"; } - else if(photonMapProcessing == PHOTONS_GENERATE_AND_SAVE) set << " (saving photon maps to file)"; + else if(photonMapProcessing == PHOTONS_REUSE) + { + set << " (reusing photon maps from memory)"; + } + else if(photonMapProcessing == PHOTONS_GENERATE_AND_SAVE) set << " (saving photon maps to file)"; } gTimer.stop("prepass"); @@ -422,6 +426,7 @@ integrator_t* pathIntegrator_t::factory(paraMap_t ¶ms, renderEnvironment_t & if(photon_maps_processing_str == "generate-save") inte->photonMapProcessing = PHOTONS_GENERATE_AND_SAVE; else if(photon_maps_processing_str == "load") inte->photonMapProcessing = PHOTONS_LOAD; + else if(photon_maps_processing_str == "reuse-previous") inte->photonMapProcessing = PHOTONS_REUSE; else inte->photonMapProcessing = PHOTONS_GENERATE_ONLY; return inte; diff --git a/src/integrators/photonintegr.cc b/src/integrators/photonintegr.cc index ff8a488f..9ead0b81 100644 --- a/src/integrators/photonintegr.cc +++ b/src/integrators/photonintegr.cc @@ -129,11 +129,11 @@ photonIntegrator_t::~photonIntegrator_t() class causticWorker_t: public yafthreads::thread_t { public: - causticWorker_t(photonMap_t &causticmap, int thread_id, const scene_t *sc, unsigned int ncausphotons, const pdf1D_t *lightpowerd, int numclights, const std::string &integratorname, const std::vector &tmp_lights, int causdepth, progressBar_t *ppb, int pbstep, unsigned int &totalphotonsshot, int maxbounces): + causticWorker_t(photonMap_t * causticmap, int thread_id, const scene_t *sc, unsigned int ncausphotons, const pdf1D_t *lightpowerd, int numclights, const std::string &integratorname, const std::vector &tmp_lights, int causdepth, progressBar_t *ppb, int pbstep, unsigned int &totalphotonsshot, int maxbounces): causticMap(causticmap), threadID(thread_id), scene(sc), nCausPhotons(ncausphotons), lightPowerD(lightpowerd), numCLights(numclights), integratorName(integratorname), tmplights(tmp_lights), causDepth(causdepth), pb(ppb), pbStep(pbstep), totalPhotonsShot(totalphotonsshot), maxBounces(maxbounces) {}; virtual void body(); protected: - photonMap_t &causticMap; + photonMap_t * causticMap; int threadID; const scene_t *scene; unsigned int nCausPhotons; @@ -177,9 +177,9 @@ void causticWorker_t::body() { if(scene->getSignals() & Y_SIG_ABORT) { return; } - //causticMap.mutex.lock(); + //causticMap->mutex.lock(); //Y_DEBUG << "Thread while First=" << this << " curr=" << curr << " curr_thread=" << curr_thread << " done=" << done << yendl; - //causticMap.mutex.unlock(); + //causticMap->mutex.unlock(); unsigned int haltoncurr = curr + nCausPhotons_thread * threadID; @@ -196,9 +196,9 @@ void causticWorker_t::body() if(lightNum >= numCLights) { - causticMap.mutex.lock(); + causticMap->mutex.lock(); Y_ERROR << integratorName << ": lightPDF sample error! " << sL << "/" << lightNum << yendl; - causticMap.mutex.unlock(); + causticMap->mutex.unlock(); return; } @@ -222,9 +222,9 @@ void causticWorker_t::body() { if(std::isnan(pcol.R) || std::isnan(pcol.G) || std::isnan(pcol.B)) { - causticMap.mutex.lock(); + causticMap->mutex.lock(); Y_WARNING << integratorName << ": NaN on photon color for light" << lightNum + 1 << "." << yendl; - causticMap.mutex.unlock(); + causticMap->mutex.unlock(); continue; } @@ -296,21 +296,21 @@ void causticWorker_t::body() } done = (curr >= nCausPhotons_thread); } - causticMap.mutex.lock(); - causticMap.appendVector(localCausticPhotons, curr); + causticMap->mutex.lock(); + causticMap->appendVector(localCausticPhotons, curr); totalPhotonsShot += curr; - causticMap.mutex.unlock(); + causticMap->mutex.unlock(); } class diffuseWorker_t: public yafthreads::thread_t { public: - diffuseWorker_t(photonMap_t &diffusemap, int thread_id, const scene_t *sc, unsigned int ndiffusephotons, const pdf1D_t *lightpowerd, int numdlights, const std::string &integratorname, const std::vector &tmp_lights, progressBar_t *ppb, int pbstep, unsigned int &totalphotonsshot, int maxbounces, bool finalgather, preGatherData_t &ppgdat): + diffuseWorker_t(photonMap_t * diffusemap, int thread_id, const scene_t *sc, unsigned int ndiffusephotons, const pdf1D_t *lightpowerd, int numdlights, const std::string &integratorname, const std::vector &tmp_lights, progressBar_t *ppb, int pbstep, unsigned int &totalphotonsshot, int maxbounces, bool finalgather, preGatherData_t &ppgdat): diffuseMap(diffusemap), threadID(thread_id), scene(sc), nDiffusePhotons(ndiffusephotons), lightPowerD(lightpowerd), numDLights(numdlights), integratorName(integratorname), tmplights(tmp_lights), pb(ppb), pbStep(pbstep), totalPhotonsShot(totalphotonsshot), maxBounces(maxbounces), finalGather(finalgather), pgdat(ppgdat) {}; virtual void body(); protected: - photonMap_t &diffuseMap; + photonMap_t * diffuseMap; int threadID; const scene_t *scene; unsigned int nDiffusePhotons; @@ -370,9 +370,9 @@ void diffuseWorker_t::body() int lightNum = lightPowerD->DSample(sL, &lightNumPdf); if(lightNum >= numDLights) { - diffuseMap.mutex.lock(); + diffuseMap->mutex.lock(); Y_ERROR << integratorName << ": lightPDF sample error! " << sL << "/" << lightNum << yendl; - diffuseMap.mutex.unlock(); + diffuseMap->mutex.unlock(); return; } @@ -398,9 +398,9 @@ void diffuseWorker_t::body() { if(std::isnan(pcol.R) || std::isnan(pcol.G) || std::isnan(pcol.B)) { - diffuseMap.mutex.lock(); + diffuseMap->mutex.lock(); Y_WARNING << integratorName << ": NaN on photon color for light" << lightNum + 1 << "." << yendl; - diffuseMap.mutex.unlock(); + diffuseMap->mutex.unlock(); continue; } @@ -474,10 +474,10 @@ void diffuseWorker_t::body() } done = (curr >= nDiffusePhotons_thread); } - diffuseMap.mutex.lock(); - diffuseMap.appendVector(localDiffusePhotons, curr); + diffuseMap->mutex.lock(); + diffuseMap->appendVector(localDiffusePhotons, curr); totalPhotonsShot += curr; - diffuseMap.mutex.unlock(); + diffuseMap->mutex.unlock(); pgdat.mutex.lock(); pgdat.rad_points.insert(std::end(pgdat.rad_points), std::begin(localRadPoints), std::end(localRadPoints)); @@ -487,16 +487,16 @@ void diffuseWorker_t::body() class photonMapKdTreeWorker_t: public yafthreads::thread_t { public: - photonMapKdTreeWorker_t(photonMap_t &photonmap): + photonMapKdTreeWorker_t(photonMap_t * photonmap): photonMap(photonmap) {}; virtual void body(); protected: - photonMap_t &photonMap; + photonMap_t * photonMap; }; void photonMapKdTreeWorker_t::body() { - photonMap.updateTree(); + photonMap->updateTree(); } bool photonIntegrator_t::preprocess() @@ -517,8 +517,6 @@ bool photonIntegrator_t::preprocess() } set << "RayDepth=" << rDepth << " "; - diffuseMap.clear(); - causticMap.clear(); background = scene->getBackground(); lights = scene->lights; std::vector tmplights; @@ -543,27 +541,27 @@ bool photonIntegrator_t::preprocess() if(caustics_enabled()) { std::string filename = boost::filesystem::temp_directory_path().string(); - filename += "/yafaray_caustics_photon.map"; - Y_INFO << integratorName << ": Loading caustics photon map from: " << filename << yendl; - if(photonMapLoad(causticMap, filename)) Y_VERBOSE << integratorName << ": Caustics map loaded." << yendl; + filename += "/yafaray_photonMap_caustics.tmp"; + Y_INFO << integratorName << ": Loading caustics photon map from: " << filename << ". If it does not match the scene you could have crashes and/or incorrect renders, USE WITH CARE!" << yendl; + if(photonMapLoad(session.causticMap, filename)) Y_VERBOSE << integratorName << ": Caustics map loaded." << yendl; else photonMapProcessing = PHOTONS_GENERATE_AND_SAVE; } if(diffuse_enabled()) { std::string filename = boost::filesystem::temp_directory_path().string(); - filename += "/yafaray_diffuse_photon.map"; - Y_INFO << integratorName << ": Loading diffuse photon map from: " << filename << yendl; - if(photonMapLoad(diffuseMap, filename)) Y_VERBOSE << integratorName << ": Diffuse map loaded." << yendl; + filename += "/yafaray_photonMap_diffuse.tmp"; + Y_INFO << integratorName << ": Loading diffuse photon map from: " << filename << ". If it does not match the scene you could have crashes and/or incorrect renders, USE WITH CARE!" << yendl; + if(photonMapLoad(session.diffuseMap, filename)) Y_VERBOSE << integratorName << ": Diffuse map loaded." << yendl; else photonMapProcessing = PHOTONS_GENERATE_AND_SAVE; } if(diffuse_enabled() && finalGather) { std::string filename = boost::filesystem::temp_directory_path().string(); - filename += "/yafaray_fg_radiance_photon.map"; - Y_INFO << integratorName << ": Loading FG radiance photon map from: " << filename << yendl; - if(photonMapLoad(radianceMap, filename)) Y_VERBOSE << integratorName << ": FG radiance map loaded." << yendl; + filename += "/yafaray_photonMap_fg_radiance.tmp"; + Y_INFO << integratorName << ": Loading FG radiance photon map from: " << filename << ". If it does not match the scene you could have crashes and/or incorrect renders, USE WITH CARE!" << yendl; + if(photonMapLoad(session.radianceMap, filename)) Y_VERBOSE << integratorName << ": FG radiance map loaded." << yendl; else photonMapProcessing = PHOTONS_GENERATE_AND_SAVE; } @@ -573,13 +571,52 @@ bool photonIntegrator_t::preprocess() } } + if(photonMapProcessing == PHOTONS_REUSE) + { + if(caustics_enabled()) + { + Y_INFO << integratorName << ": Reusing caustics photon map from memory. If it does not match the scene you could have crashes and/or incorrect renders, USE WITH CARE!" << yendl; + if(session.causticMap->nPhotons() == 0) + { + photonMapProcessing = PHOTONS_GENERATE_ONLY; + } + } + + if(diffuse_enabled()) + { + Y_INFO << integratorName << ": Reusing diffuse photon map from memory. If it does not match the scene you could have crashes and/or incorrect renders, USE WITH CARE!" << yendl; + if(session.diffuseMap->nPhotons() == 0) + { + photonMapProcessing = PHOTONS_GENERATE_ONLY; + } + } + + if(diffuse_enabled() && finalGather) + { + Y_INFO << integratorName << ": Reusing FG radiance photon map from memory. If it does not match the scene you could have crashes and/or incorrect renders, USE WITH CARE!" << yendl; + if(session.diffuseMap->nPhotons() == 0) + { + photonMapProcessing = PHOTONS_GENERATE_ONLY; + } + } + + if(photonMapProcessing == PHOTONS_GENERATE_ONLY) + { + Y_WARNING << integratorName << ": One of the photon maps in memory was empty, they cannot be reused: changing to Generate mode." << yendl; + } + } + if(photonMapProcessing == PHOTONS_LOAD) { set << " (loading photon maps from file)"; } + else if(photonMapProcessing == PHOTONS_REUSE) + { + set << " (reusing photon maps from memory)"; + } else if(photonMapProcessing == PHOTONS_GENERATE_AND_SAVE) set << " (saving photon maps to file)"; - if(photonMapProcessing == PHOTONS_LOAD) + if(photonMapProcessing == PHOTONS_LOAD || photonMapProcessing == PHOTONS_REUSE) { gTimer.stop("prepass"); Y_INFO << integratorName << ": Photonmap building time: " << std::fixed << std::setprecision(1) << gTimer.getTime("prepass") << "s" << yendl; @@ -593,6 +630,9 @@ bool photonIntegrator_t::preprocess() return true; } + session.diffuseMap->clear(); + session.causticMap->clear(); + ray_t ray; float lightNumPdf, lightPdf; int numCLights = 0; @@ -604,7 +644,7 @@ bool photonIntegrator_t::preprocess() //shoot photons unsigned int curr=0; // for radiance map: - preGatherData_t pgdat(&diffuseMap); + preGatherData_t pgdat(session.diffuseMap); surfacePoint_t sp; renderState_t state; @@ -673,7 +713,7 @@ bool photonIntegrator_t::preprocess() if(nThreads > 1) { std::vector workers; - for(int i=0; irun(); for(int i=0;iwait(); for(int i=0;ipushPhoton(np); + session.diffuseMap->setNumPaths(curr); } // create entry for radiance photon: // don't forget to choose subset only, face normal forward; geometric vs. smooth normal? @@ -807,13 +847,13 @@ bool photonIntegrator_t::preprocess() tmplights.clear(); - if(diffuseMap.nPhotons() < 50) + if(session.diffuseMap->nPhotons() < 50) { Y_ERROR << integratorName << ": Too few diffuse photons, stopping now." << yendl; return false; } - Y_VERBOSE << integratorName << ": Stored diffuse photons: " << diffuseMap.nPhotons() << yendl; + Y_VERBOSE << integratorName << ": Stored diffuse photons: " << session.diffuseMap->nPhotons() << yendl; } else { @@ -823,22 +863,22 @@ bool photonIntegrator_t::preprocess() #ifdef USING_THREADS photonMapKdTreeWorker_t * diffuseMapBuildKdTree = nullptr; - if( diffuse_enabled() && diffuseMap.nPhotons() > 0 && scene->getNumThreadsPhotons() >= 2) + if( diffuse_enabled() && session.diffuseMap->nPhotons() > 0 && scene->getNumThreadsPhotons() >= 2) { Y_INFO << integratorName << ": Building diffuse photons kd-tree:" << yendl; pb->setTag("Building diffuse photons kd-tree..."); - diffuseMapBuildKdTree = new photonMapKdTreeWorker_t(diffuseMap); + diffuseMapBuildKdTree = new photonMapKdTreeWorker_t(session.diffuseMap); diffuseMapBuildKdTree->run(); } else #endif - if( diffuse_enabled() && diffuseMap.nPhotons() > 0) + if( diffuse_enabled() && session.diffuseMap->nPhotons() > 0) { Y_INFO << integratorName << ": Building diffuse photons kd-tree:" << yendl; pb->setTag("Building diffuse photons kd-tree..."); - diffuseMap.updateTree(); + session.diffuseMap->updateTree(); Y_VERBOSE << integratorName << ": Done." << yendl; } @@ -896,7 +936,7 @@ bool photonIntegrator_t::preprocess() if(nThreads > 1) { std::vector workers; - for(int i=0; irun(); for(int i=0;iwait(); for(int i=0;ipushPhoton(np); + session.causticMap->setNumPaths(curr); } } @@ -1025,7 +1065,7 @@ bool photonIntegrator_t::preprocess() delete lightPowerD; Y_INFO << integratorName << ": Shot "<nPhotons() << yendl; } else { @@ -1040,29 +1080,29 @@ bool photonIntegrator_t::preprocess() #ifdef USING_THREADS photonMapKdTreeWorker_t * causticMapBuildKdTree = nullptr; - if(caustics_enabled() && causticMap.nPhotons() > 0 && scene->getNumThreadsPhotons() >= 2) + if(caustics_enabled() && session.causticMap->nPhotons() > 0 && scene->getNumThreadsPhotons() >= 2) { Y_INFO << integratorName << ": Building caustic photons kd-tree:" << yendl; pb->setTag("Building caustic photons kd-tree..."); - causticMapBuildKdTree = new photonMapKdTreeWorker_t(causticMap); + causticMapBuildKdTree = new photonMapKdTreeWorker_t(session.causticMap); causticMapBuildKdTree->run(); } else #endif { - if( caustics_enabled() && causticMap.nPhotons() > 0) + if( caustics_enabled() && session.causticMap->nPhotons() > 0) { Y_INFO << integratorName << ": Building caustic photons kd-tree:" << yendl; pb->setTag("Building caustic photons kd-tree..."); - causticMap.updateTree(); + session.causticMap->updateTree(); Y_VERBOSE << integratorName << ": Done." << yendl; } } #ifdef USING_THREADS - if( diffuse_enabled() && diffuseMap.nPhotons() > 0 && scene->getNumThreadsPhotons() >= 2) + if( diffuse_enabled() && session.diffuseMap->nPhotons() > 0 && scene->getNumThreadsPhotons() >= 2) { diffuseMapBuildKdTree->wait(); @@ -1103,15 +1143,15 @@ bool photonIntegrator_t::preprocess() for(int i=0;iwait(); for(int i=0;iswapVector(pgdat.radianceVec); pgdat.pbar->done(); pgdat.pbar->setTag("Pregathering radiance data done..."); if(!intpb) delete pgdat.pbar; #else - if(radianceMap.nPhotons() != 0) + if(session.radianceMap->nPhotons() != 0) { Y_WARNING << integratorName << ": radianceMap not empty!" << yendl; - radianceMap.clear(); + session.radianceMap->clear(); } Y_INFO << integratorName << ": Creating radiance map..." << yendl; @@ -1124,13 +1164,13 @@ bool photonIntegrator_t::preprocess() for(unsigned int n=0; n< pgdat.rad_points.size(); ++n) { PFLOAT radius = dsRadius_2; //actually the square radius... - int nGathered = diffuseMap.gather(pgdat.rad_points[n].pos, gathered, nDifuseSearch, radius); + int nGathered = session.diffuseMap->gather(pgdat.rad_points[n].pos, gathered, nDifuseSearch, radius); color_t sum(0.0); if(nGathered > 0) { color_t surfCol = pgdat.rad_points[n].refl; vector3d_t rnorm = pgdat.rad_points[n].normal; - float scale = 1.f / ( float(diffuseMap.nPaths()) * radius * M_PI); + float scale = 1.f / ( float(session.diffuseMap->nPaths()) * radius * M_PI); if(std::isnan(scale)) { @@ -1147,7 +1187,7 @@ bool photonIntegrator_t::preprocess() } } photon_t radP(pgdat.rad_points[n].normal, pgdat.rad_points[n].pos, sum); - radianceMap.pushPhoton(radP); + session.radianceMap->pushPhoton(radP); if(n && !(n&7)) pbar->update(8); } pbar->done(); @@ -1155,12 +1195,12 @@ bool photonIntegrator_t::preprocess() free(gathered); #endif Y_VERBOSE << integratorName << ": Radiance tree built... Updating the tree..." << yendl; - radianceMap.updateTree(); + session.radianceMap->updateTree(); Y_VERBOSE << integratorName << ": Done." << yendl; } #ifdef USING_THREADS - if(caustics_enabled() && causticMap.nPhotons() > 0 && scene->getNumThreadsPhotons() >= 2) + if(caustics_enabled() && session.causticMap->nPhotons() > 0 && scene->getNumThreadsPhotons() >= 2) { causticMapBuildKdTree->wait(); @@ -1172,28 +1212,28 @@ bool photonIntegrator_t::preprocess() if(photonMapProcessing == PHOTONS_GENERATE_AND_SAVE) { - if( diffuse_enabled() && diffuseMap.nPhotons() > 0) + if( diffuse_enabled() && session.diffuseMap->nPhotons() > 0) { std::string filename = boost::filesystem::temp_directory_path().string(); - filename += "/yafaray_diffuse_photon.map"; + filename += "/yafaray_photonMap_diffuse.tmp"; Y_INFO << integratorName << ": Saving diffuse photon map to: " << filename << yendl; - if(photonMapSave(diffuseMap, filename)) Y_VERBOSE << integratorName << ": Diffuse map saved." << yendl; + if(photonMapSave(session.diffuseMap, filename)) Y_VERBOSE << integratorName << ": Diffuse map saved." << yendl; } - if( caustics_enabled() && causticMap.nPhotons() > 0) + if( caustics_enabled() && session.causticMap->nPhotons() > 0) { std::string filename = boost::filesystem::temp_directory_path().string(); - filename += "/yafaray_caustics_photon.map"; + filename += "/yafaray_photonMap_caustics.tmp"; Y_INFO << integratorName << ": Saving caustics photon map to: " << filename << yendl; - if(photonMapSave(causticMap, filename)) Y_VERBOSE << integratorName << ": Caustics map saved." << yendl; + if(photonMapSave(session.causticMap, filename)) Y_VERBOSE << integratorName << ": Caustics map saved." << yendl; } - if(diffuse_enabled() && finalGather && radianceMap.nPhotons() > 0) + if(diffuse_enabled() && finalGather && session.radianceMap->nPhotons() > 0) { std::string filename = boost::filesystem::temp_directory_path().string(); - filename += "/yafaray_fg_radiance_photon.map"; + filename += "/yafaray_photonMap_fg_radiance.tmp"; Y_INFO << integratorName << ": Saving FG radiance photon map to: " << filename << yendl; - if(photonMapSave(radianceMap, filename)) Y_VERBOSE << integratorName << ": FG radiance map saved." << yendl; + if(photonMapSave(session.radianceMap, filename)) Y_VERBOSE << integratorName << ": FG radiance map saved." << yendl; } } @@ -1288,7 +1328,7 @@ color_t photonIntegrator_t::finalGathering(renderState_t &state, const surfacePo else if(caustic) { vector3d_t sf = FACE_FORWARD(hit.Ng, hit.N, pwo); - const photon_t *nearest = radianceMap.findNearest(hit.P, sf, lookupRad); + const photon_t *nearest = session.radianceMap->findNearest(hit.P, sf, lookupRad); if(nearest) lcol = nearest->color(); } @@ -1347,7 +1387,7 @@ color_t photonIntegrator_t::finalGathering(renderState_t &state, const surfacePo if(matBSDFs & (BSDF_DIFFUSE | BSDF_GLOSSY)) { vector3d_t sf = FACE_FORWARD(hit.Ng, hit.N, -pRay.dir); - const photon_t *nearest = radianceMap.findNearest(hit.P, sf, lookupRad); + const photon_t *nearest = session.radianceMap->findNearest(hit.P, sf, lookupRad); if(nearest) lcol = nearest->color(); if(matBSDFs & BSDF_EMIT) lcol += p_mat->emit(state, hit, -pRay.dir); pathCol += lcol * throughput; @@ -1401,7 +1441,7 @@ colorA_t photonIntegrator_t::integrate(renderState_t &state, diffRay_t &ray, col if(showMap) { vector3d_t N = FACE_FORWARD(sp.Ng, sp.N, wo); - const photon_t *nearest = radianceMap.findNearest(sp.P, N, lookupRad); + const photon_t *nearest = session.radianceMap->findNearest(sp.P, N, lookupRad); if(nearest) col += nearest->color(); } else @@ -1409,7 +1449,7 @@ colorA_t photonIntegrator_t::integrate(renderState_t &state, diffRay_t &ray, col if(state.raylevel == 0 && colorPasses.enabled(PASS_INT_RADIANCE)) { vector3d_t N = FACE_FORWARD(sp.Ng, sp.N, wo); - const photon_t *nearest = radianceMap.findNearest(sp.P, N, lookupRad); + const photon_t *nearest = session.radianceMap->findNearest(sp.P, N, lookupRad); if(nearest) colorPasses(PASS_INT_RADIANCE) = nearest->color(); } @@ -1435,7 +1475,7 @@ colorA_t photonIntegrator_t::integrate(renderState_t &state, diffRay_t &ray, col if(diffuse_enabled() && showMap) { vector3d_t N = FACE_FORWARD(sp.Ng, sp.N, wo); - const photon_t *nearest = diffuseMap.findNearest(sp.P, N, dsRadius); + const photon_t *nearest = session.diffuseMap->findNearest(sp.P, N, dsRadius); if(nearest) col += nearest->color(); } else @@ -1443,7 +1483,7 @@ colorA_t photonIntegrator_t::integrate(renderState_t &state, diffRay_t &ray, col if(diffuse_enabled() && state.raylevel == 0 && colorPasses.enabled(PASS_INT_RADIANCE)) { vector3d_t N = FACE_FORWARD(sp.Ng, sp.N, wo); - const photon_t *nearest = radianceMap.findNearest(sp.P, N, lookupRad); + const photon_t *nearest = session.radianceMap->findNearest(sp.P, N, lookupRad); if(nearest) colorPasses(PASS_INT_RADIANCE) = nearest->color(); } @@ -1459,13 +1499,13 @@ colorA_t photonIntegrator_t::integrate(renderState_t &state, diffRay_t &ray, col int nGathered=0; - if(diffuse_enabled() && diffuseMap.nPhotons() > 0) nGathered = diffuseMap.gather(sp.P, gathered, nDiffuseSearch, radius); + if(diffuse_enabled() && session.diffuseMap->nPhotons() > 0) nGathered = session.diffuseMap->gather(sp.P, gathered, nDiffuseSearch, radius); color_t sum(0.0); if(diffuse_enabled() && nGathered > 0) { if(nGathered > _nMax) _nMax = nGathered; - float scale = 1.f / ( (float)diffuseMap.nPaths() * radius * M_PI); + float scale = 1.f / ( (float)session.diffuseMap->nPaths() * radius * M_PI); for(int i=0; idirection(); @@ -1618,6 +1658,7 @@ integrator_t* photonIntegrator_t::factory(paraMap_t ¶ms, renderEnvironment_t if(photon_maps_processing_str == "generate-save") ite->photonMapProcessing = PHOTONS_GENERATE_AND_SAVE; else if(photon_maps_processing_str == "load") ite->photonMapProcessing = PHOTONS_LOAD; + else if(photon_maps_processing_str == "reuse-previous") ite->photonMapProcessing = PHOTONS_REUSE; else ite->photonMapProcessing = PHOTONS_GENERATE_ONLY; return ite; diff --git a/src/yafraycore/CMakeLists.txt b/src/yafraycore/CMakeLists.txt index 8626cd14..f4ced56c 100644 --- a/src/yafraycore/CMakeLists.txt +++ b/src/yafraycore/CMakeLists.txt @@ -1,7 +1,7 @@ include_directories(${YAF_INCLUDE_DIRS} ${LIBXML2_INCLUDE_DIR} ${OPENEXR_INCLUDE_DIRS} ${FREETYPE_INCLUDE_DIRS}) set(YF_CORE_SOURCES bound.cc yafsystem.cc environment.cc console.cc color_console.cc - logging.cc faure_tables.cc std_primitives.cc color.cc renderpasses.cc + logging.cc session.cc faure_tables.cc std_primitives.cc color.cc renderpasses.cc matrix4.cc object3d.cc timer.cc kdtree.cc ray_kdtree.cc hashgrid.cc tribox3_d.cc triclip.cc scene.cc imagefilm.cc imagesplitter.cc material.cc nodematerial.cc triangle.cc vector3d.cc photon.cc xmlparser.cc spectrum.cc volume.cc diff --git a/src/yafraycore/logging.cc b/src/yafraycore/logging.cc index 13f46a68..80137aca 100644 --- a/src/yafraycore/logging.cc +++ b/src/yafraycore/logging.cc @@ -22,11 +22,17 @@ */ #include #include +#include __BEGIN_YAFRAY -// Initialization of the master instance of yafLog -yafarayLog_t yafLog = yafarayLog_t(); +yafarayLog_t::yafarayLog_t() +{ +} + +yafarayLog_t::~yafarayLog_t() +{ +} // Definition of the logging functions diff --git a/src/yafraycore/mcintegrator.cc b/src/yafraycore/mcintegrator.cc index 632b071b..69b981d4 100644 --- a/src/yafraycore/mcintegrator.cc +++ b/src/yafraycore/mcintegrator.cc @@ -329,11 +329,11 @@ inline color_t mcIntegrator_t::doLightEstimation(renderState_t &state, light_t * class causticWorker_t: public yafthreads::thread_t { public: - causticWorker_t(photonMap_t &causticmap, int thread_id, const scene_t *sc, unsigned int ncausphotons, pdf1D_t *lightpowerd, int numlights, const std::string &integratorname, const std::vector &causlights, int causdepth, progressBar_t *ppb, int pbstep, unsigned int &totalphotonsshot): + causticWorker_t(photonMap_t * causticmap, int thread_id, const scene_t *sc, unsigned int ncausphotons, pdf1D_t *lightpowerd, int numlights, const std::string &integratorname, const std::vector &causlights, int causdepth, progressBar_t *ppb, int pbstep, unsigned int &totalphotonsshot): causticMap(causticmap), threadID(thread_id), scene(sc), nCausPhotons(ncausphotons), lightPowerD(lightpowerd), numLights(numlights), integratorName(integratorname), causLights(causlights), causDepth(causdepth), pb(ppb), pbStep(pbstep), totalPhotonsShot(totalphotonsshot) {}; virtual void body(); protected: - photonMap_t &causticMap; + photonMap_t * causticMap; int threadID; const scene_t *scene; unsigned int nCausPhotons; @@ -390,9 +390,9 @@ void causticWorker_t::body() if(lightNum >= numLights) { - causticMap.mutex.lock(); + causticMap->mutex.lock(); Y_ERROR << integratorName << ": lightPDF sample error! " << sL << "/" << lightNum << yendl; - causticMap.mutex.unlock(); + causticMap->mutex.unlock(); return; } @@ -417,9 +417,9 @@ void causticWorker_t::body() { if(std::isnan(pcol.R) || std::isnan(pcol.G) || std::isnan(pcol.B)) { - causticMap.mutex.lock(); + causticMap->mutex.lock(); Y_WARNING << integratorName << ": NaN (photon color)" << yendl; - causticMap.mutex.unlock(); + causticMap->mutex.unlock(); break; } color_t transm(1.f), vcol; @@ -489,10 +489,10 @@ void causticWorker_t::body() } done = (curr >= nCausPhotons_thread); } - causticMap.mutex.lock(); - causticMap.appendVector(localCausticPhotons, curr); + causticMap->mutex.lock(); + causticMap->appendVector(localCausticPhotons, curr); totalPhotonsShot += curr; - causticMap.mutex.unlock(); + causticMap->mutex.unlock(); } bool mcIntegrator_t::createCausticMap() @@ -500,9 +500,9 @@ bool mcIntegrator_t::createCausticMap() if(photonMapProcessing == PHOTONS_LOAD) { std::string filename = boost::filesystem::temp_directory_path().string(); - filename += "/yafaray_caustics_photon.map"; - Y_INFO << integratorName << ": Loading caustics photon map from: " << filename << yendl; - if(photonMapLoad(causticMap, filename)) + filename += "/yafaray_photonMap_caustics.tmp"; + Y_INFO << integratorName << ": Loading caustics photon map from: " << filename << ". If it does not match the scene you could have crashes and/or incorrect renders, USE WITH CARE!" << yendl; + if(photonMapLoad(session.causticMap, filename)) { Y_VERBOSE << integratorName << ": Caustics map loaded." << yendl; return true; @@ -513,9 +513,20 @@ bool mcIntegrator_t::createCausticMap() Y_WARNING << integratorName << ": photon map loading failed, changing to Generate and Save mode." << yendl; } } + + if(photonMapProcessing == PHOTONS_REUSE) + { + Y_INFO << integratorName << ": Reusing caustics photon map from memory. If it does not match the scene you could have crashes and/or incorrect renders, USE WITH CARE!" << yendl; + if(session.causticMap->nPhotons() == 0) + { + photonMapProcessing = PHOTONS_GENERATE_ONLY; + Y_WARNING << integratorName << ": One of the photon maps in memory was empty, they cannot be reused: changing to Generate mode." << yendl; + } + else return true; + } - causticMap.clear(); - causticMap.reserveMemory(nCausPhotons); + session.causticMap->clear(); + session.causticMap->reserveMemory(nCausPhotons); ray_t ray; std::vector causLights; @@ -571,7 +582,7 @@ bool mcIntegrator_t::createCausticMap() if(nThreads > 1) { std::vector workers; - for(int i=0; irun(); for(int i=0;iwait(); for(int i=0;iP, pcol); - causticMap.pushPhoton(np); - causticMap.setNumPaths(curr); + session.causticMap->pushPhoton(np); + session.causticMap->setNumPaths(curr); } } // need to break in the middle otherwise we scatter the photon and then discard it => redundant @@ -704,22 +715,22 @@ bool mcIntegrator_t::createCausticMap() pb->setTag("Caustic photon map built."); Y_VERBOSE << integratorName << ": Done." << yendl; Y_INFO << integratorName << ": Shot " << curr << " caustic photons from " << numLights <<" light(s)." << yendl; - Y_VERBOSE << integratorName << ": Stored caustic photons: " << causticMap.nPhotons() << yendl; + Y_VERBOSE << integratorName << ": Stored caustic photons: " << session.causticMap->nPhotons() << yendl; delete lightPowerD; - if(causticMap.nPhotons() > 0) + if(session.causticMap->nPhotons() > 0) { pb->setTag("Building caustic photons kd-tree..."); - causticMap.updateTree(); + session.causticMap->updateTree(); Y_VERBOSE << integratorName << ": Done." << yendl; if(photonMapProcessing == PHOTONS_GENERATE_AND_SAVE) { std::string filename = boost::filesystem::temp_directory_path().string(); - filename += "/yafaray_caustics_photon.map"; + filename += "/yafaray_photonMap_caustics.tmp"; Y_INFO << integratorName << ": Saving caustics photon map to: " << filename << yendl; - if(photonMapSave(causticMap, filename)) Y_VERBOSE << integratorName << ": Caustics map saved." << yendl; + if(photonMapSave(session.causticMap, filename)) Y_VERBOSE << integratorName << ": Caustics map saved." << yendl; } } @@ -736,14 +747,14 @@ bool mcIntegrator_t::createCausticMap() inline color_t mcIntegrator_t::estimateCausticPhotons(renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo) const { - if(!causticMap.ready()) return color_t(0.f); + if(!session.causticMap->ready()) return color_t(0.f); foundPhoton_t *gathered = new foundPhoton_t[nCausSearch];//(foundPhoton_t *)alloca(nCausSearch * sizeof(foundPhoton_t)); int nGathered = 0; float gRadiusSquare = causRadius * causRadius; - nGathered = causticMap.gather(sp.P, gathered, nCausSearch, gRadiusSquare); + nGathered = session.causticMap->gather(sp.P, gathered, nCausSearch, gRadiusSquare); gRadiusSquare = 1.f / gRadiusSquare; @@ -763,7 +774,7 @@ inline color_t mcIntegrator_t::estimateCausticPhotons(renderState_t &state, cons k = kernel(gathered[i].distSquare, gRadiusSquare); sum += surfCol * k * photon->color(); } - sum *= 1.f / ( float(causticMap.nPaths()) ); + sum *= 1.f / ( float(session.causticMap->nPaths()) ); } delete [] gathered; diff --git a/src/yafraycore/photon.cc b/src/yafraycore/photon.cc index feb19027..f783777d 100644 --- a/src/yafraycore/photon.cc +++ b/src/yafraycore/photon.cc @@ -48,7 +48,7 @@ void photonGather_t::operator()(const photon_t *photon, PFLOAT dist2, PFLOAT &ma } } -bool photonMapLoad(photonMap_t &map, const std::string &filename, bool debugXMLformat) +bool photonMapLoad(photonMap_t * map, const std::string &filename, bool debugXMLformat) { try { @@ -57,28 +57,28 @@ bool photonMapLoad(photonMap_t &map, const std::string &filename, bool debugXMLf if(debugXMLformat) { boost::archive::xml_iarchive ia(ifs); - map.clear(); - ia >> BOOST_SERIALIZATION_NVP(map); + map->clear(); + ia >> BOOST_SERIALIZATION_NVP(*map); ifs.close(); } else { boost::archive::binary_iarchive ia(ifs); - map.clear(); - ia >> BOOST_SERIALIZATION_NVP(map); + map->clear(); + ia >> BOOST_SERIALIZATION_NVP(*map); ifs.close(); } return true; } catch(std::exception& ex){ // elminate any dangling references - map.clear(); + map->clear(); Y_WARNING << "PhotonMap: error '" << ex.what() << "' while loading photon map file: '" << filename << "'" << yendl; return false; } } -bool photonMapSave(const photonMap_t &map, const std::string &filename, bool debugXMLformat) +bool photonMapSave(const photonMap_t * map, const std::string &filename, bool debugXMLformat) { try { @@ -87,13 +87,13 @@ bool photonMapSave(const photonMap_t &map, const std::string &filename, bool deb if(debugXMLformat) { boost::archive::xml_oarchive oa(ofs); - oa << BOOST_SERIALIZATION_NVP(map); + oa << BOOST_SERIALIZATION_NVP(*map); ofs.close(); } else { boost::archive::binary_oarchive oa(ofs); - oa << BOOST_SERIALIZATION_NVP(map); + oa << BOOST_SERIALIZATION_NVP(*map); ofs.close(); } return true; diff --git a/src/yafraycore/session.cc b/src/yafraycore/session.cc new file mode 100644 index 00000000..a093f6ef --- /dev/null +++ b/src/yafraycore/session.cc @@ -0,0 +1,50 @@ +/**************************************************************************** + * session.cc: YafaRay Session control + * This is part of the yafray package + * Copyright (C) 2016 David Bluecame + * Session control and persistent objects between renders + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include +#include +#include + +__BEGIN_YAFRAY + +// Initialization of the master instance of yafLog +yafarayLog_t yafLog = yafarayLog_t(); + +// Initialization of the master session instance +session_t session = session_t(); + +session_t::session_t() +{ + Y_VERBOSE << "Session:started" << yendl; + causticMap = new photonMap_t; + diffuseMap = new photonMap_t; + radianceMap = new photonMap_t; +} + +session_t::~session_t() +{ + delete radianceMap; + delete diffuseMap; + delete causticMap; + Y_VERBOSE << "Session: ended" << yendl; +} + +__END_YAFRAY + From 3585d87c7442129c9f803e5a3294616f7f8c6be0 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Mon, 18 Apr 2016 21:50:33 +0100 Subject: [PATCH 007/124] Fix AO Clay pass self shadow problem, reported by RioFranco (Olivier) --- src/yafraycore/mcintegrator.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/yafraycore/mcintegrator.cc b/src/yafraycore/mcintegrator.cc index 69b981d4..4b565528 100644 --- a/src/yafraycore/mcintegrator.cc +++ b/src/yafraycore/mcintegrator.cc @@ -1172,6 +1172,9 @@ color_t mcIntegrator_t::sampleAmbientOcclusionPassClay(renderState_t &state, con s2 = addMod1(s2, state.dc2); } + if(scene->shadowBiasAuto) lightRay.tmin = scene->shadowBias * std::max(1.f, vector3d_t(sp.P).length()); + else lightRay.tmin = scene->shadowBias; + lightRay.tmax = aoDist; float W = 0.f; From fa82e16eb8bdbb0c1ac3fd963a2a6ba6dd6d6c8c Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Mon, 18 Apr 2016 21:59:15 +0100 Subject: [PATCH 008/124] SPPM: corrected Total Time calculation --- src/integrators/sppm.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/integrators/sppm.cc b/src/integrators/sppm.cc index 963fc93f..7a498d9d 100644 --- a/src/integrators/sppm.cc +++ b/src/integrators/sppm.cc @@ -321,8 +321,8 @@ bool SPPM::renderTile(int numView, renderArea_t &a, int n_samples, int offset, b //photon pass, scatter photon void SPPM::prePass(int samples, int offset, bool adaptive) { - gTimer.addEvent("prePass"); - gTimer.start("prePass"); + gTimer.addEvent("prepass"); + gTimer.start("prepass"); Y_INFO << integratorName << ": Starting Photon tracing pass..." << yendl; @@ -558,12 +558,12 @@ void SPPM::prePass(int samples, int offset, bool adaptive) if(!intpb) delete pb; - gTimer.stop("prePass"); + gTimer.stop("prepass"); if(bHashgrid) - Y_INFO << integratorName << ": PhotonGrid building time: " << gTimer.getTime("prePass") << yendl; + Y_INFO << integratorName << ": PhotonGrid building time: " << gTimer.getTime("prepass") << yendl; else - Y_INFO << integratorName << ": PhotonMap building time: " << gTimer.getTime("prePass") << yendl; + Y_INFO << integratorName << ": PhotonMap building time: " << gTimer.getTime("prepass") << yendl; return; } From 7d66940db3eae2e648804b47075d0eb24d8b6b15 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Tue, 19 Apr 2016 05:24:26 +0100 Subject: [PATCH 009/124] Photon Map enable/disable caustic/diffuse: standardise and better integrate with existing Direct Light enable/disable caustic parameters --- include/integrators/photonintegr.h | 8 ++-- src/integrators/photonintegr.cc | 68 +++++++++++++++--------------- 2 files changed, 37 insertions(+), 39 deletions(-) diff --git a/include/integrators/photonintegr.h b/include/integrators/photonintegr.h index 8f205fac..27273767 100644 --- a/include/integrators/photonintegr.h +++ b/include/integrators/photonintegr.h @@ -31,12 +31,10 @@ class YAFRAYPLUGIN_EXPORT photonIntegrator_t: public mcIntegrator_t protected: color_t finalGathering(renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo, colorPasses_t &colorPasses) const; - bool caustics_enabled() const { return bEnableCaustics; } - bool diffuse_enabled() const { return bEnableDiffuse; } - void enableCaustics(const bool caustics) { bEnableCaustics = caustics; } - void enableDiffuse(const bool diffuse) { bEnableDiffuse = diffuse; } + void enableCaustics(const bool caustics) { usePhotonCaustics = caustics; } + void enableDiffuse(const bool diffuse) { usePhotonDiffuse = diffuse; } - bool bEnableCaustics, bEnableDiffuse; //!< enable/disable caustics or diffuse photon processing + bool usePhotonDiffuse; //!< enable/disable diffuse photon processing bool finalGather, showMap; bool prepass; unsigned int nDiffusePhotons; diff --git a/src/integrators/photonintegr.cc b/src/integrators/photonintegr.cc index 9ead0b81..afa37590 100644 --- a/src/integrators/photonintegr.cc +++ b/src/integrators/photonintegr.cc @@ -105,8 +105,8 @@ void preGatherWorker_t::body() photonIntegrator_t::photonIntegrator_t(unsigned int dPhotons, unsigned int cPhotons, bool transpShad, int shadowDepth, float dsRad, float cRad) { - bEnableCaustics = true; - bEnableDiffuse = true; + usePhotonCaustics = true; + usePhotonDiffuse = true; type = SURFACE; trShad = transpShad; finalGather = true; @@ -521,12 +521,12 @@ bool photonIntegrator_t::preprocess() lights = scene->lights; std::vector tmplights; - if(caustics_enabled()) + if(usePhotonCaustics) { set << "\nCaustic photons=" << nCausPhotons << " search=" << nCausSearch <<" radius=" << causRadius << " depth=" << causDepth << " "; } - if(diffuse_enabled()) + if(usePhotonDiffuse) { set << "\nDiffuse photons=" << nDiffusePhotons << " search=" << nDiffuseSearch <<" radius=" << dsRadius << " "; } @@ -538,7 +538,7 @@ bool photonIntegrator_t::preprocess() if(photonMapProcessing == PHOTONS_LOAD) { - if(caustics_enabled()) + if(usePhotonCaustics) { std::string filename = boost::filesystem::temp_directory_path().string(); filename += "/yafaray_photonMap_caustics.tmp"; @@ -547,7 +547,7 @@ bool photonIntegrator_t::preprocess() else photonMapProcessing = PHOTONS_GENERATE_AND_SAVE; } - if(diffuse_enabled()) + if(usePhotonDiffuse) { std::string filename = boost::filesystem::temp_directory_path().string(); filename += "/yafaray_photonMap_diffuse.tmp"; @@ -556,7 +556,7 @@ bool photonIntegrator_t::preprocess() else photonMapProcessing = PHOTONS_GENERATE_AND_SAVE; } - if(diffuse_enabled() && finalGather) + if(usePhotonDiffuse && finalGather) { std::string filename = boost::filesystem::temp_directory_path().string(); filename += "/yafaray_photonMap_fg_radiance.tmp"; @@ -573,7 +573,7 @@ bool photonIntegrator_t::preprocess() if(photonMapProcessing == PHOTONS_REUSE) { - if(caustics_enabled()) + if(usePhotonCaustics) { Y_INFO << integratorName << ": Reusing caustics photon map from memory. If it does not match the scene you could have crashes and/or incorrect renders, USE WITH CARE!" << yendl; if(session.causticMap->nPhotons() == 0) @@ -582,7 +582,7 @@ bool photonIntegrator_t::preprocess() } } - if(diffuse_enabled()) + if(usePhotonDiffuse) { Y_INFO << integratorName << ": Reusing diffuse photon map from memory. If it does not match the scene you could have crashes and/or incorrect renders, USE WITH CARE!" << yendl; if(session.diffuseMap->nPhotons() == 0) @@ -591,7 +591,7 @@ bool photonIntegrator_t::preprocess() } } - if(diffuse_enabled() && finalGather) + if(usePhotonDiffuse && finalGather) { Y_INFO << integratorName << ": Reusing FG radiance photon map from memory. If it does not match the scene you could have crashes and/or incorrect renders, USE WITH CARE!" << yendl; if(session.diffuseMap->nPhotons() == 0) @@ -673,7 +673,7 @@ bool photonIntegrator_t::preprocess() enableDiffuse(false); } - if( diffuse_enabled() ) + if( usePhotonDiffuse ) { fNumLights = (float)numDLights; energies = new float[numDLights]; @@ -863,7 +863,7 @@ bool photonIntegrator_t::preprocess() #ifdef USING_THREADS photonMapKdTreeWorker_t * diffuseMapBuildKdTree = nullptr; - if( diffuse_enabled() && session.diffuseMap->nPhotons() > 0 && scene->getNumThreadsPhotons() >= 2) + if( usePhotonDiffuse && session.diffuseMap->nPhotons() > 0 && scene->getNumThreadsPhotons() >= 2) { Y_INFO << integratorName << ": Building diffuse photons kd-tree:" << yendl; pb->setTag("Building diffuse photons kd-tree..."); @@ -874,7 +874,7 @@ bool photonIntegrator_t::preprocess() } else #endif - if( diffuse_enabled() && session.diffuseMap->nPhotons() > 0) + if( usePhotonDiffuse && session.diffuseMap->nPhotons() > 0) { Y_INFO << integratorName << ": Building diffuse photons kd-tree:" << yendl; pb->setTag("Building diffuse photons kd-tree..."); @@ -897,7 +897,7 @@ bool photonIntegrator_t::preprocess() enableCaustics(false); } - if( caustics_enabled() ) + if( usePhotonCaustics ) { curr=0; @@ -1080,7 +1080,7 @@ bool photonIntegrator_t::preprocess() #ifdef USING_THREADS photonMapKdTreeWorker_t * causticMapBuildKdTree = nullptr; - if(caustics_enabled() && session.causticMap->nPhotons() > 0 && scene->getNumThreadsPhotons() >= 2) + if(usePhotonCaustics && session.causticMap->nPhotons() > 0 && scene->getNumThreadsPhotons() >= 2) { Y_INFO << integratorName << ": Building caustic photons kd-tree:" << yendl; pb->setTag("Building caustic photons kd-tree..."); @@ -1092,7 +1092,7 @@ bool photonIntegrator_t::preprocess() else #endif { - if( caustics_enabled() && session.causticMap->nPhotons() > 0) + if( usePhotonCaustics && session.causticMap->nPhotons() > 0) { Y_INFO << integratorName << ": Building caustic photons kd-tree:" << yendl; pb->setTag("Building caustic photons kd-tree..."); @@ -1102,7 +1102,7 @@ bool photonIntegrator_t::preprocess() } #ifdef USING_THREADS - if( diffuse_enabled() && session.diffuseMap->nPhotons() > 0 && scene->getNumThreadsPhotons() >= 2) + if( usePhotonDiffuse && session.diffuseMap->nPhotons() > 0 && scene->getNumThreadsPhotons() >= 2) { diffuseMapBuildKdTree->wait(); @@ -1112,7 +1112,7 @@ bool photonIntegrator_t::preprocess() } #endif - if(diffuse_enabled() && finalGather) //create radiance map: + if(usePhotonDiffuse && finalGather) //create radiance map: { #ifdef USING_THREADS // == remove too close radiance points ==// @@ -1200,7 +1200,7 @@ bool photonIntegrator_t::preprocess() } #ifdef USING_THREADS - if(caustics_enabled() && session.causticMap->nPhotons() > 0 && scene->getNumThreadsPhotons() >= 2) + if(usePhotonCaustics && session.causticMap->nPhotons() > 0 && scene->getNumThreadsPhotons() >= 2) { causticMapBuildKdTree->wait(); @@ -1212,7 +1212,7 @@ bool photonIntegrator_t::preprocess() if(photonMapProcessing == PHOTONS_GENERATE_AND_SAVE) { - if( diffuse_enabled() && session.diffuseMap->nPhotons() > 0) + if( usePhotonDiffuse && session.diffuseMap->nPhotons() > 0) { std::string filename = boost::filesystem::temp_directory_path().string(); filename += "/yafaray_photonMap_diffuse.tmp"; @@ -1220,7 +1220,7 @@ bool photonIntegrator_t::preprocess() if(photonMapSave(session.diffuseMap, filename)) Y_VERBOSE << integratorName << ": Diffuse map saved." << yendl; } - if( caustics_enabled() && session.causticMap->nPhotons() > 0) + if( usePhotonCaustics && session.causticMap->nPhotons() > 0) { std::string filename = boost::filesystem::temp_directory_path().string(); filename += "/yafaray_photonMap_caustics.tmp"; @@ -1228,7 +1228,7 @@ bool photonIntegrator_t::preprocess() if(photonMapSave(session.causticMap, filename)) Y_VERBOSE << integratorName << ": Caustics map saved." << yendl; } - if(diffuse_enabled() && finalGather && session.radianceMap->nPhotons() > 0) + if(usePhotonDiffuse && finalGather && session.radianceMap->nPhotons() > 0) { std::string filename = boost::filesystem::temp_directory_path().string(); filename += "/yafaray_photonMap_fg_radiance.tmp"; @@ -1436,7 +1436,7 @@ colorA_t photonIntegrator_t::integrate(renderState_t &state, diffRay_t &ray, col state.includeLights = false; - if(diffuse_enabled() && finalGather) + if(usePhotonDiffuse && finalGather) { if(showMap) { @@ -1472,7 +1472,7 @@ colorA_t photonIntegrator_t::integrate(renderState_t &state, diffRay_t &ray, col } else { - if(diffuse_enabled() && showMap) + if(usePhotonDiffuse && showMap) { vector3d_t N = FACE_FORWARD(sp.Ng, sp.N, wo); const photon_t *nearest = session.diffuseMap->findNearest(sp.P, N, dsRadius); @@ -1480,7 +1480,7 @@ colorA_t photonIntegrator_t::integrate(renderState_t &state, diffRay_t &ray, col } else { - if(diffuse_enabled() && state.raylevel == 0 && colorPasses.enabled(PASS_INT_RADIANCE)) + if(usePhotonDiffuse && state.raylevel == 0 && colorPasses.enabled(PASS_INT_RADIANCE)) { vector3d_t N = FACE_FORWARD(sp.Ng, sp.N, wo); const photon_t *nearest = session.radianceMap->findNearest(sp.P, N, lookupRad); @@ -1499,9 +1499,9 @@ colorA_t photonIntegrator_t::integrate(renderState_t &state, diffRay_t &ray, col int nGathered=0; - if(diffuse_enabled() && session.diffuseMap->nPhotons() > 0) nGathered = session.diffuseMap->gather(sp.P, gathered, nDiffuseSearch, radius); + if(usePhotonDiffuse && session.diffuseMap->nPhotons() > 0) nGathered = session.diffuseMap->gather(sp.P, gathered, nDiffuseSearch, radius); color_t sum(0.0); - if(diffuse_enabled() && nGathered > 0) + if(usePhotonDiffuse && nGathered > 0) { if(nGathered > _nMax) _nMax = nGathered; @@ -1518,7 +1518,7 @@ colorA_t photonIntegrator_t::integrate(renderState_t &state, diffRay_t &ray, col } // add caustics - if(caustics_enabled() && bsdfs & BSDF_DIFFUSE) + if(usePhotonCaustics && bsdfs & BSDF_DIFFUSE) { if(AA_clamp_indirect>0.f) { @@ -1600,12 +1600,12 @@ integrator_t* photonIntegrator_t::factory(paraMap_t ¶ms, renderEnvironment_t color_t AO_col(1.f); bool bg_transp = false; bool bg_transp_refract = false; - bool enable_caustics = true; - bool enable_diffuse = true; + bool caustics = true; + bool diffuse = true; std::string photon_maps_processing_str = "generate"; - params.getParam("enable_caustics", enable_caustics); - params.getParam("enable_diffuse", enable_diffuse); + params.getParam("caustics", caustics); + params.getParam("diffuse", diffuse); params.getParam("transpShad", transpShad); params.getParam("shadowDepth", shadowDepth); @@ -1634,8 +1634,8 @@ integrator_t* photonIntegrator_t::factory(paraMap_t ¶ms, renderEnvironment_t photonIntegrator_t* ite = new photonIntegrator_t(numPhotons, numCPhotons, transpShad, shadowDepth, dsRad, cRad); - ite->bEnableCaustics = enable_caustics; - ite->bEnableDiffuse = enable_diffuse; + ite->usePhotonCaustics = caustics; + ite->usePhotonDiffuse = diffuse; ite->rDepth = raydepth; ite->nDiffuseSearch = search; From f807f4b892c4b2e226d89551af9fc8409bd66581 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Tue, 19 Apr 2016 05:53:30 +0100 Subject: [PATCH 010/124] Allow saving "empty" photon maps, to avoid recalculating the rest if one was not saved --- src/integrators/photonintegr.cc | 6 +++--- src/yafraycore/mcintegrator.cc | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/integrators/photonintegr.cc b/src/integrators/photonintegr.cc index afa37590..3f3955dc 100644 --- a/src/integrators/photonintegr.cc +++ b/src/integrators/photonintegr.cc @@ -1212,7 +1212,7 @@ bool photonIntegrator_t::preprocess() if(photonMapProcessing == PHOTONS_GENERATE_AND_SAVE) { - if( usePhotonDiffuse && session.diffuseMap->nPhotons() > 0) + if( usePhotonDiffuse ) { std::string filename = boost::filesystem::temp_directory_path().string(); filename += "/yafaray_photonMap_diffuse.tmp"; @@ -1220,7 +1220,7 @@ bool photonIntegrator_t::preprocess() if(photonMapSave(session.diffuseMap, filename)) Y_VERBOSE << integratorName << ": Diffuse map saved." << yendl; } - if( usePhotonCaustics && session.causticMap->nPhotons() > 0) + if( usePhotonCaustics ) { std::string filename = boost::filesystem::temp_directory_path().string(); filename += "/yafaray_photonMap_caustics.tmp"; @@ -1228,7 +1228,7 @@ bool photonIntegrator_t::preprocess() if(photonMapSave(session.causticMap, filename)) Y_VERBOSE << integratorName << ": Caustics map saved." << yendl; } - if(usePhotonDiffuse && finalGather && session.radianceMap->nPhotons() > 0) + if( usePhotonDiffuse && finalGather ) { std::string filename = boost::filesystem::temp_directory_path().string(); filename += "/yafaray_photonMap_fg_radiance.tmp"; diff --git a/src/yafraycore/mcintegrator.cc b/src/yafraycore/mcintegrator.cc index 4b565528..fc1b77bb 100644 --- a/src/yafraycore/mcintegrator.cc +++ b/src/yafraycore/mcintegrator.cc @@ -724,14 +724,14 @@ bool mcIntegrator_t::createCausticMap() pb->setTag("Building caustic photons kd-tree..."); session.causticMap->updateTree(); Y_VERBOSE << integratorName << ": Done." << yendl; + } - if(photonMapProcessing == PHOTONS_GENERATE_AND_SAVE) - { - std::string filename = boost::filesystem::temp_directory_path().string(); - filename += "/yafaray_photonMap_caustics.tmp"; - Y_INFO << integratorName << ": Saving caustics photon map to: " << filename << yendl; - if(photonMapSave(session.causticMap, filename)) Y_VERBOSE << integratorName << ": Caustics map saved." << yendl; - } + if(photonMapProcessing == PHOTONS_GENERATE_AND_SAVE) + { + std::string filename = boost::filesystem::temp_directory_path().string(); + filename += "/yafaray_photonMap_caustics.tmp"; + Y_INFO << integratorName << ": Saving caustics photon map to: " << filename << yendl; + if(photonMapSave(session.causticMap, filename)) Y_VERBOSE << integratorName << ": Caustics map saved." << yendl; } if(!intpb) delete pb; From 369a7ee43ee67a3f018b01bfabc745bf23e1f7ad Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Tue, 19 Apr 2016 06:06:11 +0100 Subject: [PATCH 011/124] Allow reusing previous maps if some were empty, but not all --- src/integrators/photonintegr.cc | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/src/integrators/photonintegr.cc b/src/integrators/photonintegr.cc index 3f3955dc..73bfd2bf 100644 --- a/src/integrators/photonintegr.cc +++ b/src/integrators/photonintegr.cc @@ -538,13 +538,17 @@ bool photonIntegrator_t::preprocess() if(photonMapProcessing == PHOTONS_LOAD) { + bool causticMapFailedLoad = false; + bool diffuseMapFailedLoad = false; + bool fgRadianceMapFailedLoad = false; + if(usePhotonCaustics) { std::string filename = boost::filesystem::temp_directory_path().string(); filename += "/yafaray_photonMap_caustics.tmp"; Y_INFO << integratorName << ": Loading caustics photon map from: " << filename << ". If it does not match the scene you could have crashes and/or incorrect renders, USE WITH CARE!" << yendl; if(photonMapLoad(session.causticMap, filename)) Y_VERBOSE << integratorName << ": Caustics map loaded." << yendl; - else photonMapProcessing = PHOTONS_GENERATE_AND_SAVE; + else causticMapFailedLoad = true; } if(usePhotonDiffuse) @@ -553,7 +557,7 @@ bool photonIntegrator_t::preprocess() filename += "/yafaray_photonMap_diffuse.tmp"; Y_INFO << integratorName << ": Loading diffuse photon map from: " << filename << ". If it does not match the scene you could have crashes and/or incorrect renders, USE WITH CARE!" << yendl; if(photonMapLoad(session.diffuseMap, filename)) Y_VERBOSE << integratorName << ": Diffuse map loaded." << yendl; - else photonMapProcessing = PHOTONS_GENERATE_AND_SAVE; + else diffuseMapFailedLoad = true; } if(usePhotonDiffuse && finalGather) @@ -562,23 +566,28 @@ bool photonIntegrator_t::preprocess() filename += "/yafaray_photonMap_fg_radiance.tmp"; Y_INFO << integratorName << ": Loading FG radiance photon map from: " << filename << ". If it does not match the scene you could have crashes and/or incorrect renders, USE WITH CARE!" << yendl; if(photonMapLoad(session.radianceMap, filename)) Y_VERBOSE << integratorName << ": FG radiance map loaded." << yendl; - else photonMapProcessing = PHOTONS_GENERATE_AND_SAVE; + else fgRadianceMapFailedLoad = true; } - if(photonMapProcessing == PHOTONS_GENERATE_AND_SAVE) + if(causticMapFailedLoad || diffuseMapFailedLoad || fgRadianceMapFailedLoad) { - Y_WARNING << integratorName << ": photon map loading failed, changing to Generate and Save mode." << yendl; + photonMapProcessing = PHOTONS_GENERATE_AND_SAVE; + Y_WARNING << integratorName << ": photon maps loading failed, changing to Generate and Save mode." << yendl; } } if(photonMapProcessing == PHOTONS_REUSE) { + bool causticMapEmpty = false; + bool diffuseMapEmpty = false; + bool fgRadianceMapEmpty = false; + if(usePhotonCaustics) { Y_INFO << integratorName << ": Reusing caustics photon map from memory. If it does not match the scene you could have crashes and/or incorrect renders, USE WITH CARE!" << yendl; if(session.causticMap->nPhotons() == 0) { - photonMapProcessing = PHOTONS_GENERATE_ONLY; + causticMapEmpty = true; } } @@ -587,22 +596,23 @@ bool photonIntegrator_t::preprocess() Y_INFO << integratorName << ": Reusing diffuse photon map from memory. If it does not match the scene you could have crashes and/or incorrect renders, USE WITH CARE!" << yendl; if(session.diffuseMap->nPhotons() == 0) { - photonMapProcessing = PHOTONS_GENERATE_ONLY; + diffuseMapEmpty = true; } } if(usePhotonDiffuse && finalGather) { Y_INFO << integratorName << ": Reusing FG radiance photon map from memory. If it does not match the scene you could have crashes and/or incorrect renders, USE WITH CARE!" << yendl; - if(session.diffuseMap->nPhotons() == 0) + if(session.radianceMap->nPhotons() == 0) { - photonMapProcessing = PHOTONS_GENERATE_ONLY; + fgRadianceMapEmpty = true; } } - if(photonMapProcessing == PHOTONS_GENERATE_ONLY) + if(causticMapEmpty && diffuseMapEmpty && fgRadianceMapEmpty) { - Y_WARNING << integratorName << ": One of the photon maps in memory was empty, they cannot be reused: changing to Generate mode." << yendl; + photonMapProcessing = PHOTONS_GENERATE_ONLY; + Y_WARNING << integratorName << ": all previous photon maps in memory were empty, they cannot be reused: changing to Generate mode." << yendl; } } From b05147c10f760c5b770e1ee1e8aa007d1703510f Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Wed, 20 Apr 2016 06:21:45 +0100 Subject: [PATCH 012/124] New Dark Detection Type: Curve As requested in http://yafaray.org/node/704, I've introduced the new "curve" type for Dark noise detection I've made a table with these (per-pixel) values for AA threshold based on each pixel brightness: Brigh.=AA thrsh. 0.10= 0.0001 0.20= .001 0.30= .002 0.40= .0035 0.50= .0055 0.60= .0075 0.70= .010 0.80= .015 0.90= .025 1.00= .04 1.20= .08 1.40= .095 1.80= .100 --- include/core_api/imagefilm.h | 11 +++++++++- include/core_api/scene.h | 5 +++-- include/core_api/tiledintegrator.h | 1 + src/integrators/sppm.cc | 4 ++-- src/yafraycore/environment.cc | 16 ++++++++++++-- src/yafraycore/imagefilm.cc | 34 ++++++++++++++++++++++++++---- src/yafraycore/integrator.cc | 9 ++++---- src/yafraycore/scene.cc | 6 ++++-- 8 files changed, 69 insertions(+), 17 deletions(-) diff --git a/include/core_api/imagefilm.h b/include/core_api/imagefilm.h index bb331673..640df56f 100755 --- a/include/core_api/imagefilm.h +++ b/include/core_api/imagefilm.h @@ -53,6 +53,13 @@ class colorPasses_t; #define IF_DENSITYIMAGE 2 #define IF_ALL (IF_IMAGE | IF_DENSITYIMAGE) +enum darkDetectionType_t +{ + DARK_DETECTION_NONE, + DARK_DETECTION_LINEAR, + DARK_DETECTION_CURVE, +}; + class YAFRAYCORE_EXPORT imageFilm_t { public: @@ -118,10 +125,11 @@ class YAFRAYCORE_EXPORT imageFilm_t void setProgressBar(progressBar_t *pb); /*! The following methods set the strings used for the parameters badge rendering */ int getTotalPixels() const { return w*h; }; - void setAANoiseParams(bool detect_color_noise, float dark_threshold_factor, int variance_edge_size, int variance_pixels, float clamp_samples); + void setAANoiseParams(bool detect_color_noise, int dark_detection_type, float dark_threshold_factor, int variance_edge_size, int variance_pixels, float clamp_samples); /*! Methods for rendering the parameters badge; Note that FreeType lib is needed to render text */ void drawRenderSettings(std::stringstream & ss); void reset_accumulated_image_area_flush_time() { accumulated_image_area_flush_time = 0.0; } + float dark_threshold_curve_interpolate(float pixel_brightness); #if HAVE_FREETYPE void drawFontBitmap( FT_Bitmap_* bitmap, int x, int y); @@ -142,6 +150,7 @@ class YAFRAYCORE_EXPORT imageFilm_t float gamma2; //For optional secondary file output CFLOAT AA_thesh; bool AA_detect_color_noise; + int AA_dark_detection_type; float AA_dark_threshold_factor; int AA_variance_edge_size; int AA_variance_pixels; diff --git a/include/core_api/scene.h b/include/core_api/scene.h index 9efc1c61..30b3a203 100644 --- a/include/core_api/scene.h +++ b/include/core_api/scene.h @@ -180,7 +180,7 @@ class YAFRAYCORE_EXPORT scene_t void setSurfIntegrator(surfaceIntegrator_t *s); surfaceIntegrator_t* getSurfIntegrator() const { return surfIntegrator; } void setVolIntegrator(volumeIntegrator_t *v); - void setAntialiasing(int numSamples, int numPasses, int incSamples, double threshold, float resampled_floor, float sample_multiplier_factor, float light_sample_multiplier_factor, float indirect_sample_multiplier_factor, bool detect_color_noise, float dark_threshold_factor, int variance_edge_size, int variance_pixels, float clamp_samples, float clamp_indirect); + void setAntialiasing(int numSamples, int numPasses, int incSamples, double threshold, float resampled_floor, float sample_multiplier_factor, float light_sample_multiplier_factor, float indirect_sample_multiplier_factor, bool detect_color_noise, int dark_detection_type, float dark_threshold_factor, int variance_edge_size, int variance_pixels, float clamp_samples, float clamp_indirect); void setNumThreads(int threads); void setNumThreadsPhotons(int threads_photons); void setMode(int m){ mode = m; } @@ -195,7 +195,7 @@ class YAFRAYCORE_EXPORT scene_t int getNumThreadsPhotons() const { return nthreads_photons; } int getSignals() const; //! only for backward compatibility! - void getAAParameters(int &samples, int &passes, int &inc_samples, CFLOAT &threshold, float &resampled_floor, float &sample_multiplier_factor, float &light_sample_multiplier_factor, float &indirect_sample_multiplier_factor, bool &detect_color_noise, float &dark_threshold_factor, int &variance_edge_size, int &variance_pixels, float &clamp_samples, float &clamp_indirect) const; + void getAAParameters(int &samples, int &passes, int &inc_samples, CFLOAT &threshold, float &resampled_floor, float &sample_multiplier_factor, float &light_sample_multiplier_factor, float &indirect_sample_multiplier_factor, bool &detect_color_noise, int &dark_detection_type, float &dark_threshold_factor, int &variance_edge_size, int &variance_pixels, float &clamp_samples, float &clamp_indirect) const; bool intersect(const ray_t &ray, surfacePoint_t &sp) const; bool isShadowed(renderState_t &state, const ray_t &ray, float &obj_index, float &mat_index) const; bool isShadowed(renderState_t &state, const ray_t &ray, int maxDepth, color_t &filt, float &obj_index, float &mat_index) const; @@ -238,6 +238,7 @@ class YAFRAYCORE_EXPORT scene_t float AA_light_sample_multiplier_factor; float AA_indirect_sample_multiplier_factor; bool AA_detect_color_noise; + int AA_dark_detection_type; float AA_dark_threshold_factor; int AA_variance_edge_size; int AA_variance_pixels; diff --git a/include/core_api/tiledintegrator.h b/include/core_api/tiledintegrator.h index cbec9d0f..6155511a 100644 --- a/include/core_api/tiledintegrator.h +++ b/include/core_api/tiledintegrator.h @@ -37,6 +37,7 @@ class YAFRAYCORE_EXPORT tiledIntegrator_t: public surfaceIntegrator_t float AA_light_sample_multiplier_factor; float AA_indirect_sample_multiplier_factor; bool AA_detect_color_noise; + int AA_dark_detection_type; float AA_dark_threshold_factor; int AA_variance_edge_size; int AA_variance_pixels; diff --git a/src/integrators/sppm.cc b/src/integrators/sppm.cc index 7a498d9d..5f9552c5 100644 --- a/src/integrators/sppm.cc +++ b/src/integrators/sppm.cc @@ -47,7 +47,7 @@ bool SPPM::render(int numView, yafaray::imageFilm_t *image) { std::stringstream passString; imageFilm = image; - scene->getAAParameters(AA_samples, AA_passes, AA_inc_samples, AA_threshold, AA_resampled_floor, AA_sample_multiplier_factor, AA_light_sample_multiplier_factor, AA_indirect_sample_multiplier_factor, AA_detect_color_noise, AA_dark_threshold_factor, AA_variance_edge_size, AA_variance_pixels, AA_clamp_samples, AA_clamp_indirect); + scene->getAAParameters(AA_samples, AA_passes, AA_inc_samples, AA_threshold, AA_resampled_floor, AA_sample_multiplier_factor, AA_light_sample_multiplier_factor, AA_indirect_sample_multiplier_factor, AA_detect_color_noise, AA_dark_detection_type, AA_dark_threshold_factor, AA_variance_edge_size, AA_variance_pixels, AA_clamp_samples, AA_clamp_indirect); AA_sample_multiplier = 1.f; AA_light_sample_multiplier = 1.f; @@ -63,7 +63,7 @@ bool SPPM::render(int numView, yafaray::imageFilm_t *image) gTimer.addEvent("rendert"); gTimer.start("rendert"); imageFilm->init(passNum); - imageFilm->setAANoiseParams(AA_detect_color_noise, AA_dark_threshold_factor, AA_variance_edge_size, AA_variance_pixels, AA_clamp_samples); + imageFilm->setAANoiseParams(AA_detect_color_noise, AA_dark_detection_type, AA_dark_threshold_factor, AA_variance_edge_size, AA_variance_pixels, AA_clamp_samples); const camera_t* camera = scene->getCamera(); diff --git a/src/yafraycore/environment.cc b/src/yafraycore/environment.cc index d54a218a..e142f984 100755 --- a/src/yafraycore/environment.cc +++ b/src/yafraycore/environment.cc @@ -746,6 +746,8 @@ bool renderEnvironment_t::setupScene(scene_t &scene, const paraMap_t ¶ms, co float AA_light_sample_multiplier_factor = 1.f; float AA_indirect_sample_multiplier_factor = 1.f; bool AA_detect_color_noise = false; + std::string AA_dark_detection_type_string = "none"; + int AA_dark_detection_type = DARK_DETECTION_NONE; float AA_dark_threshold_factor = 0.f; int AA_variance_edge_size = 10; int AA_variance_pixels = 0; @@ -809,6 +811,7 @@ bool renderEnvironment_t::setupScene(scene_t &scene, const paraMap_t ¶ms, co params.getParam("AA_light_sample_multiplier_factor", AA_light_sample_multiplier_factor); params.getParam("AA_indirect_sample_multiplier_factor", AA_indirect_sample_multiplier_factor); params.getParam("AA_detect_color_noise", AA_detect_color_noise); + params.getParam("AA_dark_detection_type", AA_dark_detection_type_string); params.getParam("AA_dark_threshold_factor", AA_dark_threshold_factor); params.getParam("AA_variance_edge_size", AA_variance_edge_size); params.getParam("AA_variance_pixels", AA_variance_pixels); @@ -831,7 +834,16 @@ bool renderEnvironment_t::setupScene(scene_t &scene, const paraMap_t ¶ms, co params.getParam("filter_type", name); // AA filter type - aaSettings << "AA Settings (" << ((name)?*name:"box") << "): passes=" << AA_passes << " samples=" << AA_samples << " inc_samples=" << AA_inc_samples << " resamp.floor=" << AA_resampled_floor << "\nsample.mul=" << AA_sample_multiplier_factor << " light.sam.mul=" << AA_light_sample_multiplier_factor << " ind.sam.mul=" << AA_indirect_sample_multiplier_factor << "\ncol.noise=" << AA_detect_color_noise << " dark.thr=" << AA_dark_threshold_factor << " var.edge=" << AA_variance_edge_size << " var.pix=" << AA_variance_pixels << " clamp=" << AA_clamp_samples << " ind.clamp=" << AA_clamp_indirect; + if(AA_dark_detection_type_string == "linear") AA_dark_detection_type = DARK_DETECTION_LINEAR; + else if(AA_dark_detection_type_string == "curve") AA_dark_detection_type = DARK_DETECTION_CURVE; + else AA_dark_detection_type = DARK_DETECTION_NONE; + + aaSettings << "AA Settings (" << ((name)?*name:"box") << "): passes=" << AA_passes << " samples=" << AA_samples << " inc_samples=" << AA_inc_samples << " resamp.floor=" << AA_resampled_floor << "\nsample.mul=" << AA_sample_multiplier_factor << " light.sam.mul=" << AA_light_sample_multiplier_factor << " ind.sam.mul=" << AA_indirect_sample_multiplier_factor << "\ncol.noise=" << AA_detect_color_noise; + + if(AA_dark_detection_type == DARK_DETECTION_LINEAR) aaSettings << " dark.thr(lin),fac=" << AA_dark_threshold_factor; + else if(AA_dark_detection_type == DARK_DETECTION_CURVE) aaSettings << " dark.thr(curve)"; + + aaSettings << " var.edge=" << AA_variance_edge_size << " var.pix=" << AA_variance_pixels << " clamp=" << AA_clamp_samples << " ind.clamp=" << AA_clamp_indirect; yafLog.appendAANoiseSettings(aaSettings.str()); @@ -839,7 +851,7 @@ bool renderEnvironment_t::setupScene(scene_t &scene, const paraMap_t ¶ms, co scene.setImageFilm(film); scene.setSurfIntegrator((surfaceIntegrator_t*)inte); scene.setVolIntegrator((volumeIntegrator_t*)volInte); - scene.setAntialiasing(AA_samples, AA_passes, AA_inc_samples, AA_threshold, AA_resampled_floor, AA_sample_multiplier_factor, AA_light_sample_multiplier_factor, AA_indirect_sample_multiplier_factor, AA_detect_color_noise, AA_dark_threshold_factor, AA_variance_edge_size, AA_variance_pixels, AA_clamp_samples, AA_clamp_indirect); + scene.setAntialiasing(AA_samples, AA_passes, AA_inc_samples, AA_threshold, AA_resampled_floor, AA_sample_multiplier_factor, AA_light_sample_multiplier_factor, AA_indirect_sample_multiplier_factor, AA_detect_color_noise, AA_dark_detection_type, AA_dark_threshold_factor, AA_variance_edge_size, AA_variance_pixels, AA_clamp_samples, AA_clamp_indirect); scene.setNumThreads(nthreads); scene.setNumThreadsPhotons(nthreads_photons); if(backg) scene.setBackground(backg); diff --git a/src/yafraycore/imagefilm.cc b/src/yafraycore/imagefilm.cc index d356a605..f865505a 100755 --- a/src/yafraycore/imagefilm.cc +++ b/src/yafraycore/imagefilm.cc @@ -35,6 +35,7 @@ #include #include #include +#include #if HAVE_FREETYPE #include @@ -128,7 +129,6 @@ imageFilm_t::imageFilm_t (int width, int height, int xstart, int ystart, colorOu cy1 = ystart + height; filterTable = new float[FILTER_TABLE_SIZE * FILTER_TABLE_SIZE]; - //Creation of the image buffers for the render passes for(int idx = 0; idx < env->getRenderPasses()->extPassesSize(); ++idx) { @@ -263,8 +263,15 @@ int imageFilm_t::nextPass(int numView, bool adaptive_AA, std::string integratorN colorA_t pixCol = (*imagePasses.at(0))(x, y).normalized(); float pixColBri = pixCol.abscol2bri(); - - if(AA_dark_threshold_factor > 0.f) AA_thresh_scaled = AA_thesh*((1.f-AA_dark_threshold_factor) + (pixColBri*AA_dark_threshold_factor)); + + if(AA_dark_detection_type == DARK_DETECTION_LINEAR) + { + if(AA_dark_threshold_factor > 0.f) AA_thresh_scaled = AA_thesh*((1.f-AA_dark_threshold_factor) + (pixColBri*AA_dark_threshold_factor)); + } + else if(AA_dark_detection_type == DARK_DETECTION_CURVE) + { + AA_thresh_scaled = dark_threshold_curve_interpolate(pixColBri); + } if(pixCol.colorDifference((*imagePasses.at(0))(x+1, y).normalized(), AA_detect_color_noise) >= AA_thresh_scaled) { @@ -838,9 +845,10 @@ void imageFilm_t::setProgressBar(progressBar_t *pb) pbar = pb; } -void imageFilm_t::setAANoiseParams(bool detect_color_noise, float dark_threshold_factor, int variance_edge_size, int variance_pixels, float clamp_samples) +void imageFilm_t::setAANoiseParams(bool detect_color_noise, int dark_detection_type, float dark_threshold_factor, int variance_edge_size, int variance_pixels, float clamp_samples) { AA_detect_color_noise = detect_color_noise; + AA_dark_detection_type = dark_detection_type; AA_dark_threshold_factor = dark_threshold_factor; AA_variance_edge_size = variance_edge_size; AA_variance_pixels = variance_pixels; @@ -1034,4 +1042,22 @@ void imageFilm_t::drawRenderSettings(std::stringstream & ss) Y_INFO << "imageFilm: Rendering parameters badge created." << yendl; } +float imageFilm_t::dark_threshold_curve_interpolate(float pixel_brightness) +{ + if(pixel_brightness <= 0.10f) return 0.0001f; + else if(pixel_brightness > 0.10f && pixel_brightness <= 0.20f) return (0.0001f + (pixel_brightness - 0.10f) * (0.0010f - 0.0001f) / 0.10f); + else if(pixel_brightness > 0.20f && pixel_brightness <= 0.30f) return (0.0010f + (pixel_brightness - 0.20f) * (0.0020f - 0.0010f) / 0.10f); + else if(pixel_brightness > 0.30f && pixel_brightness <= 0.40f) return (0.0020f + (pixel_brightness - 0.30f) * (0.0035f - 0.0020f) / 0.10f); + else if(pixel_brightness > 0.40f && pixel_brightness <= 0.50f) return (0.0035f + (pixel_brightness - 0.40f) * (0.0055f - 0.0035f) / 0.10f); + else if(pixel_brightness > 0.50f && pixel_brightness <= 0.60f) return (0.0055f + (pixel_brightness - 0.50f) * (0.0075f - 0.0055f) / 0.10f); + else if(pixel_brightness > 0.60f && pixel_brightness <= 0.70f) return (0.0075f + (pixel_brightness - 0.60f) * (0.0100f - 0.0075f) / 0.10f); + else if(pixel_brightness > 0.70f && pixel_brightness <= 0.80f) return (0.0100f + (pixel_brightness - 0.70f) * (0.0150f - 0.0100f) / 0.10f); + else if(pixel_brightness > 0.80f && pixel_brightness <= 0.90f) return (0.0150f + (pixel_brightness - 0.80f) * (0.0250f - 0.0150f) / 0.10f); + else if(pixel_brightness > 0.90f && pixel_brightness <= 1.00f) return (0.0250f + (pixel_brightness - 0.90f) * (0.0400f - 0.0250f) / 0.10f); + else if(pixel_brightness > 1.00f && pixel_brightness <= 1.20f) return (0.0400f + (pixel_brightness - 1.00f) * (0.0800f - 0.0400f) / 0.20f); + else if(pixel_brightness > 1.20f && pixel_brightness <= 1.40f) return (0.0800f + (pixel_brightness - 1.20f) * (0.0950f - 0.0800f) / 0.20f); + else if(pixel_brightness > 1.40f && pixel_brightness <= 1.80f) return (0.0950f + (pixel_brightness - 1.40f) * (0.1000f - 0.0950f) / 0.40f); + else if(pixel_brightness > 1.80f) return 0.1000f; +} + __END_YAFRAY diff --git a/src/yafraycore/integrator.cc b/src/yafraycore/integrator.cc index 3204fb89..04602a99 100644 --- a/src/yafraycore/integrator.cc +++ b/src/yafraycore/integrator.cc @@ -136,7 +136,7 @@ bool tiledIntegrator_t::render(int numView, imageFilm_t *image) { std::stringstream passString; imageFilm = image; - scene->getAAParameters(AA_samples, AA_passes, AA_inc_samples, AA_threshold, AA_resampled_floor, AA_sample_multiplier_factor, AA_light_sample_multiplier_factor, AA_indirect_sample_multiplier_factor, AA_detect_color_noise, AA_dark_threshold_factor, AA_variance_edge_size, AA_variance_pixels, AA_clamp_samples, AA_clamp_indirect); + scene->getAAParameters(AA_samples, AA_passes, AA_inc_samples, AA_threshold, AA_resampled_floor, AA_sample_multiplier_factor, AA_light_sample_multiplier_factor, AA_indirect_sample_multiplier_factor, AA_detect_color_noise, AA_dark_detection_type, AA_dark_threshold_factor, AA_variance_edge_size, AA_variance_pixels, AA_clamp_samples, AA_clamp_indirect); iAA_passes = 1.f / (float) AA_passes; AA_sample_multiplier = 1.f; @@ -153,7 +153,8 @@ bool tiledIntegrator_t::render(int numView, imageFilm_t *image) Y_VERBOSE << "AA_light_sample_multiplier_factor: "<< AA_light_sample_multiplier_factor << yendl; Y_VERBOSE << "AA_indirect_sample_multiplier_factor: "<< AA_indirect_sample_multiplier_factor << yendl; Y_VERBOSE << "AA_detect_color_noise: "<< AA_detect_color_noise << yendl; - Y_VERBOSE << "AA_dark_threshold_factor: "<< AA_dark_threshold_factor << yendl; + if(AA_dark_detection_type == DARK_DETECTION_LINEAR) Y_VERBOSE << "AA_dark_threshold (linear), factor: "<< AA_dark_threshold_factor << yendl; + if(AA_dark_detection_type == DARK_DETECTION_CURVE) Y_VERBOSE << "AA_dark_threshold (curve)" << yendl; Y_VERBOSE << "AA_variance_edge_size: "<< AA_variance_edge_size << yendl; Y_VERBOSE << "AA_variance_pixels: "<< AA_variance_pixels << yendl; Y_VERBOSE << "AA_clamp_samples: "<< AA_clamp_samples << yendl; @@ -170,7 +171,7 @@ bool tiledIntegrator_t::render(int numView, imageFilm_t *image) gTimer.addEvent("image_area_flush"); imageFilm->init(AA_passes); - imageFilm->setAANoiseParams(AA_detect_color_noise, AA_dark_threshold_factor, AA_variance_edge_size, AA_variance_pixels, AA_clamp_samples); + imageFilm->setAANoiseParams(AA_detect_color_noise, AA_dark_detection_type, AA_dark_threshold_factor, AA_variance_edge_size, AA_variance_pixels, AA_clamp_samples); maxDepth = 0.f; minDepth = 1e38f; @@ -199,7 +200,7 @@ bool tiledIntegrator_t::render(int numView, imageFilm_t *image) Y_INFO << integratorName << ": Sample multiplier = " << AA_sample_multiplier << ", Light Sample multiplier = " << AA_light_sample_multiplier << ", Indirect Sample multiplier = " << AA_indirect_sample_multiplier << yendl; - imageFilm->setAANoiseParams(AA_detect_color_noise, AA_dark_threshold_factor, AA_variance_edge_size, AA_variance_pixels, AA_clamp_samples); + imageFilm->setAANoiseParams(AA_detect_color_noise, AA_dark_detection_type, AA_dark_threshold_factor, AA_variance_edge_size, AA_variance_pixels, AA_clamp_samples); if(resampled_pixels <= 0.f && !AAthresholdChanged) { diff --git a/src/yafraycore/scene.cc b/src/yafraycore/scene.cc index e0532d1d..3e456777 100644 --- a/src/yafraycore/scene.cc +++ b/src/yafraycore/scene.cc @@ -93,7 +93,7 @@ int scene_t::getSignals() const return sig; } -void scene_t::getAAParameters(int &samples, int &passes, int &inc_samples, CFLOAT &threshold, float &resampled_floor, float &sample_multiplier_factor, float &light_sample_multiplier_factor, float &indirect_sample_multiplier_factor, bool &detect_color_noise, float &dark_threshold_factor, int &variance_edge_size, int &variance_pixels, float &clamp_samples, float &clamp_indirect) const +void scene_t::getAAParameters(int &samples, int &passes, int &inc_samples, CFLOAT &threshold, float &resampled_floor, float &sample_multiplier_factor, float &light_sample_multiplier_factor, float &indirect_sample_multiplier_factor, bool &detect_color_noise, int &dark_detection_type, float &dark_threshold_factor, int &variance_edge_size, int &variance_pixels, float &clamp_samples, float &clamp_indirect) const { samples = AA_samples; passes = AA_passes; @@ -104,6 +104,7 @@ void scene_t::getAAParameters(int &samples, int &passes, int &inc_samples, CFLOA light_sample_multiplier_factor = AA_light_sample_multiplier_factor; indirect_sample_multiplier_factor = AA_indirect_sample_multiplier_factor; detect_color_noise = AA_detect_color_noise; + dark_detection_type = AA_dark_detection_type; dark_threshold_factor = AA_dark_threshold_factor; variance_edge_size = AA_variance_edge_size; variance_pixels = AA_variance_pixels; @@ -798,7 +799,7 @@ bound_t scene_t::getSceneBound() const return sceneBound; } -void scene_t::setAntialiasing(int numSamples, int numPasses, int incSamples, double threshold, float resampled_floor, float sample_multiplier_factor, float light_sample_multiplier_factor, float indirect_sample_multiplier_factor, bool detect_color_noise, float dark_threshold_factor, int variance_edge_size, int variance_pixels, float clamp_samples, float clamp_indirect) +void scene_t::setAntialiasing(int numSamples, int numPasses, int incSamples, double threshold, float resampled_floor, float sample_multiplier_factor, float light_sample_multiplier_factor, float indirect_sample_multiplier_factor, bool detect_color_noise, int dark_detection_type, float dark_threshold_factor, int variance_edge_size, int variance_pixels, float clamp_samples, float clamp_indirect) { AA_samples = std::max(1, numSamples); AA_passes = numPasses; @@ -809,6 +810,7 @@ void scene_t::setAntialiasing(int numSamples, int numPasses, int incSamples, dou AA_light_sample_multiplier_factor = light_sample_multiplier_factor; AA_indirect_sample_multiplier_factor = indirect_sample_multiplier_factor; AA_detect_color_noise = detect_color_noise; + AA_dark_detection_type = dark_detection_type; AA_dark_threshold_factor = dark_threshold_factor; AA_variance_edge_size = variance_edge_size; AA_variance_pixels = variance_pixels; From 7ce06e8f38018fb01c3f31ebd650952369ed419e Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sat, 23 Apr 2016 11:38:29 +0400 Subject: [PATCH 013/124] Changes to compile in Visual Studio 2013. Also, changes to select manually Python paths if needed --- CMakeModules/FindYafPythonLibs.cmake | 6 +++--- include/core_api/color.h | 0 include/core_api/imagefilm.h | 0 include/core_api/texture.h | 0 include/interface/xmlinterface.h | 0 include/interface/yafrayinterface.h | 0 include/textures/imagetex.h | 0 include/utilities/mathOptimizations.h | 7 +------ include/yafraycore/xmlparser.h | 0 src/bindings/yafaray_v3_interface.i | 0 src/interface/xmlinterface.cc | 0 src/interface/yafrayinterface.cc | 0 src/textures/basicnodes.cc | 0 src/textures/imagetex.cc | 0 src/xml_loader/xml-loader.cc | 0 src/yafraycore/console.cc | 3 +++ src/yafraycore/environment.cc | 0 src/yafraycore/imagefilm.cc | 0 src/yafraycore/xmlparser.cc | 0 19 files changed, 7 insertions(+), 9 deletions(-) mode change 100755 => 100644 include/core_api/color.h mode change 100755 => 100644 include/core_api/imagefilm.h mode change 100755 => 100644 include/core_api/texture.h mode change 100755 => 100644 include/interface/xmlinterface.h mode change 100755 => 100644 include/interface/yafrayinterface.h mode change 100755 => 100644 include/textures/imagetex.h mode change 100755 => 100644 include/yafraycore/xmlparser.h mode change 100755 => 100644 src/bindings/yafaray_v3_interface.i mode change 100755 => 100644 src/interface/xmlinterface.cc mode change 100755 => 100644 src/interface/yafrayinterface.cc mode change 100755 => 100644 src/textures/basicnodes.cc mode change 100755 => 100644 src/textures/imagetex.cc mode change 100755 => 100644 src/xml_loader/xml-loader.cc mode change 100755 => 100644 src/yafraycore/environment.cc mode change 100755 => 100644 src/yafraycore/imagefilm.cc mode change 100755 => 100644 src/yafraycore/xmlparser.cc diff --git a/CMakeModules/FindYafPythonLibs.cmake b/CMakeModules/FindYafPythonLibs.cmake index 06fca574..c398cb71 100644 --- a/CMakeModules/FindYafPythonLibs.cmake +++ b/CMakeModules/FindYafPythonLibs.cmake @@ -36,9 +36,9 @@ ELSE(NOT REQUIRED_PYTHON_VERSION) SET(_CURRENT_VERSION ${REQUIRED_PYTHON_VERSION}) ENDIF(NOT REQUIRED_PYTHON_VERSION) -UNSET(PYTHON_DEBUG_LIBRARY CACHE) -UNSET(PYTHON_LIBRARY CACHE) -UNSET(PYTHON_INCLUDE_DIR CACHE) +#UNSET(PYTHON_DEBUG_LIBRARY CACHE) +#UNSET(PYTHON_LIBRARY CACHE) +#UNSET(PYTHON_INCLUDE_DIR CACHE) STRING(REPLACE "." "" _CURRENT_VERSION_NO_DOTS ${_CURRENT_VERSION}) diff --git a/include/core_api/color.h b/include/core_api/color.h old mode 100755 new mode 100644 diff --git a/include/core_api/imagefilm.h b/include/core_api/imagefilm.h old mode 100755 new mode 100644 diff --git a/include/core_api/texture.h b/include/core_api/texture.h old mode 100755 new mode 100644 diff --git a/include/interface/xmlinterface.h b/include/interface/xmlinterface.h old mode 100755 new mode 100644 diff --git a/include/interface/yafrayinterface.h b/include/interface/yafrayinterface.h old mode 100755 new mode 100644 diff --git a/include/textures/imagetex.h b/include/textures/imagetex.h old mode 100755 new mode 100644 diff --git a/include/utilities/mathOptimizations.h b/include/utilities/mathOptimizations.h index 43e6d084..32cd09ef 100644 --- a/include/utilities/mathOptimizations.h +++ b/include/utilities/mathOptimizations.h @@ -114,12 +114,7 @@ inline float asmSqrt(float n) { float r = n; #ifdef _MSC_VER - __asm - { - fld r - fsqrt - fstp r - } + r = sqrt(n); #elif defined (__APPLE__) asm( "flds %0;" diff --git a/include/yafraycore/xmlparser.h b/include/yafraycore/xmlparser.h old mode 100755 new mode 100644 diff --git a/src/bindings/yafaray_v3_interface.i b/src/bindings/yafaray_v3_interface.i old mode 100755 new mode 100644 diff --git a/src/interface/xmlinterface.cc b/src/interface/xmlinterface.cc old mode 100755 new mode 100644 diff --git a/src/interface/yafrayinterface.cc b/src/interface/yafrayinterface.cc old mode 100755 new mode 100644 diff --git a/src/textures/basicnodes.cc b/src/textures/basicnodes.cc old mode 100755 new mode 100644 diff --git a/src/textures/imagetex.cc b/src/textures/imagetex.cc old mode 100755 new mode 100644 diff --git a/src/xml_loader/xml-loader.cc b/src/xml_loader/xml-loader.cc old mode 100755 new mode 100644 diff --git a/src/yafraycore/console.cc b/src/yafraycore/console.cc index 9e937939..d4f586dc 100644 --- a/src/yafraycore/console.cc +++ b/src/yafraycore/console.cc @@ -3,6 +3,9 @@ #include #include #include +#ifdef _MSC_VER +#include +#endif __BEGIN_YAFRAY diff --git a/src/yafraycore/environment.cc b/src/yafraycore/environment.cc old mode 100755 new mode 100644 diff --git a/src/yafraycore/imagefilm.cc b/src/yafraycore/imagefilm.cc old mode 100755 new mode 100644 diff --git a/src/yafraycore/xmlparser.cc b/src/yafraycore/xmlparser.cc old mode 100755 new mode 100644 From 2b71cd657016c166358377a5cd4ed33ad319869f Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Wed, 27 Apr 2016 20:45:38 +0100 Subject: [PATCH 014/124] C++11 Threads: replacing the entire Threads system with the new-style C++11 standard threads Additionally to the migration to C++11 threads: * Fixed photon maps getting dimmer with every render when using multithread photons. * Adjusted the Progress Bars to show save/load * Removing CMake references to old thread system and all (very old) Scons files --- CMakeConfig/UserConfig.template | 11 - CMakeLists.txt | 20 - include/core_api/imagefilm.h | 3 +- include/core_api/mcintegrator.h | 1 + include/core_api/scene.h | 3 +- include/core_api/session.h | 3 + include/core_api/tiledintegrator.h | 10 +- include/integrators/photonintegr.h | 18 +- include/integrators/sppm.h | 1 - include/yafraycore/ccthreads.h | 119 ----- include/yafraycore/monitor.h | 3 +- include/yafraycore/photon.h | 5 +- src/backgrounds/SConscript | 26 -- src/cameras/SConscript | 30 -- src/image_handlers/SConscript | 28 -- src/integrators/SConscript | 39 -- src/integrators/photonintegr.cc | 669 ++++++++++++----------------- src/interface/SConscript | 17 - src/lights/SConscript | 45 -- src/materials/SConscript | 36 -- src/textures/SConscript | 27 -- src/volumes/SConscript | 27 -- src/xml_loader/SConscript | 24 -- src/yafraycore/CMakeLists.txt | 4 +- src/yafraycore/SConscript | 57 --- src/yafraycore/ccthreads.cc | 258 ----------- src/yafraycore/integrator.cc | 60 +-- src/yafraycore/kdtree.cc | 4 +- src/yafraycore/mcintegrator.cc | 270 ++++++------ src/yafraycore/ray_kdtree.cc | 4 +- 30 files changed, 440 insertions(+), 1382 deletions(-) delete mode 100644 include/yafraycore/ccthreads.h delete mode 100644 src/backgrounds/SConscript delete mode 100644 src/cameras/SConscript delete mode 100644 src/image_handlers/SConscript delete mode 100644 src/integrators/SConscript delete mode 100644 src/interface/SConscript delete mode 100644 src/lights/SConscript delete mode 100644 src/materials/SConscript delete mode 100644 src/textures/SConscript delete mode 100644 src/volumes/SConscript delete mode 100644 src/xml_loader/SConscript delete mode 100644 src/yafraycore/SConscript delete mode 100644 src/yafraycore/ccthreads.cc diff --git a/CMakeConfig/UserConfig.template b/CMakeConfig/UserConfig.template index 5bc2c5b2..d1d6cef5 100644 --- a/CMakeConfig/UserConfig.template +++ b/CMakeConfig/UserConfig.template @@ -14,17 +14,6 @@ set(YAF_USER_CONFIG ON) ################################################################################ ############################## Build configuration ############################# -# # -# Build with POSIX threads (pthreads) wrapper instead of # -# native threads wrapper on windows platforms # -# # -# NOTE: This option is ignored on *nix platforms # -# # -# Default: OFF # -# # - -set(WITH_Pthreads OFF) - # # # Build font rendering with FreeType # # # diff --git a/CMakeLists.txt b/CMakeLists.txt index 30d28383..73291f95 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,6 @@ set(CMAKE_COLOR_MAKEFILE ON) set(CMAKE_VERBOSE_MAKEFILE OFF) ####### Options ######## -option(WITH_Pthreads "Build with POSIX threads wrapper on windows platforms" OFF) option(WITH_Freetype "Build font rendering with FreeType" ON) option(WITH_OpenEXR "Build OpenEXR image I/O plugin" ON) option(WITH_JPEG "Build JPEG image I/O plugin" ON) @@ -81,30 +80,11 @@ else(LIBXML2_FOUND) message("Using LibXML: no") endif(LIBXML2_FOUND) -find_package(Threads REQUIRED) - if(WIN32) add_definitions(-DWIN32 ) add_definitions(-D_USE_MATH_DEFINES ) add_definitions(-D_hypot=hypot ) endif(WIN32) - -# Find optional libs -if(CMAKE_HAVE_PTHREAD_H) - if(WIN32) - if(WITH_Pthreads) - add_definitions(-DHAVE_PTHREAD) - message("Using Posix Threads: yes") - else(WITH_Pthreads) - message("Using Posix Threads: no (disabled by user)") - endif(WITH_Pthreads) - else(WIN32) - add_definitions(-DHAVE_PTHREAD) - message("Using Posix Threads: yes") - endif(WIN32) -else(CMAKE_HAVE_PTHREAD_H) - message("Using Posix Threads: no (not found)") -endif(CMAKE_HAVE_PTHREAD_H) if(WITH_Freetype) find_package(Freetype REQUIRED) diff --git a/include/core_api/imagefilm.h b/include/core_api/imagefilm.h index 640df56f..3598b714 100644 --- a/include/core_api/imagefilm.h +++ b/include/core_api/imagefilm.h @@ -26,7 +26,6 @@ #include #include "color.h" -#include #include #include #include @@ -159,7 +158,7 @@ class YAFRAYCORE_EXPORT imageFilm_t float *filterTable; colorOutput_t *output; // Thread mutes for shared access - yafthreads::mutex_t imageMutex, splitterMutex, outMutex, densityImageMutex; + std::mutex imageMutex, splitterMutex, outMutex, densityImageMutex; bool split, interactive, abort; double imageOutputPartialSaveTimeInterval; bool estimateDensity; diff --git a/include/core_api/mcintegrator.h b/include/core_api/mcintegrator.h index d4e35374..0574679f 100644 --- a/include/core_api/mcintegrator.h +++ b/include/core_api/mcintegrator.h @@ -57,6 +57,7 @@ class YAFRAYCORE_EXPORT mcIntegrator_t: public tiledIntegrator_t virtual color_t sampleAmbientOcclusion(renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo) const; virtual color_t sampleAmbientOcclusionPass(renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo) const; virtual color_t sampleAmbientOcclusionPassClay(renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo) const; + virtual void causticWorker(photonMap_t * causticMap, int threadID, const scene_t *scene, unsigned int nCausPhotons, pdf1D_t *lightPowerD, int numLights, const std::string &integratorName, const std::vector &causLights, int causDepth, progressBar_t *pb, int pbStep, unsigned int &totalPhotonsShot); int rDepth; //! Ray depth bool trShad; //! Use transparent shadows diff --git a/include/core_api/scene.h b/include/core_api/scene.h index 30b3a203..f13ca982 100644 --- a/include/core_api/scene.h +++ b/include/core_api/scene.h @@ -7,7 +7,6 @@ #include"color.h" #include"vector3d.h" #include -#include #include #include #include @@ -249,7 +248,7 @@ class YAFRAYCORE_EXPORT scene_t int mode; //!< sets the scene mode (triangle-only, virtual primitives) int signals; const renderEnvironment_t *env; //!< reference to the environment to which this scene belongs to - mutable yafthreads::mutex_t sig_mutex; + mutable std::mutex sig_mutex; }; __END_YAFRAY diff --git a/include/core_api/session.h b/include/core_api/session.h index 5dbd28cd..dc547149 100644 --- a/include/core_api/session.h +++ b/include/core_api/session.h @@ -28,6 +28,9 @@ #include #include #include +#include +#include +#include #include diff --git a/include/core_api/tiledintegrator.h b/include/core_api/tiledintegrator.h index 6155511a..02a28831 100644 --- a/include/core_api/tiledintegrator.h +++ b/include/core_api/tiledintegrator.h @@ -8,6 +8,8 @@ __BEGIN_YAFRAY +class threadControl_t; + class YAFRAYCORE_EXPORT tiledIntegrator_t: public surfaceIntegrator_t { public: @@ -23,6 +25,7 @@ class YAFRAYCORE_EXPORT tiledIntegrator_t: public surfaceIntegrator_t virtual bool renderPass(int numView, int samples, int offset, bool adaptive, int AA_pass_number); /*! render a tile; only required by default implementation of render() */ virtual bool renderTile(int numView, renderArea_t &a, int n_samples, int offset, bool adaptive, int threadID, int AA_pass_number = 0); + virtual void renderWorker(int mNumView, tiledIntegrator_t *integrator, scene_t *scene, imageFilm_t *imageFilm, threadControl_t *control, int threadID, int samples, int offset=0, bool adaptive=false, int AA_pass=0); // virtual void recursiveRaytrace(renderState_t &state, diffRay_t &ray, int rDepth, BSDF_t bsdfs, surfacePoint_t &sp, vector3d_t &wo, color_t &col, float &alpha) const; virtual void precalcDepths(); @@ -53,18 +56,15 @@ class YAFRAYCORE_EXPORT tiledIntegrator_t: public surfaceIntegrator_t }; -#ifdef USING_THREADS - struct threadControl_t { threadControl_t() : finishedThreads(0) {} - yafthreads::conditionVar_t countCV; //!< condition variable to signal main thread + std::mutex m; + std::condition_variable c; //!< condition variable to signal main thread std::vector areas; //!< area to be output to e.g. blender, if any volatile int finishedThreads; //!< number of finished threads, lock countCV when increasing/reading! }; -#endif - __END_YAFRAY #endif // Y_TILEDINTEGRATOR_H diff --git a/include/integrators/photonintegr.h b/include/integrators/photonintegr.h index 27273767..fc3444bc 100644 --- a/include/integrators/photonintegr.h +++ b/include/integrators/photonintegr.h @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -20,6 +19,18 @@ __BEGIN_YAFRAY +struct preGatherData_t +{ + preGatherData_t(photonMap_t *dm): diffuseMap(dm), fetched(0) {} + photonMap_t *diffuseMap; + + std::vector rad_points; + std::vector radianceVec; + progressBar_t *pbar; + volatile int fetched; + std::mutex mutx; +}; + class YAFRAYPLUGIN_EXPORT photonIntegrator_t: public mcIntegrator_t { public: @@ -28,6 +39,11 @@ class YAFRAYPLUGIN_EXPORT photonIntegrator_t: public mcIntegrator_t virtual bool preprocess(); virtual colorA_t integrate(renderState_t &state, diffRay_t &ray, colorPasses_t &colorPasses, int additionalDepth = 0) const; static integrator_t* factory(paraMap_t ¶ms, renderEnvironment_t &render); + virtual void preGatherWorker(preGatherData_t * gdata, float dsRad, int nSearch); + virtual void causticWorker(photonMap_t * causticMap, int threadID, const scene_t *scene, unsigned int nCausPhotons, const pdf1D_t *lightPowerD, int numCLights, const std::string &integratorName, const std::vector &tmplights, int causDepth, progressBar_t *pb, int pbStep, unsigned int &totalPhotonsShot, int maxBounces); + virtual void diffuseWorker(photonMap_t * diffuseMap, int threadID, const scene_t *scene, unsigned int nDiffusePhotons, const pdf1D_t *lightPowerD, int numDLights, const std::string &integratorName, const std::vector &tmplights, progressBar_t *pb, int pbStep, unsigned int &totalPhotonsShot, int maxBounces, bool finalGather, preGatherData_t &pgdat); + virtual void photonMapKdTreeWorker(photonMap_t * photonMap); + protected: color_t finalGathering(renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo, colorPasses_t &colorPasses) const; diff --git a/include/integrators/sppm.h b/include/integrators/sppm.h index 2d9168ef..b843e16d 100644 --- a/include/integrators/sppm.h +++ b/include/integrators/sppm.h @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include diff --git a/include/yafraycore/ccthreads.h b/include/yafraycore/ccthreads.h deleted file mode 100644 index 9c600106..00000000 --- a/include/yafraycore/ccthreads.h +++ /dev/null @@ -1,119 +0,0 @@ -#ifndef Y_CCTHREADS_H -#define Y_CCTHREADS_H - -#include - -#include - -#if HAVE_PTHREAD - #include - #define USING_THREADS -#elif defined(WIN32) - #include - #define USING_THREADS - #define WIN32_THREADS -#endif - -namespace yafthreads { - -/*! The try to provide a platform independant mutex, as a matter of fact - it is simply a pthread wrapper now... -*/ -class YAFRAYCORE_EXPORT mutex_t -{ - public: - mutex_t(); - void lock(); - void unlock(); - ~mutex_t(); - protected: - mutex_t(const mutex_t &m); - mutex_t & operator = (const mutex_t &m); -#if HAVE_PTHREAD - pthread_mutex_t m; -#elif defined( WIN32_THREADS ) - HANDLE winMutex; -#endif -}; - -/*! The try to provide a platform independant read-shared write-exclusive lock, - as a matter of fact it is simply a pthread wrapper now... -*/ -class YAFRAYCORE_EXPORT rwlock_t -{ - public: - rwlock_t(); - void readLock(); - void writeLock(); - void unlock(); - ~rwlock_t(); - protected: - rwlock_t(const rwlock_t &l); - rwlock_t & operator = (const rwlock_t &l); -#if HAVE_PTHREAD - pthread_rwlock_t l; -#endif -}; - - -/*! The try to provide a platform independant codition object, as a matter of fact - it is simply a pthread wrapper now... - It is mutex and condition variable in one! - Usage: waiting thread: lock(); ...initialize conditions to be met...; wait(); - signalling thread: lock(); ...check if you want to signal...; [signal();] unlock(); -*/ -class YAFRAYCORE_EXPORT conditionVar_t -{ - public: - conditionVar_t(); - ~conditionVar_t(); - void lock(); - void unlock(); - void signal(); - void wait(); - protected: - conditionVar_t(const conditionVar_t &m); - conditionVar_t & operator = (const conditionVar_t &m); -#if HAVE_PTHREAD - pthread_mutex_t m; - pthread_cond_t c; -#elif defined( WIN32_THREADS ) - HANDLE condHandle; - HANDLE winMutex; -#endif -}; - -class YAFRAYCORE_EXPORT thread_t -{ -#if HAVE_PTHREAD - friend void * wrapper(void *data); -#elif defined( WIN32_THREADS ) - friend DWORD WINAPI wrapper (void *data); -#endif - public: - thread_t() {running=false;}; - virtual ~thread_t(); - virtual void body()=0; - void run(); - void wait(); - bool isRunning()const {return running;}; -#if HAVE_PTHREAD - pthread_t getPid() {return id;}; -#elif defined( WIN32_THREADS ) - DWORD getPid() {return id;}; -#endif - protected: - bool running; - mutex_t lock; -#if HAVE_PTHREAD - pthread_t id; - pthread_attr_t attr; -#elif defined( WIN32_THREADS ) - DWORD id; - HANDLE winThread; -#endif -}; - -} // yafthreads - -#endif diff --git a/include/yafraycore/monitor.h b/include/yafraycore/monitor.h index 0dd0699d..f54530c9 100644 --- a/include/yafraycore/monitor.h +++ b/include/yafraycore/monitor.h @@ -3,7 +3,6 @@ #define Y_MONITOR_H #include -#include __BEGIN_YAFRAY //! Progress bar abstract class with pure virtual members @@ -19,7 +18,7 @@ class YAFRAYCORE_EXPORT progressBar_t virtual void done() = 0; //! method to pass some informative text to the progress bar in case needed virtual void setTag(const char* text) = 0; - yafthreads::mutex_t mutex; + std::mutex mutx; }; /*! the default console progress bar (implemented in console.cc) diff --git a/include/yafraycore/photon.h b/include/yafraycore/photon.h index ee7fc847..ceb4e629 100644 --- a/include/yafraycore/photon.h +++ b/include/yafraycore/photon.h @@ -6,7 +6,6 @@ #include "pkdtree.h" #include -#include #include #include @@ -170,9 +169,7 @@ class YAFRAYCORE_EXPORT photonMap_t // void gather(const point3d_t &P, std::vector< foundPhoton_t > &found, unsigned int K, PFLOAT &sqRadius) const; int gather(const point3d_t &P, foundPhoton_t *found, unsigned int K, PFLOAT &sqRadius) const; const photon_t* findNearest(const point3d_t &P, const vector3d_t &n, PFLOAT dist) const; -#ifdef USING_THREADS - yafthreads::mutex_t mutex; -#endif + std::mutex mutx; protected: std::vector photons; diff --git a/src/backgrounds/SConscript b/src/backgrounds/SConscript deleted file mode 100644 index a8f8298b..00000000 --- a/src/backgrounds/SConscript +++ /dev/null @@ -1,26 +0,0 @@ -import sys - -#Import('config') -Import('plugin_env') -Import('append_includes') - -backg_env = plugin_env.Clone(); - -backg_env.Append (LIBS = ['bglight']) -backg_env.Append (LIBPATH = ['../lights']) -append_includes(backg_env, ['PTHREAD']) - -sunsky=backg_env.SharedLibrary (target='sunsky', source=['sunsky.cc', 'sunspectrum.cc']) -backg_env.Install('${YF_PLUGINPATH}',sunsky) - -textureback=backg_env.SharedLibrary (target='textureback', source=['textureback.cc']) -backg_env.Install('${YF_PLUGINPATH}',textureback) - -gradientback=backg_env.SharedLibrary (target='gradientback', source=['gradientback.cc']) -backg_env.Install('${YF_PLUGINPATH}',gradientback) - -DarkSky=backg_env.SharedLibrary (target='DarkSky', source=['DarkSky/darksky.cc']) -backg_env.Install('${YF_PLUGINPATH}', DarkSky) - -backg_env.Install('${YF_PACKPATH}${YF_PLUGINPATH}',[gradientback, textureback, sunsky, DarkSky]) -backg_env.Alias('install_backg','${YF_PLUGINPATH}') diff --git a/src/cameras/SConscript b/src/cameras/SConscript deleted file mode 100644 index 5d813226..00000000 --- a/src/cameras/SConscript +++ /dev/null @@ -1,30 +0,0 @@ -import sys -Import('append_includes') - -Import('plugin_env') -Import('static_env') -Import('append_lib') - -cameras_env = plugin_env.Clone(); - -#perspectiveCamera=cameras_env.SharedLibrary (target='perspectiveCamera', source=['perspectiveCamera.cc']) -#cameras_env.Install('${YF_PLUGINPATH}',perspectiveCamera) -perspectiveCameras=cameras_env.SharedLibrary (target='perspectiveCameras', source=['perspectiveCamera.cc','architectCamera.cc']) -cameras_env.Install('${YF_PLUGINPATH}',perspectiveCameras) - -orthographicCamera=cameras_env.SharedLibrary (target='orthographicCamera', source=['orthographicCamera.cc']) -cameras_env.Install('${YF_PLUGINPATH}',orthographicCamera) - -angularCamera=cameras_env.SharedLibrary (target='angularCamera', source=['angularCamera.cc']) -cameras_env.Install('${YF_PLUGINPATH}',angularCamera) - -#architectCamera_env = cameras_env.Clone(); -#architectCamera_env.Append(LIBS = ['perspectiveCamera']) -#architectCamera_env.Append(LIBPATH = ['../cameras']) -#architectCamera=architectCamera_env.SharedLibrary (target='architectCamera', source=['architectCamera.cc']) -#cameras_env.Install('${YF_PLUGINPATH}',architectCamera) - -#cameras_env.Install('${YF_PACKPATH}${YF_PLUGINPATH}',[perspectiveCamera,architectCamera,orthographicCamera,angularCamera]) -cameras_env.Install('${YF_PACKPATH}${YF_PLUGINPATH}',[perspectiveCameras,orthographicCamera,angularCamera]) - -cameras_env.Alias('install_cameras','${YF_PLUGINPATH}') diff --git a/src/image_handlers/SConscript b/src/image_handlers/SConscript deleted file mode 100644 index 7a390703..00000000 --- a/src/image_handlers/SConscript +++ /dev/null @@ -1,28 +0,0 @@ -import sys - -Import('plugin_env') -Import('append_lib') -Import('append_includes') - -image_handlers_env = plugin_env.Clone(); - -append_includes(image_handlers_env, ['PTHREAD','EXR','PNG']) -append_lib(image_handlers_env, ['JPEG','PNG','EXR','ZLIB','TIFF']) - -exr = image_handlers_env.SharedLibrary (target='exrHandler', source=['exrHandler.cc']) -image_handlers_env.Install('${YF_PLUGINPATH}',exr) - -tga = image_handlers_env.SharedLibrary (target='tgaHandler', source=['tgaHandler.cc']) -image_handlers_env.Install('${YF_PLUGINPATH}',tga) - -png = image_handlers_env.SharedLibrary (target='pngHandler', source=['pngHandler.cc']) -image_handlers_env.Install('${YF_PLUGINPATH}',png) - -jpg = image_handlers_env.SharedLibrary (target='jpgHandler', source=['jpgHandler.cc']) -image_handlers_env.Install('${YF_PLUGINPATH}',jpg) - -tif = image_handlers_env.SharedLibrary (target='tifHandler', source=['tifHandler.cc']) -image_handlers_env.Install('${YF_PLUGINPATH}',tif) - -image_handlers_env.Install('${YF_PACKPATH}${YF_PLUGINPATH}',[exr, tga, png, jpg, tif]) -image_handlers_env.Alias('install_image_handlers','${YF_PLUGINPATH}') diff --git a/src/integrators/SConscript b/src/integrators/SConscript deleted file mode 100644 index 6e537b36..00000000 --- a/src/integrators/SConscript +++ /dev/null @@ -1,39 +0,0 @@ -import sys -Import('append_lib') - -#Import('config') -Import('plugin_env') - -integr_env = plugin_env.Clone(); -append_lib(integr_env, ['PTHREAD', 'MISC']) - -directlight=integr_env.SharedLibrary (target='directlight', source=['directlight.cc', 'common.cc']) -integr_env.Install('${YF_PLUGINPATH}',directlight) - -photonmap=integr_env.SharedLibrary (target='photonmap', source=['photonintegr.cc', 'common.cc']) -integr_env.Install('${YF_PLUGINPATH}',photonmap) - -pathtrace=integr_env.SharedLibrary (target='pathtrace', source=['pathtracer.cc', 'common.cc']) -integr_env.Install('${YF_PLUGINPATH}',pathtrace) - -bidirpath=integr_env.SharedLibrary (target='bidirpath', source=['bidirpath.cc','common.cc']) -integr_env.Install('${YF_PLUGINPATH}',bidirpath) - -EmissionIntegrator=integr_env.SharedLibrary (target='EmissionIntegrator', source=['EmissionIntegrator.cc']) -integr_env.Install('${YF_PLUGINPATH}',EmissionIntegrator) - -SingleScatterIntegrator=integr_env.SharedLibrary (target='SingleScatterIntegrator', source=['SingleScatterIntegrator.cc']) -integr_env.Install('${YF_PLUGINPATH}',SingleScatterIntegrator) - -EmptyVolumeIntegrator=integr_env.SharedLibrary (target='EmptyVolumeIntegrator', source=['EmptyVolumeIntegrator.cc']) -integr_env.Install('${YF_PLUGINPATH}',EmptyVolumeIntegrator) - -DebugIntegrator=integr_env.SharedLibrary (target='DebugIntegrator', source=['DebugIntegrator.cc']) -integr_env.Install('${YF_PLUGINPATH}',DebugIntegrator) - -SkyIntegrator=integr_env.SharedLibrary (target='SkyIntegrator', source=['SkyIntegrator.cc']) -integr_env.Install('${YF_PLUGINPATH}',SkyIntegrator) - -integr_env.Install('${YF_PACKPATH}${YF_PLUGINPATH}',[directlight,photonmap,pathtrace,bidirpath,EmissionIntegrator, - SingleScatterIntegrator,EmptyVolumeIntegrator,DebugIntegrator,SkyIntegrator]) -integr_env.Alias('install_integr','${YF_PLUGINPATH}') diff --git a/src/integrators/photonintegr.cc b/src/integrators/photonintegr.cc index 73bfd2bf..c1cfd83c 100644 --- a/src/integrators/photonintegr.cc +++ b/src/integrators/photonintegr.cc @@ -28,39 +28,16 @@ __BEGIN_YAFRAY -struct preGatherData_t -{ - preGatherData_t(photonMap_t *dm): diffuseMap(dm), fetched(0) {} - photonMap_t *diffuseMap; - - std::vector rad_points; - std::vector radianceVec; - progressBar_t *pbar; - volatile int fetched; - yafthreads::mutex_t mutex; -}; - -class preGatherWorker_t: public yafthreads::thread_t -{ - public: - preGatherWorker_t(preGatherData_t *dat, float dsRad, int search): - gdata(dat), dsRadius_2(dsRad*dsRad), nSearch(search) {}; - virtual void body(); - protected: - preGatherData_t *gdata; - float dsRadius_2; - int nSearch; -}; - -void preGatherWorker_t::body() +void photonIntegrator_t::preGatherWorker(preGatherData_t * gdata, float dsRad, int nSearch) { unsigned int start, end, total; + float dsRadius_2 = dsRad*dsRad; - gdata->mutex.lock(); + gdata->mutx.lock(); start = gdata->fetched; total = gdata->rad_points.size(); end = gdata->fetched = std::min(total, start + 32); - gdata->mutex.unlock(); + gdata->mutx.unlock(); foundPhoton_t *gathered = new foundPhoton_t[nSearch]; @@ -94,11 +71,11 @@ void preGatherWorker_t::body() gdata->radianceVec[n] = photon_t(rnorm, gdata->rad_points[n].pos, sum); } - gdata->mutex.lock(); + gdata->mutx.lock(); start = gdata->fetched; end = gdata->fetched = std::min(total, start + 32); gdata->pbar->update(32); - gdata->mutex.unlock(); + gdata->mutx.unlock(); } delete[] gathered; } @@ -126,30 +103,8 @@ photonIntegrator_t::~photonIntegrator_t() // Empty } -class causticWorker_t: public yafthreads::thread_t -{ - public: - causticWorker_t(photonMap_t * causticmap, int thread_id, const scene_t *sc, unsigned int ncausphotons, const pdf1D_t *lightpowerd, int numclights, const std::string &integratorname, const std::vector &tmp_lights, int causdepth, progressBar_t *ppb, int pbstep, unsigned int &totalphotonsshot, int maxbounces): - causticMap(causticmap), threadID(thread_id), scene(sc), nCausPhotons(ncausphotons), lightPowerD(lightpowerd), numCLights(numclights), integratorName(integratorname), tmplights(tmp_lights), causDepth(causdepth), pb(ppb), pbStep(pbstep), totalPhotonsShot(totalphotonsshot), maxBounces(maxbounces) {}; - virtual void body(); - protected: - photonMap_t * causticMap; - int threadID; - const scene_t *scene; - unsigned int nCausPhotons; - const pdf1D_t *lightPowerD; - int numCLights; - const std::string &integratorName; - const std::vector &tmplights; - int causDepth; - std::vector localCausticPhotons; - progressBar_t *pb; - int pbStep; - unsigned int &totalPhotonsShot; - int maxBounces; -}; - -void causticWorker_t::body() + +void photonIntegrator_t::causticWorker(photonMap_t * causticMap, int threadID, const scene_t *scene, unsigned int nCausPhotons, const pdf1D_t *lightPowerD, int numCLights, const std::string &integratorName, const std::vector &tmplights, int causDepth, progressBar_t *pb, int pbStep, unsigned int &totalPhotonsShot, int maxBounces) { ray_t ray; float lightNumPdf, lightPdf, s1, s2, s3, s4, s5, s6, s7, sL; @@ -168,6 +123,7 @@ void causticWorker_t::body() float fNumLights = (float)numCLights; unsigned int nCausPhotons_thread = 1 + ( (nCausPhotons - 1) / scene->getNumThreadsPhotons() ); + std::vector localCausticPhotons; localCausticPhotons.clear(); localCausticPhotons.reserve(nCausPhotons_thread); @@ -177,10 +133,6 @@ void causticWorker_t::body() { if(scene->getSignals() & Y_SIG_ABORT) { return; } - //causticMap->mutex.lock(); - //Y_DEBUG << "Thread while First=" << this << " curr=" << curr << " curr_thread=" << curr_thread << " done=" << done << yendl; - //causticMap->mutex.unlock(); - unsigned int haltoncurr = curr + nCausPhotons_thread * threadID; state.chromatic = true; @@ -196,9 +148,9 @@ void causticWorker_t::body() if(lightNum >= numCLights) { - causticMap->mutex.lock(); + causticMap->mutx.lock(); Y_ERROR << integratorName << ": lightPDF sample error! " << sL << "/" << lightNum << yendl; - causticMap->mutex.unlock(); + causticMap->mutx.unlock(); return; } @@ -222,9 +174,9 @@ void causticWorker_t::body() { if(std::isnan(pcol.R) || std::isnan(pcol.G) || std::isnan(pcol.B)) { - causticMap->mutex.lock(); + causticMap->mutx.lock(); Y_WARNING << integratorName << ": NaN on photon color for light" << lightNum + 1 << "." << yendl; - causticMap->mutex.unlock(); + causticMap->mutx.unlock(); continue; } @@ -290,45 +242,19 @@ void causticWorker_t::body() ++curr; if(curr % pbStep == 0) { - pb->mutex.lock(); + pb->mutx.lock(); pb->update(); - pb->mutex.unlock(); + pb->mutx.unlock(); } done = (curr >= nCausPhotons_thread); } - causticMap->mutex.lock(); + causticMap->mutx.lock(); causticMap->appendVector(localCausticPhotons, curr); totalPhotonsShot += curr; - causticMap->mutex.unlock(); + causticMap->mutx.unlock(); } - -class diffuseWorker_t: public yafthreads::thread_t -{ - public: - diffuseWorker_t(photonMap_t * diffusemap, int thread_id, const scene_t *sc, unsigned int ndiffusephotons, const pdf1D_t *lightpowerd, int numdlights, const std::string &integratorname, const std::vector &tmp_lights, progressBar_t *ppb, int pbstep, unsigned int &totalphotonsshot, int maxbounces, bool finalgather, preGatherData_t &ppgdat): - diffuseMap(diffusemap), threadID(thread_id), scene(sc), nDiffusePhotons(ndiffusephotons), lightPowerD(lightpowerd), numDLights(numdlights), integratorName(integratorname), tmplights(tmp_lights), pb(ppb), pbStep(pbstep), totalPhotonsShot(totalphotonsshot), maxBounces(maxbounces), finalGather(finalgather), pgdat(ppgdat) {}; - virtual void body(); - protected: - photonMap_t * diffuseMap; - int threadID; - const scene_t *scene; - unsigned int nDiffusePhotons; - const pdf1D_t *lightPowerD; - int numDLights; - const std::string &integratorName; - const std::vector &tmplights; - std::vector localDiffusePhotons; - std::vector localRadPoints; - progressBar_t *pb; - int pbStep; - unsigned int &totalPhotonsShot; - int maxBounces; - bool finalGather; - preGatherData_t &pgdat; -}; - -void diffuseWorker_t::body() +void photonIntegrator_t::diffuseWorker(photonMap_t * diffuseMap, int threadID, const scene_t *scene, unsigned int nDiffusePhotons, const pdf1D_t *lightPowerD, int numDLights, const std::string &integratorName, const std::vector &tmplights, progressBar_t *pb, int pbStep, unsigned int &totalPhotonsShot, int maxBounces, bool finalGather, preGatherData_t &pgdat) { ray_t ray; float lightNumPdf, lightPdf, s1, s2, s3, s4, s5, s6, s7, sL; @@ -348,9 +274,11 @@ void diffuseWorker_t::body() unsigned int nDiffusePhotons_thread = 1 + ( (nDiffusePhotons - 1) / scene->getNumThreadsPhotons() ); + std::vector localDiffusePhotons; + std::vector localRadPoints; + localDiffusePhotons.clear(); localDiffusePhotons.reserve(nDiffusePhotons_thread); - localRadPoints.clear(); float invDiffPhotons = 1.f / (float)nDiffusePhotons; @@ -370,9 +298,9 @@ void diffuseWorker_t::body() int lightNum = lightPowerD->DSample(sL, &lightNumPdf); if(lightNum >= numDLights) { - diffuseMap->mutex.lock(); + diffuseMap->mutx.lock(); Y_ERROR << integratorName << ": lightPDF sample error! " << sL << "/" << lightNum << yendl; - diffuseMap->mutex.unlock(); + diffuseMap->mutx.unlock(); return; } @@ -398,9 +326,9 @@ void diffuseWorker_t::body() { if(std::isnan(pcol.R) || std::isnan(pcol.G) || std::isnan(pcol.B)) { - diffuseMap->mutex.lock(); + diffuseMap->mutx.lock(); Y_WARNING << integratorName << ": NaN on photon color for light" << lightNum + 1 << "." << yendl; - diffuseMap->mutex.unlock(); + diffuseMap->mutx.unlock(); continue; } @@ -468,39 +396,33 @@ void diffuseWorker_t::body() ++curr; if(curr % pbStep == 0) { - pb->mutex.lock(); + pb->mutx.lock(); pb->update(); - pb->mutex.unlock(); + pb->mutx.unlock(); } done = (curr >= nDiffusePhotons_thread); } - diffuseMap->mutex.lock(); + diffuseMap->mutx.lock(); diffuseMap->appendVector(localDiffusePhotons, curr); totalPhotonsShot += curr; - diffuseMap->mutex.unlock(); + diffuseMap->mutx.unlock(); - pgdat.mutex.lock(); + pgdat.mutx.lock(); pgdat.rad_points.insert(std::end(pgdat.rad_points), std::begin(localRadPoints), std::end(localRadPoints)); - pgdat.mutex.unlock(); + pgdat.mutx.unlock(); } -class photonMapKdTreeWorker_t: public yafthreads::thread_t -{ - public: - photonMapKdTreeWorker_t(photonMap_t * photonmap): - photonMap(photonmap) {}; - virtual void body(); - protected: - photonMap_t * photonMap; -}; - -void photonMapKdTreeWorker_t::body() +void photonIntegrator_t::photonMapKdTreeWorker(photonMap_t * photonMap) { photonMap->updateTree(); } bool photonIntegrator_t::preprocess() { + progressBar_t *pb; + if(intpb) pb = intpb; + else pb = new ConsoleProgressBar_t(80); + lookupRad = 4*dsRadius*dsRadius; std::stringstream set; @@ -544,6 +466,7 @@ bool photonIntegrator_t::preprocess() if(usePhotonCaustics) { + pb->setTag("Loading caustic photon map from temp folder..."); std::string filename = boost::filesystem::temp_directory_path().string(); filename += "/yafaray_photonMap_caustics.tmp"; Y_INFO << integratorName << ": Loading caustics photon map from: " << filename << ". If it does not match the scene you could have crashes and/or incorrect renders, USE WITH CARE!" << yendl; @@ -553,6 +476,7 @@ bool photonIntegrator_t::preprocess() if(usePhotonDiffuse) { + pb->setTag("Loading diffuse photon map from temp folder..."); std::string filename = boost::filesystem::temp_directory_path().string(); filename += "/yafaray_photonMap_diffuse.tmp"; Y_INFO << integratorName << ": Loading diffuse photon map from: " << filename << ". If it does not match the scene you could have crashes and/or incorrect renders, USE WITH CARE!" << yendl; @@ -562,6 +486,7 @@ bool photonIntegrator_t::preprocess() if(usePhotonDiffuse && finalGather) { + pb->setTag("Loading FG radiance map from temp folder..."); std::string filename = boost::filesystem::temp_directory_path().string(); filename += "/yafaray_photonMap_fg_radiance.tmp"; Y_INFO << integratorName << ": Loading FG radiance photon map from: " << filename << ". If it does not match the scene you could have crashes and/or incorrect renders, USE WITH CARE!" << yendl; @@ -641,7 +566,13 @@ bool photonIntegrator_t::preprocess() } session.diffuseMap->clear(); + session.diffuseMap->setNumPaths(0); + session.diffuseMap->reserveMemory(nDiffusePhotons); session.causticMap->clear(); + session.causticMap->setNumPaths(0); + session.causticMap->reserveMemory(nCausPhotons); + session.radianceMap->clear(); + session.radianceMap->setNumPaths(0); ray_t ray; float lightNumPdf, lightPdf; @@ -661,10 +592,7 @@ bool photonIntegrator_t::preprocess() unsigned char userdata[USER_DATA_SIZE+7]; state.userdata = (void *)( &userdata[7] - ( ((size_t)&userdata[7])&7 ) ); // pad userdata to 8 bytes state.cam = scene->getCamera(); - progressBar_t *pb; int pbStep; - if(intpb) pb = intpb; - else pb = new ConsoleProgressBar_t(80); tmplights.clear(); @@ -713,139 +641,135 @@ bool photonIntegrator_t::preprocess() pb->setTag("Building diffuse photon map..."); //Pregather diffuse photons -#ifdef USING_THREADS int nThreads = scene->getNumThreadsPhotons(); nDiffusePhotons = (nDiffusePhotons / nThreads) * nThreads; //rounding the number of diffuse photons so it's a number divisible by the number of threads (distribute uniformly among the threads) Y_PARAMS << integratorName << ": Shooting "< 1) + if(nThreads >= 2) { - std::vector workers; - for(int i=0; irun(); - for(int i=0;iwait(); - for(int i=0;i threads; + for(int i=0; igetSignals() & Y_SIG_ABORT) { pb->done(); if(!intpb) delete pb; return false; } - - s1 = RI_vdC(curr); - s2 = scrHalton(2, curr); - s3 = scrHalton(3, curr); - s4 = scrHalton(4, curr); - - sL = float(curr) * invDiffPhotons; - int lightNum = lightPowerD->DSample(sL, &lightNumPdf); - if(lightNum >= numDLights) - { - Y_ERROR << integratorName << ": lightPDF sample error! " << sL << "/" << lightNum << "... stopping now." << yendl; - delete lightPowerD; - return false; - } - - pcol = tmplights[lightNum]->emitPhoton(s1, s2, s3, s4, ray, lightPdf); - ray.tmin = scene->rayMinDist; - ray.tmax = -1.0; - pcol *= fNumLights*lightPdf/lightNumPdf; //remember that lightPdf is the inverse of th pdf, hence *=... + float invDiffPhotons = 1.f / (float)nDiffusePhotons; + float s1, s2, s3, s4, s5, s6, s7, sL; - if(pcol.isBlack()) + while(!done) { - ++curr; - done = (curr >= nDiffusePhotons); - continue; - } + if(scene->getSignals() & Y_SIG_ABORT) { pb->done(); if(!intpb) delete pb; return false; } - int nBounces=0; - bool causticPhoton = false; - bool directPhoton = true; - const material_t *material = nullptr; - BSDF_t bsdfs; + s1 = RI_vdC(curr); + s2 = scrHalton(2, curr); + s3 = scrHalton(3, curr); + s4 = scrHalton(4, curr); - while( scene->intersect(ray, sp) ) - { - if(std::isnan(pcol.R) || std::isnan(pcol.G) || std::isnan(pcol.B)) + sL = float(curr) * invDiffPhotons; + int lightNum = lightPowerD->DSample(sL, &lightNumPdf); + if(lightNum >= numDLights) { - Y_WARNING << integratorName << ": NaN on photon color for light" << lightNum + 1 << "." << yendl; - continue; + Y_ERROR << integratorName << ": lightPDF sample error! " << sL << "/" << lightNum << "... stopping now." << yendl; + delete lightPowerD; + return false; } + + pcol = tmplights[lightNum]->emitPhoton(s1, s2, s3, s4, ray, lightPdf); + ray.tmin = scene->rayMinDist; + ray.tmax = -1.0; + pcol *= fNumLights*lightPdf/lightNumPdf; //remember that lightPdf is the inverse of th pdf, hence *=... - color_t transm(1.f); - color_t vcol(0.f); - const volumeHandler_t* vol = nullptr; - - if(material) + if(pcol.isBlack()) { - if((bsdfs&BSDF_VOLUMETRIC) && (vol=material->getVolumeHandler(sp.Ng * -ray.dir < 0))) - { - if(vol->transmittance(state, ray, vcol)) transm = vcol; - } + ++curr; + done = (curr >= nDiffusePhotons); + continue; } - - vector3d_t wi = -ray.dir, wo; - material = sp.material; - material->initBSDF(state, sp, bsdfs); - - if(bsdfs & (BSDF_DIFFUSE)) + + int nBounces=0; + bool causticPhoton = false; + bool directPhoton = true; + const material_t *material = nullptr; + BSDF_t bsdfs; + + while( scene->intersect(ray, sp) ) { - //deposit photon on surface - if(!causticPhoton) + if(std::isnan(pcol.R) || std::isnan(pcol.G) || std::isnan(pcol.B)) + { + Y_WARNING << integratorName << ": NaN on photon color for light" << lightNum + 1 << "." << yendl; + continue; + } + + color_t transm(1.f); + color_t vcol(0.f); + const volumeHandler_t* vol = nullptr; + + if(material) { - photon_t np(wi, sp.P, pcol); - session.diffuseMap->pushPhoton(np); - session.diffuseMap->setNumPaths(curr); + if((bsdfs&BSDF_VOLUMETRIC) && (vol=material->getVolumeHandler(sp.Ng * -ray.dir < 0))) + { + if(vol->transmittance(state, ray, vcol)) transm = vcol; + } } - // create entry for radiance photon: - // don't forget to choose subset only, face normal forward; geometric vs. smooth normal? - if(finalGather && ourRandom() < 0.125 && !causticPhoton ) + + vector3d_t wi = -ray.dir, wo; + material = sp.material; + material->initBSDF(state, sp, bsdfs); + + if(bsdfs & (BSDF_DIFFUSE)) { - vector3d_t N = FACE_FORWARD(sp.Ng, sp.N, wi); - radData_t rd(sp.P, N); - rd.refl = material->getReflectivity(state, sp, BSDF_DIFFUSE | BSDF_GLOSSY | BSDF_REFLECT); - rd.transm = material->getReflectivity(state, sp, BSDF_DIFFUSE | BSDF_GLOSSY | BSDF_TRANSMIT); - pgdat.rad_points.push_back(rd); + //deposit photon on surface + if(!causticPhoton) + { + photon_t np(wi, sp.P, pcol); + session.diffuseMap->pushPhoton(np); + session.diffuseMap->setNumPaths(curr); + } + // create entry for radiance photon: + // don't forget to choose subset only, face normal forward; geometric vs. smooth normal? + if(finalGather && ourRandom() < 0.125 && !causticPhoton ) + { + vector3d_t N = FACE_FORWARD(sp.Ng, sp.N, wi); + radData_t rd(sp.P, N); + rd.refl = material->getReflectivity(state, sp, BSDF_DIFFUSE | BSDF_GLOSSY | BSDF_REFLECT); + rd.transm = material->getReflectivity(state, sp, BSDF_DIFFUSE | BSDF_GLOSSY | BSDF_TRANSMIT); + pgdat.rad_points.push_back(rd); + } } - } - // need to break in the middle otherwise we scatter the photon and then discard it => redundant - if(nBounces == maxBounces) break; - // scatter photon - int d5 = 3*nBounces + 5; - - s5 = scrHalton(d5, curr); - s6 = scrHalton(d5+1, curr); - s7 = scrHalton(d5+2, curr); - - pSample_t sample(s5, s6, s7, BSDF_ALL, pcol, transm); + // need to break in the middle otherwise we scatter the photon and then discard it => redundant + if(nBounces == maxBounces) break; + // scatter photon + int d5 = 3*nBounces + 5; + + s5 = scrHalton(d5, curr); + s6 = scrHalton(d5+1, curr); + s7 = scrHalton(d5+2, curr); + + pSample_t sample(s5, s6, s7, BSDF_ALL, pcol, transm); - bool scattered = material->scatterPhoton(state, sp, wi, wo, sample); - if(!scattered) break; //photon was absorped. + bool scattered = material->scatterPhoton(state, sp, wi, wo, sample); + if(!scattered) break; //photon was absorped. - pcol = sample.color; + pcol = sample.color; - causticPhoton = ((sample.sampledFlags & (BSDF_GLOSSY | BSDF_SPECULAR | BSDF_DISPERSIVE)) && directPhoton) || - ((sample.sampledFlags & (BSDF_GLOSSY | BSDF_SPECULAR | BSDF_FILTER | BSDF_DISPERSIVE)) && causticPhoton); - directPhoton = (sample.sampledFlags & BSDF_FILTER) && directPhoton; + causticPhoton = ((sample.sampledFlags & (BSDF_GLOSSY | BSDF_SPECULAR | BSDF_DISPERSIVE)) && directPhoton) || + ((sample.sampledFlags & (BSDF_GLOSSY | BSDF_SPECULAR | BSDF_FILTER | BSDF_DISPERSIVE)) && causticPhoton); + directPhoton = (sample.sampledFlags & BSDF_FILTER) && directPhoton; - ray.from = sp.P; - ray.dir = wo; - ray.tmin = scene->rayMinDist; - ray.tmax = -1.0; - ++nBounces; + ray.from = sp.P; + ray.dir = wo; + ray.tmin = scene->rayMinDist; + ray.tmax = -1.0; + ++nBounces; + } + ++curr; + if(curr % pbStep == 0) pb->update(); + done = (curr >= nDiffusePhotons); } - ++curr; - if(curr % pbStep == 0) pb->update(); - done = (curr >= nDiffusePhotons); - } } pb->done(); @@ -870,20 +794,17 @@ bool photonIntegrator_t::preprocess() Y_INFO << integratorName << ": Diffuse photon mapping disabled, skipping..." << yendl; } -#ifdef USING_THREADS - photonMapKdTreeWorker_t * diffuseMapBuildKdTree = nullptr; - + std::thread * diffuseMapBuildKdTree_thread = nullptr; + if( usePhotonDiffuse && session.diffuseMap->nPhotons() > 0 && scene->getNumThreadsPhotons() >= 2) { Y_INFO << integratorName << ": Building diffuse photons kd-tree:" << yendl; pb->setTag("Building diffuse photons kd-tree..."); - diffuseMapBuildKdTree = new photonMapKdTreeWorker_t(session.diffuseMap); - - diffuseMapBuildKdTree->run(); + diffuseMapBuildKdTree_thread = new std::thread(&photonIntegrator_t::photonMapKdTreeWorker, this, session.diffuseMap); } else -#endif + if( usePhotonDiffuse && session.diffuseMap->nPhotons() > 0) { Y_INFO << integratorName << ": Building diffuse photons kd-tree:" << yendl; @@ -935,139 +856,135 @@ bool photonIntegrator_t::preprocess() pb->setTag("Building caustics photon map..."); //Pregather caustic photons - -#ifdef USING_THREADS int nThreads = scene->getNumThreadsPhotons(); nCausPhotons = (nCausPhotons / nThreads) * nThreads; //rounding the number of diffuse photons so it's a number divisible by the number of threads (distribute uniformly among the threads) Y_PARAMS << integratorName << ": Shooting "< 1) + + if(nThreads >= 2) { - std::vector workers; - for(int i=0; irun(); - for(int i=0;iwait(); - for(int i=0;i threads; + for(int i=0; igetSignals() & Y_SIG_ABORT) { pb->done(); if(!intpb) delete pb; return false; } - state.chromatic = true; - state.wavelength = scrHalton(5,curr); - - s1 = RI_vdC(curr); - s2 = scrHalton(2, curr); - s3 = scrHalton(3, curr); - s4 = scrHalton(4, curr); - - sL = float(curr) * invCaustPhotons; - int lightNum = lightPowerD->DSample(sL, &lightNumPdf); + bool done=false; - if(lightNum >= numCLights) + float invCaustPhotons = 1.f / (float)nCausPhotons; + float s1, s2, s3, s4, s5, s6, s7, sL; + + while(!done) { - Y_ERROR << integratorName << ": lightPDF sample error! "<getSignals() & Y_SIG_ABORT) { pb->done(); if(!intpb) delete pb; return false; } + state.chromatic = true; + state.wavelength = scrHalton(5,curr); - pcol = tmplights[lightNum]->emitPhoton(s1, s2, s3, s4, ray, lightPdf); - ray.tmin = scene->rayMinDist; - ray.tmax = -1.0; - pcol *= fNumLights*lightPdf/lightNumPdf; //remember that lightPdf is the inverse of th pdf, hence *=... - if(pcol.isBlack()) - { - ++curr; - done = (curr >= nCausPhotons); - continue; - } - int nBounces=0; - bool causticPhoton = false; - bool directPhoton = true; - const material_t *material = nullptr; - BSDF_t bsdfs; + s1 = RI_vdC(curr); + s2 = scrHalton(2, curr); + s3 = scrHalton(3, curr); + s4 = scrHalton(4, curr); - while( scene->intersect(ray, sp) ) - { - if(std::isnan(pcol.R) || std::isnan(pcol.G) || std::isnan(pcol.B)) + sL = float(curr) * invCaustPhotons; + int lightNum = lightPowerD->DSample(sL, &lightNumPdf); + + if(lightNum >= numCLights) { - Y_WARNING << integratorName << ": NaN on photon color for light" << lightNum + 1 << "." << yendl; + Y_ERROR << integratorName << ": lightPDF sample error! "<emitPhoton(s1, s2, s3, s4, ray, lightPdf); + ray.tmin = scene->rayMinDist; + ray.tmax = -1.0; + pcol *= fNumLights*lightPdf/lightNumPdf; //remember that lightPdf is the inverse of th pdf, hence *=... + if(pcol.isBlack()) + { + ++curr; + done = (curr >= nCausPhotons); continue; } - - color_t transm(1.f); - color_t vcol(0.f); - const volumeHandler_t* vol = nullptr; - - if(material) + int nBounces=0; + bool causticPhoton = false; + bool directPhoton = true; + const material_t *material = nullptr; + BSDF_t bsdfs; + + while( scene->intersect(ray, sp) ) { - if((bsdfs&BSDF_VOLUMETRIC) && (vol=material->getVolumeHandler(sp.Ng * -ray.dir < 0))) + if(std::isnan(pcol.R) || std::isnan(pcol.G) || std::isnan(pcol.B)) { - if(vol->transmittance(state, ray, vcol)) transm = vcol; + Y_WARNING << integratorName << ": NaN on photon color for light" << lightNum + 1 << "." << yendl; + continue; } - } - - vector3d_t wi = -ray.dir, wo; - material = sp.material; - material->initBSDF(state, sp, bsdfs); + + color_t transm(1.f); + color_t vcol(0.f); + const volumeHandler_t* vol = nullptr; + + if(material) + { + if((bsdfs&BSDF_VOLUMETRIC) && (vol=material->getVolumeHandler(sp.Ng * -ray.dir < 0))) + { + if(vol->transmittance(state, ray, vcol)) transm = vcol; + } + } + + vector3d_t wi = -ray.dir, wo; + material = sp.material; + material->initBSDF(state, sp, bsdfs); - if(bsdfs & BSDF_DIFFUSE) - { - if(causticPhoton) + if(bsdfs & BSDF_DIFFUSE) { - photon_t np(wi, sp.P, pcol); - session.causticMap->pushPhoton(np); - session.causticMap->setNumPaths(curr); + if(causticPhoton) + { + photon_t np(wi, sp.P, pcol); + session.causticMap->pushPhoton(np); + session.causticMap->setNumPaths(curr); + } } - } - - // need to break in the middle otherwise we scatter the photon and then discard it => redundant - if(nBounces == maxBounces) break; - // scatter photon - int d5 = 3*nBounces + 5; + + // need to break in the middle otherwise we scatter the photon and then discard it => redundant + if(nBounces == maxBounces) break; + // scatter photon + int d5 = 3*nBounces + 5; - s5 = scrHalton(d5, curr); - s6 = scrHalton(d5+1, curr); - s7 = scrHalton(d5+2, curr); + s5 = scrHalton(d5, curr); + s6 = scrHalton(d5+1, curr); + s7 = scrHalton(d5+2, curr); - pSample_t sample(s5, s6, s7, BSDF_ALL, pcol, transm); + pSample_t sample(s5, s6, s7, BSDF_ALL, pcol, transm); - bool scattered = material->scatterPhoton(state, sp, wi, wo, sample); - if(!scattered) break; //photon was absorped. + bool scattered = material->scatterPhoton(state, sp, wi, wo, sample); + if(!scattered) break; //photon was absorped. - pcol = sample.color; + pcol = sample.color; - causticPhoton = ((sample.sampledFlags & (BSDF_GLOSSY | BSDF_SPECULAR | BSDF_DISPERSIVE)) && directPhoton) || - ((sample.sampledFlags & (BSDF_GLOSSY | BSDF_SPECULAR | BSDF_FILTER | BSDF_DISPERSIVE)) && causticPhoton); - directPhoton = (sample.sampledFlags & BSDF_FILTER) && directPhoton; - - if(state.chromatic && (sample.sampledFlags & BSDF_DISPERSIVE)) - { - state.chromatic=false; - color_t wl_col; - wl2rgb(state.wavelength, wl_col); - pcol *= wl_col; + causticPhoton = ((sample.sampledFlags & (BSDF_GLOSSY | BSDF_SPECULAR | BSDF_DISPERSIVE)) && directPhoton) || + ((sample.sampledFlags & (BSDF_GLOSSY | BSDF_SPECULAR | BSDF_FILTER | BSDF_DISPERSIVE)) && causticPhoton); + directPhoton = (sample.sampledFlags & BSDF_FILTER) && directPhoton; + + if(state.chromatic && (sample.sampledFlags & BSDF_DISPERSIVE)) + { + state.chromatic=false; + color_t wl_col; + wl2rgb(state.wavelength, wl_col); + pcol *= wl_col; + } + + ray.from = sp.P; + ray.dir = wo; + ray.tmin = scene->rayMinDist; + ray.tmax = -1.0; + ++nBounces; } - - ray.from = sp.P; - ray.dir = wo; - ray.tmin = scene->rayMinDist; - ray.tmax = -1.0; - ++nBounces; + ++curr; + if(curr % pbStep == 0) pb->update(); + done = (curr >= nCausPhotons); } - ++curr; - if(curr % pbStep == 0) pb->update(); - done = (curr >= nCausPhotons); - } } pb->done(); @@ -1085,22 +1002,17 @@ bool photonIntegrator_t::preprocess() tmplights.clear(); if(!intpb) delete pb; - - -#ifdef USING_THREADS - photonMapKdTreeWorker_t * causticMapBuildKdTree = nullptr; + + std::thread * causticMapBuildKdTree_thread = nullptr; if(usePhotonCaustics && session.causticMap->nPhotons() > 0 && scene->getNumThreadsPhotons() >= 2) { Y_INFO << integratorName << ": Building caustic photons kd-tree:" << yendl; pb->setTag("Building caustic photons kd-tree..."); - causticMapBuildKdTree = new photonMapKdTreeWorker_t(session.causticMap); - - causticMapBuildKdTree->run(); + causticMapBuildKdTree_thread = new std::thread(&photonIntegrator_t::photonMapKdTreeWorker, this, session.causticMap); } else -#endif { if( usePhotonCaustics && session.causticMap->nPhotons() > 0) { @@ -1111,20 +1023,17 @@ bool photonIntegrator_t::preprocess() } } -#ifdef USING_THREADS - if( usePhotonDiffuse && session.diffuseMap->nPhotons() > 0 && scene->getNumThreadsPhotons() >= 2) + if( usePhotonDiffuse && session.diffuseMap->nPhotons() > 0 && scene->getNumThreadsPhotons() >= 2 && diffuseMapBuildKdTree_thread) { - diffuseMapBuildKdTree->wait(); - - delete diffuseMapBuildKdTree; + diffuseMapBuildKdTree_thread->join(); + delete diffuseMapBuildKdTree_thread; + diffuseMapBuildKdTree_thread = nullptr; Y_VERBOSE << integratorName << ": Diffuse photon map: done." << yendl; } -#endif if(usePhotonDiffuse && finalGather) //create radiance map: { -#ifdef USING_THREADS // == remove too close radiance points ==// kdtree::pointKdTree< radData_t > *rTree = new kdtree::pointKdTree< radData_t >(pgdat.rad_points); std::vector< radData_t > cleaned; @@ -1146,84 +1055,34 @@ bool photonIntegrator_t::preprocess() else pgdat.pbar = new ConsoleProgressBar_t(80); pgdat.pbar->init(pgdat.rad_points.size()); pgdat.pbar->setTag("Pregathering radiance data for final gathering..."); - std::vector workers; - for(int i=0; irun(); - for(int i=0;iwait(); - for(int i=0;i threads; + for(int i=0; iswapVector(pgdat.radianceVec); pgdat.pbar->done(); pgdat.pbar->setTag("Pregathering radiance data done..."); if(!intpb) delete pgdat.pbar; -#else - if(session.radianceMap->nPhotons() != 0) - { - Y_WARNING << integratorName << ": radianceMap not empty!" << yendl; - session.radianceMap->clear(); - } - - Y_INFO << integratorName << ": Creating radiance map..." << yendl; - progressBar_t *pbar; - if(intpb) pbar = intpb; - else pbar = new ConsoleProgressBar_t(80); - pbar->init(pgdat.rad_points.size()); - foundPhoton_t *gathered = (foundPhoton_t *)malloc(nDifuseSearch * sizeof(foundPhoton_t)); - PFLOAT dsRadius_2 = dsRadius*dsRadius; - for(unsigned int n=0; n< pgdat.rad_points.size(); ++n) - { - PFLOAT radius = dsRadius_2; //actually the square radius... - int nGathered = session.diffuseMap->gather(pgdat.rad_points[n].pos, gathered, nDifuseSearch, radius); - color_t sum(0.0); - if(nGathered > 0) - { - color_t surfCol = pgdat.rad_points[n].refl; - vector3d_t rnorm = pgdat.rad_points[n].normal; - float scale = 1.f / ( float(session.diffuseMap->nPaths()) * radius * M_PI); - - if(std::isnan(scale)) - { - Y_WARNING << integratorName << ": NaN on (scale)" << yendl; - break; - } - - for(int i=0; idirection(); - - if( rnorm * pdir > 0.f ) sum += surfCol * scale * gathered[i].photon->color(); - else sum += pgdat.rad_points[n].transm * scale * gathered[i].photon->color(); - } - } - photon_t radP(pgdat.rad_points[n].normal, pgdat.rad_points[n].pos, sum); - session.radianceMap->pushPhoton(radP); - if(n && !(n&7)) pbar->update(8); - } - pbar->done(); - if(!pbar) delete pbar; - free(gathered); -#endif Y_VERBOSE << integratorName << ": Radiance tree built... Updating the tree..." << yendl; session.radianceMap->updateTree(); Y_VERBOSE << integratorName << ": Done." << yendl; } -#ifdef USING_THREADS - if(usePhotonCaustics && session.causticMap->nPhotons() > 0 && scene->getNumThreadsPhotons() >= 2) + if(usePhotonCaustics && session.causticMap->nPhotons() > 0 && scene->getNumThreadsPhotons() >= 2 && causticMapBuildKdTree_thread) { - causticMapBuildKdTree->wait(); - - delete causticMapBuildKdTree; + causticMapBuildKdTree_thread->join(); + delete causticMapBuildKdTree_thread; + causticMapBuildKdTree_thread = nullptr; Y_VERBOSE << integratorName << ": Caustic photon map: done." << yendl; } -#endif if(photonMapProcessing == PHOTONS_GENERATE_AND_SAVE) { if( usePhotonDiffuse ) { + pb->setTag("Saving diffuse photon map to temp folder..."); std::string filename = boost::filesystem::temp_directory_path().string(); filename += "/yafaray_photonMap_diffuse.tmp"; Y_INFO << integratorName << ": Saving diffuse photon map to: " << filename << yendl; @@ -1232,6 +1091,7 @@ bool photonIntegrator_t::preprocess() if( usePhotonCaustics ) { + pb->setTag("Saving caustic photon map to temp folder..."); std::string filename = boost::filesystem::temp_directory_path().string(); filename += "/yafaray_photonMap_caustics.tmp"; Y_INFO << integratorName << ": Saving caustics photon map to: " << filename << yendl; @@ -1240,6 +1100,7 @@ bool photonIntegrator_t::preprocess() if( usePhotonDiffuse && finalGather ) { + pb->setTag("Saving FG radiance map to temp folder..."); std::string filename = boost::filesystem::temp_directory_path().string(); filename += "/yafaray_photonMap_fg_radiance.tmp"; Y_INFO << integratorName << ": Saving FG radiance photon map to: " << filename << yendl; diff --git a/src/interface/SConscript b/src/interface/SConscript deleted file mode 100644 index ef4b81ec..00000000 --- a/src/interface/SConscript +++ /dev/null @@ -1,17 +0,0 @@ -import sys - -#Import('config') -Import('plugin_env') -Import('append_lib') -Import('append_includes') - -interf_env = plugin_env.Clone(); -append_lib(interf_env, ['MISC']) -append_includes(interf_env, ['PTHREAD']) - -interf=interf_env.SharedLibrary (target='yafarayplugin', source=['yafrayinterface.cc', 'xmlinterface.cc']) -interf_env.Install('${YF_LIBOUT}',interf) - -interf_env.Install('${YF_PACKPATH}${YF_LIBOUT}',interf) - -interf_env.Alias('install_interf','${YF_LIBOUT}') diff --git a/src/lights/SConscript b/src/lights/SConscript deleted file mode 100644 index 9ad568d3..00000000 --- a/src/lights/SConscript +++ /dev/null @@ -1,45 +0,0 @@ -import sys -Import('append_includes') - -#Import('config') -Import('plugin_env') -Import('static_env') -Import('append_lib') - -lights_env = plugin_env.Clone() -#append_lib(lights_env, ['EXR']) -append_includes(lights_env, ['EXR']) -append_includes(lights_env, ['PTHREAD']) -append_includes(static_env, ['PTHREAD']) - -sunlight=lights_env.SharedLibrary (target='sunlight', source=['sunlight.cc']) -#lights_env.Depends(sunlight,'../yafraycore'); -lights_env.Install('${YF_PLUGINPATH}',sunlight) - -pointlight=lights_env.SharedLibrary (target='pointlight', source=['pointlight.cc']) -#lights_env.Depends(pointlight,'../yafraycore'); -lights_env.Install('${YF_PLUGINPATH}',pointlight) - -directional=lights_env.SharedLibrary (target='directional', source=['directional.cc']) -#lights_env.Depends(directional,'../yafraycore'); -lights_env.Install('${YF_PLUGINPATH}',directional) - -spotlight=lights_env.SharedLibrary (target='spotlight', source=['spotlight.cc']) -lights_env.Install('${YF_PLUGINPATH}',spotlight) - -bglight=static_env.Library (target='bglight', source=['bglight.cc']) -#lights_env.Install(config.pluginpath,bglight) - -arealight=lights_env.SharedLibrary (target='arealight', source=['arealight.cc', 'meshlight.cc', 'bgportallight.cc']) -#lights_env.Depends(arealight,'../yafraycore'); -lights_env.Install('${YF_PLUGINPATH}',arealight) - -spherelight=lights_env.SharedLibrary (target='spherelight', source=['spherelight.cc']) -lights_env.Install('${YF_PLUGINPATH}',spherelight) - -iesLight=lights_env.SharedLibrary (target='iesLight', source=['iesLight.cc']) -lights_env.Install('${YF_PLUGINPATH}',iesLight) - -lights_env.Install('${YF_PACKPATH}${YF_PLUGINPATH}',[sunlight,pointlight,directional,spotlight,arealight,spherelight,iesLight]) - -lights_env.Alias('install_lights','${YF_PLUGINPATH}') diff --git a/src/materials/SConscript b/src/materials/SConscript deleted file mode 100644 index c2d7cb89..00000000 --- a/src/materials/SConscript +++ /dev/null @@ -1,36 +0,0 @@ -import sys - -#Import('config') -Import('plugin_env') -Import('append_includes') - -mat_env = plugin_env.Clone(); -append_includes(mat_env, ['PTHREAD']) - -glass=mat_env.SharedLibrary (target='glass', source=['glass.cc', 'roughglass.cc']) -mat_env.Install('${YF_PLUGINPATH}',glass) - -blendermat=mat_env.SharedLibrary (target='blendermat', source=['blendmat.cc']) -mat_env.Install('${YF_PLUGINPATH}',blendermat) - -glossymat=mat_env.SharedLibrary (target='glossymat', source=['glossy_mat.cc'])#, 'microfacet.cc']) -mat_env.Install('${YF_PLUGINPATH}',glossymat) - -shinydiffuse=mat_env.SharedLibrary (target='shinydiffuse', source=['shinydiff.cc']) -mat_env.Install('${YF_PLUGINPATH}',shinydiffuse) - -coatedglossy=mat_env.SharedLibrary (target='coatedglossy', source=['coatedglossy.cc'])#, 'microfacet.cc']) -mat_env.Install('${YF_PLUGINPATH}',coatedglossy) - -simplemats=mat_env.SharedLibrary (target='simplemats', source=['simplemats.cc', 'maskmat.cc']) -mat_env.Install('${YF_PLUGINPATH}',simplemats) - -volumetrics=mat_env.SharedLibrary(target='volumetrics', source=['beer.cc']) -mat_env.Install('${YF_PLUGINPATH}',volumetrics) -#rgbe_texture=mat_env.SharedLibrary (target='rgbe_texture', source=['rgbe_texture.cc']) -#mat_env.Depends(rgbe_texture,'../yafraycore'); -#mat_env.Install(config.pluginpath,rgbe_texture) - -mat_env.Install('${YF_PACKPATH}${YF_PLUGINPATH}',[glass,blendermat,glossymat,shinydiffuse,coatedglossy,simplemats,volumetrics]) - -mat_env.Alias('install_mat','${YF_PLUGINPATH}') diff --git a/src/textures/SConscript b/src/textures/SConscript deleted file mode 100644 index c93fd410..00000000 --- a/src/textures/SConscript +++ /dev/null @@ -1,27 +0,0 @@ -import sys - -Import('plugin_env') -Import('append_lib') -Import('append_includes') - -tex_env = plugin_env.Clone(); -append_includes(tex_env, ['PTHREAD']) - -image_env = tex_env.Clone() -append_lib(image_env, ['JPEG', 'PNG', 'EXR', 'ZLIB']) - -image_sources=['basictex.cc','noise.cc', 'jpeg.cc', 'imagetex.cc', 'rgbe_texture.cc'] -#if config.png.present: -if tex_env['WITH_YF_PNG']: - image_sources += ['png.cc'] - -basictex=image_env.SharedLibrary (target='basictex', source=image_sources) -image_env.Install('${YF_PLUGINPATH}',basictex) - -# nodes: -basicnodes=tex_env.SharedLibrary (target='basicnodes', source=['basicnodes.cc', 'layernode.cc']) -tex_env.Install('${YF_PLUGINPATH}',basicnodes) - -tex_env.Install('${YF_PACKPATH}${YF_PLUGINPATH}',[basictex,basicnodes]) - -tex_env.Alias('install_tex','${YF_PLUGINPATH}') diff --git a/src/volumes/SConscript b/src/volumes/SConscript deleted file mode 100644 index 5d30f127..00000000 --- a/src/volumes/SConscript +++ /dev/null @@ -1,27 +0,0 @@ -import sys - -#Import('config') -Import('plugin_env') -Import('static_env') -Import('append_lib') - -volume_env = plugin_env.Clone() - -uniformvolume=volume_env.SharedLibrary (target='UniformVolume', source=['UniformVolume.cc']) -volume_env.Install('${YF_PLUGINPATH}',uniformvolume) - -ExpDensityVolume=volume_env.SharedLibrary (target='ExpDensityVolume', source=['ExpDensityVolume.cc']) -volume_env.Install('${YF_PLUGINPATH}',ExpDensityVolume) - -NoiseVolume=volume_env.SharedLibrary (target='NoiseVolume', source=['NoiseVolume.cc']) -volume_env.Install('${YF_PLUGINPATH}',NoiseVolume) - -GridVolume=volume_env.SharedLibrary (target='GridVolume', source=['GridVolume.cc']) -volume_env.Install('${YF_PLUGINPATH}',GridVolume) - -SkyVolume=volume_env.SharedLibrary (target='SkyVolume', source=['SkyVolume.cc']) -volume_env.Install('${YF_PLUGINPATH}',SkyVolume) - -volume_env.Install('${YF_PACKPATH}${YF_PLUGINPATH}',[uniformvolume,ExpDensityVolume,NoiseVolume,SkyVolume]) - -volume_env.Alias('install_volumes','${YF_PLUGINPATH}') diff --git a/src/xml_loader/SConscript b/src/xml_loader/SConscript deleted file mode 100644 index 9b1a25d5..00000000 --- a/src/xml_loader/SConscript +++ /dev/null @@ -1,24 +0,0 @@ -import sys -import os - -Import('program_env') -Import('append_lib') -Import('append_includes') - -xml_loader_env = program_env.Clone() -append_includes(xml_loader_env, ['PTHREAD']) - -xml_loader_files = ['xml-loader.cc'] - -append_lib(xml_loader_env, ['EXR', 'PTHREAD']) - -xml_loader_env.Prepend (LIBPATH = ['../yafraycore'] ) -xml_loader_env.Append(LIBS = ['${YF_CORELIB}']) - -yafaray_xml=xml_loader_env.Program (target='yafaray-xml', source=xml_loader_files) - -xml_loader_env.Install('${YF_BINPATH}',yafaray_xml) - -xml_loader_env.Install('${YF_PACKPATH}${YF_BINPATH}',yafaray_xml) - -xml_loader_env.Alias('install_xml_loader','${YF_BINPATH}') diff --git a/src/yafraycore/CMakeLists.txt b/src/yafraycore/CMakeLists.txt index f4ced56c..b83bfb76 100644 --- a/src/yafraycore/CMakeLists.txt +++ b/src/yafraycore/CMakeLists.txt @@ -5,7 +5,7 @@ set(YF_CORE_SOURCES bound.cc yafsystem.cc environment.cc console.cc color_consol matrix4.cc object3d.cc timer.cc kdtree.cc ray_kdtree.cc hashgrid.cc tribox3_d.cc triclip.cc scene.cc imagefilm.cc imagesplitter.cc material.cc nodematerial.cc triangle.cc vector3d.cc photon.cc xmlparser.cc spectrum.cc volume.cc - surface.cc integrator.cc mcintegrator.cc ccthreads.cc + surface.cc integrator.cc mcintegrator.cc imageOutput.cc memoryIO.cc ${headers}) add_definitions(-DBUILDING_YAFRAYCORE) @@ -22,6 +22,6 @@ if(APPLE) # set rpath - Jens add_custom_command(TARGET yafaray_v3_core POST_BUILD COMMAND install_name_tool -add_rpath @loader_path/ libyafaray_v3_core.dylib) endif(APPLE) -target_link_libraries(yafaray_v3_core ${CMAKE_THREAD_LIBS_INIT} ${DLLOAD_LIB} ${OPENEXR_LIBRARIES} ${LIBXML2_LIBRARIES} ${FREETYPE_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(yafaray_v3_core ${DLLOAD_LIB} ${OPENEXR_LIBRARIES} ${LIBXML2_LIBRARIES} ${FREETYPE_LIBRARIES} ${Boost_LIBRARIES}) install (TARGETS yafaray_v3_core ${YAF_TARGET_TYPE} DESTINATION ${YAF_LIB_DIR}) diff --git a/src/yafraycore/SConscript b/src/yafraycore/SConscript deleted file mode 100644 index a14872d9..00000000 --- a/src/yafraycore/SConscript +++ /dev/null @@ -1,57 +0,0 @@ -import sys -import os - -Import('shared_env') -#Import('config') -Import('append_lib') -core_env = shared_env.Clone(); - -core_env.Append (CPPDEFINES= ['BUILDING_YAFRAYCORE']) - -source_files = ['bound.cc', - 'yafsystem.cc', - 'environment.cc', - 'console.cc', - 'faure_tables.cc', - 'std_primitives.cc', - 'color.cc', - 'matrix4.cc', - 'object3d.cc', - 'timer.cc', - 'kdtree.cc', - 'ray_kdtree.cc', - 'tribox3_d.cc', - 'triclip.cc', - 'scene.cc', - 'imagefilm.cc', - 'imagesplitter.cc', - 'material.cc', - 'nodematerial.cc', - 'ccthreads.cc', - 'triangle.cc', - 'vector3d.cc', - 'tga_io.cc', - 'photon.cc', - 'xmlparser.cc', - 'spectrum.cc', - 'volume.cc', - 'memoryIO.cc', - 'surface.cc', - 'integrator.cc', - 'imageOutput.cc' - ] - -#if config.exr.present: -if core_env['WITH_YF_EXR']: - source_files.append('EXR_io.cc') - -#append_lib(core_env, [config.pthread, config.exr, config.xml, config.freetype2, config.others]) -append_lib(core_env, ['PTHREAD', 'EXR', 'XML', 'FREETYPE', 'PNG', 'ZLIB', 'MISC']) - -#core_env.Install(config.libpath, core_env.SharedLibrary(target=config.corelib, source=source_files) ) -#core_env.Alias('install_core',config.libpath) -yafcore = core_env.SharedLibrary(target='${YF_CORELIB}', source=source_files); -core_env.Install('${YF_LIBOUT}', yafcore ) -core_env.Install('${YF_PACKPATH}${YF_LIBOUT}', yafcore ) -core_env.Alias('install_core','${YF_LIBOUT}') - diff --git a/src/yafraycore/ccthreads.cc b/src/yafraycore/ccthreads.cc deleted file mode 100644 index d91b3cbf..00000000 --- a/src/yafraycore/ccthreads.cc +++ /dev/null @@ -1,258 +0,0 @@ -#include -#include -#include - -#ifdef __APPLE__ -#include -#endif - -namespace yafthreads { - -mutex_t::mutex_t() -{ -#if HAVE_PTHREAD - int error=pthread_mutex_init(&m, nullptr); - switch(error) - { - case EINVAL: throw std::runtime_error("pthread_mutex_init error EINVAL"); break; - case ENOMEM: throw std::runtime_error("pthread_mutex_init error ENOMEM"); break; - case EAGAIN: throw std::runtime_error("pthread_mutex_init error EAGAIN"); break; - default: break; - } -#elif defined( WIN32_THREADS ) - winMutex = CreateMutex(0, FALSE, 0); -#endif -} - -void mutex_t::lock() -{ -#if HAVE_PTHREAD - if(pthread_mutex_lock(&m)) - { - throw std::runtime_error("Error mutex lock"); - } -#elif defined( WIN32_THREADS ) - WaitForSingleObject(winMutex, INFINITE); -#endif -} - -void mutex_t::unlock() -{ -#if HAVE_PTHREAD - if(pthread_mutex_unlock(&m)) - { - throw std::runtime_error("Error mutex lock"); - } -#elif defined( WIN32_THREADS ) - ReleaseMutex(winMutex); -#endif -} - -mutex_t::~mutex_t() -{ -#if HAVE_PTHREAD - pthread_mutex_destroy(&m); -#elif defined( WIN32_THREADS ) - CloseHandle(winMutex); -#endif -} - -/* read-shared write-exclusive lock */ -rwlock_t::rwlock_t() -{ -#if HAVE_PTHREAD - int error=pthread_rwlock_init(&l, nullptr); - switch(error) - { - case EINVAL: throw std::runtime_error("pthread_rwlock_init error EINVAL"); break; - case ENOMEM: throw std::runtime_error("pthread_rwlock_init error ENOMEM"); break; - case EAGAIN: throw std::runtime_error("pthread_rwlock_init error EAGAIN"); break; - default: break; - } -#endif -} - -void rwlock_t::readLock() -{ -#if HAVE_PTHREAD - if(pthread_rwlock_rdlock(&l)) - { - throw std::runtime_error("Error rwlock readLock"); - } -#endif -} - -void rwlock_t::writeLock() -{ -#if HAVE_PTHREAD - if(pthread_rwlock_wrlock(&l)) - { - throw std::runtime_error("Error rwlock writeLock"); - } -#endif -} - -void rwlock_t::unlock() -{ -#if HAVE_PTHREAD - if(pthread_rwlock_unlock(&l)) - { - throw std::runtime_error("Error rwlock unlock"); - } -#endif -} - -rwlock_t::~rwlock_t() -{ -#if HAVE_PTHREAD - pthread_rwlock_destroy(&l); -#endif -} - - -/* condition object */ - -conditionVar_t::conditionVar_t() -{ -#if HAVE_PTHREAD - int error=pthread_mutex_init(&m, nullptr); - switch(error) - { - case EINVAL: throw std::runtime_error("pthread_mutex_init error EINVAL"); break; - case ENOMEM: throw std::runtime_error("pthread_mutex_init error ENOMEM"); break; - case EAGAIN: throw std::runtime_error("pthread_mutex_init error EAGAIN"); break; - default: break; - } - error = pthread_cond_init (&c, nullptr); - if(error != 0) - { - throw std::runtime_error("pthread_cond_init error\n"); - } -#elif defined( WIN32_THREADS ) - condHandle = CreateEvent(0, FALSE, FALSE, "yafConditionSignal"); - winMutex = CreateMutex(0, FALSE, 0); -#endif -} - -void conditionVar_t::lock() -{ -#if HAVE_PTHREAD - if(pthread_mutex_lock(&m)) - { - throw std::runtime_error("Error mutex lock"); - } -#elif defined( WIN32_THREADS ) - WaitForSingleObject(winMutex, INFINITE); -#endif -} - -void conditionVar_t::unlock() -{ -#if HAVE_PTHREAD - if(pthread_mutex_unlock(&m)) - { - throw std::runtime_error("Error mutex lock"); - } -#elif defined( WIN32_THREADS ) - ReleaseMutex(winMutex); -#endif -} - -void conditionVar_t::signal() -{ -#if HAVE_PTHREAD - if(pthread_cond_signal(&c)) - { - throw std::runtime_error("Error condition signal"); - } -#elif defined( WIN32_THREADS ) - SetEvent(condHandle); -#endif -} - -void conditionVar_t::wait() -{ -#if HAVE_PTHREAD - if(pthread_cond_wait(&c, &m)) - { - throw std::runtime_error("Error condition wait"); - } -#elif defined( WIN32_THREADS ) - unlock(); - SignalObjectAndWait(condHandle, winMutex, INFINITE, FALSE); -#endif -} - -conditionVar_t::~conditionVar_t() -{ -#if HAVE_PTHREAD - pthread_mutex_destroy(&m); - pthread_cond_destroy(&c); -#elif defined( WIN32_THREADS ) - CloseHandle(condHandle); - CloseHandle(winMutex); -#endif -} - -#if HAVE_PTHREAD -void * wrapper(void *data) -{ - using namespace yafaray; - thread_t *obj = (thread_t *)data; - try{ obj->body(); } - catch(std::exception &e) - { - Y_ERROR << "Threads: Exception occured: " << e.what() << yendl; - } - obj->running=false; - pthread_exit(0); - return nullptr; -} - -void thread_t::run() -{ - pthread_attr_init(&attr); - pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_JOINABLE); - pthread_attr_setstacksize(&attr,1048576); //A bigger stack size helps to avoid crashes when you use many simultaneous threads. - pthread_create(&id,&attr,wrapper,this); - running=true; -} - -void thread_t::wait() -{ - pthread_join(id,nullptr); - running=false; -} - -thread_t::~thread_t() -{ - if(running) wait(); -} -#elif defined( WIN32_THREADS ) -DWORD WINAPI wrapper (void *data) -{ - thread_t *obj=(thread_t *)data; - obj->body(); - return 0; -} - -void thread_t::run() -{ - winThread = CreateThread(0, 0, wrapper, this, 0, &id); - running = true; -} - -void thread_t::wait() -{ - WaitForSingleObject(winThread, INFINITE); - running = false; -} - -thread_t::~thread_t() -{ - if(running) wait(); - CloseHandle(winThread); -} -#endif - -} // yafthreads diff --git a/src/yafraycore/integrator.cc b/src/yafraycore/integrator.cc index 04602a99..4f0cc448 100644 --- a/src/yafraycore/integrator.cc +++ b/src/yafraycore/integrator.cc @@ -40,49 +40,25 @@ __BEGIN_YAFRAY -#ifdef USING_THREADS - -class renderWorker_t: public yafthreads::thread_t -{ - public: - renderWorker_t(int numView, tiledIntegrator_t *it, scene_t *s, imageFilm_t *f, threadControl_t *c, int id, int smpls, int offs=0, bool adptv=false, int AA_pass_number=0): - integrator(it), scene(s), imageFilm(f), control(c), samples(smpls), mNumView(numView), offset(offs), threadID(id), adaptive(adptv), AA_pass(AA_pass_number) - { - //Empty - } - virtual void body(); - protected: - tiledIntegrator_t *integrator; - scene_t *scene; - imageFilm_t *imageFilm; - threadControl_t *control; - int samples; - int mNumView; - int offset; - int threadID; - bool adaptive; - int AA_pass; -}; - -void renderWorker_t::body() +void tiledIntegrator_t::renderWorker(int mNumView, tiledIntegrator_t *integrator, scene_t *scene, imageFilm_t *imageFilm, threadControl_t *control, int threadID, int samples, int offset, bool adaptive, int AA_pass) { renderArea_t a; + while(imageFilm->nextArea(mNumView, a)) { if(scene->getSignals() & Y_SIG_ABORT) break; integrator->preTile(a, samples, offset, adaptive, threadID); integrator->renderTile(mNumView, a, samples, offset, adaptive, threadID, AA_pass); - control->countCV.lock(); + + std::unique_lock lk(control->m); control->areas.push_back(a); - control->countCV.signal(); - control->countCV.unlock(); + control->c.notify_one(); + } - control->countCV.lock(); + std::unique_lock lk(control->m); ++(control->finishedThreads); - control->countCV.signal(); - control->countCV.unlock(); + control->c.notify_one(); } -#endif void tiledIntegrator_t::preRender() { @@ -243,31 +219,27 @@ bool tiledIntegrator_t::renderPass(int numView, int samples, int offset, bool ad int nthreads = scene->getNumThreads(); -#ifdef USING_THREADS if(nthreads>1) { threadControl_t tc; - std::vector workers; - for(int i=0;i threads; for(int i=0;irun(); + threads.push_back(std::thread(&tiledIntegrator_t::renderWorker, this, numView, this, scene, imageFilm, &tc, i, samples, offset, adaptive, AA_pass_number)); } - //update finished tiles - tc.countCV.lock(); + + std::unique_lock lk(tc.m); while(tc.finishedThreads < nthreads) { - tc.countCV.wait(); + tc.c.wait(lk); for(size_t i=0; ifinishArea(numView, tc.areas[i]); tc.areas.clear(); } - tc.countCV.unlock(); - //join all threads (although they probably have exited already, but not necessarily): - for(int i=0;iwait(); delete workers[i];} //Fix for Linux hangs/crashes, it's better to wait for threads to end before deleting the thread objects. Using code to wait for the threads to end in the destructors is not recommended. + + for(auto& t : threads) t.join(); //join all threads (although they probably have exited already, but not necessarily): } else { -#endif renderArea_t a; while(imageFilm->nextArea(numView, a)) { @@ -276,9 +248,7 @@ bool tiledIntegrator_t::renderPass(int numView, int samples, int offset, bool ad renderTile(numView, a, samples, offset, adaptive, 0); imageFilm->finishArea(numView, a); } -#ifdef USING_THREADS } -#endif return true; //hm...quite useless the return value :) } diff --git a/src/yafraycore/kdtree.cc b/src/yafraycore/kdtree.cc index bf9df9d3..5b54f4a2 100644 --- a/src/yafraycore/kdtree.cc +++ b/src/yafraycore/kdtree.cc @@ -7,9 +7,7 @@ //#include #include #include -#if ( HAVE_PTHREAD && defined (__GNUC__) && !defined (__clang__)) -#include -#endif + #include __BEGIN_YAFRAY diff --git a/src/yafraycore/mcintegrator.cc b/src/yafraycore/mcintegrator.cc index fc1b77bb..5f6327f0 100644 --- a/src/yafraycore/mcintegrator.cc +++ b/src/yafraycore/mcintegrator.cc @@ -326,29 +326,7 @@ inline color_t mcIntegrator_t::doLightEstimation(renderState_t &state, light_t * return col; } -class causticWorker_t: public yafthreads::thread_t -{ - public: - causticWorker_t(photonMap_t * causticmap, int thread_id, const scene_t *sc, unsigned int ncausphotons, pdf1D_t *lightpowerd, int numlights, const std::string &integratorname, const std::vector &causlights, int causdepth, progressBar_t *ppb, int pbstep, unsigned int &totalphotonsshot): - causticMap(causticmap), threadID(thread_id), scene(sc), nCausPhotons(ncausphotons), lightPowerD(lightpowerd), numLights(numlights), integratorName(integratorname), causLights(causlights), causDepth(causdepth), pb(ppb), pbStep(pbstep), totalPhotonsShot(totalphotonsshot) {}; - virtual void body(); - protected: - photonMap_t * causticMap; - int threadID; - const scene_t *scene; - unsigned int nCausPhotons; - pdf1D_t *lightPowerD; - int numLights; - const std::string &integratorName; - const std::vector &causLights; - int causDepth; - std::vector localCausticPhotons; - progressBar_t *pb; - int pbStep; - unsigned int &totalPhotonsShot; -}; - -void causticWorker_t::body() +void mcIntegrator_t::causticWorker(photonMap_t * causticMap, int threadID, const scene_t *scene, unsigned int nCausPhotons, pdf1D_t *lightPowerD, int numLights, const std::string &integratorName, const std::vector &causLights, int causDepth, progressBar_t *pb, int pbStep, unsigned int &totalPhotonsShot) { bool done=false; float s1, s2, s3, s4, s5, s6, s7, sL; @@ -358,6 +336,8 @@ void causticWorker_t::body() unsigned int curr = 0; unsigned int nCausPhotons_thread = 1 + ( (nCausPhotons - 1) / scene->getNumThreadsPhotons() ); + std::vector localCausticPhotons; + surfacePoint_t sp1, sp2; surfacePoint_t *hit=&sp1, *hit2=&sp2; ray_t ray; @@ -390,9 +370,9 @@ void causticWorker_t::body() if(lightNum >= numLights) { - causticMap->mutex.lock(); + causticMap->mutx.lock(); Y_ERROR << integratorName << ": lightPDF sample error! " << sL << "/" << lightNum << yendl; - causticMap->mutex.unlock(); + causticMap->mutx.unlock(); return; } @@ -417,9 +397,9 @@ void causticWorker_t::body() { if(std::isnan(pcol.R) || std::isnan(pcol.G) || std::isnan(pcol.B)) { - causticMap->mutex.lock(); + causticMap->mutx.lock(); Y_WARNING << integratorName << ": NaN (photon color)" << yendl; - causticMap->mutex.unlock(); + causticMap->mutx.unlock(); break; } color_t transm(1.f), vcol; @@ -483,22 +463,27 @@ void causticWorker_t::body() ++curr; if(curr % pbStep == 0) { - pb->mutex.lock(); + pb->mutx.lock(); pb->update(); - pb->mutex.unlock(); + pb->mutx.unlock(); } done = (curr >= nCausPhotons_thread); } - causticMap->mutex.lock(); + causticMap->mutx.lock(); causticMap->appendVector(localCausticPhotons, curr); totalPhotonsShot += curr; - causticMap->mutex.unlock(); + causticMap->mutx.unlock(); } bool mcIntegrator_t::createCausticMap() { + progressBar_t *pb; + if(intpb) pb = intpb; + else pb = new ConsoleProgressBar_t(80); + if(photonMapProcessing == PHOTONS_LOAD) { + pb->setTag("Loading caustic photon map from temp folder..."); std::string filename = boost::filesystem::temp_directory_path().string(); filename += "/yafaray_photonMap_caustics.tmp"; Y_INFO << integratorName << ": Loading caustics photon map from: " << filename << ". If it does not match the scene you could have crashes and/or incorrect renders, USE WITH CARE!" << yendl; @@ -526,6 +511,7 @@ bool mcIntegrator_t::createCausticMap() } session.causticMap->clear(); + session.causticMap->setNumPaths(0); session.causticMap->reserveMemory(nCausPhotons); ray_t ray; std::vector causLights; @@ -539,9 +525,6 @@ bool mcIntegrator_t::createCausticMap() } int numLights = causLights.size(); - progressBar_t *pb; - if(intpb) pb = intpb; - else pb = new ConsoleProgressBar_t(80); if(numLights > 0) { @@ -572,143 +555,139 @@ bool mcIntegrator_t::createCausticMap() unsigned int curr=0; -#ifdef USING_THREADS int nThreads = scene->getNumThreadsPhotons(); nCausPhotons = (nCausPhotons / nThreads) * nThreads; //rounding the number of diffuse photons so it's a number divisible by the number of threads (distribute uniformly among the threads) Y_PARAMS << integratorName << ": Shooting "< 1) + if(nThreads >= 2) { - std::vector workers; - for(int i=0; irun(); - for(int i=0;iwait(); - for(int i=0;i threads; + for(int i=0; igetCamera(); - unsigned char userdata[USER_DATA_SIZE+7]; - state.userdata = (void *)( &userdata[7] - ( ((size_t)&userdata[7])&7 ) ); // pad userdata to 8 bytes + renderState_t state; + state.cam = scene->getCamera(); + unsigned char userdata[USER_DATA_SIZE+7]; + state.userdata = (void *)( &userdata[7] - ( ((size_t)&userdata[7])&7 ) ); // pad userdata to 8 bytes - while(!done) - { - if(scene->getSignals() & Y_SIG_ABORT) { pb->done(); if(!intpb) delete pb; return false; } - state.chromatic = true; - state.wavelength = RI_S(curr); - s1 = RI_vdC(curr); - s2 = scrHalton(2, curr); - s3 = scrHalton(3, curr); - s4 = scrHalton(4, curr); + while(!done) + { + if(scene->getSignals() & Y_SIG_ABORT) { pb->done(); if(!intpb) delete pb; return false; } + state.chromatic = true; + state.wavelength = RI_S(curr); + s1 = RI_vdC(curr); + s2 = scrHalton(2, curr); + s3 = scrHalton(3, curr); + s4 = scrHalton(4, curr); - sL = float(curr) / float(nCausPhotons); + sL = float(curr) / float(nCausPhotons); - int lightNum = lightPowerD->DSample(sL, &lightNumPdf); + int lightNum = lightPowerD->DSample(sL, &lightNumPdf); - if(lightNum >= numLights) - { - Y_ERROR << integratorName << ": lightPDF sample error! " << sL << "/" << lightNum << yendl; - delete lightPowerD; - return false; - } + if(lightNum >= numLights) + { + Y_ERROR << integratorName << ": lightPDF sample error! " << sL << "/" << lightNum << yendl; + delete lightPowerD; + return false; + } - color_t pcol = causLights[lightNum]->emitPhoton(s1, s2, s3, s4, ray, lightPdf); - ray.tmin = scene->rayMinDist; - ray.tmax = -1.0; - pcol *= fNumLights * lightPdf / lightNumPdf; //remember that lightPdf is the inverse of th pdf, hence *=... - if(pcol.isBlack()) - { - ++curr; - done = (curr >= nCausPhotons); - continue; - } - BSDF_t bsdfs = BSDF_NONE; - int nBounces = 0; - bool causticPhoton = false; - bool directPhoton = true; - const material_t *material = nullptr; - const volumeHandler_t *vol = nullptr; - - while( scene->intersect(ray, *hit2) ) - { - if(std::isnan(pcol.R) || std::isnan(pcol.G) || std::isnan(pcol.B)) + color_t pcol = causLights[lightNum]->emitPhoton(s1, s2, s3, s4, ray, lightPdf); + ray.tmin = scene->rayMinDist; + ray.tmax = -1.0; + pcol *= fNumLights * lightPdf / lightNumPdf; //remember that lightPdf is the inverse of th pdf, hence *=... + if(pcol.isBlack()) { - Y_WARNING << integratorName << ": NaN (photon color)" << yendl; - break; + ++curr; + done = (curr >= nCausPhotons); + continue; } - color_t transm(1.f), vcol; - // check for volumetric effects - if(material) + BSDF_t bsdfs = BSDF_NONE; + int nBounces = 0; + bool causticPhoton = false; + bool directPhoton = true; + const material_t *material = nullptr; + const volumeHandler_t *vol = nullptr; + + while( scene->intersect(ray, *hit2) ) { - if((bsdfs&BSDF_VOLUMETRIC) && (vol=material->getVolumeHandler(hit->Ng * ray.dir < 0))) + if(std::isnan(pcol.R) || std::isnan(pcol.G) || std::isnan(pcol.B)) { - vol->transmittance(state, ray, vcol); - transm = vcol; + Y_WARNING << integratorName << ": NaN (photon color)" << yendl; + break; } + color_t transm(1.f), vcol; + // check for volumetric effects + if(material) + { + if((bsdfs&BSDF_VOLUMETRIC) && (vol=material->getVolumeHandler(hit->Ng * ray.dir < 0))) + { + vol->transmittance(state, ray, vcol); + transm = vcol; + } - } - std::swap(hit, hit2); - vector3d_t wi = -ray.dir, wo; - material = hit->material; - material->initBSDF(state, *hit, bsdfs); - if(bsdfs & (BSDF_DIFFUSE | BSDF_GLOSSY)) - { - //deposit caustic photon on surface - if(causticPhoton) + } + std::swap(hit, hit2); + vector3d_t wi = -ray.dir, wo; + material = hit->material; + material->initBSDF(state, *hit, bsdfs); + if(bsdfs & (BSDF_DIFFUSE | BSDF_GLOSSY)) { - photon_t np(wi, hit->P, pcol); - session.causticMap->pushPhoton(np); - session.causticMap->setNumPaths(curr); + //deposit caustic photon on surface + if(causticPhoton) + { + photon_t np(wi, hit->P, pcol); + session.causticMap->pushPhoton(np); + session.causticMap->setNumPaths(curr); + } } + // need to break in the middle otherwise we scatter the photon and then discard it => redundant + if(nBounces == causDepth) break; + // scatter photon + int d5 = 3*nBounces + 5; + //int d6 = d5 + 1; + + s5 = scrHalton(d5, curr); + s6 = scrHalton(d5+1, curr); + s7 = scrHalton(d5+2, curr); + + pSample_t sample(s5, s6, s7, BSDF_ALL_SPECULAR | BSDF_GLOSSY | BSDF_FILTER | BSDF_DISPERSIVE, pcol, transm); + bool scattered = material->scatterPhoton(state, *hit, wi, wo, sample); + if(!scattered) break; //photon was absorped. + pcol = sample.color; + // hm...dispersive is not really a scattering qualifier like specular/glossy/diffuse or the special case filter... + causticPhoton = ((sample.sampledFlags & (BSDF_GLOSSY | BSDF_SPECULAR | BSDF_DISPERSIVE)) && directPhoton) || + ((sample.sampledFlags & (BSDF_GLOSSY | BSDF_SPECULAR | BSDF_FILTER | BSDF_DISPERSIVE)) && causticPhoton); + // light through transparent materials can be calculated by direct lighting, so still consider them direct! + directPhoton = (sample.sampledFlags & BSDF_FILTER) && directPhoton; + // caustic-only calculation can be stopped if: + if(!(causticPhoton || directPhoton)) break; + + if(state.chromatic && (sample.sampledFlags & BSDF_DISPERSIVE)) + { + state.chromatic=false; + color_t wl_col; + wl2rgb(state.wavelength, wl_col); + pcol *= wl_col; + } + ray.from = hit->P; + ray.dir = wo; + ray.tmin = scene->rayMinDist; + ray.tmax = -1.0; + ++nBounces; } - // need to break in the middle otherwise we scatter the photon and then discard it => redundant - if(nBounces == causDepth) break; - // scatter photon - int d5 = 3*nBounces + 5; - //int d6 = d5 + 1; - - s5 = scrHalton(d5, curr); - s6 = scrHalton(d5+1, curr); - s7 = scrHalton(d5+2, curr); - - pSample_t sample(s5, s6, s7, BSDF_ALL_SPECULAR | BSDF_GLOSSY | BSDF_FILTER | BSDF_DISPERSIVE, pcol, transm); - bool scattered = material->scatterPhoton(state, *hit, wi, wo, sample); - if(!scattered) break; //photon was absorped. - pcol = sample.color; - // hm...dispersive is not really a scattering qualifier like specular/glossy/diffuse or the special case filter... - causticPhoton = ((sample.sampledFlags & (BSDF_GLOSSY | BSDF_SPECULAR | BSDF_DISPERSIVE)) && directPhoton) || - ((sample.sampledFlags & (BSDF_GLOSSY | BSDF_SPECULAR | BSDF_FILTER | BSDF_DISPERSIVE)) && causticPhoton); - // light through transparent materials can be calculated by direct lighting, so still consider them direct! - directPhoton = (sample.sampledFlags & BSDF_FILTER) && directPhoton; - // caustic-only calculation can be stopped if: - if(!(causticPhoton || directPhoton)) break; - - if(state.chromatic && (sample.sampledFlags & BSDF_DISPERSIVE)) - { - state.chromatic=false; - color_t wl_col; - wl2rgb(state.wavelength, wl_col); - pcol *= wl_col; - } - ray.from = hit->P; - ray.dir = wo; - ray.tmin = scene->rayMinDist; - ray.tmax = -1.0; - ++nBounces; + ++curr; + if(curr % pbStep == 0) pb->update(); + done = (curr >= nCausPhotons); } - ++curr; - if(curr % pbStep == 0) pb->update(); - done = (curr >= nCausPhotons); - } } pb->done(); @@ -728,6 +707,7 @@ bool mcIntegrator_t::createCausticMap() if(photonMapProcessing == PHOTONS_GENERATE_AND_SAVE) { + pb->setTag("Saving caustic photon map to temp folder..."); std::string filename = boost::filesystem::temp_directory_path().string(); filename += "/yafaray_photonMap_caustics.tmp"; Y_INFO << integratorName << ": Saving caustics photon map to: " << filename << yendl; diff --git a/src/yafraycore/ray_kdtree.cc b/src/yafraycore/ray_kdtree.cc index e9657a7c..39eafdef 100644 --- a/src/yafraycore/ray_kdtree.cc +++ b/src/yafraycore/ray_kdtree.cc @@ -7,7 +7,7 @@ //#include #include #include -#if ( HAVE_PTHREAD && defined (__GNUC__) && !defined (__clang__)) +#if (defined (__GNUC__) && !defined (__clang__)) #include #endif #include @@ -974,7 +974,7 @@ bool kdTree_t::IntersectTS(renderState_t &state, const ray_t &ray, int maxDep vector3d_t invDir(1.f/ray.dir.x, 1.f/ray.dir.y, 1.f/ray.dir.z); int depth=0; -#if ( HAVE_PTHREAD && defined (__GNUC__) && !defined (__clang__)) +#if (defined (__GNUC__) && !defined (__clang__)) std::set, __gnu_cxx::__mt_alloc > filtered; #else std::set filtered; From 4c1ebc8e464f2f189b52abc95887da5277f41ab7 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Wed, 27 Apr 2016 20:51:17 +0100 Subject: [PATCH 015/124] C++11 Threads: performance optimizations. Replacing standard C++11 implementation for MinGW by Meganz threads implementation (quite faster in Windows-MinGW) Meganz threads from: https://github.com/meganz/mingw-std-threads Also removing a warning from imagefilm. --- include/core_api/session.h | 12 +- include/utilities/mingw-std-threads/LICENSE | 24 ++ include/utilities/mingw-std-threads/README.md | 46 +++ .../mingw.condition_variable.h | 211 ++++++++++++++ .../utilities/mingw-std-threads/mingw.mutex.h | 275 ++++++++++++++++++ .../mingw-std-threads/mingw.thread.h | 167 +++++++++++ .../mingw-std-threads/tests/CMakeLists.txt | 7 + .../mingw-std-threads/tests/tests.cpp | 60 ++++ src/integrators/photonintegr.cc | 9 +- src/yafraycore/imagefilm.cc | 2 +- src/yafraycore/mcintegrator.cc | 3 +- 11 files changed, 806 insertions(+), 10 deletions(-) create mode 100644 include/utilities/mingw-std-threads/LICENSE create mode 100644 include/utilities/mingw-std-threads/README.md create mode 100644 include/utilities/mingw-std-threads/mingw.condition_variable.h create mode 100644 include/utilities/mingw-std-threads/mingw.mutex.h create mode 100644 include/utilities/mingw-std-threads/mingw.thread.h create mode 100644 include/utilities/mingw-std-threads/tests/CMakeLists.txt create mode 100644 include/utilities/mingw-std-threads/tests/tests.cpp diff --git a/include/core_api/session.h b/include/core_api/session.h index dc547149..7341ca29 100644 --- a/include/core_api/session.h +++ b/include/core_api/session.h @@ -32,7 +32,17 @@ #include #include #include - +#if defined(_WIN32) && defined(__MINGW32__) + #undef _GLIBCXX_HAS_GTHREADS + #include + #include + #include + #include +#else + #include + #include + #include +#endif __BEGIN_YAFRAY diff --git a/include/utilities/mingw-std-threads/LICENSE b/include/utilities/mingw-std-threads/LICENSE new file mode 100644 index 00000000..ac525cf2 --- /dev/null +++ b/include/utilities/mingw-std-threads/LICENSE @@ -0,0 +1,24 @@ +Copyright (c) 2016, Mega Limited +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/include/utilities/mingw-std-threads/README.md b/include/utilities/mingw-std-threads/README.md new file mode 100644 index 00000000..92c31faf --- /dev/null +++ b/include/utilities/mingw-std-threads/README.md @@ -0,0 +1,46 @@ +mingw-std-threads +================= + +Standard C++11 threading classes implementation, which are currently still missing +on MinGW GCC. + +Windows compatibility +===================== +This implementation should work with Windows XP (regardless of service pack), or newer. +Since Vista, Windows has native condition variables, but we do not rely on them, to keep compatibility +with Windows XP. + +Usage +===== + +This is a header-only library. To use, just include the corresponding mingw.xxx.h file, where +xxx would be the name of the standard header that you would normally include. +For additional mutex helper classes, such as std::scoped_guard or std::unique_lock, you need to +include <mutex> before including mingw.mutex.h + +Compatibility +============= + +This code has been tested to work with MinGW-w64 5.3.0, but should work with any other MinGW version +that has the std threading classes missing, has C++11 support for lambda functions, variadic +templates, and has working mutex helper classes in <mutex>. + +Switching from the win32-pthread based implemetation +==================================================== +It seems that recent versions of mingw-w64 include a win32 port of pthreads, and have +the std::thread, std::mutex etc classes implemented and working, based on that compatibility +layer. This is a somewhat heavier implementation, as it brings a not very thin abstraction layer. +So you may still want to use this implementation for efficiency purposes. Unfortunately you can't use it +standalone and independent of the system <mutex> header, as it relies on it for std::unique_lock and other +non-trivial utility classes. In that case you will need to edit the c++-config.h file of your MinGW setup +and comment out the definition of _GLIBCXX_HAS_GTHREADS. This will cause the system headers to not define the +actual thread, mutex, etc classes, but still define the necessary utility classes. + +Why MinGW has no threading classes +================================== +It seems that for cross-platform threading implementation, the GCC standard library relies on +the gthreads/pthreads library. If this library is not available, as is the case with MinGW, the +std::thread, std::mutex, std::condition_variable are not defined. However, higher-level mutex +helper classes are still defined in <mutex> and are usable. Hence, this implementation +does not re-define them, and to use these helpers, you should include <mutex> as well, as explained +in the usage section. diff --git a/include/utilities/mingw-std-threads/mingw.condition_variable.h b/include/utilities/mingw-std-threads/mingw.condition_variable.h new file mode 100644 index 00000000..b6647581 --- /dev/null +++ b/include/utilities/mingw-std-threads/mingw.condition_variable.h @@ -0,0 +1,211 @@ +/** +* @file condition_variable.h +* @brief std::condition_variable implementation for MinGW +* +* (c) 2013-2016 by Mega Limited, Auckland, New Zealand +* @author Alexander Vassilev +* +* @copyright Simplified (2-clause) BSD License. +* You should have received a copy of the license along with this +* program. +* +* This code is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +* @note +* This file may become part of the mingw-w64 runtime package. If/when this happens, +* the appropriate license will be added, i.e. this code will become dual-licensed, +* and the current BSD 2-clause license will stay. +*/ + +#ifndef MINGW_CONDITIONAL_VARIABLE_H +#define MINGW_CONDITIONAL_VARIABLE_H +#include +#include +#include "mingw.mutex.h" +#include +#include +#include +#ifdef _GLIBCXX_HAS_GTHREADS +#error This version of MinGW seems to include a win32 port of pthreads, and probably \ + already has C++11 std threading classes implemented, based on pthreads. \ + It is likely that you will get errors about redefined classes, and unfortunately \ + this implementation can not be used standalone and independent of the system \ + header, since it relies on it for \ + std::unique_lock and other utility classes. If you would still like to use this \ + implementation (as it is more lightweight), you have to edit the \ + c++-config.h system header of your MinGW to not define _GLIBCXX_HAS_GTHREADS. \ + This will prevent system headers from defining actual threading classes while still \ + defining the necessary utility classes. +#endif + +namespace std +{ + +enum class cv_status { no_timeout, timeout }; +class condition_variable_any +{ +protected: + recursive_mutex mMutex; + atomic mNumWaiters; + HANDLE mSemaphore; + HANDLE mWakeEvent; +public: + typedef HANDLE native_handle_type; + native_handle_type native_handle() {return mSemaphore;} + condition_variable_any(const condition_variable_any&) = delete; + condition_variable_any& operator=(const condition_variable_any&) = delete; + condition_variable_any() + :mNumWaiters(0), mSemaphore(CreateSemaphore(NULL, 0, 0xFFFF, NULL)), + mWakeEvent(CreateEvent(NULL, FALSE, FALSE, NULL)) + {} + ~condition_variable_any() { CloseHandle(mWakeEvent); CloseHandle(mSemaphore); } +protected: + template + bool wait_impl(M& lock, DWORD timeout) + { + { + lock_guard guard(mMutex); + mNumWaiters++; + } + lock.unlock(); + DWORD ret = WaitForSingleObject(mSemaphore, timeout); + + mNumWaiters--; + SetEvent(mWakeEvent); + lock.lock(); + if (ret == WAIT_OBJECT_0) + return true; + else if (ret == WAIT_TIMEOUT) + return false; +//2 possible cases: +//1)The point in notify_all() where we determine the count to +//increment the semaphore with has not been reached yet: +//we just need to decrement mNumWaiters, but setting the event does not hurt +// +//2)Semaphore has just been released with mNumWaiters just before +//we decremented it. This means that the semaphore count +//after all waiters finish won't be 0 - because not all waiters +//woke up by acquiring the semaphore - we woke up by a timeout. +//The notify_all() must handle this grafecully +// + else + throw system_error(EPROTO, generic_category()); + } +public: + template + void wait(M& lock) + { + wait_impl(lock, INFINITE); + } + template + void wait(M& lock, Predicate pred) + { + while(!pred()) + { + wait(lock); + }; + } + + void notify_all() noexcept + { + lock_guard lock(mMutex); //block any further wait requests until all current waiters are unblocked + if (mNumWaiters.load() <= 0) + return; + + ReleaseSemaphore(mSemaphore, mNumWaiters, NULL); + while(mNumWaiters > 0) + { + auto ret = WaitForSingleObject(mWakeEvent, 1000); + if ((ret == WAIT_FAILED) || (ret == WAIT_ABANDONED)) + throw system_error(EPROTO, generic_category()); + } + assert(mNumWaiters == 0); +//in case some of the waiters timed out just after we released the +//semaphore by mNumWaiters, it won't be zero now, because not all waiters +//woke up by acquiring the semaphore. So we must zero the semaphore before +//we accept waiters for the next event +//See _wait_impl for details + while(WaitForSingleObject(mSemaphore, 0) == WAIT_OBJECT_0); + } + void notify_one() noexcept + { + lock_guard lock(mMutex); + if (!mNumWaiters) + return; + int targetWaiters = mNumWaiters.load() - 1; + ReleaseSemaphore(mSemaphore, 1, NULL); + while(mNumWaiters > targetWaiters) + { + auto ret = WaitForSingleObject(mWakeEvent, 1000); + if ((ret == WAIT_FAILED) || (ret == WAIT_ABANDONED)) + throw system_error(EPROTO, generic_category()); + } + assert(mNumWaiters == targetWaiters); + } + template + std::cv_status wait_for(M& lock, + const std::chrono::duration& rel_time) + { + long long timeout = chrono::duration_cast(rel_time).count(); + if (timeout < 0) + timeout = 0; + bool ret = wait_impl(lock, (DWORD)timeout); + return ret?cv_status::no_timeout:cv_status::timeout; + } + + template + bool wait_for(M& lock, + const std::chrono::duration& rel_time, Predicate pred) + { + wait_for(lock, rel_time); + return pred(); + } + template + cv_status wait_until (M& lock, + const chrono::time_point& abs_time) + { + return wait_for(lock, abs_time - Clock::now()); + } + template + bool wait_until (M& lock, + const std::chrono::time_point& abs_time, + Predicate pred) + { + auto time = abs_time - Clock::now(); + if (time < 0) + return pred(); + else + return wait_for(lock, time, pred); + } +}; +class condition_variable: protected condition_variable_any +{ +protected: + typedef condition_variable_any base; +public: + using base::native_handle_type; + using base::native_handle; + using base::base; + using base::notify_all; + using base::notify_one; + void wait(unique_lock &lock) + { base::wait(lock); } + template + void wait(unique_lock& lock, Predicate pred) + { base::wait(lock, pred); } + template + std::cv_status wait_for(unique_lock& lock, const std::chrono::duration& rel_time) + { return base::wait_for(lock, rel_time); } + template + bool wait_for(unique_lock& lock, const std::chrono::duration& rel_time, Predicate pred) + { return base::wait_for(lock, rel_time, pred); } + template + cv_status wait_until (unique_lock& lock, const chrono::time_point& abs_time) + { return base::wait_for(lock, abs_time); } + template + bool wait_until (unique_lock& lock, const std::chrono::time_point& abs_time, Predicate pred) + { return base::wait_until(lock, abs_time, pred); } +}; +} +#endif // MINGW_CONDITIONAL_VARIABLE_H diff --git a/include/utilities/mingw-std-threads/mingw.mutex.h b/include/utilities/mingw-std-threads/mingw.mutex.h new file mode 100644 index 00000000..d4532026 --- /dev/null +++ b/include/utilities/mingw-std-threads/mingw.mutex.h @@ -0,0 +1,275 @@ +/** +* @file mingw.mutex.h +* @brief std::mutex et al implementation for MinGW +** (c) 2013-2016 by Mega Limited, Auckland, New Zealand +* @author Alexander Vassilev +* +* @copyright Simplified (2-clause) BSD License. +* You should have received a copy of the license along with this +* program. +* +* This code is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +* @note +* This file may become part of the mingw-w64 runtime package. If/when this happens, +* the appropriate license will be added, i.e. this code will become dual-licensed, +* and the current BSD 2-clause license will stay. +*/ + +#ifndef WIN32STDMUTEX_H +#define WIN32STDMUTEX_H +#ifdef _GLIBCXX_HAS_GTHREADS +#error This version of MinGW seems to include a win32 port of pthreads, and probably \ + already has C++11 std threading classes implemented, based on pthreads. \ + You are likely to have class redefinition errors below, and unfirtunately this \ + implementation can not be used standalone \ + and independent of the system header, since it relies on it for \ + std::unique_lock and other utility classes. If you would still like to use this \ + implementation (as it is more lightweight), you have to edit the \ + c++-config.h system header of your MinGW to not define _GLIBCXX_HAS_GTHREADS. \ + This will prevent system headers from defining actual threading classes while still \ + defining the necessary utility classes. +#endif +// Recursion checks on non-recursive locks have some performance penalty, so the user +// may want to disable the checks in release builds. In that case, make sure they +// are always enabled in debug builds. + +#if defined(STDMUTEX_NO_RECURSION_CHECKS) && !defined(NDEBUG) + #undef STDMUTEX_NO_RECURSION_CHECKS +#endif + +#include +#include +#include + +#ifndef EPROTO + #define EPROTO 134 +#endif +#ifndef EOWNERDEAD + #define EOWNERDEAD 133 +#endif + +namespace std +{ +class recursive_mutex +{ +protected: + CRITICAL_SECTION mHandle; +public: + typedef LPCRITICAL_SECTION native_handle_type; + native_handle_type native_handle() {return &mHandle;} + recursive_mutex() noexcept + { + InitializeCriticalSection(&mHandle); + } + recursive_mutex (const recursive_mutex&) = delete; + recursive_mutex& operator=(const recursive_mutex&) = delete; + ~recursive_mutex() noexcept + { + DeleteCriticalSection(&mHandle); + } + void lock() + { + EnterCriticalSection(&mHandle); + } + void unlock() + { + LeaveCriticalSection(&mHandle); + } + bool try_lock() + { + return (TryEnterCriticalSection(&mHandle)!=0); + } +}; +template +class _NonRecursive: protected B +{ +protected: + typedef B base; + DWORD mOwnerThread; +public: + using base::native_handle_type; + using base::native_handle; + _NonRecursive() noexcept :base(), mOwnerThread(0) {} + _NonRecursive (const _NonRecursive&) = delete; + _NonRecursive& operator= (const _NonRecursive&) = delete; + void lock() + { + base::lock(); + checkSetOwnerAfterLock(); + } +protected: + void checkSetOwnerAfterLock() + { + DWORD self = GetCurrentThreadId(); + if (mOwnerThread == self) + { + fprintf(stderr, "FATAL: Recursive locking or non-recursive mutex detected. Throwing sysetm exception\n"); + fflush(stderr); + throw system_error(EDEADLK, generic_category()); + } + mOwnerThread = self; + } + void checkSetOwnerBeforeUnlock() + { + DWORD self = GetCurrentThreadId(); + if (mOwnerThread != self) + { + fprintf(stderr, "FATAL: Recursive unlocking of non-recursive mutex detected. Throwing system exception\n"); + fflush(stderr); + throw system_error(EDEADLK, generic_category()); + } + mOwnerThread = 0; + } +public: + void unlock() + { + checkSetOwnerBeforeUnlock(); + base::unlock(); + } + bool try_lock() + { + bool ret = base::try_lock(); + if (ret) + checkSetOwnerAfterLock(); + return ret; + } +}; + +#ifndef STDMUTEX_NO_RECURSION_CHECKS + typedef _NonRecursive mutex; +#else + typedef recursive_mutex mutex; +#endif + +class recursive_timed_mutex +{ +protected: + HANDLE mHandle; +public: + typedef HANDLE native_handle_type; + native_handle_type native_handle() const {return mHandle;} + recursive_timed_mutex(const recursive_timed_mutex&) = delete; + recursive_timed_mutex& operator=(const recursive_timed_mutex&) = delete; + recursive_timed_mutex(): mHandle(CreateMutex(NULL, FALSE, NULL)){} + ~recursive_timed_mutex() + { + CloseHandle(mHandle); + } + void lock() + { + DWORD ret = WaitForSingleObject(mHandle, INFINITE); + if (ret != WAIT_OBJECT_0) + { + if (ret == WAIT_ABANDONED) + throw system_error(EOWNERDEAD, generic_category()); + else + throw system_error(EPROTO, generic_category()); + } + } + void unlock() + { + if (!ReleaseMutex(mHandle)) + throw system_error(EDEADLK, generic_category()); + } + bool try_lock() + { + DWORD ret = WaitForSingleObject(mHandle, 0); + if (ret == WAIT_TIMEOUT) + return false; + else if (ret == WAIT_OBJECT_0) + return true; + else if (ret == WAIT_ABANDONED) + throw system_error(EOWNERDEAD, generic_category()); + else + throw system_error(EPROTO, generic_category()); + } + template + bool try_lock_for(const std::chrono::duration& dur) + { + DWORD timeout = (DWORD)chrono::duration_cast(dur).count(); + + DWORD ret = WaitForSingleObject(mHandle, timeout); + if (ret == WAIT_TIMEOUT) + return false; + else if (ret == WAIT_OBJECT_0) + return true; + else if (ret == WAIT_ABANDONED) + throw system_error(EOWNERDEAD, generic_category()); + else + throw system_error(EPROTO, generic_category()); + } + template + bool try_lock_until(const std::chrono::time_point& timeout_time) + { + return try_lock_for(timeout_time - Clock::now()); + } +}; + +class timed_mutex: public _NonRecursive +{ +protected: + typedef _NonRecursive base; +public: + using base::base; + timed_mutex(const timed_mutex&) = delete; + timed_mutex& operator=(const timed_mutex&) = delete; + template + void try_lock_for(const std::chrono::duration& dur) + { + bool ret = base::try_lock_for(dur); +#ifndef STDMUTEX_NO_RECURSION_CHECKS + if (ret) + checkSetOwnerAfterLock(); +#endif + return ret; + } +public: + template + bool try_lock_until(const std::chrono::time_point& timeout_time) + { + bool ret = base::try_lock_until(timeout_time); +#ifndef STDMUTEX_NO_RECURSION_CHECKS + if (ret) + checkSetOwnerAfterLock(); +#endif + return ret; + } +}; +// You can use the scoped locks and other helpers that are still provided by +// In that case, you must include before including this file, so that this +// file will not try to redefine them +#ifndef _GLIBCXX_MUTEX + +/// Do not acquire ownership of the mutex. +struct defer_lock_t { }; + + /// Try to acquire ownership of the mutex without blocking. +struct try_to_lock_t { }; + + /// Assume the calling thread has already obtained mutex ownership + /// and manage it. +struct adopt_lock_t { }; + +constexpr defer_lock_t defer_lock { }; +constexpr try_to_lock_t try_to_lock { }; +constexpr adopt_lock_t adopt_lock { }; + +template +class lock_guard +{ +protected: + M& mMutex; +public: + typedef M mutex_type; + lock_guard(const lock_guard&) = delete; + lock_guard& operator=(const lock_guard&) = delete; + explicit lock_guard(mutex_type& m): mMutex(m) { mMutex.lock(); } + lock_guard(mutex_type& m, std::adopt_lock_t):mMutex(m){} + ~lock_guard() { mMutex.unlock(); } +}; + +#endif +} +#endif // WIN32STDMUTEX_H diff --git a/include/utilities/mingw-std-threads/mingw.thread.h b/include/utilities/mingw-std-threads/mingw.thread.h new file mode 100644 index 00000000..6c1a9973 --- /dev/null +++ b/include/utilities/mingw-std-threads/mingw.thread.h @@ -0,0 +1,167 @@ +/** +* @file mingw.thread.h +* @brief std::thread implementation for MinGW +* (c) 2013-2016 by Mega Limited, Auckland, New Zealand +* @author Alexander Vassilev +* +* @copyright Simplified (2-clause) BSD License. +* You should have received a copy of the license along with this +* program. +* +* This code is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +* @note +* This file may become part of the mingw-w64 runtime package. If/when this happens, +* the appropriate license will be added, i.e. this code will become dual-licensed, +* and the current BSD 2-clause license will stay. +*/ + +#ifndef WIN32STDTHREAD_H +#define WIN32STDTHREAD_H + +#include +#include +#include +#include +#include +#include + +#ifdef _GLIBCXX_HAS_GTHREADS +#error This version of MinGW seems to include a win32 port of pthreads, and probably \ + already has C++11 std threading classes implemented, based on pthreads. \ + It is likely that you will get class redefinition errors below, and unfortunately \ + this implementation can not be used standalone \ + and independent of the system header, since it relies on it for \ + std::unique_lock and other utility classes. If you would still like to use this \ + implementation (as it is more lightweight), you have to edit the \ + c++-config.h system header of your MinGW to not define _GLIBCXX_HAS_GTHREADS. \ + This will prevent system headers from defining actual threading classes while still \ + defining the necessary utility classes. +#endif + +//instead of INVALID_HANDLE_VALUE _beginthreadex returns 0 +#define _STD_THREAD_INVALID_HANDLE 0 +namespace std +{ + +class thread +{ +public: + class id + { + DWORD mId; + void clear() {mId = 0;} + friend class thread; + public: + id(DWORD aId=0):mId(aId){} + bool operator==(const id& other) const {return mId == other.mId;} + }; +protected: + HANDLE mHandle; + id mThreadId; +public: + typedef HANDLE native_handle_type; + id get_id() const noexcept {return mThreadId;} + native_handle_type native_handle() const {return mHandle;} + thread(): mHandle(_STD_THREAD_INVALID_HANDLE){} + + thread(thread&& other) + :mHandle(other.mHandle), mThreadId(other.mThreadId) + { + other.mHandle = _STD_THREAD_INVALID_HANDLE; + other.mThreadId.clear(); + } + + thread(const thread &other)=delete; + + template + explicit thread(Function&& f, Args&&... args) + { + typedef decltype(std::bind(f, args...)) Call; + Call* call = new Call(std::bind(f, args...)); + mHandle = (HANDLE)_beginthreadex(NULL, 0, threadfunc, + (LPVOID)call, 0, (unsigned*)&(mThreadId.mId)); + } + template + static unsigned int __stdcall threadfunc(void* arg) + { + std::unique_ptr upCall(static_cast(arg)); + (*upCall)(); + return (unsigned long)0; + } + bool joinable() const {return mHandle != _STD_THREAD_INVALID_HANDLE;} + void join() + { + if (get_id() == GetCurrentThreadId()) + throw system_error(EDEADLK, generic_category()); + if (mHandle == _STD_THREAD_INVALID_HANDLE) + throw system_error(ESRCH, generic_category()); + if (!joinable()) + throw system_error(EINVAL, generic_category()); + WaitForSingleObject(mHandle, INFINITE); + CloseHandle(mHandle); + mHandle = _STD_THREAD_INVALID_HANDLE; + mThreadId.clear(); + } + + ~thread() + { + if (joinable()) + std::terminate(); + } + thread& operator=(const thread&) = delete; + thread& operator=(thread&& other) noexcept + { + if (joinable()) + std::terminate(); + swap(std::forward(other)); + return *this; + } + void swap(thread&& other) noexcept + { + std::swap(mHandle, other.mHandle); + std::swap(mThreadId.mId, other.mThreadId.mId); + } + static unsigned int hardware_concurrency() noexcept + { + static int ncpus = -1; + if (ncpus == -1) + { + SYSTEM_INFO sysinfo; + GetSystemInfo(&sysinfo); + ncpus = sysinfo.dwNumberOfProcessors; + } + return ncpus; + } + void detach() + { + if (!joinable()) + throw system_error(); + if (mHandle != _STD_THREAD_INVALID_HANDLE) + { + CloseHandle(mHandle); + mHandle = _STD_THREAD_INVALID_HANDLE; + } + mThreadId.clear(); + } +}; + +namespace this_thread +{ + inline thread::id get_id() {return thread::id(GetCurrentThreadId());} + inline void yield() {Sleep(0);} + template< class Rep, class Period > + void sleep_for( const std::chrono::duration& sleep_duration) + { + Sleep(chrono::duration_cast(sleep_duration).count()); + } + template + void sleep_until(const std::chrono::time_point& sleep_time) + { + sleep_for(sleep_time-Clock::now()); + } +} + +} +#endif // WIN32STDTHREAD_H diff --git a/include/utilities/mingw-std-threads/tests/CMakeLists.txt b/include/utilities/mingw-std-threads/tests/CMakeLists.txt new file mode 100644 index 00000000..e1727d0b --- /dev/null +++ b/include/utilities/mingw-std-threads/tests/CMakeLists.txt @@ -0,0 +1,7 @@ +project(stdthreadtest) +cmake_minimum_required(VERSION 2.8) + +add_definitions(-std=c++11) +add_executable(${PROJECT_NAME} tests.cpp) + + diff --git a/include/utilities/mingw-std-threads/tests/tests.cpp b/include/utilities/mingw-std-threads/tests/tests.cpp new file mode 100644 index 00000000..268e3b69 --- /dev/null +++ b/include/utilities/mingw-std-threads/tests/tests.cpp @@ -0,0 +1,60 @@ +#undef _GLIBCXX_HAS_GTHREADS +#include "../mingw.thread.h" +#include +#include "../mingw.mutex.h" +#include "../mingw.condition_variable.h" +#include +#include + +using namespace std; + +bool cond = false; +std::mutex m; +std::condition_variable cv; +#define LOG(fmtString,...) printf(fmtString "\n", ##__VA_ARGS__); fflush(stdout) +int main() +{ + std::thread t([](bool a, const char* b, int c)mutable + { + try + { + LOG("Worker thread started, sleeping for a while..."); + assert(a && !strcmp(b, "test message") && (c == -20)); + this_thread::sleep_for(std::chrono::milliseconds(5000)); + { + lock_guard lock(m); + cond = true; + LOG("Notifying condvar"); + cv.notify_all(); + } + + LOG("Worker thread finishing"); + } + catch(std::exception& e) + { + printf("EXCEPTION in worker thread: %s\n", e.what()); + } + }, + true, "test message", -20); + try + { + LOG("Main thread: waiting on condvar..."); + { + std::unique_lock lk(m); + cv.wait(lk, []{ return cond;} ); + LOG("condvar notified, cond = %d", cond); + } + LOG("Main thread: Waiting on worker join..."); + + t.join(); + LOG("Main thread: Worker thread joined"); + fflush(stdout); + } + catch(std::exception& e) + { + LOG("EXCEPTION in main thread: %s", e.what()); + } + + return 0; +} + diff --git a/src/integrators/photonintegr.cc b/src/integrators/photonintegr.cc index c1cfd83c..ec2fe33b 100644 --- a/src/integrators/photonintegr.cc +++ b/src/integrators/photonintegr.cc @@ -131,8 +131,6 @@ void photonIntegrator_t::causticWorker(photonMap_t * causticMap, int threadID, c while(!done) { - if(scene->getSignals() & Y_SIG_ABORT) { return; } - unsigned int haltoncurr = curr + nCausPhotons_thread * threadID; state.chromatic = true; @@ -245,6 +243,7 @@ void photonIntegrator_t::causticWorker(photonMap_t * causticMap, int threadID, c pb->mutx.lock(); pb->update(); pb->mutx.unlock(); + if(scene->getSignals() & Y_SIG_ABORT) { return; } } done = (curr >= nCausPhotons_thread); } @@ -285,8 +284,6 @@ void photonIntegrator_t::diffuseWorker(photonMap_t * diffuseMap, int threadID, c while(!done) { - if(scene->getSignals() & Y_SIG_ABORT) { return; } - unsigned int haltoncurr = curr + nDiffusePhotons_thread * threadID; s1 = RI_vdC(haltoncurr); @@ -399,6 +396,7 @@ void photonIntegrator_t::diffuseWorker(photonMap_t * diffuseMap, int threadID, c pb->mutx.lock(); pb->update(); pb->mutx.unlock(); + if(scene->getSignals() & Y_SIG_ABORT) { return; } } done = (curr >= nDiffusePhotons_thread); } @@ -872,10 +870,9 @@ bool photonIntegrator_t::preprocess() else { bool done=false; - float invCaustPhotons = 1.f / (float)nCausPhotons; float s1, s2, s3, s4, s5, s6, s7, sL; - + while(!done) { if(scene->getSignals() & Y_SIG_ABORT) { pb->done(); if(!intpb) delete pb; return false; } diff --git a/src/yafraycore/imagefilm.cc b/src/yafraycore/imagefilm.cc index f865505a..376f5d8e 100644 --- a/src/yafraycore/imagefilm.cc +++ b/src/yafraycore/imagefilm.cc @@ -1057,7 +1057,7 @@ float imageFilm_t::dark_threshold_curve_interpolate(float pixel_brightness) else if(pixel_brightness > 1.00f && pixel_brightness <= 1.20f) return (0.0400f + (pixel_brightness - 1.00f) * (0.0800f - 0.0400f) / 0.20f); else if(pixel_brightness > 1.20f && pixel_brightness <= 1.40f) return (0.0800f + (pixel_brightness - 1.20f) * (0.0950f - 0.0800f) / 0.20f); else if(pixel_brightness > 1.40f && pixel_brightness <= 1.80f) return (0.0950f + (pixel_brightness - 1.40f) * (0.1000f - 0.0950f) / 0.40f); - else if(pixel_brightness > 1.80f) return 0.1000f; + else return 0.1000f; } __END_YAFRAY diff --git a/src/yafraycore/mcintegrator.cc b/src/yafraycore/mcintegrator.cc index 5f6327f0..6c7c771b 100644 --- a/src/yafraycore/mcintegrator.cc +++ b/src/yafraycore/mcintegrator.cc @@ -352,8 +352,6 @@ void mcIntegrator_t::causticWorker(photonMap_t * causticMap, int threadID, const while(!done) { - if(scene->getSignals() & Y_SIG_ABORT) { return; } - unsigned int haltoncurr = curr + nCausPhotons_thread * threadID; state.chromatic = true; @@ -466,6 +464,7 @@ void mcIntegrator_t::causticWorker(photonMap_t * causticMap, int threadID, const pb->mutx.lock(); pb->update(); pb->mutx.unlock(); + if(scene->getSignals() & Y_SIG_ABORT) { return; } } done = (curr >= nCausPhotons_thread); } From 356c9739c41ac606a6bd41bdaec1e99ef7bd5878 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Wed, 27 Apr 2016 21:18:27 +0100 Subject: [PATCH 016/124] System Information: first tests adding system information to YafaRay logs --- include/core_api/session.h | 1 + include/core_api/sysinfo.h | 44 ++++++++++++++++++++++++++++++++++ src/yafraycore/CMakeLists.txt | 2 +- src/yafraycore/imagefilm.cc | 1 + src/yafraycore/sysinfo.cc | 45 +++++++++++++++++++++++++++++++++++ 5 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 include/core_api/sysinfo.h create mode 100644 src/yafraycore/sysinfo.cc diff --git a/include/core_api/session.h b/include/core_api/session.h index 7341ca29..7226bada 100644 --- a/include/core_api/session.h +++ b/include/core_api/session.h @@ -32,6 +32,7 @@ #include #include #include +#include #if defined(_WIN32) && defined(__MINGW32__) #undef _GLIBCXX_HAS_GTHREADS #include diff --git a/include/core_api/sysinfo.h b/include/core_api/sysinfo.h new file mode 100644 index 00000000..4fa5d706 --- /dev/null +++ b/include/core_api/sysinfo.h @@ -0,0 +1,44 @@ +/**************************************************************************** + * sysinfo.h: YafaRay System Information + * This is part of the yafray package + * Copyright (C) 2016 David Bluecame + * System Information, compilation information, etc + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef Y_SYSINFO_H +#define Y_SYSINFO_H + +#include +#include +#include +#include +#include +#include +#include + +__BEGIN_YAFRAY + +extern YAFRAYCORE_EXPORT std::string sysInfoGetArchitecture(); +extern YAFRAYCORE_EXPORT std::string sysInfoGetCompiler(); +extern YAFRAYCORE_EXPORT std::string sysInfoGetOS(); +extern YAFRAYCORE_EXPORT std::string sysInfoGetPlatform(); +extern YAFRAYCORE_EXPORT std::string sysInfoGetHW(); +extern YAFRAYCORE_EXPORT std::string sysInfoGetRuntimeInformation(); + +__END_YAFRAY + +#endif diff --git a/src/yafraycore/CMakeLists.txt b/src/yafraycore/CMakeLists.txt index b83bfb76..b0c5ddd7 100644 --- a/src/yafraycore/CMakeLists.txt +++ b/src/yafraycore/CMakeLists.txt @@ -1,7 +1,7 @@ include_directories(${YAF_INCLUDE_DIRS} ${LIBXML2_INCLUDE_DIR} ${OPENEXR_INCLUDE_DIRS} ${FREETYPE_INCLUDE_DIRS}) set(YF_CORE_SOURCES bound.cc yafsystem.cc environment.cc console.cc color_console.cc - logging.cc session.cc faure_tables.cc std_primitives.cc color.cc renderpasses.cc + sysinfo.cc logging.cc session.cc faure_tables.cc std_primitives.cc color.cc renderpasses.cc matrix4.cc object3d.cc timer.cc kdtree.cc ray_kdtree.cc hashgrid.cc tribox3_d.cc triclip.cc scene.cc imagefilm.cc imagesplitter.cc material.cc nodematerial.cc triangle.cc vector3d.cc photon.cc xmlparser.cc spectrum.cc volume.cc diff --git a/src/yafraycore/imagefilm.cc b/src/yafraycore/imagefilm.cc index 376f5d8e..f7b2f49f 100644 --- a/src/yafraycore/imagefilm.cc +++ b/src/yafraycore/imagefilm.cc @@ -520,6 +520,7 @@ void imageFilm_t::flush(int numView, int flags, colorOutput_t *out) if(!yafLog.getLoggingComments().empty()) ssBadge << yafLog.getLoggingComments() << "\n"; ssBadge << "\nYafaRay (" << version << ")"; + ssBadge << " " << sysInfoGetOS() << " "; ssBadge << std::setprecision(2); double times = gTimer.getTime("rendert"); diff --git a/src/yafraycore/sysinfo.cc b/src/yafraycore/sysinfo.cc new file mode 100644 index 00000000..68d36ec0 --- /dev/null +++ b/src/yafraycore/sysinfo.cc @@ -0,0 +1,45 @@ +/**************************************************************************** + * sysinfo.cc: YafaRay System Information + * This is part of the yafray package + * Copyright (C) 2016 David Bluecame + * System Information, compilation information, etc + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include + +__BEGIN_YAFRAY + +//std::string sysInfoGetArchitecture(); +//std::string sysInfoGetCompiler(); +std::string sysInfoGetOS() +{ +#ifdef BOOST_OS_LINUX + return "Linux"; +#elif BOOST_OS_MACOS + return "MacOSX"; +#elif BOOST_OS_WINDOWS + return "Windows"; +#else + return "Other OS"; +#endif +} + +//std::string sysInfoGetPlatform(); +//std::string sysInfoGetHW(); +//std::string sysInfoGetRuntimeInformation(); + +__END_YAFRAY + From d7c9a96a5aae9e5d9e546ed191fa2f8d203dbbf8 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Wed, 27 Apr 2016 21:48:02 +0100 Subject: [PATCH 017/124] System Information: more information added --- src/yafraycore/imagefilm.cc | 2 +- src/yafraycore/sysinfo.cc | 58 ++++++++++++++++++++++++++++++++----- 2 files changed, 52 insertions(+), 8 deletions(-) diff --git a/src/yafraycore/imagefilm.cc b/src/yafraycore/imagefilm.cc index f7b2f49f..953b2586 100644 --- a/src/yafraycore/imagefilm.cc +++ b/src/yafraycore/imagefilm.cc @@ -520,7 +520,7 @@ void imageFilm_t::flush(int numView, int flags, colorOutput_t *out) if(!yafLog.getLoggingComments().empty()) ssBadge << yafLog.getLoggingComments() << "\n"; ssBadge << "\nYafaRay (" << version << ")"; - ssBadge << " " << sysInfoGetOS() << " "; + ssBadge << " " << sysInfoGetOS() << " " << sysInfoGetArchitecture() << " " << sysInfoGetPlatform() << " " << sysInfoGetCompiler(); ssBadge << std::setprecision(2); double times = gTimer.getTime("rendert"); diff --git a/src/yafraycore/sysinfo.cc b/src/yafraycore/sysinfo.cc index 68d36ec0..b3d36a5e 100644 --- a/src/yafraycore/sysinfo.cc +++ b/src/yafraycore/sysinfo.cc @@ -22,22 +22,66 @@ __BEGIN_YAFRAY -//std::string sysInfoGetArchitecture(); -//std::string sysInfoGetCompiler(); +std::string sysInfoGetArchitecture() +{ +#if BOOST_ARCH_X86_32 + return "x86 32bit"; +#elif BOOST_ARCH_X86_64 + return "x86 64bit"; +#else + return ""; +#endif +} + +std::string sysInfoGetCompiler() +{ +#if BOOST_COMP_CLANG + return "Clang"; +#elif BOOST_COMP_GNUC + return "Gnu GCC C/C++"; +#elif BOOST_COMP_INTEL + return "Intel compiler"; +#elif BOOST_COMP_LLVM + return "LLVM"; +#elif BOOST_COMP_MSVC + return "Microsoft Visual C/C++"; +#else + return ""; +#endif +} + std::string sysInfoGetOS() { -#ifdef BOOST_OS_LINUX - return "Linux"; -#elif BOOST_OS_MACOS +#if BOOST_OS_MACOS return "MacOSX"; +#elif BOOST_OS_LINUX + return "Linux"; #elif BOOST_OS_WINDOWS return "Windows"; #else - return "Other OS"; + return ""; +#endif +} + +std::string sysInfoGetPlatform() +{ +#if BOOST_PLAT_MINGW + #if __MINGW32__ + return "MinGW 32bit v" + __MINGW32_VERSION_MAJOR + "." __MINGW32_VERSION_MINOR; + #elif __MINGW64__ + return "MinGW 64bit v" + __MINGW64_VERSION_MAJOR + "." __MINGW64_VERSION_MINOR; + #else + return "MinGW"; + #endif +#elif BOOST_PLAT_WINDOWS_DESKTOP + return "Windows desktop"; +#elif BOOST_PLAT_WINDOWS_RUNTIME + return "Windows runtime"; +#else + return ""; #endif } -//std::string sysInfoGetPlatform(); //std::string sysInfoGetHW(); //std::string sysInfoGetRuntimeInformation(); From 68bf4fee5926fe756e2ccd31b9c2f42dd1954e0a Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Wed, 27 Apr 2016 22:05:23 +0100 Subject: [PATCH 018/124] Fixing MinGW build errors after last changes --- include/core_api/session.h | 4 ---- src/yafraycore/sysinfo.cc | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/include/core_api/session.h b/include/core_api/session.h index 7226bada..15540a7d 100644 --- a/include/core_api/session.h +++ b/include/core_api/session.h @@ -27,10 +27,6 @@ #include #include #include -#include -#include -#include -#include #include #include #if defined(_WIN32) && defined(__MINGW32__) diff --git a/src/yafraycore/sysinfo.cc b/src/yafraycore/sysinfo.cc index b3d36a5e..70b028d9 100644 --- a/src/yafraycore/sysinfo.cc +++ b/src/yafraycore/sysinfo.cc @@ -67,9 +67,9 @@ std::string sysInfoGetPlatform() { #if BOOST_PLAT_MINGW #if __MINGW32__ - return "MinGW 32bit v" + __MINGW32_VERSION_MAJOR + "." __MINGW32_VERSION_MINOR; + return "MinGW 32bit"; #elif __MINGW64__ - return "MinGW 64bit v" + __MINGW64_VERSION_MAJOR + "." __MINGW64_VERSION_MINOR; + return "MinGW 64bit"; #else return "MinGW"; #endif From ad24276062565c2b2666562b263490179bc664bc Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Thu, 28 Apr 2016 09:16:27 +0400 Subject: [PATCH 019/124] System Information: final format --- src/yafraycore/environment.cc | 4 ++-- src/yafraycore/imagefilm.cc | 3 +-- src/yafraycore/sysinfo.cc | 28 +++++++++------------------- 3 files changed, 12 insertions(+), 23 deletions(-) diff --git a/src/yafraycore/environment.cc b/src/yafraycore/environment.cc index e142f984..eb6ddb14 100644 --- a/src/yafraycore/environment.cc +++ b/src/yafraycore/environment.cc @@ -70,9 +70,9 @@ __BEGIN_YAFRAY renderEnvironment_t::renderEnvironment_t() { #ifdef RELEASE - Y_INFO << PACKAGE << " " << VERSION << yendl; + Y_INFO << PACKAGE << " (" << VERSION << ")" << " " << sysInfoGetOS() << sysInfoGetArchitecture() << sysInfoGetPlatform() << sysInfoGetCompiler() << yendl; #else - Y_INFO << PACKAGE << " (" << YAF_SVN_REV << ")" << yendl; + Y_INFO << PACKAGE << " (" << YAF_SVN_REV << ")" << " " << sysInfoGetOS() << sysInfoGetArchitecture() << sysInfoGetPlatform() << sysInfoGetCompiler() << yendl; #endif object_factory["sphere"] = sphere_factory; output2 = nullptr; diff --git a/src/yafraycore/imagefilm.cc b/src/yafraycore/imagefilm.cc index 953b2586..1094ff89 100644 --- a/src/yafraycore/imagefilm.cc +++ b/src/yafraycore/imagefilm.cc @@ -519,8 +519,7 @@ void imageFilm_t::flush(int numView, int flags, colorOutput_t *out) else if(yafLog.getLoggingAuthor().empty() && !yafLog.getLoggingContact().empty()) ssBadge << yafLog.getLoggingContact() << "\n"; if(!yafLog.getLoggingComments().empty()) ssBadge << yafLog.getLoggingComments() << "\n"; - ssBadge << "\nYafaRay (" << version << ")"; - ssBadge << " " << sysInfoGetOS() << " " << sysInfoGetArchitecture() << " " << sysInfoGetPlatform() << " " << sysInfoGetCompiler(); + ssBadge << "\nYafaRay (" << version << ")" << " " << sysInfoGetOS() << sysInfoGetArchitecture() << sysInfoGetPlatform() << sysInfoGetCompiler(); ssBadge << std::setprecision(2); double times = gTimer.getTime("rendert"); diff --git a/src/yafraycore/sysinfo.cc b/src/yafraycore/sysinfo.cc index 70b028d9..d5adef98 100644 --- a/src/yafraycore/sysinfo.cc +++ b/src/yafraycore/sysinfo.cc @@ -25,9 +25,9 @@ __BEGIN_YAFRAY std::string sysInfoGetArchitecture() { #if BOOST_ARCH_X86_32 - return "x86 32bit"; + return "32bit "; #elif BOOST_ARCH_X86_64 - return "x86 64bit"; + return "64bit "; #else return ""; #endif @@ -38,13 +38,13 @@ std::string sysInfoGetCompiler() #if BOOST_COMP_CLANG return "Clang"; #elif BOOST_COMP_GNUC - return "Gnu GCC C/C++"; + return "GCC"; #elif BOOST_COMP_INTEL - return "Intel compiler"; + return "ICC"; #elif BOOST_COMP_LLVM return "LLVM"; #elif BOOST_COMP_MSVC - return "Microsoft Visual C/C++"; + return "MSVC"; #else return ""; #endif @@ -53,11 +53,11 @@ std::string sysInfoGetCompiler() std::string sysInfoGetOS() { #if BOOST_OS_MACOS - return "MacOSX"; + return "MacOSX "; #elif BOOST_OS_LINUX - return "Linux"; + return "Linux "; #elif BOOST_OS_WINDOWS - return "Windows"; + return "Windows "; #else return ""; #endif @@ -66,17 +66,7 @@ std::string sysInfoGetOS() std::string sysInfoGetPlatform() { #if BOOST_PLAT_MINGW - #if __MINGW32__ - return "MinGW 32bit"; - #elif __MINGW64__ - return "MinGW 64bit"; - #else - return "MinGW"; - #endif -#elif BOOST_PLAT_WINDOWS_DESKTOP - return "Windows desktop"; -#elif BOOST_PLAT_WINDOWS_RUNTIME - return "Windows runtime"; + return "MinGW "; #else return ""; #endif From a094f14957732a63517b61ddc6fbbb3738c18110 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sat, 30 Apr 2016 04:42:19 +0100 Subject: [PATCH 020/124] Photon pointkdtree Multi Threaded implementation for faster calculations. Also included photon map name, and deleted old (unused?) buildTree2 function --- include/yafraycore/photon.h | 7 ++ include/yafraycore/pkdtree.h | 117 ++++++++++++++++++++------------ src/integrators/photonintegr.cc | 11 ++- src/yafraycore/photon.cc | 2 +- src/yafraycore/session.cc | 3 + 5 files changed, 92 insertions(+), 48 deletions(-) diff --git a/include/yafraycore/photon.h b/include/yafraycore/photon.h index ceb4e629..1a50ae90 100644 --- a/include/yafraycore/photon.h +++ b/include/yafraycore/photon.h @@ -155,8 +155,11 @@ class YAFRAYCORE_EXPORT photonMap_t { public: photonMap_t(): paths(0), updated(false), searchRadius(1.), tree(nullptr){ } + photonMap_t(const std::string &mapname, int threads): paths(0), updated(false), searchRadius(1.), tree(nullptr), name(mapname),threadsPKDtree(threads) { } ~photonMap_t(){ if(tree) delete tree; } void setNumPaths(int n){ paths=n; } + void setName(const std::string &mapname) { name = mapname; } + void setNumThreadsPKDtree(int threads){ threadsPKDtree = threads; } int nPaths() const{ return paths; } int nPhotons() const{ return photons.size(); } void pushPhoton(photon_t &p) { photons.push_back(p); updated=false; } @@ -177,6 +180,8 @@ class YAFRAYCORE_EXPORT photonMap_t bool updated; PFLOAT searchRadius; kdtree::pointKdTree *tree; + std::string name; + int threadsPKDtree = 1; friend class boost::serialization::access; template void serialize(Archive & ar, const unsigned int version) @@ -185,6 +190,8 @@ class YAFRAYCORE_EXPORT photonMap_t ar & BOOST_SERIALIZATION_NVP(paths); ar & BOOST_SERIALIZATION_NVP(updated); ar & BOOST_SERIALIZATION_NVP(searchRadius); + ar & BOOST_SERIALIZATION_NVP(name); + ar & BOOST_SERIALIZATION_NVP(threadsPKDtree); ar & BOOST_SERIALIZATION_NVP(tree); } }; diff --git a/include/yafraycore/pkdtree.h b/include/yafraycore/pkdtree.h index 41eb39aa..ee4f0b55 100644 --- a/include/yafraycore/pkdtree.h +++ b/include/yafraycore/pkdtree.h @@ -69,7 +69,7 @@ class pointKdTree { public: pointKdTree() {}; - pointKdTree(const std::vector &dat); + pointKdTree(const std::vector &dat, const std::string &mapName, int numThreads=1); ~pointKdTree(){ if(nodes) y_free(nodes); } template void lookup(const point3d_t &p, const LookupProc &proc, PFLOAT &maxDistSquared) const; double lookupStat()const{ return double(Y_PROCS)/double(Y_LOOKUPS); } //!< ratio of photons tested per lookup call @@ -82,11 +82,13 @@ class pointKdTree int axis; //!< the split axis of parent node }; void buildTree(u_int32 start, u_int32 end, bound_t &nodeBound, const T **prims); - void buildTree2(u_int32 start, u_int32 end, bound_t &nodeBound, const T **prims, int axis=0); + void buildTreeWorker(u_int32 start, u_int32 end, bound_t &nodeBound, const T **prims, int level, uint32_t & localNextFreeNode, kdNode * localNodes); kdNode *nodes; u_int32 nElements, nextFreeNode; bound_t treeBound; mutable unsigned int Y_LOOKUPS, Y_PROCS; + int maxLevelThreads = 0; //max level where we will launch threads. We will try to launch at least as many threads as scene threads parameter + std::mutex mutx; friend class boost::serialization::access; template void save(Archive & ar, const unsigned int version) const @@ -115,7 +117,7 @@ class pointKdTree }; template -pointKdTree::pointKdTree(const std::vector &dat) +pointKdTree::pointKdTree(const std::vector &dat, const std::string &mapName, int numThreads) { Y_LOOKUPS=0; Y_PROCS=0; nextFreeNode = 0; @@ -123,11 +125,12 @@ pointKdTree::pointKdTree(const std::vector &dat) if(nElements == 0) { - Y_ERROR << "pointKdTree: Empty vector!" << yendl; + Y_ERROR << "pointKdTree: " << mapName << " empty vector!" << yendl; return; } nodes = (kdNode *)y_memalign(64, 4*nElements*sizeof(kdNode)); //actually we could allocate one less...2n-1 + const T **elements = new const T*[nElements]; for(u_int32 i=0; i::pointKdTree(const std::vector &dat) for(u_int32 i=1; i::pointKdTree(const std::vector &dat) template void pointKdTree::buildTree(u_int32 start, u_int32 end, bound_t &nodeBound, const T **prims) { - if(end - start == 1) - { - nodes[nextFreeNode].createLeaf(prims[start]); - nextFreeNode++; - return; - } - int splitAxis = nodeBound.largestAxis(); - int splitEl = (start+end)/2; - std::nth_element(&prims[start], &prims[splitEl], - &prims[end], CompareNode(splitAxis)); - u_int32 curNode = nextFreeNode; - PFLOAT splitPos = prims[splitEl]->pos[splitAxis]; - nodes[curNode].createInterior(splitAxis, splitPos); - ++nextFreeNode; - bound_t boundL = nodeBound, boundR = nodeBound; - switch(splitAxis){ - case 0: boundL.setMaxX(splitPos); boundR.setMinX(splitPos); break; - case 1: boundL.setMaxY(splitPos); boundR.setMinY(splitPos); break; - case 2: boundL.setMaxZ(splitPos); boundR.setMinZ(splitPos); break; - } - //<< recurse below child >> - buildTree(start, splitEl, boundL, prims); - //<< recurse above child >> - nodes[curNode].setRightChild (nextFreeNode); - buildTree(splitEl, end, boundR, prims); + buildTreeWorker(start, end, nodeBound, prims, 0, nextFreeNode, nodes); } template -void pointKdTree::buildTree2(u_int32 start, u_int32 end, bound_t &nodeBound, const T **prims, int axis) +void pointKdTree::buildTreeWorker(u_int32 start, u_int32 end, bound_t &nodeBound, const T **prims, int level, uint32_t & localNextFreeNode, kdNode * localNodes) { + ++level; if(end - start == 1) { - nodes[nextFreeNode].createLeaf(prims[start]); - nextFreeNode++; + localNodes[localNextFreeNode].createLeaf(prims[start]); + localNextFreeNode++; return; } - - int splitAxis = axis; + int splitAxis = nodeBound.largestAxis(); int splitEl = (start+end)/2; std::nth_element(&prims[start], &prims[splitEl], &prims[end], CompareNode(splitAxis)); - u_int32 curNode = nextFreeNode; + u_int32 curNode = localNextFreeNode; PFLOAT splitPos = prims[splitEl]->pos[splitAxis]; - nodes[curNode].createInterior(splitAxis, splitPos); - ++nextFreeNode; + localNodes[curNode].createInterior(splitAxis, splitPos); + ++localNextFreeNode; bound_t boundL = nodeBound, boundR = nodeBound; switch(splitAxis){ case 0: boundL.setMaxX(splitPos); boundR.setMinX(splitPos); break; case 1: boundL.setMaxY(splitPos); boundR.setMinY(splitPos); break; case 2: boundL.setMaxZ(splitPos); boundR.setMinZ(splitPos); break; } - //<< recurse below child >> - buildTree2(start, splitEl, boundL, prims, (axis+1)%3); - //<< recurse above child >> - nodes[curNode].setRightChild (nextFreeNode); - buildTree2(splitEl, end, boundR, prims, (axis+1)%3); + + if(level <= maxLevelThreads) //launch threads for the first "x" levels to try to match (at least) the scene threads parameter + { + //<< recurse below child >> + uint32_t nextFreeNode1 = 0; + kdNode * nodes1 = (kdNode *)y_memalign(64, 4*(splitEl-start)*sizeof(kdNode)); + std::thread * belowWorker = new std::thread(&pointKdTree::buildTreeWorker, this, start, splitEl, std::ref(boundL), prims, level, std::ref(nextFreeNode1), nodes1); + + //<< recurse above child >> + uint32_t nextFreeNode2 = 0; + kdNode * nodes2 = (kdNode *)y_memalign(64, 4*(end-splitEl)*sizeof(kdNode)); + std::thread * aboveWorker = new std::thread(&pointKdTree::buildTreeWorker, this, splitEl, end, std::ref(boundR), prims, level, std::ref(nextFreeNode2), nodes2); + + belowWorker->join(); + aboveWorker->join(); + delete belowWorker; + delete aboveWorker; + + for(uint32_t i=0; i> + buildTreeWorker(start, splitEl, boundL, prims, level, localNextFreeNode, localNodes); + //<< recurse above child >> + localNodes[curNode].setRightChild (localNextFreeNode); + buildTreeWorker(splitEl, end, boundR, prims, level, localNextFreeNode, localNodes); + } + --level; } diff --git a/src/integrators/photonintegr.cc b/src/integrators/photonintegr.cc index ec2fe33b..d8bf454d 100644 --- a/src/integrators/photonintegr.cc +++ b/src/integrators/photonintegr.cc @@ -484,7 +484,7 @@ bool photonIntegrator_t::preprocess() if(usePhotonDiffuse && finalGather) { - pb->setTag("Loading FG radiance map from temp folder..."); + pb->setTag("Loading FG radiance photon map from temp folder..."); std::string filename = boost::filesystem::temp_directory_path().string(); filename += "/yafaray_photonMap_fg_radiance.tmp"; Y_INFO << integratorName << ": Loading FG radiance photon map from: " << filename << ". If it does not match the scene you could have crashes and/or incorrect renders, USE WITH CARE!" << yendl; @@ -566,11 +566,16 @@ bool photonIntegrator_t::preprocess() session.diffuseMap->clear(); session.diffuseMap->setNumPaths(0); session.diffuseMap->reserveMemory(nDiffusePhotons); + session.diffuseMap->setNumThreadsPKDtree(scene->getNumThreadsPhotons()); + session.causticMap->clear(); session.causticMap->setNumPaths(0); session.causticMap->reserveMemory(nCausPhotons); + session.causticMap->setNumThreadsPKDtree(scene->getNumThreadsPhotons()); + session.radianceMap->clear(); session.radianceMap->setNumPaths(0); + session.radianceMap->setNumThreadsPKDtree(scene->getNumThreadsPhotons()); ray_t ray; float lightNumPdf, lightPdf; @@ -1032,7 +1037,7 @@ bool photonIntegrator_t::preprocess() if(usePhotonDiffuse && finalGather) //create radiance map: { // == remove too close radiance points ==// - kdtree::pointKdTree< radData_t > *rTree = new kdtree::pointKdTree< radData_t >(pgdat.rad_points); + kdtree::pointKdTree< radData_t > *rTree = new kdtree::pointKdTree< radData_t >(pgdat.rad_points, "FG Radiance Photon Map", scene->getNumThreadsPhotons()); std::vector< radData_t > cleaned; for(unsigned int i=0; isetTag("Saving FG radiance map to temp folder..."); + pb->setTag("Saving FG radiance photon map to temp folder..."); std::string filename = boost::filesystem::temp_directory_path().string(); filename += "/yafaray_photonMap_fg_radiance.tmp"; Y_INFO << integratorName << ": Saving FG radiance photon map to: " << filename << yendl; diff --git a/src/yafraycore/photon.cc b/src/yafraycore/photon.cc index f783777d..0f8b01b0 100644 --- a/src/yafraycore/photon.cc +++ b/src/yafraycore/photon.cc @@ -109,7 +109,7 @@ void photonMap_t::updateTree() if(tree) delete tree; if(photons.size() > 0) { - tree = new kdtree::pointKdTree(photons); + tree = new kdtree::pointKdTree(photons, name, threadsPKDtree); updated = true; } else tree=0; diff --git a/src/yafraycore/session.cc b/src/yafraycore/session.cc index a093f6ef..549631bd 100644 --- a/src/yafraycore/session.cc +++ b/src/yafraycore/session.cc @@ -34,8 +34,11 @@ session_t::session_t() { Y_VERBOSE << "Session:started" << yendl; causticMap = new photonMap_t; + causticMap->setName("Caustic Photon Map"); diffuseMap = new photonMap_t; + causticMap->setName("Diffuse Photon Map"); radianceMap = new photonMap_t; + causticMap->setName("FG Radiance Photon Map"); } session_t::~session_t() From a5d19d08385d5e67295d8b501a38c6bd5be67d4a Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sat, 30 Apr 2016 05:03:45 +0100 Subject: [PATCH 021/124] Added multithread PKDtree to mcintegrator (for caustic in direct light and path tracing). Also fixed photon map names in pkdtrees --- src/yafraycore/mcintegrator.cc | 2 ++ src/yafraycore/session.cc | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/yafraycore/mcintegrator.cc b/src/yafraycore/mcintegrator.cc index 6c7c771b..c154054f 100644 --- a/src/yafraycore/mcintegrator.cc +++ b/src/yafraycore/mcintegrator.cc @@ -512,6 +512,8 @@ bool mcIntegrator_t::createCausticMap() session.causticMap->clear(); session.causticMap->setNumPaths(0); session.causticMap->reserveMemory(nCausPhotons); + session.causticMap->setNumThreadsPKDtree(scene->getNumThreadsPhotons()); + ray_t ray; std::vector causLights; diff --git a/src/yafraycore/session.cc b/src/yafraycore/session.cc index 549631bd..57ffd943 100644 --- a/src/yafraycore/session.cc +++ b/src/yafraycore/session.cc @@ -36,9 +36,9 @@ session_t::session_t() causticMap = new photonMap_t; causticMap->setName("Caustic Photon Map"); diffuseMap = new photonMap_t; - causticMap->setName("Diffuse Photon Map"); + diffuseMap->setName("Diffuse Photon Map"); radianceMap = new photonMap_t; - causticMap->setName("FG Radiance Photon Map"); + radianceMap->setName("FG Radiance Photon Map"); } session_t::~session_t() From 58ac71cc63545057c90ce4bc1f5902b88d4c5d6e Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sat, 30 Apr 2016 05:06:32 +0100 Subject: [PATCH 022/124] Change default value for photon threads to automatic (-1) as render threads --- src/yafraycore/environment.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/yafraycore/environment.cc b/src/yafraycore/environment.cc index eb6ddb14..fab4a601 100644 --- a/src/yafraycore/environment.cc +++ b/src/yafraycore/environment.cc @@ -739,7 +739,7 @@ void renderEnvironment_t::setupLoggingAndBadge(const paraMap_t ¶ms) bool renderEnvironment_t::setupScene(scene_t &scene, const paraMap_t ¶ms, colorOutput_t &output, progressBar_t *pb) { const std::string *name=0; - int AA_passes=1, AA_samples=1, AA_inc_samples=1, nthreads=-1, nthreads_photons=1; + int AA_passes=1, AA_samples=1, AA_inc_samples=1, nthreads=-1, nthreads_photons=-1; double AA_threshold=0.05; float AA_resampled_floor=0.f; float AA_sample_multiplier_factor = 1.f; From 895f9185a221ebf2d26843520a24d224b24f8e79 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sat, 30 Apr 2016 05:09:17 +0100 Subject: [PATCH 023/124] If no explicit "nthreads_photons" parameter is set, use for it the same as the scene render threads parameter --- src/yafraycore/environment.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/yafraycore/environment.cc b/src/yafraycore/environment.cc index fab4a601..3798e162 100644 --- a/src/yafraycore/environment.cc +++ b/src/yafraycore/environment.cc @@ -818,6 +818,9 @@ bool renderEnvironment_t::setupScene(scene_t &scene, const paraMap_t ¶ms, co params.getParam("AA_clamp_samples", AA_clamp_samples); params.getParam("AA_clamp_indirect", AA_clamp_indirect); params.getParam("threads", nthreads); // number of threads, -1 = auto detection + + nthreads_photons = nthreads; //if no "threads_photons" parameter exists, make "nthreads_photons" equal to render threads + params.getParam("threads_photons", nthreads_photons); // number of threads for photon mapping, -1 = auto detection params.getParam("adv_auto_shadow_bias_enabled", adv_auto_shadow_bias_enabled); params.getParam("adv_shadow_bias_value", adv_shadow_bias_value); From b0ce741c0a94e2c5a84f1de8f29745d30c524dcb Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sat, 30 Apr 2016 11:33:58 +0100 Subject: [PATCH 024/124] New multithread Photon Maps/PKDtree: fixing crashes in Windows and when using yafaray-xml --- include/yafraycore/pkdtree.h | 46 +++++++++++++++++++-------------- src/integrators/photonintegr.cc | 4 +-- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/include/yafraycore/pkdtree.h b/include/yafraycore/pkdtree.h index ee4f0b55..b9a01374 100644 --- a/include/yafraycore/pkdtree.h +++ b/include/yafraycore/pkdtree.h @@ -143,11 +143,11 @@ pointKdTree::pointKdTree(const std::vector &dat, const std::string &mapNam int realThreads = (int) pow(2.f, maxLevelThreads); //real amount of threads we will create during pkdtree creation depending on the maximum level where we will generate threads Y_INFO << "pointKdTree: Starting " << mapName << " recusive tree build for " << nElements << " elements [using " << realThreads << " threads]" << yendl; - + buildTree(0, nElements, treeBound, elements); Y_VERBOSE << "pointKdTree: " << mapName << " tree built." << yendl; - + delete[] elements; } @@ -182,44 +182,50 @@ void pointKdTree::buildTreeWorker(u_int32 start, u_int32 end, bound_t &nodeBo case 2: boundL.setMaxZ(splitPos); boundR.setMinZ(splitPos); break; } - if(level <= maxLevelThreads) //launch threads for the first "x" levels to try to match (at least) the scene threads parameter + if (level <= maxLevelThreads) //launch threads for the first "x" levels to try to match (at least) the scene threads parameter { //<< recurse below child >> uint32_t nextFreeNode1 = 0; - kdNode * nodes1 = (kdNode *)y_memalign(64, 4*(splitEl-start)*sizeof(kdNode)); + kdNode * nodes1 = (kdNode *)y_memalign(64, 4 * (splitEl - start)*sizeof(kdNode)); std::thread * belowWorker = new std::thread(&pointKdTree::buildTreeWorker, this, start, splitEl, std::ref(boundL), prims, level, std::ref(nextFreeNode1), nodes1); - + //<< recurse above child >> uint32_t nextFreeNode2 = 0; - kdNode * nodes2 = (kdNode *)y_memalign(64, 4*(end-splitEl)*sizeof(kdNode)); + kdNode * nodes2 = (kdNode *)y_memalign(64, 4 * (end - splitEl)*sizeof(kdNode)); std::thread * aboveWorker = new std::thread(&pointKdTree::buildTreeWorker, this, splitEl, end, std::ref(boundR), prims, level, std::ref(nextFreeNode2), nodes2); belowWorker->join(); aboveWorker->join(); delete belowWorker; delete aboveWorker; - - for(uint32_t i=0; inPhotons() > 0 && scene->getNumThreadsPhotons() >= 2) @@ -1034,6 +1032,8 @@ bool photonIntegrator_t::preprocess() Y_VERBOSE << integratorName << ": Diffuse photon map: done." << yendl; } + if (!intpb) delete pb; + if(usePhotonDiffuse && finalGather) //create radiance map: { // == remove too close radiance points ==// From f6a3ed60b64b48afaf521f6f4b9c572021bdf3e6 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sat, 30 Apr 2016 16:40:57 +0100 Subject: [PATCH 025/124] Logging system: added Duration to the logs (console, txt and HTML). Also created a mutex in the log to try to avoid garbled logs with threads. --- include/core_api/logging.h | 20 ++++++++++- src/yafraycore/logging.cc | 70 +++++++++++++++++++++++++++++++------- 2 files changed, 77 insertions(+), 13 deletions(-) diff --git a/include/core_api/logging.h b/include/core_api/logging.h index 71a0da2f..1404c1bc 100644 --- a/include/core_api/logging.h +++ b/include/core_api/logging.h @@ -30,6 +30,17 @@ #include #include #include +#if defined(_WIN32) && defined(__MINGW32__) + #undef _GLIBCXX_HAS_GTHREADS + #include + #include + #include + #include +#else + #include + #include + #include +#endif __BEGIN_YAFRAY @@ -51,10 +62,11 @@ class YAFRAYCORE_EXPORT logEntry_t friend class yafarayLog_t; public: - logEntry_t(std::time_t datetime, int verb_level, std::string description):eventDateTime(datetime),mVerbLevel(verb_level),eventDescription(description) {} + logEntry_t(std::time_t datetime, double duration, int verb_level, std::string description):eventDateTime(datetime),eventDuration(duration),mVerbLevel(verb_level),eventDescription(description) {} protected: std::time_t eventDateTime; + double eventDuration; int mVerbLevel; std::string eventDescription; }; @@ -64,6 +76,7 @@ class YAFRAYCORE_EXPORT yafarayLog_t { public: yafarayLog_t(); + yafarayLog_t(const yafarayLog_t&); //customizing copy constructor so we can use a std::mutex as a class member (not copiable) ~yafarayLog_t(); @@ -106,8 +119,11 @@ class YAFRAYCORE_EXPORT yafarayLog_t void setConsoleMasterVerbosity(int vlevel); void setLogMasterVerbosity(int vlevel); std::string printTime(std::time_t datetime) const; + std::string printDuration(double duration) const; std::string printDate(std::time_t datetime) const; int vlevel_from_string(std::string strVLevel) const; + + std::mutex mutx; //To try to avoid garbled output when there are several threads trying to output data to the log template yafarayLog_t & operator << ( const T &obj ) @@ -149,6 +165,8 @@ class YAFRAYCORE_EXPORT yafarayLog_t std::string mRenderSettings; bool drawAANoiseSettings = true; bool drawRenderSettings = true; + std::time_t previousConsoleEventDateTime = 0; + std::time_t previousLogEventDateTime = 0; }; extern YAFRAYCORE_EXPORT yafarayLog_t yafLog; diff --git a/src/yafraycore/logging.cc b/src/yafraycore/logging.cc index 80137aca..7fc88e2b 100644 --- a/src/yafraycore/logging.cc +++ b/src/yafraycore/logging.cc @@ -30,6 +30,10 @@ yafarayLog_t::yafarayLog_t() { } +yafarayLog_t::yafarayLog_t(const yafarayLog_t&) //We need to redefine the copy constructor to avoid trying to copy the mutex (not copiable). This copy constructor will not copy anything, but we only have one log object in the session anyway so it should be ok. +{ +} + yafarayLog_t::~yafarayLog_t() { } @@ -62,7 +66,7 @@ void yafarayLog_t::saveTxtLog(const std::string &name) for (auto it = m_MemoryLog.begin() ; it != m_MemoryLog.end(); ++it) { - txtLogFile << "[" << printDate(it->eventDateTime) << " " << printTime(it->eventDateTime) << "] "; + txtLogFile << "[" << printDate(it->eventDateTime) << " " << printTime(it->eventDateTime) << " (" << printDuration(it->eventDuration) << ")] "; switch(it->mVerbLevel) { @@ -153,11 +157,11 @@ void yafarayLog_t::saveHtmlLog(const std::string &name) if(!m_MemoryLog.empty()) { - htmlLogFile << "

" << std::endl; + htmlLogFile << "

DateTimeVerbosityDescription
" << std::endl; for(auto it = m_MemoryLog.begin() ; it != m_MemoryLog.end(); ++it) { - htmlLogFile << ""; + htmlLogFile << ""; switch(it->mVerbLevel) { @@ -196,24 +200,43 @@ void yafarayLog_t::clearAll() yafarayLog_t & yafarayLog_t::out(int verbosity_level) { + mutx.lock(); + mVerbLevel = verbosity_level; std::time_t current_datetime = std::time(nullptr); - if(mVerbLevel <= mLogMasterVerbLevel) m_MemoryLog.push_back(logEntry_t(current_datetime, mVerbLevel, "")); - + + if(mVerbLevel <= mLogMasterVerbLevel) + { + if(previousLogEventDateTime == 0) previousLogEventDateTime = current_datetime; + double duration = std::difftime(current_datetime, previousLogEventDateTime); + + m_MemoryLog.push_back(logEntry_t(current_datetime, duration, mVerbLevel, "")); + + previousLogEventDateTime = current_datetime; + } + if(mVerbLevel <= mConsoleMasterVerbLevel) { + if(previousConsoleEventDateTime == 0) previousConsoleEventDateTime = current_datetime; + double duration = std::difftime(current_datetime, previousConsoleEventDateTime); + switch(mVerbLevel) { - case VL_DEBUG: std::cout << setColor(Magenta) << "[" << printTime(current_datetime) << "] DEBUG: " << setColor(); break; - case VL_VERBOSE: std::cout << setColor(Green) << "[" << printTime(current_datetime) << "] VERB: " << setColor(); break; - case VL_INFO: std::cout << setColor(Green) << "[" << printTime(current_datetime) << "] INFO: " << setColor(); break; - case VL_PARAMS: std::cout << setColor(Cyan) << "[" << printTime(current_datetime) << "] PARM: " << setColor(); break; - case VL_WARNING: std::cout << setColor(Yellow) << "[" << printTime(current_datetime) << "] WARNING: " << setColor(); break; - case VL_ERROR: std::cout << setColor(Red) << "[" << printTime(current_datetime) << "] ERROR: " << setColor(); break; - default: std::cout << setColor(White) << "[" << printTime(current_datetime) << "] LOG: " << setColor(); break; + case VL_DEBUG: std::cout << setColor(Magenta) << "[" << printTime(current_datetime) << " (" << printDuration(duration) << ")] DEBUG: " << setColor(); break; + case VL_VERBOSE: std::cout << setColor(Green) << "[" << printTime(current_datetime) << " (" << printDuration(duration) << ")] VERB: " << setColor(); break; + case VL_INFO: std::cout << setColor(Green) << "[" << printTime(current_datetime) << " (" << printDuration(duration) << ")] INFO: " << setColor(); break; + case VL_PARAMS: std::cout << setColor(Cyan) << "[" << printTime(current_datetime) << " (" << printDuration(duration) << ")] PARM: " << setColor(); break; + case VL_WARNING: std::cout << setColor(Yellow) << "[" << printTime(current_datetime) << " (" << printDuration(duration) << ")] WARNING: " << setColor(); break; + case VL_ERROR: std::cout << setColor(Red) << "[" << printTime(current_datetime) << " (" << printDuration(duration) << ")] ERROR: " << setColor(); break; + default: std::cout << setColor(White) << "[" << printTime(current_datetime) << " (" << printDuration(duration) << ")] LOG: " << setColor(); break; } + + previousConsoleEventDateTime = current_datetime; } + + mutx.unlock(); + return *this; } @@ -260,6 +283,29 @@ std::string yafarayLog_t::printDate(std::time_t datetime) const return std::string(mbstr); } +std::string yafarayLog_t::printDuration(double duration) const +{ + std::ostringstream strDur; + + int duration_int = (int) duration; + int hours = duration_int / 3600; + int minutes = (duration_int % 3600) / 60; + int seconds = duration_int % 60; + + if(hours == 0) strDur << " "; + else strDur << "+" << std::setw(3) << hours << "h"; + + if(hours == 0 && minutes == 0) strDur << " "; + else if (hours == 0 && minutes != 0) strDur << "+" << std::setw(2) << minutes << "m"; + else strDur << " " << std::setw(2) << minutes << "m"; + + if(hours == 0 && minutes == 0 && seconds == 0) strDur << " "; + else if (hours == 0 && minutes == 0 && seconds != 0) strDur << "+" << std::setw(2) << seconds << "s"; + else strDur << " " << std::setw(2) << seconds << "s"; + + return std::string(strDur.str()); +} + void yafarayLog_t::appendAANoiseSettings(const std::string &aa_noise_settings) { mAANoiseSettings += aa_noise_settings; From ca830d70b9edb269287fc581cbefb017b303e491 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sat, 30 Apr 2016 17:54:38 +0100 Subject: [PATCH 026/124] New duration in log, make it simpler and smaller in Console log --- include/core_api/logging.h | 1 + src/yafraycore/logging.cc | 42 +++++++++++++++++++++++++++++++------- 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/include/core_api/logging.h b/include/core_api/logging.h index 1404c1bc..cc783571 100644 --- a/include/core_api/logging.h +++ b/include/core_api/logging.h @@ -120,6 +120,7 @@ class YAFRAYCORE_EXPORT yafarayLog_t void setLogMasterVerbosity(int vlevel); std::string printTime(std::time_t datetime) const; std::string printDuration(double duration) const; + std::string printDurationSimpleFormat(double duration) const; std::string printDate(std::time_t datetime) const; int vlevel_from_string(std::string strVLevel) const; diff --git a/src/yafraycore/logging.cc b/src/yafraycore/logging.cc index 7fc88e2b..c3633f40 100644 --- a/src/yafraycore/logging.cc +++ b/src/yafraycore/logging.cc @@ -223,15 +223,20 @@ yafarayLog_t & yafarayLog_t::out(int verbosity_level) switch(mVerbLevel) { - case VL_DEBUG: std::cout << setColor(Magenta) << "[" << printTime(current_datetime) << " (" << printDuration(duration) << ")] DEBUG: " << setColor(); break; - case VL_VERBOSE: std::cout << setColor(Green) << "[" << printTime(current_datetime) << " (" << printDuration(duration) << ")] VERB: " << setColor(); break; - case VL_INFO: std::cout << setColor(Green) << "[" << printTime(current_datetime) << " (" << printDuration(duration) << ")] INFO: " << setColor(); break; - case VL_PARAMS: std::cout << setColor(Cyan) << "[" << printTime(current_datetime) << " (" << printDuration(duration) << ")] PARM: " << setColor(); break; - case VL_WARNING: std::cout << setColor(Yellow) << "[" << printTime(current_datetime) << " (" << printDuration(duration) << ")] WARNING: " << setColor(); break; - case VL_ERROR: std::cout << setColor(Red) << "[" << printTime(current_datetime) << " (" << printDuration(duration) << ")] ERROR: " << setColor(); break; - default: std::cout << setColor(White) << "[" << printTime(current_datetime) << " (" << printDuration(duration) << ")] LOG: " << setColor(); break; + case VL_DEBUG: std::cout << setColor(Magenta) << "[" << printTime(current_datetime) << "] DEBUG"; break; + case VL_VERBOSE: std::cout << setColor(Green) << "[" << printTime(current_datetime) << "] VERB"; break; + case VL_INFO: std::cout << setColor(Green) << "[" << printTime(current_datetime) << "] INFO"; break; + case VL_PARAMS: std::cout << setColor(Cyan) << "[" << printTime(current_datetime) << "] PARM"; break; + case VL_WARNING: std::cout << setColor(Yellow) << "[" << printTime(current_datetime) << "] WARNING"; break; + case VL_ERROR: std::cout << setColor(Red) << "[" << printTime(current_datetime) << "] ERROR"; break; + default: std::cout << setColor(White) << "[" << printTime(current_datetime) << "] LOG"; break; } + if(duration == 0) std::cout << ": "; + else std::cout << " (" << printDurationSimpleFormat(duration) << "): "; + + std::cout << setColor(); + previousConsoleEventDateTime = current_datetime; } @@ -306,6 +311,29 @@ std::string yafarayLog_t::printDuration(double duration) const return std::string(strDur.str()); } +std::string yafarayLog_t::printDurationSimpleFormat(double duration) const +{ + std::ostringstream strDur; + + int duration_int = (int) duration; + int hours = duration_int / 3600; + int minutes = (duration_int % 3600) / 60; + int seconds = duration_int % 60; + + if(hours == 0) strDur << ""; + else strDur << "+" << std::setw(2) << hours << "h"; + + if(hours == 0 && minutes == 0) strDur << ""; + else if (hours == 0 && minutes != 0) strDur << "+" << std::setw(2) << minutes << "m"; + else strDur << "" << std::setw(2) << minutes << "m"; + + if(hours == 0 && minutes == 0 && seconds == 0) strDur << ""; + else if (hours == 0 && minutes == 0 && seconds != 0) strDur << "+" << std::setw(2) << seconds << "s"; + else strDur << "" << std::setw(2) << seconds << "s"; + + return std::string(strDur.str()); +} + void yafarayLog_t::appendAANoiseSettings(const std::string &aa_noise_settings) { mAANoiseSettings += aa_noise_settings; From cb985d3bf5d40164c965787910d6280f182c2654 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sat, 30 Apr 2016 20:03:11 +0100 Subject: [PATCH 027/124] Implemented multi threaded PKDtrees in SPPM. Pending making SPPM photon map creation also multithreaded. --- src/integrators/sppm.cc | 49 +++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/src/integrators/sppm.cc b/src/integrators/sppm.cc index 5f9552c5..c5d039d8 100644 --- a/src/integrators/sppm.cc +++ b/src/integrators/sppm.cc @@ -327,7 +327,18 @@ void SPPM::prePass(int samples, int offset, bool adaptive) Y_INFO << integratorName << ": Starting Photon tracing pass..." << yendl; if(bHashgrid) photonGrid.clear(); - else {diffuseMap.clear(); causticMap.clear();} + else + { + session.diffuseMap->clear(); + session.diffuseMap->setNumPaths(0); + session.diffuseMap->reserveMemory(nPhotons); + session.diffuseMap->setNumThreadsPKDtree(scene->getNumThreadsPhotons()); + + session.causticMap->clear(); + session.causticMap->setNumPaths(0); + session.causticMap->reserveMemory(nPhotons); + session.causticMap->setNumThreadsPKDtree(scene->getNumThreadsPhotons()); + } background = scene->getBackground(); lights = scene->lights; @@ -460,8 +471,8 @@ void SPPM::prePass(int samples, int offset, bool adaptive) if(bHashgrid) photonGrid.pushPhoton(np); else { - diffuseMap.pushPhoton(np); - diffuseMap.setNumPaths(curr); + session.diffuseMap->pushPhoton(np); + session.diffuseMap->setNumPaths(curr); } ndPhotonStored++; } @@ -473,8 +484,8 @@ void SPPM::prePass(int samples, int offset, bool adaptive) if(bHashgrid) photonGrid.pushPhoton(np); else { - causticMap.pushPhoton(np); - causticMap.setNumPaths(curr); + session.causticMap->pushPhoton(np); + session.causticMap->setNumPaths(curr); } ndPhotonStored++; } @@ -525,7 +536,7 @@ void SPPM::prePass(int samples, int offset, bool adaptive) totalnPhotons += nPhotons; // accumulate the total photon number, not using nPath for the case of hashgrid. - Y_VERBOSE << integratorName << ": Stored photons: "<< diffuseMap.nPhotons() + causticMap.nPhotons() << yendl; + Y_VERBOSE << integratorName << ": Stored photons: "<< session.diffuseMap->nPhotons() + session.causticMap->nPhotons() << yendl; if(bHashgrid) { @@ -535,19 +546,19 @@ void SPPM::prePass(int samples, int offset, bool adaptive) } else { - if(diffuseMap.nPhotons() > 0) + if(session.diffuseMap->nPhotons() > 0) { Y_INFO << integratorName << ": Building diffuse photons kd-tree:" << yendl; - diffuseMap.updateTree(); + session.diffuseMap->updateTree(); Y_VERBOSE << integratorName << ": Done." << yendl; } - if(causticMap.nPhotons() > 0) + if(session.causticMap->nPhotons() > 0) { Y_INFO << integratorName << ": Building caustic photons kd-tree:" << yendl; - causticMap.updateTree(); + session.causticMap->updateTree(); Y_VERBOSE << integratorName << ": Done." << yendl; } - if(diffuseMap.nPhotons() < 50) + if(session.diffuseMap->nPhotons() < 50) { Y_ERROR << integratorName << ": Too few photons, stopping now." << yendl; return; @@ -633,10 +644,10 @@ GatherInfo SPPM::traceGatherRay(yafaray::renderState_t &state, yafaray::diffRay_ PFLOAT radius_2 = radius_1; int nGathered_1 = 0, nGathered_2 = 0; - if(diffuseMap.nPhotons() > 0) - nGathered_1 = diffuseMap.gather(sp.P, gathered, nSearch, radius_1); - if(causticMap.nPhotons() > 0) - nGathered_2 = causticMap.gather(sp.P, gathered, nSearch, radius_2); + if(session.diffuseMap->nPhotons() > 0) + nGathered_1 = session.diffuseMap->gather(sp.P, gathered, nSearch, radius_1); + if(session.causticMap->nPhotons() > 0) + nGathered_2 = session.causticMap->gather(sp.P, gathered, nSearch, radius_2); if(nGathered_1 > 0 || nGathered_2 >0) // it none photon gathered, we just skip. { if(radius_1 < radius_2) // we choose the smaller one to be the initial radius. @@ -655,9 +666,9 @@ GatherInfo SPPM::traceGatherRay(yafaray::renderState_t &state, yafaray::diffRay_ nGathered = photonGrid.gather(sp.P, gathered, nMaxGather, radius2); // disable now else { - if(diffuseMap.nPhotons() > 0) // this is needed to avoid a runtime error. + if(session.diffuseMap->nPhotons() > 0) // this is needed to avoid a runtime error. { - nGathered = diffuseMap.gather(sp.P, gathered, nMaxGather, radius2); //we always collected all the photon inside the radius + nGathered = session.diffuseMap->gather(sp.P, gathered, nMaxGather, radius2); //we always collected all the photon inside the radius } if(nGathered > 0) @@ -697,11 +708,11 @@ GatherInfo SPPM::traceGatherRay(yafaray::renderState_t &state, yafaray::diffRay_ } // gather caustics photons - if(bsdfs & BSDF_DIFFUSE && causticMap.ready()) + if(bsdfs & BSDF_DIFFUSE && session.causticMap->ready()) { radius2 = hp.radius2; //reset radius2 & nGathered - nGathered = causticMap.gather(sp.P, gathered, nMaxGather, radius2); + nGathered = session.causticMap->gather(sp.P, gathered, nMaxGather, radius2); if(nGathered > 0) { color_t surfCol(0.f); From d52705f0e3f73561e33840cecd7c3d7e3b0d646a Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sun, 1 May 2016 07:31:27 +0100 Subject: [PATCH 028/124] SPPM MultiThreaded Photon Mapping, including multithreaded PKDTree implementation --- include/integrators/sppm.h | 2 + src/integrators/sppm.cc | 362 ++++++++++++++++++++++++++++--------- 2 files changed, 281 insertions(+), 83 deletions(-) diff --git a/include/integrators/sppm.h b/include/integrators/sppm.h index b843e16d..a68d1457 100644 --- a/include/integrators/sppm.h +++ b/include/integrators/sppm.h @@ -68,6 +68,8 @@ class YAFRAYPLUGIN_EXPORT SPPM: public mcIntegrator_t void initializePPM(); /*! based on integrate method to do the gatering trace, need double-check deadly. */ GatherInfo traceGatherRay(renderState_t &state, diffRay_t &ray, HitPoint &hp, colorPasses_t &colorPasses); + void photonWorker(photonMap_t * diffuseMap, photonMap_t * causticMap, int threadID, const scene_t *scene, unsigned int nPhotons, const pdf1D_t *lightPowerD, int numDLights, const std::string &integratorName, const std::vector &tmplights, progressBar_t *pb, int pbStep, unsigned int &totalPhotonsShot, int maxBounces, random_t & prng); + protected: hashGrid_t photonGrid; // the hashgrid for holding photons photonMap_t diffuseMap,causticMap; // photonmap diff --git a/src/integrators/sppm.cc b/src/integrators/sppm.cc index c5d039d8..8d164772 100644 --- a/src/integrators/sppm.cc +++ b/src/integrators/sppm.cc @@ -318,90 +318,34 @@ bool SPPM::renderTile(int numView, renderArea_t &a, int n_samples, int offset, b return true; } -//photon pass, scatter photon -void SPPM::prePass(int samples, int offset, bool adaptive) +void SPPM::photonWorker(photonMap_t * diffuseMap, photonMap_t * causticMap, int threadID, const scene_t *scene, unsigned int nPhotons, const pdf1D_t *lightPowerD, int numDLights, const std::string &integratorName, const std::vector &tmplights, progressBar_t *pb, int pbStep, unsigned int &totalPhotonsShot, int maxBounces, random_t & prng) { - gTimer.addEvent("prepass"); - gTimer.start("prepass"); - - Y_INFO << integratorName << ": Starting Photon tracing pass..." << yendl; - - if(bHashgrid) photonGrid.clear(); - else - { - session.diffuseMap->clear(); - session.diffuseMap->setNumPaths(0); - session.diffuseMap->reserveMemory(nPhotons); - session.diffuseMap->setNumThreadsPKDtree(scene->getNumThreadsPhotons()); - - session.causticMap->clear(); - session.causticMap->setNumPaths(0); - session.causticMap->reserveMemory(nPhotons); - session.causticMap->setNumThreadsPKDtree(scene->getNumThreadsPhotons()); - } - - background = scene->getBackground(); - lights = scene->lights; - std::vector tmplights; - - //background do not emit photons, or it is merged into normal light? - ray_t ray; float lightNumPdf, lightPdf, s1, s2, s3, s4, s5, s6, s7, sL; - int numDLights = 0; - float fNumLights = 0.f; - float *energies = nullptr; color_t pcol; - tmplights.clear(); - - for(int i=0; i<(int)lights.size(); ++i) - { - numDLights++; - tmplights.push_back(lights[i]); - } - - fNumLights = (float)numDLights; - energies = new float[numDLights]; - - for (int i=0; itotalEnergy().energy(); - - lightPowerD = new pdf1D_t(energies, numDLights); - - Y_VERBOSE << integratorName << ": Light(s) photon color testing for photon map:" << yendl; - - for(int i=0;iemitPhoton(.5, .5, .5, .5, ray, lightPdf); - lightNumPdf = lightPowerD->func[i] * lightPowerD->invIntegral; - pcol *= fNumLights * lightPdf / lightNumPdf; //remember that lightPdf is the inverse of the pdf, hence *=... - Y_VERBOSE << integratorName << ": Light [" << i+1 << "] Photon col:" << pcol << " | lnpdf: " << lightNumPdf << yendl; - } - - delete[] energies; - //shoot photons bool done=false; unsigned int curr=0; - + surfacePoint_t sp; - random_t prng(offset*(4517)+123); renderState_t state(&prng); unsigned char userdata[USER_DATA_SIZE+7]; state.userdata = (void *)( &userdata[7] - ( ((size_t)&userdata[7])&7 ) ); // pad userdata to 8 bytes state.cam = scene->getCamera(); - progressBar_t *pb; - int pbStep; - if(intpb) pb = intpb; - else pb = new ConsoleProgressBar_t(80); + + float fNumLights = (float)numDLights; - if(bHashgrid) Y_INFO << integratorName << ": Building photon hashgrid..." << yendl; - else Y_INFO << integratorName << ": Building photon map..." << yendl; + unsigned int nPhotons_thread = 1 + ( (nPhotons - 1) / scene->getNumThreadsPhotons() ); - pb->init(128); - pbStep = std::max(1U, nPhotons/128); - //pb->setTag("Building photon map..."); + std::vector localCausticPhotons; + localCausticPhotons.clear(); + localCausticPhotons.reserve(nPhotons_thread); + std::vector localDiffusePhotons; + localDiffusePhotons.clear(); + localDiffusePhotons.reserve(nPhotons_thread); + //Pregather photons float invDiffPhotons = 1.f / (float)nPhotons; @@ -410,19 +354,26 @@ void SPPM::prePass(int samples, int offset, bool adaptive) while(!done) { - if(scene->getSignals() & Y_SIG_ABORT) { pb->done(); if(!intpb) delete pb; return; } + unsigned int haltoncurr = curr + nPhotons_thread * threadID; + state.chromatic = true; - state.wavelength = scrHalton(5, curr); + state.wavelength = scrHalton(5, haltoncurr); // Tried LD, get bad and strange results for some stategy. - s1 = hal1.getNext(); + s1 = hal1.getNext(); s2 = hal2.getNext(); - s3 = hal3.getNext(); - s4 = hal4.getNext(); + s3 = hal3.getNext(); + s4 = hal4.getNext(); - sL = float(curr) * invDiffPhotons; // Does sL also need more random for each pass? + sL = float(haltoncurr) * invDiffPhotons; // Does sL also need more random for each pass? int lightNum = lightPowerD->DSample(sL, &lightNumPdf); - if(lightNum >= numDLights){ Y_ERROR << integratorName << ": lightPDF sample error! "<= numDLights) + { + diffuseMap->mutx.lock(); + Y_ERROR << integratorName << ": lightPDF sample error! "<mutx.unlock(); + return; + } pcol = tmplights[lightNum]->emitPhoton(s1, s2, s3, s4, ray, lightPdf); ray.tmin = scene->rayMinDist; @@ -445,7 +396,12 @@ void SPPM::prePass(int samples, int offset, bool adaptive) while( scene->intersect(ray, sp) ) //scatter photons. { if(std::isnan(pcol.R) || std::isnan(pcol.G) || std::isnan(pcol.B)) - { Y_WARNING << integratorName << ": NaN on photon color for light" << lightNum + 1 << ".\n"; continue; } + { + diffuseMap->mutx.lock(); + Y_WARNING << integratorName << ": NaN on photon color for light" << lightNum + 1 << "." << yendl; + diffuseMap->mutx.unlock(); + continue; + } color_t transm(1.f); color_t vcol(0.f); @@ -471,8 +427,7 @@ void SPPM::prePass(int samples, int offset, bool adaptive) if(bHashgrid) photonGrid.pushPhoton(np); else { - session.diffuseMap->pushPhoton(np); - session.diffuseMap->setNumPaths(curr); + localDiffusePhotons.push_back(np); } ndPhotonStored++; } @@ -484,8 +439,7 @@ void SPPM::prePass(int samples, int offset, bool adaptive) if(bHashgrid) photonGrid.pushPhoton(np); else { - session.causticMap->pushPhoton(np); - session.causticMap->setNumPaths(curr); + localCausticPhotons.push_back(np); } ndPhotonStored++; } @@ -522,12 +476,254 @@ void SPPM::prePass(int samples, int offset, bool adaptive) ray.tmin = scene->rayMinDist; ray.tmax = -1.0; ++nBounces; - } ++curr; - if(curr % pbStep == 0) pb->update(); - done = (curr >= nPhotons); + if(curr % pbStep == 0) + { + pb->mutx.lock(); + pb->update(); + pb->mutx.unlock(); + if(scene->getSignals() & Y_SIG_ABORT) { return; } + } + done = (curr >= nPhotons_thread); + } + diffuseMap->mutx.lock(); + causticMap->mutx.lock(); + diffuseMap->appendVector(localDiffusePhotons, curr); + causticMap->appendVector(localCausticPhotons, curr); + totalPhotonsShot += curr; + causticMap->mutx.unlock(); + diffuseMap->mutx.unlock(); +} + + +//photon pass, scatter photon +void SPPM::prePass(int samples, int offset, bool adaptive) +{ + gTimer.addEvent("prepass"); + gTimer.start("prepass"); + + Y_INFO << integratorName << ": Starting Photon tracing pass..." << yendl; + + if(bHashgrid) photonGrid.clear(); + else + { + session.diffuseMap->clear(); + session.diffuseMap->setNumPaths(0); + session.diffuseMap->reserveMemory(nPhotons); + session.diffuseMap->setNumThreadsPKDtree(scene->getNumThreadsPhotons()); + + session.causticMap->clear(); + session.causticMap->setNumPaths(0); + session.causticMap->reserveMemory(nPhotons); + session.causticMap->setNumThreadsPKDtree(scene->getNumThreadsPhotons()); + } + + background = scene->getBackground(); + lights = scene->lights; + std::vector tmplights; + + //background do not emit photons, or it is merged into normal light? + + ray_t ray; + float lightNumPdf, lightPdf, s1, s2, s3, s4, s5, s6, s7, sL; + int numDLights = 0; + float fNumLights = 0.f; + float *energies = nullptr; + color_t pcol; + + tmplights.clear(); + + for(int i=0; i<(int)lights.size(); ++i) + { + numDLights++; + tmplights.push_back(lights[i]); + } + + fNumLights = (float)numDLights; + energies = new float[numDLights]; + + for (int i=0; itotalEnergy().energy(); + + lightPowerD = new pdf1D_t(energies, numDLights); + + Y_VERBOSE << integratorName << ": Light(s) photon color testing for photon map:" << yendl; + + for(int i=0;iemitPhoton(.5, .5, .5, .5, ray, lightPdf); + lightNumPdf = lightPowerD->func[i] * lightPowerD->invIntegral; + pcol *= fNumLights * lightPdf / lightNumPdf; //remember that lightPdf is the inverse of the pdf, hence *=... + Y_VERBOSE << integratorName << ": Light [" << i+1 << "] Photon col:" << pcol << " | lnpdf: " << lightNumPdf << yendl; } + + delete[] energies; + + //shoot photons + unsigned int curr=0; + + surfacePoint_t sp; + random_t prng(offset*(4517)+123); + renderState_t state(&prng); + unsigned char userdata[USER_DATA_SIZE+7]; + state.userdata = (void *)( &userdata[7] - ( ((size_t)&userdata[7])&7 ) ); // pad userdata to 8 bytes + state.cam = scene->getCamera(); + progressBar_t *pb; + int pbStep; + if(intpb) pb = intpb; + else pb = new ConsoleProgressBar_t(80); + + if(bHashgrid) Y_INFO << integratorName << ": Building photon hashgrid..." << yendl; + else Y_INFO << integratorName << ": Building photon map..." << yendl; + + pb->init(128); + pbStep = std::max(1U, nPhotons/128); + //pb->setTag("Building photon map..."); + + int nThreads = scene->getNumThreadsPhotons(); + + nPhotons = (nPhotons / nThreads) * nThreads; //rounding the number of diffuse photons so it's a number divisible by the number of threads (distribute uniformly among the threads) + + Y_PARAMS << integratorName << ": Shooting "<= 2) + { + std::vector threads; + for(int i=0; igetSignals() & Y_SIG_ABORT) { pb->done(); if(!intpb) delete pb; return; } + state.chromatic = true; + state.wavelength = scrHalton(5, curr); + + // Tried LD, get bad and strange results for some stategy. + s1 = hal1.getNext(); + s2 = hal2.getNext(); + s3 = hal3.getNext(); + s4 = hal4.getNext(); + + sL = float(curr) * invDiffPhotons; // Does sL also need more random for each pass? + int lightNum = lightPowerD->DSample(sL, &lightNumPdf); + if(lightNum >= numDLights){ Y_ERROR << integratorName << ": lightPDF sample error! "<emitPhoton(s1, s2, s3, s4, ray, lightPdf); + ray.tmin = scene->rayMinDist; + ray.tmax = -1.0; + pcol *= fNumLights*lightPdf/lightNumPdf; //remember that lightPdf is the inverse of th pdf, hence *=... + + if(pcol.isBlack()) + { + ++curr; + done = (curr >= nPhotons); + continue; + } + + int nBounces=0; + bool causticPhoton = false; + bool directPhoton = true; + const material_t *material = nullptr; + BSDF_t bsdfs; + + while( scene->intersect(ray, sp) ) //scatter photons. + { + if(std::isnan(pcol.R) || std::isnan(pcol.G) || std::isnan(pcol.B)) + { Y_WARNING << integratorName << ": NaN on photon color for light" << lightNum + 1 << ".\n"; continue; } + + color_t transm(1.f); + color_t vcol(0.f); + const volumeHandler_t* vol; + + if(material) + { + if((bsdfs&BSDF_VOLUMETRIC) && (vol=material->getVolumeHandler(sp.Ng * -ray.dir < 0))) + { + if(vol->transmittance(state, ray, vcol)) transm = vcol; + } + } + + vector3d_t wi = -ray.dir, wo; + material = sp.material; + material->initBSDF(state, sp, bsdfs); + + //deposit photon on diffuse surface, now we only have one map for all, elimate directPhoton for we estimate it directly + if(!directPhoton && !causticPhoton && (bsdfs & (BSDF_DIFFUSE))) + { + photon_t np(wi, sp.P, pcol);// pcol used here + + if(bHashgrid) photonGrid.pushPhoton(np); + else + { + session.diffuseMap->pushPhoton(np); + session.diffuseMap->setNumPaths(curr); + } + ndPhotonStored++; + } + // add caustic photon + if(!directPhoton && causticPhoton && (bsdfs & (BSDF_DIFFUSE | BSDF_GLOSSY))) + { + photon_t np(wi, sp.P, pcol);// pcol used here + + if(bHashgrid) photonGrid.pushPhoton(np); + else + { + session.causticMap->pushPhoton(np); + session.causticMap->setNumPaths(curr); + } + ndPhotonStored++; + } + + // need to break in the middle otherwise we scatter the photon and then discard it => redundant + if(nBounces == maxBounces) break; + + // scatter photon + s5 = ourRandom(); // now should use this to see correctness + s6 = ourRandom(); + s7 = ourRandom(); + + pSample_t sample(s5, s6, s7, BSDF_ALL, pcol, transm); + + bool scattered = material->scatterPhoton(state, sp, wi, wo, sample); + if(!scattered) break; //photon was absorped. actually based on russian roulette + + pcol = sample.color; + + causticPhoton = ((sample.sampledFlags & (BSDF_GLOSSY | BSDF_SPECULAR | BSDF_DISPERSIVE)) && directPhoton) || + ((sample.sampledFlags & (BSDF_GLOSSY | BSDF_SPECULAR | BSDF_FILTER | BSDF_DISPERSIVE)) && causticPhoton); + directPhoton = (sample.sampledFlags & BSDF_FILTER) && directPhoton; + + if(state.chromatic && (sample.sampledFlags & BSDF_DISPERSIVE)) + { + state.chromatic=false; + color_t wl_col; + wl2rgb(state.wavelength, wl_col); + pcol *= wl_col; + } + + ray.from = sp.P; + ray.dir = wo; + ray.tmin = scene->rayMinDist; + ray.tmax = -1.0; + ++nBounces; + + } + ++curr; + if(curr % pbStep == 0) pb->update(); + done = (curr >= nPhotons); + } + } + pb->done(); //pb->setTag("Photon map built."); Y_VERBOSE << integratorName << ":Photon map built." << yendl; From e88a7eebb2d843e1e441d1cc4fa1eb209767f5db Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sun, 1 May 2016 17:51:19 +0100 Subject: [PATCH 029/124] Set version to v3.0.0-Alpha state (it will be a very early release, only for devs) --- include/yafray_constants.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/yafray_constants.h b/include/yafray_constants.h index 20de5326..f3a93f44 100644 --- a/include/yafray_constants.h +++ b/include/yafray_constants.h @@ -5,7 +5,7 @@ #define __END_YAFRAY } #define PACKAGE "YafaRay" -#define VERSION "3.0.0-beta1" +#define VERSION "3.0.0-ALPHA1" #if (__GNUC__ > 3) #define GCC_HASCLASSVISIBILITY From 5cb0980236e8e7e71e33d6231582a63423dc7dab Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Mon, 2 May 2016 17:40:16 +0100 Subject: [PATCH 030/124] Fix regression in textures transparency, among others, looked inverted --- src/textures/layernode.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/textures/layernode.cc b/src/textures/layernode.cc index 1cc2becf..97123828 100644 --- a/src/textures/layernode.cc +++ b/src/textures/layernode.cc @@ -89,7 +89,7 @@ void layerNode_t::eval(nodeStack_t &stack, const renderState_t &state, const sur } } - rval = texture_value_blend(default_val, rval, Tin, stencilTin * valfac, mode, do_scalar); + rval = texture_value_blend(default_val, rval, Tin, stencilTin * valfac, mode, (do_scalar<0)); if(rval<0.f) rval=0.f; } rcol.A = stencilTin; From 7914110d10a481b3fac85fe2e8d2fabbf0cc962f Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Fri, 6 May 2016 05:38:17 +0100 Subject: [PATCH 031/124] Fix crash if number of photons < number of threads --- src/integrators/photonintegr.cc | 4 ++-- src/integrators/sppm.cc | 2 +- src/yafraycore/mcintegrator.cc | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/integrators/photonintegr.cc b/src/integrators/photonintegr.cc index 6353d2bf..57d4c6ce 100644 --- a/src/integrators/photonintegr.cc +++ b/src/integrators/photonintegr.cc @@ -646,7 +646,7 @@ bool photonIntegrator_t::preprocess() int nThreads = scene->getNumThreadsPhotons(); - nDiffusePhotons = (nDiffusePhotons / nThreads) * nThreads; //rounding the number of diffuse photons so it's a number divisible by the number of threads (distribute uniformly among the threads) + nDiffusePhotons = std::max((unsigned int) nThreads, (nDiffusePhotons / nThreads) * nThreads); //rounding the number of diffuse photons so it's a number divisible by the number of threads (distribute uniformly among the threads). At least 1 photon per thread Y_PARAMS << integratorName << ": Shooting "<getNumThreadsPhotons(); - nCausPhotons = (nCausPhotons / nThreads) * nThreads; //rounding the number of diffuse photons so it's a number divisible by the number of threads (distribute uniformly among the threads) + nCausPhotons = std::max((unsigned int) nThreads, (nCausPhotons / nThreads) * nThreads); //rounding the number of diffuse photons so it's a number divisible by the number of threads (distribute uniformly among the threads). At least 1 photon per thread Y_PARAMS << integratorName << ": Shooting "<getNumThreadsPhotons(); - nPhotons = (nPhotons / nThreads) * nThreads; //rounding the number of diffuse photons so it's a number divisible by the number of threads (distribute uniformly among the threads) + nPhotons = std::max((unsigned int) nThreads, (nPhotons / nThreads) * nThreads); //rounding the number of diffuse photons so it's a number divisible by the number of threads (distribute uniformly among the threads). At least 1 photon per thread Y_PARAMS << integratorName << ": Shooting "<getNumThreadsPhotons(); - nCausPhotons = (nCausPhotons / nThreads) * nThreads; //rounding the number of diffuse photons so it's a number divisible by the number of threads (distribute uniformly among the threads) + nCausPhotons = std::max((unsigned int) nThreads, (nCausPhotons / nThreads) * nThreads); //rounding the number of diffuse photons so it's a number divisible by the number of threads (distribute uniformly among the threads). At least 1 photon per thread Y_PARAMS << integratorName << ": Shooting "< Date: Sat, 7 May 2016 07:13:58 +0100 Subject: [PATCH 032/124] Photon threads: ensure level is correctly changed in all return paths --- include/yafraycore/pkdtree.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/yafraycore/pkdtree.h b/include/yafraycore/pkdtree.h index b9a01374..9699f7be 100644 --- a/include/yafraycore/pkdtree.h +++ b/include/yafraycore/pkdtree.h @@ -165,6 +165,7 @@ void pointKdTree::buildTreeWorker(u_int32 start, u_int32 end, bound_t &nodeBo { localNodes[localNextFreeNode].createLeaf(prims[start]); localNextFreeNode++; + --level; return; } int splitAxis = nodeBound.largestAxis(); From 6f7d5a0cf368c5e3f997732a069318ebeea81b40 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sat, 7 May 2016 07:53:45 +0100 Subject: [PATCH 033/124] Added Centre Tiles generation, by default now --- include/core_api/imagesplitter.h | 14 +++++++++++++- src/yafraycore/environment.cc | 5 +++-- src/yafraycore/imagesplitter.cc | 24 ++++++++++++++++-------- 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/include/core_api/imagesplitter.h b/include/core_api/imagesplitter.h index efdf1a6d..25762c2d 100644 --- a/include/core_api/imagesplitter.h +++ b/include/core_api/imagesplitter.h @@ -5,6 +5,7 @@ #include #include +#include __BEGIN_YAFRAY @@ -53,7 +54,7 @@ struct renderArea_t class imageSpliter_t { public: - enum tilesOrderType { LINEAR, RANDOM }; + enum tilesOrderType { LINEAR, RANDOM, CENTRE_RANDOM }; imageSpliter_t(int w, int h, int x0,int y0, int bsize, tilesOrderType torder, int nthreads); /* return the n-th area to be rendered. \return false if n is out of range, true otherwise @@ -64,6 +65,7 @@ class imageSpliter_t int size()const {return regions.size();}; protected: + friend class imageSpliterCentreSorter_t; struct region_t { int x,y,w,h; @@ -74,6 +76,16 @@ class imageSpliter_t tilesOrderType tilesorder; }; +class imageSpliterCentreSorter_t { + int imageW, imageH; +public: + imageSpliterCentreSorter_t(int image_w, int image_h) : imageW(image_w), imageH(image_h) {} + bool operator()(imageSpliter_t::region_t const & a, imageSpliter_t::region_t const & b) const { + return ((a.x - imageW/2) * (a.x - imageW/2) + (a.y - imageH/2) * (a.y - imageH/2)) < ((b.x - imageW/2) * (b.x - imageW/2) + (b.y - imageH/2) * (b.y - imageH/2)); + } +}; + + __END_YAFRAY #endif // Y_IMAGESPLITTER_H diff --git a/src/yafraycore/environment.cc b/src/yafraycore/environment.cc index 3798e162..102429e1 100644 --- a/src/yafraycore/environment.cc +++ b/src/yafraycore/environment.cc @@ -608,13 +608,14 @@ imageFilm_t* renderEnvironment_t::createImageFilm(const paraMap_t ¶ms, color } else Y_WARN_ENV << "No AA filter defined defaulting to Box!" << yendl; - imageSpliter_t::tilesOrderType tilesOrder=imageSpliter_t::LINEAR; + imageSpliter_t::tilesOrderType tilesOrder=imageSpliter_t::CENTRE_RANDOM; if(tiles_order) { if(*tiles_order == "linear") tilesOrder = imageSpliter_t::LINEAR; else if(*tiles_order == "random") tilesOrder = imageSpliter_t::RANDOM; + else if(*tiles_order == "centre") tilesOrder = imageSpliter_t::CENTRE_RANDOM; } - else Y_VERBOSE_ENV << "Defaulting to Linear tiles order." << yendl; // this is info imho not a warning + else Y_VERBOSE_ENV << "Defaulting to Centre tiles order." << yendl; // this is info imho not a warning imageFilm_t *film = new imageFilm_t(width, height, xstart, ystart, output, filt_sz, type, this, showSampledPixels, tileSize, tilesOrder, premult); diff --git a/src/yafraycore/imagesplitter.cc b/src/yafraycore/imagesplitter.cc index 8ed88d23..6f872078 100644 --- a/src/yafraycore/imagesplitter.cc +++ b/src/yafraycore/imagesplitter.cc @@ -32,9 +32,11 @@ imageSpliter_t::imageSpliter_t(int w, int h, int x0,int y0, int bsize, tilesOrde switch(tilesorder) { - case RANDOM: std::random_shuffle( regions_raw.begin(), regions_raw.end() ); - case LINEAR: - default: break; + case RANDOM: std::random_shuffle( regions_raw.begin(), regions_raw.end() ); + case CENTRE_RANDOM: std::random_shuffle( regions.begin(), regions.end() ); + std::sort( regions.begin(), regions.end(), imageSpliterCentreSorter_t(w, h) ); + case LINEAR: break; + default: break; } std::vector regions_subdivided; @@ -66,13 +68,19 @@ imageSpliter_t::imageSpliter_t(int w, int h, int x0,int y0, int bsize, tilesOrde } } } - + switch(tilesorder) { - case RANDOM: std::random_shuffle( regions.begin(), regions.end() ); - std::random_shuffle( regions_subdivided.begin(), regions_subdivided.end() ); - case LINEAR: - default: break; + case RANDOM: std::random_shuffle( regions.begin(), regions.end() ); + std::random_shuffle( regions_subdivided.begin(), regions_subdivided.end() ); + break; + case CENTRE_RANDOM: std::random_shuffle( regions.begin(), regions.end() ); + std::sort( regions.begin(), regions.end(), imageSpliterCentreSorter_t(w, h) ); + std::random_shuffle( regions_subdivided.begin(), regions_subdivided.end() ); + std::sort( regions_subdivided.begin(), regions_subdivided.end(), imageSpliterCentreSorter_t(w, h) ); + break; + case LINEAR: break; + default: break; } regions.insert(regions.end(), regions_subdivided.begin(), regions_subdivided.end()); From 73a9712a2a4c9153701f643fbf3e81365f312b5f Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sat, 7 May 2016 08:03:01 +0100 Subject: [PATCH 034/124] New Centre tiles: changes to ensure tiles are also centered when rendering a portion of an image (border) --- include/core_api/imagesplitter.h | 9 +++++---- src/yafraycore/imagesplitter.cc | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/include/core_api/imagesplitter.h b/include/core_api/imagesplitter.h index 25762c2d..11eb139c 100644 --- a/include/core_api/imagesplitter.h +++ b/include/core_api/imagesplitter.h @@ -77,11 +77,12 @@ class imageSpliter_t }; class imageSpliterCentreSorter_t { - int imageW, imageH; + int imageW, imageH, imageX0, imageY0; public: - imageSpliterCentreSorter_t(int image_w, int image_h) : imageW(image_w), imageH(image_h) {} - bool operator()(imageSpliter_t::region_t const & a, imageSpliter_t::region_t const & b) const { - return ((a.x - imageW/2) * (a.x - imageW/2) + (a.y - imageH/2) * (a.y - imageH/2)) < ((b.x - imageW/2) * (b.x - imageW/2) + (b.y - imageH/2) * (b.y - imageH/2)); + imageSpliterCentreSorter_t(int image_w, int image_h, int image_x0, int image_y0) : imageW(image_w), imageH(image_h), imageX0(image_x0), imageY0(image_y0) {} + bool operator()(imageSpliter_t::region_t const & a, imageSpliter_t::region_t const & b) const + { + return ((a.x-imageX0 - imageW/2) * (a.x-imageX0 - imageW/2) + (a.y-imageY0 - imageH/2) * (a.y-imageY0 - imageH/2)) < ((b.x-imageX0 - imageW/2) * (b.x-imageX0 - imageW/2) + (b.y-imageY0 - imageH/2) * (b.y-imageY0 - imageH/2)); } }; diff --git a/src/yafraycore/imagesplitter.cc b/src/yafraycore/imagesplitter.cc index 6f872078..68e62fcf 100644 --- a/src/yafraycore/imagesplitter.cc +++ b/src/yafraycore/imagesplitter.cc @@ -34,7 +34,7 @@ imageSpliter_t::imageSpliter_t(int w, int h, int x0,int y0, int bsize, tilesOrde { case RANDOM: std::random_shuffle( regions_raw.begin(), regions_raw.end() ); case CENTRE_RANDOM: std::random_shuffle( regions.begin(), regions.end() ); - std::sort( regions.begin(), regions.end(), imageSpliterCentreSorter_t(w, h) ); + std::sort( regions.begin(), regions.end(), imageSpliterCentreSorter_t(w, h, x0, y0) ); case LINEAR: break; default: break; } @@ -75,9 +75,9 @@ imageSpliter_t::imageSpliter_t(int w, int h, int x0,int y0, int bsize, tilesOrde std::random_shuffle( regions_subdivided.begin(), regions_subdivided.end() ); break; case CENTRE_RANDOM: std::random_shuffle( regions.begin(), regions.end() ); - std::sort( regions.begin(), regions.end(), imageSpliterCentreSorter_t(w, h) ); + std::sort( regions.begin(), regions.end(), imageSpliterCentreSorter_t(w, h, x0, y0) ); std::random_shuffle( regions_subdivided.begin(), regions_subdivided.end() ); - std::sort( regions_subdivided.begin(), regions_subdivided.end(), imageSpliterCentreSorter_t(w, h) ); + std::sort( regions_subdivided.begin(), regions_subdivided.end(), imageSpliterCentreSorter_t(w, h, x0, y0) ); break; case LINEAR: break; default: break; From 6ba26cd7aff374e3abd4e3b3b2c835d478db894e Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sat, 7 May 2016 08:32:32 +0100 Subject: [PATCH 035/124] Minor optimization when Dark Threshold Factor is 0.f --- src/yafraycore/imagefilm.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/yafraycore/imagefilm.cc b/src/yafraycore/imagefilm.cc index 1094ff89..ff556571 100644 --- a/src/yafraycore/imagefilm.cc +++ b/src/yafraycore/imagefilm.cc @@ -264,7 +264,7 @@ int imageFilm_t::nextPass(int numView, bool adaptive_AA, std::string integratorN colorA_t pixCol = (*imagePasses.at(0))(x, y).normalized(); float pixColBri = pixCol.abscol2bri(); - if(AA_dark_detection_type == DARK_DETECTION_LINEAR) + if(AA_dark_detection_type == DARK_DETECTION_LINEAR && AA_dark_threshold_factor > 0.f) { if(AA_dark_threshold_factor > 0.f) AA_thresh_scaled = AA_thesh*((1.f-AA_dark_threshold_factor) + (pixColBri*AA_dark_threshold_factor)); } From e14731fbc4132d89a5c7a592e597000eb2981d72 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sat, 7 May 2016 21:04:11 +0100 Subject: [PATCH 036/124] Badge/Logs: add Render Information to TXT/HTML header lines (version, resolution, render times, etc) --- include/core_api/logging.h | 2 ++ src/yafraycore/imagefilm.cc | 1 + src/yafraycore/logging.cc | 8 ++++---- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/include/core_api/logging.h b/include/core_api/logging.h index cc783571..a0f7016e 100644 --- a/include/core_api/logging.h +++ b/include/core_api/logging.h @@ -94,6 +94,7 @@ class YAFRAYCORE_EXPORT yafarayLog_t void setImagePath(const std::string &path) { mImagePath = path; } void appendAANoiseSettings(const std::string &aa_noise_settings); void appendRenderSettings(const std::string &render_settings); + void setRenderInfo(const std::string &render_info) { mRenderInfo = render_info; } void setDrawAANoiseSettings(bool draw_noise_settings) { drawAANoiseSettings = draw_noise_settings; } void setDrawRenderSettings(bool draw_render_settings) { drawRenderSettings = draw_render_settings; } @@ -164,6 +165,7 @@ class YAFRAYCORE_EXPORT yafarayLog_t std::string mLoggingCustomIcon; std::string mAANoiseSettings; std::string mRenderSettings; + std::string mRenderInfo; bool drawAANoiseSettings = true; bool drawRenderSettings = true; std::time_t previousConsoleEventDateTime = 0; diff --git a/src/yafraycore/imagefilm.cc b/src/yafraycore/imagefilm.cc index ff556571..23db7fff 100644 --- a/src/yafraycore/imagefilm.cc +++ b/src/yafraycore/imagefilm.cc @@ -542,6 +542,7 @@ void imageFilm_t::flush(int numView, int flags, colorOutput_t *out) std::stringstream ssLog; ssLog << ssBadge.str(); + yafLog.setRenderInfo(ssBadge.str()); if(yafLog.getDrawRenderSettings()) ssBadge << " | " << yafLog.getRenderSettings(); if(yafLog.getDrawAANoiseSettings()) ssBadge << "\n" << yafLog.getAANoiseSettings(); diff --git a/src/yafraycore/logging.cc b/src/yafraycore/logging.cc index c3633f40..a192f4e4 100644 --- a/src/yafraycore/logging.cc +++ b/src/yafraycore/logging.cc @@ -57,8 +57,8 @@ void yafarayLog_t::saveTxtLog(const std::string &name) if(!mLoggingContact.empty()) txtLogFile << "Contact: \"" << mLoggingContact << "\"" << std::endl; if(!mLoggingComments.empty()) txtLogFile << "Comments: \"" << mLoggingComments << "\"" << std::endl; - txtLogFile << std::endl << "Render Settings:" << std::endl << " " << mRenderSettings << std::endl; - txtLogFile << std::endl << "AA and Noise Control Settings:" << std::endl << " " << mAANoiseSettings << std::endl; + txtLogFile << std::endl << "Render Information:" << std::endl << " " << mRenderInfo << std::endl << " " << mRenderSettings << std::endl; + txtLogFile << std::endl << "AA/Noise Control Settings:" << std::endl << " " << mAANoiseSettings << std::endl; if(!m_MemoryLog.empty()) { @@ -151,8 +151,8 @@ void yafarayLog_t::saveHtmlLog(const std::string &name) htmlLogFile << "
DateTimeDur.VerbosityDescription
" << printDate(it->eventDateTime) << "" << printTime(it->eventDateTime) << "
" << printDate(it->eventDateTime) << "" << printTime(it->eventDateTime) << "" << printDuration(it->eventDuration) << "
" << std::endl; htmlLogFile << "

" << std::endl; - htmlLogFile << "" << std::endl; - htmlLogFile << "" << std::endl; + htmlLogFile << "" << std::endl; + htmlLogFile << "" << std::endl; htmlLogFile << "
Render Settings:" << mRenderSettings << "
AA and Noise Control Settings:" << mAANoiseSettings << "
Render Information:

" << mRenderInfo << "

" << mRenderSettings <<"

AA/Noise Control Settings:" << mAANoiseSettings << "
" << std::endl; if(!m_MemoryLog.empty()) From 56d691f9db2f29601e4a7c9f88175ff6fe23f4b2 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sat, 7 May 2016 22:22:35 +0100 Subject: [PATCH 037/124] Version change to ALPHA2 --- include/yafray_constants.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/yafray_constants.h b/include/yafray_constants.h index f3a93f44..fe8adc05 100644 --- a/include/yafray_constants.h +++ b/include/yafray_constants.h @@ -5,7 +5,7 @@ #define __END_YAFRAY } #define PACKAGE "YafaRay" -#define VERSION "3.0.0-ALPHA1" +#define VERSION "3.0.0-ALPHA2" #if (__GNUC__ > 3) #define GCC_HASCLASSVISIBILITY From a91955b15175f730de59bb56e9ab0a596cc63272 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sat, 14 May 2016 16:22:09 +0100 Subject: [PATCH 038/124] New AutoSave function (end of pass or time interval), with improved progress badge. Removed option -pst in yafaray-xml, now via parameter. Allow CTRL+C in yafaray-xml with correct image saving. Moved interactive from film to session. SPPM progress bar and tags fixed. --- include/core_api/imagefilm.h | 9 ++- include/core_api/session.h | 37 ++++++++- include/interface/yafrayinterface.h | 1 + include/utilities/math_utils.h | 6 ++ include/yafraycore/monitor.h | 23 ++++-- include/yafraycore/timer.h | 1 + src/bindings/yafaray_v3_interface.i | 27 ++++++- src/image_handlers/exrHandler.cc | 7 +- src/image_handlers/hdrHandler.cc | 5 +- src/image_handlers/jpgHandler.cc | 7 +- src/image_handlers/pngHandler.cc | 4 +- src/image_handlers/tgaHandler.cc | 4 +- src/image_handlers/tifHandler.cc | 4 +- src/integrators/sppm.cc | 64 +++++++++++---- src/interface/yafrayinterface.cc | 16 +++- src/xml_loader/xml-loader.cc | 39 +++++++-- src/yafraycore/console.cc | 21 +++-- src/yafraycore/environment.cc | 35 +++++--- src/yafraycore/imageOutput.cc | 48 ++++++++--- src/yafraycore/imagefilm.cc | 115 ++++++++++++++++++++------- src/yafraycore/integrator.cc | 23 +++++- src/yafraycore/session.cc | 119 ++++++++++++++++++++++++++++ src/yafraycore/timer.cc | 18 +++++ 23 files changed, 525 insertions(+), 108 deletions(-) diff --git a/include/core_api/imagefilm.h b/include/core_api/imagefilm.h index 3598b714..d0d5e114 100644 --- a/include/core_api/imagefilm.h +++ b/include/core_api/imagefilm.h @@ -116,10 +116,9 @@ class YAFRAYCORE_EXPORT imageFilm_t void setPremult2(bool premult); /*! Sets the adaptative AA sampling threshold */ void setAAThreshold(CFLOAT thresh){ AA_thesh=thresh; } - /*! Enables interactive color buffer output for preview during render */ - void setInteractive(bool ia){ interactive = ia; } /*! Enables partial image saving during render every time_interval seconds. Time=0.0 (default) disables partial saving. */ void setImageOutputPartialSaveTimeInterval(double time_interval){ imageOutputPartialSaveTimeInterval = time_interval; } + void setImageOutputPartialSaveEndPass(bool save_end_pass) { saveEndPass = save_end_pass; } /*! Sets a custom progress bar in the image film */ void setProgressBar(progressBar_t *pb); /*! The following methods set the strings used for the parameters badge rendering */ @@ -129,6 +128,9 @@ class YAFRAYCORE_EXPORT imageFilm_t void drawRenderSettings(std::stringstream & ss); void reset_accumulated_image_area_flush_time() { accumulated_image_area_flush_time = 0.0; } float dark_threshold_curve_interpolate(float pixel_brightness); + int getWidth() const { return w; } + int getHeight() const { return h; } + int getNumPasses() const { return nPasses; } #if HAVE_FREETYPE void drawFontBitmap( FT_Bitmap_* bitmap, int x, int y); @@ -159,7 +161,8 @@ class YAFRAYCORE_EXPORT imageFilm_t colorOutput_t *output; // Thread mutes for shared access std::mutex imageMutex, splitterMutex, outMutex, densityImageMutex; - bool split, interactive, abort; + bool split, abort; + bool saveEndPass; double imageOutputPartialSaveTimeInterval; bool estimateDensity; int numSamples; diff --git a/include/core_api/session.h b/include/core_api/session.h index 15540a7d..0a82f976 100644 --- a/include/core_api/session.h +++ b/include/core_api/session.h @@ -49,12 +49,43 @@ class YAFRAYCORE_EXPORT session_t { public: session_t(); + session_t(const session_t&); //customizing copy constructor so we can use a std::mutex as a class member (not copiable) ~session_t(); + + void setStatusRenderStarted(); + void setStatusRenderResumed(); + void setStatusRenderFinished(); + void setStatusRenderAborted(); + void setStatusTotalPasses(int total_passes); + void setStatusCurrentPass(int current_pass); + void setStatusCurrentPassPercent(float current_pass_percent); + void setInteractive(bool interactive); - photonMap_t * causticMap; - photonMap_t * diffuseMap; - photonMap_t * radianceMap; + bool renderInProgress(); + bool renderResumed(); + bool renderFinished(); + bool renderAborted(); + int totalPasses(); + int currentPass(); + float currentPassPercent(); + bool isInteractive(); + + photonMap_t * causticMap = nullptr; + photonMap_t * diffuseMap = nullptr; + photonMap_t * radianceMap = nullptr; + + std::mutex mutx; + + protected: + bool mRenderInProgress = false; + bool mRenderFinished = false; + bool mRenderResumed = false; + bool mRenderAborted = false; + int mTotalPasses = 0; + int mCurrentPass = 0; + float mCurrentPassPercent = 0.f; + bool mInteractive = false; }; extern YAFRAYCORE_EXPORT session_t session; diff --git a/include/interface/yafrayinterface.h b/include/interface/yafrayinterface.h index 22bfa947..befee809 100644 --- a/include/interface/yafrayinterface.h +++ b/include/interface/yafrayinterface.h @@ -87,6 +87,7 @@ class YAFRAYPLUGIN_EXPORT yafrayInterface_t virtual bool startScene(int type=0); //!< start a new scene; Must be called before any of the scene_t related callbacks! virtual bool setLoggingAndBadgeSettings(); virtual bool setupRenderPasses(); //!< setup render passes information + bool setInteractive(bool interactive); virtual void abort(); virtual paraMap_t* getRenderParameters() { return params; } virtual bool getRenderedImage(int numView, colorOutput_t &output); //!< put the rendered image to output diff --git a/include/utilities/math_utils.h b/include/utilities/math_utils.h index e0435173..c83058f3 100644 --- a/include/utilities/math_utils.h +++ b/include/utilities/math_utils.h @@ -50,4 +50,10 @@ inline int Ceil2Int(double val) { #endif } +inline double RoundFloatPrecision(double val, double precision) //To round, for example 3.2384764 to 3.24 use precision 0.01 +{ + if(precision <= 0.0) return 0.0; + else return std::round(val / precision) * precision; +} + #endif // Y_MATHUTIL_H diff --git a/include/yafraycore/monitor.h b/include/yafraycore/monitor.h index f54530c9..2019239d 100644 --- a/include/yafraycore/monitor.h +++ b/include/yafraycore/monitor.h @@ -11,13 +11,17 @@ class YAFRAYCORE_EXPORT progressBar_t public: virtual ~progressBar_t(){} //! initialize (or reset) the monitor, give the total number of steps that can occur - virtual void init(int total_area = 100) = 0; + virtual void init(int totalSteps = 100) = 0; //! update the montior, increment by given number of steps; init has to be called before the first update. - virtual void update(int added_area = 1) = 0; + virtual void update(int steps = 1) = 0; //! finish progress bar. It could output some summary, simply disappear from GUI or whatever... virtual void done() = 0; //! method to pass some informative text to the progress bar in case needed virtual void setTag(const char* text) = 0; + virtual void setTag(std::string text) = 0; + virtual std::string getTag() const = 0; + virtual float getPercent() const = 0; + virtual float getTotalSteps() const = 0; std::mutex mutx; }; @@ -27,16 +31,21 @@ class YAFRAYCORE_EXPORT ConsoleProgressBar_t : public progressBar_t { public: ConsoleProgressBar_t(int cwidth = 80); - virtual void init(int total_area); - virtual void update(int added_area); + virtual void init(int totalSteps); + virtual void update(int steps=1); virtual void done(); - virtual void setTag(const char* text) {}; + virtual void setTag(const char* text) { tag = std::string(text); }; + virtual void setTag(std::string text) { tag = text; }; + virtual std::string getTag() const { return tag; } + virtual float getPercent() const; + virtual float getTotalSteps() const { return nSteps; } protected: int width, totalBarLen; int lastBarLen; - int totalArea; - int doneArea; + int nSteps; + int doneSteps; + std::string tag; }; diff --git a/include/yafraycore/timer.h b/include/yafraycore/timer.h index f43d67b6..748c8976 100644 --- a/include/yafraycore/timer.h +++ b/include/yafraycore/timer.h @@ -22,6 +22,7 @@ class YAFRAYCORE_EXPORT timer_t bool stop(const std::string &name); bool reset(const std::string &name); double getTime(const std::string &name); + double getTimeNotStopping(const std::string &name); static void splitTime(double t, double *secs, int *mins=nullptr, int *hours=nullptr, int *days=nullptr); diff --git a/src/bindings/yafaray_v3_interface.i b/src/bindings/yafaray_v3_interface.i index 81e3c8bc..121a410c 100644 --- a/src/bindings/yafaray_v3_interface.i +++ b/src/bindings/yafaray_v3_interface.i @@ -464,7 +464,8 @@ public: virtual void init(int totalSteps) { - steps_to_percent = 1.f / (float) totalSteps; + nSteps = totalSteps; + steps_to_percent = 1.f / (float) nSteps; doneSteps = 0; report_progress(0.f); } @@ -482,6 +483,7 @@ public: virtual void setTag(const char* text) { + tag = std::string(text); PyGILState_STATE gstate; gstate = PyGILState_Ensure(); PyObject* result = PyObject_CallFunction(callb, "ss", "tag", text); @@ -490,11 +492,31 @@ public: PyGILState_Release(gstate); } + virtual void setTag(std::string text) + { + tag = text; + PyGILState_STATE gstate; + gstate = PyGILState_Ensure(); + PyObject* result = PyObject_CallFunction(callb, "ss", "tag", text.c_str()); + Py_XDECREF(result); + //std::cout << "setTag: result->ob_refcnt=" << result->ob_refcnt << std::endl; + PyGILState_Release(gstate); + } + + virtual std::string getTag() const + { + return tag; + } + + virtual float getPercent() const { return 100.f * std::min(1.f, (float) doneSteps * steps_to_percent); } + virtual float getTotalSteps() const { return nSteps; } + private: PyObject *callb; float steps_to_percent; - int doneSteps; + int doneSteps, nSteps; + std::string tag; }; %} @@ -722,6 +744,7 @@ namespace yafaray virtual bool startScene(int type=0); //!< start a new scene; Must be called before any of the scene_t related callbacks! virtual bool setLoggingAndBadgeSettings(); virtual bool setupRenderPasses(); //!< setup render passes information + bool setInteractive(bool interactive); virtual void abort(); virtual paraMap_t* getRenderParameters() { return params; } virtual bool getRenderedImage(int numView, colorOutput_t &output); //!< put the rendered image to output diff --git a/src/image_handlers/exrHandler.cc b/src/image_handlers/exrHandler.cc index 75c8bdd8..d42c901f 100644 --- a/src/image_handlers/exrHandler.cc +++ b/src/image_handlers/exrHandler.cc @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -96,7 +97,8 @@ exrHandler_t::~exrHandler_t() bool exrHandler_t::saveToFile(const std::string &name, int imagePassNumber) { - Y_INFO << handlerName << ": Saving RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << name << "\"..." << yendl; + if(session.renderInProgress()) Y_VERBOSE << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << name << "\"..." << yendl; + else Y_INFO << handlerName << ": Saving RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << name << "\"..." << yendl; int chan_size = sizeof(half); const int num_colchan = 4; @@ -141,7 +143,8 @@ bool exrHandler_t::saveToFileMultiChannel(const std::string &name, const renderP { std::string extPassName; - Y_INFO << handlerName << ": Saving Multilayer EXR" << " file as \"" << name << "\"..." << yendl; + if(session.renderInProgress()) Y_VERBOSE << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") Multilayer EXR" << " file as \"" << name << "\"..." << yendl; + else Y_INFO << handlerName << ": Saving Multilayer EXR" << " file as \"" << name << "\"..." << yendl; int chan_size = sizeof(half); const int num_colchan = 4; diff --git a/src/image_handlers/hdrHandler.cc b/src/image_handlers/hdrHandler.cc index a811e703..e4cbf418 100644 --- a/src/image_handlers/hdrHandler.cc +++ b/src/image_handlers/hdrHandler.cc @@ -25,10 +25,12 @@ #include #include #include +#include #include #include #include +#include #include "hdrUtils.h" @@ -451,7 +453,8 @@ bool hdrHandler_t::saveToFile(const std::string &name, int imagePassNumber) } else { - Y_INFO << handlerName << ": Saving RGBE file as \"" << name << "\"..." << yendl; + if(session.renderInProgress()) Y_VERBOSE << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") RGBE file as \"" << name << "\"..." << yendl; + else Y_INFO << handlerName << ": Saving RGBE file as \"" << name << "\"..." << yendl; if (m_hasAlpha) Y_VERBOSE << handlerName << ": Ignoring alpha channel." << yendl; writeHeader(file); diff --git a/src/image_handlers/jpgHandler.cc b/src/image_handlers/jpgHandler.cc index 9c836ee4..4e51532e 100644 --- a/src/image_handlers/jpgHandler.cc +++ b/src/image_handlers/jpgHandler.cc @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -140,7 +141,8 @@ colorA_t jpgHandler_t::getPixel(int x, int y, int imagePassNumber) bool jpgHandler_t::saveToFile(const std::string &name, int imagePassNumber) { - Y_INFO << handlerName << ": Saving RGB" << " file as \"" << name << "\"..." << yendl; + if(session.renderInProgress()) Y_VERBOSE << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") RGB" << " file as \"" << name << "\"..." << yendl; + else Y_INFO << handlerName << ": Saving RGB" << " file as \"" << name << "\"..." << yendl; FILE * fp; struct jpeg_compress_struct info; @@ -202,7 +204,8 @@ bool jpgHandler_t::saveToFile(const std::string &name, int imagePassNumber) if(m_hasAlpha) { std::string alphaname = name.substr(0, name.size() - 4) + "_alpha.jpg"; - Y_INFO << handlerName << ": Saving Alpha channel as \"" << alphaname << "\"..." << yendl; + if(session.renderInProgress()) Y_VERBOSE << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") Alpha channel as \"" << alphaname << "\"..." << yendl; + else Y_INFO << handlerName << ": Saving Alpha channel as \"" << alphaname << "\"..." << yendl; fp = fopen(alphaname.c_str(), "wb"); diff --git a/src/image_handlers/pngHandler.cc b/src/image_handlers/pngHandler.cc index ad935a36..ea3064cc 100644 --- a/src/image_handlers/pngHandler.cc +++ b/src/image_handlers/pngHandler.cc @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -128,7 +129,8 @@ colorA_t pngHandler_t::getPixel(int x, int y, int imagePassNumber) bool pngHandler_t::saveToFile(const std::string &name, int imagePassNumber) { - Y_INFO << handlerName << ": Saving RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << name << "\"..." << yendl; + if(session.renderInProgress()) Y_VERBOSE << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << name << "\"..." << yendl; + else Y_INFO << handlerName << ": Saving RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << name << "\"..." << yendl; FILE *fp; png_structp pngPtr; diff --git a/src/image_handlers/tgaHandler.cc b/src/image_handlers/tgaHandler.cc index 1c5721ae..737168e7 100644 --- a/src/image_handlers/tgaHandler.cc +++ b/src/image_handlers/tgaHandler.cc @@ -24,6 +24,7 @@ #include #include #include +#include #include "tgaUtils.h" @@ -129,7 +130,8 @@ tgaHandler_t::~tgaHandler_t() bool tgaHandler_t::saveToFile(const std::string &name, int imagePassNumber) { - Y_INFO << handlerName << ": Saving " << ((m_hasAlpha) ? "RGBA" : "RGB" ) << " file as \"" << name << "\"..." << yendl; + if(session.renderInProgress()) Y_VERBOSE << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") " << ((m_hasAlpha) ? "RGBA" : "RGB" ) << " file as \"" << name << "\"..." << yendl; + else Y_INFO << handlerName << ": Saving " << ((m_hasAlpha) ? "RGBA" : "RGB" ) << " file as \"" << name << "\"..." << yendl; std::string imageId = "Image rendered with YafaRay"; tgaHeader_t header; diff --git a/src/image_handlers/tifHandler.cc b/src/image_handlers/tifHandler.cc index f2b94d46..8e2e13ff 100644 --- a/src/image_handlers/tifHandler.cc +++ b/src/image_handlers/tifHandler.cc @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -116,7 +117,8 @@ colorA_t tifHandler_t::getPixel(int x, int y, int imagePassNumber) bool tifHandler_t::saveToFile(const std::string &name, int imagePassNumber) { - Y_INFO << handlerName << ": Saving RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << name << "\"..." << yendl; + if(session.renderInProgress()) Y_VERBOSE << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << name << "\"..." << yendl; + else Y_INFO << handlerName << ": Saving RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << name << "\"..." << yendl; TIFF *out = TIFFOpen(name.c_str(), "w"); int channels; diff --git a/src/integrators/sppm.cc b/src/integrators/sppm.cc index 0488e177..c997b3b4 100644 --- a/src/integrators/sppm.cc +++ b/src/integrators/sppm.cc @@ -48,6 +48,15 @@ bool SPPM::render(int numView, yafaray::imageFilm_t *image) std::stringstream passString; imageFilm = image; scene->getAAParameters(AA_samples, AA_passes, AA_inc_samples, AA_threshold, AA_resampled_floor, AA_sample_multiplier_factor, AA_light_sample_multiplier_factor, AA_indirect_sample_multiplier_factor, AA_detect_color_noise, AA_dark_detection_type, AA_dark_threshold_factor, AA_variance_edge_size, AA_variance_pixels, AA_clamp_samples, AA_clamp_indirect); + + std::stringstream aaSettings; + aaSettings << " passes=" << passNum << " samples=" << AA_samples << " inc_samples=" << AA_inc_samples; + aaSettings << " clamp=" << AA_clamp_samples << " ind.clamp=" << AA_clamp_indirect; + + yafLog.appendAANoiseSettings(aaSettings.str()); + + + session.setStatusTotalPasses(passNum); //passNum is total number of passes in SPPM AA_sample_multiplier = 1.f; AA_light_sample_multiplier = 1.f; @@ -56,17 +65,35 @@ bool SPPM::render(int numView, yafaray::imageFilm_t *image) Y_VERBOSE << integratorName << ": AA_clamp_samples: "<< AA_clamp_samples << yendl; Y_VERBOSE << integratorName << ": AA_clamp_indirect: "<< AA_clamp_indirect << yendl; + std::stringstream set; + + set << "SPPM "; + + if(trShad) + { + set << "ShadowDepth=" << sDepth << " "; + } + set << "RayDepth=" << rDepth << " "; + + yafLog.appendRenderSettings(set.str()); + Y_VERBOSE << set.str() << yendl; + + passString << "Rendering pass 1 of " << std::max(1, passNum) << "..."; Y_INFO << integratorName << ": " << passString.str() << yendl; if(intpb) intpb->setTag(passString.str().c_str()); gTimer.addEvent("rendert"); gTimer.start("rendert"); + + imageFilm->reset_accumulated_image_area_flush_time(); + gTimer.addEvent("image_area_flush"); + imageFilm->init(passNum); imageFilm->setAANoiseParams(AA_detect_color_noise, AA_dark_detection_type, AA_dark_threshold_factor, AA_variance_edge_size, AA_variance_pixels, AA_clamp_samples); const camera_t* camera = scene->getCamera(); - + maxDepth = 0.f; minDepth = 1e38f; @@ -95,28 +122,21 @@ bool SPPM::render(int numView, yafaray::imageFilm_t *image) } maxDepth = 0.f; gTimer.stop("rendert"); + session.setStatusRenderFinished(); Y_INFO << integratorName << ": Overall rendertime: "<< gTimer.getTime("rendert") << "s." << yendl; // Integrator Settings for "drawRenderSettings()" in imageFilm, SPPM has own render method, so "getSettings()" // in integrator.h has no effect and Integrator settings won't be printed to the parameter badge. - - std::stringstream set; - set << "SPPM "; - - if(trShad) - { - set << "ShadowDepth=" << sDepth << " "; - } - set << "RayDepth=" << rDepth << " "; - + set.clear(); + set << "Passes rendered: " << passInfo << " "; set << "\nPhotons=" << nPhotons << " search=" << nSearch <<" radius=" << dsRadius << "(init.estim=" << initialEstimate << ") total photons=" << totalnPhotons << " "; yafLog.appendRenderSettings(set.str()); Y_VERBOSE << set.str() << yendl; - + return true; } @@ -568,9 +588,17 @@ void SPPM::prePass(int samples, int offset, bool adaptive) unsigned char userdata[USER_DATA_SIZE+7]; state.userdata = (void *)( &userdata[7] - ( ((size_t)&userdata[7])&7 ) ); // pad userdata to 8 bytes state.cam = scene->getCamera(); + progressBar_t *pb; + std::string previousProgressTag; + int previousProgressTotalSteps = 0; int pbStep; - if(intpb) pb = intpb; + if(intpb) + { + pb = intpb; + previousProgressTag = pb->getTag(); + previousProgressTotalSteps = pb->getTotalSteps(); + } else pb = new ConsoleProgressBar_t(80); if(bHashgrid) Y_INFO << integratorName << ": Building photon hashgrid..." << yendl; @@ -578,7 +606,7 @@ void SPPM::prePass(int samples, int offset, bool adaptive) pb->init(128); pbStep = std::max(1U, nPhotons/128); - //pb->setTag("Building photon map..."); + pb->setTag(previousProgressTag + " - building photon map..."); int nThreads = scene->getNumThreadsPhotons(); @@ -725,7 +753,7 @@ void SPPM::prePass(int samples, int offset, bool adaptive) } pb->done(); - //pb->setTag("Photon map built."); + pb->setTag(previousProgressTag + " - photon map built."); Y_VERBOSE << integratorName << ":Photon map built." << yendl; Y_INFO << integratorName << ": Shot " << curr << " photons from " << numDLights << " light(s)" << yendl; delete lightPowerD; @@ -772,6 +800,12 @@ void SPPM::prePass(int samples, int offset, bool adaptive) else Y_INFO << integratorName << ": PhotonMap building time: " << gTimer.getTime("prepass") << yendl; + if(intpb) + { + intpb->setTag(previousProgressTag); + intpb->init(previousProgressTotalSteps); + } + return; } diff --git a/src/interface/yafrayinterface.cc b/src/interface/yafrayinterface.cc index 8f743610..6683ad36 100644 --- a/src/interface/yafrayinterface.cc +++ b/src/interface/yafrayinterface.cc @@ -85,6 +85,12 @@ bool yafrayInterface_t::setupRenderPasses() return true; } +bool yafrayInterface_t::setInteractive(bool interactive) +{ + session.setInteractive(interactive); + return true; +} + bool yafrayInterface_t::startGeometry() { return scene->startGeometry(); } bool yafrayInterface_t::endGeometry() { return scene->endGeometry(); } @@ -288,7 +294,7 @@ VolumeRegion* yafrayInterface_t::createVolumeRegion(const char* name) return nullptr; } -unsigned int yafrayInterface_t::createObject (const char* name) +unsigned int yafrayInterface_t::createObject(const char* name) { object3d_t *object = env->createObject(name, *params); if(!object) return 0; @@ -297,7 +303,12 @@ unsigned int yafrayInterface_t::createObject (const char* name) return 0; } -void yafrayInterface_t::abort(){ if(scene) scene->abort(); } +void yafrayInterface_t::abort() +{ + if(scene) scene->abort(); + session.setStatusRenderAborted(); + Y_WARNING << "Interface: Render aborted by user." << yendl; +} bool yafrayInterface_t::getRenderedImage(int numView, colorOutput_t &output) { @@ -368,6 +379,7 @@ void yafrayInterface_t::printError(const std::string &msg) void yafrayInterface_t::render(colorOutput_t &output, progressBar_t *pb) { if(! env->setupScene(*scene, *params, output, pb) ) return; + session.setStatusRenderStarted(); scene->render(); film = scene->getImageFilm(); //delete film; diff --git a/src/xml_loader/xml-loader.cc b/src/xml_loader/xml-loader.cc index b67bfea0..17ab4258 100644 --- a/src/xml_loader/xml-loader.cc +++ b/src/xml_loader/xml-loader.cc @@ -2,6 +2,7 @@ #include #include #include +#include #ifdef WIN32 #include @@ -18,8 +19,33 @@ using namespace::yafaray; +scene_t *globalScene = nullptr; + +void ctrl_c_handler(int signal) +{ + if(globalScene) + { + globalScene->abort(); + session.setStatusRenderAborted(); + Y_WARNING << "Interface: Render aborted by user." << yendl; + } + else + { + session.setStatusRenderAborted(); + Y_WARNING << "Interface: Render aborted by user." << yendl; + exit(1); + } +} + int main(int argc, char *argv[]) { + //handle CTRL+C events + struct sigaction signalHandler; + signalHandler.sa_handler = ctrl_c_handler; + sigemptyset(&signalHandler.sa_mask); + signalHandler.sa_flags = 0; + sigaction(SIGINT, &signalHandler, nullptr); + std::string xmlLoaderVersion = "YafaRay XML loader version: " + std::string(VERSION); cliParser_t parse(argc, argv, 2, 1, "You need to set at least a yafaray's valid XML file."); @@ -86,7 +112,6 @@ int main(int argc, char *argv[]) parse.setOption("l","log-file-output", false, "Enable log file output(s): \"none\", \"txt\", \"html\" or \"txt+html\". Log file name will be same as selected image name,"); parse.setOption("z","z-buffer", true, "Enables the rendering of the depth map (Z-Buffer) (this flag overrides XML setting)."); parse.setOption("nz","no-z-buffer", true, "Disables the rendering of the depth map (Z-Buffer) (this flag overrides XML setting)."); - parse.setOption("pst","partial-save-timer", false, "Sets timer in seconds for partial saving of images during render. If set to 0 (default) it will disable this feature. IMPORTANT: the more frequently partial images are saved, the slower the render will be."); bool parseOk = parse.parseCommandLine(); @@ -120,7 +145,6 @@ int main(int argc, char *argv[]) int threads = parse.getOptionInteger("t"); bool zbuf = parse.getFlag("z"); bool nozbuf = parse.getFlag("nz"); - int partial_save_timer = parse.getOptionInteger("pst"); if(format.empty()) format = "tga"; bool formatValid = false; @@ -164,6 +188,9 @@ int main(int argc, char *argv[]) } scene_t *scene = new scene_t(env); + + globalScene = scene; //for the CTRL+C handler + env->setScene(scene); paraMap_t render; @@ -235,13 +262,11 @@ int main(int argc, char *argv[]) else return 1; if(! env->setupScene(*scene, render, *out) ) return 1; - imageFilm_t *film = scene->getImageFilm(); - film->setInteractive(false); - film->setImageOutputPartialSaveTimeInterval((double) partial_save_timer); - - + session.setInteractive(false); + session.setStatusRenderStarted(); scene->render(); + env->clearAll(); delete film; diff --git a/src/yafraycore/console.cc b/src/yafraycore/console.cc index d4f586dc..3bc963ee 100644 --- a/src/yafraycore/console.cc +++ b/src/yafraycore/console.cc @@ -1,5 +1,6 @@ #include +#include #include #include #include @@ -14,23 +15,23 @@ std::cout << "\r" << setColor(Green) << "Progress: " << \ setColor(Red, true) << "[" << setColor(Green, true) << std::string(progFull, '#') << std::string(progEmpty, ' ') << setColor(Red, true) << "] " << \ setColor() << "(" << setColor(Yellow, true) << per << "%" << setColor() << ")" << std::flush -ConsoleProgressBar_t::ConsoleProgressBar_t(int cwidth): width(cwidth), totalArea(0), doneArea(0) +ConsoleProgressBar_t::ConsoleProgressBar_t(int cwidth): width(cwidth), nSteps(0), doneSteps(0) { totalBarLen = width - 22; } -void ConsoleProgressBar_t::init(int total_area) +void ConsoleProgressBar_t::init(int totalSteps) { - totalArea=total_area; - doneArea = 0; + nSteps=totalSteps; + doneSteps = 0; lastBarLen = 0; printBar(totalBarLen, 0, 0); } -void ConsoleProgressBar_t::update(int added_area) +void ConsoleProgressBar_t::update(int steps) { - doneArea += added_area; - float progress = (float) std::min(doneArea, totalArea) / (float) totalArea; + doneSteps += steps; + float progress = (float) std::min(doneSteps, nSteps) / (float) nSteps; int barLen = std::min(totalBarLen, (int)(totalBarLen*progress)); if(!(barLen >= 0)) barLen = 0; if(barLen > lastBarLen) @@ -45,4 +46,10 @@ void ConsoleProgressBar_t::done() printBar(0, totalBarLen, 100) << yendl; } +float ConsoleProgressBar_t::getPercent() const +{ + float progress = 100.f * RoundFloatPrecision((float) std::min(doneSteps, nSteps) / (float) nSteps, 0.01); + return progress; +} + __END_YAFRAY diff --git a/src/yafraycore/environment.cc b/src/yafraycore/environment.cc index 102429e1..5fbf3124 100644 --- a/src/yafraycore/environment.cc +++ b/src/yafraycore/environment.cc @@ -567,6 +567,8 @@ imageFilm_t* renderEnvironment_t::createImageFilm(const paraMap_t ¶ms, color int tileSize = 32; bool premult = false; bool premult2 = false; + float partial_save_timer = 0.f; + bool partial_save_each_pass = false; params.getParam("color_space", color_space_string); params.getParam("gamma", gamma); @@ -583,7 +585,9 @@ imageFilm_t* renderEnvironment_t::createImageFilm(const paraMap_t ¶ms, color params.getParam("tiles_order", tiles_order); // Order of the render buckets or tiles params.getParam("premult", premult); // Premultipy Alpha channel for better alpha antialiasing against bg params.getParam("premult2", premult2); // Premultipy Alpha channel for better alpha antialiasing against bg, for the optional secondary output - + params.getParam("partial_save_timer", partial_save_timer); // Time for partially save image + params.getParam("partial_save_each_pass", partial_save_each_pass); // If enabled, it will autosave the image at the end of each pass + if(color_space_string == "sRGB") color_space = SRGB; else if(color_space_string == "XYZ") color_space = XYZ_D65; else if(color_space_string == "LinearRGB") color_space = LINEAR_RGB; @@ -635,6 +639,19 @@ imageFilm_t* renderEnvironment_t::createImageFilm(const paraMap_t ¶ms, color film->setPremult2(premult2); + if(partial_save_each_pass) + { + Y_INFO_ENV << "Autosave partially rendered image at the end of each pass" << yendl; + film->setImageOutputPartialSaveTimeInterval(0.0); + film->setImageOutputPartialSaveEndPass(true); + } + else + { + Y_INFO_ENV << "Autosave partially rendered image using time interval = " << partial_save_timer << "s" << yendl; + if(partial_save_timer > 0.f) film->setImageOutputPartialSaveTimeInterval((double) partial_save_timer); + film->setImageOutputPartialSaveEndPass(false); + } + return film; } @@ -758,8 +775,7 @@ bool renderEnvironment_t::setupScene(scene_t &scene, const paraMap_t ¶ms, co bool adv_auto_shadow_bias_enabled=true; float adv_shadow_bias_value=YAF_SHADOW_BIAS; bool adv_auto_min_raydist_enabled=true; - float adv_min_raydist_value=MIN_RAYDIST; - std::stringstream aaSettings; + float adv_min_raydist_value=MIN_RAYDIST; if(! params.getParam("camera_name", name) ) { @@ -838,19 +854,14 @@ bool renderEnvironment_t::setupScene(scene_t &scene, const paraMap_t ¶ms, co params.getParam("filter_type", name); // AA filter type + std::stringstream aaSettings; + aaSettings << "AA Settings (" << ((name)?*name:"box") << "):"; + yafLog.appendAANoiseSettings(aaSettings.str()); + if(AA_dark_detection_type_string == "linear") AA_dark_detection_type = DARK_DETECTION_LINEAR; else if(AA_dark_detection_type_string == "curve") AA_dark_detection_type = DARK_DETECTION_CURVE; else AA_dark_detection_type = DARK_DETECTION_NONE; - aaSettings << "AA Settings (" << ((name)?*name:"box") << "): passes=" << AA_passes << " samples=" << AA_samples << " inc_samples=" << AA_inc_samples << " resamp.floor=" << AA_resampled_floor << "\nsample.mul=" << AA_sample_multiplier_factor << " light.sam.mul=" << AA_light_sample_multiplier_factor << " ind.sam.mul=" << AA_indirect_sample_multiplier_factor << "\ncol.noise=" << AA_detect_color_noise; - - if(AA_dark_detection_type == DARK_DETECTION_LINEAR) aaSettings << " dark.thr(lin),fac=" << AA_dark_threshold_factor; - else if(AA_dark_detection_type == DARK_DETECTION_CURVE) aaSettings << " dark.thr(curve)"; - - aaSettings << " var.edge=" << AA_variance_edge_size << " var.pix=" << AA_variance_pixels << " clamp=" << AA_clamp_samples << " ind.clamp=" << AA_clamp_indirect; - - yafLog.appendAANoiseSettings(aaSettings.str()); - //setup scene and render. scene.setImageFilm(film); scene.setSurfIntegrator((surfaceIntegrator_t*)inte); diff --git a/src/yafraycore/imageOutput.cc b/src/yafraycore/imageOutput.cc index 8f6624ca..37e3e72d 100644 --- a/src/yafraycore/imageOutput.cc +++ b/src/yafraycore/imageOutput.cc @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -89,11 +90,18 @@ void imageOutput_t::flush(int numView, const renderPasses_t *renderPasses) { if(image->isMultiLayer()) { - if(numView == 0) image->saveToFile(fname, 0); //This should not be necessary but Blender API seems to be limited and the API "load_from_file" function does not work (yet) with multilayer EXR, so I have to generate this extra combined pass file so it's displayed in the Blender window. + if(numView == 0) + { + image->saveToFile(fname+".tmp", 0); //This should not be necessary but Blender API seems to be limited and the API "load_from_file" function does not work (yet) with multilayer EXR, so I have to generate this extra combined pass file so it's displayed in the Blender window. + boost::filesystem::copy_file(fname+".tmp", fname, boost::filesystem::copy_option::overwrite_if_exists); + boost::filesystem::remove(fname+".tmp"); + } fnamePass = path + base_name + " [" + "multilayer" + "]"+ ext; - image->saveToFileMultiChannel(fnamePass, renderPasses); + image->saveToFileMultiChannel(fnamePass+".tmp", renderPasses); + boost::filesystem::copy_file(fnamePass+".tmp", fnamePass, boost::filesystem::copy_option::overwrite_if_exists); + boost::filesystem::remove(fnamePass+".tmp"); yafLog.setImagePath(fnamePass); //to show the image in the HTML log output } else @@ -104,27 +112,45 @@ void imageOutput_t::flush(int numView, const renderPasses_t *renderPasses) if(numView == 0 && idx == 0) { - image->saveToFile(fname, idx); //default image filename, when not using views nor passes and for reloading into Blender + image->saveToFile(fname+".tmp", idx); //default image filename, when not using views nor passes and for reloading into Blender + boost::filesystem::copy_file(fname+".tmp", fname, boost::filesystem::copy_option::overwrite_if_exists); + boost::filesystem::remove(fname+".tmp"); yafLog.setImagePath(fname); //to show the image in the HTML log output } if(passName != "not found" && (renderPasses->extPassesSize()>=2 || renderPasses->view_names.size() >= 2)) { fnamePass = path + base_name + " [pass " + passName + "]"+ ext; - image->saveToFile(fnamePass, idx); + image->saveToFile(fnamePass+".tmp", idx); + boost::filesystem::copy_file(fnamePass+".tmp", fnamePass, boost::filesystem::copy_option::overwrite_if_exists); + boost::filesystem::remove(fnamePass+".tmp"); if(idx == 0) yafLog.setImagePath(fnamePass); //to show the image in the HTML log output } } } } - std::string fLogName = path + base_name + "_log.txt"; - yafLog.saveTxtLog(fLogName); - - std::string fLogHtmlName = path + base_name + "_log.html"; - yafLog.saveHtmlLog(fLogHtmlName); - - yafLog.clearMemoryLog(); + try + { + std::string fLogName = path + base_name + "_log.txt"; + yafLog.saveTxtLog(fLogName+".tmp"); + boost::filesystem::copy_file(fLogName+".tmp",fLogName,boost::filesystem::copy_option::overwrite_if_exists); + boost::filesystem::remove(fLogName+".tmp"); + } + catch(const boost::filesystem::filesystem_error& e) + { + } + + try + { + std::string fLogHtmlName = path + base_name + "_log.html"; + yafLog.saveHtmlLog(fLogHtmlName+".tmp"); + boost::filesystem::copy_file(fLogHtmlName+".tmp",fLogHtmlName,boost::filesystem::copy_option::overwrite_if_exists); + boost::filesystem::remove(fLogHtmlName+".tmp"); + } + catch(const boost::filesystem::filesystem_error& e) + { + } } __END_YAFRAY diff --git a/src/yafraycore/imagefilm.cc b/src/yafraycore/imagefilm.cc index 23db7fff..83df2a1d 100644 --- a/src/yafraycore/imagefilm.cc +++ b/src/yafraycore/imagefilm.cc @@ -122,7 +122,7 @@ imageFilm_t::imageFilm_t (int width, int height, int xstart, int ystart, colorOu renderEnvironment_t *e, bool showSamMask, int tSize, imageSpliter_t::tilesOrderType tOrder, bool pmA): flags(0), w(width), h(height), cx0(xstart), cy0(ystart), colorSpace(RAW_MANUAL_GAMMA), gamma(1.0), colorSpace2(RAW_MANUAL_GAMMA), gamma2(1.0), filterw(filterSize*0.5), output(&out), - split(true), interactive(true), abort(false), imageOutputPartialSaveTimeInterval(0.0), splitter(nullptr), pbar(nullptr), + split(true), abort(false), saveEndPass(false), imageOutputPartialSaveTimeInterval(0.0), splitter(nullptr), pbar(nullptr), env(e), showMask(showSamMask), tileSize(tSize), tilesOrder(tOrder), premultAlpha(pmA), premultAlpha2(false) { cx1 = xstart + width; @@ -168,6 +168,7 @@ imageFilm_t::imageFilm_t (int width, int height, int xstart, int ystart, colorOu area_cnt = 0; pbar = new ConsoleProgressBar_t(80); + session.setStatusCurrentPassPercent(pbar->getPercent()); AA_detect_color_noise = false; AA_dark_threshold_factor = 0.f; @@ -221,6 +222,7 @@ void imageFilm_t::init(int numPasses) else area_cnt = 1; if(pbar) pbar->init(w * h); + session.setStatusCurrentPassPercent(pbar->getPercent()); abort = false; completed_cnt = 0; @@ -235,6 +237,24 @@ int imageFilm_t::nextPass(int numView, bool adaptive_AA, std::string integratorN splitterMutex.unlock(); nPass++; std::stringstream passString; + + if(session.isInteractive()) + { + colorOutput_t *out2 = env->getOutput2(); + + if(out2 && saveEndPass && session.renderInProgress()) + { + this->flush(numView, IF_ALL, out2); + } + } + else + { + if(output && saveEndPass && session.renderInProgress()) + { + this->flush(numView, IF_ALL, output); + } + } + if(flags) flags->clear(); else flags = new tiledBitArray2D_t<3>(w, h, true); @@ -350,7 +370,7 @@ int imageFilm_t::nextPass(int numView, bool adaptive_AA, std::string integratorN { ++n_resample; - if(interactive && showMask) + if(session.isInteractive() && showMask) { for(size_t idx = 0; idx < imagePasses.size(); ++idx) { @@ -373,8 +393,7 @@ int imageFilm_t::nextPass(int numView, bool adaptive_AA, std::string integratorN n_resample = h*w; } - //if(interactive) //FIXME DAVID, SHOULD I PUT THIS BACK?, TEST WITH BLENDER AND XML+MULTILAYER - output->flush(numView, env->getRenderPasses()); + if(session.isInteractive()) output->flush(numView, env->getRenderPasses()); passString << "Rendering pass " << nPass << " of " << nPasses << ", resampling " << n_resample << " pixels."; @@ -383,6 +402,7 @@ int imageFilm_t::nextPass(int numView, bool adaptive_AA, std::string integratorN if(pbar) { pbar->init(w * h); + session.setStatusCurrentPassPercent(pbar->getPercent()); pbar->setTag(passString.str().c_str()); } completed_cnt = 0; @@ -410,7 +430,7 @@ bool imageFilm_t::nextArea(int numView, renderArea_t &a) a.sy0 = a.Y + ifilterw; a.sy1 = a.Y + a.H - ifilterw; - if(interactive) + if(session.isInteractive()) { outMutex.lock(); int end_x = a.X+a.W, end_y = a.Y+a.H; @@ -472,17 +492,33 @@ void imageFilm_t::finishArea(int numView, renderArea_t &a) } } - if(interactive) output->flushArea(numView, a.X, a.Y, end_x+cx0, end_y+cy0, env->getRenderPasses()); + if(session.isInteractive()) + { + output->flushArea(numView, a.X, a.Y, end_x+cx0, end_y+cy0, env->getRenderPasses()); + gTimer.stop("image_area_flush"); + accumulated_image_area_flush_time += gTimer.getTime("image_area_flush"); + if(accumulated_image_area_flush_time < 0.f) reset_accumulated_image_area_flush_time(); //to solve some strange very negative value when using yafaray-xml, race condition somewhere? + gTimer.start("image_area_flush"); + + colorOutput_t *out2 = env->getOutput2(); + + if(out2 && session.renderInProgress() && ((imageOutputPartialSaveTimeInterval > 0.f) && ((accumulated_image_area_flush_time > imageOutputPartialSaveTimeInterval) ||accumulated_image_area_flush_time == 0.0))) + { + this->flush(numView, IF_ALL, out2); + reset_accumulated_image_area_flush_time(); + } + } else { gTimer.stop("image_area_flush"); accumulated_image_area_flush_time += gTimer.getTime("image_area_flush"); + if(accumulated_image_area_flush_time < 0.f) reset_accumulated_image_area_flush_time(); //to solve some strange very negative value when using yafaray-xml, race condition somewhere? gTimer.start("image_area_flush"); - - if((imageOutputPartialSaveTimeInterval > 0.f) && ((accumulated_image_area_flush_time > imageOutputPartialSaveTimeInterval) ||accumulated_image_area_flush_time == 0.0)) + + if(session.renderInProgress() && (imageOutputPartialSaveTimeInterval > 0.f) && ((accumulated_image_area_flush_time > imageOutputPartialSaveTimeInterval) ||accumulated_image_area_flush_time == 0.0)) { - output->flush(numView, env->getRenderPasses()); + this->flush(numView, IF_ALL, output); reset_accumulated_image_area_flush_time(); } } @@ -491,6 +527,7 @@ void imageFilm_t::finishArea(int numView, renderArea_t &a) { if(++completed_cnt == area_cnt) pbar->done(); else pbar->update(a.W * a.H); + session.setStatusCurrentPassPercent(pbar->getPercent()); } outMutex.unlock(); @@ -498,12 +535,16 @@ void imageFilm_t::finishArea(int numView, renderArea_t &a) void imageFilm_t::flush(int numView, int flags, colorOutput_t *out) { - outMutex.lock(); - - Y_INFO << "imageFilm: Flushing buffer (View number " << numView << ")..." << yendl; + if(session.renderFinished()) + { + outMutex.lock(); + Y_INFO << "imageFilm: Flushing buffer (View number " << numView << ")..." << yendl; + } - colorOutput_t *colout = out ? out : output; + colorOutput_t *out1 = out ? out : output; colorOutput_t *out2 = env->getOutput2(); + + if(out1 == out2) out1 = nullptr; //if we are already flushing the secondary output (out2) as main output (out1), then disable out1 to avoid duplicated work #ifdef RELEASE std::string version = std::string(VERSION); @@ -522,10 +563,14 @@ void imageFilm_t::flush(int numView, int flags, colorOutput_t *out) ssBadge << "\nYafaRay (" << version << ")" << " " << sysInfoGetOS() << sysInfoGetArchitecture() << sysInfoGetPlatform() << sysInfoGetCompiler(); ssBadge << std::setprecision(2); - double times = gTimer.getTime("rendert"); + double times = gTimer.getTimeNotStopping("rendert"); + if(session.renderFinished()) times = gTimer.getTime("rendert"); int timem, timeh; gTimer.splitTime(times, ×, &timem, &timeh); ssBadge << " | " << w << "x" << h; + if(session.renderInProgress()) ssBadge << " | in progress " << std::fixed << std::setprecision(1) << session.currentPassPercent() << "% of pass: " << session.currentPass() << " / " << session.totalPasses(); + else if(session.renderAborted()) ssBadge << " | stopped at " << std::fixed << std::setprecision(1) << session.currentPassPercent() << "% of pass: " << session.currentPass() << " / " << session.totalPasses(); + else ssBadge << " | " << session.totalPasses() << " passes"; //if(cx0 != 0) ssBadge << ", xstart=" << cx0; //if(cy0 != 0) ssBadge << ", ystart=" << cy0; ssBadge << " | Render time:"; @@ -533,7 +578,8 @@ void imageFilm_t::flush(int numView, int flags, colorOutput_t *out) if (timem > 0) ssBadge << " " << timem << "m"; ssBadge << " " << times << "s"; - times = gTimer.getTime("rendert") + gTimer.getTime("prepass"); + times = gTimer.getTimeNotStopping("rendert") + gTimer.getTime("prepass"); + if(session.renderFinished()) times = gTimer.getTime("rendert") + gTimer.getTime("prepass"); gTimer.splitTime(times, ×, &timem, &timeh); ssBadge << " | Total time:"; if (timeh > 0) ssBadge << " " << timeh << "h"; @@ -552,13 +598,15 @@ void imageFilm_t::flush(int numView, int flags, colorOutput_t *out) if(yafLog.getUseParamsBadge()) { - if((colout && colout->isImageOutput()) || (out2 && out2->isImageOutput())) drawRenderSettings(ssBadge); + if((out1 && out1->isImageOutput()) || (out2 && out2->isImageOutput())) drawRenderSettings(ssBadge); } - Y_PARAMS << "--------------------------------------------------------------------------------" << yendl; - for (std::string line; std::getline(ssLog, line, '\n');) if(line != "" && line != "\n") Y_PARAMS << line << yendl; - Y_PARAMS << "--------------------------------------------------------------------------------" << yendl; - + if(session.renderFinished()) + { + Y_PARAMS << "--------------------------------------------------------------------------------" << yendl; + for (std::string line; std::getline(ssLog, line, '\n');) if(line != "" && line != "\n") Y_PARAMS << line << yendl; + Y_PARAMS << "--------------------------------------------------------------------------------" << yendl; + } #ifndef HAVE_FREETYPE Y_WARNING << "imageFilm: Compiled without FreeType support." << yendl; @@ -576,7 +624,7 @@ void imageFilm_t::flush(int numView, int flags, colorOutput_t *out) int outputDisplaceRenderedImageBadgeHeight = 0, out2DisplaceRenderedImageBadgeHeight = 0; - if(colout && colout->isImageOutput() && yafLog.isParamsBadgeTop()) outputDisplaceRenderedImageBadgeHeight = yafLog.getBadgeHeight(); + if(out1 && out1->isImageOutput() && yafLog.isParamsBadgeTop()) outputDisplaceRenderedImageBadgeHeight = yafLog.getBadgeHeight(); if(out2 && out2->isImageOutput() && yafLog.isParamsBadgeTop()) out2DisplaceRenderedImageBadgeHeight = yafLog.getBadgeHeight(); @@ -624,14 +672,14 @@ void imageFilm_t::flush(int numView, int flags, colorOutput_t *out) } } - colout->putPixel(numView, i, j+outputDisplaceRenderedImageBadgeHeight, env->getRenderPasses(), colExtPasses); + if(out1) out1->putPixel(numView, i, j+outputDisplaceRenderedImageBadgeHeight, env->getRenderPasses(), colExtPasses); if(out2) out2->putPixel(numView, i, j+out2DisplaceRenderedImageBadgeHeight, env->getRenderPasses(), colExtPasses2); } } if(yafLog.getUseParamsBadge() && dpimage) { - if(colout && colout->isImageOutput()) + if(out1 && out1->isImageOutput()) { int badgeStartY = h; @@ -646,7 +694,7 @@ void imageFilm_t::flush(int numView, int flags, colorOutput_t *out) colorA_t &dpcol = (*dpimage)(i, j-badgeStartY); colExtPasses[idx] = colorA_t(dpcol, 1.f); } - colout->putPixel(numView, i, j, env->getRenderPasses(), colExtPasses); + out1->putPixel(numView, i, j, env->getRenderPasses(), colExtPasses); } } } @@ -672,12 +720,15 @@ void imageFilm_t::flush(int numView, int flags, colorOutput_t *out) } } - colout->flush(numView, env->getRenderPasses()); + if(out1 && (session.renderFinished() || !out2)) out1->flush(numView, env->getRenderPasses()); if(out2) out2->flush(numView, env->getRenderPasses()); - outMutex.unlock(); - - Y_VERBOSE << "imageFilm: Done." << yendl; + if(session.renderFinished()) + { + yafLog.clearMemoryLog(); + outMutex.unlock(); + Y_VERBOSE << "imageFilm: Done." << yendl; + } } bool imageFilm_t::doMoreSamples(int x, int y) const @@ -889,7 +940,11 @@ void imageFilm_t::drawFontBitmap( FT_Bitmap* bitmap, int x, int y) void imageFilm_t::drawRenderSettings(std::stringstream & ss) { - if(dpimage) return; + if(dpimage) + { + delete dpimage; + dpimage = nullptr; + } dpHeight = yafLog.getBadgeHeight(); @@ -1040,7 +1095,7 @@ void imageFilm_t::drawRenderSettings(std::stringstream & ss) delete logo; } - Y_INFO << "imageFilm: Rendering parameters badge created." << yendl; + Y_VERBOSE << "imageFilm: Rendering parameters badge created." << yendl; } float imageFilm_t::dark_threshold_curve_interpolate(float pixel_brightness) diff --git a/src/yafraycore/integrator.cc b/src/yafraycore/integrator.cc index 4f0cc448..356786da 100644 --- a/src/yafraycore/integrator.cc +++ b/src/yafraycore/integrator.cc @@ -113,8 +113,22 @@ bool tiledIntegrator_t::render(int numView, imageFilm_t *image) std::stringstream passString; imageFilm = image; scene->getAAParameters(AA_samples, AA_passes, AA_inc_samples, AA_threshold, AA_resampled_floor, AA_sample_multiplier_factor, AA_light_sample_multiplier_factor, AA_indirect_sample_multiplier_factor, AA_detect_color_noise, AA_dark_detection_type, AA_dark_threshold_factor, AA_variance_edge_size, AA_variance_pixels, AA_clamp_samples, AA_clamp_indirect); + + std::stringstream aaSettings; + aaSettings << " passes=" << AA_passes; + aaSettings << " samples=" << AA_samples << " inc_samples=" << AA_inc_samples << " resamp.floor=" << AA_resampled_floor << "\nsample.mul=" << AA_sample_multiplier_factor << " light.sam.mul=" << AA_light_sample_multiplier_factor << " ind.sam.mul=" << AA_indirect_sample_multiplier_factor << "\ncol.noise=" << AA_detect_color_noise; + + if(AA_dark_detection_type == DARK_DETECTION_LINEAR) aaSettings << " dark.thr(lin),fac=" << AA_dark_threshold_factor; + else if(AA_dark_detection_type == DARK_DETECTION_CURVE) aaSettings << " dark.thr(curve)"; + + aaSettings << " var.edge=" << AA_variance_edge_size << " var.pix=" << AA_variance_pixels << " clamp=" << AA_clamp_samples << " ind.clamp=" << AA_clamp_indirect; + + yafLog.appendAANoiseSettings(aaSettings.str()); + iAA_passes = 1.f / (float) AA_passes; + session.setStatusTotalPasses(AA_passes); + AA_sample_multiplier = 1.f; AA_light_sample_multiplier = 1.f; AA_indirect_sample_multiplier = 1.f; @@ -136,6 +150,7 @@ bool tiledIntegrator_t::render(int numView, imageFilm_t *image) Y_VERBOSE << "AA_clamp_samples: "<< AA_clamp_samples << yendl; Y_VERBOSE << "AA_clamp_indirect: "<< AA_clamp_indirect << yendl; Y_PARAMS << "Max. " << AA_samples + std::max(0,AA_passes-1) * AA_inc_samples << " total samples" << yendl; + passString << "Rendering pass 1 of " << std::max(1, AA_passes) << "..."; Y_INFO << passString.str() << yendl; if(intpb) intpb->setTag(passString.str().c_str()); @@ -207,6 +222,7 @@ bool tiledIntegrator_t::render(int numView, imageFilm_t *image) } maxDepth = 0.f; gTimer.stop("rendert"); + session.setStatusRenderFinished(); Y_INFO << integratorName << ": Overall rendertime: " << gTimer.getTime("rendert") << "s" << yendl; return true; @@ -219,6 +235,8 @@ bool tiledIntegrator_t::renderPass(int numView, int samples, int offset, bool ad int nthreads = scene->getNumThreads(); + session.setStatusCurrentPass(AA_pass_number+1); + if(nthreads>1) { threadControl_t tc; @@ -232,7 +250,10 @@ bool tiledIntegrator_t::renderPass(int numView, int samples, int offset, bool ad while(tc.finishedThreads < nthreads) { tc.c.wait(lk); - for(size_t i=0; ifinishArea(numView, tc.areas[i]); + for(size_t i=0; ifinishArea(numView, tc.areas[i]); + } tc.areas.clear(); } diff --git a/src/yafraycore/session.cc b/src/yafraycore/session.cc index 57ffd943..37b3ca29 100644 --- a/src/yafraycore/session.cc +++ b/src/yafraycore/session.cc @@ -30,6 +30,10 @@ yafarayLog_t yafLog = yafarayLog_t(); // Initialization of the master session instance session_t session = session_t(); +session_t::session_t(const session_t&) //We need to redefine the copy constructor to avoid trying to copy the mutex (not copiable). This copy constructor will not copy anything, but we only have one session object anyway so it should be ok. +{ +} + session_t::session_t() { Y_VERBOSE << "Session:started" << yendl; @@ -49,5 +53,120 @@ session_t::~session_t() Y_VERBOSE << "Session: ended" << yendl; } +void session_t::setStatusRenderStarted() +{ + mutx.lock(); + + mRenderInProgress = true; + mRenderFinished = false; + mRenderResumed = false; + mRenderAborted = false; + mTotalPasses = 0; + mCurrentPass = 0; + mCurrentPassPercent = 0.f; + + mutx.unlock(); +} + +void session_t::setStatusRenderResumed() +{ + mutx.lock(); + + mRenderInProgress = true; + mRenderFinished = false; + mRenderResumed = true; + mRenderAborted = false; + + mutx.unlock(); +} + +void session_t::setStatusRenderFinished() +{ + mutx.lock(); + + mRenderInProgress = false; + mRenderFinished = true; + + mutx.unlock(); +} + +void session_t::setStatusRenderAborted() +{ + mutx.lock(); + + mRenderInProgress = false; + mRenderAborted = true; + + mutx.unlock(); +} + +void session_t::setStatusTotalPasses(int total_passes) +{ + mutx.lock(); + mTotalPasses = total_passes; + mutx.unlock(); +} + +void session_t::setStatusCurrentPass(int current_pass) +{ + mutx.lock(); + mCurrentPass = current_pass; + mutx.unlock(); +} + +void session_t::setStatusCurrentPassPercent(float current_pass_percent) +{ + mutx.lock(); + mCurrentPassPercent = current_pass_percent; + mutx.unlock(); +} + +void session_t::setInteractive(bool interactive) +{ + mutx.lock(); + mInteractive = interactive; + mutx.unlock(); +} + +bool session_t::renderInProgress() +{ + return mRenderInProgress; +} + +bool session_t::renderResumed() +{ + return mRenderResumed; +} + +bool session_t::renderFinished() +{ + return mRenderFinished; +} + +bool session_t::renderAborted() +{ + return mRenderAborted; +} + +int session_t::totalPasses() +{ + return mTotalPasses; +} + +int session_t::currentPass() +{ + return mCurrentPass; +} + +float session_t::currentPassPercent() +{ + return mCurrentPassPercent; +} + +bool session_t::isInteractive() +{ + return mInteractive; +} + __END_YAFRAY diff --git a/src/yafraycore/timer.cc b/src/yafraycore/timer.cc index 9b4df704..bbfbe041 100644 --- a/src/yafraycore/timer.cc +++ b/src/yafraycore/timer.cc @@ -70,6 +70,24 @@ double timer_t::getTime(const std::string &name) #endif } +double timer_t::getTimeNotStopping(const std::string &name) +{ + auto i=events.find(name); + if (i==events.end()) return -1; +#ifdef WIN32 + else return ((double) (clock() - i->second.start) ) / CLOCKS_PER_SEC; +#else + else + { + timeval now; + struct timezone tz; + gettimeofday(&now, &tz); + const tdata_t &td = i->second; + return (now.tv_sec - td.tvs.tv_sec) + double(now.tv_usec - td.tvs.tv_usec)/1.0e6; + } +#endif +} + bool timer_t::includes(const std::string &label)const { From 8cda424e88e63a225523a031a984f5080b754b73 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sat, 14 May 2016 17:05:26 +0100 Subject: [PATCH 039/124] yafaray-xml CTRL+C handling for Windows --- src/xml_loader/xml-loader.cc | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/src/xml_loader/xml-loader.cc b/src/xml_loader/xml-loader.cc index 17ab4258..38bdfbbf 100644 --- a/src/xml_loader/xml-loader.cc +++ b/src/xml_loader/xml-loader.cc @@ -21,6 +21,23 @@ using namespace::yafaray; scene_t *globalScene = nullptr; +#ifdef WIN32 +BOOL WINAPI ctrl_c_handler(DWORD signal) { + if(globalScene) + { + globalScene->abort(); + session.setStatusRenderAborted(); + Y_WARNING << "Interface: Render aborted by user." << yendl; + } + else + { + session.setStatusRenderAborted(); + Y_WARNING << "Interface: Render aborted by user." << yendl; + exit(1); + } + return TRUE; +} +#else void ctrl_c_handler(int signal) { if(globalScene) @@ -36,16 +53,21 @@ void ctrl_c_handler(int signal) exit(1); } } +#endif int main(int argc, char *argv[]) { //handle CTRL+C events - struct sigaction signalHandler; +#ifdef WIN32 + SetConsoleCtrlHandler(ctrl_c_handler, true); +#else + struct std::sigaction signalHandler; signalHandler.sa_handler = ctrl_c_handler; - sigemptyset(&signalHandler.sa_mask); + std::sigemptyset(&signalHandler.sa_mask); signalHandler.sa_flags = 0; - sigaction(SIGINT, &signalHandler, nullptr); - + std::sigaction(SIGINT, &signalHandler, nullptr); +#endif + std::string xmlLoaderVersion = "YafaRay XML loader version: " + std::string(VERSION); cliParser_t parse(argc, argv, 2, 1, "You need to set at least a yafaray's valid XML file."); From 484bb88f4cd5ac6c0c8c1829233d507841db7b26 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sat, 14 May 2016 17:11:51 +0100 Subject: [PATCH 040/124] Correction to the previous commit --- src/xml_loader/xml-loader.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/xml_loader/xml-loader.cc b/src/xml_loader/xml-loader.cc index 38bdfbbf..61a8c260 100644 --- a/src/xml_loader/xml-loader.cc +++ b/src/xml_loader/xml-loader.cc @@ -61,11 +61,11 @@ int main(int argc, char *argv[]) #ifdef WIN32 SetConsoleCtrlHandler(ctrl_c_handler, true); #else - struct std::sigaction signalHandler; + struct sigaction signalHandler; signalHandler.sa_handler = ctrl_c_handler; - std::sigemptyset(&signalHandler.sa_mask); + sigemptyset(&signalHandler.sa_mask); signalHandler.sa_flags = 0; - std::sigaction(SIGINT, &signalHandler, nullptr); + sigaction(SIGINT, &signalHandler, nullptr); #endif std::string xmlLoaderVersion = "YafaRay XML loader version: " + std::string(VERSION); From 3cdd5689e25731d8a8982bfa4c144a5cae69b6a0 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sat, 14 May 2016 21:23:37 +0100 Subject: [PATCH 041/124] Autosave: remove .tmp from messages in log, for clarity --- src/image_handlers/exrHandler.cc | 13 +++++++++---- src/image_handlers/hdrHandler.cc | 6 ++++-- src/image_handlers/jpgHandler.cc | 6 ++++-- src/image_handlers/pngHandler.cc | 6 ++++-- src/image_handlers/tgaHandler.cc | 6 ++++-- src/image_handlers/tifHandler.cc | 6 ++++-- 6 files changed, 29 insertions(+), 14 deletions(-) diff --git a/src/image_handlers/exrHandler.cc b/src/image_handlers/exrHandler.cc index d42c901f..0cb86de2 100644 --- a/src/image_handlers/exrHandler.cc +++ b/src/image_handlers/exrHandler.cc @@ -97,8 +97,10 @@ exrHandler_t::~exrHandler_t() bool exrHandler_t::saveToFile(const std::string &name, int imagePassNumber) { - if(session.renderInProgress()) Y_VERBOSE << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << name << "\"..." << yendl; - else Y_INFO << handlerName << ": Saving RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << name << "\"..." << yendl; + std::string nameWithoutTmp = name; + nameWithoutTmp.erase(nameWithoutTmp.length()-4); + if(session.renderInProgress()) Y_VERBOSE << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << nameWithoutTmp << "\"..." << yendl; + else Y_INFO << handlerName << ": Saving RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << nameWithoutTmp << "\"..." << yendl; int chan_size = sizeof(half); const int num_colchan = 4; @@ -142,9 +144,12 @@ bool exrHandler_t::saveToFile(const std::string &name, int imagePassNumber) bool exrHandler_t::saveToFileMultiChannel(const std::string &name, const renderPasses_t *renderPasses) { std::string extPassName; + + std::string nameWithoutTmp = name; + nameWithoutTmp.erase(nameWithoutTmp.length()-4); - if(session.renderInProgress()) Y_VERBOSE << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") Multilayer EXR" << " file as \"" << name << "\"..." << yendl; - else Y_INFO << handlerName << ": Saving Multilayer EXR" << " file as \"" << name << "\"..." << yendl; + if(session.renderInProgress()) Y_VERBOSE << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") Multilayer EXR" << " file as \"" << nameWithoutTmp << "\"..." << yendl; + else Y_INFO << handlerName << ": Saving Multilayer EXR" << " file as \"" << nameWithoutTmp << "\"..." << yendl; int chan_size = sizeof(half); const int num_colchan = 4; diff --git a/src/image_handlers/hdrHandler.cc b/src/image_handlers/hdrHandler.cc index e4cbf418..bcfb7a89 100644 --- a/src/image_handlers/hdrHandler.cc +++ b/src/image_handlers/hdrHandler.cc @@ -453,8 +453,10 @@ bool hdrHandler_t::saveToFile(const std::string &name, int imagePassNumber) } else { - if(session.renderInProgress()) Y_VERBOSE << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") RGBE file as \"" << name << "\"..." << yendl; - else Y_INFO << handlerName << ": Saving RGBE file as \"" << name << "\"..." << yendl; + std::string nameWithoutTmp = name; + nameWithoutTmp.erase(nameWithoutTmp.length()-4); + if(session.renderInProgress()) Y_VERBOSE << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") RGBE file as \"" << nameWithoutTmp << "\"..." << yendl; + else Y_INFO << handlerName << ": Saving RGBE file as \"" << nameWithoutTmp << "\"..." << yendl; if (m_hasAlpha) Y_VERBOSE << handlerName << ": Ignoring alpha channel." << yendl; writeHeader(file); diff --git a/src/image_handlers/jpgHandler.cc b/src/image_handlers/jpgHandler.cc index 4e51532e..05bfb27d 100644 --- a/src/image_handlers/jpgHandler.cc +++ b/src/image_handlers/jpgHandler.cc @@ -141,8 +141,10 @@ colorA_t jpgHandler_t::getPixel(int x, int y, int imagePassNumber) bool jpgHandler_t::saveToFile(const std::string &name, int imagePassNumber) { - if(session.renderInProgress()) Y_VERBOSE << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") RGB" << " file as \"" << name << "\"..." << yendl; - else Y_INFO << handlerName << ": Saving RGB" << " file as \"" << name << "\"..." << yendl; + std::string nameWithoutTmp = name; + nameWithoutTmp.erase(nameWithoutTmp.length()-4); + if(session.renderInProgress()) Y_VERBOSE << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") RGB" << " file as \"" << nameWithoutTmp << "\"..." << yendl; + else Y_INFO << handlerName << ": Saving RGB" << " file as \"" << nameWithoutTmp << "\"..." << yendl; FILE * fp; struct jpeg_compress_struct info; diff --git a/src/image_handlers/pngHandler.cc b/src/image_handlers/pngHandler.cc index ea3064cc..c1dce5fc 100644 --- a/src/image_handlers/pngHandler.cc +++ b/src/image_handlers/pngHandler.cc @@ -129,8 +129,10 @@ colorA_t pngHandler_t::getPixel(int x, int y, int imagePassNumber) bool pngHandler_t::saveToFile(const std::string &name, int imagePassNumber) { - if(session.renderInProgress()) Y_VERBOSE << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << name << "\"..." << yendl; - else Y_INFO << handlerName << ": Saving RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << name << "\"..." << yendl; + std::string nameWithoutTmp = name; + nameWithoutTmp.erase(nameWithoutTmp.length()-4); + if(session.renderInProgress()) Y_VERBOSE << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << nameWithoutTmp << "\"..." << yendl; + else Y_INFO << handlerName << ": Saving RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << nameWithoutTmp << "\"..." << yendl; FILE *fp; png_structp pngPtr; diff --git a/src/image_handlers/tgaHandler.cc b/src/image_handlers/tgaHandler.cc index 737168e7..0c3fdd8d 100644 --- a/src/image_handlers/tgaHandler.cc +++ b/src/image_handlers/tgaHandler.cc @@ -130,8 +130,10 @@ tgaHandler_t::~tgaHandler_t() bool tgaHandler_t::saveToFile(const std::string &name, int imagePassNumber) { - if(session.renderInProgress()) Y_VERBOSE << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") " << ((m_hasAlpha) ? "RGBA" : "RGB" ) << " file as \"" << name << "\"..." << yendl; - else Y_INFO << handlerName << ": Saving " << ((m_hasAlpha) ? "RGBA" : "RGB" ) << " file as \"" << name << "\"..." << yendl; + std::string nameWithoutTmp = name; + nameWithoutTmp.erase(nameWithoutTmp.length()-4); + if(session.renderInProgress()) Y_VERBOSE << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") " << ((m_hasAlpha) ? "RGBA" : "RGB" ) << " file as \"" << nameWithoutTmp << "\"..." << yendl; + else Y_INFO << handlerName << ": Saving " << ((m_hasAlpha) ? "RGBA" : "RGB" ) << " file as \"" << nameWithoutTmp << "\"..." << yendl; std::string imageId = "Image rendered with YafaRay"; tgaHeader_t header; diff --git a/src/image_handlers/tifHandler.cc b/src/image_handlers/tifHandler.cc index 8e2e13ff..7ef4dcf3 100644 --- a/src/image_handlers/tifHandler.cc +++ b/src/image_handlers/tifHandler.cc @@ -117,8 +117,10 @@ colorA_t tifHandler_t::getPixel(int x, int y, int imagePassNumber) bool tifHandler_t::saveToFile(const std::string &name, int imagePassNumber) { - if(session.renderInProgress()) Y_VERBOSE << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << name << "\"..." << yendl; - else Y_INFO << handlerName << ": Saving RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << name << "\"..." << yendl; + std::string nameWithoutTmp = name; + nameWithoutTmp.erase(nameWithoutTmp.length()-4); + if(session.renderInProgress()) Y_VERBOSE << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << nameWithoutTmp << "\"..." << yendl; + else Y_INFO << handlerName << ": Saving RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << nameWithoutTmp << "\"..." << yendl; TIFF *out = TIFFOpen(name.c_str(), "w"); int channels; From ce66426c6825d1b151975cf582b8d8af65dd1859 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sun, 15 May 2016 07:01:53 +0100 Subject: [PATCH 042/124] Also adding controlled CTRL+C capability to the Blender Exporter Image output as I did to yafaray-xml --- src/interface/yafrayinterface.cc | 53 ++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/interface/yafrayinterface.cc b/src/interface/yafrayinterface.cc index 6683ad36..b2467bf8 100644 --- a/src/interface/yafrayinterface.cc +++ b/src/interface/yafrayinterface.cc @@ -5,11 +5,63 @@ #include #include #include +#include + +#ifdef WIN32 + #include +#endif __BEGIN_YAFRAY +scene_t *globalScene = nullptr; + +#ifdef WIN32 +BOOL WINAPI ctrl_c_handler(DWORD signal) { + if(globalScene) + { + globalScene->abort(); + session.setStatusRenderAborted(); + Y_WARNING << "Interface: Render aborted by user." << yendl; + } + else + { + session.setStatusRenderAborted(); + Y_WARNING << "Interface: Render aborted by user." << yendl; + exit(1); + } + return TRUE; +} +#else +void ctrl_c_handler(int signal) +{ + if(globalScene) + { + globalScene->abort(); + session.setStatusRenderAborted(); + Y_WARNING << "Interface: Render aborted by user." << yendl; + } + else + { + session.setStatusRenderAborted(); + Y_WARNING << "Interface: Render aborted by user." << yendl; + exit(1); + } +} +#endif + yafrayInterface_t::yafrayInterface_t(): scene(nullptr), film(nullptr), inputGamma(1.f), inputColorSpace(RAW_MANUAL_GAMMA) { + //handle CTRL+C events +#ifdef WIN32 + SetConsoleCtrlHandler(ctrl_c_handler, true); +#else + struct sigaction signalHandler; + signalHandler.sa_handler = ctrl_c_handler; + sigemptyset(&signalHandler.sa_mask); + signalHandler.sa_flags = 0; + sigaction(SIGINT, &signalHandler, nullptr); +#endif + env = new renderEnvironment_t(); params = new paraMap_t; eparams = new std::list; @@ -68,6 +120,7 @@ bool yafrayInterface_t::startScene(int type) { if(scene) delete scene; scene = new scene_t(env); + globalScene = scene; //for the CTRL+C handler scene->setMode(type); env->setScene(scene); return true; From bc58e486b6afdb35d1deb11b15fb8d8e4757bde6 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sun, 15 May 2016 08:31:46 +0100 Subject: [PATCH 043/124] yafaray-xml: automatic detection of libraries and plugins folders, working in Linux --- include/core_api/session.h | 3 +++ src/xml_loader/CMakeLists.txt | 2 ++ src/xml_loader/xml-loader.cc | 4 ++++ src/yafraycore/environment.cc | 7 +++++++ src/yafraycore/session.cc | 10 ++++++++++ 5 files changed, 26 insertions(+) diff --git a/include/core_api/session.h b/include/core_api/session.h index 0a82f976..23a2b23b 100644 --- a/include/core_api/session.h +++ b/include/core_api/session.h @@ -61,6 +61,7 @@ class YAFRAYCORE_EXPORT session_t void setStatusCurrentPass(int current_pass); void setStatusCurrentPassPercent(float current_pass_percent); void setInteractive(bool interactive); + void setPathYafaRayXml(std::string path); bool renderInProgress(); bool renderResumed(); @@ -70,6 +71,7 @@ class YAFRAYCORE_EXPORT session_t int currentPass(); float currentPassPercent(); bool isInteractive(); + std::string getPathYafaRayXml(); photonMap_t * causticMap = nullptr; photonMap_t * diffuseMap = nullptr; @@ -86,6 +88,7 @@ class YAFRAYCORE_EXPORT session_t int mCurrentPass = 0; float mCurrentPassPercent = 0.f; bool mInteractive = false; + std::string mPathYafaRayXml; }; extern YAFRAYCORE_EXPORT session_t session; diff --git a/src/xml_loader/CMakeLists.txt b/src/xml_loader/CMakeLists.txt index 8e0234aa..9aa22b42 100644 --- a/src/xml_loader/CMakeLists.txt +++ b/src/xml_loader/CMakeLists.txt @@ -1,3 +1,5 @@ +SET(CMAKE_INSTALL_RPATH "$ORIGIN/:$ORIGIN/bin") + include_directories(${YAF_INCLUDE_DIRS}) add_executable(yafaray-xml xml-loader.cc) diff --git a/src/xml_loader/xml-loader.cc b/src/xml_loader/xml-loader.cc index 61a8c260..3d96b86c 100644 --- a/src/xml_loader/xml-loader.cc +++ b/src/xml_loader/xml-loader.cc @@ -8,6 +8,8 @@ #include #endif +#include + #include #include #include @@ -68,6 +70,8 @@ int main(int argc, char *argv[]) sigaction(SIGINT, &signalHandler, nullptr); #endif + session.setPathYafaRayXml(boost::filesystem::system_complete(argv[0]).parent_path().string()); + std::string xmlLoaderVersion = "YafaRay XML loader version: " + std::string(VERSION); cliParser_t parse(argc, argv, 2, 1, "You need to set at least a yafaray's valid XML file."); diff --git a/src/yafraycore/environment.cc b/src/yafraycore/environment.cc index 5fbf3124..d2eaaaa9 100644 --- a/src/yafraycore/environment.cc +++ b/src/yafraycore/environment.cc @@ -142,6 +142,13 @@ void renderEnvironment_t::loadPlugins(const std::string &path) bool renderEnvironment_t::getPluginPath(std::string &path) { + if(!session.getPathYafaRayXml().empty()) //Get plugin path from a subfolder of the current yafaray_xml executable file path + { + path = session.getPathYafaRayXml()+"/bin/plugins/"; + return true; + } + +//Next is DEPRECATED and probably will not even be executed now, but I'm keeping it for now just in case #ifdef _WIN32 HKEY hkey; DWORD dwSize; //, dwType; diff --git a/src/yafraycore/session.cc b/src/yafraycore/session.cc index 37b3ca29..d667a16a 100644 --- a/src/yafraycore/session.cc +++ b/src/yafraycore/session.cc @@ -128,6 +128,11 @@ void session_t::setInteractive(bool interactive) mutx.unlock(); } +void session_t::setPathYafaRayXml(std::string path) +{ + mPathYafaRayXml = path; +} + bool session_t::renderInProgress() { return mRenderInProgress; @@ -168,5 +173,10 @@ bool session_t::isInteractive() return mInteractive; } +std::string session_t::getPathYafaRayXml() +{ + return mPathYafaRayXml; +} + __END_YAFRAY From 078b6e2deb04e1ecc8f84b37c7a9030f33201424 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sun, 15 May 2016 11:16:39 +0100 Subject: [PATCH 044/124] yafaray-xml autodetection of plugins path, adjusted same folder for all OS and removed old registry/PATH code --- src/yafraycore/environment.cc | 46 +++-------------------------------- 1 file changed, 4 insertions(+), 42 deletions(-) diff --git a/src/yafraycore/environment.cc b/src/yafraycore/environment.cc index d2eaaaa9..d35a53ea 100644 --- a/src/yafraycore/environment.cc +++ b/src/yafraycore/environment.cc @@ -142,51 +142,13 @@ void renderEnvironment_t::loadPlugins(const std::string &path) bool renderEnvironment_t::getPluginPath(std::string &path) { - if(!session.getPathYafaRayXml().empty()) //Get plugin path from a subfolder of the current yafaray_xml executable file path + //Get plugin path from a subfolder of the current yafaray_xml executable file path + if(!session.getPathYafaRayXml().empty()) { - path = session.getPathYafaRayXml()+"/bin/plugins/"; + path = session.getPathYafaRayXml()+"/plugins/"; return true; } - -//Next is DEPRECATED and probably will not even be executed now, but I'm keeping it for now just in case -#ifdef _WIN32 - HKEY hkey; - DWORD dwSize; //, dwType; - - if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\YafaRay Team\\YafaRay",0,KEY_READ,&hkey)==ERROR_SUCCESS) - { - //dwType = REG_EXPAND_SZ; - dwSize = MAX_PATH; - DWORD dwStat; - - char *pInstallDir=(char *)malloc(MAX_PATH); - - dwStat = RegQueryValueEx(hkey, TEXT("InstallDir"), nullptr, nullptr, (LPBYTE)pInstallDir, &dwSize); - - if (dwStat == NO_ERROR) - { - path = std::string(pInstallDir) + "\\plugins"; - free(pInstallDir); - RegCloseKey(hkey); - return true; - } - - Y_ERROR_ENV << "Couldn't READ \'InstallDir\' value." << yendl; - free(pInstallDir); - RegCloseKey(hkey); - } - else Y_ERROR_ENV << "Couldn't find registry key." << yendl; - - Y_ERROR << "Please fix your registry. Maybe you need add/modify" << yendl; - Y_ERROR << "HKEY_LOCAL_MACHINE\\Software\\YafaRay Team\\YafaRay\\InstallDir" << yendl; - Y_ERROR << "key at registry. You can use \"regedit.exe\" to adjust it at" << yendl; - Y_ERROR << "your own risk. If you are unsure, reinstall YafaRay" << yendl; - - return false; -#else - path = std::string(Y_PLUGINPATH); - return true; -#endif + else return false; } From 9c43b40ae456ffbbbba0c5df5bed1e853d1ace1c Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sun, 15 May 2016 11:40:12 +0100 Subject: [PATCH 045/124] yafaray-xml dynamic libraries loading from same place as executable --- src/xml_loader/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/xml_loader/CMakeLists.txt b/src/xml_loader/CMakeLists.txt index 9aa22b42..8cc6446f 100644 --- a/src/xml_loader/CMakeLists.txt +++ b/src/xml_loader/CMakeLists.txt @@ -1,4 +1,8 @@ -SET(CMAKE_INSTALL_RPATH "$ORIGIN/:$ORIGIN/bin") +if(APPLE) + SET(CMAKE_INSTALL_RPATH @loader_path) +else(APPLE) + SET(CMAKE_INSTALL_RPATH "$ORIGIN/") #If multiple directories are needed this can be used for example: โ€œ$ORIGIN/:$ORIGIN/$ +endif(APPLE) include_directories(${YAF_INCLUDE_DIRS}) From f39e177dcd420ab79c65473a8f24584cb0059723 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sun, 15 May 2016 12:04:07 +0100 Subject: [PATCH 046/124] Autosave: better exception handling and changed autosave messages verbosity --- src/image_handlers/exrHandler.cc | 4 +-- src/image_handlers/hdrHandler.cc | 2 +- src/image_handlers/jpgHandler.cc | 4 +-- src/image_handlers/pngHandler.cc | 2 +- src/image_handlers/tgaHandler.cc | 2 +- src/image_handlers/tifHandler.cc | 2 +- src/yafraycore/imageOutput.cc | 59 +++++++++++++++++++++++++------- 7 files changed, 54 insertions(+), 21 deletions(-) diff --git a/src/image_handlers/exrHandler.cc b/src/image_handlers/exrHandler.cc index 0cb86de2..4c8fba0b 100644 --- a/src/image_handlers/exrHandler.cc +++ b/src/image_handlers/exrHandler.cc @@ -99,7 +99,7 @@ bool exrHandler_t::saveToFile(const std::string &name, int imagePassNumber) { std::string nameWithoutTmp = name; nameWithoutTmp.erase(nameWithoutTmp.length()-4); - if(session.renderInProgress()) Y_VERBOSE << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << nameWithoutTmp << "\"..." << yendl; + if(session.renderInProgress()) Y_INFO << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << nameWithoutTmp << "\"..." << yendl; else Y_INFO << handlerName << ": Saving RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << nameWithoutTmp << "\"..." << yendl; int chan_size = sizeof(half); @@ -148,7 +148,7 @@ bool exrHandler_t::saveToFileMultiChannel(const std::string &name, const renderP std::string nameWithoutTmp = name; nameWithoutTmp.erase(nameWithoutTmp.length()-4); - if(session.renderInProgress()) Y_VERBOSE << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") Multilayer EXR" << " file as \"" << nameWithoutTmp << "\"..." << yendl; + if(session.renderInProgress()) Y_INFO << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") Multilayer EXR" << " file as \"" << nameWithoutTmp << "\"..." << yendl; else Y_INFO << handlerName << ": Saving Multilayer EXR" << " file as \"" << nameWithoutTmp << "\"..." << yendl; int chan_size = sizeof(half); diff --git a/src/image_handlers/hdrHandler.cc b/src/image_handlers/hdrHandler.cc index bcfb7a89..c295a86a 100644 --- a/src/image_handlers/hdrHandler.cc +++ b/src/image_handlers/hdrHandler.cc @@ -455,7 +455,7 @@ bool hdrHandler_t::saveToFile(const std::string &name, int imagePassNumber) { std::string nameWithoutTmp = name; nameWithoutTmp.erase(nameWithoutTmp.length()-4); - if(session.renderInProgress()) Y_VERBOSE << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") RGBE file as \"" << nameWithoutTmp << "\"..." << yendl; + if(session.renderInProgress()) Y_INFO << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") RGBE file as \"" << nameWithoutTmp << "\"..." << yendl; else Y_INFO << handlerName << ": Saving RGBE file as \"" << nameWithoutTmp << "\"..." << yendl; if (m_hasAlpha) Y_VERBOSE << handlerName << ": Ignoring alpha channel." << yendl; diff --git a/src/image_handlers/jpgHandler.cc b/src/image_handlers/jpgHandler.cc index 05bfb27d..01400040 100644 --- a/src/image_handlers/jpgHandler.cc +++ b/src/image_handlers/jpgHandler.cc @@ -143,7 +143,7 @@ bool jpgHandler_t::saveToFile(const std::string &name, int imagePassNumber) { std::string nameWithoutTmp = name; nameWithoutTmp.erase(nameWithoutTmp.length()-4); - if(session.renderInProgress()) Y_VERBOSE << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") RGB" << " file as \"" << nameWithoutTmp << "\"..." << yendl; + if(session.renderInProgress()) Y_INFO << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") RGB" << " file as \"" << nameWithoutTmp << "\"..." << yendl; else Y_INFO << handlerName << ": Saving RGB" << " file as \"" << nameWithoutTmp << "\"..." << yendl; FILE * fp; @@ -206,7 +206,7 @@ bool jpgHandler_t::saveToFile(const std::string &name, int imagePassNumber) if(m_hasAlpha) { std::string alphaname = name.substr(0, name.size() - 4) + "_alpha.jpg"; - if(session.renderInProgress()) Y_VERBOSE << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") Alpha channel as \"" << alphaname << "\"..." << yendl; + if(session.renderInProgress()) Y_INFO << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") Alpha channel as \"" << alphaname << "\"..." << yendl; else Y_INFO << handlerName << ": Saving Alpha channel as \"" << alphaname << "\"..." << yendl; fp = fopen(alphaname.c_str(), "wb"); diff --git a/src/image_handlers/pngHandler.cc b/src/image_handlers/pngHandler.cc index c1dce5fc..dcc32b6e 100644 --- a/src/image_handlers/pngHandler.cc +++ b/src/image_handlers/pngHandler.cc @@ -131,7 +131,7 @@ bool pngHandler_t::saveToFile(const std::string &name, int imagePassNumber) { std::string nameWithoutTmp = name; nameWithoutTmp.erase(nameWithoutTmp.length()-4); - if(session.renderInProgress()) Y_VERBOSE << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << nameWithoutTmp << "\"..." << yendl; + if(session.renderInProgress()) Y_INFO << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << nameWithoutTmp << "\"..." << yendl; else Y_INFO << handlerName << ": Saving RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << nameWithoutTmp << "\"..." << yendl; FILE *fp; diff --git a/src/image_handlers/tgaHandler.cc b/src/image_handlers/tgaHandler.cc index 0c3fdd8d..07c6e1ab 100644 --- a/src/image_handlers/tgaHandler.cc +++ b/src/image_handlers/tgaHandler.cc @@ -132,7 +132,7 @@ bool tgaHandler_t::saveToFile(const std::string &name, int imagePassNumber) { std::string nameWithoutTmp = name; nameWithoutTmp.erase(nameWithoutTmp.length()-4); - if(session.renderInProgress()) Y_VERBOSE << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") " << ((m_hasAlpha) ? "RGBA" : "RGB" ) << " file as \"" << nameWithoutTmp << "\"..." << yendl; + if(session.renderInProgress()) Y_INFO << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") " << ((m_hasAlpha) ? "RGBA" : "RGB" ) << " file as \"" << nameWithoutTmp << "\"..." << yendl; else Y_INFO << handlerName << ": Saving " << ((m_hasAlpha) ? "RGBA" : "RGB" ) << " file as \"" << nameWithoutTmp << "\"..." << yendl; std::string imageId = "Image rendered with YafaRay"; diff --git a/src/image_handlers/tifHandler.cc b/src/image_handlers/tifHandler.cc index 7ef4dcf3..3c047d39 100644 --- a/src/image_handlers/tifHandler.cc +++ b/src/image_handlers/tifHandler.cc @@ -119,7 +119,7 @@ bool tifHandler_t::saveToFile(const std::string &name, int imagePassNumber) { std::string nameWithoutTmp = name; nameWithoutTmp.erase(nameWithoutTmp.length()-4); - if(session.renderInProgress()) Y_VERBOSE << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << nameWithoutTmp << "\"..." << yendl; + if(session.renderInProgress()) Y_INFO << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << nameWithoutTmp << "\"..." << yendl; else Y_INFO << handlerName << ": Saving RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << nameWithoutTmp << "\"..." << yendl; TIFF *out = TIFFOpen(name.c_str(), "w"); diff --git a/src/yafraycore/imageOutput.cc b/src/yafraycore/imageOutput.cc index 37e3e72d..7ea7b17a 100644 --- a/src/yafraycore/imageOutput.cc +++ b/src/yafraycore/imageOutput.cc @@ -93,15 +93,30 @@ void imageOutput_t::flush(int numView, const renderPasses_t *renderPasses) if(numView == 0) { image->saveToFile(fname+".tmp", 0); //This should not be necessary but Blender API seems to be limited and the API "load_from_file" function does not work (yet) with multilayer EXR, so I have to generate this extra combined pass file so it's displayed in the Blender window. - boost::filesystem::copy_file(fname+".tmp", fname, boost::filesystem::copy_option::overwrite_if_exists); - boost::filesystem::remove(fname+".tmp"); + try + { + boost::filesystem::copy_file(fname+".tmp", fname, boost::filesystem::copy_option::overwrite_if_exists); + boost::filesystem::remove(fname+".tmp"); + } + catch(const boost::filesystem::filesystem_error& e) + { + Y_WARNING << "Output: file operation error \"" << e.what() << yendl; + } } fnamePass = path + base_name + " [" + "multilayer" + "]"+ ext; image->saveToFileMultiChannel(fnamePass+".tmp", renderPasses); - boost::filesystem::copy_file(fnamePass+".tmp", fnamePass, boost::filesystem::copy_option::overwrite_if_exists); - boost::filesystem::remove(fnamePass+".tmp"); + try + { + boost::filesystem::copy_file(fnamePass+".tmp", fnamePass, boost::filesystem::copy_option::overwrite_if_exists); + boost::filesystem::remove(fnamePass+".tmp"); + } + catch(const boost::filesystem::filesystem_error& e) + { + Y_WARNING << "Output: file operation error \"" << e.what() << yendl; + } + yafLog.setImagePath(fnamePass); //to show the image in the HTML log output } else @@ -113,8 +128,16 @@ void imageOutput_t::flush(int numView, const renderPasses_t *renderPasses) if(numView == 0 && idx == 0) { image->saveToFile(fname+".tmp", idx); //default image filename, when not using views nor passes and for reloading into Blender - boost::filesystem::copy_file(fname+".tmp", fname, boost::filesystem::copy_option::overwrite_if_exists); - boost::filesystem::remove(fname+".tmp"); + try + { + boost::filesystem::copy_file(fname+".tmp", fname, boost::filesystem::copy_option::overwrite_if_exists); + boost::filesystem::remove(fname+".tmp"); + } + catch(const boost::filesystem::filesystem_error& e) + { + Y_WARNING << "Output: file operation error \"" << e.what() << yendl; + } + yafLog.setImagePath(fname); //to show the image in the HTML log output } @@ -122,34 +145,44 @@ void imageOutput_t::flush(int numView, const renderPasses_t *renderPasses) { fnamePass = path + base_name + " [pass " + passName + "]"+ ext; image->saveToFile(fnamePass+".tmp", idx); - boost::filesystem::copy_file(fnamePass+".tmp", fnamePass, boost::filesystem::copy_option::overwrite_if_exists); - boost::filesystem::remove(fnamePass+".tmp"); + try + { + boost::filesystem::copy_file(fnamePass+".tmp", fnamePass, boost::filesystem::copy_option::overwrite_if_exists); + boost::filesystem::remove(fnamePass+".tmp"); + } + catch(const boost::filesystem::filesystem_error& e) + { + Y_WARNING << "Output: file operation error \"" << e.what() << yendl; + } + if(idx == 0) yafLog.setImagePath(fnamePass); //to show the image in the HTML log output } } } } + std::string fLogName = path + base_name + "_log.txt"; + yafLog.saveTxtLog(fLogName+".tmp"); try - { - std::string fLogName = path + base_name + "_log.txt"; - yafLog.saveTxtLog(fLogName+".tmp"); + { boost::filesystem::copy_file(fLogName+".tmp",fLogName,boost::filesystem::copy_option::overwrite_if_exists); boost::filesystem::remove(fLogName+".tmp"); } catch(const boost::filesystem::filesystem_error& e) { + Y_WARNING << "Output: file operation error \"" << e.what() << yendl; } + std::string fLogHtmlName = path + base_name + "_log.html"; + yafLog.saveHtmlLog(fLogHtmlName+".tmp"); try { - std::string fLogHtmlName = path + base_name + "_log.html"; - yafLog.saveHtmlLog(fLogHtmlName+".tmp"); boost::filesystem::copy_file(fLogHtmlName+".tmp",fLogHtmlName,boost::filesystem::copy_option::overwrite_if_exists); boost::filesystem::remove(fLogHtmlName+".tmp"); } catch(const boost::filesystem::filesystem_error& e) { + Y_WARNING << "Output: file operation error \"" << e.what() << yendl; } } From 86541f290964aec921403ee3c613aa60f2194b64 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sun, 15 May 2016 21:06:45 +0100 Subject: [PATCH 047/124] New ImageFilm load/autosave feature! This might help for continuing interrupted renders, but could cause crashes and wrong results if the film does not match the scene exactly. USE WITH CARE! --- include/core_api/imagefilm.h | 18 +++++ include/core_api/imagesplitter.h | 43 ++++++++++++ include/core_api/session.h | 3 + include/utilities/image_buffers.h | 43 ++++++++++-- include/utilities/tiled_array.h | 30 +++++++++ src/yafraycore/environment.cc | 10 +++ src/yafraycore/imageOutput.cc | 2 +- src/yafraycore/imagefilm.cc | 106 ++++++++++++++++++++++++++++++ src/yafraycore/integrator.cc | 2 + src/yafraycore/session.cc | 14 ++++ 10 files changed, 266 insertions(+), 5 deletions(-) diff --git a/include/core_api/imagefilm.h b/include/core_api/imagefilm.h index d0d5e114..4c5f3663 100644 --- a/include/core_api/imagefilm.h +++ b/include/core_api/imagefilm.h @@ -130,7 +130,12 @@ class YAFRAYCORE_EXPORT imageFilm_t float dark_threshold_curve_interpolate(float pixel_brightness); int getWidth() const { return w; } int getHeight() const { return h; } + int getCurrentPass() const { return nPass; } int getNumPasses() const { return nPasses; } + void setAutoSave(bool auto_save); + void setAutoLoad(bool auto_load); + bool imageFilmLoad(const std::string &filename, bool debugXMLformat); + bool imageFilmSave(const std::string &filename, bool debugXMLformat); #if HAVE_FREETYPE void drawFontBitmap( FT_Bitmap_* bitmap, int x, int y); @@ -177,6 +182,19 @@ class YAFRAYCORE_EXPORT imageFilm_t bool premultAlpha2; //For optional secondary file output int nPasses; double accumulated_image_area_flush_time; + bool autoSave; // If enabled, it will autosave the Image Film at the same time as the image files + bool autoLoad; // If enabled, it will load the image film from a file before start rendering, might be useful to continue interrupted renders but it has to be used with care. If it does not match exactly the scene, bad results or even crashes could happen. + + friend class boost::serialization::access; + template void serialize(Archive & ar, const unsigned int version) + { + ar & BOOST_SERIALIZATION_NVP(imagePasses); + //ar & BOOST_SERIALIZATION_NVP(densityImage); + //ar & BOOST_SERIALIZATION_NVP(dpimage); + //ar & BOOST_SERIALIZATION_NVP(flags); + //ar & BOOST_SERIALIZATION_NVP(splitter); + //ar & BOOST_SERIALIZATION_NVP(nPass); + } }; __END_YAFRAY diff --git a/include/core_api/imagesplitter.h b/include/core_api/imagesplitter.h index 11eb139c..3e025bbc 100644 --- a/include/core_api/imagesplitter.h +++ b/include/core_api/imagesplitter.h @@ -7,6 +7,13 @@ #include #include +#include +#include +#include +#include +#include +#include + __BEGIN_YAFRAY struct renderArea_t @@ -45,6 +52,24 @@ struct renderArea_t // std::vector image; // std::vector depth; std::vector resample; + + friend class boost::serialization::access; + template void serialize(Archive & ar, const unsigned int version) + { + ar & BOOST_SERIALIZATION_NVP(X); + ar & BOOST_SERIALIZATION_NVP(Y); + ar & BOOST_SERIALIZATION_NVP(W); + ar & BOOST_SERIALIZATION_NVP(H); + ar & BOOST_SERIALIZATION_NVP(realX); + ar & BOOST_SERIALIZATION_NVP(realY); + ar & BOOST_SERIALIZATION_NVP(realW); + ar & BOOST_SERIALIZATION_NVP(realH); + ar & BOOST_SERIALIZATION_NVP(sx0); + ar & BOOST_SERIALIZATION_NVP(sx1); + ar & BOOST_SERIALIZATION_NVP(sy0); + ar & BOOST_SERIALIZATION_NVP(sy1); + ar & BOOST_SERIALIZATION_NVP(resample); + } }; /*! Splits the image to be rendered into pieces, e.g. "buckets" for @@ -55,6 +80,7 @@ class imageSpliter_t { public: enum tilesOrderType { LINEAR, RANDOM, CENTRE_RANDOM }; + imageSpliter_t() {}; imageSpliter_t(int w, int h, int x0,int y0, int bsize, tilesOrderType torder, int nthreads); /* return the n-th area to be rendered. \return false if n is out of range, true otherwise @@ -70,10 +96,27 @@ class imageSpliter_t { int x,y,w,h; // int rx,ry,rw,rh; + template void serialize(Archive & ar, const unsigned int version) + { + ar & BOOST_SERIALIZATION_NVP(x); + ar & BOOST_SERIALIZATION_NVP(y); + ar & BOOST_SERIALIZATION_NVP(w); + ar & BOOST_SERIALIZATION_NVP(h); + } }; int width,height,blocksize; std::vector regions; tilesOrderType tilesorder; + + friend class boost::serialization::access; + template void serialize(Archive & ar, const unsigned int version) + { + ar & BOOST_SERIALIZATION_NVP(width); + ar & BOOST_SERIALIZATION_NVP(height); + ar & BOOST_SERIALIZATION_NVP(blocksize); + ar & BOOST_SERIALIZATION_NVP(regions); + ar & BOOST_SERIALIZATION_NVP(tilesorder); + } }; class imageSpliterCentreSorter_t { diff --git a/include/core_api/session.h b/include/core_api/session.h index 23a2b23b..79b09d39 100644 --- a/include/core_api/session.h +++ b/include/core_api/session.h @@ -62,6 +62,7 @@ class YAFRAYCORE_EXPORT session_t void setStatusCurrentPassPercent(float current_pass_percent); void setInteractive(bool interactive); void setPathYafaRayXml(std::string path); + void setPathImageOutput(std::string path); bool renderInProgress(); bool renderResumed(); @@ -72,6 +73,7 @@ class YAFRAYCORE_EXPORT session_t float currentPassPercent(); bool isInteractive(); std::string getPathYafaRayXml(); + std::string getPathImageOutput(); photonMap_t * causticMap = nullptr; photonMap_t * diffuseMap = nullptr; @@ -89,6 +91,7 @@ class YAFRAYCORE_EXPORT session_t float mCurrentPassPercent = 0.f; bool mInteractive = false; std::string mPathYafaRayXml; + std::string mPathImageOutput; }; extern YAFRAYCORE_EXPORT session_t session; diff --git a/include/utilities/image_buffers.h b/include/utilities/image_buffers.h index 1d404a7e..ad692093 100644 --- a/include/utilities/image_buffers.h +++ b/include/utilities/image_buffers.h @@ -29,6 +29,13 @@ #include #include +#include +#include +#include +#include +#include +#include + __BEGIN_YAFRAY /*! Color weighted pixel structure */ @@ -44,6 +51,13 @@ class pixel_t colorA_t col; float weight; + + friend class boost::serialization::access; + template void serialize(Archive & ar, const unsigned int version) + { + ar & BOOST_SERIALIZATION_NVP(col); + ar & BOOST_SERIALIZATION_NVP(weight); + } }; /*! Gray scale weighted pixel structure */ @@ -58,6 +72,13 @@ class pixelGray_t } float val; float weight; + + friend class boost::serialization::access; + template void serialize(Archive & ar, const unsigned int version) + { + ar & BOOST_SERIALIZATION_NVP(val); + ar & BOOST_SERIALIZATION_NVP(weight); + } }; class rgba8888_t @@ -210,11 +231,18 @@ template class generic2DBuffer_t return data[x][y]; } -private: - +protected: std::vector< std::vector< T > > data; int width; int height; + + friend class boost::serialization::access; + template void serialize(Archive & ar, const unsigned int version) + { + ar & BOOST_SERIALIZATION_NVP(data); + ar & BOOST_SERIALIZATION_NVP(width); + ar & BOOST_SERIALIZATION_NVP(height); + } }; template class genericScanlineBuffer_t @@ -248,11 +276,18 @@ template class genericScanlineBuffer_t return data[x * height + y]; } -private: - +protected: std::vector< T > data; int width; int height; + + friend class boost::serialization::access; + template void serialize(Archive & ar, const unsigned int version) + { + ar & BOOST_SERIALIZATION_NVP(data); + ar & BOOST_SERIALIZATION_NVP(width); + ar & BOOST_SERIALIZATION_NVP(height); + } }; typedef generic2DBuffer_t rgba2DImage_t; //!< Weighted RGBA image buffer typedef diff --git a/include/utilities/tiled_array.h b/include/utilities/tiled_array.h index 4e104d1a..7ca340c5 100644 --- a/include/utilities/tiled_array.h +++ b/include/utilities/tiled_array.h @@ -5,6 +5,13 @@ #include #include "y_alloc.h" +#include +#include +#include +#include +#include +#include + __BEGIN_YAFRAY template class tiledArray2D_t @@ -76,6 +83,17 @@ template class tiledArray2D_t T *data; int nx, ny, xBlocks; int blockSize, blockMask; + + friend class boost::serialization::access; + template void serialize(Archive & ar, const unsigned int version) + { + ar & BOOST_SERIALIZATION_NVP(data); + ar & BOOST_SERIALIZATION_NVP(nx); + ar & BOOST_SERIALIZATION_NVP(ny); + ar & BOOST_SERIALIZATION_NVP(xBlocks); + ar & BOOST_SERIALIZATION_NVP(blockSize); + ar & BOOST_SERIALIZATION_NVP(blockMask); + } }; @@ -133,6 +151,18 @@ template class tiledBitArray2D_t size_t nAlloc; int nx, ny, xBlocks; int blockSize, blockMask; + + friend class boost::serialization::access; + template void serialize(Archive & ar, const unsigned int version) + { + ar & BOOST_SERIALIZATION_NVP(data); + ar & BOOST_SERIALIZATION_NVP(nAlloc); + ar & BOOST_SERIALIZATION_NVP(nx); + ar & BOOST_SERIALIZATION_NVP(ny); + ar & BOOST_SERIALIZATION_NVP(xBlocks); + ar & BOOST_SERIALIZATION_NVP(blockSize); + ar & BOOST_SERIALIZATION_NVP(blockMask); + } }; __END_YAFRAY diff --git a/src/yafraycore/environment.cc b/src/yafraycore/environment.cc index d35a53ea..34df4f60 100644 --- a/src/yafraycore/environment.cc +++ b/src/yafraycore/environment.cc @@ -538,6 +538,8 @@ imageFilm_t* renderEnvironment_t::createImageFilm(const paraMap_t ¶ms, color bool premult2 = false; float partial_save_timer = 0.f; bool partial_save_each_pass = false; + bool film_autosave = false; + bool film_load = false; params.getParam("color_space", color_space_string); params.getParam("gamma", gamma); @@ -556,6 +558,8 @@ imageFilm_t* renderEnvironment_t::createImageFilm(const paraMap_t ¶ms, color params.getParam("premult2", premult2); // Premultipy Alpha channel for better alpha antialiasing against bg, for the optional secondary output params.getParam("partial_save_timer", partial_save_timer); // Time for partially save image params.getParam("partial_save_each_pass", partial_save_each_pass); // If enabled, it will autosave the image at the end of each pass + params.getParam("film_autosave", film_autosave); // If enabled, it will autosave the Image Film at the same time as the image files + params.getParam("film_load", film_load); // If enabled, it will load the image film from a file before start rendering, might be useful to continue interrupted renders but it has to be used with care. If it does not match exactly the scene, bad results or even crashes could happen if(color_space_string == "sRGB") color_space = SRGB; else if(color_space_string == "XYZ") color_space = XYZ_D65; @@ -621,6 +625,12 @@ imageFilm_t* renderEnvironment_t::createImageFilm(const paraMap_t ¶ms, color film->setImageOutputPartialSaveEndPass(false); } + film->setAutoSave(film_autosave); + if(film_autosave) Y_INFO_ENV << "Enabling imageFilm AutoSave feature" << yendl; + + film->setAutoLoad(film_load); + if(film_autosave) Y_INFO_ENV << "Enabling imageFilm AutoLoad feature. It will load the image film from a file before start rendering. If it does not match exactly the scene, bad results or even crashes could happen. Use WITH CARE!" << yendl; + return film; } diff --git a/src/yafraycore/imageOutput.cc b/src/yafraycore/imageOutput.cc index 7ea7b17a..9d8eccc7 100644 --- a/src/yafraycore/imageOutput.cc +++ b/src/yafraycore/imageOutput.cc @@ -30,7 +30,7 @@ __BEGIN_YAFRAY imageOutput_t::imageOutput_t(imageHandler_t * handle, const std::string &name, int bx, int by) : image(handle), fname(name), bX(bx), bY(by) { - //empty + session.setPathImageOutput(fname); } imageOutput_t::imageOutput_t() diff --git a/src/yafraycore/imagefilm.cc b/src/yafraycore/imagefilm.cc index 83df2a1d..0e9ce9d4 100644 --- a/src/yafraycore/imagefilm.cc +++ b/src/yafraycore/imagefilm.cc @@ -36,6 +36,7 @@ #include #include #include +#include #if HAVE_FREETYPE #include @@ -175,6 +176,9 @@ imageFilm_t::imageFilm_t (int width, int height, int xstart, int ystart, colorOu AA_variance_edge_size = 10; AA_variance_pixels = 0; AA_clamp_samples = 0.f; + + autoSave = false; + autoLoad = false; } imageFilm_t::~imageFilm_t () @@ -228,6 +232,24 @@ void imageFilm_t::init(int numPasses) completed_cnt = 0; nPass = 1; nPasses = numPasses; + + if(autoLoad) + { + std::string filmPath = session.getPathImageOutput()+".film"; + std::string filmPathBackup = filmPath+"-previous.bak"; + Y_INFO << "imageFilm: Loading film from: \"" << filmPath << "\"" << yendl; + this->imageFilmLoad(filmPath, false); + Y_VERBOSE << "imageFilm: Making backup of previously saved film to: \"" << filmPathBackup << "\"" << yendl; + try + { + boost::filesystem::copy_file(filmPath, filmPathBackup, boost::filesystem::copy_option::overwrite_if_exists); + } + catch(const boost::filesystem::filesystem_error& e) + { + Y_WARNING << "imageFilm: error during imageFilm file backup \"" << e.what() << "\"" << yendl; + } + session.setStatusRenderResumed(); + } } int imageFilm_t::nextPass(int numView, bool adaptive_AA, std::string integratorName) @@ -723,6 +745,14 @@ void imageFilm_t::flush(int numView, int flags, colorOutput_t *out) if(out1 && (session.renderFinished() || !out2)) out1->flush(numView, env->getRenderPasses()); if(out2) out2->flush(numView, env->getRenderPasses()); + if(autoSave) + { + std::string filmPath = session.getPathImageOutput()+".film"; + Y_INFO << "imageFilm: Saving film to: \"" << filmPath << "\"" << yendl; + this->imageFilmSave(filmPath, false); + Y_VERBOSE << "imageFilm: Saved film to: \"" << filmPath << "\"" << yendl; + } + if(session.renderFinished()) { yafLog.clearMemoryLog(); @@ -1116,4 +1146,80 @@ float imageFilm_t::dark_threshold_curve_interpolate(float pixel_brightness) else return 0.1000f; } +void imageFilm_t::setAutoSave(bool auto_save) +{ + autoSave = auto_save; +} + +void imageFilm_t::setAutoLoad(bool auto_load) +{ + autoLoad = auto_load; +} + +bool imageFilm_t::imageFilmLoad(const std::string &filename, bool debugXMLformat) +{ + try + { + std::ifstream ifs(filename, std::fstream::binary); + + if(debugXMLformat) + { + boost::archive::xml_iarchive ia(ifs); + //map->clear(); //FIXME DAVID + ia >> BOOST_SERIALIZATION_NVP(*this); + ifs.close(); + } + else + { + boost::archive::binary_iarchive ia(ifs); + //map->clear(); //FIXME DAVID + ia >> BOOST_SERIALIZATION_NVP(*this); + ifs.close(); + } + return true; + } + catch(std::exception& ex){ + // elminate any dangling references + //map->clear(); //FIXME DAVID + Y_WARNING << "imageFilm: error '" << ex.what() << "' while loading ImageFilm file: '" << filename << "'" << yendl; + return false; + } +} + +bool imageFilm_t::imageFilmSave(const std::string &filename, bool debugXMLformat) +{ + try + { + std::ofstream ofs(filename+".tmp", std::fstream::binary); + + if(debugXMLformat) + { + boost::archive::xml_oarchive oa(ofs); + oa << BOOST_SERIALIZATION_NVP(*this); + ofs.close(); + } + else + { + boost::archive::binary_oarchive oa(ofs); + oa << BOOST_SERIALIZATION_NVP(*this); + ofs.close(); + } + } + catch(std::exception& ex){ + Y_WARNING << "imageFilm: error '" << ex.what() << "' while saving ImageFilm file: '" << filename << "'" << yendl; + return false; + } + + try + { + boost::filesystem::copy_file(filename+".tmp", filename, boost::filesystem::copy_option::overwrite_if_exists); + boost::filesystem::remove(filename+".tmp"); + } + catch(const boost::filesystem::filesystem_error& e) + { + Y_WARNING << "imageFilm: file operation error \"" << e.what() << yendl; + } + return true; +} + __END_YAFRAY diff --git a/src/yafraycore/integrator.cc b/src/yafraycore/integrator.cc index 356786da..b9e3dbb2 100644 --- a/src/yafraycore/integrator.cc +++ b/src/yafraycore/integrator.cc @@ -35,8 +35,10 @@ #include #include +#include #include +#include __BEGIN_YAFRAY diff --git a/src/yafraycore/session.cc b/src/yafraycore/session.cc index d667a16a..cac6e284 100644 --- a/src/yafraycore/session.cc +++ b/src/yafraycore/session.cc @@ -130,7 +130,16 @@ void session_t::setInteractive(bool interactive) void session_t::setPathYafaRayXml(std::string path) { + mutx.lock(); mPathYafaRayXml = path; + mutx.unlock(); +} + +void session_t::setPathImageOutput(std::string path) +{ + mutx.lock(); + mPathImageOutput = path; + mutx.unlock(); } bool session_t::renderInProgress() @@ -178,5 +187,10 @@ std::string session_t::getPathYafaRayXml() return mPathYafaRayXml; } +std::string session_t::getPathImageOutput() +{ + return mPathImageOutput; +} + __END_YAFRAY From 22cf2d76505f0dcd2fe67bc4f7639b554445f251 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sun, 15 May 2016 21:30:48 +0100 Subject: [PATCH 048/124] Version change to ALPHA3. Added new extended LICENSES file with licenses details for the dependency libraries as well. --- LICENSE | 519 ---------- LICENSES | 1925 ++++++++++++++++++++++++++++++++++++ include/yafray_constants.h | 2 +- 3 files changed, 1926 insertions(+), 520 deletions(-) delete mode 100644 LICENSE create mode 100644 LICENSES diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 753ffee0..00000000 --- a/LICENSE +++ /dev/null @@ -1,519 +0,0 @@ -This program called YAFARAY was originally written by Alejandro Conty -and Alfredo de Greef under the name YAFRAY in 2001 and it's under the LGPL -license. - -Copyright (C) 2005 by the authors by now Mathias Wein, Alejandro Conty -and Alfredo de Greef - -This is free software, get info about LGPL and opensource at -http://www.gnu.org - -This software comes with absolutely no guaranty, so use it at your own risk - ------------------------------------------------------------------------------ - - - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - diff --git a/LICENSES b/LICENSES new file mode 100644 index 00000000..acac0109 --- /dev/null +++ b/LICENSES @@ -0,0 +1,1925 @@ +YAFARAY AND DEPENDENCIES LICENSES +================================= + + +YAFARAY LICENSES +================ + +YafaRay Blender Exporter code +------------------------------ +https://github.com/YafaRay/Blender-Exporter + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. + + + + + +YafaRay Core code +----------------- +https://github.com/YafaRay/Core + +This program called YAFARAY was originally written by Alejandro Conty +and Alfredo de Greef under the name YAFRAY in 2001 and it's under the LGPL +license. + +Copyright (C) 2005 by the authors by now Mathias Wein, Alejandro Conty +and Alfredo de Greef + +This is free software, get info about LGPL and opensource at +http://www.gnu.org + +This software comes with absolutely no guaranty, so use it at your own risk + +----------------------------------------------------------------------------- + + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + + + + +DEPENDENCIES LICENSES +===================== + + +FreeType +-------- + The FreeType Project LICENSE + ---------------------------- + + 2006-Jan-27 + + Copyright 1996-2002, 2006 by + David Turner, Robert Wilhelm, and Werner Lemberg + + + +Introduction +============ + + The FreeType Project is distributed in several archive packages; + some of them may contain, in addition to the FreeType font engine, + various tools and contributions which rely on, or relate to, the + FreeType Project. + + This license applies to all files found in such packages, and + which do not fall under their own explicit license. The license + affects thus the FreeType font engine, the test programs, + documentation and makefiles, at the very least. + + This license was inspired by the BSD, Artistic, and IJG + (Independent JPEG Group) licenses, which all encourage inclusion + and use of free software in commercial and freeware products + alike. As a consequence, its main points are that: + + o We don't promise that this software works. However, we will be + interested in any kind of bug reports. (`as is' distribution) + + o You can use this software for whatever you want, in parts or + full form, without having to pay us. (`royalty-free' usage) + + o You may not pretend that you wrote this software. If you use + it, or only parts of it, in a program, you must acknowledge + somewhere in your documentation that you have used the + FreeType code. (`credits') + + We specifically permit and encourage the inclusion of this + software, with or without modifications, in commercial products. + We disclaim all warranties covering The FreeType Project and + assume no liability related to The FreeType Project. + + + Finally, many people asked us for a preferred form for a + credit/disclaimer to use in compliance with this license. We thus + encourage you to use the following text: + + """ + Portions of this software are copyright ยฉ The FreeType + Project (www.freetype.org). All rights reserved. + """ + + Please replace with the value from the FreeType version you + actually use. + + +Legal Terms +=========== + +0. Definitions +-------------- + + Throughout this license, the terms `package', `FreeType Project', + and `FreeType archive' refer to the set of files originally + distributed by the authors (David Turner, Robert Wilhelm, and + Werner Lemberg) as the `FreeType Project', be they named as alpha, + beta or final release. + + `You' refers to the licensee, or person using the project, where + `using' is a generic term including compiling the project's source + code as well as linking it to form a `program' or `executable'. + This program is referred to as `a program using the FreeType + engine'. + + This license applies to all files distributed in the original + FreeType Project, including all source code, binaries and + documentation, unless otherwise stated in the file in its + original, unmodified form as distributed in the original archive. + If you are unsure whether or not a particular file is covered by + this license, you must contact us to verify this. + + The FreeType Project is copyright (C) 1996-2000 by David Turner, + Robert Wilhelm, and Werner Lemberg. All rights reserved except as + specified below. + +1. No Warranty +-------------- + + THE FREETYPE PROJECT IS PROVIDED `AS IS' WITHOUT WARRANTY OF ANY + KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + PURPOSE. IN NO EVENT WILL ANY OF THE AUTHORS OR COPYRIGHT HOLDERS + BE LIABLE FOR ANY DAMAGES CAUSED BY THE USE OR THE INABILITY TO + USE, OF THE FREETYPE PROJECT. + +2. Redistribution +----------------- + + This license grants a worldwide, royalty-free, perpetual and + irrevocable right and license to use, execute, perform, compile, + display, copy, create derivative works of, distribute and + sublicense the FreeType Project (in both source and object code + forms) and derivative works thereof for any purpose; and to + authorize others to exercise some or all of the rights granted + herein, subject to the following conditions: + + o Redistribution of source code must retain this license file + (`FTL.TXT') unaltered; any additions, deletions or changes to + the original files must be clearly indicated in accompanying + documentation. The copyright notices of the unaltered, + original files must be preserved in all copies of source + files. + + o Redistribution in binary form must provide a disclaimer that + states that the software is based in part of the work of the + FreeType Team, in the distribution documentation. We also + encourage you to put an URL to the FreeType web page in your + documentation, though this isn't mandatory. + + These conditions apply to any software derived from or based on + the FreeType Project, not just the unmodified files. If you use + our work, you must acknowledge us. However, no fee need be paid + to us. + +3. Advertising +-------------- + + Neither the FreeType authors and contributors nor you shall use + the name of the other for commercial, advertising, or promotional + purposes without specific prior written permission. + + We suggest, but do not require, that you use one or more of the + following phrases to refer to this software in your documentation + or advertising materials: `FreeType Project', `FreeType Engine', + `FreeType library', or `FreeType Distribution'. + + As you have not signed this license, you are not required to + accept it. However, as the FreeType Project is copyrighted + material, only this license, or another one contracted with the + authors, grants you the right to use, distribute, and modify it. + Therefore, by using, distributing, or modifying the FreeType + Project, you indicate that you understand and accept all the terms + of this license. + +4. Contacts +----------- + + There are two mailing lists related to FreeType: + + o freetype@nongnu.org + + Discusses general use and applications of FreeType, as well as + future and wanted additions to the library and distribution. + If you are looking for support, start in this list if you + haven't found anything to help you in the documentation. + + o freetype-devel@nongnu.org + + Discusses bugs, as well as engine internals, design issues, + specific licenses, porting, etc. + + Our home page can be found at + + http://www.freetype.org + + + +OpenEXR and ILMBase +------------------- + +Copyright (c) 2006, Industrial Light & Magic, a division of Lucasfilm +Entertainment Company Ltd. Portions contributed and copyright held by +others as indicated. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above + copyright notice, this list of conditions and the following + disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided with + the distribution. + + * Neither the name of Industrial Light & Magic nor the names of + any other contributors to this software may be used to endorse or + promote products derived from this software without specific prior + written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + + +JPEG +---- + +In plain English: + +1. We don't promise that this software works. (But if you find any bugs, + please let us know!) +2. You can use this software for whatever you want. You don't have to pay us. +3. You may not pretend that you wrote this software. If you use it in a + program, you must acknowledge somewhere in your documentation that + you've used the IJG code. + +In legalese: + +The authors make NO WARRANTY or representation, either express or implied, +with respect to this software, its quality, accuracy, merchantability, or +fitness for a particular purpose. This software is provided "AS IS", and you, +its user, assume the entire risk as to its quality and accuracy. + +This software is copyright (C) 1991-2012, Thomas G. Lane, Guido Vollbeding. +All Rights Reserved except as specified below. + +Permission is hereby granted to use, copy, modify, and distribute this +software (or portions thereof) for any purpose, without fee, subject to these +conditions: +(1) If any part of the source code for this software is distributed, then this +README file must be included, with this copyright and no-warranty notice +unaltered; and any additions, deletions, or changes to the original files +must be clearly indicated in accompanying documentation. +(2) If only executable code is distributed, then the accompanying +documentation must state that "this software is based in part on the work of +the Independent JPEG Group". +(3) Permission for use of this software is granted only if the user accepts +full responsibility for any undesirable consequences; the authors accept +NO LIABILITY for damages of any kind. + +These conditions apply to any software derived from or based on the IJG code, +not just to the unmodified library. If you use our work, you ought to +acknowledge us. + +Permission is NOT granted for the use of any IJG author's name or company name +in advertising or publicity relating to this software or products derived from +it. This software may be referred to only as "the Independent JPEG Group's +software". + +We specifically permit and encourage the use of this software as the basis of +commercial products, provided that all warranty or liability claims are +assumed by the product vendor. + + +ansi2knr.c is included in this distribution by permission of L. Peter Deutsch, +sole proprietor of its copyright holder, Aladdin Enterprises of Menlo Park, CA. +ansi2knr.c is NOT covered by the above copyright and conditions, but instead +by the usual distribution terms of the Free Software Foundation; principally, +that you must include source code if you redistribute it. (See the file +ansi2knr.c for full details.) However, since ansi2knr.c is not needed as part +of any program generated from the IJG code, this does not limit you more than +the foregoing paragraphs do. + +The Unix configuration script "configure" was produced with GNU Autoconf. +It is copyright by the Free Software Foundation but is freely distributable. +The same holds for its supporting scripts (config.guess, config.sub, +ltmain.sh). Another support script, install-sh, is copyright by X Consortium +but is also freely distributable. + +The IJG distribution formerly included code to read and write GIF files. +To avoid entanglement with the Unisys LZW patent, GIF reading support has +been removed altogether, and the GIF writer has been simplified to produce +"uncompressed GIFs". This technique does not use the LZW algorithm; the +resulting GIF files are larger than usual, but are readable by all standard +GIF decoders. + +We are required to state that + "The Graphics Interchange Format(c) is the Copyright property of + CompuServe Incorporated. GIF(sm) is a Service Mark property of + CompuServe Incorporated." + + + +LibICONV +-------- + + GNU LIBRARY GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1991 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the library GPL. It is + numbered 2 because it goes with version 2 of the ordinary GPL.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Library General Public License, applies to some +specially designated Free Software Foundation software, and to any +other libraries whose authors decide to use it. You can use it for +your libraries, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if +you distribute copies of the library, or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link a program with the library, you must provide +complete object files to the recipients so that they can relink them +with the library, after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + Our method of protecting your rights has two steps: (1) copyright +the library, and (2) offer you this license which gives you legal +permission to copy, distribute and/or modify the library. + + Also, for each distributor's protection, we want to make certain +that everyone understands that there is no warranty for this free +library. If the library is modified by someone else and passed on, we +want its recipients to know that what they have is not the original +version, so that any problems introduced by others will not reflect on +the original authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that companies distributing free +software will individually obtain patent licenses, thus in effect +transforming the program into proprietary software. To prevent this, +we have made it clear that any patent must be licensed for everyone's +free use or not licensed at all. + + Most GNU software, including some libraries, is covered by the ordinary +GNU General Public License, which was designed for utility programs. This +license, the GNU Library General Public License, applies to certain +designated libraries. This license is quite different from the ordinary +one; be sure to read it in full, and don't assume that anything in it is +the same as in the ordinary license. + + The reason we have a separate public license for some libraries is that +they blur the distinction we usually make between modifying or adding to a +program and simply using it. Linking a program with a library, without +changing the library, is in some sense simply using the library, and is +analogous to running a utility program or application program. However, in +a textual and legal sense, the linked executable is a combined work, a +derivative of the original library, and the ordinary General Public License +treats it as such. + + Because of this blurred distinction, using the ordinary General +Public License for libraries did not effectively promote software +sharing, because most developers did not use the libraries. We +concluded that weaker conditions might promote sharing better. + + However, unrestricted linking of non-free programs would deprive the +users of those programs of all benefit from the free status of the +libraries themselves. This Library General Public License is intended to +permit developers of non-free programs to use free libraries, while +preserving your freedom as a user of such programs to change the free +libraries that are incorporated in them. (We have not seen how to achieve +this as regards changes in header files, but we have achieved it as regards +changes in the actual functions of the Library.) The hope is that this +will lead to faster development of free libraries. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, while the latter only +works together with the library. + + Note that it is possible for a library to be covered by the ordinary +General Public License rather than by this special one. + + GNU LIBRARY GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library which +contains a notice placed by the copyright holder or other authorized +party saying it may be distributed under the terms of this Library +General Public License (also called "this License"). Each licensee is +addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also compile or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + c) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + d) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the source code distributed need not include anything that is normally +distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Library General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301, USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + + +LibPNG +------ + +This copy of the libpng notices is provided for your convenience. In case of +any discrepancy between this copy and the notices in the file png.h that is +included in the libpng distribution, the latter shall prevail. + +COPYRIGHT NOTICE, DISCLAIMER, and LICENSE: + +If you modify libpng you may insert additional notices immediately following +this sentence. + +This code is released under the libpng license. + +libpng versions 1.2.6, August 15, 2004, through 1.6.3, July 18, 2013, are +Copyright (c) 2004, 2006-2013 Glenn Randers-Pehrson, and are +distributed according to the same disclaimer and license as libpng-1.2.5 +with the following individual added to the list of Contributing Authors + + Cosmin Truta + +libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, are +Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are +distributed according to the same disclaimer and license as libpng-1.0.6 +with the following individuals added to the list of Contributing Authors + + Simon-Pierre Cadieux + Eric S. Raymond + Gilles Vollant + +and with the following additions to the disclaimer: + + There is no warranty against interference with your enjoyment of the + library or against infringement. There is no warranty that our + efforts or the library will fulfill any of your particular purposes + or needs. This library is provided with all faults, and the entire + risk of satisfactory quality, performance, accuracy, and effort is with + the user. + +libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are +Copyright (c) 1998, 1999 Glenn Randers-Pehrson, and are +distributed according to the same disclaimer and license as libpng-0.96, +with the following individuals added to the list of Contributing Authors: + + Tom Lane + Glenn Randers-Pehrson + Willem van Schaik + +libpng versions 0.89, June 1996, through 0.96, May 1997, are +Copyright (c) 1996, 1997 Andreas Dilger +Distributed according to the same disclaimer and license as libpng-0.88, +with the following individuals added to the list of Contributing Authors: + + John Bowler + Kevin Bracey + Sam Bushell + Magnus Holmgren + Greg Roelofs + Tom Tanner + +libpng versions 0.5, May 1995, through 0.88, January 1996, are +Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. + +For the purposes of this copyright and license, "Contributing Authors" +is defined as the following set of individuals: + + Andreas Dilger + Dave Martindale + Guy Eric Schalnat + Paul Schmidt + Tim Wegner + +The PNG Reference Library is supplied "AS IS". The Contributing Authors +and Group 42, Inc. disclaim all warranties, expressed or implied, +including, without limitation, the warranties of merchantability and of +fitness for any purpose. The Contributing Authors and Group 42, Inc. +assume no liability for direct, indirect, incidental, special, exemplary, +or consequential damages, which may result from the use of the PNG +Reference Library, even if advised of the possibility of such damage. + +Permission is hereby granted to use, copy, modify, and distribute this +source code, or portions hereof, for any purpose, without fee, subject +to the following restrictions: + +1. The origin of this source code must not be misrepresented. + +2. Altered versions must be plainly marked as such and must not + be misrepresented as being the original source. + +3. This Copyright notice may not be removed or altered from any + source or altered source distribution. + +The Contributing Authors and Group 42, Inc. specifically permit, without +fee, and encourage the use of this source code as a component to +supporting the PNG file format in commercial products. If you use this +source code in a product, acknowledgment is not required but would be +appreciated. + + +A "png_get_copyright" function is available, for convenient use in "about" +boxes and the like: + + printf("%s",png_get_copyright(NULL)); + +Also, the PNG logo (in PNG format, of course) is supplied in the +files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31). + +Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a +certification mark of the Open Source Initiative. + +Glenn Randers-Pehrson +glennrp at users.sourceforge.net +July 18, 2013 + + + +LibXML2 +------- +Except where otherwise noted in the source code (e.g. the files hash.c, +list.c and the trio files, which are covered by a similar licence but +with different Copyright notices) all the files are: + + Copyright (C) 1998-2012 Daniel Veillard. All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is fur- +nished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT- +NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + + + +TIFF +---- +Copyright (c) 1988-1997 Sam Leffler +Copyright (c) 1991-1997 Silicon Graphics, Inc. + +Permission to use, copy, modify, distribute, and sell this software and +its documentation for any purpose is hereby granted without fee, provided +that (i) the above copyright notices and this permission notice appear in +all copies of the software and related documentation, and (ii) the names of +Sam Leffler and Silicon Graphics may not be used in any advertising or +publicity relating to the software without the specific, prior written +permission of Sam Leffler and Silicon Graphics. + +THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + +IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +OF THIS SOFTWARE. + + + +ZLIB +---- +Copyright notice: + + (C) 1995-2013 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + +If you use the zlib library in a product, we would appreciate *not* receiving +lengthy legal documents to sign. The sources are provided for free but without +warranty of any kind. The library has been entirely written by Jean-loup +Gailly and Mark Adler; it does not include third-party code. + +If you redistribute modified sources, we would appreciate that you include in +the file ChangeLog history information documenting your changes. Please read +the FAQ for more information on the distribution of modified source versions. + + + +BOOST +----- +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + + + +mingw-std-threads +----------------- +Copyright (c) 2016, Mega Limited +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/include/yafray_constants.h b/include/yafray_constants.h index fe8adc05..23a1c699 100644 --- a/include/yafray_constants.h +++ b/include/yafray_constants.h @@ -5,7 +5,7 @@ #define __END_YAFRAY } #define PACKAGE "YafaRay" -#define VERSION "3.0.0-ALPHA2" +#define VERSION "3.0.0-ALPHA3" #if (__GNUC__ > 3) #define GCC_HASCLASSVISIBILITY From 8942b19b586b692629c919b567c4edb3fa2c12e0 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Mon, 16 May 2016 05:21:51 +0100 Subject: [PATCH 049/124] If film loaded (resumed) don't do a full first pass. More impressive and would avoid re-sampling unnecessary areas without noise in the loaded film --- src/integrators/sppm.cc | 3 ++- src/yafraycore/integrator.cc | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/integrators/sppm.cc b/src/integrators/sppm.cc index c997b3b4..1a90971a 100644 --- a/src/integrators/sppm.cc +++ b/src/integrators/sppm.cc @@ -102,7 +102,8 @@ bool SPPM::render(int numView, yafaray::imageFilm_t *image) if(scene->pass_enabled(PASS_INT_Z_DEPTH_NORM) || scene->pass_enabled(PASS_INT_MIST)) precalcDepths(); initializePPM(); // seems could integrate into the preRender - renderPass(numView, 1, 0, false, 0); + if(session.renderResumed()) renderPass(numView, 0, 0, false, 0); + else renderPass(numView, 1, 0, false, 0); std::string initialEstimate = "no"; if(PM_IRE) initialEstimate = "yes"; diff --git a/src/yafraycore/integrator.cc b/src/yafraycore/integrator.cc index b9e3dbb2..379d90b6 100644 --- a/src/yafraycore/integrator.cc +++ b/src/yafraycore/integrator.cc @@ -175,7 +175,8 @@ bool tiledIntegrator_t::render(int numView, imageFilm_t *image) preRender(); - renderPass(numView, AA_samples, 0, false, 0); + if(session.renderResumed()) renderPass(numView, 0, 0, false, 0); + else renderPass(numView, AA_samples, 0, false, 0); int acumAASamples = AA_samples; bool AAthresholdChanged = true; From f80276d9bfcead214ef1e51690591b2a2155705c Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Mon, 16 May 2016 17:54:38 +0100 Subject: [PATCH 050/124] New image film loading, more clear messages for user, tags, etc --- src/integrators/sppm.cc | 9 +++++++++ src/yafraycore/imagefilm.cc | 2 ++ src/yafraycore/integrator.cc | 10 ++++++++++ 3 files changed, 21 insertions(+) diff --git a/src/integrators/sppm.cc b/src/integrators/sppm.cc index 1a90971a..6dd17b7d 100644 --- a/src/integrators/sppm.cc +++ b/src/integrators/sppm.cc @@ -92,6 +92,15 @@ bool SPPM::render(int numView, yafaray::imageFilm_t *image) imageFilm->init(passNum); imageFilm->setAANoiseParams(AA_detect_color_noise, AA_dark_detection_type, AA_dark_threshold_factor, AA_variance_edge_size, AA_variance_pixels, AA_clamp_samples); + if(session.renderResumed()) + { + passString.clear(); + passString << "Loading film file, skipping pass 1..."; + intpb->setTag(passString.str().c_str()); + } + + Y_INFO << integratorName << ": " << passString.str() << yendl; + const camera_t* camera = scene->getCamera(); maxDepth = 0.f; diff --git a/src/yafraycore/imagefilm.cc b/src/yafraycore/imagefilm.cc index 0e9ce9d4..599573c1 100644 --- a/src/yafraycore/imagefilm.cc +++ b/src/yafraycore/imagefilm.cc @@ -417,6 +417,8 @@ int imageFilm_t::nextPass(int numView, bool adaptive_AA, std::string integratorN if(session.isInteractive()) output->flush(numView, env->getRenderPasses()); + if(session.renderResumed()) passString << "Film loaded + "; + passString << "Rendering pass " << nPass << " of " << nPasses << ", resampling " << n_resample << " pixels."; Y_INFO << integratorName << ": " << passString.str() << yendl; diff --git a/src/yafraycore/integrator.cc b/src/yafraycore/integrator.cc index 379d90b6..9d5bb8be 100644 --- a/src/yafraycore/integrator.cc +++ b/src/yafraycore/integrator.cc @@ -154,6 +154,7 @@ bool tiledIntegrator_t::render(int numView, imageFilm_t *image) Y_PARAMS << "Max. " << AA_samples + std::max(0,AA_passes-1) * AA_inc_samples << " total samples" << yendl; passString << "Rendering pass 1 of " << std::max(1, AA_passes) << "..."; + Y_INFO << passString.str() << yendl; if(intpb) intpb->setTag(passString.str().c_str()); @@ -166,6 +167,15 @@ bool tiledIntegrator_t::render(int numView, imageFilm_t *image) imageFilm->init(AA_passes); imageFilm->setAANoiseParams(AA_detect_color_noise, AA_dark_detection_type, AA_dark_threshold_factor, AA_variance_edge_size, AA_variance_pixels, AA_clamp_samples); + if(session.renderResumed()) + { + passString.clear(); + passString << "Loading film file, skipping pass 1..."; + intpb->setTag(passString.str().c_str()); + } + + Y_INFO << integratorName << ": " << passString.str() << yendl; + maxDepth = 0.f; minDepth = 1e38f; From 181248245aee2daf4dc402c19eae283f12090d34 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Mon, 16 May 2016 20:04:07 +0100 Subject: [PATCH 051/124] ImageFilm autosave/load: fixed crash if film different passes or resolution. Fixed film saved in previews. Better messages for user. --- include/core_api/imagefilm.h | 46 ++++++++++++++++++++++++++++++++++-- src/yafraycore/imagefilm.cc | 18 ++++++++++---- 2 files changed, 57 insertions(+), 7 deletions(-) diff --git a/include/core_api/imagefilm.h b/include/core_api/imagefilm.h index 4c5f3663..862b444b 100644 --- a/include/core_api/imagefilm.h +++ b/include/core_api/imagefilm.h @@ -185,9 +185,29 @@ class YAFRAYCORE_EXPORT imageFilm_t bool autoSave; // If enabled, it will autosave the Image Film at the same time as the image files bool autoLoad; // If enabled, it will load the image film from a file before start rendering, might be useful to continue interrupted renders but it has to be used with care. If it does not match exactly the scene, bad results or even crashes could happen. + struct filmload_check_t + { + int w, h, cx0, cx1, cy0, cy1; + size_t numPasses; + friend class boost::serialization::access; + template void serialize(Archive & ar, const unsigned int version) + { + ar & BOOST_SERIALIZATION_NVP(w); + ar & BOOST_SERIALIZATION_NVP(h); + ar & BOOST_SERIALIZATION_NVP(cx0); + ar & BOOST_SERIALIZATION_NVP(cx1); + ar & BOOST_SERIALIZATION_NVP(cy0); + ar & BOOST_SERIALIZATION_NVP(cy1); + ar & BOOST_SERIALIZATION_NVP(numPasses); + } + }; + + filmload_check_t filmload_check; + friend class boost::serialization::access; - template void serialize(Archive & ar, const unsigned int version) - { + template void save(Archive & ar, const unsigned int version) const + { + ar & BOOST_SERIALIZATION_NVP(filmload_check); ar & BOOST_SERIALIZATION_NVP(imagePasses); //ar & BOOST_SERIALIZATION_NVP(densityImage); //ar & BOOST_SERIALIZATION_NVP(dpimage); @@ -195,6 +215,28 @@ class YAFRAYCORE_EXPORT imageFilm_t //ar & BOOST_SERIALIZATION_NVP(splitter); //ar & BOOST_SERIALIZATION_NVP(nPass); } + template void load(Archive & ar, const unsigned int version) + { + ar & BOOST_SERIALIZATION_NVP(filmload_check); + + if(filmload_check.w != w || filmload_check.h != h || filmload_check.cx0 != cx0 || filmload_check.cx1 != cx1 || filmload_check.cy0 != cy0 || filmload_check.cy1 != cy1 || filmload_check.numPasses != imagePasses.size()) + { + Y_WARNING << "imageFilm: loading imageFilm file failed because parameters are different. Expected: w="<flush(numView, env->getRenderPasses()); if(out2) out2->flush(numView, env->getRenderPasses()); - if(autoSave) + if(autoSave && (!session.isInteractive() || (session.isInteractive() && out2))) //only save film if the session is not interactive (i.e. yafaray-xml or render into file) or else if the session is interactive and we have secondary file output. We don't want to save the film in the material/lamp/world previews or if we don't have secondary file output (both cases interactive without out2) { std::string filmPath = session.getPathImageOutput()+".film"; Y_INFO << "imageFilm: Saving film to: \"" << filmPath << "\"" << yendl; From 54e0e3dfbbf21c5de645b15426bd76aee70b2ac0 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Mon, 16 May 2016 20:04:57 +0100 Subject: [PATCH 052/124] Change to v3.0.0-ALPHA4 --- include/yafray_constants.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/yafray_constants.h b/include/yafray_constants.h index 23a1c699..c6489c0d 100644 --- a/include/yafray_constants.h +++ b/include/yafray_constants.h @@ -5,7 +5,7 @@ #define __END_YAFRAY } #define PACKAGE "YafaRay" -#define VERSION "3.0.0-ALPHA3" +#define VERSION "3.0.0-ALPHA4" #if (__GNUC__ > 3) #define GCC_HASCLASSVISIBILITY From 0177f862a3ed7d3cdda9c9e816eb58d9dc64acfb Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Tue, 17 May 2016 19:32:07 +0100 Subject: [PATCH 053/124] ImageFilm loading: make sure sampling after loading does not repeat already sampled samples (save/load sampling offset in film file) --- include/core_api/imagefilm.h | 11 +++++++++-- src/integrators/sppm.cc | 11 +++++++++-- src/yafraycore/imagefilm.cc | 1 + src/yafraycore/integrator.cc | 15 +++++++++++++-- 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/include/core_api/imagefilm.h b/include/core_api/imagefilm.h index 862b444b..cb36f02a 100644 --- a/include/core_api/imagefilm.h +++ b/include/core_api/imagefilm.h @@ -132,6 +132,8 @@ class YAFRAYCORE_EXPORT imageFilm_t int getHeight() const { return h; } int getCurrentPass() const { return nPass; } int getNumPasses() const { return nPasses; } + int getSamplingOffset() const { return samplingOffset; } + void setSamplingOffset(int offset) { samplingOffset = offset; } void setAutoSave(bool auto_save); void setAutoLoad(bool auto_load); bool imageFilmLoad(const std::string &filename, bool debugXMLformat); @@ -182,6 +184,7 @@ class YAFRAYCORE_EXPORT imageFilm_t bool premultAlpha2; //For optional secondary file output int nPasses; double accumulated_image_area_flush_time; + int samplingOffset; //To ensure sampling after loading the image film continues and does not repeat already done samples bool autoSave; // If enabled, it will autosave the Image Film at the same time as the image files bool autoLoad; // If enabled, it will load the image film from a file before start rendering, might be useful to continue interrupted renders but it has to be used with care. If it does not match exactly the scene, bad results or even crashes could happen. @@ -206,8 +209,10 @@ class YAFRAYCORE_EXPORT imageFilm_t friend class boost::serialization::access; template void save(Archive & ar, const unsigned int version) const - { + { + Y_DEBUG<<"FilmSave samplingOffset="<nextPass(numView, false, integratorName); nRefined = 0; - renderPass(numView, 1, 1 + (i-1)*1, false, i); // offset are only related to the passNum, since we alway have only one sample. + renderPass(numView, 1, acumAASamples, false, i); // offset are only related to the passNum, since we alway have only one sample. + acumAASamples += 1; Y_INFO << integratorName << ": This pass refined " << nRefined << " of " << hpNum << " pixels." << yendl; } maxDepth = 0.f; diff --git a/src/yafraycore/imagefilm.cc b/src/yafraycore/imagefilm.cc index e1ec4692..bd00226c 100644 --- a/src/yafraycore/imagefilm.cc +++ b/src/yafraycore/imagefilm.cc @@ -232,6 +232,7 @@ void imageFilm_t::init(int numPasses) completed_cnt = 0; nPass = 1; nPasses = numPasses; + samplingOffset = 0; if(autoLoad) { diff --git a/src/yafraycore/integrator.cc b/src/yafraycore/integrator.cc index 9d5bb8be..202a8b78 100644 --- a/src/yafraycore/integrator.cc +++ b/src/yafraycore/integrator.cc @@ -185,10 +185,15 @@ bool tiledIntegrator_t::render(int numView, imageFilm_t *image) preRender(); - if(session.renderResumed()) renderPass(numView, 0, 0, false, 0); + int acumAASamples = AA_samples; + + if(session.renderResumed()) + { + acumAASamples = imageFilm->getSamplingOffset(); + renderPass(numView, 0, acumAASamples, false, 0); + } else renderPass(numView, AA_samples, 0, false, 0); - int acumAASamples = AA_samples; bool AAthresholdChanged = true; int resampled_pixels = 0; @@ -219,6 +224,8 @@ bool tiledIntegrator_t::render(int numView, imageFilm_t *image) int AA_samples_mult = (int) ceilf(AA_inc_samples * AA_sample_multiplier); + Y_DEBUG << "acumAASamples="<nPhotons() == 0) { - causticMapEmpty = true; + Y_WARNING << integratorName << ": Caustic photon map enabled but empty, cannot be reused: changing to Generate mode." << yendl; + photonMapProcessing = PHOTONS_GENERATE_ONLY; } } @@ -519,24 +516,20 @@ bool photonIntegrator_t::preprocess() Y_INFO << integratorName << ": Reusing diffuse photon map from memory. If it does not match the scene you could have crashes and/or incorrect renders, USE WITH CARE!" << yendl; if(session.diffuseMap->nPhotons() == 0) { - diffuseMapEmpty = true; + Y_WARNING << integratorName << ": Diffuse photon map enabled but empty, cannot be reused: changing to Generate mode." << yendl; + photonMapProcessing = PHOTONS_GENERATE_ONLY; } } - if(usePhotonDiffuse && finalGather) + if(finalGather) { Y_INFO << integratorName << ": Reusing FG radiance photon map from memory. If it does not match the scene you could have crashes and/or incorrect renders, USE WITH CARE!" << yendl; if(session.radianceMap->nPhotons() == 0) { - fgRadianceMapEmpty = true; + Y_WARNING << integratorName << ": FG radiance photon map enabled but empty, cannot be reused: changing to Generate mode." << yendl; + photonMapProcessing = PHOTONS_GENERATE_ONLY; } } - - if(causticMapEmpty && diffuseMapEmpty && fgRadianceMapEmpty) - { - photonMapProcessing = PHOTONS_GENERATE_ONLY; - Y_WARNING << integratorName << ": all previous photon maps in memory were empty, they cannot be reused: changing to Generate mode." << yendl; - } } if(photonMapProcessing == PHOTONS_LOAD) From e9aebe6ed491d5d809671341c548844a6541175f Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Tue, 17 May 2016 20:09:34 +0100 Subject: [PATCH 055/124] Log/HTML saving: remove unnecessary warnings from log files writing process --- include/core_api/logging.h | 2 ++ src/yafraycore/imageOutput.cc | 42 ++++++++++++++++++++--------------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/include/core_api/logging.h b/include/core_api/logging.h index a0f7016e..93e3786e 100644 --- a/include/core_api/logging.h +++ b/include/core_api/logging.h @@ -98,6 +98,8 @@ class YAFRAYCORE_EXPORT yafarayLog_t void setDrawAANoiseSettings(bool draw_noise_settings) { drawAANoiseSettings = draw_noise_settings; } void setDrawRenderSettings(bool draw_render_settings) { drawRenderSettings = draw_render_settings; } + bool getSaveLog() const { return mSaveLog; } + bool getSaveHTML() const { return mSaveHTML; } bool getUseParamsBadge() { return mDrawParams; } bool isParamsBadgeTop() { return mParamsBadgeTop; } std::string getLoggingTitle() const { return mLoggingTitle; } diff --git a/src/yafraycore/imageOutput.cc b/src/yafraycore/imageOutput.cc index 9d8eccc7..00bb6ae0 100644 --- a/src/yafraycore/imageOutput.cc +++ b/src/yafraycore/imageOutput.cc @@ -161,28 +161,34 @@ void imageOutput_t::flush(int numView, const renderPasses_t *renderPasses) } } - std::string fLogName = path + base_name + "_log.txt"; - yafLog.saveTxtLog(fLogName+".tmp"); - try - { - boost::filesystem::copy_file(fLogName+".tmp",fLogName,boost::filesystem::copy_option::overwrite_if_exists); - boost::filesystem::remove(fLogName+".tmp"); - } - catch(const boost::filesystem::filesystem_error& e) + if(yafLog.getSaveLog()) { - Y_WARNING << "Output: file operation error \"" << e.what() << yendl; + std::string fLogName = path + base_name + "_log.txt"; + yafLog.saveTxtLog(fLogName+".tmp"); + try + { + boost::filesystem::copy_file(fLogName+".tmp",fLogName,boost::filesystem::copy_option::overwrite_if_exists); + boost::filesystem::remove(fLogName+".tmp"); + } + catch(const boost::filesystem::filesystem_error& e) + { + Y_WARNING << "Output: file operation error \"" << e.what() << yendl; + } } - std::string fLogHtmlName = path + base_name + "_log.html"; - yafLog.saveHtmlLog(fLogHtmlName+".tmp"); - try - { - boost::filesystem::copy_file(fLogHtmlName+".tmp",fLogHtmlName,boost::filesystem::copy_option::overwrite_if_exists); - boost::filesystem::remove(fLogHtmlName+".tmp"); - } - catch(const boost::filesystem::filesystem_error& e) + if(yafLog.getSaveHTML()) { - Y_WARNING << "Output: file operation error \"" << e.what() << yendl; + std::string fLogHtmlName = path + base_name + "_log.html"; + yafLog.saveHtmlLog(fLogHtmlName+".tmp"); + try + { + boost::filesystem::copy_file(fLogHtmlName+".tmp",fLogHtmlName,boost::filesystem::copy_option::overwrite_if_exists); + boost::filesystem::remove(fLogHtmlName+".tmp"); + } + catch(const boost::filesystem::filesystem_error& e) + { + Y_WARNING << "Output: file operation error \"" << e.what() << yendl; + } } } From b6f8b5b9d40e5c46e3de4b86fe9f00fcf1eaf8be Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Tue, 17 May 2016 20:29:57 +0100 Subject: [PATCH 056/124] Version change to v3.0.0-ALPHA5: fixed Film load resampling same samples as before, and some crashes with photon map reusing --- include/yafray_constants.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/yafray_constants.h b/include/yafray_constants.h index c6489c0d..6ea0f870 100644 --- a/include/yafray_constants.h +++ b/include/yafray_constants.h @@ -5,7 +5,7 @@ #define __END_YAFRAY } #define PACKAGE "YafaRay" -#define VERSION "3.0.0-ALPHA4" +#define VERSION "3.0.0-ALPHA5" #if (__GNUC__ > 3) #define GCC_HASCLASSVISIBILITY From d6070692b6e5691f2bb65f4bd3fe5cf3595a7624 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Wed, 18 May 2016 18:48:04 +0100 Subject: [PATCH 057/124] Remove image extension from film file, etc --- src/yafraycore/imageOutput.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/yafraycore/imageOutput.cc b/src/yafraycore/imageOutput.cc index 00bb6ae0..6d29cffb 100644 --- a/src/yafraycore/imageOutput.cc +++ b/src/yafraycore/imageOutput.cc @@ -30,7 +30,7 @@ __BEGIN_YAFRAY imageOutput_t::imageOutput_t(imageHandler_t * handle, const std::string &name, int bx, int by) : image(handle), fname(name), bX(bx), bY(by) { - session.setPathImageOutput(fname); + session.setPathImageOutput(boost::filesystem::change_extension(fname, "").string()); } imageOutput_t::imageOutput_t() From 5dc2a75e933a2e69a890e8ec55d0a8c7e9729ed4 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Wed, 18 May 2016 19:38:08 +0100 Subject: [PATCH 058/124] Save/Load photon maps from the same folder as the exported image. If no exported image use the system temporary folder (OS specific) --- src/integrators/photonintegr.cc | 38 ++++++++++++++------------------- src/yafraycore/mcintegrator.cc | 18 +++++++--------- src/yafraycore/session.cc | 5 ++++- 3 files changed, 28 insertions(+), 33 deletions(-) diff --git a/src/integrators/photonintegr.cc b/src/integrators/photonintegr.cc index 94a4f105..8e579846 100644 --- a/src/integrators/photonintegr.cc +++ b/src/integrators/photonintegr.cc @@ -464,19 +464,17 @@ bool photonIntegrator_t::preprocess() if(usePhotonCaustics) { - pb->setTag("Loading caustic photon map from temp folder..."); - std::string filename = boost::filesystem::temp_directory_path().string(); - filename += "/yafaray_photonMap_caustics.tmp"; - Y_INFO << integratorName << ": Loading caustics photon map from: " << filename << ". If it does not match the scene you could have crashes and/or incorrect renders, USE WITH CARE!" << yendl; - if(photonMapLoad(session.causticMap, filename)) Y_VERBOSE << integratorName << ": Caustics map loaded." << yendl; + pb->setTag("Loading caustic photon map from file..."); + std::string filename = session.getPathImageOutput() + "_caustic.photonmap"; + Y_INFO << integratorName << ": Loading caustic photon map from: " << filename << ". If it does not match the scene you could have crashes and/or incorrect renders, USE WITH CARE!" << yendl; + if(photonMapLoad(session.causticMap, filename)) Y_VERBOSE << integratorName << ": Caustic map loaded." << yendl; else causticMapFailedLoad = true; } if(usePhotonDiffuse) { - pb->setTag("Loading diffuse photon map from temp folder..."); - std::string filename = boost::filesystem::temp_directory_path().string(); - filename += "/yafaray_photonMap_diffuse.tmp"; + pb->setTag("Loading diffuse photon map from file..."); + std::string filename = session.getPathImageOutput() + "_diffuse.photonmap"; Y_INFO << integratorName << ": Loading diffuse photon map from: " << filename << ". If it does not match the scene you could have crashes and/or incorrect renders, USE WITH CARE!" << yendl; if(photonMapLoad(session.diffuseMap, filename)) Y_VERBOSE << integratorName << ": Diffuse map loaded." << yendl; else diffuseMapFailedLoad = true; @@ -484,9 +482,8 @@ bool photonIntegrator_t::preprocess() if(usePhotonDiffuse && finalGather) { - pb->setTag("Loading FG radiance photon map from temp folder..."); - std::string filename = boost::filesystem::temp_directory_path().string(); - filename += "/yafaray_photonMap_fg_radiance.tmp"; + pb->setTag("Loading FG radiance photon map from file..."); + std::string filename = session.getPathImageOutput() + "_fg_radiance.photonmap"; Y_INFO << integratorName << ": Loading FG radiance photon map from: " << filename << ". If it does not match the scene you could have crashes and/or incorrect renders, USE WITH CARE!" << yendl; if(photonMapLoad(session.radianceMap, filename)) Y_VERBOSE << integratorName << ": FG radiance map loaded." << yendl; else fgRadianceMapFailedLoad = true; @@ -1077,27 +1074,24 @@ bool photonIntegrator_t::preprocess() { if( usePhotonDiffuse ) { - pb->setTag("Saving diffuse photon map to temp folder..."); - std::string filename = boost::filesystem::temp_directory_path().string(); - filename += "/yafaray_photonMap_diffuse.tmp"; + pb->setTag("Saving diffuse photon map to file..."); + std::string filename = session.getPathImageOutput() + "_diffuse.photonmap"; Y_INFO << integratorName << ": Saving diffuse photon map to: " << filename << yendl; if(photonMapSave(session.diffuseMap, filename)) Y_VERBOSE << integratorName << ": Diffuse map saved." << yendl; } if( usePhotonCaustics ) { - pb->setTag("Saving caustic photon map to temp folder..."); - std::string filename = boost::filesystem::temp_directory_path().string(); - filename += "/yafaray_photonMap_caustics.tmp"; - Y_INFO << integratorName << ": Saving caustics photon map to: " << filename << yendl; - if(photonMapSave(session.causticMap, filename)) Y_VERBOSE << integratorName << ": Caustics map saved." << yendl; + pb->setTag("Saving caustic photon map to file..."); + std::string filename = session.getPathImageOutput() + "_caustic.photonmap"; + Y_INFO << integratorName << ": Saving caustic photon map to: " << filename << yendl; + if(photonMapSave(session.causticMap, filename)) Y_VERBOSE << integratorName << ": Caustic map saved." << yendl; } if( usePhotonDiffuse && finalGather ) { - pb->setTag("Saving FG radiance photon map to temp folder..."); - std::string filename = boost::filesystem::temp_directory_path().string(); - filename += "/yafaray_photonMap_fg_radiance.tmp"; + pb->setTag("Saving FG radiance photon map to file..."); + std::string filename = session.getPathImageOutput() + "_fg_radiance.photonmap"; Y_INFO << integratorName << ": Saving FG radiance photon map to: " << filename << yendl; if(photonMapSave(session.radianceMap, filename)) Y_VERBOSE << integratorName << ": FG radiance map saved." << yendl; } diff --git a/src/yafraycore/mcintegrator.cc b/src/yafraycore/mcintegrator.cc index 08ca28e2..fc0c2742 100644 --- a/src/yafraycore/mcintegrator.cc +++ b/src/yafraycore/mcintegrator.cc @@ -482,13 +482,12 @@ bool mcIntegrator_t::createCausticMap() if(photonMapProcessing == PHOTONS_LOAD) { - pb->setTag("Loading caustic photon map from temp folder..."); - std::string filename = boost::filesystem::temp_directory_path().string(); - filename += "/yafaray_photonMap_caustics.tmp"; - Y_INFO << integratorName << ": Loading caustics photon map from: " << filename << ". If it does not match the scene you could have crashes and/or incorrect renders, USE WITH CARE!" << yendl; + pb->setTag("Loading caustic photon map from file..."); + std::string filename = session.getPathImageOutput() + "_caustic.photonmap"; + Y_INFO << integratorName << ": Loading caustic photon map from: " << filename << ". If it does not match the scene you could have crashes and/or incorrect renders, USE WITH CARE!" << yendl; if(photonMapLoad(session.causticMap, filename)) { - Y_VERBOSE << integratorName << ": Caustics map loaded." << yendl; + Y_VERBOSE << integratorName << ": Caustic map loaded." << yendl; return true; } else @@ -708,11 +707,10 @@ bool mcIntegrator_t::createCausticMap() if(photonMapProcessing == PHOTONS_GENERATE_AND_SAVE) { - pb->setTag("Saving caustic photon map to temp folder..."); - std::string filename = boost::filesystem::temp_directory_path().string(); - filename += "/yafaray_photonMap_caustics.tmp"; - Y_INFO << integratorName << ": Saving caustics photon map to: " << filename << yendl; - if(photonMapSave(session.causticMap, filename)) Y_VERBOSE << integratorName << ": Caustics map saved." << yendl; + pb->setTag("Saving caustic photon map to file..."); + std::string filename = session.getPathImageOutput() + "_caustic.photonmap"; + Y_INFO << integratorName << ": Saving caustic photon map to: " << filename << yendl; + if(photonMapSave(session.causticMap, filename)) Y_VERBOSE << integratorName << ": Caustic map saved." << yendl; } if(!intpb) delete pb; diff --git a/src/yafraycore/session.cc b/src/yafraycore/session.cc index cac6e284..03d0c282 100644 --- a/src/yafraycore/session.cc +++ b/src/yafraycore/session.cc @@ -20,6 +20,7 @@ */ #include #include +#include #include __BEGIN_YAFRAY @@ -189,7 +190,9 @@ std::string session_t::getPathYafaRayXml() std::string session_t::getPathImageOutput() { - return mPathImageOutput; + if(mPathImageOutput.empty()) return boost::filesystem::temp_directory_path().string()+"/yafaray"; //if no image output folder was specified, use the system temporary folder + else return mPathImageOutput; + } __END_YAFRAY From 9c1ea0c4bb5cc7f635d0ea9ec03bd020662b123a Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Wed, 18 May 2016 20:20:24 +0100 Subject: [PATCH 059/124] New: base sampling offset, first step for multi-computer film generation --- include/core_api/imagefilm.h | 9 ++++++--- src/yafraycore/environment.cc | 5 +++++ src/yafraycore/imagefilm.cc | 1 - src/yafraycore/integrator.cc | 12 ++++++------ 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/include/core_api/imagefilm.h b/include/core_api/imagefilm.h index cb36f02a..82ff8d20 100644 --- a/include/core_api/imagefilm.h +++ b/include/core_api/imagefilm.h @@ -132,8 +132,10 @@ class YAFRAYCORE_EXPORT imageFilm_t int getHeight() const { return h; } int getCurrentPass() const { return nPass; } int getNumPasses() const { return nPasses; } - int getSamplingOffset() const { return samplingOffset; } - void setSamplingOffset(int offset) { samplingOffset = offset; } + unsigned int getBaseSamplingOffset() const { return baseSamplingOffset; } + unsigned int getSamplingOffset() const { return samplingOffset; } + void setBaseSamplingOffset(unsigned int offset) { baseSamplingOffset = offset; } + void setSamplingOffset(unsigned int offset) { samplingOffset = offset; } void setAutoSave(bool auto_save); void setAutoLoad(bool auto_load); bool imageFilmLoad(const std::string &filename, bool debugXMLformat); @@ -184,7 +186,8 @@ class YAFRAYCORE_EXPORT imageFilm_t bool premultAlpha2; //For optional secondary file output int nPasses; double accumulated_image_area_flush_time; - int samplingOffset; //To ensure sampling after loading the image film continues and does not repeat already done samples + unsigned int baseSamplingOffset = 0; //Base sampling offset, in case of multi-computer rendering each should have a different offset so they don't "repeat" the same samples (user configurable) + unsigned int samplingOffset = 0; //To ensure sampling after loading the image film continues and does not repeat already done samples bool autoSave; // If enabled, it will autosave the Image Film at the same time as the image files bool autoLoad; // If enabled, it will load the image film from a file before start rendering, might be useful to continue interrupted renders but it has to be used with care. If it does not match exactly the scene, bad results or even crashes could happen. diff --git a/src/yafraycore/environment.cc b/src/yafraycore/environment.cc index 34df4f60..64f79928 100644 --- a/src/yafraycore/environment.cc +++ b/src/yafraycore/environment.cc @@ -755,6 +755,7 @@ bool renderEnvironment_t::setupScene(scene_t &scene, const paraMap_t ¶ms, co float adv_shadow_bias_value=YAF_SHADOW_BIAS; bool adv_auto_min_raydist_enabled=true; float adv_min_raydist_value=MIN_RAYDIST; + int adv_base_sampling_offset = 0; if(! params.getParam("camera_name", name) ) { @@ -822,6 +823,7 @@ bool renderEnvironment_t::setupScene(scene_t &scene, const paraMap_t ¶ms, co params.getParam("adv_shadow_bias_value", adv_shadow_bias_value); params.getParam("adv_auto_min_raydist_enabled", adv_auto_min_raydist_enabled); params.getParam("adv_min_raydist_value", adv_min_raydist_value); + params.getParam("adv_base_sampling_offset", adv_base_sampling_offset); //Base sampling offset, in case of multi-computer rendering each should have a different offset so they don't "repeat" the same samples (user configurable) imageFilm_t *film = createImageFilm(params, output); @@ -854,6 +856,9 @@ bool renderEnvironment_t::setupScene(scene_t &scene, const paraMap_t ¶ms, co scene.rayMinDistAuto = adv_auto_min_raydist_enabled; scene.rayMinDist = adv_min_raydist_value; + Y_DEBUG << "adv_base_sampling_offset="<setBaseSamplingOffset(adv_base_sampling_offset); + return true; } diff --git a/src/yafraycore/imagefilm.cc b/src/yafraycore/imagefilm.cc index bd00226c..e1ec4692 100644 --- a/src/yafraycore/imagefilm.cc +++ b/src/yafraycore/imagefilm.cc @@ -232,7 +232,6 @@ void imageFilm_t::init(int numPasses) completed_cnt = 0; nPass = 1; nPasses = numPasses; - samplingOffset = 0; if(autoLoad) { diff --git a/src/yafraycore/integrator.cc b/src/yafraycore/integrator.cc index 202a8b78..d12f8b29 100644 --- a/src/yafraycore/integrator.cc +++ b/src/yafraycore/integrator.cc @@ -251,14 +251,14 @@ bool tiledIntegrator_t::render(int numView, imageFilm_t *image) bool tiledIntegrator_t::renderPass(int numView, int samples, int offset, bool adaptive, int AA_pass_number) { - Y_DEBUG << "Sampling: samples="< void serialize(Archive & ar, const unsigned int version) { @@ -205,17 +209,23 @@ class YAFRAYCORE_EXPORT imageFilm_t ar & BOOST_SERIALIZATION_NVP(cy0); ar & BOOST_SERIALIZATION_NVP(cy1); ar & BOOST_SERIALIZATION_NVP(numPasses); + ar & BOOST_SERIALIZATION_NVP(filmStructureVersion); } }; + //IMPORTANT: change the FILM_STRUCTURE_VERSION string if there are significant changes in the film structure + #define FILM_STRUCTURE_VERSION "1.0" + filmload_check_t filmload_check; friend class boost::serialization::access; template void save(Archive & ar, const unsigned int version) const { - Y_DEBUG<<"FilmSave samplingOffset="<setAutoLoad(film_load); - if(film_autosave) Y_INFO_ENV << "Enabling imageFilm AutoLoad feature. It will load the image film from a file before start rendering. If it does not match exactly the scene, bad results or even crashes could happen. Use WITH CARE!" << yendl; + if(film_load) Y_INFO_ENV << "Enabling imageFilm AutoLoad feature. It will load the image film from a file before start rendering. If it does not match exactly the scene, bad results or even crashes could happen. Use WITH CARE!" << yendl; return film; } @@ -756,6 +756,7 @@ bool renderEnvironment_t::setupScene(scene_t &scene, const paraMap_t ¶ms, co bool adv_auto_min_raydist_enabled=true; float adv_min_raydist_value=MIN_RAYDIST; int adv_base_sampling_offset = 0; + int adv_computer_node = 0; if(! params.getParam("camera_name", name) ) { @@ -824,7 +825,7 @@ bool renderEnvironment_t::setupScene(scene_t &scene, const paraMap_t ¶ms, co params.getParam("adv_auto_min_raydist_enabled", adv_auto_min_raydist_enabled); params.getParam("adv_min_raydist_value", adv_min_raydist_value); params.getParam("adv_base_sampling_offset", adv_base_sampling_offset); //Base sampling offset, in case of multi-computer rendering each should have a different offset so they don't "repeat" the same samples (user configurable) - + params.getParam("adv_computer_node", adv_computer_node); //Computer node in multi-computer render environments/render farms imageFilm_t *film = createImageFilm(params, output); if (pb) @@ -858,6 +859,7 @@ bool renderEnvironment_t::setupScene(scene_t &scene, const paraMap_t ¶ms, co Y_DEBUG << "adv_base_sampling_offset="<setBaseSamplingOffset(adv_base_sampling_offset); + film->setComputerNode(adv_computer_node); return true; } diff --git a/src/yafraycore/imagefilm.cc b/src/yafraycore/imagefilm.cc index e1ec4692..e3e3423e 100644 --- a/src/yafraycore/imagefilm.cc +++ b/src/yafraycore/imagefilm.cc @@ -37,6 +37,10 @@ #include #include #include +#include +#define BOOST_RANGE_ENABLE_CONCEPT_ASSERT 0 +#include +#include #if HAVE_FREETYPE #include @@ -235,22 +239,51 @@ void imageFilm_t::init(int numPasses) if(autoLoad) { - std::string filmPath = session.getPathImageOutput()+".film"; - std::string filmPathBackup = filmPath+"-previous.bak"; - Y_INFO << "imageFilm: Loading film from: \"" << filmPath << "\"" << yendl; - this->imageFilmLoad(filmPath, false); - Y_VERBOSE << "imageFilm: Making backup of previously saved film to: \"" << filmPathBackup << "\"" << yendl; - try - { - boost::filesystem::copy_file(filmPath, filmPathBackup, boost::filesystem::copy_option::overwrite_if_exists); - } - catch(const boost::filesystem::filesystem_error& e) + std::string filmPath = session.getPathImageOutput(); + std::stringstream node; + node << std::setfill('0') << std::setw(4) << computerNode; + filmPath += " - node " + node.str(); + filmPath += ".film"; + + //http://stackoverflow.com/questions/1257721/can-i-use-a-mask-to-iterate-files-in-a-directory-with-boost + //Thanks to http://stackoverflow.com/users/148405/oleg-svechkarenko for this code + + const std::string target_path( session.getPathImageOutput() ); + const boost::regex my_filter( ".*\\.film$" ); + boost::smatch what; + + for (auto &entry: boost::make_iterator_range(boost::filesystem::directory_iterator(boost::filesystem::path(target_path).parent_path()), {}) + | boost::adaptors::filtered(static_cast(&boost::filesystem::is_regular_file)) + | boost::adaptors::filtered([&](const boost::filesystem::path &path){ return boost::regex_match(path.filename().string(), what, my_filter); }) + ) { - Y_WARNING << "imageFilm: error during imageFilm file backup \"" << e.what() << "\"" << yendl; + std::string loadedFilmPath = entry.path().string(); + Y_INFO << "imageFilm: Loading film from: \"" << loadedFilmPath << "\"" << yendl; + imageFilm_t *loadedFilm = new imageFilm_t(w, h, cx0, cy0, *output, 1.0, BOX, env); + loadedFilm->imageFilmLoad(loadedFilmPath, false); + + for(size_t idx=0; idximagePasses[idx]; + (*imagePasses[idx])(i,j).col += (*loadedImageBuffer)(i,j).col; + (*imagePasses[idx])(i,j).weight += (*loadedImageBuffer)(i,j).weight; + } + } + } + + if(samplingOffset < loadedFilm->samplingOffset) samplingOffset = loadedFilm->samplingOffset; + if(baseSamplingOffset < loadedFilm->baseSamplingOffset) baseSamplingOffset = loadedFilm->baseSamplingOffset; + + delete loadedFilm; } } //film load check data initialization + filmload_check.filmStructureVersion = FILM_STRUCTURE_VERSION; filmload_check.w = w; filmload_check.h = h; filmload_check.cx0 = cx0; @@ -602,7 +635,11 @@ void imageFilm_t::flush(int numView, int flags, colorOutput_t *out) ssBadge << " | " << w << "x" << h; if(session.renderInProgress()) ssBadge << " | " << (session.renderResumed() ? "film loaded + " : "") << "in progress " << std::fixed << std::setprecision(1) << session.currentPassPercent() << "% of pass: " << session.currentPass() << " / " << session.totalPasses(); else if(session.renderAborted()) ssBadge << " | " << (session.renderResumed() ? "film loaded + " : "") << "stopped at " << std::fixed << std::setprecision(1) << session.currentPassPercent() << "% of pass: " << session.currentPass() << " / " << session.totalPasses(); - else ssBadge << " | " << (session.renderResumed() ? "film loaded + " : "") << session.totalPasses() << " passes"; + else + { + if(session.renderResumed()) ssBadge << " | film loaded + " << session.totalPasses()-1 << " passes"; + else ssBadge << " | " << session.totalPasses() << " passes"; + } //if(cx0 != 0) ssBadge << ", xstart=" << cx0; //if(cy0 != 0) ssBadge << ", ystart=" << cy0; ssBadge << " | Render time:"; @@ -757,7 +794,25 @@ void imageFilm_t::flush(int numView, int flags, colorOutput_t *out) if(autoSave && (!session.isInteractive() || (session.isInteractive() && out2))) //only save film if the session is not interactive (i.e. yafaray-xml or render into file) or else if the session is interactive and we have secondary file output. We don't want to save the film in the material/lamp/world previews or if we don't have secondary file output (both cases interactive without out2) { - std::string filmPath = session.getPathImageOutput()+".film"; + std::string filmPath = session.getPathImageOutput(); + std::stringstream node; + node << std::setfill('0') << std::setw(4) << computerNode; + filmPath += " - node " + node.str(); + filmPath += ".film"; + std::string filmPathBackup = filmPath+"-previous.bak"; + + if(boost::filesystem::exists(filmPath)) + { + Y_VERBOSE << "imageFilm: Making backup of previously saved film to: \"" << filmPathBackup << "\"" << yendl; + try + { + boost::filesystem::copy_file(filmPath, filmPathBackup, boost::filesystem::copy_option::overwrite_if_exists); + } + catch(const boost::filesystem::filesystem_error& e) + { + Y_WARNING << "imageFilm: error during imageFilm file backup \"" << e.what() << "\"" << yendl; + } + } Y_INFO << "imageFilm: Saving film to: \"" << filmPath << "\"" << yendl; this->imageFilmSave(filmPath, false); Y_VERBOSE << "imageFilm: Saved film to: \"" << filmPath << "\"" << yendl; @@ -1175,22 +1230,18 @@ bool imageFilm_t::imageFilmLoad(const std::string &filename, bool debugXMLformat if(debugXMLformat) { boost::archive::xml_iarchive ia(ifs); - //map->clear(); //FIXME DAVID ia >> BOOST_SERIALIZATION_NVP(*this); ifs.close(); } else { boost::archive::binary_iarchive ia(ifs); - //map->clear(); //FIXME DAVID ia >> BOOST_SERIALIZATION_NVP(*this); ifs.close(); } return true; } catch(std::exception& ex){ - // elminate any dangling references - //map->clear(); //FIXME DAVID Y_WARNING << "imageFilm: error '" << ex.what() << "' while loading ImageFilm file: '" << filename << "'" << yendl; return false; } diff --git a/src/yafraycore/integrator.cc b/src/yafraycore/integrator.cc index d12f8b29..6e2fcb92 100644 --- a/src/yafraycore/integrator.cc +++ b/src/yafraycore/integrator.cc @@ -367,12 +367,14 @@ bool tiledIntegrator_t::renderTile(int numView, renderArea_t &a, int n_samples, dx = (0.5+(PFLOAT)sample)*d1; dy = RI_LP(sample+rstate.samplingOffs); } + if(sampleLns) { lens_u = halU.getNext(); lens_v = halV.getNext(); } c_ray = camera->shootRay(j+dx, i+dy, lens_u, lens_v, wt); + if(wt==0.0) { imageFilm->addSample(tmpPassesZero, j, i, dx, dy, &a, sample, AA_pass_number, inv_AA_max_possible_samples); From 062432bda74567ddcbe6d266f768455abac5d1a9 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sat, 21 May 2016 09:50:27 +0100 Subject: [PATCH 061/124] Version change to v3.0.0-ALPHA6 --- include/yafray_constants.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/yafray_constants.h b/include/yafray_constants.h index 6ea0f870..171af946 100644 --- a/include/yafray_constants.h +++ b/include/yafray_constants.h @@ -5,7 +5,7 @@ #define __END_YAFRAY } #define PACKAGE "YafaRay" -#define VERSION "3.0.0-ALPHA5" +#define VERSION "3.0.0-ALPHA6" #if (__GNUC__ > 3) #define GCC_HASCLASSVISIBILITY From 4e345ee8eaa543a0c6f0779aa775b6e1cfa4dcba Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sat, 21 May 2016 10:09:07 +0100 Subject: [PATCH 062/124] Added license information for one of the boost-regex dependencies --- LICENSES | 397 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 397 insertions(+) diff --git a/LICENSES b/LICENSES index acac0109..643db743 100644 --- a/LICENSES +++ b/LICENSES @@ -1923,3 +1923,400 @@ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +icu (dependency of boost-regex) +------------------------------- +ICU License - ICU 1.8.1 and later + +COPYRIGHT AND PERMISSION NOTICE + +Copyright (c) 1995-2016 International Business Machines Corporation and others + +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, and/or sell copies of the Software, and to permit persons +to whom the Software is furnished to do so, provided that the above +copyright notice(s) and this permission notice appear in all copies of +the Software and that both the above copyright notice(s) and this +permission notice appear in supporting documentation. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY +SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER +RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF +CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +Except as contained in this notice, the name of a copyright holder +shall not be used in advertising or otherwise to promote the sale, use +or other dealings in this Software without prior written authorization +of the copyright holder. + + +All trademarks and registered trademarks mentioned herein are the +property of their respective owners. + +--------------------- + +Third-Party Software Licenses + +This section contains third-party software notices and/or additional +terms for licensed third-party software components included within ICU +libraries. + +1. Unicode Data Files and Software + +COPYRIGHT AND PERMISSION NOTICE + +Copyright ยฉ 1991-2016 Unicode, Inc. All rights reserved. +Distributed under the Terms of Use in +http://www.unicode.org/copyright.html. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Unicode data files and any associated documentation +(the "Data Files") or Unicode software and any associated documentation +(the "Software") to deal in the Data Files or Software +without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, and/or sell copies of +the Data Files or Software, and to permit persons to whom the Data Files +or Software are furnished to do so, provided that +(a) this copyright and permission notice appear with all copies +of the Data Files or Software, +(b) this copyright and permission notice appear in associated +documentation, and +(c) there is clear notice in each modified Data File or in the Software +as well as in the documentation associated with the Data File(s) or +Software that the data or software has been modified. + +THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT OF THIRD PARTY RIGHTS. +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS +NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL +DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THE DATA FILES OR SOFTWARE. + +Except as contained in this notice, the name of a copyright holder +shall not be used in advertising or otherwise to promote the sale, +use or other dealings in these Data Files or Software without prior +written authorization of the copyright holder. + +2. Chinese/Japanese Word Break Dictionary Data (cjdict.txt) + + # The Google Chrome software developed by Google is licensed under + # the BSD license. Other software included in this distribution is + # provided under other licenses, as set forth below. + # + # The BSD License + # http://opensource.org/licenses/bsd-license.php + # Copyright (C) 2006-2008, Google Inc. + # + # All rights reserved. + # + # Redistribution and use in source and binary forms, with or without + # modification, are permitted provided that the following conditions are met: + # + # Redistributions of source code must retain the above copyright notice, + # this list of conditions and the following disclaimer. + # Redistributions in binary form must reproduce the above + # copyright notice, this list of conditions and the following + # disclaimer in the documentation and/or other materials provided with + # the distribution. + # Neither the name of Google Inc. nor the names of its + # contributors may be used to endorse or promote products derived from + # this software without specific prior written permission. + # + # + # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + # CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + # BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + # + # + # The word list in cjdict.txt are generated by combining three word lists + # listed below with further processing for compound word breaking. The + # frequency is generated with an iterative training against Google web + # corpora. + # + # * Libtabe (Chinese) + # - https://sourceforge.net/project/?group_id=1519 + # - Its license terms and conditions are shown below. + # + # * IPADIC (Japanese) + # - http://chasen.aist-nara.ac.jp/chasen/distribution.html + # - Its license terms and conditions are shown below. + # + # ---------COPYING.libtabe ---- BEGIN-------------------- + # + # /* + # * Copyrighy (c) 1999 TaBE Project. + # * Copyright (c) 1999 Pai-Hsiang Hsiao. + # * All rights reserved. + # * + # * Redistribution and use in source and binary forms, with or without + # * modification, are permitted provided that the following conditions + # * are met: + # * + # * . Redistributions of source code must retain the above copyright + # * notice, this list of conditions and the following disclaimer. + # * . Redistributions in binary form must reproduce the above copyright + # * notice, this list of conditions and the following disclaimer in + # * the documentation and/or other materials provided with the + # * distribution. + # * . Neither the name of the TaBE Project nor the names of its + # * contributors may be used to endorse or promote products derived + # * from this software without specific prior written permission. + # * + # * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + # * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + # * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + # * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + # * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + # * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + # * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + # * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + # * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + # * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + # * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + # * OF THE POSSIBILITY OF SUCH DAMAGE. + # */ + # + # /* + # * Copyright (c) 1999 Computer Systems and Communication Lab, + # * Institute of Information Science, Academia + # * Sinica. All rights reserved. + # * + # * Redistribution and use in source and binary forms, with or without + # * modification, are permitted provided that the following conditions + # * are met: + # * + # * . Redistributions of source code must retain the above copyright + # * notice, this list of conditions and the following disclaimer. + # * . Redistributions in binary form must reproduce the above copyright + # * notice, this list of conditions and the following disclaimer in + # * the documentation and/or other materials provided with the + # * distribution. + # * . Neither the name of the Computer Systems and Communication Lab + # * nor the names of its contributors may be used to endorse or + # * promote products derived from this software without specific + # * prior written permission. + # * + # * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + # * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + # * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + # * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + # * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + # * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + # * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + # * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + # * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + # * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + # * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + # * OF THE POSSIBILITY OF SUCH DAMAGE. + # */ + # + # Copyright 1996 Chih-Hao Tsai @ Beckman Institute, + # University of Illinois + # c-tsai4@uiuc.edu http://casper.beckman.uiuc.edu/~c-tsai4 + # + # ---------------COPYING.libtabe-----END-------------------------------- + # + # + # ---------------COPYING.ipadic-----BEGIN------------------------------- + # + # Copyright 2000, 2001, 2002, 2003 Nara Institute of Science + # and Technology. All Rights Reserved. + # + # Use, reproduction, and distribution of this software is permitted. + # Any copy of this software, whether in its original form or modified, + # must include both the above copyright notice and the following + # paragraphs. + # + # Nara Institute of Science and Technology (NAIST), + # the copyright holders, disclaims all warranties with regard to this + # software, including all implied warranties of merchantability and + # fitness, in no event shall NAIST be liable for + # any special, indirect or consequential damages or any damages + # whatsoever resulting from loss of use, data or profits, whether in an + # action of contract, negligence or other tortuous action, arising out + # of or in connection with the use or performance of this software. + # + # A large portion of the dictionary entries + # originate from ICOT Free Software. The following conditions for ICOT + # Free Software applies to the current dictionary as well. + # + # Each User may also freely distribute the Program, whether in its + # original form or modified, to any third party or parties, PROVIDED + # that the provisions of Section 3 ("NO WARRANTY") will ALWAYS appear + # on, or be attached to, the Program, which is distributed substantially + # in the same form as set out herein and that such intended + # distribution, if actually made, will neither violate or otherwise + # contravene any of the laws and regulations of the countries having + # jurisdiction over the User or the intended distribution itself. + # + # NO WARRANTY + # + # The program was produced on an experimental basis in the course of the + # research and development conducted during the project and is provided + # to users as so produced on an experimental basis. Accordingly, the + # program is provided without any warranty whatsoever, whether express, + # implied, statutory or otherwise. The term "warranty" used herein + # includes, but is not limited to, any warranty of the quality, + # performance, merchantability and fitness for a particular purpose of + # the program and the nonexistence of any infringement or violation of + # any right of any third party. + # + # Each user of the program will agree and understand, and be deemed to + # have agreed and understood, that there is no warranty whatsoever for + # the program and, accordingly, the entire risk arising from or + # otherwise connected with the program is assumed by the user. + # + # Therefore, neither ICOT, the copyright holder, or any other + # organization that participated in or was otherwise related to the + # development of the program and their respective officials, directors, + # officers and other employees shall be held liable for any and all + # damages, including, without limitation, general, special, incidental + # and consequential damages, arising out of or otherwise in connection + # with the use or inability to use the program or any product, material + # or result produced or otherwise obtained by using the program, + # regardless of whether they have been advised of, or otherwise had + # knowledge of, the possibility of such damages at any time during the + # project or thereafter. Each user will be deemed to have agreed to the + # foregoing by his or her commencement of use of the program. The term + # "use" as used herein includes, but is not limited to, the use, + # modification, copying and distribution of the program and the + # production of secondary products from the program. + # + # In the case where the program, whether in its original form or + # modified, was distributed or delivered to or received by a user from + # any person, organization or entity other than ICOT, unless it makes or + # grants independently of ICOT any specific warranty to the user in + # writing, such person, organization or entity, will also be exempted + # from and not be held liable to the user for any such damages as noted + # above as far as the program is concerned. + # + # ---------------COPYING.ipadic-----END---------------------------------- + +3. Lao Word Break Dictionary Data (laodict.txt) + + # Copyright (c) 2013 International Business Machines Corporation + # and others. All Rights Reserved. + # + # Project: http://code.google.com/p/lao-dictionary/ + # Dictionary: http://lao-dictionary.googlecode.com/git/Lao-Dictionary.txt + # License: http://lao-dictionary.googlecode.com/git/Lao-Dictionary-LICENSE.txt + # (copied below) + # + # This file is derived from the above dictionary, with slight + # modifications. + # ---------------------------------------------------------------------- + # Copyright (C) 2013 Brian Eugene Wilson, Robert Martin Campbell. + # All rights reserved. + # + # Redistribution and use in source and binary forms, with or without + # modification, + # are permitted provided that the following conditions are met: + # + # + # Redistributions of source code must retain the above copyright notice, this + # list of conditions and the following disclaimer. Redistributions in + # binary form must reproduce the above copyright notice, this list of + # conditions and the following disclaimer in the documentation and/or + # other materials provided with the distribution. + # + # + # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + # OF THE POSSIBILITY OF SUCH DAMAGE. + # -------------------------------------------------------------------------- + +4. Burmese Word Break Dictionary Data (burmesedict.txt) + + # Copyright (c) 2014 International Business Machines Corporation + # and others. All Rights Reserved. + # + # This list is part of a project hosted at: + # github.com/kanyawtech/myanmar-karen-word-lists + # + # -------------------------------------------------------------------------- + # Copyright (c) 2013, LeRoy Benjamin Sharon + # All rights reserved. + # + # Redistribution and use in source and binary forms, with or without + # modification, are permitted provided that the following conditions + # are met: Redistributions of source code must retain the above + # copyright notice, this list of conditions and the following + # disclaimer. Redistributions in binary form must reproduce the + # above copyright notice, this list of conditions and the following + # disclaimer in the documentation and/or other materials provided + # with the distribution. + # + # Neither the name Myanmar Karen Word Lists, nor the names of its + # contributors may be used to endorse or promote products derived + # from this software without specific prior written permission. + # + # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + # CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS + # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + # TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + # TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + # THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + # SUCH DAMAGE. + # -------------------------------------------------------------------------- + +5. Time Zone Database + + ICU uses the public domain data and code derived from Time Zone +Database for its time zone support. The ownership of the TZ database +is explained in BCP 175: Procedure for Maintaining the Time Zone +Database section 7. + + # 7. Database Ownership + # + # The TZ database itself is not an IETF Contribution or an IETF + # document. Rather it is a pre-existing and regularly updated work + # that is in the public domain, and is intended to remain in the + # public domain. Therefore, BCPs 78 [RFC5378] and 79 [RFC3979] do + # not apply to the TZ Database or contributions that individuals make + # to it. Should any claims be made and substantiated against the TZ + # Database, the organization that is providing the IANA + # Considerations defined in this RFC, under the memorandum of + # understanding with the IETF, currently ICANN, may act in accordance + # with all competent court orders. No ownership claims will be made + # by ICANN or the IETF Trust on the database or the code. Any person + # making a contribution to the database or code waives all rights to + # future claims in that contribution or in the TZ Database. From ec176a579cd958ffab37fbe5c7bb4e153f475231 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sun, 22 May 2016 12:22:10 +0100 Subject: [PATCH 063/124] Fix weird exception in Film Load due to boost::regex. Removing boost::regex and all dependencies and replacing by C++11 std::regex Also removing the ICU dependencies and licenses --- AUTHORS | 0 CMakeConfig/CPackConfig.txt | 0 CMakeConfig/GenConfHeaders.txt | 0 CMakeConfig/UserConfig.template | 0 CMakeConfig/templates/yaf_revision.h.cmake | 0 CMakeConfig/templates/yafray_config.h.cmake | 0 CMakeLists.txt | 2 +- CMakeModules/FindOpenEXR.cmake | 0 CMakeModules/FindYafPythonLibs.cmake | 0 CMakeModules/FindYafSWIG.cmake | 0 CMakeModules/UseYafSWIG.cmake | 0 CODING | 0 INSTALL | 0 LICENSES | 398 ------------------ README | 0 include/cameras/angularCamera.h | 0 include/cameras/architectCamera.h | 0 include/cameras/orthographicCamera.h | 0 include/cameras/perspectiveCamera.h | 0 include/core_api/background.h | 0 include/core_api/bound.h | 0 include/core_api/camera.h | 0 include/core_api/color.h | 0 include/core_api/color_console.h | 0 include/core_api/environment.h | 0 include/core_api/imagefilm.h | 0 include/core_api/imagehandler.h | 0 include/core_api/imagesplitter.h | 0 include/core_api/integrator.h | 0 include/core_api/light.h | 0 include/core_api/logging.h | 0 include/core_api/material.h | 0 include/core_api/matrix4.h | 0 include/core_api/mcintegrator.h | 0 include/core_api/object3d.h | 0 include/core_api/output.h | 0 include/core_api/params.h | 0 include/core_api/primitive.h | 0 include/core_api/ray.h | 0 include/core_api/renderpasses.h | 0 include/core_api/sampling.h | 0 include/core_api/scene.h | 0 include/core_api/session.h | 0 include/core_api/shader.h | 0 include/core_api/surface.h | 0 include/core_api/sysinfo.h | 0 include/core_api/texture.h | 0 include/core_api/tiledintegrator.h | 0 include/core_api/vector3d.h | 0 include/core_api/volume.h | 0 include/core_api/yafsystem.h | 0 include/integrators/integr_utils.h | 0 include/integrators/photonintegr.h | 0 include/integrators/sppm.h | 0 include/interface/xmlinterface.h | 0 include/interface/yafrayinterface.h | 0 include/lights/arealight.h | 0 include/lights/bglight.h | 0 include/lights/bgportallight.h | 0 include/lights/meshlight.h | 0 include/materials/blendmat.h | 0 include/materials/maskmat.h | 0 include/materials/microfacet.h | 0 include/materials/roughglass.h | 0 include/materials/shinydiff.h | 0 include/resources/guifont.h | 0 include/resources/yafLogoTiny.h | 0 include/resources/yafarayicon.h | 0 include/textures/basicnodes.h | 0 include/textures/basictex.h | 0 include/textures/imagetex.h | 0 include/textures/layernode.h | 0 include/textures/noise.h | 0 include/utilities/ColorConv.h | 0 include/utilities/buffer.h | 0 include/utilities/console_utils.h | 0 include/utilities/curveUtils.h | 0 include/utilities/geometry.h | 0 include/utilities/iesUtils.h | 0 include/utilities/image_buffers.h | 0 include/utilities/interpolation.h | 0 include/utilities/mathOptimizations.h | 0 include/utilities/math_utils.h | 0 include/utilities/mcqmc.h | 0 include/utilities/mingw-std-threads/LICENSE | 0 include/utilities/mingw-std-threads/README.md | 0 .../mingw.condition_variable.h | 0 .../utilities/mingw-std-threads/mingw.mutex.h | 0 .../mingw-std-threads/mingw.thread.h | 0 .../mingw-std-threads/tests/CMakeLists.txt | 0 .../mingw-std-threads/tests/tests.cpp | 0 include/utilities/sample_utils.h | 0 include/utilities/spectralData.h | 0 include/utilities/stringUtils.h | 0 include/utilities/tiled_array.h | 0 include/utilities/winunistd.h | 0 include/utilities/y_alloc.h | 0 include/yafray_constants.h | 0 include/yafraycore/hashgrid.h | 0 include/yafraycore/image.h | 0 include/yafraycore/imageOutput.h | 0 include/yafraycore/kdtree.h | 0 include/yafraycore/memoryIO.h | 0 include/yafraycore/meshtypes.h | 0 include/yafraycore/monitor.h | 0 include/yafraycore/nodematerial.h | 0 include/yafraycore/octree.h | 0 include/yafraycore/photon.h | 0 include/yafraycore/pkdtree.h | 0 include/yafraycore/ray_kdtree.h | 0 include/yafraycore/scr_halton.h | 0 include/yafraycore/spectrum.h | 0 include/yafraycore/std_primitives.h | 0 include/yafraycore/timer.h | 0 include/yafraycore/triangle.h | 0 include/yafraycore/triangle_inline.h | 0 include/yafraycore/xmlparser.h | 0 src/CMakeLists.txt | 0 src/backgrounds/CMakeLists.txt | 0 src/backgrounds/darksky.cc | 0 src/backgrounds/gradientback.cc | 0 src/backgrounds/sunsky.cc | 0 src/backgrounds/sunspectrum.cc | 0 src/backgrounds/textureback.cc | 0 src/bindings/CMakeLists.txt | 0 src/bindings/yafaray_v3_interface.i | 0 src/cameras/CMakeLists.txt | 0 src/cameras/angularCamera.cc | 0 src/cameras/architectCamera.cc | 0 src/cameras/orthographicCamera.cc | 0 src/cameras/perspectiveCamera.cc | 0 src/image_handlers/CMakeLists.txt | 0 src/image_handlers/exrHandler.cc | 0 src/image_handlers/hdrHandler.cc | 0 src/image_handlers/hdrUtils.h | 0 src/image_handlers/jpgHandler.cc | 0 src/image_handlers/pngHandler.cc | 0 src/image_handlers/pngUtils.h | 0 src/image_handlers/tgaHandler.cc | 0 src/image_handlers/tgaUtils.h | 0 src/image_handlers/tifHandler.cc | 0 src/integrators/CMakeLists.txt | 0 src/integrators/DebugIntegrator.cc | 0 src/integrators/EmissionIntegrator.cc | 0 src/integrators/EmptyVolumeIntegrator.cc | 0 src/integrators/SingleScatterIntegrator.cc | 0 src/integrators/SkyIntegrator.cc | 0 src/integrators/bidirpath.cc | 0 src/integrators/directlight.cc | 0 src/integrators/pathtracer.cc | 0 src/integrators/photonintegr.cc | 0 src/integrators/sppm.cc | 0 src/interface/CMakeLists.txt | 0 src/interface/xmlinterface.cc | 0 src/interface/yafrayinterface.cc | 0 src/lights/CMakeLists.txt | 0 src/lights/arealight.cc | 0 src/lights/bglight.cc | 0 src/lights/bgportallight.cc | 0 src/lights/directional.cc | 0 src/lights/iesLight.cc | 0 src/lights/meshlight.cc | 0 src/lights/pointlight.cc | 0 src/lights/spherelight.cc | 0 src/lights/spotlight.cc | 0 src/lights/sunlight.cc | 0 src/materials/CMakeLists.txt | 0 src/materials/beer.cc | 0 src/materials/blend.cc | 0 src/materials/coatedglossy.cc | 0 src/materials/glass.cc | 0 src/materials/glossy.cc | 0 src/materials/mask.cc | 0 src/materials/roughglass.cc | 0 src/materials/shinydiffuse.cc | 0 src/materials/simple.cc | 0 src/textures/CMakeLists.txt | 0 src/textures/basicnodes.cc | 0 src/textures/basictex.cc | 0 src/textures/imagetex.cc | 0 src/textures/layernode.cc | 0 src/textures/noise.cc | 0 src/volumes/CMakeLists.txt | 0 src/volumes/ExpDensityVolume.cc | 0 src/volumes/GridVolume.cc | 0 src/volumes/NoiseVolume.cc | 0 src/volumes/SkyVolume.cc | 0 src/volumes/UniformVolume.cc | 0 src/xml_loader/CMakeLists.txt | 0 src/xml_loader/xml-loader.cc | 0 src/yafraycore/CMakeLists.txt | 0 src/yafraycore/bound.cc | 0 src/yafraycore/color.cc | 0 src/yafraycore/color_console.cc | 0 src/yafraycore/console.cc | 0 src/yafraycore/environment.cc | 0 src/yafraycore/faure_tables.cc | 0 src/yafraycore/gboundtree.h | 0 src/yafraycore/hashgrid.cc | 0 src/yafraycore/imageOutput.cc | 0 src/yafraycore/imagefilm.cc | 64 +-- src/yafraycore/imagesplitter.cc | 0 src/yafraycore/integrator.cc | 0 src/yafraycore/kdtree.cc | 0 src/yafraycore/logging.cc | 0 src/yafraycore/material.cc | 0 src/yafraycore/matrix4.cc | 0 src/yafraycore/mcintegrator.cc | 0 src/yafraycore/memoryIO.cc | 0 src/yafraycore/nodematerial.cc | 0 src/yafraycore/object3d.cc | 0 src/yafraycore/photon.cc | 0 src/yafraycore/ray_kdtree.cc | 0 src/yafraycore/renderpasses.cc | 0 src/yafraycore/scene.cc | 0 src/yafraycore/session.cc | 0 src/yafraycore/spectrum.cc | 0 src/yafraycore/std_primitives.cc | 0 src/yafraycore/surface.cc | 0 src/yafraycore/sysinfo.cc | 0 src/yafraycore/timer.cc | 0 src/yafraycore/triangle.cc | 0 src/yafraycore/tribox3_d.cc | 0 src/yafraycore/triclip.cc | 0 src/yafraycore/vector3d.cc | 0 src/yafraycore/volume.cc | 0 src/yafraycore/xmlparser.cc | 0 src/yafraycore/yafsystem.cc | 0 228 files changed, 37 insertions(+), 427 deletions(-) mode change 100644 => 100755 AUTHORS mode change 100644 => 100755 CMakeConfig/CPackConfig.txt mode change 100644 => 100755 CMakeConfig/GenConfHeaders.txt mode change 100644 => 100755 CMakeConfig/UserConfig.template mode change 100644 => 100755 CMakeConfig/templates/yaf_revision.h.cmake mode change 100644 => 100755 CMakeConfig/templates/yafray_config.h.cmake mode change 100644 => 100755 CMakeLists.txt mode change 100644 => 100755 CMakeModules/FindOpenEXR.cmake mode change 100644 => 100755 CMakeModules/FindYafPythonLibs.cmake mode change 100644 => 100755 CMakeModules/FindYafSWIG.cmake mode change 100644 => 100755 CMakeModules/UseYafSWIG.cmake mode change 100644 => 100755 CODING mode change 100644 => 100755 INSTALL mode change 100644 => 100755 LICENSES mode change 100644 => 100755 README mode change 100644 => 100755 include/cameras/angularCamera.h mode change 100644 => 100755 include/cameras/architectCamera.h mode change 100644 => 100755 include/cameras/orthographicCamera.h mode change 100644 => 100755 include/cameras/perspectiveCamera.h mode change 100644 => 100755 include/core_api/background.h mode change 100644 => 100755 include/core_api/bound.h mode change 100644 => 100755 include/core_api/camera.h mode change 100644 => 100755 include/core_api/color.h mode change 100644 => 100755 include/core_api/color_console.h mode change 100644 => 100755 include/core_api/environment.h mode change 100644 => 100755 include/core_api/imagefilm.h mode change 100644 => 100755 include/core_api/imagehandler.h mode change 100644 => 100755 include/core_api/imagesplitter.h mode change 100644 => 100755 include/core_api/integrator.h mode change 100644 => 100755 include/core_api/light.h mode change 100644 => 100755 include/core_api/logging.h mode change 100644 => 100755 include/core_api/material.h mode change 100644 => 100755 include/core_api/matrix4.h mode change 100644 => 100755 include/core_api/mcintegrator.h mode change 100644 => 100755 include/core_api/object3d.h mode change 100644 => 100755 include/core_api/output.h mode change 100644 => 100755 include/core_api/params.h mode change 100644 => 100755 include/core_api/primitive.h mode change 100644 => 100755 include/core_api/ray.h mode change 100644 => 100755 include/core_api/renderpasses.h mode change 100644 => 100755 include/core_api/sampling.h mode change 100644 => 100755 include/core_api/scene.h mode change 100644 => 100755 include/core_api/session.h mode change 100644 => 100755 include/core_api/shader.h mode change 100644 => 100755 include/core_api/surface.h mode change 100644 => 100755 include/core_api/sysinfo.h mode change 100644 => 100755 include/core_api/texture.h mode change 100644 => 100755 include/core_api/tiledintegrator.h mode change 100644 => 100755 include/core_api/vector3d.h mode change 100644 => 100755 include/core_api/volume.h mode change 100644 => 100755 include/core_api/yafsystem.h mode change 100644 => 100755 include/integrators/integr_utils.h mode change 100644 => 100755 include/integrators/photonintegr.h mode change 100644 => 100755 include/integrators/sppm.h mode change 100644 => 100755 include/interface/xmlinterface.h mode change 100644 => 100755 include/interface/yafrayinterface.h mode change 100644 => 100755 include/lights/arealight.h mode change 100644 => 100755 include/lights/bglight.h mode change 100644 => 100755 include/lights/bgportallight.h mode change 100644 => 100755 include/lights/meshlight.h mode change 100644 => 100755 include/materials/blendmat.h mode change 100644 => 100755 include/materials/maskmat.h mode change 100644 => 100755 include/materials/microfacet.h mode change 100644 => 100755 include/materials/roughglass.h mode change 100644 => 100755 include/materials/shinydiff.h mode change 100644 => 100755 include/resources/guifont.h mode change 100644 => 100755 include/resources/yafLogoTiny.h mode change 100644 => 100755 include/resources/yafarayicon.h mode change 100644 => 100755 include/textures/basicnodes.h mode change 100644 => 100755 include/textures/basictex.h mode change 100644 => 100755 include/textures/imagetex.h mode change 100644 => 100755 include/textures/layernode.h mode change 100644 => 100755 include/textures/noise.h mode change 100644 => 100755 include/utilities/ColorConv.h mode change 100644 => 100755 include/utilities/buffer.h mode change 100644 => 100755 include/utilities/console_utils.h mode change 100644 => 100755 include/utilities/curveUtils.h mode change 100644 => 100755 include/utilities/geometry.h mode change 100644 => 100755 include/utilities/iesUtils.h mode change 100644 => 100755 include/utilities/image_buffers.h mode change 100644 => 100755 include/utilities/interpolation.h mode change 100644 => 100755 include/utilities/mathOptimizations.h mode change 100644 => 100755 include/utilities/math_utils.h mode change 100644 => 100755 include/utilities/mcqmc.h mode change 100644 => 100755 include/utilities/mingw-std-threads/LICENSE mode change 100644 => 100755 include/utilities/mingw-std-threads/README.md mode change 100644 => 100755 include/utilities/mingw-std-threads/mingw.condition_variable.h mode change 100644 => 100755 include/utilities/mingw-std-threads/mingw.mutex.h mode change 100644 => 100755 include/utilities/mingw-std-threads/mingw.thread.h mode change 100644 => 100755 include/utilities/mingw-std-threads/tests/CMakeLists.txt mode change 100644 => 100755 include/utilities/mingw-std-threads/tests/tests.cpp mode change 100644 => 100755 include/utilities/sample_utils.h mode change 100644 => 100755 include/utilities/spectralData.h mode change 100644 => 100755 include/utilities/stringUtils.h mode change 100644 => 100755 include/utilities/tiled_array.h mode change 100644 => 100755 include/utilities/winunistd.h mode change 100644 => 100755 include/utilities/y_alloc.h mode change 100644 => 100755 include/yafray_constants.h mode change 100644 => 100755 include/yafraycore/hashgrid.h mode change 100644 => 100755 include/yafraycore/image.h mode change 100644 => 100755 include/yafraycore/imageOutput.h mode change 100644 => 100755 include/yafraycore/kdtree.h mode change 100644 => 100755 include/yafraycore/memoryIO.h mode change 100644 => 100755 include/yafraycore/meshtypes.h mode change 100644 => 100755 include/yafraycore/monitor.h mode change 100644 => 100755 include/yafraycore/nodematerial.h mode change 100644 => 100755 include/yafraycore/octree.h mode change 100644 => 100755 include/yafraycore/photon.h mode change 100644 => 100755 include/yafraycore/pkdtree.h mode change 100644 => 100755 include/yafraycore/ray_kdtree.h mode change 100644 => 100755 include/yafraycore/scr_halton.h mode change 100644 => 100755 include/yafraycore/spectrum.h mode change 100644 => 100755 include/yafraycore/std_primitives.h mode change 100644 => 100755 include/yafraycore/timer.h mode change 100644 => 100755 include/yafraycore/triangle.h mode change 100644 => 100755 include/yafraycore/triangle_inline.h mode change 100644 => 100755 include/yafraycore/xmlparser.h mode change 100644 => 100755 src/CMakeLists.txt mode change 100644 => 100755 src/backgrounds/CMakeLists.txt mode change 100644 => 100755 src/backgrounds/darksky.cc mode change 100644 => 100755 src/backgrounds/gradientback.cc mode change 100644 => 100755 src/backgrounds/sunsky.cc mode change 100644 => 100755 src/backgrounds/sunspectrum.cc mode change 100644 => 100755 src/backgrounds/textureback.cc mode change 100644 => 100755 src/bindings/CMakeLists.txt mode change 100644 => 100755 src/bindings/yafaray_v3_interface.i mode change 100644 => 100755 src/cameras/CMakeLists.txt mode change 100644 => 100755 src/cameras/angularCamera.cc mode change 100644 => 100755 src/cameras/architectCamera.cc mode change 100644 => 100755 src/cameras/orthographicCamera.cc mode change 100644 => 100755 src/cameras/perspectiveCamera.cc mode change 100644 => 100755 src/image_handlers/CMakeLists.txt mode change 100644 => 100755 src/image_handlers/exrHandler.cc mode change 100644 => 100755 src/image_handlers/hdrHandler.cc mode change 100644 => 100755 src/image_handlers/hdrUtils.h mode change 100644 => 100755 src/image_handlers/jpgHandler.cc mode change 100644 => 100755 src/image_handlers/pngHandler.cc mode change 100644 => 100755 src/image_handlers/pngUtils.h mode change 100644 => 100755 src/image_handlers/tgaHandler.cc mode change 100644 => 100755 src/image_handlers/tgaUtils.h mode change 100644 => 100755 src/image_handlers/tifHandler.cc mode change 100644 => 100755 src/integrators/CMakeLists.txt mode change 100644 => 100755 src/integrators/DebugIntegrator.cc mode change 100644 => 100755 src/integrators/EmissionIntegrator.cc mode change 100644 => 100755 src/integrators/EmptyVolumeIntegrator.cc mode change 100644 => 100755 src/integrators/SingleScatterIntegrator.cc mode change 100644 => 100755 src/integrators/SkyIntegrator.cc mode change 100644 => 100755 src/integrators/bidirpath.cc mode change 100644 => 100755 src/integrators/directlight.cc mode change 100644 => 100755 src/integrators/pathtracer.cc mode change 100644 => 100755 src/integrators/photonintegr.cc mode change 100644 => 100755 src/integrators/sppm.cc mode change 100644 => 100755 src/interface/CMakeLists.txt mode change 100644 => 100755 src/interface/xmlinterface.cc mode change 100644 => 100755 src/interface/yafrayinterface.cc mode change 100644 => 100755 src/lights/CMakeLists.txt mode change 100644 => 100755 src/lights/arealight.cc mode change 100644 => 100755 src/lights/bglight.cc mode change 100644 => 100755 src/lights/bgportallight.cc mode change 100644 => 100755 src/lights/directional.cc mode change 100644 => 100755 src/lights/iesLight.cc mode change 100644 => 100755 src/lights/meshlight.cc mode change 100644 => 100755 src/lights/pointlight.cc mode change 100644 => 100755 src/lights/spherelight.cc mode change 100644 => 100755 src/lights/spotlight.cc mode change 100644 => 100755 src/lights/sunlight.cc mode change 100644 => 100755 src/materials/CMakeLists.txt mode change 100644 => 100755 src/materials/beer.cc mode change 100644 => 100755 src/materials/blend.cc mode change 100644 => 100755 src/materials/coatedglossy.cc mode change 100644 => 100755 src/materials/glass.cc mode change 100644 => 100755 src/materials/glossy.cc mode change 100644 => 100755 src/materials/mask.cc mode change 100644 => 100755 src/materials/roughglass.cc mode change 100644 => 100755 src/materials/shinydiffuse.cc mode change 100644 => 100755 src/materials/simple.cc mode change 100644 => 100755 src/textures/CMakeLists.txt mode change 100644 => 100755 src/textures/basicnodes.cc mode change 100644 => 100755 src/textures/basictex.cc mode change 100644 => 100755 src/textures/imagetex.cc mode change 100644 => 100755 src/textures/layernode.cc mode change 100644 => 100755 src/textures/noise.cc mode change 100644 => 100755 src/volumes/CMakeLists.txt mode change 100644 => 100755 src/volumes/ExpDensityVolume.cc mode change 100644 => 100755 src/volumes/GridVolume.cc mode change 100644 => 100755 src/volumes/NoiseVolume.cc mode change 100644 => 100755 src/volumes/SkyVolume.cc mode change 100644 => 100755 src/volumes/UniformVolume.cc mode change 100644 => 100755 src/xml_loader/CMakeLists.txt mode change 100644 => 100755 src/xml_loader/xml-loader.cc mode change 100644 => 100755 src/yafraycore/CMakeLists.txt mode change 100644 => 100755 src/yafraycore/bound.cc mode change 100644 => 100755 src/yafraycore/color.cc mode change 100644 => 100755 src/yafraycore/color_console.cc mode change 100644 => 100755 src/yafraycore/console.cc mode change 100644 => 100755 src/yafraycore/environment.cc mode change 100644 => 100755 src/yafraycore/faure_tables.cc mode change 100644 => 100755 src/yafraycore/gboundtree.h mode change 100644 => 100755 src/yafraycore/hashgrid.cc mode change 100644 => 100755 src/yafraycore/imageOutput.cc mode change 100644 => 100755 src/yafraycore/imagefilm.cc mode change 100644 => 100755 src/yafraycore/imagesplitter.cc mode change 100644 => 100755 src/yafraycore/integrator.cc mode change 100644 => 100755 src/yafraycore/kdtree.cc mode change 100644 => 100755 src/yafraycore/logging.cc mode change 100644 => 100755 src/yafraycore/material.cc mode change 100644 => 100755 src/yafraycore/matrix4.cc mode change 100644 => 100755 src/yafraycore/mcintegrator.cc mode change 100644 => 100755 src/yafraycore/memoryIO.cc mode change 100644 => 100755 src/yafraycore/nodematerial.cc mode change 100644 => 100755 src/yafraycore/object3d.cc mode change 100644 => 100755 src/yafraycore/photon.cc mode change 100644 => 100755 src/yafraycore/ray_kdtree.cc mode change 100644 => 100755 src/yafraycore/renderpasses.cc mode change 100644 => 100755 src/yafraycore/scene.cc mode change 100644 => 100755 src/yafraycore/session.cc mode change 100644 => 100755 src/yafraycore/spectrum.cc mode change 100644 => 100755 src/yafraycore/std_primitives.cc mode change 100644 => 100755 src/yafraycore/surface.cc mode change 100644 => 100755 src/yafraycore/sysinfo.cc mode change 100644 => 100755 src/yafraycore/timer.cc mode change 100644 => 100755 src/yafraycore/triangle.cc mode change 100644 => 100755 src/yafraycore/tribox3_d.cc mode change 100644 => 100755 src/yafraycore/triclip.cc mode change 100644 => 100755 src/yafraycore/vector3d.cc mode change 100644 => 100755 src/yafraycore/volume.cc mode change 100644 => 100755 src/yafraycore/xmlparser.cc mode change 100644 => 100755 src/yafraycore/yafsystem.cc diff --git a/AUTHORS b/AUTHORS old mode 100644 new mode 100755 diff --git a/CMakeConfig/CPackConfig.txt b/CMakeConfig/CPackConfig.txt old mode 100644 new mode 100755 diff --git a/CMakeConfig/GenConfHeaders.txt b/CMakeConfig/GenConfHeaders.txt old mode 100644 new mode 100755 diff --git a/CMakeConfig/UserConfig.template b/CMakeConfig/UserConfig.template old mode 100644 new mode 100755 diff --git a/CMakeConfig/templates/yaf_revision.h.cmake b/CMakeConfig/templates/yaf_revision.h.cmake old mode 100644 new mode 100755 diff --git a/CMakeConfig/templates/yafray_config.h.cmake b/CMakeConfig/templates/yafray_config.h.cmake old mode 100644 new mode 100755 diff --git a/CMakeLists.txt b/CMakeLists.txt old mode 100644 new mode 100755 index bd615932..73291f95 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,7 +67,7 @@ if(YAF_USER_EXTRA_LIBS) endif(YAF_USER_EXTRA_LIBS) # find the required libs -FIND_PACKAGE(Boost COMPONENTS system filesystem serialization regex REQUIRED) +FIND_PACKAGE(Boost COMPONENTS system filesystem serialization REQUIRED) INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIR} ) find_package(ZLIB REQUIRED) diff --git a/CMakeModules/FindOpenEXR.cmake b/CMakeModules/FindOpenEXR.cmake old mode 100644 new mode 100755 diff --git a/CMakeModules/FindYafPythonLibs.cmake b/CMakeModules/FindYafPythonLibs.cmake old mode 100644 new mode 100755 diff --git a/CMakeModules/FindYafSWIG.cmake b/CMakeModules/FindYafSWIG.cmake old mode 100644 new mode 100755 diff --git a/CMakeModules/UseYafSWIG.cmake b/CMakeModules/UseYafSWIG.cmake old mode 100644 new mode 100755 diff --git a/CODING b/CODING old mode 100644 new mode 100755 diff --git a/INSTALL b/INSTALL old mode 100644 new mode 100755 diff --git a/LICENSES b/LICENSES old mode 100644 new mode 100755 index 643db743..2b830228 --- a/LICENSES +++ b/LICENSES @@ -1922,401 +1922,3 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - - -icu (dependency of boost-regex) -------------------------------- -ICU License - ICU 1.8.1 and later - -COPYRIGHT AND PERMISSION NOTICE - -Copyright (c) 1995-2016 International Business Machines Corporation and others - -All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, and/or sell copies of the Software, and to permit persons -to whom the Software is furnished to do so, provided that the above -copyright notice(s) and this permission notice appear in all copies of -the Software and that both the above copyright notice(s) and this -permission notice appear in supporting documentation. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT -OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY -SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER -RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF -CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN -CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -Except as contained in this notice, the name of a copyright holder -shall not be used in advertising or otherwise to promote the sale, use -or other dealings in this Software without prior written authorization -of the copyright holder. - - -All trademarks and registered trademarks mentioned herein are the -property of their respective owners. - ---------------------- - -Third-Party Software Licenses - -This section contains third-party software notices and/or additional -terms for licensed third-party software components included within ICU -libraries. - -1. Unicode Data Files and Software - -COPYRIGHT AND PERMISSION NOTICE - -Copyright ยฉ 1991-2016 Unicode, Inc. All rights reserved. -Distributed under the Terms of Use in -http://www.unicode.org/copyright.html. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of the Unicode data files and any associated documentation -(the "Data Files") or Unicode software and any associated documentation -(the "Software") to deal in the Data Files or Software -without restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, and/or sell copies of -the Data Files or Software, and to permit persons to whom the Data Files -or Software are furnished to do so, provided that -(a) this copyright and permission notice appear with all copies -of the Data Files or Software, -(b) this copyright and permission notice appear in associated -documentation, and -(c) there is clear notice in each modified Data File or in the Software -as well as in the documentation associated with the Data File(s) or -Software that the data or software has been modified. - -THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF -ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT OF THIRD PARTY RIGHTS. -IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS -NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL -DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, -DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER -TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THE DATA FILES OR SOFTWARE. - -Except as contained in this notice, the name of a copyright holder -shall not be used in advertising or otherwise to promote the sale, -use or other dealings in these Data Files or Software without prior -written authorization of the copyright holder. - -2. Chinese/Japanese Word Break Dictionary Data (cjdict.txt) - - # The Google Chrome software developed by Google is licensed under - # the BSD license. Other software included in this distribution is - # provided under other licenses, as set forth below. - # - # The BSD License - # http://opensource.org/licenses/bsd-license.php - # Copyright (C) 2006-2008, Google Inc. - # - # All rights reserved. - # - # Redistribution and use in source and binary forms, with or without - # modification, are permitted provided that the following conditions are met: - # - # Redistributions of source code must retain the above copyright notice, - # this list of conditions and the following disclaimer. - # Redistributions in binary form must reproduce the above - # copyright notice, this list of conditions and the following - # disclaimer in the documentation and/or other materials provided with - # the distribution. - # Neither the name of Google Inc. nor the names of its - # contributors may be used to endorse or promote products derived from - # this software without specific prior written permission. - # - # - # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - # CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - # BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - # - # - # The word list in cjdict.txt are generated by combining three word lists - # listed below with further processing for compound word breaking. The - # frequency is generated with an iterative training against Google web - # corpora. - # - # * Libtabe (Chinese) - # - https://sourceforge.net/project/?group_id=1519 - # - Its license terms and conditions are shown below. - # - # * IPADIC (Japanese) - # - http://chasen.aist-nara.ac.jp/chasen/distribution.html - # - Its license terms and conditions are shown below. - # - # ---------COPYING.libtabe ---- BEGIN-------------------- - # - # /* - # * Copyrighy (c) 1999 TaBE Project. - # * Copyright (c) 1999 Pai-Hsiang Hsiao. - # * All rights reserved. - # * - # * Redistribution and use in source and binary forms, with or without - # * modification, are permitted provided that the following conditions - # * are met: - # * - # * . Redistributions of source code must retain the above copyright - # * notice, this list of conditions and the following disclaimer. - # * . Redistributions in binary form must reproduce the above copyright - # * notice, this list of conditions and the following disclaimer in - # * the documentation and/or other materials provided with the - # * distribution. - # * . Neither the name of the TaBE Project nor the names of its - # * contributors may be used to endorse or promote products derived - # * from this software without specific prior written permission. - # * - # * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - # * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - # * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - # * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - # * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - # * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - # * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - # * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - # * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - # * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - # * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - # * OF THE POSSIBILITY OF SUCH DAMAGE. - # */ - # - # /* - # * Copyright (c) 1999 Computer Systems and Communication Lab, - # * Institute of Information Science, Academia - # * Sinica. All rights reserved. - # * - # * Redistribution and use in source and binary forms, with or without - # * modification, are permitted provided that the following conditions - # * are met: - # * - # * . Redistributions of source code must retain the above copyright - # * notice, this list of conditions and the following disclaimer. - # * . Redistributions in binary form must reproduce the above copyright - # * notice, this list of conditions and the following disclaimer in - # * the documentation and/or other materials provided with the - # * distribution. - # * . Neither the name of the Computer Systems and Communication Lab - # * nor the names of its contributors may be used to endorse or - # * promote products derived from this software without specific - # * prior written permission. - # * - # * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - # * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - # * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - # * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - # * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - # * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - # * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - # * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - # * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - # * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - # * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - # * OF THE POSSIBILITY OF SUCH DAMAGE. - # */ - # - # Copyright 1996 Chih-Hao Tsai @ Beckman Institute, - # University of Illinois - # c-tsai4@uiuc.edu http://casper.beckman.uiuc.edu/~c-tsai4 - # - # ---------------COPYING.libtabe-----END-------------------------------- - # - # - # ---------------COPYING.ipadic-----BEGIN------------------------------- - # - # Copyright 2000, 2001, 2002, 2003 Nara Institute of Science - # and Technology. All Rights Reserved. - # - # Use, reproduction, and distribution of this software is permitted. - # Any copy of this software, whether in its original form or modified, - # must include both the above copyright notice and the following - # paragraphs. - # - # Nara Institute of Science and Technology (NAIST), - # the copyright holders, disclaims all warranties with regard to this - # software, including all implied warranties of merchantability and - # fitness, in no event shall NAIST be liable for - # any special, indirect or consequential damages or any damages - # whatsoever resulting from loss of use, data or profits, whether in an - # action of contract, negligence or other tortuous action, arising out - # of or in connection with the use or performance of this software. - # - # A large portion of the dictionary entries - # originate from ICOT Free Software. The following conditions for ICOT - # Free Software applies to the current dictionary as well. - # - # Each User may also freely distribute the Program, whether in its - # original form or modified, to any third party or parties, PROVIDED - # that the provisions of Section 3 ("NO WARRANTY") will ALWAYS appear - # on, or be attached to, the Program, which is distributed substantially - # in the same form as set out herein and that such intended - # distribution, if actually made, will neither violate or otherwise - # contravene any of the laws and regulations of the countries having - # jurisdiction over the User or the intended distribution itself. - # - # NO WARRANTY - # - # The program was produced on an experimental basis in the course of the - # research and development conducted during the project and is provided - # to users as so produced on an experimental basis. Accordingly, the - # program is provided without any warranty whatsoever, whether express, - # implied, statutory or otherwise. The term "warranty" used herein - # includes, but is not limited to, any warranty of the quality, - # performance, merchantability and fitness for a particular purpose of - # the program and the nonexistence of any infringement or violation of - # any right of any third party. - # - # Each user of the program will agree and understand, and be deemed to - # have agreed and understood, that there is no warranty whatsoever for - # the program and, accordingly, the entire risk arising from or - # otherwise connected with the program is assumed by the user. - # - # Therefore, neither ICOT, the copyright holder, or any other - # organization that participated in or was otherwise related to the - # development of the program and their respective officials, directors, - # officers and other employees shall be held liable for any and all - # damages, including, without limitation, general, special, incidental - # and consequential damages, arising out of or otherwise in connection - # with the use or inability to use the program or any product, material - # or result produced or otherwise obtained by using the program, - # regardless of whether they have been advised of, or otherwise had - # knowledge of, the possibility of such damages at any time during the - # project or thereafter. Each user will be deemed to have agreed to the - # foregoing by his or her commencement of use of the program. The term - # "use" as used herein includes, but is not limited to, the use, - # modification, copying and distribution of the program and the - # production of secondary products from the program. - # - # In the case where the program, whether in its original form or - # modified, was distributed or delivered to or received by a user from - # any person, organization or entity other than ICOT, unless it makes or - # grants independently of ICOT any specific warranty to the user in - # writing, such person, organization or entity, will also be exempted - # from and not be held liable to the user for any such damages as noted - # above as far as the program is concerned. - # - # ---------------COPYING.ipadic-----END---------------------------------- - -3. Lao Word Break Dictionary Data (laodict.txt) - - # Copyright (c) 2013 International Business Machines Corporation - # and others. All Rights Reserved. - # - # Project: http://code.google.com/p/lao-dictionary/ - # Dictionary: http://lao-dictionary.googlecode.com/git/Lao-Dictionary.txt - # License: http://lao-dictionary.googlecode.com/git/Lao-Dictionary-LICENSE.txt - # (copied below) - # - # This file is derived from the above dictionary, with slight - # modifications. - # ---------------------------------------------------------------------- - # Copyright (C) 2013 Brian Eugene Wilson, Robert Martin Campbell. - # All rights reserved. - # - # Redistribution and use in source and binary forms, with or without - # modification, - # are permitted provided that the following conditions are met: - # - # - # Redistributions of source code must retain the above copyright notice, this - # list of conditions and the following disclaimer. Redistributions in - # binary form must reproduce the above copyright notice, this list of - # conditions and the following disclaimer in the documentation and/or - # other materials provided with the distribution. - # - # - # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - # OF THE POSSIBILITY OF SUCH DAMAGE. - # -------------------------------------------------------------------------- - -4. Burmese Word Break Dictionary Data (burmesedict.txt) - - # Copyright (c) 2014 International Business Machines Corporation - # and others. All Rights Reserved. - # - # This list is part of a project hosted at: - # github.com/kanyawtech/myanmar-karen-word-lists - # - # -------------------------------------------------------------------------- - # Copyright (c) 2013, LeRoy Benjamin Sharon - # All rights reserved. - # - # Redistribution and use in source and binary forms, with or without - # modification, are permitted provided that the following conditions - # are met: Redistributions of source code must retain the above - # copyright notice, this list of conditions and the following - # disclaimer. Redistributions in binary form must reproduce the - # above copyright notice, this list of conditions and the following - # disclaimer in the documentation and/or other materials provided - # with the distribution. - # - # Neither the name Myanmar Karen Word Lists, nor the names of its - # contributors may be used to endorse or promote products derived - # from this software without specific prior written permission. - # - # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - # CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS - # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - # TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - # TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF - # THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - # SUCH DAMAGE. - # -------------------------------------------------------------------------- - -5. Time Zone Database - - ICU uses the public domain data and code derived from Time Zone -Database for its time zone support. The ownership of the TZ database -is explained in BCP 175: Procedure for Maintaining the Time Zone -Database section 7. - - # 7. Database Ownership - # - # The TZ database itself is not an IETF Contribution or an IETF - # document. Rather it is a pre-existing and regularly updated work - # that is in the public domain, and is intended to remain in the - # public domain. Therefore, BCPs 78 [RFC5378] and 79 [RFC3979] do - # not apply to the TZ Database or contributions that individuals make - # to it. Should any claims be made and substantiated against the TZ - # Database, the organization that is providing the IANA - # Considerations defined in this RFC, under the memorandum of - # understanding with the IETF, currently ICANN, may act in accordance - # with all competent court orders. No ownership claims will be made - # by ICANN or the IETF Trust on the database or the code. Any person - # making a contribution to the database or code waives all rights to - # future claims in that contribution or in the TZ Database. diff --git a/README b/README old mode 100644 new mode 100755 diff --git a/include/cameras/angularCamera.h b/include/cameras/angularCamera.h old mode 100644 new mode 100755 diff --git a/include/cameras/architectCamera.h b/include/cameras/architectCamera.h old mode 100644 new mode 100755 diff --git a/include/cameras/orthographicCamera.h b/include/cameras/orthographicCamera.h old mode 100644 new mode 100755 diff --git a/include/cameras/perspectiveCamera.h b/include/cameras/perspectiveCamera.h old mode 100644 new mode 100755 diff --git a/include/core_api/background.h b/include/core_api/background.h old mode 100644 new mode 100755 diff --git a/include/core_api/bound.h b/include/core_api/bound.h old mode 100644 new mode 100755 diff --git a/include/core_api/camera.h b/include/core_api/camera.h old mode 100644 new mode 100755 diff --git a/include/core_api/color.h b/include/core_api/color.h old mode 100644 new mode 100755 diff --git a/include/core_api/color_console.h b/include/core_api/color_console.h old mode 100644 new mode 100755 diff --git a/include/core_api/environment.h b/include/core_api/environment.h old mode 100644 new mode 100755 diff --git a/include/core_api/imagefilm.h b/include/core_api/imagefilm.h old mode 100644 new mode 100755 diff --git a/include/core_api/imagehandler.h b/include/core_api/imagehandler.h old mode 100644 new mode 100755 diff --git a/include/core_api/imagesplitter.h b/include/core_api/imagesplitter.h old mode 100644 new mode 100755 diff --git a/include/core_api/integrator.h b/include/core_api/integrator.h old mode 100644 new mode 100755 diff --git a/include/core_api/light.h b/include/core_api/light.h old mode 100644 new mode 100755 diff --git a/include/core_api/logging.h b/include/core_api/logging.h old mode 100644 new mode 100755 diff --git a/include/core_api/material.h b/include/core_api/material.h old mode 100644 new mode 100755 diff --git a/include/core_api/matrix4.h b/include/core_api/matrix4.h old mode 100644 new mode 100755 diff --git a/include/core_api/mcintegrator.h b/include/core_api/mcintegrator.h old mode 100644 new mode 100755 diff --git a/include/core_api/object3d.h b/include/core_api/object3d.h old mode 100644 new mode 100755 diff --git a/include/core_api/output.h b/include/core_api/output.h old mode 100644 new mode 100755 diff --git a/include/core_api/params.h b/include/core_api/params.h old mode 100644 new mode 100755 diff --git a/include/core_api/primitive.h b/include/core_api/primitive.h old mode 100644 new mode 100755 diff --git a/include/core_api/ray.h b/include/core_api/ray.h old mode 100644 new mode 100755 diff --git a/include/core_api/renderpasses.h b/include/core_api/renderpasses.h old mode 100644 new mode 100755 diff --git a/include/core_api/sampling.h b/include/core_api/sampling.h old mode 100644 new mode 100755 diff --git a/include/core_api/scene.h b/include/core_api/scene.h old mode 100644 new mode 100755 diff --git a/include/core_api/session.h b/include/core_api/session.h old mode 100644 new mode 100755 diff --git a/include/core_api/shader.h b/include/core_api/shader.h old mode 100644 new mode 100755 diff --git a/include/core_api/surface.h b/include/core_api/surface.h old mode 100644 new mode 100755 diff --git a/include/core_api/sysinfo.h b/include/core_api/sysinfo.h old mode 100644 new mode 100755 diff --git a/include/core_api/texture.h b/include/core_api/texture.h old mode 100644 new mode 100755 diff --git a/include/core_api/tiledintegrator.h b/include/core_api/tiledintegrator.h old mode 100644 new mode 100755 diff --git a/include/core_api/vector3d.h b/include/core_api/vector3d.h old mode 100644 new mode 100755 diff --git a/include/core_api/volume.h b/include/core_api/volume.h old mode 100644 new mode 100755 diff --git a/include/core_api/yafsystem.h b/include/core_api/yafsystem.h old mode 100644 new mode 100755 diff --git a/include/integrators/integr_utils.h b/include/integrators/integr_utils.h old mode 100644 new mode 100755 diff --git a/include/integrators/photonintegr.h b/include/integrators/photonintegr.h old mode 100644 new mode 100755 diff --git a/include/integrators/sppm.h b/include/integrators/sppm.h old mode 100644 new mode 100755 diff --git a/include/interface/xmlinterface.h b/include/interface/xmlinterface.h old mode 100644 new mode 100755 diff --git a/include/interface/yafrayinterface.h b/include/interface/yafrayinterface.h old mode 100644 new mode 100755 diff --git a/include/lights/arealight.h b/include/lights/arealight.h old mode 100644 new mode 100755 diff --git a/include/lights/bglight.h b/include/lights/bglight.h old mode 100644 new mode 100755 diff --git a/include/lights/bgportallight.h b/include/lights/bgportallight.h old mode 100644 new mode 100755 diff --git a/include/lights/meshlight.h b/include/lights/meshlight.h old mode 100644 new mode 100755 diff --git a/include/materials/blendmat.h b/include/materials/blendmat.h old mode 100644 new mode 100755 diff --git a/include/materials/maskmat.h b/include/materials/maskmat.h old mode 100644 new mode 100755 diff --git a/include/materials/microfacet.h b/include/materials/microfacet.h old mode 100644 new mode 100755 diff --git a/include/materials/roughglass.h b/include/materials/roughglass.h old mode 100644 new mode 100755 diff --git a/include/materials/shinydiff.h b/include/materials/shinydiff.h old mode 100644 new mode 100755 diff --git a/include/resources/guifont.h b/include/resources/guifont.h old mode 100644 new mode 100755 diff --git a/include/resources/yafLogoTiny.h b/include/resources/yafLogoTiny.h old mode 100644 new mode 100755 diff --git a/include/resources/yafarayicon.h b/include/resources/yafarayicon.h old mode 100644 new mode 100755 diff --git a/include/textures/basicnodes.h b/include/textures/basicnodes.h old mode 100644 new mode 100755 diff --git a/include/textures/basictex.h b/include/textures/basictex.h old mode 100644 new mode 100755 diff --git a/include/textures/imagetex.h b/include/textures/imagetex.h old mode 100644 new mode 100755 diff --git a/include/textures/layernode.h b/include/textures/layernode.h old mode 100644 new mode 100755 diff --git a/include/textures/noise.h b/include/textures/noise.h old mode 100644 new mode 100755 diff --git a/include/utilities/ColorConv.h b/include/utilities/ColorConv.h old mode 100644 new mode 100755 diff --git a/include/utilities/buffer.h b/include/utilities/buffer.h old mode 100644 new mode 100755 diff --git a/include/utilities/console_utils.h b/include/utilities/console_utils.h old mode 100644 new mode 100755 diff --git a/include/utilities/curveUtils.h b/include/utilities/curveUtils.h old mode 100644 new mode 100755 diff --git a/include/utilities/geometry.h b/include/utilities/geometry.h old mode 100644 new mode 100755 diff --git a/include/utilities/iesUtils.h b/include/utilities/iesUtils.h old mode 100644 new mode 100755 diff --git a/include/utilities/image_buffers.h b/include/utilities/image_buffers.h old mode 100644 new mode 100755 diff --git a/include/utilities/interpolation.h b/include/utilities/interpolation.h old mode 100644 new mode 100755 diff --git a/include/utilities/mathOptimizations.h b/include/utilities/mathOptimizations.h old mode 100644 new mode 100755 diff --git a/include/utilities/math_utils.h b/include/utilities/math_utils.h old mode 100644 new mode 100755 diff --git a/include/utilities/mcqmc.h b/include/utilities/mcqmc.h old mode 100644 new mode 100755 diff --git a/include/utilities/mingw-std-threads/LICENSE b/include/utilities/mingw-std-threads/LICENSE old mode 100644 new mode 100755 diff --git a/include/utilities/mingw-std-threads/README.md b/include/utilities/mingw-std-threads/README.md old mode 100644 new mode 100755 diff --git a/include/utilities/mingw-std-threads/mingw.condition_variable.h b/include/utilities/mingw-std-threads/mingw.condition_variable.h old mode 100644 new mode 100755 diff --git a/include/utilities/mingw-std-threads/mingw.mutex.h b/include/utilities/mingw-std-threads/mingw.mutex.h old mode 100644 new mode 100755 diff --git a/include/utilities/mingw-std-threads/mingw.thread.h b/include/utilities/mingw-std-threads/mingw.thread.h old mode 100644 new mode 100755 diff --git a/include/utilities/mingw-std-threads/tests/CMakeLists.txt b/include/utilities/mingw-std-threads/tests/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/include/utilities/mingw-std-threads/tests/tests.cpp b/include/utilities/mingw-std-threads/tests/tests.cpp old mode 100644 new mode 100755 diff --git a/include/utilities/sample_utils.h b/include/utilities/sample_utils.h old mode 100644 new mode 100755 diff --git a/include/utilities/spectralData.h b/include/utilities/spectralData.h old mode 100644 new mode 100755 diff --git a/include/utilities/stringUtils.h b/include/utilities/stringUtils.h old mode 100644 new mode 100755 diff --git a/include/utilities/tiled_array.h b/include/utilities/tiled_array.h old mode 100644 new mode 100755 diff --git a/include/utilities/winunistd.h b/include/utilities/winunistd.h old mode 100644 new mode 100755 diff --git a/include/utilities/y_alloc.h b/include/utilities/y_alloc.h old mode 100644 new mode 100755 diff --git a/include/yafray_constants.h b/include/yafray_constants.h old mode 100644 new mode 100755 diff --git a/include/yafraycore/hashgrid.h b/include/yafraycore/hashgrid.h old mode 100644 new mode 100755 diff --git a/include/yafraycore/image.h b/include/yafraycore/image.h old mode 100644 new mode 100755 diff --git a/include/yafraycore/imageOutput.h b/include/yafraycore/imageOutput.h old mode 100644 new mode 100755 diff --git a/include/yafraycore/kdtree.h b/include/yafraycore/kdtree.h old mode 100644 new mode 100755 diff --git a/include/yafraycore/memoryIO.h b/include/yafraycore/memoryIO.h old mode 100644 new mode 100755 diff --git a/include/yafraycore/meshtypes.h b/include/yafraycore/meshtypes.h old mode 100644 new mode 100755 diff --git a/include/yafraycore/monitor.h b/include/yafraycore/monitor.h old mode 100644 new mode 100755 diff --git a/include/yafraycore/nodematerial.h b/include/yafraycore/nodematerial.h old mode 100644 new mode 100755 diff --git a/include/yafraycore/octree.h b/include/yafraycore/octree.h old mode 100644 new mode 100755 diff --git a/include/yafraycore/photon.h b/include/yafraycore/photon.h old mode 100644 new mode 100755 diff --git a/include/yafraycore/pkdtree.h b/include/yafraycore/pkdtree.h old mode 100644 new mode 100755 diff --git a/include/yafraycore/ray_kdtree.h b/include/yafraycore/ray_kdtree.h old mode 100644 new mode 100755 diff --git a/include/yafraycore/scr_halton.h b/include/yafraycore/scr_halton.h old mode 100644 new mode 100755 diff --git a/include/yafraycore/spectrum.h b/include/yafraycore/spectrum.h old mode 100644 new mode 100755 diff --git a/include/yafraycore/std_primitives.h b/include/yafraycore/std_primitives.h old mode 100644 new mode 100755 diff --git a/include/yafraycore/timer.h b/include/yafraycore/timer.h old mode 100644 new mode 100755 diff --git a/include/yafraycore/triangle.h b/include/yafraycore/triangle.h old mode 100644 new mode 100755 diff --git a/include/yafraycore/triangle_inline.h b/include/yafraycore/triangle_inline.h old mode 100644 new mode 100755 diff --git a/include/yafraycore/xmlparser.h b/include/yafraycore/xmlparser.h old mode 100644 new mode 100755 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/src/backgrounds/CMakeLists.txt b/src/backgrounds/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/src/backgrounds/darksky.cc b/src/backgrounds/darksky.cc old mode 100644 new mode 100755 diff --git a/src/backgrounds/gradientback.cc b/src/backgrounds/gradientback.cc old mode 100644 new mode 100755 diff --git a/src/backgrounds/sunsky.cc b/src/backgrounds/sunsky.cc old mode 100644 new mode 100755 diff --git a/src/backgrounds/sunspectrum.cc b/src/backgrounds/sunspectrum.cc old mode 100644 new mode 100755 diff --git a/src/backgrounds/textureback.cc b/src/backgrounds/textureback.cc old mode 100644 new mode 100755 diff --git a/src/bindings/CMakeLists.txt b/src/bindings/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/src/bindings/yafaray_v3_interface.i b/src/bindings/yafaray_v3_interface.i old mode 100644 new mode 100755 diff --git a/src/cameras/CMakeLists.txt b/src/cameras/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/src/cameras/angularCamera.cc b/src/cameras/angularCamera.cc old mode 100644 new mode 100755 diff --git a/src/cameras/architectCamera.cc b/src/cameras/architectCamera.cc old mode 100644 new mode 100755 diff --git a/src/cameras/orthographicCamera.cc b/src/cameras/orthographicCamera.cc old mode 100644 new mode 100755 diff --git a/src/cameras/perspectiveCamera.cc b/src/cameras/perspectiveCamera.cc old mode 100644 new mode 100755 diff --git a/src/image_handlers/CMakeLists.txt b/src/image_handlers/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/src/image_handlers/exrHandler.cc b/src/image_handlers/exrHandler.cc old mode 100644 new mode 100755 diff --git a/src/image_handlers/hdrHandler.cc b/src/image_handlers/hdrHandler.cc old mode 100644 new mode 100755 diff --git a/src/image_handlers/hdrUtils.h b/src/image_handlers/hdrUtils.h old mode 100644 new mode 100755 diff --git a/src/image_handlers/jpgHandler.cc b/src/image_handlers/jpgHandler.cc old mode 100644 new mode 100755 diff --git a/src/image_handlers/pngHandler.cc b/src/image_handlers/pngHandler.cc old mode 100644 new mode 100755 diff --git a/src/image_handlers/pngUtils.h b/src/image_handlers/pngUtils.h old mode 100644 new mode 100755 diff --git a/src/image_handlers/tgaHandler.cc b/src/image_handlers/tgaHandler.cc old mode 100644 new mode 100755 diff --git a/src/image_handlers/tgaUtils.h b/src/image_handlers/tgaUtils.h old mode 100644 new mode 100755 diff --git a/src/image_handlers/tifHandler.cc b/src/image_handlers/tifHandler.cc old mode 100644 new mode 100755 diff --git a/src/integrators/CMakeLists.txt b/src/integrators/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/src/integrators/DebugIntegrator.cc b/src/integrators/DebugIntegrator.cc old mode 100644 new mode 100755 diff --git a/src/integrators/EmissionIntegrator.cc b/src/integrators/EmissionIntegrator.cc old mode 100644 new mode 100755 diff --git a/src/integrators/EmptyVolumeIntegrator.cc b/src/integrators/EmptyVolumeIntegrator.cc old mode 100644 new mode 100755 diff --git a/src/integrators/SingleScatterIntegrator.cc b/src/integrators/SingleScatterIntegrator.cc old mode 100644 new mode 100755 diff --git a/src/integrators/SkyIntegrator.cc b/src/integrators/SkyIntegrator.cc old mode 100644 new mode 100755 diff --git a/src/integrators/bidirpath.cc b/src/integrators/bidirpath.cc old mode 100644 new mode 100755 diff --git a/src/integrators/directlight.cc b/src/integrators/directlight.cc old mode 100644 new mode 100755 diff --git a/src/integrators/pathtracer.cc b/src/integrators/pathtracer.cc old mode 100644 new mode 100755 diff --git a/src/integrators/photonintegr.cc b/src/integrators/photonintegr.cc old mode 100644 new mode 100755 diff --git a/src/integrators/sppm.cc b/src/integrators/sppm.cc old mode 100644 new mode 100755 diff --git a/src/interface/CMakeLists.txt b/src/interface/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/src/interface/xmlinterface.cc b/src/interface/xmlinterface.cc old mode 100644 new mode 100755 diff --git a/src/interface/yafrayinterface.cc b/src/interface/yafrayinterface.cc old mode 100644 new mode 100755 diff --git a/src/lights/CMakeLists.txt b/src/lights/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/src/lights/arealight.cc b/src/lights/arealight.cc old mode 100644 new mode 100755 diff --git a/src/lights/bglight.cc b/src/lights/bglight.cc old mode 100644 new mode 100755 diff --git a/src/lights/bgportallight.cc b/src/lights/bgportallight.cc old mode 100644 new mode 100755 diff --git a/src/lights/directional.cc b/src/lights/directional.cc old mode 100644 new mode 100755 diff --git a/src/lights/iesLight.cc b/src/lights/iesLight.cc old mode 100644 new mode 100755 diff --git a/src/lights/meshlight.cc b/src/lights/meshlight.cc old mode 100644 new mode 100755 diff --git a/src/lights/pointlight.cc b/src/lights/pointlight.cc old mode 100644 new mode 100755 diff --git a/src/lights/spherelight.cc b/src/lights/spherelight.cc old mode 100644 new mode 100755 diff --git a/src/lights/spotlight.cc b/src/lights/spotlight.cc old mode 100644 new mode 100755 diff --git a/src/lights/sunlight.cc b/src/lights/sunlight.cc old mode 100644 new mode 100755 diff --git a/src/materials/CMakeLists.txt b/src/materials/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/src/materials/beer.cc b/src/materials/beer.cc old mode 100644 new mode 100755 diff --git a/src/materials/blend.cc b/src/materials/blend.cc old mode 100644 new mode 100755 diff --git a/src/materials/coatedglossy.cc b/src/materials/coatedglossy.cc old mode 100644 new mode 100755 diff --git a/src/materials/glass.cc b/src/materials/glass.cc old mode 100644 new mode 100755 diff --git a/src/materials/glossy.cc b/src/materials/glossy.cc old mode 100644 new mode 100755 diff --git a/src/materials/mask.cc b/src/materials/mask.cc old mode 100644 new mode 100755 diff --git a/src/materials/roughglass.cc b/src/materials/roughglass.cc old mode 100644 new mode 100755 diff --git a/src/materials/shinydiffuse.cc b/src/materials/shinydiffuse.cc old mode 100644 new mode 100755 diff --git a/src/materials/simple.cc b/src/materials/simple.cc old mode 100644 new mode 100755 diff --git a/src/textures/CMakeLists.txt b/src/textures/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/src/textures/basicnodes.cc b/src/textures/basicnodes.cc old mode 100644 new mode 100755 diff --git a/src/textures/basictex.cc b/src/textures/basictex.cc old mode 100644 new mode 100755 diff --git a/src/textures/imagetex.cc b/src/textures/imagetex.cc old mode 100644 new mode 100755 diff --git a/src/textures/layernode.cc b/src/textures/layernode.cc old mode 100644 new mode 100755 diff --git a/src/textures/noise.cc b/src/textures/noise.cc old mode 100644 new mode 100755 diff --git a/src/volumes/CMakeLists.txt b/src/volumes/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/src/volumes/ExpDensityVolume.cc b/src/volumes/ExpDensityVolume.cc old mode 100644 new mode 100755 diff --git a/src/volumes/GridVolume.cc b/src/volumes/GridVolume.cc old mode 100644 new mode 100755 diff --git a/src/volumes/NoiseVolume.cc b/src/volumes/NoiseVolume.cc old mode 100644 new mode 100755 diff --git a/src/volumes/SkyVolume.cc b/src/volumes/SkyVolume.cc old mode 100644 new mode 100755 diff --git a/src/volumes/UniformVolume.cc b/src/volumes/UniformVolume.cc old mode 100644 new mode 100755 diff --git a/src/xml_loader/CMakeLists.txt b/src/xml_loader/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/src/xml_loader/xml-loader.cc b/src/xml_loader/xml-loader.cc old mode 100644 new mode 100755 diff --git a/src/yafraycore/CMakeLists.txt b/src/yafraycore/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/src/yafraycore/bound.cc b/src/yafraycore/bound.cc old mode 100644 new mode 100755 diff --git a/src/yafraycore/color.cc b/src/yafraycore/color.cc old mode 100644 new mode 100755 diff --git a/src/yafraycore/color_console.cc b/src/yafraycore/color_console.cc old mode 100644 new mode 100755 diff --git a/src/yafraycore/console.cc b/src/yafraycore/console.cc old mode 100644 new mode 100755 diff --git a/src/yafraycore/environment.cc b/src/yafraycore/environment.cc old mode 100644 new mode 100755 diff --git a/src/yafraycore/faure_tables.cc b/src/yafraycore/faure_tables.cc old mode 100644 new mode 100755 diff --git a/src/yafraycore/gboundtree.h b/src/yafraycore/gboundtree.h old mode 100644 new mode 100755 diff --git a/src/yafraycore/hashgrid.cc b/src/yafraycore/hashgrid.cc old mode 100644 new mode 100755 diff --git a/src/yafraycore/imageOutput.cc b/src/yafraycore/imageOutput.cc old mode 100644 new mode 100755 diff --git a/src/yafraycore/imagefilm.cc b/src/yafraycore/imagefilm.cc old mode 100644 new mode 100755 index e3e3423e..0c3a349a --- a/src/yafraycore/imagefilm.cc +++ b/src/yafraycore/imagefilm.cc @@ -36,11 +36,10 @@ #include #include #include +#include #include #include -#define BOOST_RANGE_ENABLE_CONCEPT_ASSERT 0 #include -#include #if HAVE_FREETYPE #include @@ -245,40 +244,49 @@ void imageFilm_t::init(int numPasses) filmPath += " - node " + node.str(); filmPath += ".film"; - //http://stackoverflow.com/questions/1257721/can-i-use-a-mask-to-iterate-files-in-a-directory-with-boost - //Thanks to http://stackoverflow.com/users/148405/oleg-svechkarenko for this code + const std::string target_path( boost::filesystem::path(session.getPathImageOutput()).parent_path().string() ); + const std::regex filmFilter(".*\\.film$"); + std::vector filmFilesList; - const std::string target_path( session.getPathImageOutput() ); - const boost::regex my_filter( ".*\\.film$" ); - boost::smatch what; - - for (auto &entry: boost::make_iterator_range(boost::filesystem::directory_iterator(boost::filesystem::path(target_path).parent_path()), {}) - | boost::adaptors::filtered(static_cast(&boost::filesystem::is_regular_file)) - | boost::adaptors::filtered([&](const boost::filesystem::path &path){ return boost::regex_match(path.filename().string(), what, my_filter); }) - ) + try { - std::string loadedFilmPath = entry.path().string(); - Y_INFO << "imageFilm: Loading film from: \"" << loadedFilmPath << "\"" << yendl; - imageFilm_t *loadedFilm = new imageFilm_t(w, h, cx0, cy0, *output, 1.0, BOX, env); - loadedFilm->imageFilmLoad(loadedFilmPath, false); - - for(size_t idx=0; idxstatus())) continue; + if(!std::regex_match(it->path().filename().string(), filmFilter)) continue; + filmFilesList.push_back(it->path().string()); + } + std::sort(filmFilesList.begin(), filmFilesList.end()); + + for(auto filmFile: filmFilesList) + { + Y_INFO << "imageFilm: Loading film from: \"" << filmFile << "\"" << yendl; + imageFilm_t *loadedFilm = new imageFilm_t(w, h, cx0, cy0, *output, 1.0, BOX, env); + loadedFilm->imageFilmLoad(filmFile, false); + + for(size_t idx=0; idximagePasses[idx]; - (*imagePasses[idx])(i,j).col += (*loadedImageBuffer)(i,j).col; - (*imagePasses[idx])(i,j).weight += (*loadedImageBuffer)(i,j).weight; + for(int j=0; jimagePasses[idx]; + (*imagePasses[idx])(i,j).col += (*loadedImageBuffer)(i,j).col; + (*imagePasses[idx])(i,j).weight += (*loadedImageBuffer)(i,j).weight; + } } } + + if(samplingOffset < loadedFilm->samplingOffset) samplingOffset = loadedFilm->samplingOffset; + if(baseSamplingOffset < loadedFilm->baseSamplingOffset) baseSamplingOffset = loadedFilm->baseSamplingOffset; + + delete loadedFilm; } - - if(samplingOffset < loadedFilm->samplingOffset) samplingOffset = loadedFilm->samplingOffset; - if(baseSamplingOffset < loadedFilm->baseSamplingOffset) baseSamplingOffset = loadedFilm->baseSamplingOffset; - - delete loadedFilm; + } + catch(const boost::filesystem::filesystem_error& e) + { + Y_WARNING << "imageFilm: error during imageFilm loading process: \"" << e.what() << "\"" << yendl; } } diff --git a/src/yafraycore/imagesplitter.cc b/src/yafraycore/imagesplitter.cc old mode 100644 new mode 100755 diff --git a/src/yafraycore/integrator.cc b/src/yafraycore/integrator.cc old mode 100644 new mode 100755 diff --git a/src/yafraycore/kdtree.cc b/src/yafraycore/kdtree.cc old mode 100644 new mode 100755 diff --git a/src/yafraycore/logging.cc b/src/yafraycore/logging.cc old mode 100644 new mode 100755 diff --git a/src/yafraycore/material.cc b/src/yafraycore/material.cc old mode 100644 new mode 100755 diff --git a/src/yafraycore/matrix4.cc b/src/yafraycore/matrix4.cc old mode 100644 new mode 100755 diff --git a/src/yafraycore/mcintegrator.cc b/src/yafraycore/mcintegrator.cc old mode 100644 new mode 100755 diff --git a/src/yafraycore/memoryIO.cc b/src/yafraycore/memoryIO.cc old mode 100644 new mode 100755 diff --git a/src/yafraycore/nodematerial.cc b/src/yafraycore/nodematerial.cc old mode 100644 new mode 100755 diff --git a/src/yafraycore/object3d.cc b/src/yafraycore/object3d.cc old mode 100644 new mode 100755 diff --git a/src/yafraycore/photon.cc b/src/yafraycore/photon.cc old mode 100644 new mode 100755 diff --git a/src/yafraycore/ray_kdtree.cc b/src/yafraycore/ray_kdtree.cc old mode 100644 new mode 100755 diff --git a/src/yafraycore/renderpasses.cc b/src/yafraycore/renderpasses.cc old mode 100644 new mode 100755 diff --git a/src/yafraycore/scene.cc b/src/yafraycore/scene.cc old mode 100644 new mode 100755 diff --git a/src/yafraycore/session.cc b/src/yafraycore/session.cc old mode 100644 new mode 100755 diff --git a/src/yafraycore/spectrum.cc b/src/yafraycore/spectrum.cc old mode 100644 new mode 100755 diff --git a/src/yafraycore/std_primitives.cc b/src/yafraycore/std_primitives.cc old mode 100644 new mode 100755 diff --git a/src/yafraycore/surface.cc b/src/yafraycore/surface.cc old mode 100644 new mode 100755 diff --git a/src/yafraycore/sysinfo.cc b/src/yafraycore/sysinfo.cc old mode 100644 new mode 100755 diff --git a/src/yafraycore/timer.cc b/src/yafraycore/timer.cc old mode 100644 new mode 100755 diff --git a/src/yafraycore/triangle.cc b/src/yafraycore/triangle.cc old mode 100644 new mode 100755 diff --git a/src/yafraycore/tribox3_d.cc b/src/yafraycore/tribox3_d.cc old mode 100644 new mode 100755 diff --git a/src/yafraycore/triclip.cc b/src/yafraycore/triclip.cc old mode 100644 new mode 100755 diff --git a/src/yafraycore/vector3d.cc b/src/yafraycore/vector3d.cc old mode 100644 new mode 100755 diff --git a/src/yafraycore/volume.cc b/src/yafraycore/volume.cc old mode 100644 new mode 100755 diff --git a/src/yafraycore/xmlparser.cc b/src/yafraycore/xmlparser.cc old mode 100644 new mode 100755 diff --git a/src/yafraycore/yafsystem.cc b/src/yafraycore/yafsystem.cc old mode 100644 new mode 100755 From ecb132917d837033eed7545438c61b8306abfc3c Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sun, 22 May 2016 12:53:57 +0100 Subject: [PATCH 064/124] Changed film format from binary to text. It's slower and bigger, but portable among different platforms. --- include/core_api/imagesplitter.h | 2 ++ src/yafraycore/imagefilm.cc | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/core_api/imagesplitter.h b/include/core_api/imagesplitter.h index 3e025bbc..55150943 100755 --- a/include/core_api/imagesplitter.h +++ b/include/core_api/imagesplitter.h @@ -9,6 +9,8 @@ #include #include +#include +#include #include #include #include diff --git a/src/yafraycore/imagefilm.cc b/src/yafraycore/imagefilm.cc index 0c3a349a..55c30d30 100755 --- a/src/yafraycore/imagefilm.cc +++ b/src/yafraycore/imagefilm.cc @@ -1243,7 +1243,8 @@ bool imageFilm_t::imageFilmLoad(const std::string &filename, bool debugXMLformat } else { - boost::archive::binary_iarchive ia(ifs); + //boost::archive::binary_iarchive ia(ifs); + boost::archive::text_iarchive ia(ifs); ia >> BOOST_SERIALIZATION_NVP(*this); ifs.close(); } @@ -1269,7 +1270,8 @@ bool imageFilm_t::imageFilmSave(const std::string &filename, bool debugXMLformat } else { - boost::archive::binary_oarchive oa(ofs); + //boost::archive::binary_oarchive oa(ofs); + boost::archive::text_oarchive oa(ofs); oa << BOOST_SERIALIZATION_NVP(*this); ofs.close(); } From 6a8484a23ee6ad66037484c6d94a08c5257c9d24 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sun, 22 May 2016 18:55:56 +0100 Subject: [PATCH 065/124] Move third party headers to dedicated "third_party" include subfolder for clarity Changes to be committed: modified: include/core_api/logging.h modified: include/core_api/session.h renamed: include/utilities/mingw-std-threads/LICENSE -> include/third_party/mingw-std-threads/LICENSE renamed: include/utilities/mingw-std-threads/README.md -> include/third_party/mingw-std-threads/README.md renamed: include/utilities/mingw-std-threads/mingw.condition_variable.h -> include/third_party/mingw-std-threads/mingw.condition_variable.h renamed: include/utilities/mingw-std-threads/mingw.mutex.h -> include/third_party/mingw-std-threads/mingw.mutex.h renamed: include/utilities/mingw-std-threads/mingw.thread.h -> include/third_party/mingw-std-threads/mingw.thread.h renamed: include/utilities/mingw-std-threads/tests/CMakeLists.txt -> include/third_party/mingw-std-threads/tests/CMakeLists.txt renamed: include/utilities/mingw-std-threads/tests/tests.cpp -> include/third_party/mingw-std-threads/tests/tests.cpp --- include/core_api/logging.h | 6 +++--- include/core_api/session.h | 6 +++--- .../{utilities => third_party}/mingw-std-threads/LICENSE | 0 .../{utilities => third_party}/mingw-std-threads/README.md | 0 .../mingw-std-threads/mingw.condition_variable.h | 0 .../mingw-std-threads/mingw.mutex.h | 0 .../mingw-std-threads/mingw.thread.h | 0 .../mingw-std-threads/tests/CMakeLists.txt | 0 .../mingw-std-threads/tests/tests.cpp | 0 9 files changed, 6 insertions(+), 6 deletions(-) rename include/{utilities => third_party}/mingw-std-threads/LICENSE (100%) rename include/{utilities => third_party}/mingw-std-threads/README.md (100%) rename include/{utilities => third_party}/mingw-std-threads/mingw.condition_variable.h (100%) rename include/{utilities => third_party}/mingw-std-threads/mingw.mutex.h (100%) rename include/{utilities => third_party}/mingw-std-threads/mingw.thread.h (100%) rename include/{utilities => third_party}/mingw-std-threads/tests/CMakeLists.txt (100%) rename include/{utilities => third_party}/mingw-std-threads/tests/tests.cpp (100%) diff --git a/include/core_api/logging.h b/include/core_api/logging.h index 93e3786e..9164e0d9 100755 --- a/include/core_api/logging.h +++ b/include/core_api/logging.h @@ -32,10 +32,10 @@ #include #if defined(_WIN32) && defined(__MINGW32__) #undef _GLIBCXX_HAS_GTHREADS - #include + #include #include - #include - #include + #include + #include #else #include #include diff --git a/include/core_api/session.h b/include/core_api/session.h index 79b09d39..128972ac 100755 --- a/include/core_api/session.h +++ b/include/core_api/session.h @@ -31,10 +31,10 @@ #include #if defined(_WIN32) && defined(__MINGW32__) #undef _GLIBCXX_HAS_GTHREADS - #include + #include #include - #include - #include + #include + #include #else #include #include diff --git a/include/utilities/mingw-std-threads/LICENSE b/include/third_party/mingw-std-threads/LICENSE similarity index 100% rename from include/utilities/mingw-std-threads/LICENSE rename to include/third_party/mingw-std-threads/LICENSE diff --git a/include/utilities/mingw-std-threads/README.md b/include/third_party/mingw-std-threads/README.md similarity index 100% rename from include/utilities/mingw-std-threads/README.md rename to include/third_party/mingw-std-threads/README.md diff --git a/include/utilities/mingw-std-threads/mingw.condition_variable.h b/include/third_party/mingw-std-threads/mingw.condition_variable.h similarity index 100% rename from include/utilities/mingw-std-threads/mingw.condition_variable.h rename to include/third_party/mingw-std-threads/mingw.condition_variable.h diff --git a/include/utilities/mingw-std-threads/mingw.mutex.h b/include/third_party/mingw-std-threads/mingw.mutex.h similarity index 100% rename from include/utilities/mingw-std-threads/mingw.mutex.h rename to include/third_party/mingw-std-threads/mingw.mutex.h diff --git a/include/utilities/mingw-std-threads/mingw.thread.h b/include/third_party/mingw-std-threads/mingw.thread.h similarity index 100% rename from include/utilities/mingw-std-threads/mingw.thread.h rename to include/third_party/mingw-std-threads/mingw.thread.h diff --git a/include/utilities/mingw-std-threads/tests/CMakeLists.txt b/include/third_party/mingw-std-threads/tests/CMakeLists.txt similarity index 100% rename from include/utilities/mingw-std-threads/tests/CMakeLists.txt rename to include/third_party/mingw-std-threads/tests/CMakeLists.txt diff --git a/include/utilities/mingw-std-threads/tests/tests.cpp b/include/third_party/mingw-std-threads/tests/tests.cpp similarity index 100% rename from include/utilities/mingw-std-threads/tests/tests.cpp rename to include/third_party/mingw-std-threads/tests/tests.cpp From dba87492187ee34d4f41774cba372ee06bd838a1 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Wed, 25 May 2016 05:27:16 +0100 Subject: [PATCH 066/124] ImageFilm load: Autodetection of text/binary file --- src/yafraycore/imagefilm.cc | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/yafraycore/imagefilm.cc b/src/yafraycore/imagefilm.cc index 55c30d30..194c4586 100755 --- a/src/yafraycore/imagefilm.cc +++ b/src/yafraycore/imagefilm.cc @@ -1234,16 +1234,31 @@ bool imageFilm_t::imageFilmLoad(const std::string &filename, bool debugXMLformat try { std::ifstream ifs(filename, std::fstream::binary); + char *memblock = new char [1]; + ifs.seekg (0, std::ios::beg); + ifs.read (memblock, 1); + bool binaryfile = false; + if(memblock[0] < '0') binaryfile = true; //If first character in the film file is not an ASCII number then consider it a binary file + delete memblock; + ifs.seekg (0, std::ios::beg); if(debugXMLformat) { + Y_DEBUG << "serialization: trying to load in XML format" << yendl; boost::archive::xml_iarchive ia(ifs); ia >> BOOST_SERIALIZATION_NVP(*this); ifs.close(); } + else if(binaryfile == true) + { + Y_DEBUG << "serialization: trying to load in Binary format" << yendl; + boost::archive::binary_iarchive ia(ifs); + ia >> BOOST_SERIALIZATION_NVP(*this); + ifs.close(); + } else { - //boost::archive::binary_iarchive ia(ifs); + Y_DEBUG << "serialization: trying to load in Text format" << yendl; boost::archive::text_iarchive ia(ifs); ia >> BOOST_SERIALIZATION_NVP(*this); ifs.close(); From a25ef5f32083b42c99e043680911f2dde83924b9 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Thu, 26 May 2016 05:24:51 +0100 Subject: [PATCH 067/124] Film Save: added option to save text or binary. Also general changes to messages and Progress Bar tags to inform user of the operations taking place --- include/core_api/imagefilm.h | 2 + src/yafraycore/environment.cc | 9 +++- src/yafraycore/imagefilm.cc | 99 +++++++++++++++++++++++++++++++---- src/yafraycore/integrator.cc | 2 +- 4 files changed, 100 insertions(+), 12 deletions(-) diff --git a/include/core_api/imagefilm.h b/include/core_api/imagefilm.h index 6845715d..871b1d9a 100755 --- a/include/core_api/imagefilm.h +++ b/include/core_api/imagefilm.h @@ -139,6 +139,7 @@ class YAFRAYCORE_EXPORT imageFilm_t void setBaseSamplingOffset(unsigned int offset) { baseSamplingOffset = offset; } void setSamplingOffset(unsigned int offset) { samplingOffset = offset; } void setAutoSave(bool auto_save); + void setAutoSaveBinary(bool auto_save_binary); void setAutoLoad(bool auto_load); bool imageFilmLoad(const std::string &filename, bool debugXMLformat); bool imageFilmSave(const std::string &filename, bool debugXMLformat); @@ -192,6 +193,7 @@ class YAFRAYCORE_EXPORT imageFilm_t unsigned int samplingOffset = 0; //To ensure sampling after loading the image film continues and does not repeat already done samples unsigned int computerNode = 0; //Computer node in multi-computer render environments/render farms bool autoSave; // If enabled, it will autosave the Image Film at the same time as the image files + bool autoSaveBinary; //If enabled, it will autosave the Image Film in binary mode (faster, smaller but non-portable among systems) bool autoLoad; // If enabled, it will load the image film from a file before start rendering, might be useful to continue interrupted renders but it has to be used with care. If it does not match exactly the scene, bad results or even crashes could happen. struct filmload_check_t diff --git a/src/yafraycore/environment.cc b/src/yafraycore/environment.cc index 4054b0df..a4a0b0b2 100755 --- a/src/yafraycore/environment.cc +++ b/src/yafraycore/environment.cc @@ -539,6 +539,7 @@ imageFilm_t* renderEnvironment_t::createImageFilm(const paraMap_t ¶ms, color float partial_save_timer = 0.f; bool partial_save_each_pass = false; bool film_autosave = false; + bool film_save_binary_format = true; bool film_load = false; params.getParam("color_space", color_space_string); @@ -559,6 +560,7 @@ imageFilm_t* renderEnvironment_t::createImageFilm(const paraMap_t ¶ms, color params.getParam("partial_save_timer", partial_save_timer); // Time for partially save image params.getParam("partial_save_each_pass", partial_save_each_pass); // If enabled, it will autosave the image at the end of each pass params.getParam("film_autosave", film_autosave); // If enabled, it will autosave the Image Film at the same time as the image files + params.getParam("film_save_binary_format", film_save_binary_format); // If enabled, it will autosave the Image Film in binary format (faster, smaller, but not portable). Otherwise it will autosave in text format (portable but bigger and slower) params.getParam("film_load", film_load); // If enabled, it will load the image film from a file before start rendering, might be useful to continue interrupted renders but it has to be used with care. If it does not match exactly the scene, bad results or even crashes could happen if(color_space_string == "sRGB") color_space = SRGB; @@ -626,10 +628,13 @@ imageFilm_t* renderEnvironment_t::createImageFilm(const paraMap_t ¶ms, color } film->setAutoSave(film_autosave); - if(film_autosave) Y_INFO_ENV << "Enabling imageFilm AutoSave feature" << yendl; + film->setAutoSaveBinary(film_save_binary_format); + + if(film_autosave && film_save_binary_format) Y_INFO_ENV << "Enabling imageFilm AutoSave feature in binary format (smaller, faster but not portable among systems)" << yendl; + if(film_autosave && !film_save_binary_format) Y_INFO_ENV << "Enabling imageFilm AutoSave feature in text format (portable among systems but bigger and slower)" << yendl; film->setAutoLoad(film_load); - if(film_load) Y_INFO_ENV << "Enabling imageFilm AutoLoad feature. It will load the image film from a file before start rendering. If it does not match exactly the scene, bad results or even crashes could happen. Use WITH CARE!" << yendl; + if(film_load) Y_INFO_ENV << "Enabling imageFilm AutoLoad feature. It will load and combine all ImageFilm files (*.film) from the currently selected image output folder before start rendering, autodetecting each film format (binary/text) automatically. If they don't match exactly the scene, bad results could happen. Use WITH CARE!" << yendl; return film; } diff --git a/src/yafraycore/imagefilm.cc b/src/yafraycore/imagefilm.cc index 194c4586..7ad3eb1b 100755 --- a/src/yafraycore/imagefilm.cc +++ b/src/yafraycore/imagefilm.cc @@ -181,7 +181,9 @@ imageFilm_t::imageFilm_t (int width, int height, int xstart, int ystart, colorOu AA_clamp_samples = 0.f; autoSave = false; + autoSaveBinary = true; autoLoad = false; + } imageFilm_t::~imageFilm_t () @@ -238,6 +240,19 @@ void imageFilm_t::init(int numPasses) if(autoLoad) { + std::stringstream passString; + passString << "Loading ImageFilm files"; + + Y_INFO << passString.str() << yendl; + + std::string oldTag; + + if(pbar) + { + oldTag = pbar->getTag(); + pbar->setTag(passString.str().c_str()); + } + std::string filmPath = session.getPathImageOutput(); std::stringstream node; node << std::setfill('0') << std::setw(4) << computerNode; @@ -261,7 +276,6 @@ void imageFilm_t::init(int numPasses) for(auto filmFile: filmFilesList) { - Y_INFO << "imageFilm: Loading film from: \"" << filmFile << "\"" << yendl; imageFilm_t *loadedFilm = new imageFilm_t(w, h, cx0, cy0, *output, 1.0, BOX, env); loadedFilm->imageFilmLoad(filmFile, false); @@ -288,6 +302,8 @@ void imageFilm_t::init(int numPasses) { Y_WARNING << "imageFilm: error during imageFilm loading process: \"" << e.what() << "\"" << yendl; } + + if(pbar) pbar->setTag(oldTag); } //film load check data initialization @@ -797,11 +813,61 @@ void imageFilm_t::flush(int numView, int flags, colorOutput_t *out) } } - if(out1 && (session.renderFinished() || !out2)) out1->flush(numView, env->getRenderPasses()); - if(out2) out2->flush(numView, env->getRenderPasses()); + if(out1 && (session.renderFinished() || !out2)) + { + std::stringstream passString; + passString << "Saving image files"; + + Y_INFO << passString.str() << yendl; + + std::string oldTag; + + if(pbar) + { + oldTag = pbar->getTag(); + pbar->setTag(passString.str().c_str()); + } + + out1->flush(numView, env->getRenderPasses()); + + if(pbar) pbar->setTag(oldTag); + } + + if(out2) + { + std::stringstream passString; + passString << "Saving image files"; + + Y_INFO << passString.str() << yendl; + + std::string oldTag; + + if(pbar) + { + oldTag = pbar->getTag(); + pbar->setTag(passString.str().c_str()); + } + + out2->flush(numView, env->getRenderPasses()); + + if(pbar) pbar->setTag(oldTag); + } if(autoSave && (!session.isInteractive() || (session.isInteractive() && out2))) //only save film if the session is not interactive (i.e. yafaray-xml or render into file) or else if the session is interactive and we have secondary file output. We don't want to save the film in the material/lamp/world previews or if we don't have secondary file output (both cases interactive without out2) { + std::stringstream passString; + passString << "Saving internal ImageFilm file"; + + Y_INFO << passString.str() << yendl; + + std::string oldTag; + + if(pbar) + { + oldTag = pbar->getTag(); + pbar->setTag(passString.str().c_str()); + } + std::string filmPath = session.getPathImageOutput(); std::stringstream node; node << std::setfill('0') << std::setw(4) << computerNode; @@ -821,9 +887,9 @@ void imageFilm_t::flush(int numView, int flags, colorOutput_t *out) Y_WARNING << "imageFilm: error during imageFilm file backup \"" << e.what() << "\"" << yendl; } } - Y_INFO << "imageFilm: Saving film to: \"" << filmPath << "\"" << yendl; this->imageFilmSave(filmPath, false); - Y_VERBOSE << "imageFilm: Saved film to: \"" << filmPath << "\"" << yendl; + + if(pbar) pbar->setTag(oldTag); } if(session.renderFinished()) @@ -1224,6 +1290,11 @@ void imageFilm_t::setAutoSave(bool auto_save) autoSave = auto_save; } +void imageFilm_t::setAutoSaveBinary(bool auto_save_binary) +{ + autoSaveBinary = auto_save_binary; +} + void imageFilm_t::setAutoLoad(bool auto_load) { autoLoad = auto_load; @@ -1244,25 +1315,26 @@ bool imageFilm_t::imageFilmLoad(const std::string &filename, bool debugXMLformat if(debugXMLformat) { - Y_DEBUG << "serialization: trying to load in XML format" << yendl; + Y_INFO << "imageFilm: Loading film from: \"" << filename << "\" in XML format" << yendl; boost::archive::xml_iarchive ia(ifs); ia >> BOOST_SERIALIZATION_NVP(*this); ifs.close(); } else if(binaryfile == true) { - Y_DEBUG << "serialization: trying to load in Binary format" << yendl; + Y_INFO << "imageFilm: Loading film from: \"" << filename << "\" in Binary (non portable) format" << yendl; boost::archive::binary_iarchive ia(ifs); ia >> BOOST_SERIALIZATION_NVP(*this); ifs.close(); } else { - Y_DEBUG << "serialization: trying to load in Text format" << yendl; + Y_INFO << "imageFilm: Loading film from: \"" << filename << "\" in Text format" << yendl; boost::archive::text_iarchive ia(ifs); ia >> BOOST_SERIALIZATION_NVP(*this); ifs.close(); } + Y_VERBOSE << "imageFilm: Film loaded from file." << yendl; return true; } catch(std::exception& ex){ @@ -1279,17 +1351,26 @@ bool imageFilm_t::imageFilmSave(const std::string &filename, bool debugXMLformat if(debugXMLformat) { + Y_INFO << "imageFilm: Saving film to: \"" << filename << "\" in XML format" << yendl; boost::archive::xml_oarchive oa(ofs); oa << BOOST_SERIALIZATION_NVP(*this); ofs.close(); } + else if(autoSaveBinary) + { + Y_INFO << "imageFilm: Saving film to: \"" << filename << "\" in Binary (non portable) format" << yendl; + boost::archive::binary_oarchive oa(ofs); + oa << BOOST_SERIALIZATION_NVP(*this); + ofs.close(); + } else { - //boost::archive::binary_oarchive oa(ofs); + Y_INFO << "imageFilm: Saving film to: \"" << filename << "\" in Text format" << yendl; boost::archive::text_oarchive oa(ofs); oa << BOOST_SERIALIZATION_NVP(*this); ofs.close(); } + Y_VERBOSE << "imageFilm: Film saved to file." << yendl; } catch(std::exception& ex){ Y_WARNING << "imageFilm: error '" << ex.what() << "' while saving ImageFilm file: '" << filename << "'" << yendl; diff --git a/src/yafraycore/integrator.cc b/src/yafraycore/integrator.cc index 6e2fcb92..6bbddef1 100755 --- a/src/yafraycore/integrator.cc +++ b/src/yafraycore/integrator.cc @@ -170,7 +170,7 @@ bool tiledIntegrator_t::render(int numView, imageFilm_t *image) if(session.renderResumed()) { passString.clear(); - passString << "Loading film file, skipping pass 1..."; + passString << "Combining ImageFilm files, skipping pass 1..."; intpb->setTag(passString.str().c_str()); } From 10133b48b8a9cc5543b66ad3a57a7ffcc141b195 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Thu, 26 May 2016 05:36:59 +0100 Subject: [PATCH 068/124] ImageFilm load: make sure any still not rendered pixels from the Film are rendered in the next pass --- src/yafraycore/imagefilm.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/yafraycore/imagefilm.cc b/src/yafraycore/imagefilm.cc index 7ad3eb1b..18adce46 100755 --- a/src/yafraycore/imagefilm.cc +++ b/src/yafraycore/imagefilm.cc @@ -368,6 +368,8 @@ int imageFilm_t::nextPass(int numView, bool adaptive_AA, std::string integratorN { //We will only consider the Combined Pass (pass 0) for the AA additional sampling calculations. + if((*imagePasses.at(0))(x, y).weight <= 0.f) flags->setBit(x, y); //If after reloading ImageFiles there are pixels that were not yet rendered at all, make sure they are marked to be rendered in the next AA pass + colorA_t pixCol = (*imagePasses.at(0))(x, y).normalized(); float pixColBri = pixCol.abscol2bri(); From abf4a5bfa4ac192bbb14155075adca6004425947 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Thu, 26 May 2016 06:01:01 +0100 Subject: [PATCH 069/124] ImageFilm saving: improved backup of previous film file, faster and only at the beginning --- src/yafraycore/imagefilm.cc | 66 +++++++++++++++++++++++++++++-------- 1 file changed, 52 insertions(+), 14 deletions(-) diff --git a/src/yafraycore/imagefilm.cc b/src/yafraycore/imagefilm.cc index 18adce46..80e4c30d 100755 --- a/src/yafraycore/imagefilm.cc +++ b/src/yafraycore/imagefilm.cc @@ -306,6 +306,58 @@ void imageFilm_t::init(int numPasses) if(pbar) pbar->setTag(oldTag); } + if(autoSave) //If the imageFilm is set to Auto Save, at the start rename the previous film file as a "backup" just in case the user has made a mistake and wants to get the previous film back + { + std::stringstream passString; + passString << "Creating backup of the previous ImageFilm file..."; + + Y_INFO << passString.str() << yendl; + + std::string oldTag; + + if(pbar) + { + oldTag = pbar->getTag(); + pbar->setTag(passString.str().c_str()); + } + + std::string filmPath = session.getPathImageOutput(); + std::stringstream node; + node << std::setfill('0') << std::setw(4) << computerNode; + filmPath += " - node " + node.str(); + filmPath += ".film"; + std::string filmPathBackup = filmPath+"-previous.bak"; + +/* if(boost::filesystem::exists(filmPathBackup)) + { + Y_VERBOSE << "imageFilm: Deleting previous old ImageFilm backup file: \"" << filmPathBackup << "\"" << yendl; + try + { + boost::filesystem::remove(filmPathBackup); + } + catch(const boost::filesystem::filesystem_error& e) + { + Y_WARNING << "imageFilm: error during deletion of old ImageFilm backup \"" << e.what() << "\"" << yendl; + } + } + */ + + if(boost::filesystem::exists(filmPath)) + { + Y_VERBOSE << "imageFilm: Creating backup of previously saved film to: \"" << filmPathBackup << "\"" << yendl; + try + { + boost::filesystem::rename(filmPath, filmPathBackup); + } + catch(const boost::filesystem::filesystem_error& e) + { + Y_WARNING << "imageFilm: error during imageFilm file backup \"" << e.what() << "\"" << yendl; + } + } + + if(pbar) pbar->setTag(oldTag); + } + //film load check data initialization filmload_check.filmStructureVersion = FILM_STRUCTURE_VERSION; filmload_check.w = w; @@ -875,20 +927,6 @@ void imageFilm_t::flush(int numView, int flags, colorOutput_t *out) node << std::setfill('0') << std::setw(4) << computerNode; filmPath += " - node " + node.str(); filmPath += ".film"; - std::string filmPathBackup = filmPath+"-previous.bak"; - - if(boost::filesystem::exists(filmPath)) - { - Y_VERBOSE << "imageFilm: Making backup of previously saved film to: \"" << filmPathBackup << "\"" << yendl; - try - { - boost::filesystem::copy_file(filmPath, filmPathBackup, boost::filesystem::copy_option::overwrite_if_exists); - } - catch(const boost::filesystem::filesystem_error& e) - { - Y_WARNING << "imageFilm: error during imageFilm file backup \"" << e.what() << "\"" << yendl; - } - } this->imageFilmSave(filmPath, false); if(pbar) pbar->setTag(oldTag); From 42ad1721017e2f6a752caa2b655277628aa5e74c Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Thu, 26 May 2016 06:04:00 +0100 Subject: [PATCH 070/124] imageFilm save: removing unnecessary code --- src/yafraycore/imagefilm.cc | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/yafraycore/imagefilm.cc b/src/yafraycore/imagefilm.cc index 80e4c30d..c7573044 100755 --- a/src/yafraycore/imagefilm.cc +++ b/src/yafraycore/imagefilm.cc @@ -327,20 +327,6 @@ void imageFilm_t::init(int numPasses) filmPath += " - node " + node.str(); filmPath += ".film"; std::string filmPathBackup = filmPath+"-previous.bak"; - -/* if(boost::filesystem::exists(filmPathBackup)) - { - Y_VERBOSE << "imageFilm: Deleting previous old ImageFilm backup file: \"" << filmPathBackup << "\"" << yendl; - try - { - boost::filesystem::remove(filmPathBackup); - } - catch(const boost::filesystem::filesystem_error& e) - { - Y_WARNING << "imageFilm: error during deletion of old ImageFilm backup \"" << e.what() << "\"" << yendl; - } - } - */ if(boost::filesystem::exists(filmPath)) { From 8dfcbc92aeb789e671948894c4bdb4d072e3241e Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Thu, 26 May 2016 06:09:25 +0100 Subject: [PATCH 071/124] Changes for v3.0.0-ALPHA7: imageFilm save format option, autodetection of ImageFilm format when loading, better messages, tags and backup of film file --- include/yafray_constants.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/yafray_constants.h b/include/yafray_constants.h index 171af946..544d76a3 100755 --- a/include/yafray_constants.h +++ b/include/yafray_constants.h @@ -5,7 +5,7 @@ #define __END_YAFRAY } #define PACKAGE "YafaRay" -#define VERSION "3.0.0-ALPHA6" +#define VERSION "3.0.0-ALPHA7" #if (__GNUC__ > 3) #define GCC_HASCLASSVISIBILITY From 37af8b756e790cb9e6850b1a03fcbe13faff21df Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sun, 5 Jun 2016 13:33:07 +0100 Subject: [PATCH 072/124] Image Loading - fix for unicode filenames in Windows with MinGW and GCC v5.3 Due to a GCC fixed in v5.3 (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66855) the image loading was broken when compiling with MinGW/GCC 5.3 or higher. This fix ensures the correct endianness no matter what GCC version we use --- src/image_handlers/exrHandler.cc | 2 +- src/image_handlers/hdrHandler.cc | 2 +- src/image_handlers/jpgHandler.cc | 2 +- src/image_handlers/pngHandler.cc | 2 +- src/image_handlers/tgaHandler.cc | 2 +- src/image_handlers/tifHandler.cc | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/image_handlers/exrHandler.cc b/src/image_handlers/exrHandler.cc index 4c8fba0b..34b7af04 100755 --- a/src/image_handlers/exrHandler.cc +++ b/src/image_handlers/exrHandler.cc @@ -225,7 +225,7 @@ colorA_t exrHandler_t::getPixel(int x, int y, int imagePassNumber) bool exrHandler_t::loadFromFile(const std::string &name) { #if defined(_WIN32) - std::wstring_convert,wchar_t> convert; + std::wstring_convert,wchar_t> convert; std::wstring wname = convert.from_bytes(name); FILE *fp = _wfopen(wname.c_str(), L"rb"); //Windows needs the path in UTF16 (unicode) so we have to convert the UTF8 path to UTF16 SetConsoleOutputCP(65001); //set Windows Console to UTF8 so the image path can be displayed correctly diff --git a/src/image_handlers/hdrHandler.cc b/src/image_handlers/hdrHandler.cc index c295a86a..fc199b50 100755 --- a/src/image_handlers/hdrHandler.cc +++ b/src/image_handlers/hdrHandler.cc @@ -96,7 +96,7 @@ void hdrHandler_t::initForOutput(int width, int height, const renderPasses_t *re bool hdrHandler_t::loadFromFile(const std::string &name) { #if defined(_WIN32) - std::wstring_convert,wchar_t> convert; + std::wstring_convert,wchar_t> convert; std::wstring wname = convert.from_bytes(name); FILE *fp = _wfopen(wname.c_str(), L"rb"); //Windows needs the path in UTF16 (unicode) so we have to convert the UTF8 path to UTF16 SetConsoleOutputCP(65001); //set Windows Console to UTF8 so the image path can be displayed correctly diff --git a/src/image_handlers/jpgHandler.cc b/src/image_handlers/jpgHandler.cc index 01400040..975149bd 100755 --- a/src/image_handlers/jpgHandler.cc +++ b/src/image_handlers/jpgHandler.cc @@ -269,7 +269,7 @@ bool jpgHandler_t::loadFromFile(const std::string &name) jpgErrorManager jerr; #if defined(_WIN32) - std::wstring_convert,wchar_t> convert; + std::wstring_convert,wchar_t> convert; std::wstring wname = convert.from_bytes(name); FILE *fp = _wfopen(wname.c_str(), L"rb"); //Windows needs the path in UTF16 (unicode) so we have to convert the UTF8 path to UTF16 SetConsoleOutputCP(65001); //set Windows Console to UTF8 so the image path can be displayed correctly diff --git a/src/image_handlers/pngHandler.cc b/src/image_handlers/pngHandler.cc index dcc32b6e..bad75c86 100755 --- a/src/image_handlers/pngHandler.cc +++ b/src/image_handlers/pngHandler.cc @@ -208,7 +208,7 @@ bool pngHandler_t::loadFromFile(const std::string &name) png_infop infoPtr = nullptr; #if defined(_WIN32) - std::wstring_convert,wchar_t> convert; + std::wstring_convert,wchar_t> convert; std::wstring wname = convert.from_bytes(name); FILE *fp = _wfopen(wname.c_str(), L"rb"); //Windows needs the path in UTF16 (unicode) so we have to convert the UTF8 path to UTF16 SetConsoleOutputCP(65001); //set Windows Console to UTF8 so the image path can be displayed correctly diff --git a/src/image_handlers/tgaHandler.cc b/src/image_handlers/tgaHandler.cc index 07c6e1ab..458443a4 100755 --- a/src/image_handlers/tgaHandler.cc +++ b/src/image_handlers/tgaHandler.cc @@ -432,7 +432,7 @@ bool tgaHandler_t::precheckFile(tgaHeader_t &header, const std::string &name, bo bool tgaHandler_t::loadFromFile(const std::string &name) { #if defined(_WIN32) - std::wstring_convert,wchar_t> convert; + std::wstring_convert,wchar_t> convert; std::wstring wname = convert.from_bytes(name); FILE *fp = _wfopen(wname.c_str(), L"rb"); //Windows needs the path in UTF16 (unicode) so we have to convert the UTF8 path to UTF16 SetConsoleOutputCP(65001); //set Windows Console to UTF8 so the image path can be displayed correctly diff --git a/src/image_handlers/tifHandler.cc b/src/image_handlers/tifHandler.cc index 3c047d39..033e4dc0 100755 --- a/src/image_handlers/tifHandler.cc +++ b/src/image_handlers/tifHandler.cc @@ -179,7 +179,7 @@ bool tifHandler_t::loadFromFile(const std::string &name) uint32 w, h; #if defined(_WIN32) - std::wstring_convert,wchar_t> convert; + std::wstring_convert,wchar_t> convert; std::wstring wname = convert.from_bytes(name); TIFF *tif = TIFFOpenW(wname.c_str(), "r"); //Windows needs the path in UTF16 (unicode) so we have to convert the UTF8 path to UTF16 SetConsoleOutputCP(65001); //set Windows Console to UTF8 so the image path can be displayed correctly From 82975ee08356a8c38e0968d17613301e783aa999 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sun, 5 Jun 2016 20:52:35 +0100 Subject: [PATCH 073/124] Image Load and Save: encapsulation of Unicode file paths (work in progress) and trying (not yet) to solve EXCEPTION_ACCESS_VIOLATION when saving Logs --- include/core_api/imagehandler.h | 1 + include/utilities/fileUtils.h | 61 ++++++++++++++++++++++++++++++++ src/image_handlers/exrHandler.cc | 7 +--- src/image_handlers/hdrHandler.cc | 29 +++++++-------- src/image_handlers/jpgHandler.cc | 30 ++++++---------- src/image_handlers/pngHandler.cc | 24 +++++-------- src/image_handlers/tgaHandler.cc | 27 +++++--------- src/image_handlers/tifHandler.cc | 11 ++++-- src/yafraycore/imagefilm.cc | 7 ++-- src/yafraycore/logging.cc | 15 +++++--- 10 files changed, 125 insertions(+), 87 deletions(-) create mode 100755 include/utilities/fileUtils.h diff --git a/include/core_api/imagehandler.h b/include/core_api/imagehandler.h index 63435b87..3070dc9e 100755 --- a/include/core_api/imagehandler.h +++ b/include/core_api/imagehandler.h @@ -25,6 +25,7 @@ #include "yafray_constants.h" #include + #include #include #include diff --git a/include/utilities/fileUtils.h b/include/utilities/fileUtils.h new file mode 100755 index 00000000..3bc4aaa9 --- /dev/null +++ b/include/utilities/fileUtils.h @@ -0,0 +1,61 @@ +/**************************************************************************** + * + * fileUtils.h: File Utilities api + * This is part of the yafray package + * Copyright (C) 2016 David Bluecame + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef Y_FILEUTILS_H +#define Y_FILEUTILS_H + +#include + +#include +#include +#include + +#include + +__BEGIN_YAFRAY + +FILE * fileUnicodeOpen(const std::string &filename, const std::string &fileaccess) +{ + FILE * filepointer = nullptr; + +#if defined(_WIN32) + std::wstring_convert,wchar_t> convert; + std::wstring wfilename = convert.from_bytes(filename); + std::wstringstream wfileaccess; + wfileaccess << fileaccess.c_str(); + filepointer = _wfopen(wfilename.c_str(), wfileaccess.str().c_str()); //Windows needs the path in UTF16 (unicode) so we have to convert the UTF8 path to UTF16 + SetConsoleOutputCP(65001); //set Windows Console to UTF8 so the image path can be displayed correctly +#else + filepointer = fopen(filename.c_str(), fileaccess); +#endif + return filepointer; +} + +int fileUnicodeClose(FILE * filepointer) +{ + return fclose(filepointer); +} + + +__END_YAFRAY + +#endif diff --git a/src/image_handlers/exrHandler.cc b/src/image_handlers/exrHandler.cc index 34b7af04..afcf9c58 100755 --- a/src/image_handlers/exrHandler.cc +++ b/src/image_handlers/exrHandler.cc @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -32,12 +33,6 @@ #include #include -#include -#include -#include - -#include - using namespace Imf; using namespace Imath; diff --git a/src/image_handlers/hdrHandler.cc b/src/image_handlers/hdrHandler.cc index fc199b50..b66388b5 100755 --- a/src/image_handlers/hdrHandler.cc +++ b/src/image_handlers/hdrHandler.cc @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -95,14 +96,8 @@ void hdrHandler_t::initForOutput(int width, int height, const renderPasses_t *re bool hdrHandler_t::loadFromFile(const std::string &name) { -#if defined(_WIN32) - std::wstring_convert,wchar_t> convert; - std::wstring wname = convert.from_bytes(name); - FILE *fp = _wfopen(wname.c_str(), L"rb"); //Windows needs the path in UTF16 (unicode) so we have to convert the UTF8 path to UTF16 - SetConsoleOutputCP(65001); //set Windows Console to UTF8 so the image path can be displayed correctly -#else - FILE *fp = fopen(name.c_str(), "rb"); -#endif + FILE *fp = fileUnicodeOpen(name, "rb"); + Y_INFO << handlerName << ": Loading image \"" << name << "\"..." << yendl; if(!fp) @@ -114,7 +109,7 @@ bool hdrHandler_t::loadFromFile(const std::string &name) if (!readHeader(fp)) { Y_ERROR << handlerName << ": An error has occurred while reading the header..." << yendl; - fclose(fp); + fileUnicodeClose(fp); return false; } @@ -142,11 +137,11 @@ bool hdrHandler_t::loadFromFile(const std::string &name) if (!readORLE(fp, y, scanWidth)) { Y_ERROR << handlerName << ": An error has occurred while reading uncompressed scanline..." << yendl; - fclose(fp); + fileUnicodeClose(fp); return false; } } - fclose(fp); + fileUnicodeClose(fp); return true; } @@ -157,14 +152,14 @@ bool hdrHandler_t::loadFromFile(const std::string &name) if (fread((char *)&pix, 1, sizeof(rgbePixel_t), fp) != sizeof(rgbePixel_t)) { Y_ERROR << handlerName << ": An error has occurred while reading scanline start..." << yendl; - fclose(fp); + fileUnicodeClose(fp); return false; } if (feof(fp)) { Y_ERROR << handlerName << ": EOF reached while reading scanline start..." << yendl; - fclose(fp); + fileUnicodeClose(fp); return false; } @@ -173,14 +168,14 @@ bool hdrHandler_t::loadFromFile(const std::string &name) if (pix.getARLECount() > scanWidth) { Y_ERROR << handlerName << ": Error reading, invalid ARLE scanline width..." << yendl; - fclose(fp); + fileUnicodeClose(fp); return false; } if (!readARLE(fp, y, pix.getARLECount())) { Y_ERROR << handlerName << ": An error has occurred while reading ARLE scanline..." << yendl; - fclose(fp); + fileUnicodeClose(fp); return false; } } @@ -192,13 +187,13 @@ bool hdrHandler_t::loadFromFile(const std::string &name) if(!readORLE(fp, y, scanWidth)) { Y_ERROR << handlerName << ": An error has occurred while reading RLE scanline..." << yendl; - fclose(fp); + fileUnicodeClose(fp); return false; } } } - fclose(fp); + fileUnicodeClose(fp); Y_VERBOSE << handlerName << ": Done." << yendl; diff --git a/src/image_handlers/jpgHandler.cc b/src/image_handlers/jpgHandler.cc index 975149bd..56e49dc2 100755 --- a/src/image_handlers/jpgHandler.cc +++ b/src/image_handlers/jpgHandler.cc @@ -25,10 +25,7 @@ #include #include #include - -#include -#include -#include +#include extern "C" { @@ -146,13 +143,12 @@ bool jpgHandler_t::saveToFile(const std::string &name, int imagePassNumber) if(session.renderInProgress()) Y_INFO << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") RGB" << " file as \"" << nameWithoutTmp << "\"..." << yendl; else Y_INFO << handlerName << ": Saving RGB" << " file as \"" << nameWithoutTmp << "\"..." << yendl; - FILE * fp; struct jpeg_compress_struct info; struct jpgErrorManager jerr; int x, y, ix; yByte *scanline = nullptr; - fp = fopen(name.c_str(), "wb"); + FILE * fp = fileUnicodeOpen(name, "wb"); if (!fp) { @@ -201,7 +197,7 @@ bool jpgHandler_t::saveToFile(const std::string &name, int imagePassNumber) jpeg_finish_compress(&info); jpeg_destroy_compress(&info); - fclose(fp); + fileUnicodeClose(fp); if(m_hasAlpha) { @@ -209,7 +205,7 @@ bool jpgHandler_t::saveToFile(const std::string &name, int imagePassNumber) if(session.renderInProgress()) Y_INFO << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") Alpha channel as \"" << alphaname << "\"..." << yendl; else Y_INFO << handlerName << ": Saving Alpha channel as \"" << alphaname << "\"..." << yendl; - fp = fopen(alphaname.c_str(), "wb"); + fp = fileUnicodeOpen(alphaname, "wb"); if (!fp) { @@ -255,7 +251,7 @@ bool jpgHandler_t::saveToFile(const std::string &name, int imagePassNumber) jpeg_finish_compress(&info); jpeg_destroy_compress(&info); - fclose(fp); + fileUnicodeClose(fp); } Y_VERBOSE << handlerName << ": Done." << yendl; @@ -268,14 +264,8 @@ bool jpgHandler_t::loadFromFile(const std::string &name) jpeg_decompress_struct info; jpgErrorManager jerr; -#if defined(_WIN32) - std::wstring_convert,wchar_t> convert; - std::wstring wname = convert.from_bytes(name); - FILE *fp = _wfopen(wname.c_str(), L"rb"); //Windows needs the path in UTF16 (unicode) so we have to convert the UTF8 path to UTF16 - SetConsoleOutputCP(65001); //set Windows Console to UTF8 so the image path can be displayed correctly -#else - FILE *fp = fopen(name.c_str(), "rb"); -#endif + FILE *fp = fileUnicodeOpen(name, "rb"); + Y_INFO << handlerName << ": Loading image \"" << name << "\"..." << yendl; if(!fp) @@ -292,7 +282,7 @@ bool jpgHandler_t::loadFromFile(const std::string &name) { jpeg_destroy_decompress(&info); - fclose(fp); + fileUnicodeClose(fp); return false; } @@ -314,7 +304,7 @@ bool jpgHandler_t::loadFromFile(const std::string &name) jpeg_finish_decompress(&info); jpeg_destroy_decompress(&info); - fclose(fp); + fileUnicodeClose(fp); return false; } @@ -396,7 +386,7 @@ bool jpgHandler_t::loadFromFile(const std::string &name) jpeg_finish_decompress(&info); jpeg_destroy_decompress(&info); - fclose(fp); + fileUnicodeClose(fp); Y_VERBOSE << handlerName << ": Done." << yendl; diff --git a/src/image_handlers/pngHandler.cc b/src/image_handlers/pngHandler.cc index bad75c86..fb59a88f 100755 --- a/src/image_handlers/pngHandler.cc +++ b/src/image_handlers/pngHandler.cc @@ -25,8 +25,7 @@ #include #include #include -#include -#include +#include #include @@ -134,13 +133,12 @@ bool pngHandler_t::saveToFile(const std::string &name, int imagePassNumber) if(session.renderInProgress()) Y_INFO << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << nameWithoutTmp << "\"..." << yendl; else Y_INFO << handlerName << ": Saving RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << nameWithoutTmp << "\"..." << yendl; - FILE *fp; png_structp pngPtr; png_infop infoPtr; int channels; png_bytep *rowPointers = nullptr; - fp = fopen(name.c_str(), "wb"); + FILE * fp = fileUnicodeOpen(name, "wb"); if(!fp) { @@ -150,7 +148,7 @@ bool pngHandler_t::saveToFile(const std::string &name, int imagePassNumber) if(!fillWriteStructs(fp, (m_hasAlpha) ? PNG_COLOR_TYPE_RGB_ALPHA : PNG_COLOR_TYPE_RGB, pngPtr, infoPtr)) { - fclose(fp); + fileUnicodeClose(fp); return false; } @@ -187,7 +185,7 @@ bool pngHandler_t::saveToFile(const std::string &name, int imagePassNumber) png_destroy_write_struct(&pngPtr, &infoPtr); - fclose(fp); + fileUnicodeClose(fp); // cleanup: for(int i = 0; i < m_height; i++) @@ -207,14 +205,8 @@ bool pngHandler_t::loadFromFile(const std::string &name) png_structp pngPtr = nullptr; png_infop infoPtr = nullptr; -#if defined(_WIN32) - std::wstring_convert,wchar_t> convert; - std::wstring wname = convert.from_bytes(name); - FILE *fp = _wfopen(wname.c_str(), L"rb"); //Windows needs the path in UTF16 (unicode) so we have to convert the UTF8 path to UTF16 - SetConsoleOutputCP(65001); //set Windows Console to UTF8 so the image path can be displayed correctly -#else - FILE *fp = fopen(name.c_str(), "rb"); -#endif + FILE *fp = fileUnicodeOpen(name, "rb"); + Y_INFO << handlerName << ": Loading image \"" << name << "\"..." << yendl; if(!fp) @@ -233,7 +225,7 @@ bool pngHandler_t::loadFromFile(const std::string &name) if(!fillReadStructs(signature, pngPtr, infoPtr)) { - fclose(fp); + fileUnicodeClose(fp); return false; } @@ -243,7 +235,7 @@ bool pngHandler_t::loadFromFile(const std::string &name) readFromStructs(pngPtr, infoPtr); - fclose(fp); + fileUnicodeClose(fp); Y_VERBOSE << handlerName << ": Done." << yendl; diff --git a/src/image_handlers/tgaHandler.cc b/src/image_handlers/tgaHandler.cc index 458443a4..966021b4 100755 --- a/src/image_handlers/tgaHandler.cc +++ b/src/image_handlers/tgaHandler.cc @@ -25,13 +25,10 @@ #include #include #include +#include #include "tgaUtils.h" -#include -#include -#include - __BEGIN_YAFRAY class tgaHandler_t; @@ -145,10 +142,8 @@ bool tgaHandler_t::saveToFile(const std::string &name, int imagePassNumber) header.height = m_height; header.bitDepth = ((m_hasAlpha) ? 32 : 24 ); header.desc = TL | ((m_hasAlpha) ? alpha8 : noAlpha ); - - FILE* fp; - - fp = fopen(name.c_str(), "wb"); + + FILE * fp = fileUnicodeOpen(name, "wb"); if (fp == nullptr) return false; @@ -178,7 +173,7 @@ bool tgaHandler_t::saveToFile(const std::string &name, int imagePassNumber) } fwrite(&footer, sizeof(tgaFooter_t), 1, fp); - fclose(fp); + fileUnicodeClose(fp); } Y_VERBOSE << handlerName << ": Done." << yendl; @@ -431,14 +426,8 @@ bool tgaHandler_t::precheckFile(tgaHeader_t &header, const std::string &name, bo bool tgaHandler_t::loadFromFile(const std::string &name) { -#if defined(_WIN32) - std::wstring_convert,wchar_t> convert; - std::wstring wname = convert.from_bytes(name); - FILE *fp = _wfopen(wname.c_str(), L"rb"); //Windows needs the path in UTF16 (unicode) so we have to convert the UTF8 path to UTF16 - SetConsoleOutputCP(65001); //set Windows Console to UTF8 so the image path can be displayed correctly -#else - FILE *fp = fopen(name.c_str(), "rb"); -#endif + FILE *fp = fileUnicodeOpen(name, "rb"); + Y_INFO << handlerName << ": Loading image \"" << name << "\"..." << yendl; if(!fp) @@ -467,7 +456,7 @@ bool tgaHandler_t::loadFromFile(const std::string &name) if(!precheckFile(header, name, isGray, isRLE, hasColorMap, alphaBitDepth)) { - fclose(fp); + fileUnicodeClose(fp); return false; } @@ -607,7 +596,7 @@ bool tgaHandler_t::loadFromFile(const std::string &name) } } - fclose(fp); + fileUnicodeClose(fp); fp = nullptr; if (ColorMap) delete ColorMap; diff --git a/src/image_handlers/tifHandler.cc b/src/image_handlers/tifHandler.cc index 033e4dc0..57c7450e 100755 --- a/src/image_handlers/tifHandler.cc +++ b/src/image_handlers/tifHandler.cc @@ -25,10 +25,9 @@ #include #include #include +#include #include -#include -#include __BEGIN_YAFRAY @@ -122,7 +121,15 @@ bool tifHandler_t::saveToFile(const std::string &name, int imagePassNumber) if(session.renderInProgress()) Y_INFO << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << nameWithoutTmp << "\"..." << yendl; else Y_INFO << handlerName << ": Saving RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << nameWithoutTmp << "\"..." << yendl; +#if defined(_WIN32) + std::wstring_convert,wchar_t> convert; + std::wstring wname = convert.from_bytes(name); + TIFF *out = TIFFOpenW(wname.c_str(), "w"); //Windows needs the path in UTF16 (unicode) so we have to convert the UTF8 path to UTF16 + SetConsoleOutputCP(65001); //set Windows Console to UTF8 so the image path can be displayed correctly +#else TIFF *out = TIFFOpen(name.c_str(), "w"); +#endif + int channels; size_t bytesPerScanline; diff --git a/src/yafraycore/imagefilm.cc b/src/yafraycore/imagefilm.cc index c7573044..19d0f572 100755 --- a/src/yafraycore/imagefilm.cc +++ b/src/yafraycore/imagefilm.cc @@ -853,10 +853,11 @@ void imageFilm_t::flush(int numView, int flags, colorOutput_t *out) } } - if(out1 && (session.renderFinished() || !out2)) + if(out1 && (session.renderFinished() || out1->isImageOutput())) { std::stringstream passString; - passString << "Saving image files"; + if(out1->isImageOutput()) passString << "Saving image files"; + else passString << "Flushing output"; Y_INFO << passString.str() << yendl; @@ -873,7 +874,7 @@ void imageFilm_t::flush(int numView, int flags, colorOutput_t *out) if(pbar) pbar->setTag(oldTag); } - if(out2) + if(out2 && out2->isImageOutput()) { std::stringstream passString; passString << "Saving image files"; diff --git a/src/yafraycore/logging.cc b/src/yafraycore/logging.cc index a192f4e4..def4af14 100755 --- a/src/yafraycore/logging.cc +++ b/src/yafraycore/logging.cc @@ -45,8 +45,9 @@ void yafarayLog_t::saveTxtLog(const std::string &name) { if(!mSaveLog) return; - std::ofstream txtLogFile; - txtLogFile.open(name.c_str()); +Y_DEBUG << "yafarayLog_t::saveTxtLog(const std::string &name) " << name << yendl; + std::ofstream txtLogFile123; +/* txtLogFile.open(name.c_str()); txtLogFile << "YafaRay Image Log file " << std::endl << std::endl; @@ -82,14 +83,18 @@ void yafarayLog_t::saveTxtLog(const std::string &name) txtLogFile << it->eventDescription; } } + txtLogFile.close(); +*/ } void yafarayLog_t::saveHtmlLog(const std::string &name) { if(!mSaveHTML) return; - std::ofstream htmlLogFile; - htmlLogFile.open(name.c_str()); +Y_DEBUG << "yafarayLog_t::saveHtmlLog(const std::string &name) " << name << yendl; + + std::ofstream htmlLogFile123; +/* htmlLogFile.open(name.c_str()); std::string baseImgPath, baseImgFileName, imgExtension; @@ -178,6 +183,8 @@ void yafarayLog_t::saveHtmlLog(const std::string &name) } htmlLogFile << std::endl << "" << std::endl; } + htmlLogFile.close(); + */ } void yafarayLog_t::clearMemoryLog() From dc4630d28c042e7c9c3db1e034d4b0d49c1a9ffd Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Mon, 6 Jun 2016 04:16:53 +0100 Subject: [PATCH 074/124] Fix to compile with GCC v6.1 --- include/third_party/mingw-std-threads/mingw.mutex.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/third_party/mingw-std-threads/mingw.mutex.h b/include/third_party/mingw-std-threads/mingw.mutex.h index d4532026..cc33f43c 100755 --- a/include/third_party/mingw-std-threads/mingw.mutex.h +++ b/include/third_party/mingw-std-threads/mingw.mutex.h @@ -216,7 +216,7 @@ class timed_mutex: public _NonRecursive timed_mutex(const timed_mutex&) = delete; timed_mutex& operator=(const timed_mutex&) = delete; template - void try_lock_for(const std::chrono::duration& dur) + bool try_lock_for(const std::chrono::duration& dur) { bool ret = base::try_lock_for(dur); #ifndef STDMUTEX_NO_RECURSION_CHECKS From b2d5e0f78d34b91b3b8c06e5fccd3f90ae8564e6 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Mon, 6 Jun 2016 04:24:16 +0100 Subject: [PATCH 075/124] Re-enabling logging code, the problem with EXCEPTION_ACCESS_VIOLATION was clearly a compilation/library linking issue, not happening when compiling with in another platform with different GCC version, but now I get the exception in EXR loading! --- src/yafraycore/logging.cc | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/yafraycore/logging.cc b/src/yafraycore/logging.cc index def4af14..15a5746a 100755 --- a/src/yafraycore/logging.cc +++ b/src/yafraycore/logging.cc @@ -44,10 +44,9 @@ yafarayLog_t::~yafarayLog_t() void yafarayLog_t::saveTxtLog(const std::string &name) { if(!mSaveLog) return; - -Y_DEBUG << "yafarayLog_t::saveTxtLog(const std::string &name) " << name << yendl; - std::ofstream txtLogFile123; -/* txtLogFile.open(name.c_str()); + + std::ofstream txtLogFile; + txtLogFile.open(name.c_str()); txtLogFile << "YafaRay Image Log file " << std::endl << std::endl; @@ -84,17 +83,14 @@ Y_DEBUG << "yafarayLog_t::saveTxtLog(const std::string &name) " << name << yendl } } txtLogFile.close(); -*/ } void yafarayLog_t::saveHtmlLog(const std::string &name) { if(!mSaveHTML) return; - -Y_DEBUG << "yafarayLog_t::saveHtmlLog(const std::string &name) " << name << yendl; - std::ofstream htmlLogFile123; -/* htmlLogFile.open(name.c_str()); + std::ofstream htmlLogFile; + htmlLogFile.open(name.c_str()); std::string baseImgPath, baseImgFileName, imgExtension; @@ -184,7 +180,6 @@ Y_DEBUG << "yafarayLog_t::saveHtmlLog(const std::string &name) " << name << yend htmlLogFile << std::endl << "" << std::endl; } htmlLogFile.close(); - */ } void yafarayLog_t::clearMemoryLog() From ac7eaac0b5c5b9c5d4cf5ad1eaf50f15c03def27 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Tue, 7 Jun 2016 05:06:44 +0100 Subject: [PATCH 076/124] Corrected unicode file encapsulation for building in non-Windows platforms --- include/utilities/fileUtils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/utilities/fileUtils.h b/include/utilities/fileUtils.h index 3bc4aaa9..c24806cc 100755 --- a/include/utilities/fileUtils.h +++ b/include/utilities/fileUtils.h @@ -45,7 +45,7 @@ FILE * fileUnicodeOpen(const std::string &filename, const std::string &fileacces filepointer = _wfopen(wfilename.c_str(), wfileaccess.str().c_str()); //Windows needs the path in UTF16 (unicode) so we have to convert the UTF8 path to UTF16 SetConsoleOutputCP(65001); //set Windows Console to UTF8 so the image path can be displayed correctly #else - filepointer = fopen(filename.c_str(), fileaccess); + filepointer = fopen(filename.c_str(), fileaccess.c_str()); #endif return filepointer; } From 6cbfbf702ad04681f34855eac210aeb39c1fa887 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Thu, 9 Jun 2016 04:59:54 +0100 Subject: [PATCH 077/124] Locale and Unicode: changes to allow compilation with older GCC versions like 4.9.2 for better compatibility with older versions. Now it requires boost::locale --- CMakeLists.txt | 2 +- include/utilities/fileUtils.h | 2 +- include/utilities/stringUtils.h | 15 +++++++++++---- src/yafraycore/imagefilm.cc | 3 +-- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 73291f95..41ca22f7 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,7 +67,7 @@ if(YAF_USER_EXTRA_LIBS) endif(YAF_USER_EXTRA_LIBS) # find the required libs -FIND_PACKAGE(Boost COMPONENTS system filesystem serialization REQUIRED) +FIND_PACKAGE(Boost COMPONENTS system filesystem serialization locale REQUIRED) INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIR} ) find_package(ZLIB REQUIRED) diff --git a/include/utilities/fileUtils.h b/include/utilities/fileUtils.h index c24806cc..afab9415 100755 --- a/include/utilities/fileUtils.h +++ b/include/utilities/fileUtils.h @@ -27,7 +27,7 @@ #include #include -#include +#include #include diff --git a/include/utilities/stringUtils.h b/include/utilities/stringUtils.h index 43fa0062..293e1ec1 100755 --- a/include/utilities/stringUtils.h +++ b/include/utilities/stringUtils.h @@ -3,7 +3,6 @@ * stringUtils.h: Some std::string manipulation utilities * This is part of the yafray package * Copyright (C) 2010 Rodrigo Placencia Vazquez (DarkTide) - * (except for "utf8_to_utf16", written by John http://stackoverflow.com/users/882003/john) * Creation date: 2010-05-06 * * This library is free software; you can redistribute it and/or @@ -28,9 +27,7 @@ #include #include #include -#include -#include -#include +#include __BEGIN_YAFRAY @@ -71,6 +68,16 @@ inline std::vector tokenize(std::string str, std::string delimiter return result; } +inline std::u32string utf8_to_wutf32(const std::string& utf8str) +{ + return boost::locale::conv::utf_to_utf(utf8str.c_str(), utf8str.c_str() + utf8str.size()); +} + +inline std::string wutf32_to_utf8(const std::u32string& wutf32str) +{ + return boost::locale::conv::utf_to_utf(wutf32str.c_str(), wutf32str.c_str() + wutf32str.size()); +} + __END_YAFRAY #endif diff --git a/src/yafraycore/imagefilm.cc b/src/yafraycore/imagefilm.cc index 19d0f572..fe0ff511 100755 --- a/src/yafraycore/imagefilm.cc +++ b/src/yafraycore/imagefilm.cc @@ -1153,8 +1153,7 @@ void imageFilm_t::drawRenderSettings(std::stringstream & ss) FT_Vector pen; // untransformed origin std::string text_utf8 = ss.str(); - std::wstring_convert,char32_t> convert; - std::u32string wtext_utf32 = convert.from_bytes(text_utf8); + std::u32string wtext_utf32 = utf8_to_wutf32(text_utf8); // set font size at default dpi float fontsize = 12.5f; From bee0228fffb96d5cfd1ea988bde9eabed3825f16 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Fri, 10 Jun 2016 04:55:05 +0100 Subject: [PATCH 078/124] Changes to allow building with MinGW GCC v4.9.2. I had to enable the "manual" math constants definitions copied from math.h --- include/utilities/mathOptimizations.h | 28 ++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/include/utilities/mathOptimizations.h b/include/utilities/mathOptimizations.h index 32cd09ef..c19b6225 100755 --- a/include/utilities/mathOptimizations.h +++ b/include/utilities/mathOptimizations.h @@ -38,20 +38,22 @@ #include // Reference defines, this should be defined by the standard cmath header +// Unfortunately this fails in MinGW GCC v4.9.2, so I have to enable the "manual" definitions copied from math.h + +# define M_E 2.7182818284590452354 /* e */ +# define M_LOG2E 1.4426950408889634074 /* log_2 e */ +# define M_LOG10E 0.43429448190325182765 /* log_10 e */ +# define M_LN2 0.69314718055994530942 /* log_e 2 */ +# define M_LN10 2.30258509299404568402 /* log_e 10 */ +# define M_PI 3.14159265358979323846 /* pi */ +# define M_PI_2 1.57079632679489661923 /* pi/2 */ +# define M_PI_4 0.78539816339744830962 /* pi/4 */ +# define M_1_PI 0.31830988618379067154 /* 1/pi */ +# define M_2_PI 0.63661977236758134308 /* 2/pi */ +# define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */ +# define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ +# define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ -//# define M_E 2.7182818284590452354 /* e */ -//# define M_LOG2E 1.4426950408889634074 /* log_2 e */ -//# define M_LOG10E 0.43429448190325182765 /* log_10 e */ -//# define M_LN2 0.69314718055994530942 /* log_e 2 */ -//# define M_LN10 2.30258509299404568402 /* log_e 10 */ -//# define M_PI 3.14159265358979323846 /* pi */ -//# define M_PI_2 1.57079632679489661923 /* pi/2 */ -//# define M_PI_4 0.78539816339744830962 /* pi/4 */ -//# define M_1_PI 0.31830988618379067154 /* 1/pi */ -//# define M_2_PI 0.63661977236758134308 /* 2/pi */ -//# define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */ -//# define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ -//# define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ __BEGIN_YAFRAY From d4151615f24928e896a1673d5ba410f9f5f8924f Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Fri, 10 Jun 2016 05:12:37 +0100 Subject: [PATCH 079/124] Changes to build with MinGW 4.9.2: changing all Unicode conversions to use Boost::locale --- include/utilities/fileUtils.h | 3 +-- include/utilities/stringUtils.h | 10 ++++++++++ src/image_handlers/exrHandler.cc | 12 +++--------- src/image_handlers/tifHandler.cc | 6 ++---- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/include/utilities/fileUtils.h b/include/utilities/fileUtils.h index afab9415..716bb560 100755 --- a/include/utilities/fileUtils.h +++ b/include/utilities/fileUtils.h @@ -38,8 +38,7 @@ FILE * fileUnicodeOpen(const std::string &filename, const std::string &fileacces FILE * filepointer = nullptr; #if defined(_WIN32) - std::wstring_convert,wchar_t> convert; - std::wstring wfilename = convert.from_bytes(filename); + std::wstring wfilename = utf8_to_wutf16(filename); std::wstringstream wfileaccess; wfileaccess << fileaccess.c_str(); filepointer = _wfopen(wfilename.c_str(), wfileaccess.str().c_str()); //Windows needs the path in UTF16 (unicode) so we have to convert the UTF8 path to UTF16 diff --git a/include/utilities/stringUtils.h b/include/utilities/stringUtils.h index 293e1ec1..bec9144a 100755 --- a/include/utilities/stringUtils.h +++ b/include/utilities/stringUtils.h @@ -78,6 +78,16 @@ inline std::string wutf32_to_utf8(const std::u32string& wutf32str) return boost::locale::conv::utf_to_utf(wutf32str.c_str(), wutf32str.c_str() + wutf32str.size()); } +inline std::wstring utf8_to_wutf16(const std::string& utf8str) +{ + return boost::locale::conv::utf_to_utf(utf8str.c_str(), utf8str.c_str() + utf8str.size()); +} + +inline std::string wutf16_to_utf8(const std::wstring& wutf16str) +{ + return boost::locale::conv::utf_to_utf(wutf16str.c_str(), wutf16str.c_str() + wutf16str.size()); +} + __END_YAFRAY #endif diff --git a/src/image_handlers/exrHandler.cc b/src/image_handlers/exrHandler.cc index afcf9c58..a5161bb8 100755 --- a/src/image_handlers/exrHandler.cc +++ b/src/image_handlers/exrHandler.cc @@ -219,15 +219,9 @@ colorA_t exrHandler_t::getPixel(int x, int y, int imagePassNumber) bool exrHandler_t::loadFromFile(const std::string &name) { -#if defined(_WIN32) - std::wstring_convert,wchar_t> convert; - std::wstring wname = convert.from_bytes(name); - FILE *fp = _wfopen(wname.c_str(), L"rb"); //Windows needs the path in UTF16 (unicode) so we have to convert the UTF8 path to UTF16 - SetConsoleOutputCP(65001); //set Windows Console to UTF8 so the image path can be displayed correctly - std::string tempFilePathString = ""; //filename of the temporary exr file that will be generated to deal with the UTF16 ifstream path problems in OpenEXR libraries with MinGW -#else - FILE *fp = fopen(name.c_str(), "rb"); -#endif + std::string tempFilePathString = ""; //filename of the temporary exr file that will be generated to deal with the UTF16 ifstream path problems in OpenEXR libraries with MinGW + + FILE *fp = fileUnicodeOpen(name.c_str(), "rb"); Y_INFO << handlerName << ": Loading image \"" << name << "\"..." << yendl; if(!fp) diff --git a/src/image_handlers/tifHandler.cc b/src/image_handlers/tifHandler.cc index 57c7450e..1e11f925 100755 --- a/src/image_handlers/tifHandler.cc +++ b/src/image_handlers/tifHandler.cc @@ -122,8 +122,7 @@ bool tifHandler_t::saveToFile(const std::string &name, int imagePassNumber) else Y_INFO << handlerName << ": Saving RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << nameWithoutTmp << "\"..." << yendl; #if defined(_WIN32) - std::wstring_convert,wchar_t> convert; - std::wstring wname = convert.from_bytes(name); + std::wstring wname = utf8_to_wutf16(name); TIFF *out = TIFFOpenW(wname.c_str(), "w"); //Windows needs the path in UTF16 (unicode) so we have to convert the UTF8 path to UTF16 SetConsoleOutputCP(65001); //set Windows Console to UTF8 so the image path can be displayed correctly #else @@ -186,8 +185,7 @@ bool tifHandler_t::loadFromFile(const std::string &name) uint32 w, h; #if defined(_WIN32) - std::wstring_convert,wchar_t> convert; - std::wstring wname = convert.from_bytes(name); + std::wstring wname = utf8_to_wutf16(name); TIFF *tif = TIFFOpenW(wname.c_str(), "r"); //Windows needs the path in UTF16 (unicode) so we have to convert the UTF8 path to UTF16 SetConsoleOutputCP(65001); //set Windows Console to UTF8 so the image path can be displayed correctly #else From 96cd0f16c27279e0b5fd9ff48262b3f1229642cf Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Fri, 10 Jun 2016 05:30:35 +0100 Subject: [PATCH 080/124] Show unicode paths correctly in Windows from the beginning --- include/utilities/fileUtils.h | 1 - src/image_handlers/tifHandler.cc | 2 -- src/yafraycore/session.cc | 3 +++ 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/utilities/fileUtils.h b/include/utilities/fileUtils.h index 716bb560..8eb36523 100755 --- a/include/utilities/fileUtils.h +++ b/include/utilities/fileUtils.h @@ -42,7 +42,6 @@ FILE * fileUnicodeOpen(const std::string &filename, const std::string &fileacces std::wstringstream wfileaccess; wfileaccess << fileaccess.c_str(); filepointer = _wfopen(wfilename.c_str(), wfileaccess.str().c_str()); //Windows needs the path in UTF16 (unicode) so we have to convert the UTF8 path to UTF16 - SetConsoleOutputCP(65001); //set Windows Console to UTF8 so the image path can be displayed correctly #else filepointer = fopen(filename.c_str(), fileaccess.c_str()); #endif diff --git a/src/image_handlers/tifHandler.cc b/src/image_handlers/tifHandler.cc index 1e11f925..0777c36a 100755 --- a/src/image_handlers/tifHandler.cc +++ b/src/image_handlers/tifHandler.cc @@ -124,7 +124,6 @@ bool tifHandler_t::saveToFile(const std::string &name, int imagePassNumber) #if defined(_WIN32) std::wstring wname = utf8_to_wutf16(name); TIFF *out = TIFFOpenW(wname.c_str(), "w"); //Windows needs the path in UTF16 (unicode) so we have to convert the UTF8 path to UTF16 - SetConsoleOutputCP(65001); //set Windows Console to UTF8 so the image path can be displayed correctly #else TIFF *out = TIFFOpen(name.c_str(), "w"); #endif @@ -187,7 +186,6 @@ bool tifHandler_t::loadFromFile(const std::string &name) #if defined(_WIN32) std::wstring wname = utf8_to_wutf16(name); TIFF *tif = TIFFOpenW(wname.c_str(), "r"); //Windows needs the path in UTF16 (unicode) so we have to convert the UTF8 path to UTF16 - SetConsoleOutputCP(65001); //set Windows Console to UTF8 so the image path can be displayed correctly #else TIFF *tif = TIFFOpen(name.c_str(), "r"); #endif diff --git a/src/yafraycore/session.cc b/src/yafraycore/session.cc index 03d0c282..f6a04190 100755 --- a/src/yafraycore/session.cc +++ b/src/yafraycore/session.cc @@ -38,6 +38,9 @@ session_t::session_t(const session_t&) //We need to redefine the copy constructo session_t::session_t() { Y_VERBOSE << "Session:started" << yendl; +#if defined(_WIN32) + SetConsoleOutputCP(65001); //set Windows Console to UTF8 so the image path can be displayed correctly +#endif causticMap = new photonMap_t; causticMap->setName("Caustic Photon Map"); diffuseMap = new photonMap_t; From 3a438009426c09709a6ff83deb559e481abc2bd3 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Fri, 10 Jun 2016 05:48:56 +0100 Subject: [PATCH 081/124] Removing the mingw-std-threads code from YafaRay Core code. It should be used as a library (header only) dependency --- include/core_api/logging.h | 12 +- include/core_api/session.h | 11 - include/third_party/mingw-std-threads/LICENSE | 24 -- .../third_party/mingw-std-threads/README.md | 46 --- .../mingw.condition_variable.h | 211 -------------- .../mingw-std-threads/mingw.mutex.h | 275 ------------------ .../mingw-std-threads/mingw.thread.h | 167 ----------- .../mingw-std-threads/tests/CMakeLists.txt | 7 - .../mingw-std-threads/tests/tests.cpp | 60 ---- include/utilities/threadUtils.h | 44 +++ 10 files changed, 45 insertions(+), 812 deletions(-) delete mode 100755 include/third_party/mingw-std-threads/LICENSE delete mode 100755 include/third_party/mingw-std-threads/README.md delete mode 100755 include/third_party/mingw-std-threads/mingw.condition_variable.h delete mode 100755 include/third_party/mingw-std-threads/mingw.mutex.h delete mode 100755 include/third_party/mingw-std-threads/mingw.thread.h delete mode 100755 include/third_party/mingw-std-threads/tests/CMakeLists.txt delete mode 100755 include/third_party/mingw-std-threads/tests/tests.cpp create mode 100755 include/utilities/threadUtils.h diff --git a/include/core_api/logging.h b/include/core_api/logging.h index 9164e0d9..46e0e403 100755 --- a/include/core_api/logging.h +++ b/include/core_api/logging.h @@ -30,17 +30,7 @@ #include #include #include -#if defined(_WIN32) && defined(__MINGW32__) - #undef _GLIBCXX_HAS_GTHREADS - #include - #include - #include - #include -#else - #include - #include - #include -#endif +#include __BEGIN_YAFRAY diff --git a/include/core_api/session.h b/include/core_api/session.h index 128972ac..2cd1146a 100755 --- a/include/core_api/session.h +++ b/include/core_api/session.h @@ -29,17 +29,6 @@ #include #include #include -#if defined(_WIN32) && defined(__MINGW32__) - #undef _GLIBCXX_HAS_GTHREADS - #include - #include - #include - #include -#else - #include - #include - #include -#endif __BEGIN_YAFRAY diff --git a/include/third_party/mingw-std-threads/LICENSE b/include/third_party/mingw-std-threads/LICENSE deleted file mode 100755 index ac525cf2..00000000 --- a/include/third_party/mingw-std-threads/LICENSE +++ /dev/null @@ -1,24 +0,0 @@ -Copyright (c) 2016, Mega Limited -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -* Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - diff --git a/include/third_party/mingw-std-threads/README.md b/include/third_party/mingw-std-threads/README.md deleted file mode 100755 index 92c31faf..00000000 --- a/include/third_party/mingw-std-threads/README.md +++ /dev/null @@ -1,46 +0,0 @@ -mingw-std-threads -================= - -Standard C++11 threading classes implementation, which are currently still missing -on MinGW GCC. - -Windows compatibility -===================== -This implementation should work with Windows XP (regardless of service pack), or newer. -Since Vista, Windows has native condition variables, but we do not rely on them, to keep compatibility -with Windows XP. - -Usage -===== - -This is a header-only library. To use, just include the corresponding mingw.xxx.h file, where -xxx would be the name of the standard header that you would normally include. -For additional mutex helper classes, such as std::scoped_guard or std::unique_lock, you need to -include <mutex> before including mingw.mutex.h - -Compatibility -============= - -This code has been tested to work with MinGW-w64 5.3.0, but should work with any other MinGW version -that has the std threading classes missing, has C++11 support for lambda functions, variadic -templates, and has working mutex helper classes in <mutex>. - -Switching from the win32-pthread based implemetation -==================================================== -It seems that recent versions of mingw-w64 include a win32 port of pthreads, and have -the std::thread, std::mutex etc classes implemented and working, based on that compatibility -layer. This is a somewhat heavier implementation, as it brings a not very thin abstraction layer. -So you may still want to use this implementation for efficiency purposes. Unfortunately you can't use it -standalone and independent of the system <mutex> header, as it relies on it for std::unique_lock and other -non-trivial utility classes. In that case you will need to edit the c++-config.h file of your MinGW setup -and comment out the definition of _GLIBCXX_HAS_GTHREADS. This will cause the system headers to not define the -actual thread, mutex, etc classes, but still define the necessary utility classes. - -Why MinGW has no threading classes -================================== -It seems that for cross-platform threading implementation, the GCC standard library relies on -the gthreads/pthreads library. If this library is not available, as is the case with MinGW, the -std::thread, std::mutex, std::condition_variable are not defined. However, higher-level mutex -helper classes are still defined in <mutex> and are usable. Hence, this implementation -does not re-define them, and to use these helpers, you should include <mutex> as well, as explained -in the usage section. diff --git a/include/third_party/mingw-std-threads/mingw.condition_variable.h b/include/third_party/mingw-std-threads/mingw.condition_variable.h deleted file mode 100755 index b6647581..00000000 --- a/include/third_party/mingw-std-threads/mingw.condition_variable.h +++ /dev/null @@ -1,211 +0,0 @@ -/** -* @file condition_variable.h -* @brief std::condition_variable implementation for MinGW -* -* (c) 2013-2016 by Mega Limited, Auckland, New Zealand -* @author Alexander Vassilev -* -* @copyright Simplified (2-clause) BSD License. -* You should have received a copy of the license along with this -* program. -* -* This code is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -* @note -* This file may become part of the mingw-w64 runtime package. If/when this happens, -* the appropriate license will be added, i.e. this code will become dual-licensed, -* and the current BSD 2-clause license will stay. -*/ - -#ifndef MINGW_CONDITIONAL_VARIABLE_H -#define MINGW_CONDITIONAL_VARIABLE_H -#include -#include -#include "mingw.mutex.h" -#include -#include -#include -#ifdef _GLIBCXX_HAS_GTHREADS -#error This version of MinGW seems to include a win32 port of pthreads, and probably \ - already has C++11 std threading classes implemented, based on pthreads. \ - It is likely that you will get errors about redefined classes, and unfortunately \ - this implementation can not be used standalone and independent of the system \ - header, since it relies on it for \ - std::unique_lock and other utility classes. If you would still like to use this \ - implementation (as it is more lightweight), you have to edit the \ - c++-config.h system header of your MinGW to not define _GLIBCXX_HAS_GTHREADS. \ - This will prevent system headers from defining actual threading classes while still \ - defining the necessary utility classes. -#endif - -namespace std -{ - -enum class cv_status { no_timeout, timeout }; -class condition_variable_any -{ -protected: - recursive_mutex mMutex; - atomic mNumWaiters; - HANDLE mSemaphore; - HANDLE mWakeEvent; -public: - typedef HANDLE native_handle_type; - native_handle_type native_handle() {return mSemaphore;} - condition_variable_any(const condition_variable_any&) = delete; - condition_variable_any& operator=(const condition_variable_any&) = delete; - condition_variable_any() - :mNumWaiters(0), mSemaphore(CreateSemaphore(NULL, 0, 0xFFFF, NULL)), - mWakeEvent(CreateEvent(NULL, FALSE, FALSE, NULL)) - {} - ~condition_variable_any() { CloseHandle(mWakeEvent); CloseHandle(mSemaphore); } -protected: - template - bool wait_impl(M& lock, DWORD timeout) - { - { - lock_guard guard(mMutex); - mNumWaiters++; - } - lock.unlock(); - DWORD ret = WaitForSingleObject(mSemaphore, timeout); - - mNumWaiters--; - SetEvent(mWakeEvent); - lock.lock(); - if (ret == WAIT_OBJECT_0) - return true; - else if (ret == WAIT_TIMEOUT) - return false; -//2 possible cases: -//1)The point in notify_all() where we determine the count to -//increment the semaphore with has not been reached yet: -//we just need to decrement mNumWaiters, but setting the event does not hurt -// -//2)Semaphore has just been released with mNumWaiters just before -//we decremented it. This means that the semaphore count -//after all waiters finish won't be 0 - because not all waiters -//woke up by acquiring the semaphore - we woke up by a timeout. -//The notify_all() must handle this grafecully -// - else - throw system_error(EPROTO, generic_category()); - } -public: - template - void wait(M& lock) - { - wait_impl(lock, INFINITE); - } - template - void wait(M& lock, Predicate pred) - { - while(!pred()) - { - wait(lock); - }; - } - - void notify_all() noexcept - { - lock_guard lock(mMutex); //block any further wait requests until all current waiters are unblocked - if (mNumWaiters.load() <= 0) - return; - - ReleaseSemaphore(mSemaphore, mNumWaiters, NULL); - while(mNumWaiters > 0) - { - auto ret = WaitForSingleObject(mWakeEvent, 1000); - if ((ret == WAIT_FAILED) || (ret == WAIT_ABANDONED)) - throw system_error(EPROTO, generic_category()); - } - assert(mNumWaiters == 0); -//in case some of the waiters timed out just after we released the -//semaphore by mNumWaiters, it won't be zero now, because not all waiters -//woke up by acquiring the semaphore. So we must zero the semaphore before -//we accept waiters for the next event -//See _wait_impl for details - while(WaitForSingleObject(mSemaphore, 0) == WAIT_OBJECT_0); - } - void notify_one() noexcept - { - lock_guard lock(mMutex); - if (!mNumWaiters) - return; - int targetWaiters = mNumWaiters.load() - 1; - ReleaseSemaphore(mSemaphore, 1, NULL); - while(mNumWaiters > targetWaiters) - { - auto ret = WaitForSingleObject(mWakeEvent, 1000); - if ((ret == WAIT_FAILED) || (ret == WAIT_ABANDONED)) - throw system_error(EPROTO, generic_category()); - } - assert(mNumWaiters == targetWaiters); - } - template - std::cv_status wait_for(M& lock, - const std::chrono::duration& rel_time) - { - long long timeout = chrono::duration_cast(rel_time).count(); - if (timeout < 0) - timeout = 0; - bool ret = wait_impl(lock, (DWORD)timeout); - return ret?cv_status::no_timeout:cv_status::timeout; - } - - template - bool wait_for(M& lock, - const std::chrono::duration& rel_time, Predicate pred) - { - wait_for(lock, rel_time); - return pred(); - } - template - cv_status wait_until (M& lock, - const chrono::time_point& abs_time) - { - return wait_for(lock, abs_time - Clock::now()); - } - template - bool wait_until (M& lock, - const std::chrono::time_point& abs_time, - Predicate pred) - { - auto time = abs_time - Clock::now(); - if (time < 0) - return pred(); - else - return wait_for(lock, time, pred); - } -}; -class condition_variable: protected condition_variable_any -{ -protected: - typedef condition_variable_any base; -public: - using base::native_handle_type; - using base::native_handle; - using base::base; - using base::notify_all; - using base::notify_one; - void wait(unique_lock &lock) - { base::wait(lock); } - template - void wait(unique_lock& lock, Predicate pred) - { base::wait(lock, pred); } - template - std::cv_status wait_for(unique_lock& lock, const std::chrono::duration& rel_time) - { return base::wait_for(lock, rel_time); } - template - bool wait_for(unique_lock& lock, const std::chrono::duration& rel_time, Predicate pred) - { return base::wait_for(lock, rel_time, pred); } - template - cv_status wait_until (unique_lock& lock, const chrono::time_point& abs_time) - { return base::wait_for(lock, abs_time); } - template - bool wait_until (unique_lock& lock, const std::chrono::time_point& abs_time, Predicate pred) - { return base::wait_until(lock, abs_time, pred); } -}; -} -#endif // MINGW_CONDITIONAL_VARIABLE_H diff --git a/include/third_party/mingw-std-threads/mingw.mutex.h b/include/third_party/mingw-std-threads/mingw.mutex.h deleted file mode 100755 index cc33f43c..00000000 --- a/include/third_party/mingw-std-threads/mingw.mutex.h +++ /dev/null @@ -1,275 +0,0 @@ -/** -* @file mingw.mutex.h -* @brief std::mutex et al implementation for MinGW -** (c) 2013-2016 by Mega Limited, Auckland, New Zealand -* @author Alexander Vassilev -* -* @copyright Simplified (2-clause) BSD License. -* You should have received a copy of the license along with this -* program. -* -* This code is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -* @note -* This file may become part of the mingw-w64 runtime package. If/when this happens, -* the appropriate license will be added, i.e. this code will become dual-licensed, -* and the current BSD 2-clause license will stay. -*/ - -#ifndef WIN32STDMUTEX_H -#define WIN32STDMUTEX_H -#ifdef _GLIBCXX_HAS_GTHREADS -#error This version of MinGW seems to include a win32 port of pthreads, and probably \ - already has C++11 std threading classes implemented, based on pthreads. \ - You are likely to have class redefinition errors below, and unfirtunately this \ - implementation can not be used standalone \ - and independent of the system header, since it relies on it for \ - std::unique_lock and other utility classes. If you would still like to use this \ - implementation (as it is more lightweight), you have to edit the \ - c++-config.h system header of your MinGW to not define _GLIBCXX_HAS_GTHREADS. \ - This will prevent system headers from defining actual threading classes while still \ - defining the necessary utility classes. -#endif -// Recursion checks on non-recursive locks have some performance penalty, so the user -// may want to disable the checks in release builds. In that case, make sure they -// are always enabled in debug builds. - -#if defined(STDMUTEX_NO_RECURSION_CHECKS) && !defined(NDEBUG) - #undef STDMUTEX_NO_RECURSION_CHECKS -#endif - -#include -#include -#include - -#ifndef EPROTO - #define EPROTO 134 -#endif -#ifndef EOWNERDEAD - #define EOWNERDEAD 133 -#endif - -namespace std -{ -class recursive_mutex -{ -protected: - CRITICAL_SECTION mHandle; -public: - typedef LPCRITICAL_SECTION native_handle_type; - native_handle_type native_handle() {return &mHandle;} - recursive_mutex() noexcept - { - InitializeCriticalSection(&mHandle); - } - recursive_mutex (const recursive_mutex&) = delete; - recursive_mutex& operator=(const recursive_mutex&) = delete; - ~recursive_mutex() noexcept - { - DeleteCriticalSection(&mHandle); - } - void lock() - { - EnterCriticalSection(&mHandle); - } - void unlock() - { - LeaveCriticalSection(&mHandle); - } - bool try_lock() - { - return (TryEnterCriticalSection(&mHandle)!=0); - } -}; -template -class _NonRecursive: protected B -{ -protected: - typedef B base; - DWORD mOwnerThread; -public: - using base::native_handle_type; - using base::native_handle; - _NonRecursive() noexcept :base(), mOwnerThread(0) {} - _NonRecursive (const _NonRecursive&) = delete; - _NonRecursive& operator= (const _NonRecursive&) = delete; - void lock() - { - base::lock(); - checkSetOwnerAfterLock(); - } -protected: - void checkSetOwnerAfterLock() - { - DWORD self = GetCurrentThreadId(); - if (mOwnerThread == self) - { - fprintf(stderr, "FATAL: Recursive locking or non-recursive mutex detected. Throwing sysetm exception\n"); - fflush(stderr); - throw system_error(EDEADLK, generic_category()); - } - mOwnerThread = self; - } - void checkSetOwnerBeforeUnlock() - { - DWORD self = GetCurrentThreadId(); - if (mOwnerThread != self) - { - fprintf(stderr, "FATAL: Recursive unlocking of non-recursive mutex detected. Throwing system exception\n"); - fflush(stderr); - throw system_error(EDEADLK, generic_category()); - } - mOwnerThread = 0; - } -public: - void unlock() - { - checkSetOwnerBeforeUnlock(); - base::unlock(); - } - bool try_lock() - { - bool ret = base::try_lock(); - if (ret) - checkSetOwnerAfterLock(); - return ret; - } -}; - -#ifndef STDMUTEX_NO_RECURSION_CHECKS - typedef _NonRecursive mutex; -#else - typedef recursive_mutex mutex; -#endif - -class recursive_timed_mutex -{ -protected: - HANDLE mHandle; -public: - typedef HANDLE native_handle_type; - native_handle_type native_handle() const {return mHandle;} - recursive_timed_mutex(const recursive_timed_mutex&) = delete; - recursive_timed_mutex& operator=(const recursive_timed_mutex&) = delete; - recursive_timed_mutex(): mHandle(CreateMutex(NULL, FALSE, NULL)){} - ~recursive_timed_mutex() - { - CloseHandle(mHandle); - } - void lock() - { - DWORD ret = WaitForSingleObject(mHandle, INFINITE); - if (ret != WAIT_OBJECT_0) - { - if (ret == WAIT_ABANDONED) - throw system_error(EOWNERDEAD, generic_category()); - else - throw system_error(EPROTO, generic_category()); - } - } - void unlock() - { - if (!ReleaseMutex(mHandle)) - throw system_error(EDEADLK, generic_category()); - } - bool try_lock() - { - DWORD ret = WaitForSingleObject(mHandle, 0); - if (ret == WAIT_TIMEOUT) - return false; - else if (ret == WAIT_OBJECT_0) - return true; - else if (ret == WAIT_ABANDONED) - throw system_error(EOWNERDEAD, generic_category()); - else - throw system_error(EPROTO, generic_category()); - } - template - bool try_lock_for(const std::chrono::duration& dur) - { - DWORD timeout = (DWORD)chrono::duration_cast(dur).count(); - - DWORD ret = WaitForSingleObject(mHandle, timeout); - if (ret == WAIT_TIMEOUT) - return false; - else if (ret == WAIT_OBJECT_0) - return true; - else if (ret == WAIT_ABANDONED) - throw system_error(EOWNERDEAD, generic_category()); - else - throw system_error(EPROTO, generic_category()); - } - template - bool try_lock_until(const std::chrono::time_point& timeout_time) - { - return try_lock_for(timeout_time - Clock::now()); - } -}; - -class timed_mutex: public _NonRecursive -{ -protected: - typedef _NonRecursive base; -public: - using base::base; - timed_mutex(const timed_mutex&) = delete; - timed_mutex& operator=(const timed_mutex&) = delete; - template - bool try_lock_for(const std::chrono::duration& dur) - { - bool ret = base::try_lock_for(dur); -#ifndef STDMUTEX_NO_RECURSION_CHECKS - if (ret) - checkSetOwnerAfterLock(); -#endif - return ret; - } -public: - template - bool try_lock_until(const std::chrono::time_point& timeout_time) - { - bool ret = base::try_lock_until(timeout_time); -#ifndef STDMUTEX_NO_RECURSION_CHECKS - if (ret) - checkSetOwnerAfterLock(); -#endif - return ret; - } -}; -// You can use the scoped locks and other helpers that are still provided by -// In that case, you must include before including this file, so that this -// file will not try to redefine them -#ifndef _GLIBCXX_MUTEX - -/// Do not acquire ownership of the mutex. -struct defer_lock_t { }; - - /// Try to acquire ownership of the mutex without blocking. -struct try_to_lock_t { }; - - /// Assume the calling thread has already obtained mutex ownership - /// and manage it. -struct adopt_lock_t { }; - -constexpr defer_lock_t defer_lock { }; -constexpr try_to_lock_t try_to_lock { }; -constexpr adopt_lock_t adopt_lock { }; - -template -class lock_guard -{ -protected: - M& mMutex; -public: - typedef M mutex_type; - lock_guard(const lock_guard&) = delete; - lock_guard& operator=(const lock_guard&) = delete; - explicit lock_guard(mutex_type& m): mMutex(m) { mMutex.lock(); } - lock_guard(mutex_type& m, std::adopt_lock_t):mMutex(m){} - ~lock_guard() { mMutex.unlock(); } -}; - -#endif -} -#endif // WIN32STDMUTEX_H diff --git a/include/third_party/mingw-std-threads/mingw.thread.h b/include/third_party/mingw-std-threads/mingw.thread.h deleted file mode 100755 index 6c1a9973..00000000 --- a/include/third_party/mingw-std-threads/mingw.thread.h +++ /dev/null @@ -1,167 +0,0 @@ -/** -* @file mingw.thread.h -* @brief std::thread implementation for MinGW -* (c) 2013-2016 by Mega Limited, Auckland, New Zealand -* @author Alexander Vassilev -* -* @copyright Simplified (2-clause) BSD License. -* You should have received a copy of the license along with this -* program. -* -* This code is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -* @note -* This file may become part of the mingw-w64 runtime package. If/when this happens, -* the appropriate license will be added, i.e. this code will become dual-licensed, -* and the current BSD 2-clause license will stay. -*/ - -#ifndef WIN32STDTHREAD_H -#define WIN32STDTHREAD_H - -#include -#include -#include -#include -#include -#include - -#ifdef _GLIBCXX_HAS_GTHREADS -#error This version of MinGW seems to include a win32 port of pthreads, and probably \ - already has C++11 std threading classes implemented, based on pthreads. \ - It is likely that you will get class redefinition errors below, and unfortunately \ - this implementation can not be used standalone \ - and independent of the system header, since it relies on it for \ - std::unique_lock and other utility classes. If you would still like to use this \ - implementation (as it is more lightweight), you have to edit the \ - c++-config.h system header of your MinGW to not define _GLIBCXX_HAS_GTHREADS. \ - This will prevent system headers from defining actual threading classes while still \ - defining the necessary utility classes. -#endif - -//instead of INVALID_HANDLE_VALUE _beginthreadex returns 0 -#define _STD_THREAD_INVALID_HANDLE 0 -namespace std -{ - -class thread -{ -public: - class id - { - DWORD mId; - void clear() {mId = 0;} - friend class thread; - public: - id(DWORD aId=0):mId(aId){} - bool operator==(const id& other) const {return mId == other.mId;} - }; -protected: - HANDLE mHandle; - id mThreadId; -public: - typedef HANDLE native_handle_type; - id get_id() const noexcept {return mThreadId;} - native_handle_type native_handle() const {return mHandle;} - thread(): mHandle(_STD_THREAD_INVALID_HANDLE){} - - thread(thread&& other) - :mHandle(other.mHandle), mThreadId(other.mThreadId) - { - other.mHandle = _STD_THREAD_INVALID_HANDLE; - other.mThreadId.clear(); - } - - thread(const thread &other)=delete; - - template - explicit thread(Function&& f, Args&&... args) - { - typedef decltype(std::bind(f, args...)) Call; - Call* call = new Call(std::bind(f, args...)); - mHandle = (HANDLE)_beginthreadex(NULL, 0, threadfunc, - (LPVOID)call, 0, (unsigned*)&(mThreadId.mId)); - } - template - static unsigned int __stdcall threadfunc(void* arg) - { - std::unique_ptr upCall(static_cast(arg)); - (*upCall)(); - return (unsigned long)0; - } - bool joinable() const {return mHandle != _STD_THREAD_INVALID_HANDLE;} - void join() - { - if (get_id() == GetCurrentThreadId()) - throw system_error(EDEADLK, generic_category()); - if (mHandle == _STD_THREAD_INVALID_HANDLE) - throw system_error(ESRCH, generic_category()); - if (!joinable()) - throw system_error(EINVAL, generic_category()); - WaitForSingleObject(mHandle, INFINITE); - CloseHandle(mHandle); - mHandle = _STD_THREAD_INVALID_HANDLE; - mThreadId.clear(); - } - - ~thread() - { - if (joinable()) - std::terminate(); - } - thread& operator=(const thread&) = delete; - thread& operator=(thread&& other) noexcept - { - if (joinable()) - std::terminate(); - swap(std::forward(other)); - return *this; - } - void swap(thread&& other) noexcept - { - std::swap(mHandle, other.mHandle); - std::swap(mThreadId.mId, other.mThreadId.mId); - } - static unsigned int hardware_concurrency() noexcept - { - static int ncpus = -1; - if (ncpus == -1) - { - SYSTEM_INFO sysinfo; - GetSystemInfo(&sysinfo); - ncpus = sysinfo.dwNumberOfProcessors; - } - return ncpus; - } - void detach() - { - if (!joinable()) - throw system_error(); - if (mHandle != _STD_THREAD_INVALID_HANDLE) - { - CloseHandle(mHandle); - mHandle = _STD_THREAD_INVALID_HANDLE; - } - mThreadId.clear(); - } -}; - -namespace this_thread -{ - inline thread::id get_id() {return thread::id(GetCurrentThreadId());} - inline void yield() {Sleep(0);} - template< class Rep, class Period > - void sleep_for( const std::chrono::duration& sleep_duration) - { - Sleep(chrono::duration_cast(sleep_duration).count()); - } - template - void sleep_until(const std::chrono::time_point& sleep_time) - { - sleep_for(sleep_time-Clock::now()); - } -} - -} -#endif // WIN32STDTHREAD_H diff --git a/include/third_party/mingw-std-threads/tests/CMakeLists.txt b/include/third_party/mingw-std-threads/tests/CMakeLists.txt deleted file mode 100755 index e1727d0b..00000000 --- a/include/third_party/mingw-std-threads/tests/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -project(stdthreadtest) -cmake_minimum_required(VERSION 2.8) - -add_definitions(-std=c++11) -add_executable(${PROJECT_NAME} tests.cpp) - - diff --git a/include/third_party/mingw-std-threads/tests/tests.cpp b/include/third_party/mingw-std-threads/tests/tests.cpp deleted file mode 100755 index 268e3b69..00000000 --- a/include/third_party/mingw-std-threads/tests/tests.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#undef _GLIBCXX_HAS_GTHREADS -#include "../mingw.thread.h" -#include -#include "../mingw.mutex.h" -#include "../mingw.condition_variable.h" -#include -#include - -using namespace std; - -bool cond = false; -std::mutex m; -std::condition_variable cv; -#define LOG(fmtString,...) printf(fmtString "\n", ##__VA_ARGS__); fflush(stdout) -int main() -{ - std::thread t([](bool a, const char* b, int c)mutable - { - try - { - LOG("Worker thread started, sleeping for a while..."); - assert(a && !strcmp(b, "test message") && (c == -20)); - this_thread::sleep_for(std::chrono::milliseconds(5000)); - { - lock_guard lock(m); - cond = true; - LOG("Notifying condvar"); - cv.notify_all(); - } - - LOG("Worker thread finishing"); - } - catch(std::exception& e) - { - printf("EXCEPTION in worker thread: %s\n", e.what()); - } - }, - true, "test message", -20); - try - { - LOG("Main thread: waiting on condvar..."); - { - std::unique_lock lk(m); - cv.wait(lk, []{ return cond;} ); - LOG("condvar notified, cond = %d", cond); - } - LOG("Main thread: Waiting on worker join..."); - - t.join(); - LOG("Main thread: Worker thread joined"); - fflush(stdout); - } - catch(std::exception& e) - { - LOG("EXCEPTION in main thread: %s", e.what()); - } - - return 0; -} - diff --git a/include/utilities/threadUtils.h b/include/utilities/threadUtils.h new file mode 100755 index 00000000..3eb8b5a8 --- /dev/null +++ b/include/utilities/threadUtils.h @@ -0,0 +1,44 @@ +/**************************************************************************** + * + * threadUtils.h: Thread Utilities api + * This is part of the yafray package + * Copyright (C) 2016 David Bluecame + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef Y_THREADUTILS_H +#define Y_THREADUTILS_H + +#include + +#if defined(_WIN32) && defined(__MINGW32__) //If compiling for Windows with MinGW, the standard C++11 thread management is very slow, causing a performance drop. I'll be using the alternative (much faster) implementation from https://github.com/meganz/mingw-std-threads + #undef _GLIBCXX_HAS_GTHREADS + #include + #include + #include + #include +#else + #include + #include + #include +#endif + +__BEGIN_YAFRAY + +__END_YAFRAY + +#endif From bec44388ebe7c646f9f3ad35702d247fe1717ee3 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Fri, 10 Jun 2016 21:58:56 +0100 Subject: [PATCH 082/124] Remove warning duplicated friend message --- include/yafraycore/pkdtree.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/yafraycore/pkdtree.h b/include/yafraycore/pkdtree.h index 9699f7be..c0a0e40e 100755 --- a/include/yafraycore/pkdtree.h +++ b/include/yafraycore/pkdtree.h @@ -100,8 +100,6 @@ class pointKdTree ar & BOOST_SERIALIZATION_NVP(Y_PROCS); ar & boost::serialization::make_array(nodes, nextFreeNode); } - - friend class boost::serialization::access; template void load(Archive & ar, const unsigned int version) { ar & BOOST_SERIALIZATION_NVP(nElements); From bc7cf9b9fbfb2a9bef8a192fb122afa62d230600 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sat, 11 Jun 2016 07:48:55 +0100 Subject: [PATCH 083/124] Math constants - only redefine them if they are not already defined by the standard headers --- include/utilities/mathOptimizations.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/include/utilities/mathOptimizations.h b/include/utilities/mathOptimizations.h index c19b6225..4708c148 100755 --- a/include/utilities/mathOptimizations.h +++ b/include/utilities/mathOptimizations.h @@ -39,20 +39,47 @@ // Reference defines, this should be defined by the standard cmath header // Unfortunately this fails in MinGW GCC v4.9.2, so I have to enable the "manual" definitions copied from math.h +// Redefine only if they are not already defined by the standard headers +#ifndef M_E # define M_E 2.7182818284590452354 /* e */ +#endif +#ifndef M_LOG2E # define M_LOG2E 1.4426950408889634074 /* log_2 e */ +#endif +#ifndef M_LOG2E # define M_LOG10E 0.43429448190325182765 /* log_10 e */ +#endif +#ifndef M_LN2 # define M_LN2 0.69314718055994530942 /* log_e 2 */ +#endif +#ifndef M_LN10 # define M_LN10 2.30258509299404568402 /* log_e 10 */ +#endif +#ifndef M_PI # define M_PI 3.14159265358979323846 /* pi */ +#endif +#ifndef M_PI_2 # define M_PI_2 1.57079632679489661923 /* pi/2 */ +#endif +#ifndef M_PI_4 # define M_PI_4 0.78539816339744830962 /* pi/4 */ +#endif +#ifndef M_1_PI # define M_1_PI 0.31830988618379067154 /* 1/pi */ +#endif +#ifndef M_2_PI # define M_2_PI 0.63661977236758134308 /* 2/pi */ +#endif +#ifndef M_2_SQRTPI # define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */ +#endif +#ifndef M_SQRT2 # define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ +#endif +#ifndef M_SQRT1_2 # define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ +#endif __BEGIN_YAFRAY From c5cfb0cc2ddd1b6afccd4d9ddc54f034b1d44554 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Mon, 13 Jun 2016 16:19:40 +0100 Subject: [PATCH 084/124] Removed all CFLOAT, GFLOAT, PFLOAT and replaced with regular float I think they were a bit pointless. It was not possible to switch from float to double, for example, as there are too many "tweaks" in the code that are float-dependant anyway --- CMakeConfig/templates/yafray_config.h.cmake | 5 - CODING | 2 +- include/cameras/angularCamera.h | 6 +- include/cameras/architectCamera.h | 4 +- include/cameras/orthographicCamera.h | 6 +- include/cameras/perspectiveCamera.h | 24 ++-- include/core_api/bound.h | 44 +++---- include/core_api/camera.h | 6 +- include/core_api/color.h | 108 ++++++++--------- include/core_api/imagefilm.h | 4 +- include/core_api/imagesplitter.h | 6 +- include/core_api/material.h | 4 +- include/core_api/params.h | 6 +- include/core_api/primitive.h | 2 +- include/core_api/ray.h | 8 +- include/core_api/renderpasses.h | 2 +- include/core_api/scene.h | 22 ++-- include/core_api/shader.h | 12 +- include/core_api/surface.h | 16 +-- include/core_api/texture.h | 14 +-- include/core_api/vector3d.h | 96 +++++++-------- include/integrators/integr_utils.h | 2 +- include/lights/arealight.h | 4 +- include/lights/bgportallight.h | 2 +- include/lights/meshlight.h | 2 +- include/materials/blendmat.h | 2 +- include/materials/maskmat.h | 6 +- include/materials/microfacet.h | 2 +- include/materials/shinydiff.h | 4 +- include/textures/basicnodes.h | 4 +- include/textures/basictex.h | 54 ++++----- include/textures/imagetex.h | 4 +- include/textures/layernode.h | 8 +- include/textures/noise.h | 92 +++++++------- include/utilities/sample_utils.h | 12 +- include/yafraycore/hashgrid.h | 2 +- include/yafraycore/kdtree.h | 28 ++--- include/yafraycore/meshtypes.h | 4 +- include/yafraycore/photon.h | 28 ++--- include/yafraycore/pkdtree.h | 26 ++-- include/yafraycore/ray_kdtree.h | 18 +-- include/yafraycore/spectrum.h | 18 +-- include/yafraycore/std_primitives.h | 6 +- include/yafraycore/triangle.h | 8 +- src/bindings/yafaray_v3_interface.i | 4 +- src/cameras/angularCamera.cc | 22 ++-- src/cameras/architectCamera.cc | 18 +-- src/cameras/orthographicCamera.cc | 10 +- src/cameras/perspectiveCamera.cc | 54 ++++----- src/integrators/bidirpath.cc | 34 +++--- src/integrators/pathtracer.cc | 4 +- src/integrators/photonintegr.cc | 10 +- src/integrators/sppm.cc | 16 +-- src/lights/arealight.cc | 20 +-- src/lights/bgportallight.cc | 20 +-- src/lights/directional.cc | 16 +-- src/lights/iesLight.cc | 12 +- src/lights/meshlight.cc | 20 +-- src/lights/pointlight.cc | 18 +-- src/lights/spherelight.cc | 46 +++---- src/lights/spotlight.cc | 40 +++--- src/lights/sunlight.cc | 12 +- src/materials/beer.cc | 8 +- src/materials/blend.cc | 2 +- src/materials/coatedglossy.cc | 12 +- src/materials/glass.cc | 24 ++-- src/materials/mask.cc | 10 +- src/materials/shinydiffuse.cc | 26 ++-- src/materials/simple.cc | 4 +- src/textures/basicnodes.cc | 10 +- src/textures/basictex.cc | 84 ++++++------- src/textures/imagetex.cc | 4 +- src/textures/layernode.cc | 12 +- src/textures/noise.cc | 128 ++++++++++---------- src/yafraycore/bound.cc | 16 +-- src/yafraycore/color.cc | 40 +++--- src/yafraycore/gboundtree.h | 24 ++-- src/yafraycore/hashgrid.cc | 4 +- src/yafraycore/integrator.cc | 8 +- src/yafraycore/kdtree.cc | 46 +++---- src/yafraycore/material.cc | 6 +- src/yafraycore/matrix4.cc | 42 +++---- src/yafraycore/nodematerial.cc | 2 +- src/yafraycore/photon.cc | 12 +- src/yafraycore/ray_kdtree.cc | 46 +++---- src/yafraycore/renderpasses.cc | 2 +- src/yafraycore/scene.cc | 20 +-- src/yafraycore/spectrum.cc | 54 ++++----- src/yafraycore/std_primitives.cc | 16 +-- src/yafraycore/surface.cc | 24 ++-- src/yafraycore/vector3d.cc | 44 +++---- src/yafraycore/xmlparser.cc | 8 +- 92 files changed, 921 insertions(+), 926 deletions(-) diff --git a/CMakeConfig/templates/yafray_config.h.cmake b/CMakeConfig/templates/yafray_config.h.cmake index ebf7452b..3895b4d0 100755 --- a/CMakeConfig/templates/yafray_config.h.cmake +++ b/CMakeConfig/templates/yafray_config.h.cmake @@ -18,10 +18,5 @@ #cmakedefine HAVE_UNISTD_H 1 -__BEGIN_YAFRAY -typedef float CFLOAT; -typedef float GFLOAT; -typedef float PFLOAT; -__END_YAFRAY #endif diff --git a/CODING b/CODING index fc83628f..f41e7942 100755 --- a/CODING +++ b/CODING @@ -8,7 +8,7 @@ some coding conventions: libs added to their build environment for all HAVE_* options they pull in (directly or indirectly!) * interface functions shall not have arguments or return types which - depend on configurable typedefines (such as CFLOAT, PLOAT and GFLOAT) + depend on configurable typedefines (such as float, PLOAT and float) * use doxygen comments to document non-obvious types, classes, interfaces and functions and their usage. diff --git a/include/cameras/angularCamera.h b/include/cameras/angularCamera.h index 349e8e18..3dffea1d 100755 --- a/include/cameras/angularCamera.h +++ b/include/cameras/angularCamera.h @@ -16,15 +16,15 @@ class angularCam_t: public camera_t { public: angularCam_t(const point3d_t &pos, const point3d_t &look, const point3d_t &up, - int _resx, int _resy, PFLOAT aspect, PFLOAT angle, bool circ, + int _resx, int _resy, float aspect, float angle, bool circ, float const near_clip_distance = 0.0f, float const far_clip_distance = 1e6f); virtual void setAxis(const vector3d_t &vx, const vector3d_t &vy, const vector3d_t &vz); - virtual ray_t shootRay(PFLOAT px, PFLOAT py, float lu, float lv, PFLOAT &wt) const; + virtual ray_t shootRay(float px, float py, float lu, float lv, float &wt) const; virtual point3d_t screenproject(const point3d_t &p) const; static camera_t* factory(paraMap_t ¶ms, renderEnvironment_t &render); protected: - PFLOAT aspect,hor_phi, max_r; + float aspect,hor_phi, max_r; bool circular; }; diff --git a/include/cameras/architectCamera.h b/include/cameras/architectCamera.h index 981ff920..ab2c639e 100755 --- a/include/cameras/architectCamera.h +++ b/include/cameras/architectCamera.h @@ -13,8 +13,8 @@ class architectCam_t: public perspectiveCam_t { public: architectCam_t(const point3d_t &pos, const point3d_t &look, const point3d_t &up, - int _resx, int _resy, PFLOAT aspect=1, - PFLOAT df=1, PFLOAT ap=0, PFLOAT dofd=0, bokehType bt=BK_DISK1, bkhBiasType bbt=BB_NONE, PFLOAT bro=0, + int _resx, int _resy, float aspect=1, + float df=1, float ap=0, float dofd=0, bokehType bt=BK_DISK1, bkhBiasType bbt=BB_NONE, float bro=0, float const near_clip_distance = 0.0f, float const far_clip_distance = 1e6f); virtual ~architectCam_t(); virtual void setAxis(const vector3d_t &vx, const vector3d_t &vy, const vector3d_t &vz); diff --git a/include/cameras/orthographicCamera.h b/include/cameras/orthographicCamera.h index 1806b75c..15cac524 100755 --- a/include/cameras/orthographicCamera.h +++ b/include/cameras/orthographicCamera.h @@ -15,15 +15,15 @@ class orthoCam_t: public camera_t { public: orthoCam_t(const point3d_t &pos, const point3d_t &look, const point3d_t &up, - int _resx, int _resy, PFLOAT aspect, PFLOAT scale, + int _resx, int _resy, float aspect, float scale, float const near_clip_distance = 0.0f, float const far_clip_distance = 1e6f); virtual void setAxis(const vector3d_t &vx, const vector3d_t &vy, const vector3d_t &vz); - virtual ray_t shootRay(PFLOAT px, PFLOAT py, float lu, float lv, PFLOAT &wt) const; + virtual ray_t shootRay(float px, float py, float lu, float lv, float &wt) const; virtual point3d_t screenproject(const point3d_t &p) const; static camera_t* factory(paraMap_t ¶ms, renderEnvironment_t &render); protected: - PFLOAT scale; + float scale; point3d_t pos; }; diff --git a/include/cameras/perspectiveCamera.h b/include/cameras/perspectiveCamera.h index fb55fff1..eb4f170c 100755 --- a/include/cameras/perspectiveCamera.h +++ b/include/cameras/perspectiveCamera.h @@ -18,31 +18,31 @@ class perspectiveCam_t: public camera_t enum bokehType {BK_DISK1, BK_DISK2, BK_TRI=3, BK_SQR, BK_PENTA, BK_HEXA, BK_RING}; enum bkhBiasType {BB_NONE, BB_CENTER, BB_EDGE}; perspectiveCam_t(const point3d_t &pos, const point3d_t &look, const point3d_t &up, - int _resx, int _resy, PFLOAT aspect=1, - PFLOAT df=1, PFLOAT ap=0, PFLOAT dofd=0, bokehType bt=BK_DISK1, bkhBiasType bbt=BB_NONE, PFLOAT bro=0, + int _resx, int _resy, float aspect=1, + float df=1, float ap=0, float dofd=0, bokehType bt=BK_DISK1, bkhBiasType bbt=BB_NONE, float bro=0, float const near_clip_distance = 0.0f, float const far_clip_distance = 1e6f); virtual ~perspectiveCam_t(); virtual void setAxis(const vector3d_t &vx, const vector3d_t &vy, const vector3d_t &vz); - virtual ray_t shootRay(PFLOAT px, PFLOAT py, float lu, float lv, PFLOAT &wt) const; + virtual ray_t shootRay(float px, float py, float lu, float lv, float &wt) const; virtual bool sampleLense() const; virtual point3d_t screenproject(const point3d_t &p) const; - virtual bool project(const ray_t &wo, PFLOAT lu, PFLOAT lv, PFLOAT &u, PFLOAT &v, float &pdf) const; + virtual bool project(const ray_t &wo, float lu, float lv, float &u, float &v, float &pdf) const; static camera_t* factory(paraMap_t ¶ms, renderEnvironment_t &render); protected: - void biasDist(PFLOAT &r) const; - void sampleTSD(PFLOAT r1, PFLOAT r2, PFLOAT &u, PFLOAT &v) const; - void getLensUV(PFLOAT r1, PFLOAT r2, PFLOAT &u, PFLOAT &v) const; + void biasDist(float &r) const; + void sampleTSD(float r1, float r2, float &u, float &v) const; + void getLensUV(float r1, float r2, float &u, float &v) const; bokehType bkhtype; bkhBiasType bkhbias; vector3d_t dof_up, dof_rt; - PFLOAT aperture; - PFLOAT focal_distance, dof_distance; - PFLOAT fdist; - PFLOAT A_pix; - std::vector LS; + float aperture; + float focal_distance, dof_distance; + float fdist; + float A_pix; + std::vector LS; }; __END_YAFRAY diff --git a/include/core_api/bound.h b/include/core_api/bound.h index f0478f12..f0865544 100755 --- a/include/core_api/bound.h +++ b/include/core_api/bound.h @@ -44,13 +44,13 @@ __BEGIN_YAFRAY */ class bound_t; -YAFRAYCORE_EXPORT GFLOAT bound_distance(const bound_t &l,const bound_t &r); -GFLOAT b_intersect(const bound_t &l,const bound_t &r); +YAFRAYCORE_EXPORT float bound_distance(const bound_t &l,const bound_t &r); +float b_intersect(const bound_t &l,const bound_t &r); class YAFRAYCORE_EXPORT bound_t { - //friend YAFRAYCORE_EXPORT GFLOAT bound_distance(const bound_t &l,const bound_t &r); - //friend GFLOAT b_intersect(const bound_t &l,const bound_t &r); + //friend YAFRAYCORE_EXPORT float bound_distance(const bound_t &l,const bound_t &r); + //friend float b_intersect(const bound_t &l,const bound_t &r); public: @@ -79,32 +79,32 @@ class YAFRAYCORE_EXPORT bound_t //! Returns true if the given ray crosses the bound //bool cross(const point3d_t &from,const vector3d_t &ray)const; //! Returns true if the given ray crosses the bound closer than dist - //bool cross(const point3d_t &from, const vector3d_t &ray, PFLOAT dist)const; - //bool cross(const point3d_t &from, const vector3d_t &ray, PFLOAT &where, PFLOAT dist)const; - bool cross(const ray_t &ray, PFLOAT &enter, PFLOAT &leave, const PFLOAT dist)const; + //bool cross(const point3d_t &from, const vector3d_t &ray, float dist)const; + //bool cross(const point3d_t &from, const vector3d_t &ray, float &where, float dist)const; + bool cross(const ray_t &ray, float &enter, float &leave, const float dist)const; //! Returns the volume of the bound - GFLOAT vol() const; + float vol() const; //! Returns the lenght along X axis - PFLOAT longX()const {return g.x-a.x;}; + float longX()const {return g.x-a.x;}; //! Returns the lenght along Y axis - PFLOAT longY()const {return g.y-a.y;}; + float longY()const {return g.y-a.y;}; //! Returns the lenght along Y axis - PFLOAT longZ()const {return g.z-a.z;}; + float longZ()const {return g.z-a.z;}; //! Cuts the bound to have the given max X - void setMaxX(PFLOAT X) {g.x=X;}; + void setMaxX(float X) {g.x=X;}; //! Cuts the bound to have the given min X - void setMinX(PFLOAT X) {a.x=X;}; + void setMinX(float X) {a.x=X;}; //! Cuts the bound to have the given max Y - void setMaxY(PFLOAT Y) {g.y=Y;}; + void setMaxY(float Y) {g.y=Y;}; //! Cuts the bound to have the given min Y - void setMinY(PFLOAT Y) {a.y=Y;}; + void setMinY(float Y) {a.y=Y;}; //! Cuts the bound to have the given max Z - void setMaxZ(PFLOAT Z) {g.z=Z;}; + void setMaxZ(float Z) {g.z=Z;}; //! Cuts the bound to have the given min Z - void setMinZ(PFLOAT Z) {a.z=Z;}; + void setMinZ(float Z) {a.z=Z;}; //! Adjust bound size to include point p void include(const point3d_t &p); //! Returns true if the point is inside the bound @@ -114,16 +114,16 @@ class YAFRAYCORE_EXPORT bound_t ( pn.y >= a.y ) && ( pn.y <= g.y) && ( pn.z >= a.z ) && ( pn.z <= g.z) ); }; - PFLOAT centerX()const {return (g.x+a.x)*0.5;}; - PFLOAT centerY()const {return (g.y+a.y)*0.5;}; - PFLOAT centerZ()const {return (g.z+a.z)*0.5;}; + float centerX()const {return (g.x+a.x)*0.5;}; + float centerY()const {return (g.y+a.y)*0.5;}; + float centerZ()const {return (g.z+a.z)*0.5;}; point3d_t center()const {return (g+a)*0.5;}; int largestAxis() { vector3d_t d = g-a; return (d.x>d.y) ? ((d.x>d.z) ? 0 : 2) : ((d.y>d.z) ? 1:2 ); } - void grow(PFLOAT d) + void grow(float d) { a.x-=d; a.y-=d; @@ -155,7 +155,7 @@ inline void bound_t::include(const point3d_t &p) g.z = std::max(g.z, p.z); } -inline bool bound_t::cross(const ray_t &ray, PFLOAT &enter, PFLOAT &leave, const PFLOAT dist)const +inline bool bound_t::cross(const ray_t &ray, float &enter, float &leave, const float dist)const { // Smits method const point3d_t &a0=a,&a1=g; diff --git a/include/core_api/camera.h b/include/core_api/camera.h index ef8e4151..e595d26e 100755 --- a/include/core_api/camera.h +++ b/include/core_api/camera.h @@ -39,7 +39,7 @@ class YAFRAYCORE_EXPORT camera_t public: camera_t() { } camera_t(const point3d_t &pos, const point3d_t &look, const point3d_t &up, int _resx, int _resy, float aspect, float const near_clip_distance, float const far_clip_distance) : - position(pos), resx(_resx), resy(_resy), aspect_ratio(aspect * (PFLOAT)resy / (PFLOAT)resx),camera_name(""), view_name("") + position(pos), resx(_resx), resy(_resy), aspect_ratio(aspect * (float)resy / (float)resx),camera_name(""), view_name("") { // Calculate and store camera axis camY = up - position; @@ -62,7 +62,7 @@ class YAFRAYCORE_EXPORT camera_t virtual ~camera_t() {} virtual void setAxis(const vector3d_t &vx, const vector3d_t &vy, const vector3d_t &vz) = 0; //!< Set camera axis /*! Shoot a new ray from the camera gived image pixel coordinates px,py and lense dof effect */ - virtual ray_t shootRay(PFLOAT px, PFLOAT py, float u, float v, PFLOAT &wt) const = 0; //!< Shoot a new ray from the camera. + virtual ray_t shootRay(float px, float py, float u, float v, float &wt) const = 0; //!< Shoot a new ray from the camera. virtual point3d_t screenproject(const point3d_t &p) const = 0; //!< Get projection of point p into camera plane virtual int resX() const { return resx; } //!< Get camera X resolution @@ -73,7 +73,7 @@ class YAFRAYCORE_EXPORT camera_t /*! Indicate whether the lense need to be sampled (u, v parameters of shootRay), i.e. DOF-like effects. When false, no lense samples need to be computed */ virtual bool sampleLense() const { return false; } //!< Indicate whether the lense need to be sampled - virtual bool project(const ray_t &wo, PFLOAT lu, PFLOAT lv, PFLOAT &u, PFLOAT &v, float &pdf) const { return false; } + virtual bool project(const ray_t &wo, float lu, float lv, float &u, float &v, float &pdf) const { return false; } virtual float getNearClip() const { return nearClip; } virtual float getFarClip() const { return farClip; } void set_camera_name(std::string name) { camera_name = name; } diff --git a/include/core_api/color.h b/include/core_api/color.h index dffbff18..27a11737 100755 --- a/include/core_api/color.h +++ b/include/core_api/color.h @@ -48,44 +48,44 @@ enum colorSpaces_t class YAFRAYCORE_EXPORT color_t { friend color_t operator * (const color_t &a, const color_t &b); - friend color_t operator * (const CFLOAT f, const color_t &b); - friend color_t operator * (const color_t &b, const CFLOAT f); - friend color_t operator / (const color_t &b, const CFLOAT f); + friend color_t operator * (const float f, const color_t &b); + friend color_t operator * (const color_t &b, const float f); + friend color_t operator / (const color_t &b, const float f); friend color_t operator + (const color_t &a, const color_t &b); friend color_t operator - (const color_t &a, const color_t &b); - friend CFLOAT maxAbsDiff(const color_t &a, const color_t &b); + friend float maxAbsDiff(const color_t &a, const color_t &b); friend YAFRAYCORE_EXPORT void operator >> (unsigned char *data, color_t &c); friend YAFRAYCORE_EXPORT void operator << (unsigned char *data, const color_t &c); friend YAFRAYCORE_EXPORT void operator >> (float *data, color_t &c); friend YAFRAYCORE_EXPORT void operator << (float *data, const color_t &c); friend YAFRAYCORE_EXPORT std::ostream & operator << (std::ostream & out, const color_t c); - friend YAFRAYCORE_EXPORT color_t mix(const color_t &a, const color_t &b, CFLOAT point); + friend YAFRAYCORE_EXPORT color_t mix(const color_t &a, const color_t &b, float point); friend YAFRAYCORE_EXPORT color_t convergenceAccell(const color_t &cn_1, const color_t &cn0, const color_t &cn1); public: color_t() { R=G=B=0; } - color_t(CFLOAT r, CFLOAT g, CFLOAT b) {R=r;G=g;B=b;}; - color_t(CFLOAT g) { R=G=B=g; } - color_t(CFLOAT af[3]) { R=af[0]; G=af[1]; B=af[2]; } + color_t(float r, float g, float b) {R=r;G=g;B=b;}; + color_t(float g) { R=G=B=g; } + color_t(float af[3]) { R=af[0]; G=af[1]; B=af[2]; } bool isBlack() const { return ((R==0) && (G==0) && (B==0)); } bool isNaN() const { return (std::isnan(R) || std::isnan(G) || std::isnan(B)); } bool isInf() const { return (std::isinf(R) || std::isinf(G) || std::isinf(B)); } ~color_t() {} - void set(CFLOAT r, CFLOAT g, CFLOAT b) { R=r; G=g; B=b; } + void set(float r, float g, float b) { R=r; G=g; B=b; } color_t & operator +=(const color_t &c); color_t & operator -=(const color_t &c); color_t & operator *=(const color_t &c); - color_t & operator *=(CFLOAT f); + color_t & operator *=(float f); - CFLOAT energy() const {return (R+G+B)*0.333333f;}; + float energy() const {return (R+G+B)*0.333333f;}; // Using ITU/Photometric values Y = 0.2126 R + 0.7152 G + 0.0722 B - CFLOAT col2bri() const { return (0.2126f*R + 0.7152f*G + 0.0722f*B); } - CFLOAT abscol2bri() const { return (0.2126f*std::fabs(R) + 0.7152f*std::fabs(G) + 0.0722f*std::fabs(B)); } - void gammaAdjust(CFLOAT g){ R = fPow(R, g); G = fPow(G, g); B = fPow(B, g); } - void expgam_Adjust (CFLOAT e, CFLOAT g, bool clamp_rgb); - CFLOAT getR() const { return R; } - CFLOAT getG() const { return G; } - CFLOAT getB() const { return B; } + float col2bri() const { return (0.2126f*R + 0.7152f*G + 0.0722f*B); } + float abscol2bri() const { return (0.2126f*std::fabs(R) + 0.7152f*std::fabs(G) + 0.0722f*std::fabs(B)); } + void gammaAdjust(float g){ R = fPow(R, g); G = fPow(G, g); B = fPow(B, g); } + void expgam_Adjust (float e, float g, bool clamp_rgb); + float getR() const { return R; } + float getG() const { return G; } + float getB() const { return B; } // used in blendershader void invertRGB() @@ -109,9 +109,9 @@ class YAFRAYCORE_EXPORT color_t } void black() { R=G=B=0; } - CFLOAT minimum() const { return std::min(R, std::min(G, B)); } - CFLOAT maximum() const { return std::max(R, std::max(G, B)); } - CFLOAT absmax() const { return std::max(std::fabs(R), std::max(std::fabs(G), std::fabs(B))); } + float minimum() const { return std::min(R, std::min(G, B)); } + float maximum() const { return std::max(R, std::max(G, B)); } + float absmax() const { return std::max(std::fabs(R), std::max(std::fabs(G), std::fabs(B))); } void clampRGB0() { if (R<0.0) R=0.0; @@ -128,14 +128,14 @@ class YAFRAYCORE_EXPORT color_t void clampProportionalRGB(float maxValue); - CFLOAT linearRGB_from_sRGB(CFLOAT value_sRGB); - CFLOAT sRGB_from_linearRGB(CFLOAT value_linearRGB); + float linearRGB_from_sRGB(float value_sRGB); + float sRGB_from_linearRGB(float value_linearRGB); void linearRGB_from_ColorSpace(colorSpaces_t colorSpace, float gamma); void ColorSpace_from_linearRGB(colorSpaces_t colorSpace, float gamma); // protected: - CFLOAT R, G, B; + float R, G, B; friend class boost::serialization::access; template void serialize(Archive & ar, const unsigned int version) @@ -149,9 +149,9 @@ class YAFRAYCORE_EXPORT color_t class YAFRAYCORE_EXPORT colorA_t : public color_t { friend colorA_t operator * (const colorA_t &a, const colorA_t &b); - friend colorA_t operator * (const CFLOAT f, const colorA_t &b); - friend colorA_t operator * (const colorA_t &b, const CFLOAT f); - friend colorA_t operator / (const colorA_t &b, const CFLOAT f); + friend colorA_t operator * (const float f, const colorA_t &b); + friend colorA_t operator * (const colorA_t &b, const float f); + friend colorA_t operator / (const colorA_t &b, const float f); friend colorA_t operator + (const colorA_t &a, const colorA_t &b); friend colorA_t operator - (const colorA_t &a, const colorA_t &b); friend YAFRAYCORE_EXPORT void operator >> (unsigned char *data, colorA_t &c); @@ -159,25 +159,25 @@ class YAFRAYCORE_EXPORT colorA_t : public color_t friend YAFRAYCORE_EXPORT void operator >> (float *data, colorA_t &c); friend YAFRAYCORE_EXPORT void operator << (float *data, const colorA_t &c); friend YAFRAYCORE_EXPORT std::ostream & operator << (std::ostream & out, const colorA_t c); - friend YAFRAYCORE_EXPORT colorA_t mix(const colorA_t &a, const colorA_t &b, CFLOAT point); + friend YAFRAYCORE_EXPORT colorA_t mix(const colorA_t &a, const colorA_t &b, float point); public: colorA_t() { /* A=0; */ } colorA_t(const color_t &c):color_t(c), A(1.f) { /* A=0; */ } - colorA_t(const color_t &c, CFLOAT a):color_t(c), A(a) {} - colorA_t(CFLOAT r, CFLOAT g, CFLOAT b, CFLOAT a=0):color_t(r,g,b), A(a) {} - colorA_t(CFLOAT g):color_t(g) { A=g; } - colorA_t(CFLOAT af[4]):color_t(af) { A=af[3]; } + colorA_t(const color_t &c, float a):color_t(c), A(a) {} + colorA_t(float r, float g, float b, float a=0):color_t(r,g,b), A(a) {} + colorA_t(float g):color_t(g) { A=g; } + colorA_t(float af[4]):color_t(af) { A=af[3]; } ~colorA_t() {}; - void set(CFLOAT r, CFLOAT g, CFLOAT b, CFLOAT a=0) { color_t::set(r,g,b); A=a; } + void set(float r, float g, float b, float a=0) { color_t::set(r,g,b); A=a; } colorA_t & operator +=(const colorA_t &c); colorA_t & operator -=(const colorA_t &c); colorA_t & operator *=(const colorA_t &c); - colorA_t & operator *=(CFLOAT f); + colorA_t & operator *=(float f); void alphaPremultiply() { R*=A; G*=A; B*=A; } - CFLOAT getA() const { return A; } - void setAlpha(CFLOAT a) { A=a; } + float getA() const { return A; } + void setAlpha(float a) { A=a; } void clampRGBA0() { @@ -191,10 +191,10 @@ class YAFRAYCORE_EXPORT colorA_t : public color_t if (A<0.0) A=0.0; else if (A>1.0) A=1.0; } - CFLOAT colorDifference(colorA_t color2, bool useRGBcomponents = false); + float colorDifference(colorA_t color2, bool useRGBcomponents = false); // protected: - CFLOAT A; + float A; friend class boost::serialization::access; template void serialize(Archive & ar, const unsigned int version) @@ -212,7 +212,7 @@ class YAFRAYCORE_EXPORT rgbe_t operator color_t ()const { color_t res; - CFLOAT f; + float f; if (rgbe[3]) { /*nonzero pixel*/ f = fLdexp(1.0,rgbe[3]-(int)(128+8)); @@ -226,7 +226,7 @@ class YAFRAYCORE_EXPORT rgbe_t unsigned char rgbe[4]; }; -inline void color_t::expgam_Adjust(CFLOAT e, CFLOAT g, bool clamp_rgb) +inline void color_t::expgam_Adjust(float e, float g, bool clamp_rgb) { if ((e==0.f) && (g==1.f)) { if (clamp_rgb) clampRGB01(); @@ -253,14 +253,14 @@ YAFRAYCORE_EXPORT void operator << (unsigned char *data,const color_t &c); YAFRAYCORE_EXPORT void operator >> (float *data, color_t &c); YAFRAYCORE_EXPORT void operator << (float *data, const color_t &c); YAFRAYCORE_EXPORT std::ostream & operator << (std::ostream & out,const color_t c); -YAFRAYCORE_EXPORT color_t mix(const color_t &a,const color_t &b,CFLOAT point); +YAFRAYCORE_EXPORT color_t mix(const color_t &a,const color_t &b,float point); YAFRAYCORE_EXPORT void operator >> (unsigned char *data,colorA_t &c); YAFRAYCORE_EXPORT void operator << (unsigned char *data,const colorA_t &c); YAFRAYCORE_EXPORT void operator >> (float *data, colorA_t &c); YAFRAYCORE_EXPORT void operator << (float *data, const colorA_t &c); YAFRAYCORE_EXPORT std::ostream & operator << (std::ostream & out,const colorA_t c); -YAFRAYCORE_EXPORT colorA_t mix(const colorA_t &a,const colorA_t &b,CFLOAT point); +YAFRAYCORE_EXPORT colorA_t mix(const colorA_t &a,const colorA_t &b,float point); inline color_t operator * (const color_t &a,const color_t &b) @@ -268,17 +268,17 @@ inline color_t operator * (const color_t &a,const color_t &b) return color_t(a.R*b.R,a.G*b.G,a.B*b.B); } -inline color_t operator * (const CFLOAT f,const color_t &b) +inline color_t operator * (const float f,const color_t &b) { return color_t(f*b.R,f*b.G,f*b.B); } -inline color_t operator * (const color_t &b,const CFLOAT f) +inline color_t operator * (const color_t &b,const float f) { return color_t(f*b.R,f*b.G,f*b.B); } -inline color_t operator / (const color_t &b,CFLOAT f) +inline color_t operator / (const color_t &b,float f) { return color_t(b.R/f,b.G/f,b.B/f); } @@ -313,7 +313,7 @@ inline color_t & color_t::operator +=(const color_t &c) { R += c.R; G += c.G; B += c.B; return *this; } inline color_t & color_t::operator *=(const color_t &c) { R *= c.R; G *= c.G; B *= c.B; return *this; } -inline color_t & color_t::operator *=(CFLOAT f) +inline color_t & color_t::operator *=(float f) { R *= f; G*= f; B *= f; return *this; } inline color_t & color_t::operator -=(const color_t &c) { R -= c.R; G -= c.G; B -= c.B; return *this; } @@ -323,17 +323,17 @@ inline colorA_t operator * (const colorA_t &a,const colorA_t &b) return colorA_t(a.R*b.R, a.G*b.G, a.B*b.B, a.A*b.A); } -inline colorA_t operator * (const CFLOAT f,const colorA_t &b) +inline colorA_t operator * (const float f,const colorA_t &b) { return colorA_t(f*b.R, f*b.G, f*b.B, f*b.A); } -inline colorA_t operator * (const colorA_t &b,const CFLOAT f) +inline colorA_t operator * (const colorA_t &b,const float f) { return colorA_t(f*b.R, f*b.G, f*b.B, f*b.A); } -inline colorA_t operator / (const colorA_t &b,CFLOAT f) +inline colorA_t operator / (const colorA_t &b,float f) { if (f!=0) f=1.0/f; return colorA_t(b.R*f, b.G*f, b.B*f, b.A*f); @@ -351,10 +351,10 @@ inline colorA_t operator - (const colorA_t &a, const colorA_t &b) inline colorA_t & colorA_t::operator +=(const colorA_t &c) { R += c.R; G += c.G; B += c.B; A += c.A; return *this; } inline colorA_t & colorA_t::operator *=(const colorA_t &c) { R *= c.R; G *= c.G; B *= c.B; A *= c.A; return *this; } -inline colorA_t & colorA_t::operator *=(CFLOAT f) { R *= f; G*= f; B *= f; A *= f; return *this; } +inline colorA_t & colorA_t::operator *=(float f) { R *= f; G*= f; B *= f; A *= f; return *this; } inline colorA_t & colorA_t::operator -=(const colorA_t &c) { R -= c.R; G -= c.G; B -= c.B; A -= c.A; return *this; } -inline CFLOAT maxAbsDiff(const color_t &a,const color_t &b) +inline float maxAbsDiff(const color_t &a,const color_t &b) { return (a - b).absmax(); } @@ -377,14 +377,14 @@ static float XYZ_D65_from_linearRGB[3][3] = { 0.019300, 0.119200, 0.950500 } }; -inline CFLOAT color_t::linearRGB_from_sRGB(CFLOAT value_sRGB) +inline float color_t::linearRGB_from_sRGB(float value_sRGB) { //Calculations from http://www.color.org/chardata/rgb/sRGB.pdf if(value_sRGB <= 0.04045f) return (value_sRGB / 12.92f); else return fPow(((value_sRGB + 0.055f) / 1.055f), 2.4f); } -inline CFLOAT color_t::sRGB_from_linearRGB(CFLOAT value_linearRGB) +inline float color_t::sRGB_from_linearRGB(float value_linearRGB) { //Calculations from http://www.color.org/chardata/rgb/sRGB.pdf if(value_linearRGB <= 0.0031308f) return (value_linearRGB * 12.92f); @@ -472,7 +472,7 @@ inline void color_t::clampProportionalRGB(float maxValue) //Function to clamp th } } -inline CFLOAT colorA_t::colorDifference(colorA_t color2, bool useRGBcomponents) +inline float colorA_t::colorDifference(colorA_t color2, bool useRGBcomponents) { float colorDifference = std::fabs(color2.col2bri() - col2bri()); diff --git a/include/core_api/imagefilm.h b/include/core_api/imagefilm.h index 871b1d9a..0a2608f5 100755 --- a/include/core_api/imagefilm.h +++ b/include/core_api/imagefilm.h @@ -115,7 +115,7 @@ class YAFRAYCORE_EXPORT imageFilm_t /*! Sets the film premultiply option for optional secondary file output */ void setPremult2(bool premult); /*! Sets the adaptative AA sampling threshold */ - void setAAThreshold(CFLOAT thresh){ AA_thesh=thresh; } + void setAAThreshold(float thresh){ AA_thesh=thresh; } /*! Enables partial image saving during render every time_interval seconds. Time=0.0 (default) disables partial saving. */ void setImageOutputPartialSaveTimeInterval(double time_interval){ imageOutputPartialSaveTimeInterval = time_interval; } void setImageOutputPartialSaveEndPass(bool save_end_pass) { saveEndPass = save_end_pass; } @@ -161,7 +161,7 @@ class YAFRAYCORE_EXPORT imageFilm_t float gamma; colorSpaces_t colorSpace2; //For optional secondary file output float gamma2; //For optional secondary file output - CFLOAT AA_thesh; + float AA_thesh; bool AA_detect_color_noise; int AA_dark_detection_type; float AA_dark_threshold_factor; diff --git a/include/core_api/imagesplitter.h b/include/core_api/imagesplitter.h index 55150943..6c4cb128 100755 --- a/include/core_api/imagesplitter.h +++ b/include/core_api/imagesplitter.h @@ -42,17 +42,17 @@ struct renderArea_t realW=w; realH=h; } - bool checkResample(CFLOAT threshold); + bool checkResample(float threshold); // bool out(colorOutput_t &o); // colorA_t & imagePixel(int x,int y) {return image[(y-Y)*W+(x-X)];}; -// PFLOAT & depthPixel(int x,int y) {return depth[(y-Y)*W+(x-X)];}; +// float & depthPixel(int x,int y) {return depth[(y-Y)*W+(x-X)];}; bool resamplePixel(int x,int y) {return resample[(y-Y)*W+(x-X)];}; int X,Y,W,H,realX,realY,realW,realH; int sx0, sx1, sy0, sy1; //!< safe area, i.e. region unaffected by samples outside (needs to be set by ImageFilm_t) // std::vector image; -// std::vector depth; +// std::vector depth; std::vector resample; friend class boost::serialization::access; diff --git a/include/core_api/material.h b/include/core_api/material.h index 9af99fef..6c004db7 100755 --- a/include/core_api/material.h +++ b/include/core_api/material.h @@ -160,7 +160,7 @@ class YAFRAYCORE_EXPORT material_t virtual const volumeHandler_t* getVolumeHandler(bool inside)const { return inside ? volI : volO; } /*! special function, get the alpha-value of a material, used to calculate the alpha-channel */ - virtual CFLOAT getAlpha(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo)const { return 1.f; } + virtual float getAlpha(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo)const { return 1.f; } /*! specialized function for photon mapping. Default function uses the sample function, which will do fine for most materials unless there's a less expensive way or smarter scattering approach */ @@ -209,7 +209,7 @@ class YAFRAYCORE_EXPORT material_t protected: /* small function to apply bump mapping to a surface point you need to determine the partial derivatives for NU and NV first, e.g. from a shader node */ - void applyBump(surfacePoint_t &sp, PFLOAT dfdNU, PFLOAT dfdNV) const; + void applyBump(surfacePoint_t &sp, float dfdNU, float dfdNV) const; BSDF_t bsdfFlags; diff --git a/include/core_api/params.h b/include/core_api/params.h index f9ec390b..aa4a9466 100755 --- a/include/core_api/params.h +++ b/include/core_api/params.h @@ -66,9 +66,9 @@ class YAFRAYCORE_EXPORT parameter_t int ival; double fval; bool bval; - CFLOAT C[4]; - PFLOAT P[4]; - //PFLOAT matrix[4][4]; + float C[4]; + float P[4]; + //float matrix[4][4]; }; int vtype; //!< type of the stored value }; diff --git a/include/core_api/primitive.h b/include/core_api/primitive.h index da9c38d9..b9e13689 100755 --- a/include/core_api/primitive.h +++ b/include/core_api/primitive.h @@ -32,7 +32,7 @@ class YAFRAYCORE_EXPORT primitive_t The caller decides wether t matters or not. \return false if ray misses primitive, true otherwise \param t set this to raydepth where hit occurs */ - virtual bool intersect(const ray_t &ray, PFLOAT *t, intersectData_t &data) const = 0; + virtual bool intersect(const ray_t &ray, float *t, intersectData_t &data) const = 0; /* fill in surfacePoint_t */ virtual void getSurface(surfacePoint_t &sp, const point3d_t &hit, intersectData_t &data) const = 0; /* return the material */ diff --git a/include/core_api/ray.h b/include/core_api/ray.h index a173b584..f682fa9c 100755 --- a/include/core_api/ray.h +++ b/include/core_api/ray.h @@ -12,13 +12,13 @@ class ray_t { public: ray_t(): tmin(0), tmax(-1.0), time(0.0) {} - ray_t(const point3d_t &f, const vector3d_t &d, PFLOAT start=0.0, PFLOAT end=-1.0, PFLOAT ftime=0.0): + ray_t(const point3d_t &f, const vector3d_t &d, float start=0.0, float end=-1.0, float ftime=0.0): from(f), dir(d), tmin(start), tmax(end), time(ftime) { } point3d_t from; vector3d_t dir; - mutable PFLOAT tmin, tmax; - PFLOAT time; //!< relative frame time (values between [0;1]) at which ray was generated + mutable float tmin, tmax; + float time; //!< relative frame time (values between [0;1]) at which ray was generated }; class diffRay_t: public ray_t @@ -26,7 +26,7 @@ class diffRay_t: public ray_t public: diffRay_t(): ray_t(), hasDifferentials(false) {} diffRay_t(const ray_t &r): ray_t(r), hasDifferentials(false) {} - diffRay_t(const point3d_t &f, const vector3d_t &d, PFLOAT start=0.0, PFLOAT end=-1.0, PFLOAT ftime=0.0): + diffRay_t(const point3d_t &f, const vector3d_t &d, float start=0.0, float end=-1.0, float ftime=0.0): ray_t(f, d, start, end, ftime), hasDifferentials(false) {} bool hasDifferentials; point3d_t xfrom, yfrom; diff --git a/include/core_api/renderpasses.h b/include/core_api/renderpasses.h index 90210779..922b512c 100755 --- a/include/core_api/renderpasses.h +++ b/include/core_api/renderpasses.h @@ -223,7 +223,7 @@ class YAFRAYCORE_EXPORT colorPasses_t //Internal YafaRay color passes generated colorA_t probe_mult(const intPassTypes_t& intPassType, const colorA_t& renderedColor, const bool& condition = true); colorA_t probe_mult(const intPassTypes_t& intPassType, const colorPasses_t& colorPasses, const bool& condition = true); - colorPasses_t & operator *= (CFLOAT f); + colorPasses_t & operator *= (float f); colorPasses_t & operator *= (const color_t &a); colorPasses_t & operator *= (const colorA_t &a); colorPasses_t & operator += (const colorPasses_t &a); diff --git a/include/core_api/scene.h b/include/core_api/scene.h index f13ca982..7516fca7 100755 --- a/include/core_api/scene.h +++ b/include/core_api/scene.h @@ -63,15 +63,15 @@ struct YAFRAYCORE_EXPORT renderState_t ~renderState_t(){}; int raylevel; - CFLOAT depth; - CFLOAT contribution; //? + float depth; + float contribution; //? const void *skipelement; int currentPass; int pixelSample; //!< number of samples inside this pixels so far int rayDivision; //!< keep track of trajectory splitting int rayOffset; //!< keep track of trajectory splitting float dc1, dc2; //!< used to decorrelate samples from trajectory splitting - PFLOAT traveled; + float traveled; int pixelNumber; int threadID; //!< identify the current render thread; shall range from 0 to scene_t::getNumThreads() - 1 unsigned int samplingOffs; //!< a "noise-like" pixel offset you may use to decorelate sampling of adjacent pixel. @@ -79,8 +79,8 @@ struct YAFRAYCORE_EXPORT renderState_t const camera_t *cam; bool chromatic; //!< indicates wether the full spectrum is calculated (true) or only a single wavelength (false). bool includeLights; //!< indicate that emission of materials assiciated to lights shall be included, for correctly visible lights etc. - PFLOAT wavelength; //!< the (normalized) wavelength being used when chromatic is false. - PFLOAT time; //!< the current (normalized) frame time + float wavelength; //!< the (normalized) wavelength being used when chromatic is false. + float time; //!< the current (normalized) frame time mutable void *userdata; //!< a fixed amount of memory where materials may keep data to avoid recalculations...really need better memory management :( void *lightdata; //!< reserved; non-dirac lights may do some surface-point dependant initializations in the future to reduce redundancy... random_t *const prng; //!< a pseudorandom number generator @@ -160,11 +160,11 @@ class YAFRAYCORE_EXPORT scene_t void addNormal(const normal_t &n); bool addTriangle(int a, int b, int c, const material_t *mat); bool addTriangle(int a, int b, int c, int uv_a, int uv_b, int uv_c, const material_t *mat); - int addUV(GFLOAT u, GFLOAT v); + int addUV(float u, float v); bool startVmap(int id, int type, int dimensions); bool endVmap(); bool addVmapValues(float *val); - bool smoothMesh(objID_t id, PFLOAT angle); + bool smoothMesh(objID_t id, float angle); bool update(); bool addLight(light_t *l); @@ -194,7 +194,7 @@ class YAFRAYCORE_EXPORT scene_t int getNumThreadsPhotons() const { return nthreads_photons; } int getSignals() const; //! only for backward compatibility! - void getAAParameters(int &samples, int &passes, int &inc_samples, CFLOAT &threshold, float &resampled_floor, float &sample_multiplier_factor, float &light_sample_multiplier_factor, float &indirect_sample_multiplier_factor, bool &detect_color_noise, int &dark_detection_type, float &dark_threshold_factor, int &variance_edge_size, int &variance_pixels, float &clamp_samples, float &clamp_indirect) const; + void getAAParameters(int &samples, int &passes, int &inc_samples, float &threshold, float &resampled_floor, float &sample_multiplier_factor, float &light_sample_multiplier_factor, float &indirect_sample_multiplier_factor, bool &detect_color_noise, int &dark_detection_type, float &dark_threshold_factor, int &variance_edge_size, int &variance_pixels, float &clamp_samples, float &clamp_indirect) const; bool intersect(const ray_t &ray, surfacePoint_t &sp) const; bool isShadowed(renderState_t &state, const ray_t &ray, float &obj_index, float &mat_index) const; bool isShadowed(renderState_t &state, const ray_t &ray, int maxDepth, color_t &filt, float &obj_index, float &mat_index) const; @@ -208,10 +208,10 @@ class YAFRAYCORE_EXPORT scene_t std::vector lights; volumeIntegrator_t *volIntegrator; - PFLOAT shadowBias; //shadow bias to apply to shadows to avoid self-shadow artifacts + float shadowBias; //shadow bias to apply to shadows to avoid self-shadow artifacts bool shadowBiasAuto; //enable automatic shadow bias calculation - PFLOAT rayMinDist; //ray minimum distance + float rayMinDist; //ray minimum distance bool rayMinDistAuto; //enable automatic ray minimum distance calculation protected: @@ -231,7 +231,7 @@ class YAFRAYCORE_EXPORT scene_t int AA_samples, AA_passes; int AA_inc_samples; //!< sample count for additional passes - CFLOAT AA_threshold; + float AA_threshold; float AA_resampled_floor; //!< minimum amount of resampled pixels (% of the total pixels) below which we will automatically decrease the AA_threshold value for the next pass float AA_sample_multiplier_factor; float AA_light_sample_multiplier_factor; diff --git a/include/core_api/shader.h b/include/core_api/shader.h index 6e8d35f6..16d19582 100755 --- a/include/core_api/shader.h +++ b/include/core_api/shader.h @@ -17,9 +17,9 @@ class shaderNode_t; struct nodeResult_t { nodeResult_t() {} - nodeResult_t(colorA_t color, CFLOAT fval): col(color), f(fval) {} + nodeResult_t(colorA_t color, float fval): col(color), f(fval) {} colorA_t col; - CFLOAT f; + float f; }; class nodeStack_t @@ -81,12 +81,12 @@ class YAFRAYCORE_EXPORT shaderNode_t /*! get the color value calculated on eval */ colorA_t getColor(const nodeStack_t &stack)const { return stack(this->ID).col; } /*! get the scalar value calculated on eval */ - CFLOAT getScalar(const nodeStack_t &stack)const { return stack(this->ID).f; } + float getScalar(const nodeStack_t &stack)const { return stack(this->ID).f; } //! get the (approximate) partial derivatives df/dNU and df/dNV /*! where f is the shader function, and NU/NV/N build the shading coordinate system \param du df/dNU \param dv df/dNV */ - void getDerivative(const nodeStack_t &stack, CFLOAT &du, CFLOAT &dv)const + void getDerivative(const nodeStack_t &stack, float &du, float &dv)const { du = stack(this->ID).col.R; dv = stack(this->ID).col.G; } /* virtual void getDerivative(const surfacePoint_t &sp, float &du, float &dv)const {du=0.f, dv=0.f;} */ unsigned int ID; @@ -178,13 +178,13 @@ inline float texture_value_blend(float tex, float out, float fact, float facg, m return facm*out + fact*std::fabs(tex-out); case MN_DARK: { - CFLOAT col = fact*tex; + float col = fact*tex; if (colout) return col; return out; } diff --git a/include/core_api/surface.h b/include/core_api/surface.h index 81077f08..99e26df1 100755 --- a/include/core_api/surface.h +++ b/include/core_api/surface.h @@ -81,18 +81,18 @@ struct YAFRAYCORE_EXPORT surfacePoint_t bool available; int primNum; - GFLOAT U; //!< the u texture coord. - GFLOAT V; //!< the v texture coord. + float U; //!< the u texture coord. + float V; //!< the v texture coord. vector3d_t NU; //!< second vector building orthogonal shading space with N vector3d_t NV; //!< third vector building orthogonal shading space with N vector3d_t dPdU; //!< u-axis in world space vector3d_t dPdV; //!< v-axis in world space vector3d_t dSdU; //!< u-axis in shading space (NU, NV, N) vector3d_t dSdV; //!< v-axis in shading space (NU, NV, N) - //GFLOAT dudNU; - //GFLOAT dudNV; - //GFLOAT dvdNU; - //GFLOAT dvdNV; + //float dudNU; + //float dudNV; + //float dvdNU; + //float dvdNV; }; YAFRAYCORE_EXPORT surfacePoint_t blend_surface_points(surfacePoint_t const& sp_0, surfacePoint_t const& sp_1, float const alpha); @@ -106,8 +106,8 @@ class YAFRAYCORE_EXPORT spDifferentials_t //! compute differentials for a scattered ray void reflectedRay(const diffRay_t &in, diffRay_t &out) const; //! compute differentials for a refracted ray - void refractedRay(const diffRay_t &in, diffRay_t &out, PFLOAT IOR) const; - PFLOAT projectedPixelArea(); + void refractedRay(const diffRay_t &in, diffRay_t &out, float IOR) const; + float projectedPixelArea(); vector3d_t dPdx; vector3d_t dPdy; const surfacePoint_t &sp; diff --git a/include/core_api/texture.h b/include/core_api/texture.h index fef925a6..7e652b8f 100755 --- a/include/core_api/texture.h +++ b/include/core_api/texture.h @@ -19,17 +19,17 @@ class YAFRAYCORE_EXPORT texture_t virtual colorA_t getColor(int x, int y, int z) const { return colorA_t(0.f); } virtual colorA_t getRawColor(const point3d_t &p) const { return getColor(p); } virtual colorA_t getRawColor(int x, int y, int z) const { return getColor(x, y, z); } - virtual CFLOAT getFloat(const point3d_t &p) const { return getRawColor(p).col2bri(); } - virtual CFLOAT getFloat(int x, int y, int z) const { return getRawColor(x, y, z).col2bri(); } + virtual float getFloat(const point3d_t &p) const { return getRawColor(p).col2bri(); } + virtual float getFloat(int x, int y, int z) const { return getRawColor(x, y, z).col2bri(); } /* gives the number of values in each dimension for discrete textures */ virtual void resolution(int &x, int &y, int &z) const { x=0, y=0, z=0; } virtual void getInterpolationStep(float &step) const { step = 0.f; }; virtual ~texture_t() {} }; -inline void angmap(const point3d_t &p, PFLOAT &u, PFLOAT &v) +inline void angmap(const point3d_t &p, float &u, float &v) { - PFLOAT r = p.x*p.x + p.z*p.z; + float r = p.x*p.x + p.z*p.z; u = v = 0.f; if (r > 0.f) { @@ -42,11 +42,11 @@ inline void angmap(const point3d_t &p, PFLOAT &u, PFLOAT &v) // slightly modified Blender's own function, // works better than previous function which needed extra tweaks -inline void tubemap(const point3d_t &p, PFLOAT &u, PFLOAT &v) +inline void tubemap(const point3d_t &p, float &u, float &v) { u = 0; v = 1 - (p.z + 1)*0.5; - PFLOAT d = p.x*p.x + p.y*p.y; + float d = p.x*p.x + p.y*p.y; if (d>0) { d = 1/fSqrt(d); u = 0.5*(1 - (atan2(p.x*d, p.y*d) *M_1_PI)); @@ -54,7 +54,7 @@ inline void tubemap(const point3d_t &p, PFLOAT &u, PFLOAT &v) } // maps a direction to a 2d 0..1 interval -inline void spheremap(const point3d_t &p, PFLOAT &u, PFLOAT &v) +inline void spheremap(const point3d_t &p, float &u, float &v) { float sqrtRPhi = p.x*p.x + p.y*p.y; float sqrtRTheta = sqrtRPhi + p.z*p.z; diff --git a/include/core_api/vector3d.h b/include/core_api/vector3d.h index 4805e19a..ab5128f3 100755 --- a/include/core_api/vector3d.h +++ b/include/core_api/vector3d.h @@ -48,49 +48,49 @@ class YAFRAYCORE_EXPORT vector3d_t { public: vector3d_t() { } - vector3d_t(PFLOAT v): x(v), y(v), z(v) { } - vector3d_t(PFLOAT ix, PFLOAT iy, PFLOAT iz=0): x(ix), y(iy), z(iz) { } + vector3d_t(float v): x(v), y(v), z(v) { } + vector3d_t(float ix, float iy, float iz=0): x(ix), y(iy), z(iz) { } vector3d_t(const vector3d_t &s): x(s.x), y(s.y), z(s.z) { } explicit vector3d_t(const normal_t &n); explicit vector3d_t(const point3d_t &p); - void set(PFLOAT ix, PFLOAT iy, PFLOAT iz=0) { x=ix; y=iy; z=iz; } + void set(float ix, float iy, float iz=0) { x=ix; y=iy; z=iz; } vector3d_t& normalize(); vector3d_t& reflect(const vector3d_t &n); // normalizes and returns length - PFLOAT normLen() + float normLen() { - PFLOAT vl = x*x + y*y + z*z; + float vl = x*x + y*y + z*z; if (vl!=0.0) { vl = fSqrt(vl); - const PFLOAT d = 1.0/vl; + const float d = 1.0/vl; x*=d; y*=d; z*=d; } return vl; } // normalizes and returns length squared - PFLOAT normLenSqr() + float normLenSqr() { - PFLOAT vl = x*x + y*y + z*z; + float vl = x*x + y*y + z*z; if (vl!=0.0) { - const PFLOAT d = 1.0/fSqrt(vl); + const float d = 1.0/fSqrt(vl); x*=d; y*=d; z*=d; } return vl; } - PFLOAT length() const; - PFLOAT lengthSqr() const{ return x*x+y*y+z*z; } + float length() const; + float lengthSqr() const{ return x*x+y*y+z*z; } bool null()const { return ((x==0) && (y==0) && (z==0)); } float sinFromVectors(const vector3d_t &v); vector3d_t& operator = (const vector3d_t &s) { x=s.x; y=s.y; z=s.z; return *this;} vector3d_t& operator +=(const vector3d_t &s) { x+=s.x; y+=s.y; z+=s.z; return *this;} vector3d_t& operator -=(const vector3d_t &s) { x-=s.x; y-=s.y; z-=s.z; return *this;} - vector3d_t& operator /=(PFLOAT s) { x/=s; y/=s; z/=s; return *this;} - vector3d_t& operator *=(PFLOAT s) { x*=s; y*=s; z*=s; return *this;} - PFLOAT operator[] (int i) const{ return (&x)[i]; } //Lynx + vector3d_t& operator /=(float s) { x/=s; y/=s; z/=s; return *this;} + vector3d_t& operator *=(float s) { x*=s; y*=s; z*=s; return *this;} + float operator[] (int i) const{ return (&x)[i]; } //Lynx void abs() { x=std::fabs(x); y=std::fabs(y); z=std::fabs(z); } ~vector3d_t() {}; - PFLOAT x,y,z; + float x,y,z; friend class boost::serialization::access; template void serialize(Archive & ar, const unsigned int version) @@ -105,12 +105,12 @@ class YAFRAYCORE_EXPORT normal_t { public: normal_t(){}; - normal_t(GFLOAT nx, GFLOAT ny, GFLOAT nz): x(nx), y(ny), z(nz){} + normal_t(float nx, float ny, float nz): x(nx), y(ny), z(nz){} explicit normal_t(const vector3d_t &v): x(v.x), y(v.y), z(v.z) { } normal_t& normalize(); normal_t& operator = (const vector3d_t &v){ x=v.x, y=v.y, z=v.z; return *this; } normal_t& operator +=(const vector3d_t &s) { x+=s.x; y+=s.y; z+=s.z; return *this; } - GFLOAT x, y, z; + float x, y, z; friend class boost::serialization::access; template void serialize(Archive & ar, const unsigned int version) @@ -125,20 +125,20 @@ class YAFRAYCORE_EXPORT point3d_t { public: point3d_t() {} - point3d_t(PFLOAT ix, PFLOAT iy, PFLOAT iz=0): x(ix), y(iy), z(iz) { } + point3d_t(float ix, float iy, float iz=0): x(ix), y(iy), z(iz) { } point3d_t(const point3d_t &s): x(s.x), y(s.y), z(s.z) { } point3d_t(const vector3d_t &v): x(v.x), y(v.y), z(v.z) { } - void set(PFLOAT ix, PFLOAT iy, PFLOAT iz=0) { x=ix; y=iy; z=iz; } - PFLOAT length() const; + void set(float ix, float iy, float iz=0) { x=ix; y=iy; z=iz; } + float length() const; point3d_t& operator= (const point3d_t &s) { x=s.x; y=s.y; z=s.z; return *this; } - point3d_t& operator *=(PFLOAT s) { x*=s; y*=s; z*=s; return *this;} - point3d_t& operator +=(PFLOAT s) { x+=s; y+=s; z+=s; return *this;} + point3d_t& operator *=(float s) { x*=s; y*=s; z*=s; return *this;} + point3d_t& operator +=(float s) { x+=s; y+=s; z+=s; return *this;} point3d_t& operator +=(const point3d_t &s) { x+=s.x; y+=s.y; z+=s.z; return *this;} point3d_t& operator -=(const point3d_t &s) { x-=s.x; y-=s.y; z-=s.z; return *this;} - PFLOAT operator[] (int i) const{ return (&x)[i]; } //Lynx - PFLOAT &operator[](int i) { return (&x)[i]; } //Lynx + float operator[] (int i) const{ return (&x)[i]; } //Lynx + float &operator[](int i) { return (&x)[i]; } //Lynx ~point3d_t() {}; - PFLOAT x,y,z; + float x,y,z; friend class boost::serialization::access; template void serialize(Archive & ar, const unsigned int version) @@ -160,42 +160,42 @@ inline vector3d_t::vector3d_t(const point3d_t &p): x(p.x), y(p.y), z(p.z) { } YAFRAYCORE_EXPORT std::ostream & operator << (std::ostream &out,const vector3d_t &v); YAFRAYCORE_EXPORT std::ostream & operator << (std::ostream &out,const point3d_t &p); -inline PFLOAT operator * ( const vector3d_t &a,const vector3d_t &b) +inline float operator * ( const vector3d_t &a,const vector3d_t &b) { return (a.x*b.x+a.y*b.y+a.z*b.z); } -inline vector3d_t operator * ( PFLOAT f,const vector3d_t &b) +inline vector3d_t operator * ( float f,const vector3d_t &b) { return vector3d_t(f*b.x,f*b.y,f*b.z); } -inline vector3d_t operator * (const vector3d_t &b,PFLOAT f) +inline vector3d_t operator * (const vector3d_t &b,float f) { return vector3d_t(f*b.x,f*b.y,f*b.z); } -inline point3d_t operator * (PFLOAT f,const point3d_t &b) +inline point3d_t operator * (float f,const point3d_t &b) { return point3d_t(f*b.x,f*b.y,f*b.z); } -inline vector3d_t operator / (const vector3d_t &b,PFLOAT f) +inline vector3d_t operator / (const vector3d_t &b,float f) { return vector3d_t(b.x/f,b.y/f,b.z/f); } -inline point3d_t operator / (const point3d_t &b,PFLOAT f) +inline point3d_t operator / (const point3d_t &b,float f) { return point3d_t(b.x/f,b.y/f,b.z/f); } -inline point3d_t operator * (const point3d_t &b,PFLOAT f) +inline point3d_t operator * (const point3d_t &b,float f) { return point3d_t(b.x*f,b.y*f,b.z*f); } -inline vector3d_t operator / (PFLOAT f,const vector3d_t &b) +inline vector3d_t operator / (float f,const vector3d_t &b) { return vector3d_t(b.x/f,b.y/f,b.z/f); } @@ -259,14 +259,14 @@ inline point3d_t mult(const point3d_t &a, const vector3d_t &b) return point3d_t(a.x * b.x, a.y * b.y, a.z * b.z); } -inline PFLOAT vector3d_t::length()const +inline float vector3d_t::length()const { return fSqrt(x*x+y*y+z*z); } inline vector3d_t& vector3d_t::normalize() { - PFLOAT len = x*x + y*y + z*z; + float len = x*x + y*y + z*z; if (len!=0) { len = 1.0/fSqrt(len); @@ -289,7 +289,7 @@ inline float vector3d_t::sinFromVectors(const vector3d_t& v) inline normal_t& normal_t::normalize() { - PFLOAT len = x*x + y*y + z*z; + float len = x*x + y*y + z*z; if (len!=0) { len = 1.0/fSqrt(len); @@ -317,7 +317,7 @@ inline vector3d_t& vector3d_t::reflect(const vector3d_t &n) inline vector3d_t reflect_dir(const vector3d_t &n,const vector3d_t &v) { - const PFLOAT vn = v*n; + const float vn = v*n; if (vn<0) return -v; return 2*vn*n - v; } @@ -348,13 +348,13 @@ inline void createCS(const vector3d_t &N, vector3d_t &u, vector3d_t &v) { // Note: The root cannot become zero if // N.x==0 && N.y==0. - const PFLOAT d = 1.0/fSqrt(N.y*N.y + N.x*N.x); + const float d = 1.0/fSqrt(N.y*N.y + N.x*N.x); u.set(N.y*d, -N.x*d, 0); v = N^u; } } -YAFRAYCORE_EXPORT void ShirleyDisk(PFLOAT r1, PFLOAT r2, PFLOAT &u, PFLOAT &v); +YAFRAYCORE_EXPORT void ShirleyDisk(float r1, float r2, float &u, float &v); extern YAFRAYCORE_EXPORT int myseed; @@ -370,7 +370,7 @@ inline int ourRandomI() return myseed; } -inline PFLOAT ourRandom() +inline float ourRandom() { const int a = 0x000041A7; const int m = 0x7FFFFFFF; @@ -379,10 +379,10 @@ inline PFLOAT ourRandom() myseed = a * (myseed % q) - r * (myseed/q); if (myseed < 0) myseed += m; - return (PFLOAT)myseed/(PFLOAT)m; + return (float)myseed/(float)m; } -inline PFLOAT ourRandom(int &seed) +inline float ourRandom(int &seed) { const int a = 0x000041A7; const int m = 0x7FFFFFFF; @@ -391,15 +391,15 @@ inline PFLOAT ourRandom(int &seed) seed = a * (seed % q) - r * (seed/q); if (myseed < 0) myseed += m; - return (PFLOAT)seed/(PFLOAT)m; + return (float)seed/(float)m; } inline vector3d_t RandomSpherical() { - PFLOAT r; + float r; vector3d_t v(0.0, 0.0, ourRandom()); if ((r = 1.0 - v.z*v.z)>0.0) { - PFLOAT a = M_2PI * ourRandom(); + float a = M_2PI * ourRandom(); r = fSqrt(r); v.x = r * fCos(a); v.y = r * fSin(a); } @@ -408,9 +408,9 @@ inline vector3d_t RandomSpherical() } YAFRAYCORE_EXPORT vector3d_t randomVectorCone(const vector3d_t &D, const vector3d_t &U, const vector3d_t &V, - PFLOAT cosang, PFLOAT z1, PFLOAT z2); -YAFRAYCORE_EXPORT vector3d_t randomVectorCone(const vector3d_t &dir, PFLOAT cosangle, PFLOAT r1, PFLOAT r2); -YAFRAYCORE_EXPORT vector3d_t discreteVectorCone(const vector3d_t &dir, PFLOAT cangle, int sample, int square); + float cosang, float z1, float z2); +YAFRAYCORE_EXPORT vector3d_t randomVectorCone(const vector3d_t &dir, float cosangle, float r1, float r2); +YAFRAYCORE_EXPORT vector3d_t discreteVectorCone(const vector3d_t &dir, float cangle, int sample, int square); __END_YAFRAY diff --git a/include/integrators/integr_utils.h b/include/integrators/integr_utils.h index 9ed2eb9d..381dc60c 100755 --- a/include/integrators/integr_utils.h +++ b/include/integrators/integr_utils.h @@ -32,7 +32,7 @@ class photonMap_t; //from common.cc color_t estimateDirect_PH(renderState_t &state, const surfacePoint_t &sp, const std::vector &lights, scene_t *scene, const vector3d_t &wo, bool trShad, int sDepth); -color_t estimatePhotons(renderState_t &state, const surfacePoint_t &sp, const photonMap_t &map, const vector3d_t &wo, int nSearch, PFLOAT radius); +color_t estimatePhotons(renderState_t &state, const surfacePoint_t &sp, const photonMap_t &map, const vector3d_t &wo, int nSearch, float radius); bool createCausticMap(const scene_t &scene, const std::vector &all_lights, photonMap_t &cMap, int depth, int count, progressBar_t *pb = nullptr, std::string intName = "None"); diff --git a/include/lights/arealight.h b/include/lights/arealight.h index a87c3bbb..dbe505b2 100755 --- a/include/lights/arealight.h +++ b/include/lights/arealight.h @@ -11,7 +11,7 @@ class areaLight_t : public light_t { public: areaLight_t(const point3d_t &c, const vector3d_t &v1, const vector3d_t &v2, - const color_t &col, CFLOAT inte, int nsam, bool bLightEnabled=true, bool bCastShadows=true); + const color_t &col, float inte, int nsam, bool bLightEnabled=true, bool bCastShadows=true); ~areaLight_t(); virtual void init(scene_t &scene); virtual color_t totalEnergy() const; @@ -21,7 +21,7 @@ class areaLight_t : public light_t virtual bool illumSample(const surfacePoint_t &sp, lSample_t &s, ray_t &wi) const; virtual bool illuminate(const surfacePoint_t &sp, color_t &col, ray_t &wi)const { return false; } virtual bool canIntersect() const{ return true; } - virtual bool intersect(const ray_t &ray, PFLOAT &t, color_t &col, float &ipdf) const; + virtual bool intersect(const ray_t &ray, float &t, color_t &col, float &ipdf) const; virtual float illumPdf(const surfacePoint_t &sp, const surfacePoint_t &sp_light) const; virtual void emitPdf(const surfacePoint_t &sp, const vector3d_t &wi, float &areaPdf, float &dirPdf, float &cos_wo) const; virtual int nSamples() const { return samples; } diff --git a/include/lights/bgportallight.h b/include/lights/bgportallight.h index ef165d3a..a22dd3c1 100755 --- a/include/lights/bgportallight.h +++ b/include/lights/bgportallight.h @@ -48,7 +48,7 @@ class bgPortalLight_t : public light_t virtual bool illuminate(const surfacePoint_t &sp, color_t &col, ray_t &wi)const { return false; } virtual int nSamples() const { return samples; } virtual bool canIntersect() const{ return tree!=0 /* false */ ; } - virtual bool intersect(const ray_t &ray, PFLOAT &t, color_t &col, float &ipdf) const; + virtual bool intersect(const ray_t &ray, float &t, color_t &col, float &ipdf) const; virtual float illumPdf(const surfacePoint_t &sp, const surfacePoint_t &sp_light) const; virtual void emitPdf(const surfacePoint_t &sp, const vector3d_t &wi, float &areaPdf, float &dirPdf, float &cos_wo) const; static light_t *factory(paraMap_t ¶ms, renderEnvironment_t &render); diff --git a/include/lights/meshlight.h b/include/lights/meshlight.h index ac8dd9e4..36b57a8a 100755 --- a/include/lights/meshlight.h +++ b/include/lights/meshlight.h @@ -46,7 +46,7 @@ class meshLight_t : public light_t virtual bool illuminate(const surfacePoint_t &sp, color_t &col, ray_t &wi)const { return false; } virtual int nSamples() const { return samples; } virtual bool canIntersect() const{ return tree!=0 /* false */ ; } - virtual bool intersect(const ray_t &ray, PFLOAT &t, color_t &col, float &ipdf) const; + virtual bool intersect(const ray_t &ray, float &t, color_t &col, float &ipdf) const; virtual float illumPdf(const surfacePoint_t &sp, const surfacePoint_t &sp_light) const; virtual void emitPdf(const surfacePoint_t &sp, const vector3d_t &wi, float &areaPdf, float &dirPdf, float &cos_wo) const; static light_t *factory(paraMap_t ¶ms, renderEnvironment_t &render); diff --git a/include/materials/blendmat.h b/include/materials/blendmat.h index 6d426e44..2cc3cc25 100755 --- a/include/materials/blendmat.h +++ b/include/materials/blendmat.h @@ -31,7 +31,7 @@ class blendMat_t: public nodeMaterial_t virtual color_t emit(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo)const; virtual void getSpecular(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo, bool &reflect, bool &refract, vector3d_t *const dir, color_t *const col)const; - virtual CFLOAT getAlpha(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo)const; + virtual float getAlpha(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo)const; virtual bool scatterPhoton(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wi, vector3d_t &wo, pSample_t &s) const; virtual const volumeHandler_t* getVolumeHandler(bool inside)const; diff --git a/include/materials/maskmat.h b/include/materials/maskmat.h index 22a44072..d4b2ca35 100755 --- a/include/materials/maskmat.h +++ b/include/materials/maskmat.h @@ -12,7 +12,7 @@ class renderEnvironment_t; class maskMat_t: public nodeMaterial_t { public: - maskMat_t(const material_t *m1, const material_t *m2, CFLOAT thresh, visibility_t eVisibility=NORMAL_VISIBLE); + maskMat_t(const material_t *m1, const material_t *m2, float thresh, visibility_t eVisibility=NORMAL_VISIBLE); virtual void initBSDF(const renderState_t &state, surfacePoint_t &sp, BSDF_t &bsdfTypes)const; virtual color_t eval(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo, const vector3d_t &wi, BSDF_t bsdfs, bool force_eval = false)const; virtual color_t sample(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo, vector3d_t &wi, sample_t &s, float &W)const; @@ -22,14 +22,14 @@ class maskMat_t: public nodeMaterial_t virtual void getSpecular(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo, bool &reflect, bool &refract, vector3d_t *const dir, color_t *const col)const; virtual color_t emit(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo)const; - virtual CFLOAT getAlpha(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo)const; + virtual float getAlpha(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo)const; static material_t* factory(paraMap_t &, std::list< paraMap_t > &, renderEnvironment_t &); protected: const material_t *mat1; const material_t *mat2; shaderNode_t* mask; - CFLOAT threshold; + float threshold; //const texture_t *mask; }; diff --git a/include/materials/microfacet.h b/include/materials/microfacet.h index 33ff89be..37c396ec 100755 --- a/include/materials/microfacet.h +++ b/include/materials/microfacet.h @@ -166,7 +166,7 @@ inline void reflectMicrofacet(const vector3d_t &wo, vector3d_t &wi, const vector wi = -wi; } -inline float SchlickFresnel(PFLOAT costheta, PFLOAT R) +inline float SchlickFresnel(float costheta, float R) { float c1 = (1.f - costheta); float c2 = c1 * c1; diff --git a/include/materials/shinydiff.h b/include/materials/shinydiff.h index 31d5d999..0d684506 100755 --- a/include/materials/shinydiff.h +++ b/include/materials/shinydiff.h @@ -34,7 +34,7 @@ class shinyDiffuseMat_t: public nodeMaterial_t virtual color_t getTransparency(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo)const; virtual color_t emit(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo)const; // { return emitCol; } virtual void getSpecular(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo, bool &reflect, bool &refract, vector3d_t *const dir, color_t *const col)const; - virtual CFLOAT getAlpha(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo)const; + virtual float getAlpha(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo)const; virtual color_t getDiffuseColor(const renderState_t &state) const { SDDat_t *dat = (SDDat_t *)state.userdata; @@ -90,7 +90,7 @@ class shinyDiffuseMat_t: public nodeMaterial_t void getFresnel(const vector3d_t &wo, const vector3d_t &N, float &Kr, float ¤tIORSquared) const; void initOrenNayar(double sigma); - CFLOAT OrenNayar(const vector3d_t &wi, const vector3d_t &wo, const vector3d_t &N, bool useTextureSigma, double textureSigma) const; + float OrenNayar(const vector3d_t &wi, const vector3d_t &wo, const vector3d_t &N, bool useTextureSigma, double textureSigma) const; bool mIsTransparent; //!< Boolean value which is true if you have transparent component bool mIsTranslucent; //!< Boolean value which is true if you have translucent component diff --git a/include/textures/basicnodes.h b/include/textures/basicnodes.h index c0fc5a84..051a4f07 100755 --- a/include/textures/basicnodes.h +++ b/include/textures/basicnodes.h @@ -62,7 +62,7 @@ class mixNode_t: public shaderNode_t virtual bool getDependencies(std::vector &dep) const; static shaderNode_t* factory(const paraMap_t ¶ms,renderEnvironment_t &render); protected: - void getInputs(nodeStack_t &stack, colorA_t &cin1, colorA_t &cin2, CFLOAT &fin1, CFLOAT &fin2, CFLOAT &f2) const; + void getInputs(nodeStack_t &stack, colorA_t &cin1, colorA_t &cin2, float &fin1, float &fin2, float &f2) const; colorA_t col1, col2; float val1, val2, cfactor; const shaderNode_t *input1; @@ -70,7 +70,7 @@ class mixNode_t: public shaderNode_t const shaderNode_t *factor; }; -inline void mixNode_t::getInputs(nodeStack_t &stack, colorA_t &cin1, colorA_t &cin2, CFLOAT &fin1, CFLOAT &fin2, CFLOAT &f2) const +inline void mixNode_t::getInputs(nodeStack_t &stack, colorA_t &cin1, colorA_t &cin2, float &fin1, float &fin2, float &f2) const { f2 = (factor) ? factor->getScalar(stack) : cfactor; if(input1) diff --git a/include/textures/basictex.h b/include/textures/basictex.h index 01de0b8e..8551d08e 100755 --- a/include/textures/basictex.h +++ b/include/textures/basictex.h @@ -11,19 +11,19 @@ __BEGIN_YAFRAY class textureClouds_t : public texture_t { public: - textureClouds_t(int dep, PFLOAT sz, bool hd, + textureClouds_t(int dep, float sz, bool hd, const color_t &c1, const color_t &c2, const std::string &ntype, const std::string &btype); virtual ~textureClouds_t(); virtual colorA_t getColor(const point3d_t &p) const; - virtual CFLOAT getFloat(const point3d_t &p) const; + virtual float getFloat(const point3d_t &p) const; virtual void getInterpolationStep(float &step) const { step = size; }; static texture_t *factory(paraMap_t ¶ms,renderEnvironment_t &render); protected: int depth, bias; - PFLOAT size; + float size; bool hard; color_t color1, color2; noiseGenerator_t* nGen; @@ -33,8 +33,8 @@ class textureClouds_t : public texture_t class textureMarble_t : public texture_t { public: - textureMarble_t(int oct, PFLOAT sz, const color_t &c1, const color_t &c2, - PFLOAT _turb, PFLOAT shp, bool hrd, const std::string &ntype, const std::string &shape); + textureMarble_t(int oct, float sz, const color_t &c1, const color_t &c2, + float _turb, float shp, bool hrd, const std::string &ntype, const std::string &shape); virtual ~textureMarble_t() { if (nGen) { @@ -44,7 +44,7 @@ class textureMarble_t : public texture_t } virtual colorA_t getColor(const point3d_t &p) const; - virtual CFLOAT getFloat(const point3d_t &p) const; + virtual float getFloat(const point3d_t &p) const; virtual void getInterpolationStep(float &step) const { step = size; }; @@ -52,7 +52,7 @@ class textureMarble_t : public texture_t protected: int octaves; color_t color1, color2; - PFLOAT turb, sharpness, size; + float turb, sharpness, size; bool hard; noiseGenerator_t* nGen; enum {SIN, SAW, TRI} wshape; @@ -61,7 +61,7 @@ class textureMarble_t : public texture_t class textureWood_t : public texture_t { public: - textureWood_t(int oct, PFLOAT sz, const color_t &c1, const color_t &c2, PFLOAT _turb, + textureWood_t(int oct, float sz, const color_t &c1, const color_t &c2, float _turb, bool hrd, const std::string &ntype, const std::string &wtype, const std::string &shape); virtual ~textureWood_t() { @@ -72,7 +72,7 @@ class textureWood_t : public texture_t } virtual colorA_t getColor(const point3d_t &p) const; - virtual CFLOAT getFloat(const point3d_t &p) const; + virtual float getFloat(const point3d_t &p) const; virtual void getInterpolationStep(float &step) const { step = size; }; @@ -80,7 +80,7 @@ class textureWood_t : public texture_t protected: int octaves; color_t color1, color2; - PFLOAT turb, size; + float turb, size; bool hard, rings; noiseGenerator_t* nGen; enum {SIN, SAW, TRI} wshape; @@ -91,24 +91,24 @@ class textureVoronoi_t : public texture_t public: textureVoronoi_t(const color_t &c1, const color_t &c2, int ct, - CFLOAT _w1, CFLOAT _w2, CFLOAT _w3, CFLOAT _w4, - PFLOAT mex, PFLOAT sz, - CFLOAT isc, const std::string &dname); + float _w1, float _w2, float _w3, float _w4, + float mex, float sz, + float isc, const std::string &dname); virtual ~textureVoronoi_t() {} virtual colorA_t getColor(const point3d_t &p) const; - virtual CFLOAT getFloat(const point3d_t &p) const; + virtual float getFloat(const point3d_t &p) const; virtual void getInterpolationStep(float &step) const { step = size; }; static texture_t *factory(paraMap_t ¶ms, renderEnvironment_t &render); protected: color_t color1, color2; - CFLOAT w1, w2, w3, w4; // feature weights - CFLOAT aw1, aw2, aw3, aw4; // absolute value of above - PFLOAT size; + float w1, w2, w3, w4; // feature weights + float aw1, aw2, aw3, aw4; // absolute value of above + float size; int coltype; // color return type - CFLOAT iscale; // intensity scale + float iscale; // intensity scale voronoi_t vGen; }; @@ -116,13 +116,13 @@ class textureMusgrave_t : public texture_t { public: textureMusgrave_t(const color_t &c1, const color_t &c2, - PFLOAT H, PFLOAT lacu, PFLOAT octs, PFLOAT offs, PFLOAT gain, - PFLOAT _size, CFLOAT _iscale, + float H, float lacu, float octs, float offs, float gain, + float _size, float _iscale, const std::string &ntype, const std::string &mtype); virtual ~textureMusgrave_t(); virtual colorA_t getColor(const point3d_t &p) const; - virtual CFLOAT getFloat(const point3d_t &p) const; + virtual float getFloat(const point3d_t &p) const; virtual void getInterpolationStep(float &step) const { step = size; }; @@ -130,7 +130,7 @@ class textureMusgrave_t : public texture_t protected: color_t color1, color2; - PFLOAT size, iscale; + float size, iscale; noiseGenerator_t* nGen; musgrave_t* mGen; }; @@ -139,12 +139,12 @@ class textureDistortedNoise_t : public texture_t { public: textureDistortedNoise_t(const color_t &c1, const color_t &c2, - PFLOAT _distort, PFLOAT _size, + float _distort, float _size, const std::string &noiseb1, const std::string noiseb2); virtual ~textureDistortedNoise_t(); virtual colorA_t getColor(const point3d_t &p) const; - virtual CFLOAT getFloat(const point3d_t &p) const; + virtual float getFloat(const point3d_t &p) const; virtual void getInterpolationStep(float &step) const { step = size; }; @@ -152,7 +152,7 @@ class textureDistortedNoise_t : public texture_t protected: color_t color1, color2; - PFLOAT distort, size; + float distort, size; noiseGenerator_t *nGen1, *nGen2; }; @@ -165,7 +165,7 @@ class rgbCube_t : public texture_t public: rgbCube_t(){} virtual colorA_t getColor(const point3d_t &p) const; - virtual CFLOAT getFloat(const point3d_t &p) const; + virtual float getFloat(const point3d_t &p) const; static texture_t *factory(paraMap_t ¶ms,renderEnvironment_t &render); }; @@ -178,7 +178,7 @@ class textureBlend_t : public texture_t virtual ~textureBlend_t(); virtual colorA_t getColor(const point3d_t &p) const; - virtual CFLOAT getFloat(const point3d_t &p) const; + virtual float getFloat(const point3d_t &p) const; static texture_t *factory(paraMap_t ¶ms, renderEnvironment_t &render); }; diff --git a/include/textures/imagetex.h b/include/textures/imagetex.h index 025fd6eb..56c9d788 100755 --- a/include/textures/imagetex.h +++ b/include/textures/imagetex.h @@ -81,12 +81,12 @@ class textureImage_t : public texture_t }; /*static inline colorA_t cubicInterpolate(const colorA_t &c1, const colorA_t &c2, - const colorA_t &c3, const colorA_t &c4, CFLOAT x) + const colorA_t &c3, const colorA_t &c4, float x) { colorA_t t2(c3-c2); colorA_t t1(t2 - (c2-c1)); t2 = (c4-c3) - t2; - CFLOAT ix = 1.f-x; + float ix = 1.f-x; return x*c3 + ix*c2 + ((4.f*t2 - t1)*(x*x*x-x) + (4.f*t1 - t2)*(ix*ix*ix-ix))*0.06666667f; }*/ diff --git a/include/textures/layernode.h b/include/textures/layernode.h index ae9c1558..bde1308d 100755 --- a/include/textures/layernode.h +++ b/include/textures/layernode.h @@ -17,7 +17,7 @@ __BEGIN_YAFRAY class layerNode_t: public shaderNode_t { public: - layerNode_t(unsigned tflag, CFLOAT col_fac, CFLOAT var_fac, CFLOAT def_val, colorA_t def_col, mix_modes mmod); + layerNode_t(unsigned tflag, float col_fac, float var_fac, float def_val, colorA_t def_col, mix_modes mmod); virtual void eval(nodeStack_t &stack, const renderState_t &state, const surfacePoint_t &sp)const; virtual void eval(nodeStack_t &stack, const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo, const vector3d_t &wi)const; virtual void evalDerivative(nodeStack_t &stack, const renderState_t &state, const surfacePoint_t &sp)const; @@ -29,9 +29,9 @@ class layerNode_t: public shaderNode_t protected: const shaderNode_t *input, *upperLayer; unsigned int texflag; - CFLOAT colfac; - CFLOAT valfac; - CFLOAT default_val, upper_val; + float colfac; + float valfac; + float default_val, upper_val; colorA_t default_col, upper_col; mix_modes mode; bool do_color, do_scalar, color_input, use_alpha; diff --git a/include/textures/noise.h b/include/textures/noise.h index 0daddac7..30892300 100755 --- a/include/textures/noise.h +++ b/include/textures/noise.h @@ -13,7 +13,7 @@ class YAFRAYPLUGIN_EXPORT noiseGenerator_t public: noiseGenerator_t() {} virtual ~noiseGenerator_t() {} - virtual PFLOAT operator() (const point3d_t &pt) const=0; + virtual float operator() (const point3d_t &pt) const=0; // offset only added by blendernoise virtual point3d_t offset(const point3d_t &pt) const { return pt; } }; @@ -25,13 +25,13 @@ class YAFRAYPLUGIN_EXPORT newPerlin_t : public noiseGenerator_t public: newPerlin_t() {} virtual ~newPerlin_t() {} - virtual PFLOAT operator() (const point3d_t &pt) const; + virtual float operator() (const point3d_t &pt) const; private: - PFLOAT fade(PFLOAT t) const { return t*t*t*(t*(t*6 - 15) + 10); } - PFLOAT grad(int hash, PFLOAT x, PFLOAT y, PFLOAT z) const + float fade(float t) const { return t*t*t*(t*(t*6 - 15) + 10); } + float grad(int hash, float x, float y, float z) const { int h = hash & 15; // CONVERT LO 4 BITS OF HASH CODE - PFLOAT u = h<8 ? x : y, // INTO 12 GRADIENT DIRECTIONS. + float u = h<8 ? x : y, // INTO 12 GRADIENT DIRECTIONS. v = h<4 ? y : h==12||h==14 ? x : z; return ((h&1) == 0 ? u : -u) + ((h&2) == 0 ? v : -v); } @@ -44,7 +44,7 @@ class YAFRAYPLUGIN_EXPORT stdPerlin_t : public noiseGenerator_t public: stdPerlin_t() {} virtual ~stdPerlin_t() {} - virtual PFLOAT operator() (const point3d_t &pt) const; + virtual float operator() (const point3d_t &pt) const; }; // Blender noise, similar to Perlin's @@ -53,7 +53,7 @@ class YAFRAYPLUGIN_EXPORT blenderNoise_t : public noiseGenerator_t public: blenderNoise_t() {} virtual ~blenderNoise_t() {} - virtual PFLOAT operator() (const point3d_t &pt) const; + virtual float operator() (const point3d_t &pt) const; // offset texture point coordinates by one virtual point3d_t offset(const point3d_t &pt) const { return pt+point3d_t(1.0, 1.0, 1.0); } }; @@ -61,36 +61,36 @@ class YAFRAYPLUGIN_EXPORT blenderNoise_t : public noiseGenerator_t //--------------------------------------- // Voronoi, a.k.a. Worley/cellular basis -typedef PFLOAT (*distMetricFunc)(PFLOAT x, PFLOAT y, PFLOAT z, PFLOAT e); +typedef float (*distMetricFunc)(float x, float y, float z, float e); // distance metrics as functors /*struct distanceMetric_t { - virtual PFLOAT operator() (PFLOAT x, PFLOAT y, PFLOAT z, PFLOAT e)=0; + virtual float operator() (float x, float y, float z, float e)=0; }; struct dist_Real : public distanceMetric_t { - virtual PFLOAT operator() (PFLOAT x, PFLOAT y, PFLOAT z, PFLOAT e) { return sqrt(x*x + y*y + z*z); } + virtual float operator() (float x, float y, float z, float e) { return sqrt(x*x + y*y + z*z); } }; struct dist_Squared : public distanceMetric_t { - virtual PFLOAT operator() (PFLOAT x, PFLOAT y, PFLOAT z, PFLOAT e) { return (x*x + y*y + z*z); } + virtual float operator() (float x, float y, float z, float e) { return (x*x + y*y + z*z); } }; struct dist_Manhattan : public distanceMetric_t { - virtual PFLOAT operator() (PFLOAT x, PFLOAT y, PFLOAT z, PFLOAT e) { return (std::fabs(x) + std::fabs(y) + std::fabs(z)); } + virtual float operator() (float x, float y, float z, float e) { return (std::fabs(x) + std::fabs(y) + std::fabs(z)); } }; struct dist_Chebychev : public distanceMetric_t { - virtual PFLOAT operator() (PFLOAT x, PFLOAT y, PFLOAT z, PFLOAT e) + virtual float operator() (float x, float y, float z, float e) { x = std::fabs(x); y = std::fabs(y); z = std::fabs(z); - PFLOAT t = (x>y)?x:y; + float t = (x>y)?x:y; return ((z>t)?z:t); } }; @@ -98,9 +98,9 @@ struct dist_Chebychev : public distanceMetric_t // minkovsky preset exponent 0.5 struct dist_MinkovskyH : public distanceMetric_t { - virtual PFLOAT operator() (PFLOAT x, PFLOAT y, PFLOAT z, PFLOAT e) + virtual float operator() (float x, float y, float z, float e) { - PFLOAT d = sqrt(std::fabs(x)) + sqrt(std::fabs(y)) + sqrt(std::fabs(z)); + float d = sqrt(std::fabs(x)) + sqrt(std::fabs(y)) + sqrt(std::fabs(z)); return (d*d); } }; @@ -108,7 +108,7 @@ struct dist_MinkovskyH : public distanceMetric_t // minkovsky preset exponent 4 struct dist_Minkovsky4 : public distanceMetric_t { - virtual PFLOAT operator() (PFLOAT x, PFLOAT y, PFLOAT z, PFLOAT e) + virtual float operator() (float x, float y, float z, float e) { x *= x; y *= y; @@ -120,9 +120,9 @@ struct dist_Minkovsky4 : public distanceMetric_t // Minkovsky, general case, slow struct dist_Minkovsky : public distanceMetric_t { - virtual PFLOAT operator() (PFLOAT x, PFLOAT y, PFLOAT z, PFLOAT e) + virtual float operator() (float x, float y, float z, float e) { - return pow(pow(std::fabs(x), e) + pow(std::fabs(y), e) + pow(std::fabs(z), e), (PFLOAT)1.0/e); + return pow(pow(std::fabs(x), e) + pow(std::fabs(y), e) + pow(std::fabs(z), e), (float)1.0/e); } }; */ @@ -132,24 +132,24 @@ class YAFRAYPLUGIN_EXPORT voronoi_t : public noiseGenerator_t enum voronoiType {V_F1, V_F2, V_F3, V_F4, V_F2F1, V_CRACKLE}; enum dMetricType {DIST_REAL, DIST_SQUARED, DIST_MANHATTAN, DIST_CHEBYCHEV, DIST_MINKOVSKY_HALF, DIST_MINKOVSKY_FOUR, DIST_MINKOVSKY}; - voronoi_t(voronoiType vt=V_F1, dMetricType dm=DIST_REAL, PFLOAT mex=2.5); + voronoi_t(voronoiType vt=V_F1, dMetricType dm=DIST_REAL, float mex=2.5); virtual ~voronoi_t() { //if (distfunc) { delete distfunc; distfunc=nullptr; } } - virtual PFLOAT operator() (const point3d_t &pt) const; - PFLOAT getDistance(int x, PFLOAT da[4]) const { return da[x & 3]; } + virtual float operator() (const point3d_t &pt) const; + float getDistance(int x, float da[4]) const { return da[x & 3]; } point3d_t getPoint(int x, point3d_t pa[4]) const { return pa[x & 3]; } - void setMinkovskyExponent(PFLOAT me) { mk_exp=me; } - void getFeatures(const point3d_t &pt, PFLOAT da[4], point3d_t pa[4]) const; + void setMinkovskyExponent(float me) { mk_exp=me; } + void getFeatures(const point3d_t &pt, float da[4], point3d_t pa[4]) const; void setDistM(dMetricType dm); protected: voronoiType vType; dMetricType dmType; - PFLOAT mk_exp, w1, w2, w3,w4; + float mk_exp, w1, w2, w3,w4; // distanceMetric_t* distfunc; //test...replace functors distMetricFunc distfunc2; -// mutable PFLOAT da[4]; // distance array +// mutable float da[4]; // distance array // mutable point3d_t pa[4]; // feature point array }; @@ -159,7 +159,7 @@ class YAFRAYPLUGIN_EXPORT cellNoise_t : public noiseGenerator_t public: cellNoise_t() {} virtual ~cellNoise_t() {} - virtual PFLOAT operator() (const point3d_t &pt) const; + virtual float operator() (const point3d_t &pt) const; }; //------------------ @@ -170,79 +170,79 @@ class YAFRAYPLUGIN_EXPORT musgrave_t public: musgrave_t() {} virtual ~musgrave_t() {} - virtual PFLOAT operator() (const point3d_t &pt) const=0; + virtual float operator() (const point3d_t &pt) const=0; }; class YAFRAYPLUGIN_EXPORT fBm_t : public musgrave_t { public: - fBm_t(PFLOAT _H, PFLOAT _lacu, PFLOAT _octs, const noiseGenerator_t* _nGen) + fBm_t(float _H, float _lacu, float _octs, const noiseGenerator_t* _nGen) : H(_H), lacunarity(_lacu), octaves(_octs), nGen(_nGen) {} virtual ~fBm_t() {} - virtual PFLOAT operator() (const point3d_t &pt) const; + virtual float operator() (const point3d_t &pt) const; protected: - PFLOAT H, lacunarity, octaves; + float H, lacunarity, octaves; const noiseGenerator_t* nGen; }; class YAFRAYPLUGIN_EXPORT mFractal_t : public musgrave_t { public: - mFractal_t(PFLOAT _H, PFLOAT _lacu, PFLOAT _octs, const noiseGenerator_t* _nGen) + mFractal_t(float _H, float _lacu, float _octs, const noiseGenerator_t* _nGen) : H(_H), lacunarity(_lacu), octaves(_octs), nGen(_nGen) {} virtual ~mFractal_t() {} - virtual PFLOAT operator() (const point3d_t &pt) const; + virtual float operator() (const point3d_t &pt) const; protected: - PFLOAT H, lacunarity, octaves; + float H, lacunarity, octaves; const noiseGenerator_t* nGen; }; class YAFRAYPLUGIN_EXPORT heteroTerrain_t : public musgrave_t { public: - heteroTerrain_t(PFLOAT _H, PFLOAT _lacu, PFLOAT _octs, PFLOAT _offs, const noiseGenerator_t* _nGen) + heteroTerrain_t(float _H, float _lacu, float _octs, float _offs, const noiseGenerator_t* _nGen) : H(_H), lacunarity(_lacu), octaves(_octs), offset(_offs), nGen(_nGen) {} virtual ~heteroTerrain_t() {} - virtual PFLOAT operator() (const point3d_t &pt) const; + virtual float operator() (const point3d_t &pt) const; protected: - PFLOAT H, lacunarity, octaves, offset; + float H, lacunarity, octaves, offset; const noiseGenerator_t* nGen; }; class YAFRAYPLUGIN_EXPORT hybridMFractal_t : public musgrave_t { public: - hybridMFractal_t(PFLOAT _H, PFLOAT _lacu, PFLOAT _octs, PFLOAT _offs, PFLOAT _gain, const noiseGenerator_t* _nGen) + hybridMFractal_t(float _H, float _lacu, float _octs, float _offs, float _gain, const noiseGenerator_t* _nGen) : H(_H), lacunarity(_lacu), octaves(_octs), offset(_offs), gain(_gain), nGen(_nGen) {} virtual ~hybridMFractal_t() {} - virtual PFLOAT operator() (const point3d_t &pt) const; + virtual float operator() (const point3d_t &pt) const; protected: - PFLOAT H, lacunarity, octaves, offset, gain; + float H, lacunarity, octaves, offset, gain; const noiseGenerator_t* nGen; }; class YAFRAYPLUGIN_EXPORT ridgedMFractal_t : public musgrave_t { public: - ridgedMFractal_t(PFLOAT _H, PFLOAT _lacu, PFLOAT _octs, PFLOAT _offs, PFLOAT _gain, const noiseGenerator_t* _nGen) + ridgedMFractal_t(float _H, float _lacu, float _octs, float _offs, float _gain, const noiseGenerator_t* _nGen) : H(_H), lacunarity(_lacu), octaves(_octs), offset(_offs), gain(_gain), nGen(_nGen) {} virtual ~ridgedMFractal_t() {} - virtual PFLOAT operator() (const point3d_t &pt) const; + virtual float operator() (const point3d_t &pt) const; protected: - PFLOAT H, lacunarity, octaves, offset, gain; + float H, lacunarity, octaves, offset, gain; const noiseGenerator_t* nGen; }; // basic turbulence, half amplitude, double frequency defaults // returns value in range (0,1) -CFLOAT YAFRAYPLUGIN_EXPORT turbulence(const noiseGenerator_t* ngen, const point3d_t &pt, int oct, PFLOAT size, bool hard); +float YAFRAYPLUGIN_EXPORT turbulence(const noiseGenerator_t* ngen, const point3d_t &pt, int oct, float size, bool hard); // noise cell color (used with voronoi) colorA_t YAFRAYPLUGIN_EXPORT cellNoiseColor(const point3d_t &pt); -static inline PFLOAT getSignedNoise(const noiseGenerator_t* nGen, const point3d_t &pt) +static inline float getSignedNoise(const noiseGenerator_t* nGen, const point3d_t &pt) { - return (PFLOAT)2.0 * (*nGen)(pt) - (PFLOAT)1.0; + return (float)2.0 * (*nGen)(pt) - (float)1.0; } diff --git a/include/utilities/sample_utils.h b/include/utilities/sample_utils.h index 9f247f69..0df39d5c 100755 --- a/include/utilities/sample_utils.h +++ b/include/utilities/sample_utils.h @@ -27,8 +27,8 @@ vector3d_t inline SampleCosHemisphere(const vector3d_t &N,const vector3d_t &Ru,c if(s1>=1.0f) return N; //Fix for some white/black dots when s1>1.0. Also, this returns a fast trivial value when s1=1.0. else { - PFLOAT z1 = s1; - PFLOAT z2 = s2*M_2PI; + float z1 = s1; + float z2 = s2*M_2PI; return (Ru*fCos(z2) + Rv*fSin(z2))*fSqrt(1.0-z1) + N*fSqrt(z1); } } @@ -39,11 +39,11 @@ vector3d_t inline SampleSphere(float s1, float s2) { vector3d_t dir; dir.z = 1.0f - 2.0f*s1; - PFLOAT r = 1.0f - dir.z*dir.z; + float r = 1.0f - dir.z*dir.z; if(r>0.0f) { r = fSqrt(r); - PFLOAT a = M_2PI * s2; + float a = M_2PI * s2; dir.x = fCos(a) * r; dir.y = fSin(a) * r; } @@ -151,8 +151,8 @@ class pdf1D_t void inline minRot(const vector3d_t &D, const vector3d_t &U, const vector3d_t &D2, vector3d_t &U2, vector3d_t &V2) { - PFLOAT cosAlpha = D*D2; - PFLOAT sinAlpha = fSqrt(1 - cosAlpha*cosAlpha); + float cosAlpha = D*D2; + float sinAlpha = fSqrt(1 - cosAlpha*cosAlpha); vector3d_t v = D^D2; U2 = cosAlpha*U + (1.f-cosAlpha) * (v*U) + sinAlpha * (v^U); V2 = D2^U2; diff --git a/include/yafraycore/hashgrid.h b/include/yafraycore/hashgrid.h index 16763015..67bd2d15 100755 --- a/include/yafraycore/hashgrid.h +++ b/include/yafraycore/hashgrid.h @@ -21,7 +21,7 @@ class YAFRAYCORE_EXPORT hashGrid_t void pushPhoton(photon_t &p); - unsigned int gather(const point3d_t &P, foundPhoton_t *found, unsigned int K, PFLOAT radius); + unsigned int gather(const point3d_t &P, foundPhoton_t *found, unsigned int K, float radius); private: unsigned int Hash(const int ix, const int iy, const int iz) { diff --git a/include/yafraycore/kdtree.h b/include/yafraycore/kdtree.h index 783d080e..e62f4d38 100755 --- a/include/yafraycore/kdtree.h +++ b/include/yafraycore/kdtree.h @@ -45,9 +45,9 @@ class kdTreeNode else _emptyKd_leaves++; //stat Kd_leaves++; //stat } - void createInterior(int axis, PFLOAT d) + void createInterior(int axis, float d) { division = d; flags = (flags & ~3) | axis; Kd_inodes++; } - PFLOAT SplitPos() const { return division; } + float SplitPos() const { return division; } int SplitAxis() const { return flags & 3; } int nPrimitives() const { return flags >> 2; } bool IsLeaf() const { return (flags & 3) == 3; } @@ -56,7 +56,7 @@ class kdTreeNode union { - PFLOAT division; //!< interior: division plane position + float division; //!< interior: division plane position triangle_t** primitives; //!< leaf: list of primitives triangle_t* onePrimitive; //!< leaf: direct inxex of one primitive }; @@ -69,14 +69,14 @@ class kdTreeNode class boundEdge { public: boundEdge(){}; - boundEdge(PFLOAT position, int primitive, int bound_end): + boundEdge(float position, int primitive, int bound_end): pos(position), primNum(primitive), end(bound_end) {}; bool operator<(const boundEdge &e) const { if (pos == e.pos) return (int)end > (int)e.end; else return pos < e.pos; } - PFLOAT pos; + float pos; int primNum; int end; }; @@ -85,7 +85,7 @@ class boundEdge { struct KdStack { const kdTreeNode *node; //!< pointer to far child - PFLOAT t; //!< the entry/exit signed distance + float t; //!< the entry/exit signed distance point3d_t pb; //!< the point coordinates of entry/exit point int prev; //!< the pointer to the previous stack item }; @@ -93,7 +93,7 @@ struct KdStack struct KdToDo { const kdTreeNode *node; - PFLOAT tmin, tmax; + float tmin, tmax; }; class splitCost_t @@ -104,7 +104,7 @@ class splitCost_t int bestOffset; float bestCost; float oldCost; - PFLOAT t; + float t; int nBelow, nAbove, nEdge; }; @@ -117,7 +117,7 @@ class bin_t int n; int c_left, c_right; int c_bleft, c_both; - PFLOAT t; + float t; }; // ============================================================ @@ -129,11 +129,11 @@ class YAFRAYCORE_EXPORT triKdTree_t public: triKdTree_t(const triangle_t **v, int np, int depth=-1, int leafSize=2, float cost_ratio=0.35, float emptyBonus=0.33); - bool Intersect(const ray_t &ray, PFLOAT dist, triangle_t **tr, PFLOAT &Z, intersectData_t &data) const; -// bool IntersectDBG(const ray_t &ray, PFLOAT dist, triangle_t **tr, PFLOAT &Z) const; - bool IntersectS(const ray_t &ray, PFLOAT dist, triangle_t **tr, PFLOAT shadow_bias) const; - bool IntersectTS(renderState_t &state, const ray_t &ray, int maxDepth, PFLOAT dist, triangle_t **tr, color_t &filt, PFLOAT shadow_bias) const; -// bool IntersectO(const point3d_t &from, const vector3d_t &ray, PFLOAT dist, triangle_t **tr, PFLOAT &Z) const; + bool Intersect(const ray_t &ray, float dist, triangle_t **tr, float &Z, intersectData_t &data) const; +// bool IntersectDBG(const ray_t &ray, float dist, triangle_t **tr, float &Z) const; + bool IntersectS(const ray_t &ray, float dist, triangle_t **tr, float shadow_bias) const; + bool IntersectTS(renderState_t &state, const ray_t &ray, int maxDepth, float dist, triangle_t **tr, color_t &filt, float shadow_bias) const; +// bool IntersectO(const point3d_t &from, const vector3d_t &ray, float dist, triangle_t **tr, float &Z) const; bound_t getBound(){ return treeBound; } ~triKdTree_t(); private: diff --git a/include/yafraycore/meshtypes.h b/include/yafraycore/meshtypes.h index f96ec831..b17d0a05 100755 --- a/include/yafraycore/meshtypes.h +++ b/include/yafraycore/meshtypes.h @@ -11,8 +11,8 @@ __BEGIN_YAFRAY struct uv_t { - uv_t(GFLOAT _u, GFLOAT _v): u(_u), v(_v) {}; - GFLOAT u, v; + uv_t(float _u, float _v): u(_u), v(_v) {}; + float u, v; }; class triangle_t; diff --git a/include/yafraycore/photon.h b/include/yafraycore/photon.h index 1a50ae90..6e79b564 100755 --- a/include/yafraycore/photon.h +++ b/include/yafraycore/photon.h @@ -46,10 +46,10 @@ class dirConverter_t } protected: - PFLOAT cosphi[256]; - PFLOAT sinphi[256]; - PFLOAT costheta[255]; - PFLOAT sintheta[255]; + float cosphi[256]; + float sinphi[256]; + float costheta[255]; + float sintheta[255]; }; extern YAFRAYCORE_EXPORT dirConverter_t dirconverter; @@ -143,12 +143,12 @@ struct radData_t struct foundPhoton_t { foundPhoton_t(){}; - foundPhoton_t(const photon_t *p, PFLOAT d): photon(p), distSquare(d){} + foundPhoton_t(const photon_t *p, float d): photon(p), distSquare(d){} bool operator<(const foundPhoton_t &p2) const { return distSquare < p2.distSquare; } const photon_t *photon; - PFLOAT distSquare; + float distSquare; //temp!! - PFLOAT dis; + float dis; }; class YAFRAYCORE_EXPORT photonMap_t @@ -169,16 +169,16 @@ class YAFRAYCORE_EXPORT photonMap_t void updateTree(); void clear(){ photons.clear(); delete tree; tree = nullptr; updated=false; } bool ready() const { return updated; } - // void gather(const point3d_t &P, std::vector< foundPhoton_t > &found, unsigned int K, PFLOAT &sqRadius) const; - int gather(const point3d_t &P, foundPhoton_t *found, unsigned int K, PFLOAT &sqRadius) const; - const photon_t* findNearest(const point3d_t &P, const vector3d_t &n, PFLOAT dist) const; + // void gather(const point3d_t &P, std::vector< foundPhoton_t > &found, unsigned int K, float &sqRadius) const; + int gather(const point3d_t &P, foundPhoton_t *found, unsigned int K, float &sqRadius) const; + const photon_t* findNearest(const point3d_t &P, const vector3d_t &n, float dist) const; std::mutex mutx; protected: std::vector photons; int paths; //!< amount of photon paths that have been traced for generating the map bool updated; - PFLOAT searchRadius; + float searchRadius; kdtree::pointKdTree *tree; std::string name; int threadsPKDtree = 1; @@ -201,7 +201,7 @@ class YAFRAYCORE_EXPORT photonMap_t struct photonGather_t { photonGather_t(u_int32 mp, const point3d_t &p); - void operator()(const photon_t *photon, PFLOAT dist2, PFLOAT &maxDistSquared) const; + void operator()(const photon_t *photon, float dist2, float &maxDistSquared) const; const point3d_t &p; foundPhoton_t *photons; u_int32 nLookup; @@ -211,7 +211,7 @@ struct photonGather_t struct nearestPhoton_t { nearestPhoton_t(const point3d_t &pos, const vector3d_t &norm): p(pos), n(norm), nearest(nullptr) {} - void operator()(const photon_t *photon, PFLOAT dist2, PFLOAT &maxDistSquared) const + void operator()(const photon_t *photon, float dist2, float &maxDistSquared) const { if ( photon->direction() * n > 0.f) { nearest = photon; maxDistSquared = dist2; } } @@ -224,7 +224,7 @@ struct nearestPhoton_t struct eliminatePhoton_t { eliminatePhoton_t(const vector3d_t &norm): n(norm) {} - void operator()(const radData_t *rpoint, PFLOAT dist2, PFLOAT &maxDistSquared) const + void operator()(const radData_t *rpoint, float dist2, float &maxDistSquared) const { if ( rpoint->normal * n > 0.f) { rpoint->use = false; } } diff --git a/include/yafraycore/pkdtree.h b/include/yafraycore/pkdtree.h index c0a0e40e..fe3d32d4 100755 --- a/include/yafraycore/pkdtree.h +++ b/include/yafraycore/pkdtree.h @@ -27,12 +27,12 @@ struct kdNode flags = 3; data = d; } - void createInterior(int axis, PFLOAT d) + void createInterior(int axis, float d) { division = d; flags = (flags & ~3) | axis; } - PFLOAT SplitPos() const { return division; } + float SplitPos() const { return division; } int SplitAxis() const { return flags & 3; } int nPrimitives() const { return flags >> 2; } bool IsLeaf() const { return (flags & 3) == 3; } @@ -40,7 +40,7 @@ struct kdNode void setRightChild(u_int32 i) { flags = (flags&3) | (i << 2); } union { - PFLOAT division; + float division; const T *data; }; u_int32 flags; @@ -71,14 +71,14 @@ class pointKdTree pointKdTree() {}; pointKdTree(const std::vector &dat, const std::string &mapName, int numThreads=1); ~pointKdTree(){ if(nodes) y_free(nodes); } - template void lookup(const point3d_t &p, const LookupProc &proc, PFLOAT &maxDistSquared) const; + template void lookup(const point3d_t &p, const LookupProc &proc, float &maxDistSquared) const; double lookupStat()const{ return double(Y_PROCS)/double(Y_LOOKUPS); } //!< ratio of photons tested per lookup call protected: - template void recursiveLookup(const point3d_t &p, const LookupProc &proc, PFLOAT &maxDistSquared, int nodeNum) const; + template void recursiveLookup(const point3d_t &p, const LookupProc &proc, float &maxDistSquared, int nodeNum) const; struct KdStack { const kdNode *node; //!< pointer to far child - PFLOAT s; //!< the split val of parent node + float s; //!< the split val of parent node int axis; //!< the split axis of parent node }; void buildTree(u_int32 start, u_int32 end, bound_t &nodeBound, const T **prims); @@ -171,7 +171,7 @@ void pointKdTree::buildTreeWorker(u_int32 start, u_int32 end, bound_t &nodeBo std::nth_element(&prims[start], &prims[splitEl], &prims[end], CompareNode(splitAxis)); u_int32 curNode = localNextFreeNode; - PFLOAT splitPos = prims[splitEl]->pos[splitAxis]; + float splitPos = prims[splitEl]->pos[splitAxis]; localNodes[curNode].createInterior(splitAxis, splitPos); ++localNextFreeNode; bound_t boundL = nodeBound, boundR = nodeBound; @@ -242,7 +242,7 @@ void pointKdTree::buildTreeWorker(u_int32 start, u_int32 end, bound_t &nodeBo template template -void pointKdTree::lookup(const point3d_t &p, const LookupProc &proc, PFLOAT &maxDistSquared) const +void pointKdTree::lookup(const point3d_t &p, const LookupProc &proc, float &maxDistSquared) const { #if NON_REC_LOOKUP > 0 ++Y_LOOKUPS; @@ -257,7 +257,7 @@ void pointKdTree::lookup(const point3d_t &p, const LookupProc &proc, PFLOAT & while( !currNode->IsLeaf() ) { int axis = currNode->SplitAxis(); - PFLOAT splitVal = currNode->SplitPos(); + float splitVal = currNode->SplitPos(); if( p[axis] <= splitVal ) //need traverse left first { @@ -277,7 +277,7 @@ void pointKdTree::lookup(const point3d_t &p, const LookupProc &proc, PFLOAT & // Hand leaf-data kd-tree to processing function vector3d_t v = currNode->data->pos - p; - PFLOAT dist2 = v.lengthSqr(); + float dist2 = v.lengthSqr(); if (dist2 < maxDistSquared) { @@ -313,20 +313,20 @@ void pointKdTree::lookup(const point3d_t &p, const LookupProc &proc, PFLOAT & } template template -void pointKdTree::recursiveLookup(const point3d_t &p, const LookupProc &proc, PFLOAT &maxDistSquared, int nodeNum) const +void pointKdTree::recursiveLookup(const point3d_t &p, const LookupProc &proc, float &maxDistSquared, int nodeNum) const { const kdNode *currNode = &nodes[nodeNum]; if(currNode->IsLeaf()) { vector3d_t v = currNode->data->pos - p; - PFLOAT dist2 = v.lengthSqr(); + float dist2 = v.lengthSqr(); if (dist2 < maxDistSquared) proc(currNode->data, dist2, maxDistSquared); ++Y_PROCS; return; } int axis = currNode->SplitAxis(); - PFLOAT dist2 = p[axis] - currNode->SplitPos(); + float dist2 = p[axis] - currNode->SplitPos(); dist2 *= dist2; if(p[axis] <= currNode->SplitPos()) { diff --git a/include/yafraycore/ray_kdtree.h b/include/yafraycore/ray_kdtree.h index f3ed99ea..7b31dbcb 100755 --- a/include/yafraycore/ray_kdtree.h +++ b/include/yafraycore/ray_kdtree.h @@ -46,9 +46,9 @@ template class rkdTreeNode else _emptyKd_leaves++; //stat Kd_leaves++; //stat } - void createInterior(int axis, PFLOAT d) + void createInterior(int axis, float d) { division = d; flags = (flags & ~3) | axis; Kd_inodes++; } - PFLOAT SplitPos() const { return division; } + float SplitPos() const { return division; } int SplitAxis() const { return flags & 3; } int nPrimitives() const { return flags >> 2; } bool IsLeaf() const { return (flags & 3) == 3; } @@ -57,7 +57,7 @@ template class rkdTreeNode union { - PFLOAT division; //!< interior: division plane position + float division; //!< interior: division plane position T** primitives; //!< leaf: list of primitives T* onePrimitive; //!< leaf: direct inxex of one primitive }; @@ -68,7 +68,7 @@ template class rkdTreeNode template struct rKdStack { const rkdTreeNode *node; //!< pointer to far child - PFLOAT t; //!< the entry/exit signed distance + float t; //!< the entry/exit signed distance point3d_t pb; //!< the point coordinates of entry/exit point int prev; //!< the pointer to the previous stack item }; @@ -82,11 +82,11 @@ template class YAFRAYCORE_EXPORT kdTree_t public: kdTree_t(const T **v, int np, int depth=-1, int leafSize=2, float cost_ratio=0.35, float emptyBonus=0.33); - bool Intersect(const ray_t &ray, PFLOAT dist, T **tr, PFLOAT &Z, intersectData_t &data) const; -// bool IntersectDBG(const ray_t &ray, PFLOAT dist, triangle_t **tr, PFLOAT &Z) const; - bool IntersectS(const ray_t &ray, PFLOAT dist, T **tr, PFLOAT shadow_bias) const; - bool IntersectTS(renderState_t &state, const ray_t &ray, int maxDepth, PFLOAT dist, T **tr, color_t &filt, PFLOAT shadow_bias) const; -// bool IntersectO(const point3d_t &from, const vector3d_t &ray, PFLOAT dist, T **tr, PFLOAT &Z) const; + bool Intersect(const ray_t &ray, float dist, T **tr, float &Z, intersectData_t &data) const; +// bool IntersectDBG(const ray_t &ray, float dist, triangle_t **tr, float &Z) const; + bool IntersectS(const ray_t &ray, float dist, T **tr, float shadow_bias) const; + bool IntersectTS(renderState_t &state, const ray_t &ray, int maxDepth, float dist, T **tr, color_t &filt, float shadow_bias) const; +// bool IntersectO(const point3d_t &from, const vector3d_t &ray, float dist, T **tr, float &Z) const; bound_t getBound(){ return treeBound; } ~kdTree_t(); private: diff --git a/include/yafraycore/spectrum.h b/include/yafraycore/spectrum.h index 7fcb8490..f97df8b0 100755 --- a/include/yafraycore/spectrum.h +++ b/include/yafraycore/spectrum.h @@ -5,22 +5,22 @@ __BEGIN_YAFRAY -YAFRAYCORE_EXPORT void wl2rgb_fromCIE(CFLOAT wl, color_t &col); -//YAFRAYCORE_EXPORT void approxSpectrumRGB(CFLOAT wl, color_t &col); -//YAFRAYCORE_EXPORT void fakeSpectrum(CFLOAT p, color_t &col); -YAFRAYCORE_EXPORT void CauchyCoefficients(PFLOAT IOR, PFLOAT disp_pw, PFLOAT &CauchyA, PFLOAT &CauchyB); -YAFRAYCORE_EXPORT PFLOAT getIORcolor(PFLOAT w, PFLOAT CauchyA, PFLOAT CauchyB, color_t &col); -YAFRAYCORE_EXPORT color_t wl2XYZ(CFLOAT wl); +YAFRAYCORE_EXPORT void wl2rgb_fromCIE(float wl, color_t &col); +//YAFRAYCORE_EXPORT void approxSpectrumRGB(float wl, color_t &col); +//YAFRAYCORE_EXPORT void fakeSpectrum(float p, color_t &col); +YAFRAYCORE_EXPORT void CauchyCoefficients(float IOR, float disp_pw, float &CauchyA, float &CauchyB); +YAFRAYCORE_EXPORT float getIORcolor(float w, float CauchyA, float CauchyB, color_t &col); +YAFRAYCORE_EXPORT color_t wl2XYZ(float wl); -static inline PFLOAT getIOR(PFLOAT w, PFLOAT CauchyA, PFLOAT CauchyB) +static inline float getIOR(float w, float CauchyA, float CauchyB) { - PFLOAT wl = 300.0*w + 400.0; + float wl = 300.0*w + 400.0; return CauchyA + CauchyB/(wl*wl); } static inline void wl2rgb(float w, color_t &wl_col) { - PFLOAT wl = 300.0*w + 400.0; + float wl = 300.0*w + 400.0; wl2rgb_fromCIE(wl, wl_col); wl_col *= 2.214032659670777114f; } diff --git a/include/yafraycore/std_primitives.h b/include/yafraycore/std_primitives.h index e3ee216a..c3c2b06d 100755 --- a/include/yafraycore/std_primitives.h +++ b/include/yafraycore/std_primitives.h @@ -13,18 +13,18 @@ class object3d_t; class YAFRAYCORE_EXPORT sphere_t: public primitive_t { public: - sphere_t(point3d_t centr, PFLOAT rad, const material_t *m): center(centr), radius(rad), material(m) {} + sphere_t(point3d_t centr, float rad, const material_t *m): center(centr), radius(rad), material(m) {} virtual bound_t getBound() const; virtual bool intersectsBound(exBound_t &b) const { return true; }; //virtual bool clippingSupport() const { return false; } //virtual bool clipToBound(double bound[2][3], int axis, bound_t &clipped, void *d_old, void *d_new) const {return false;} - virtual bool intersect(const ray_t &ray, PFLOAT *t, intersectData_t &data) const; + virtual bool intersect(const ray_t &ray, float *t, intersectData_t &data) const; virtual void getSurface(surfacePoint_t &sp, const point3d_t &hit, intersectData_t &data) const; virtual const material_t* getMaterial() const { return material; } virtual const triangleObject_t* getMesh() const { return nullptr; } protected: point3d_t center; - PFLOAT radius; + float radius; const material_t *material; }; diff --git a/include/yafraycore/triangle.h b/include/yafraycore/triangle.h index 377548b2..5b58ac77 100755 --- a/include/yafraycore/triangle.h +++ b/include/yafraycore/triangle.h @@ -112,7 +112,7 @@ class YAFRAYCORE_EXPORT vTriangle_t: public primitive_t vTriangle_t(){}; vTriangle_t(int ia, int ib, int ic, meshObject_t* m): pa(ia), pb(ib), pc(ic), na(-1), nb(-1), nc(-1), mesh(m){ /*recNormal();*/ }; - virtual bool intersect(const ray_t &ray, PFLOAT *t, intersectData_t &data) const; + virtual bool intersect(const ray_t &ray, float *t, intersectData_t &data) const; virtual bound_t getBound() const; virtual bool intersectsBound(exBound_t &eb) const; virtual bool clippingSupport() const { return true; } @@ -125,7 +125,7 @@ class YAFRAYCORE_EXPORT vTriangle_t: public primitive_t void setMaterial(const material_t *m) { material = m; } void setNormals(int a, int b, int c){ na=a, nb=b, nc=c; } vector3d_t getNormal(){ return vector3d_t(normal); } - PFLOAT surfaceArea() const; + float surfaceArea() const; void sample(float s1, float s2, point3d_t &p, vector3d_t &n) const; void recNormal(); @@ -145,7 +145,7 @@ class YAFRAYCORE_EXPORT bsTriangle_t: public primitive_t bsTriangle_t(){}; bsTriangle_t(int ia, int ib, int ic, meshObject_t* m): pa(ia), pb(ib), pc(ic), na(-1), nb(-1), nc(-1), mesh(m){ }; - virtual bool intersect(const ray_t &ray, PFLOAT *t, intersectData_t &data) const; + virtual bool intersect(const ray_t &ray, float *t, intersectData_t &data) const; virtual bound_t getBound() const; //virtual bool intersectsBound(exBound_t &eb) const; // return: false:=doesn't overlap bound; true:=valid clip exists @@ -156,7 +156,7 @@ class YAFRAYCORE_EXPORT bsTriangle_t: public primitive_t // following are methods which are not part of primitive interface: void setMaterial(const material_t *m) { material = m; } void setNormals(int a, int b, int c){ na=a, nb=b, nc=c; } - //PFLOAT surfaceArea() const; + //float surfaceArea() const; //void sample(float s1, float s2, point3d_t &p, vector3d_t &n) const; protected: diff --git a/src/bindings/yafaray_v3_interface.i b/src/bindings/yafaray_v3_interface.i index 121a410c..0ae9567f 100755 --- a/src/bindings/yafaray_v3_interface.i +++ b/src/bindings/yafaray_v3_interface.i @@ -665,8 +665,8 @@ namespace yafaray void scale(float sx, float sy, float sz); int invalid() const { return _invalid; } // ignored by swig - //const PFLOAT * operator [] (int i) const { return matrix[i]; } - //PFLOAT * operator [] (int i) { return matrix[i]; } + //const float * operator [] (int i) const { return matrix[i]; } + //float * operator [] (int i) { return matrix[i]; } void setVal(int row, int col, float val) { matrix[row][col] = val; diff --git a/src/cameras/angularCamera.cc b/src/cameras/angularCamera.cc index e88099b6..eb845097 100755 --- a/src/cameras/angularCamera.cc +++ b/src/cameras/angularCamera.cc @@ -26,7 +26,7 @@ __BEGIN_YAFRAY angularCam_t::angularCam_t(const point3d_t &pos, const point3d_t &look, const point3d_t &up, - int _resx, int _resy, PFLOAT asp, PFLOAT angle, bool circ, + int _resx, int _resy, float asp, float angle, bool circ, float const near_clip_distance, float const far_clip_distance) : camera_t(pos, look, up, _resx, _resy, asp, near_clip_distance, far_clip_distance), hor_phi(angle*M_PI/180.f), circular(circ) { @@ -47,20 +47,20 @@ void angularCam_t::setAxis(const vector3d_t &vx, const vector3d_t &vy, const vec vto = camZ; } -ray_t angularCam_t::shootRay(PFLOAT px, PFLOAT py, float lu, float lv, PFLOAT &wt) const +ray_t angularCam_t::shootRay(float px, float py, float lu, float lv, float &wt) const { ray_t ray; wt = 1; // for now always 1, or 0 when circular and outside angle ray.from = position; - PFLOAT u = 1.f - 2.f * (px/(PFLOAT)resx); - PFLOAT v = 2.f * (py/(PFLOAT)resy) - 1.f; + float u = 1.f - 2.f * (px/(float)resx); + float v = 2.f * (py/(float)resy) - 1.f; v *= aspect_ratio; - PFLOAT radius = fSqrt(u*u + v*v); + float radius = fSqrt(u*u + v*v); if (circular && radius>max_r) { wt=0; return ray; } - PFLOAT theta=0; + float theta=0; if (!((u==0) && (v==0))) theta = atan2(v,u); - PFLOAT phi = radius * hor_phi; - //PFLOAT sp = sin(phi); + float phi = radius * hor_phi; + //float sp = sin(phi); ray.dir = fSin(phi)*(fCos(theta)*vright + fSin(theta)*vup ) + fCos(phi)*vto; ray.tmin = ray_plane_intersection(ray, near_plane); @@ -110,9 +110,9 @@ point3d_t angularCam_t::screenproject(const point3d_t &p) const dir.normalize(); // project p to pixel plane: - PFLOAT dx = camX * dir; - PFLOAT dy = camY * dir; - PFLOAT dz = camZ * dir; + float dx = camX * dir; + float dy = camY * dir; + float dz = camZ * dir; s.x = -dx / (4.0 * M_PI * dz); s.y = -dy / (4.0 * M_PI * dz); diff --git a/src/cameras/architectCamera.cc b/src/cameras/architectCamera.cc index a7c725ba..9f91efbb 100755 --- a/src/cameras/architectCamera.cc +++ b/src/cameras/architectCamera.cc @@ -26,8 +26,8 @@ __BEGIN_YAFRAY architectCam_t::architectCam_t(const point3d_t &pos, const point3d_t &look, const point3d_t &up, - int _resx, int _resy, PFLOAT aspect, - PFLOAT df, PFLOAT ap, PFLOAT dofd, bokehType bt, bkhBiasType bbt, PFLOAT bro, float const near_clip_distance, float const far_clip_distance) + int _resx, int _resy, float aspect, + float df, float ap, float dofd, bokehType bt, bkhBiasType bbt, float bro, float const near_clip_distance, float const far_clip_distance) :perspectiveCam_t(pos, look, up, _resx, _resy, aspect, df, ap, dofd, bt, bbt, bro, near_clip_distance, far_clip_distance) { // Initialize camera specific plane coordinates @@ -35,7 +35,7 @@ architectCam_t::architectCam_t(const point3d_t &pos, const point3d_t &look, cons int ns = (int)bkhtype; if ((ns>=3) && (ns<=6)) { - PFLOAT w=degToRad(bro), wi=(M_2PI)/(PFLOAT)ns; + float w=degToRad(bro), wi=(M_2PI)/(float)ns; ns = (ns+2)*2; LS.resize(ns); for (int i=0;i=3) && (ns<=6)) { - PFLOAT w=degToRad(bro), wi=(M_2PI)/(PFLOAT)ns; + float w=degToRad(bro), wi=(M_2PI)/(float)ns; ns = (ns+2)*2; LS.resize(ns); for (int i=0;i 0.5) return false; - u = (u + 0.5) * (PFLOAT) resx; + u = (u + 0.5) * (float) resx; v = dy * focal_distance / (dz * aspect_ratio); if(v < -0.5 || v > 0.5) return false; - v = (v + 0.5) * (PFLOAT) resy; + v = (v + 0.5) * (float) resy; // pdf = 1/A_pix * r^2 / cos(forward, dir), where r^2 is also 1/cos(vto, dir)^2 - PFLOAT cos_wo = dz; //camZ * wo.dir; + float cos_wo = dz; //camZ * wo.dir; pdf = 8.f * M_PI / (A_pix * cos_wo * cos_wo * cos_wo ); return true; } diff --git a/src/integrators/bidirpath.cc b/src/integrators/bidirpath.cc index c151fbb8..7a3b2d50 100755 --- a/src/integrators/bidirpath.cc +++ b/src/integrators/bidirpath.cc @@ -105,7 +105,7 @@ class pathData_t // additional information for current path connection: vector3d_t w_l_e; //!< direction of edge from light to eye vertex, i.e. y_s to z_t color_t f_y, f_z; //!< f for light and eye vertex that are connected - PFLOAT u, v; //!< current position on image plane + float u, v; //!< current position on image plane float d_yz; //!< distance between y_s to z_t const light_t *light; //!< the light source to which the current path is connected //float pdf_Ad_0; //!< pdf for direct lighting strategy @@ -134,8 +134,8 @@ class YAFRAYPLUGIN_EXPORT biDirIntegrator_t: public tiledIntegrator_t bool connectLPath(renderState_t &state, int t, pathData_t &pd, ray_t &lRay, color_t &lcol) const; bool connectPathE(renderState_t &state, int s, pathData_t &pd) const; //color_t estimateOneDirect(renderState_t &state, const surfacePoint_t &sp, vector3d_t wo, pathCon_t &pc)const; - CFLOAT pathWeight(renderState_t &state, int s, int t, pathData_t &pd) const; - CFLOAT pathWeight_0t(renderState_t &state, int t, pathData_t &pd) const; + float pathWeight(renderState_t &state, int s, int t, pathData_t &pd) const; + float pathWeight_0t(renderState_t &state, int t, pathData_t &pd) const; background_t *background; const camera_t *cam; @@ -151,7 +151,7 @@ class YAFRAYPLUGIN_EXPORT biDirIntegrator_t: public tiledIntegrator_t mutable std::vector threadData; pdf1D_t *lightPowerD; float fNumLights; - std::map invLightPowerD; + std::map invLightPowerD; imageFilm_t *lightImage; bool useAmbientOcclusion; //! Use ambient occlusion @@ -217,7 +217,7 @@ bool biDirIntegrator_t::preprocess() // test... /* - PFLOAT wt, u, v; + float wt, u, v; float pdf; ray_t wo = cam->shootRay(10.25, 10.25, 0, 0, wt); bool proj = cam->project(wo, 0, 0, u, v, pdf); @@ -295,7 +295,7 @@ colorA_t biDirIntegrator_t::integrate(renderState_t &state, diffRay_t &ray, colo ve.sp.P = ray.from; ve.qi_wo = ve.qi_wi = 1.f; // definitely no russian roulette here... // temporary! - PFLOAT cu, cv; + float cu, cv; float camPdf = 0.0; cam->project(ray, 0, 0, cu, cv, camPdf); if(camPdf == 0.f) camPdf = 1.f; //FIXME: this is a horrible hack to fix the -nan problems when using bidirectional integrator with Architecture, Angular or Orto cameras. The fundamental problem is that the code for those 3 cameras LACK the member function project() and therefore leave the camPdf=0.f causing -nan results. So, for now I'm forcing camPdf = 1.f if such 0.f result comes from the non-existing member function. This is BAD, but at least will allow people to work with the different cameras in bidirectional, and bidirectional integrator still needs a LOT of work to make it a decent integrator anyway. @@ -357,12 +357,12 @@ colorA_t biDirIntegrator_t::integrate(renderState_t &state, diffRay_t &ray, colo clear_path(pathData.path, s, 1); if(!connectPathE(state, s, pathData)) continue; check_path(pathData.path, s, 1); - CFLOAT wt = pathWeight(state, s, 1, pathData); + float wt = pathWeight(state, s, 1, pathData); if(wt > 0.f) { color_t li_col = evalPathE(state, s, pathData); if(li_col.isBlack()) continue; - PFLOAT ix, idx, iy, idy; + float ix, idx, iy, idy; idx = std::modf(pathData.u, &ix); idy = std::modf(pathData.v, &iy); lightImage->addDensitySample(li_col, ix, iy, idx, idy); @@ -370,7 +370,7 @@ colorA_t biDirIntegrator_t::integrate(renderState_t &state, diffRay_t &ray, colo } #endif - CFLOAT wt; + float wt; for(int t=2; t<=nEye; ++t) { //directly hit a light? @@ -574,9 +574,9 @@ inline bool biDirIntegrator_t::connectPaths(renderState_t &state, int s, int t, pathEvalVert_t &x_e = pd.path[s]; // precompute stuff in pc that is specific to the current connection of sub-paths vector3d_t vec = z.sp.P - y.sp.P; - PFLOAT dist2 = vec.normLenSqr(); - PFLOAT cos_y = std::fabs(y.sp.N * vec); - PFLOAT cos_z = std::fabs(z.sp.N * vec); + float dist2 = vec.normLenSqr(); + float cos_y = std::fabs(y.sp.N * vec); + float cos_z = std::fabs(z.sp.N * vec); state.userdata = y.userdata; x_l.pdf_f = y.sp.material->pdf(state, y.sp, y.wi, vec, BSDF_ALL); // light vert to eye vert @@ -670,7 +670,7 @@ inline bool biDirIntegrator_t::connectLPath(renderState_t &state, int t, pathDat //fill in pc...connecting to light vertex: //pathEvalVert_t &x_l = pd.path[0]; pathEvalVert_t &x_e = pd.path[1]; - PFLOAT cos_z = std::fabs(z.sp.N * vec); + float cos_z = std::fabs(z.sp.N * vec); x_e.G = std::fabs(cos_wo * cos_z) / (lRay.tmax*lRay.tmax); // or use Ng?? pd.w_l_e = vec; pd.d_yz = lRay.tmax; @@ -715,8 +715,8 @@ inline bool biDirIntegrator_t::connectPathE(renderState_t &state, int s, pathDat pathEvalVert_t &x_e = pd.path[s]; vector3d_t vec = z.sp.P - y.sp.P; - PFLOAT dist2 = vec.normLenSqr(); - PFLOAT cos_y = std::fabs(y.sp.N * vec); + float dist2 = vec.normLenSqr(); + float cos_y = std::fabs(y.sp.N * vec); ray_t wo(z.sp.P, -vec); if(! cam->project(wo, 0, 0, pd.u, pd.v, x_e.pdf_b) ) return false; @@ -762,7 +762,7 @@ inline bool biDirIntegrator_t::connectPathE(renderState_t &state, int s, pathDat ============================================================ */ // compute path densities and weight path -CFLOAT biDirIntegrator_t::pathWeight(renderState_t &state, int s, int t, pathData_t &pd) const +float biDirIntegrator_t::pathWeight(renderState_t &state, int s, int t, pathData_t &pd) const { const std::vector &path = pd.path; float pr[2*MAX_PATH_LENGTH+1], p[2*MAX_PATH_LENGTH+1]; @@ -812,7 +812,7 @@ CFLOAT biDirIntegrator_t::pathWeight(renderState_t &state, int s, int t, pathDat } // weight paths that directly hit a light, i.e. s=0; t is at least 2 // -CFLOAT biDirIntegrator_t::pathWeight_0t(renderState_t &state, int t, pathData_t &pd) const +float biDirIntegrator_t::pathWeight_0t(renderState_t &state, int t, pathData_t &pd) const { const std::vector &path = pd.path; const pathVertex_t &vl = pd.eyePath[t-1]; diff --git a/src/integrators/pathtracer.cc b/src/integrators/pathtracer.cc index 06b33c99..783e1ccc 100755 --- a/src/integrators/pathtracer.cc +++ b/src/integrators/pathtracer.cc @@ -138,7 +138,7 @@ colorA_t pathIntegrator_t::integrate(renderState_t &state, diffRay_t &ray, color static int calls=0; ++calls; color_t col(0.0); - CFLOAT alpha; + float alpha; surfacePoint_t sp; void *o_udat = state.userdata; float W = 0.f; @@ -331,7 +331,7 @@ colorA_t pathIntegrator_t::integrate(renderState_t &state, diffRay_t &ray, color if(transpRefractedBackground) { - CFLOAT m_alpha = material->getAlpha(state, sp, wo); + float m_alpha = material->getAlpha(state, sp, wo); alpha = m_alpha + (1.f-m_alpha)*alpha; } else alpha = 1.0; diff --git a/src/integrators/photonintegr.cc b/src/integrators/photonintegr.cc index 8e579846..2bb97ba5 100755 --- a/src/integrators/photonintegr.cc +++ b/src/integrators/photonintegr.cc @@ -1035,7 +1035,7 @@ bool photonIntegrator_t::preprocess() { cleaned.push_back(pgdat.rad_points[i]); eliminatePhoton_t elimProc(pgdat.rad_points[i].normal); - PFLOAT maxrad = 0.01f*dsRadius; // 10% of diffuse search radius + float maxrad = 0.01f*dsRadius; // 10% of diffuse search radius rTree->lookup(pgdat.rad_points[i].pos, elimProc, maxrad); } } @@ -1128,7 +1128,7 @@ color_t photonIntegrator_t::finalGathering(renderState_t &state, const surfacePo for(int i=0; igetAlpha(state, sp, wo); + float m_alpha = material->getAlpha(state, sp, wo); alpha = m_alpha + (1.f-m_alpha)*alpha; } else alpha = 1.0; diff --git a/src/integrators/sppm.cc b/src/integrators/sppm.cc index 2d4d3885..a94a2b59 100755 --- a/src/integrators/sppm.cc +++ b/src/integrators/sppm.cc @@ -165,9 +165,9 @@ bool SPPM::renderTile(int numView, renderArea_t &a, int n_samples, int offset, b x=camera->resX(); diffRay_t c_ray; ray_t d_ray; - PFLOAT dx=0.5, dy=0.5, d1=1.0/(PFLOAT)n_samples; + float dx=0.5, dy=0.5, d1=1.0/(float)n_samples; float lens_u=0.5f, lens_v=0.5f; - PFLOAT wt, wt_dummy; + float wt, wt_dummy; random_t prng(offset*(x*a.Y+a.X)+123); renderState_t rstate(&prng); rstate.threadID = threadID; @@ -204,7 +204,7 @@ bool SPPM::renderTile(int numView, renderArea_t &a, int n_samples, int offset, b rstate.setDefaults(); rstate.pixelSample = pass_offs+sample; - rstate.time = addMod1((PFLOAT)sample*d1, toff); //(0.5+(PFLOAT)sample)*d1; + rstate.time = addMod1((float)sample*d1, toff); //(0.5+(float)sample)*d1; // the (1/n, Larcher&Pillichshammer-Seq.) only gives good coverage when total sample count is known // hence we use scrambled (Sobol, van-der-Corput) for multipass AA @@ -841,7 +841,7 @@ GatherInfo SPPM::traceGatherRay(yafaray::renderState_t &state, yafaray::diffRay_ color_t col(0.0); GatherInfo gInfo; - CFLOAT alpha; + float alpha; surfacePoint_t sp; void *o_udat = state.userdata; @@ -887,8 +887,8 @@ GatherInfo SPPM::traceGatherRay(yafaray::renderState_t &state, yafaray::diffRay_ //if PM_IRE is on. we should estimate the initial radius using the photonMaps. (PM_IRE is only for the first pass, so not consume much time) if(PM_IRE && !hp.radiusSetted) // "waste" two gather here as it has two maps now. This make the logic simple. { - PFLOAT radius_1 = dsRadius * dsRadius; - PFLOAT radius_2 = radius_1; + float radius_1 = dsRadius * dsRadius; + float radius_2 = radius_1; int nGathered_1 = 0, nGathered_2 = 0; if(session.diffuseMap->nPhotons() > 0) @@ -907,7 +907,7 @@ GatherInfo SPPM::traceGatherRay(yafaray::renderState_t &state, yafaray::diffRay_ } int nGathered=0; - PFLOAT radius2 = hp.radius2; + float radius2 = hp.radius2; if(bHashgrid) nGathered = photonGrid.gather(sp.P, gathered, nMaxGather, radius2); // disable now @@ -1281,7 +1281,7 @@ GatherInfo SPPM::traceGatherRay(yafaray::renderState_t &state, yafaray::diffRay_ if(transpRefractedBackground) { - CFLOAT m_alpha = material->getAlpha(state, sp, wo); + float m_alpha = material->getAlpha(state, sp, wo); alpha = m_alpha + (1.f-m_alpha)*alpha; } else alpha = 1.0; diff --git a/src/lights/arealight.cc b/src/lights/arealight.cc index 51016273..5c2a3cff 100755 --- a/src/lights/arealight.cc +++ b/src/lights/arealight.cc @@ -31,7 +31,7 @@ __BEGIN_YAFRAY //int hit_t1=0, hit_t2=0; areaLight_t::areaLight_t(const point3d_t &c, const vector3d_t &v1, const vector3d_t &v2, - const color_t &col,CFLOAT inte, int nsam, bool bLightEnabled, bool bCastShadows): + const color_t &col,float inte, int nsam, bool bLightEnabled, bool bCastShadows): corner(c), toX(v1), toY(v2), samples(nsam), intensity(inte) { lLightEnabled = bLightEnabled; @@ -76,11 +76,11 @@ bool areaLight_t::illumSample(const surfacePoint_t &sp, lSample_t &s, ray_t &wi) point3d_t p = corner + s.s1*toX + s.s2*toY; vector3d_t ldir = p - sp.P; //normalize vec and compute inverse square distance - PFLOAT dist_sqr = ldir.lengthSqr(); - PFLOAT dist = fSqrt(dist_sqr); + float dist_sqr = ldir.lengthSqr(); + float dist = fSqrt(dist_sqr); if(dist <= 0.0) return false; ldir *= 1.f/dist; - PFLOAT cos_angle = ldir*fnormal; + float cos_angle = ldir*fnormal; //no light if point is behind area light (single sided!) if(cos_angle <= 0) return false; @@ -119,10 +119,10 @@ color_t areaLight_t::emitSample(vector3d_t &wo, lSample_t &s) const return color; // still not 100% sure this is correct without cosine... } -inline bool triIntersect(const point3d_t &a, const point3d_t &b, const point3d_t &c, const ray_t &ray, PFLOAT &t) +inline bool triIntersect(const point3d_t &a, const point3d_t &b, const point3d_t &c, const ray_t &ray, float &t) { vector3d_t edge1, edge2, tvec, pvec, qvec; - PFLOAT det, inv_det, u, v; + float det, inv_det, u, v; edge1 = b - a; edge2 = c - a; pvec = ray.dir ^ edge2; @@ -140,9 +140,9 @@ inline bool triIntersect(const point3d_t &a, const point3d_t &b, const point3d_t return true; } -bool areaLight_t::intersect(const ray_t &ray, PFLOAT &t, color_t &col, float &ipdf) const +bool areaLight_t::intersect(const ray_t &ray, float &t, color_t &col, float &ipdf) const { - PFLOAT cos_angle = ray.dir*fnormal; + float cos_angle = ray.dir*fnormal; //no light if point is behind area light (single sided!) if(cos_angle <= 0) return false; @@ -161,7 +161,7 @@ bool areaLight_t::intersect(const ray_t &ray, PFLOAT &t, color_t &col, float &ip float areaLight_t::illumPdf(const surfacePoint_t &sp, const surfacePoint_t &sp_light) const { vector3d_t wi = sp_light.P - sp.P; - PFLOAT r2 = wi.normLenSqr(); + float r2 = wi.normLenSqr(); float cos_n = wi*fnormal; return cos_n > 0 ? r2 * M_PI / (area * cos_n) : 0.f; } @@ -179,7 +179,7 @@ light_t* areaLight_t::factory(paraMap_t ¶ms,renderEnvironment_t &render) point3d_t p1(0.0); point3d_t p2(0.0); color_t color(1.0); - CFLOAT power = 1.0; + float power = 1.0; int samples = 4; int object = 0; bool lightEnabled = true; diff --git a/src/lights/bgportallight.cc b/src/lights/bgportallight.cc index 8d2accaa..fc1a9a25 100755 --- a/src/lights/bgportallight.cc +++ b/src/lights/bgportallight.cc @@ -123,7 +123,7 @@ color_t bgPortalLight_t::totalEnergy() const col = bg->eval(wo); for(int j=0; jgetNormal(); //not 100% sure about sign yet... + float cos_n = -wo.dir * tris[j]->getNormal(); //not 100% sure about sign yet... if(cos_n > 0) energy += col*cos_n*tris[j]->surfaceArea(); } } @@ -141,11 +141,11 @@ bool bgPortalLight_t::illumSample(const surfacePoint_t &sp, lSample_t &s, ray_t vector3d_t ldir = p - sp.P; //normalize vec and compute inverse square distance - PFLOAT dist_sqr = ldir.lengthSqr(); - PFLOAT dist = fSqrt(dist_sqr); + float dist_sqr = ldir.lengthSqr(); + float dist = fSqrt(dist_sqr); if(dist <= 0.0) return false; ldir *= 1.f/dist; - PFLOAT cos_angle = -(ldir*n); + float cos_angle = -(ldir*n); //no light if point is behind area light (single sided!) if(cos_angle <= 0) return false; @@ -193,21 +193,21 @@ color_t bgPortalLight_t::emitSample(vector3d_t &wo, lSample_t &s) const return bg->eval(r2); } -bool bgPortalLight_t::intersect(const ray_t &ray, PFLOAT &t, color_t &col, float &ipdf) const +bool bgPortalLight_t::intersect(const ray_t &ray, float &t, color_t &col, float &ipdf) const { if(!tree) return false; - PFLOAT dis; + float dis; intersectData_t bary; triangle_t *hitt=0; - if(ray.tmax<0) dis=std::numeric_limits::infinity(); + if(ray.tmax<0) dis=std::numeric_limits::infinity(); else dis=ray.tmax; // intersect with tree: if( ! tree->Intersect(ray, dis, &hitt, t, bary) ){ return false; } vector3d_t n = hitt->getNormal(); - PFLOAT cos_angle = ray.dir*(-n); + float cos_angle = ray.dir*(-n); if(cos_angle <= 0) return false; - PFLOAT idist_sqr = 1.f / (t*t); + float idist_sqr = 1.f / (t*t); ipdf = idist_sqr * area * cos_angle * (1.f/M_PI); col = bg->eval(ray) * power; @@ -217,7 +217,7 @@ bool bgPortalLight_t::intersect(const ray_t &ray, PFLOAT &t, color_t &col, float float bgPortalLight_t::illumPdf(const surfacePoint_t &sp, const surfacePoint_t &sp_light) const { vector3d_t wo = sp.P - sp_light.P; - PFLOAT r2 = wo.normLenSqr(); + float r2 = wo.normLenSqr(); float cos_n = wo * sp_light.Ng; return cos_n > 0 ? ( r2 * M_PI / (area * cos_n) ) : 0.f; } diff --git a/src/lights/directional.cc b/src/lights/directional.cc index 55595489..76beb615 100755 --- a/src/lights/directional.cc +++ b/src/lights/directional.cc @@ -28,7 +28,7 @@ __BEGIN_YAFRAY class directionalLight_t : public light_t { public: - directionalLight_t(const point3d_t &pos, vector3d_t dir, const color_t &col, CFLOAT inte, bool inf, float rad, bool bLightEnabled=true, bool bCastShadows=true); + directionalLight_t(const point3d_t &pos, vector3d_t dir, const color_t &col, float inte, bool inf, float rad, bool bLightEnabled=true, bool bCastShadows=true); virtual void init(scene_t &scene); virtual color_t totalEnergy() const { return color * radius*radius * M_PI; } virtual color_t emitPhoton(float s1, float s2, float s3, float s4, ray_t &ray, float &ipdf) const; @@ -42,14 +42,14 @@ class directionalLight_t : public light_t color_t color; vector3d_t direction, du, dv; float intensity; - PFLOAT radius; + float radius; float areaPdf; - PFLOAT worldRadius; + float worldRadius; bool infinite; int majorAxis; //!< the largest component of direction }; -directionalLight_t::directionalLight_t(const point3d_t &pos, vector3d_t dir, const color_t &col, CFLOAT inte, bool inf, float rad, bool bLightEnabled, bool bCastShadows): +directionalLight_t::directionalLight_t(const point3d_t &pos, vector3d_t dir, const color_t &col, float inte, bool inf, float rad, bool bLightEnabled, bool bCastShadows): light_t(LIGHT_DIRACDIR), position(pos), direction(dir), radius(rad), infinite(inf) { lLightEnabled = bLightEnabled; @@ -86,7 +86,7 @@ bool directionalLight_t::illuminate(const surfacePoint_t &sp, color_t &col, ray_ if(!infinite) { vector3d_t vec = position - sp.P; - PFLOAT dist = (direction ^ vec).length(); + float dist = (direction ^ vec).length(); if(dist>radius) return false; wi.tmax = (vec*direction); if(wi.tmax <= 0.0) return false; @@ -113,7 +113,7 @@ color_t directionalLight_t::emitPhoton(float s1, float s2, float s3, float s4, r { //todo ray.dir = -direction; - PFLOAT u, v; + float u, v; ShirleyDisk(s1, s2, u, v); ray.from = position + radius * (u*du + v*dv); if(infinite) ray.from += direction*worldRadius; @@ -127,7 +127,7 @@ color_t directionalLight_t::emitSample(vector3d_t &wo, lSample_t &s) const wo = -direction; s.sp->N = wo; s.flags = flags; - PFLOAT u, v; + float u, v; ShirleyDisk(s.s1, s.s2, u, v); s.sp->P = position + radius * (u*du + v*dv); if(infinite) s.sp->P += direction*worldRadius; @@ -141,7 +141,7 @@ light_t *directionalLight_t::factory(paraMap_t ¶ms,renderEnvironment_t &rend point3d_t from(0.0); point3d_t dir(0.0, 0.0, 1.0); color_t color(1.0); - CFLOAT power = 1.0; + float power = 1.0; float rad = 1.0; bool inf = true; bool lightEnabled = true; diff --git a/src/lights/iesLight.cc b/src/lights/iesLight.cc index 71e36ad9..41db165e 100755 --- a/src/lights/iesLight.cc +++ b/src/lights/iesLight.cc @@ -32,7 +32,7 @@ class iesLight_t : public light_t { public: - iesLight_t(const point3d_t &from, const point3d_t &to, const color_t &col, CFLOAT power, const std::string iesFile, int smpls, bool sSha, float ang, bool bLightEnabled=true, bool bCastShadows=true); + iesLight_t(const point3d_t &from, const point3d_t &to, const color_t &col, float power, const std::string iesFile, int smpls, bool sSha, float ang, bool bLightEnabled=true, bool bCastShadows=true); virtual color_t totalEnergy() const { return color * totEnergy;}; virtual int nSamples() const { return samples; }; @@ -42,7 +42,7 @@ class iesLight_t : public light_t virtual bool illumSample(const surfacePoint_t &sp, lSample_t &s, ray_t &wi) const; virtual bool canIntersect() const; - virtual bool intersect(const ray_t &ray, PFLOAT &t, color_t &col, float &ipdf) const; + virtual bool intersect(const ray_t &ray, float &t, color_t &col, float &ipdf) const; virtual color_t emitPhoton(float s1, float s2, float s3, float s4, ray_t &ray, float &ipdf) const; @@ -62,7 +62,7 @@ class iesLight_t : public light_t vector3d_t dir; //!< orientation of the spot cone vector3d_t ndir; //!< negative orientation (-dir) vector3d_t du, dv; //!< form a coordinate system with dir, to sample directions - PFLOAT cosEnd; //::infinity(); + if(ray.tmax<0) dis=std::numeric_limits::infinity(); else dis=ray.tmax; // intersect with tree: if( ! tree->Intersect(ray, dis, &hitt, t, bary) ){ return false; } vector3d_t n = hitt->getNormal(); - PFLOAT cos_angle = ray.dir*(-n); + float cos_angle = ray.dir*(-n); if(cos_angle <= 0) { if(doubleSided) cos_angle = std::fabs(cos_angle); else return false; } - PFLOAT idist_sqr = 1.f / (t*t); + float idist_sqr = 1.f / (t*t); ipdf = idist_sqr * area * cos_angle * (1.f/M_PI); col = color; @@ -213,7 +213,7 @@ bool meshLight_t::intersect(const ray_t &ray, PFLOAT &t, color_t &col, float &ip float meshLight_t::illumPdf(const surfacePoint_t &sp, const surfacePoint_t &sp_light) const { vector3d_t wo = sp.P - sp_light.P; - PFLOAT r2 = wo.normLenSqr(); + float r2 = wo.normLenSqr(); float cos_n = wo * sp_light.Ng; return cos_n > 0 ? r2 * M_PI / (area * cos_n) : (doubleSided ? r2 * M_PI / (area * -cos_n) : 0.f); } @@ -250,7 +250,7 @@ light_t* meshLight_t::factory(paraMap_t ¶ms,renderEnvironment_t &render) params.getParam("shoot_diffuse", shootD); params.getParam("photon_only",pOnly); - meshLight_t *light = new meshLight_t(object, color*(CFLOAT)power*M_PI, samples, doubleS, lightEnabled, castShadows); + meshLight_t *light = new meshLight_t(object, color*(float)power*M_PI, samples, doubleS, lightEnabled, castShadows); light->lShootCaustic = shootC; light->lShootDiffuse = shootD; diff --git a/src/lights/pointlight.cc b/src/lights/pointlight.cc index 06191cf4..0bb53ffa 100755 --- a/src/lights/pointlight.cc +++ b/src/lights/pointlight.cc @@ -28,7 +28,7 @@ __BEGIN_YAFRAY class pointLight_t : public light_t { public: - pointLight_t(const point3d_t &pos, const color_t &col, CFLOAT inte, bool bLightEnabled=true, bool bCastShadows=true); + pointLight_t(const point3d_t &pos, const color_t &col, float inte, bool bLightEnabled=true, bool bCastShadows=true); virtual color_t totalEnergy() const { return color * 4.0f * M_PI; } virtual color_t emitPhoton(float s1, float s2, float s3, float s4, ray_t &ray, float &ipdf) const; virtual color_t emitSample(vector3d_t &wo, lSample_t &s) const; @@ -43,7 +43,7 @@ class pointLight_t : public light_t float intensity; }; -pointLight_t::pointLight_t(const point3d_t &pos, const color_t &col, CFLOAT inte, bool bLightEnabled, bool bCastShadows): +pointLight_t::pointLight_t(const point3d_t &pos, const color_t &col, float inte, bool bLightEnabled, bool bCastShadows): light_t(LIGHT_SINGULAR), position(pos) { lLightEnabled = bLightEnabled; @@ -57,9 +57,9 @@ bool pointLight_t::illuminate(const surfacePoint_t &sp, color_t &col, ray_t &wi) if( photonOnly() ) return false; vector3d_t ldir(position - sp.P); - PFLOAT dist_sqr = ldir.x*ldir.x + ldir.y*ldir.y + ldir.z*ldir.z; - PFLOAT dist = fSqrt(dist_sqr); - PFLOAT idist_sqr = 0.0; + float dist_sqr = ldir.x*ldir.x + ldir.y*ldir.y + ldir.z*ldir.z; + float dist = fSqrt(dist_sqr); + float idist_sqr = 0.0; if(dist == 0.0) return false; idist_sqr = 1.f/(dist_sqr); @@ -68,7 +68,7 @@ bool pointLight_t::illuminate(const surfacePoint_t &sp, color_t &col, ray_t &wi) wi.tmax = dist; wi.dir = ldir; - col = color * (CFLOAT)idist_sqr; + col = color * (float)idist_sqr; return true; } @@ -78,8 +78,8 @@ bool pointLight_t::illumSample(const surfacePoint_t &sp, lSample_t &s, ray_t &wi // bleh... vector3d_t ldir(position - sp.P); - PFLOAT dist_sqr = ldir.x*ldir.x + ldir.y*ldir.y + ldir.z*ldir.z; - PFLOAT dist = fSqrt(dist_sqr); + float dist_sqr = ldir.x*ldir.x + ldir.y*ldir.y + ldir.z*ldir.z; + float dist = fSqrt(dist_sqr); if(dist == 0.0) return false; ldir *= 1.f/dist; @@ -122,7 +122,7 @@ light_t *pointLight_t::factory(paraMap_t ¶ms,renderEnvironment_t &render) { point3d_t from(0.0); color_t color(1.0); - CFLOAT power = 1.0; + float power = 1.0; bool lightEnabled = true; bool castShadows = true; bool shootD = true; diff --git a/src/lights/spherelight.cc b/src/lights/spherelight.cc index f9f8ad1e..a2175016 100755 --- a/src/lights/spherelight.cc +++ b/src/lights/spherelight.cc @@ -37,7 +37,7 @@ __BEGIN_YAFRAY class sphereLight_t : public light_t { public: - sphereLight_t(const point3d_t &c, PFLOAT rad, const color_t &col, CFLOAT inte, int nsam, bool bLightEnabled=true, bool bCastShadows=true); + sphereLight_t(const point3d_t &c, float rad, const color_t &col, float inte, int nsam, bool bLightEnabled=true, bool bCastShadows=true); ~sphereLight_t(); virtual void init(scene_t &scene); virtual color_t totalEnergy() const; @@ -47,21 +47,21 @@ class sphereLight_t : public light_t virtual bool illumSample(const surfacePoint_t &sp, lSample_t &s, ray_t &wi) const; virtual bool illuminate(const surfacePoint_t &sp, color_t &col, ray_t &wi)const { return false; } virtual bool canIntersect() const{ return false; } - virtual bool intersect(const ray_t &ray, PFLOAT &t, color_t &col, float &ipdf) const; + virtual bool intersect(const ray_t &ray, float &t, color_t &col, float &ipdf) const; virtual float illumPdf(const surfacePoint_t &sp, const surfacePoint_t &sp_light) const; virtual void emitPdf(const surfacePoint_t &sp, const vector3d_t &wo, float &areaPdf, float &dirPdf, float &cos_wo) const; virtual int nSamples() const { return samples; } static light_t *factory(paraMap_t ¶ms, renderEnvironment_t &render); protected: point3d_t center; - PFLOAT radius, square_radius, square_radius_epsilon; + float radius, square_radius, square_radius_epsilon; color_t color; //!< includes intensity amplification! so... int samples; unsigned int objID; float area, invArea; }; -sphereLight_t::sphereLight_t(const point3d_t &c, PFLOAT rad, const color_t &col, CFLOAT inte, int nsam, bool bLightEnabled, bool bCastShadows): +sphereLight_t::sphereLight_t(const point3d_t &c, float rad, const color_t &col, float inte, int nsam, bool bLightEnabled, bool bCastShadows): center(c), radius(rad), samples(nsam) { lLightEnabled = bLightEnabled; @@ -87,13 +87,13 @@ void sphereLight_t::init(scene_t &scene) color_t sphereLight_t::totalEnergy() const { return color * area /* * M_PI */; } -inline bool sphereIntersect(const ray_t &ray, const point3d_t &c, PFLOAT R2, PFLOAT &d1, PFLOAT &d2) +inline bool sphereIntersect(const ray_t &ray, const point3d_t &c, float R2, float &d1, float &d2) { vector3d_t vf=ray.from-c; - PFLOAT ea=ray.dir*ray.dir; - PFLOAT eb=2.0*vf*ray.dir; - PFLOAT ec=vf*vf-R2; - PFLOAT osc=eb*eb-4.0*ea*ec; + float ea=ray.dir*ray.dir; + float eb=2.0*vf*ray.dir; + float ec=vf*vf-R2; + float osc=eb*eb-4.0*ea*ec; if(osc<0){ d1 = fSqrt(ec/ea); return false; } // assume tangential hit/miss condition => Pythagoras osc=fSqrt(osc); d1=(-eb-osc)/(2.0*ea); @@ -106,18 +106,18 @@ bool sphereLight_t::illumSample(const surfacePoint_t &sp, lSample_t &s, ray_t &w if( photonOnly() ) return false; vector3d_t cdir = center - sp.P; - PFLOAT dist_sqr = cdir.lengthSqr(); + float dist_sqr = cdir.lengthSqr(); if(dist_sqr <= square_radius) return false; //only emit light on the outside! - PFLOAT dist = fSqrt(dist_sqr); - PFLOAT idist_sqr = 1.f/(dist_sqr); - PFLOAT cosAlpha = fSqrt(1.f - square_radius * idist_sqr); + float dist = fSqrt(dist_sqr); + float idist_sqr = 1.f/(dist_sqr); + float cosAlpha = fSqrt(1.f - square_radius * idist_sqr); cdir *= 1.f/dist; vector3d_t du, dv; createCS(cdir, du, dv); wi.dir = sampleCone(cdir, du, dv, cosAlpha, s.s1, s.s2); - PFLOAT d1, d2; + float d1, d2; if( !sphereIntersect(wi, center, square_radius_epsilon, d1, d2) ) { return false; @@ -135,16 +135,16 @@ bool sphereLight_t::illumSample(const surfacePoint_t &sp, lSample_t &s, ray_t &w return true; } -bool sphereLight_t::intersect(const ray_t &ray, PFLOAT &t, color_t &col, float &ipdf) const +bool sphereLight_t::intersect(const ray_t &ray, float &t, color_t &col, float &ipdf) const { - PFLOAT d1, d2; + float d1, d2; if( sphereIntersect(ray, center, square_radius, d1, d2) ) { vector3d_t cdir = center - ray.from; - PFLOAT dist_sqr = cdir.lengthSqr(); + float dist_sqr = cdir.lengthSqr(); if(dist_sqr <= square_radius) return false; //only emit light on the outside! - PFLOAT idist_sqr = 1.f/(dist_sqr); - PFLOAT cosAlpha = fSqrt(1.f - square_radius * idist_sqr); + float idist_sqr = 1.f/(dist_sqr); + float cosAlpha = fSqrt(1.f - square_radius * idist_sqr); ipdf = 2.f * (1.f - cosAlpha); col = color; return true; @@ -155,10 +155,10 @@ bool sphereLight_t::intersect(const ray_t &ray, PFLOAT &t, color_t &col, float & float sphereLight_t::illumPdf(const surfacePoint_t &sp, const surfacePoint_t &sp_light) const { vector3d_t cdir = center - sp.P; - PFLOAT dist_sqr = cdir.lengthSqr(); + float dist_sqr = cdir.lengthSqr(); if(dist_sqr <= square_radius) return 0.f; //only emit light on the outside! - PFLOAT idist_sqr = 1.f/(dist_sqr); - PFLOAT cosAlpha = fSqrt(1.f - square_radius * idist_sqr); + float idist_sqr = 1.f/(dist_sqr); + float cosAlpha = fSqrt(1.f - square_radius * idist_sqr); return 1.f / (2.f * (1.f - cosAlpha)); } @@ -199,7 +199,7 @@ light_t *sphereLight_t::factory(paraMap_t ¶ms,renderEnvironment_t &render) { point3d_t from(0.0); color_t color(1.0); - CFLOAT power = 1.0; + float power = 1.0; float radius = 1.f; int samples = 4; int object = 0; diff --git a/src/lights/spotlight.cc b/src/lights/spotlight.cc index d1ee35ce..2e73e844 100755 --- a/src/lights/spotlight.cc +++ b/src/lights/spotlight.cc @@ -28,7 +28,7 @@ __BEGIN_YAFRAY class spotLight_t : public light_t { public: - spotLight_t(const point3d_t &from, const point3d_t &to, const color_t &col, CFLOAT power, PFLOAT angle, PFLOAT falloff, bool sSha, int smpl, float ssfuzzy, bool bLightEnabled=true, bool bCastShadows=true); + spotLight_t(const point3d_t &from, const point3d_t &to, const color_t &col, float power, float angle, float falloff, bool sSha, int smpl, float ssfuzzy, bool bLightEnabled=true, bool bCastShadows=true); virtual ~spotLight_t(); virtual color_t totalEnergy() const; virtual color_t emitPhoton(float s1, float s2, float s3, float s4, ray_t &ray, float &ipdf) const; @@ -46,8 +46,8 @@ class spotLight_t : public light_t vector3d_t dir; //!< orientation of the spot cone vector3d_t ndir; //!< negative orientation (-dir) vector3d_t du, dv; //!< form a coordinate system with dir, to sample directions - PFLOAT cosStart, cosEnd; //= cosStart) // not affected by falloff { - col = color * (CFLOAT)idist_sqr; + col = color * (float)idist_sqr; } else { - PFLOAT v = (cosa - cosEnd)*icosDiff; + float v = (cosa - cosEnd)*icosDiff; v = v*v*(3.f - 2.f*v); - col = color * (CFLOAT)(v * idist_sqr); + col = color * (float)(v * idist_sqr); } wi.tmax = dist; @@ -152,7 +152,7 @@ bool spotLight_t::illumSample(const surfacePoint_t &sp, lSample_t &s, ray_t &wi) ldir *= 1.f/dist; //normalize - PFLOAT cosa = ndir*ldir; + float cosa = ndir*ldir; if(cosa < cosEnd) return false; //outside cone wi.tmax = dist; @@ -164,9 +164,9 @@ bool spotLight_t::illumSample(const surfacePoint_t &sp, lSample_t &s, ray_t &wi) } else { - PFLOAT v = (cosa - cosEnd)*icosDiff; + float v = (cosa - cosEnd)*icosDiff; v = v*v*(3.f - 2.f*v); - s.col = color * (CFLOAT)v; + s.col = color * (float)v; } s.flags = flags; @@ -198,8 +198,8 @@ color_t spotLight_t::emitPhoton(float s1, float s2, float s3, float s4, ray_t &r ipdf = M_2PI * (cosStart - cosEnd) / (interv2 * spdf); double cosAng = cosEnd + (cosStart - cosEnd) * (double)sm2; double sinAng = fSqrt(1.0 - cosAng*cosAng); - PFLOAT t1 = M_2PI*s1; - ray.dir = (du*fCos(t1) + dv*fSin(t1))*(PFLOAT)sinAng + dir*(PFLOAT)cosAng; + float t1 = M_2PI*s1; + ray.dir = (du*fCos(t1) + dv*fSin(t1))*(float)sinAng + dir*(float)cosAng; return color * spdf*pdf->integral; // scale is just the actual falloff function, since spdf is func * invIntegral... } return color; @@ -222,8 +222,8 @@ color_t spotLight_t::emitSample(vector3d_t &wo, lSample_t &s) const s.dirPdf = (interv2 * spdf) / ( M_2PI * (cosStart - cosEnd) ); double cosAng = cosEnd + (cosStart - cosEnd) * (double)sm2; double sinAng = fSqrt(1.0 - cosAng*cosAng); - PFLOAT t1 = M_2PI*s.s1; - wo = (du*fCos(t1) + dv*fSin(t1))*(PFLOAT)sinAng + dir*(PFLOAT)cosAng; + float t1 = M_2PI*s.s1; + wo = (du*fCos(t1) + dv*fSin(t1))*(float)sinAng + dir*(float)cosAng; float v = sm2*sm2*(3.f - 2.f*sm2); return color * v; } @@ -235,7 +235,7 @@ void spotLight_t::emitPdf(const surfacePoint_t &sp, const vector3d_t &wo, float areaPdf = 1.f; cos_wo = 1.f; - PFLOAT cosa = dir*wo; + float cosa = dir*wo; if(cosa < cosEnd) dirPdf = 0.f; else if(cosa >= cosStart) // not affected by falloff { @@ -243,7 +243,7 @@ void spotLight_t::emitPdf(const surfacePoint_t &sp, const vector3d_t &wo, float } else { - PFLOAT v = (cosa - cosEnd)*icosDiff; + float v = (cosa - cosEnd)*icosDiff; v = v*v*(3.f - 2.f*v); dirPdf = interv2 * v * 2.f / ( M_2PI * (cosStart - cosEnd) ); //divide by integral of v (0.5)? } diff --git a/src/lights/sunlight.cc b/src/lights/sunlight.cc index d845727e..0c3d0429 100755 --- a/src/lights/sunlight.cc +++ b/src/lights/sunlight.cc @@ -27,7 +27,7 @@ __BEGIN_YAFRAY class sunLight_t : public light_t { public: - sunLight_t(vector3d_t dir, const color_t &col, CFLOAT inte, float angle, int nSamples, bool bLightEnabled=true, bool bCastShadows=true); + sunLight_t(vector3d_t dir, const color_t &col, float inte, float angle, int nSamples, bool bLightEnabled=true, bool bCastShadows=true); virtual void init(scene_t &scene); virtual color_t totalEnergy() const { return color * ePdf; } virtual color_t emitPhoton(float s1, float s2, float s3, float s4, ray_t &ray, float &ipdf) const; @@ -35,7 +35,7 @@ class sunLight_t : public light_t virtual bool illumSample(const surfacePoint_t &sp, lSample_t &s, ray_t &wi) const; virtual bool illuminate(const surfacePoint_t &sp, color_t &col, ray_t &wi) const{ return false; } virtual bool canIntersect() const{ return true; } - virtual bool intersect(const ray_t &ray, PFLOAT &t, color_t &col, float &ipdf) const; + virtual bool intersect(const ray_t &ray, float &t, color_t &col, float &ipdf) const; virtual int nSamples() const { return samples; } static light_t *factory(paraMap_t ¶ms, renderEnvironment_t &render); protected: @@ -49,7 +49,7 @@ class sunLight_t : public light_t float ePdf; }; -sunLight_t::sunLight_t(vector3d_t dir, const color_t &col, CFLOAT inte, float angle, int nSamples, bool bLightEnabled, bool bCastShadows): +sunLight_t::sunLight_t(vector3d_t dir, const color_t &col, float inte, float angle, int nSamples, bool bLightEnabled, bool bCastShadows): direction(dir), samples(nSamples) { lLightEnabled = bLightEnabled; @@ -88,9 +88,9 @@ bool sunLight_t::illumSample(const surfacePoint_t &sp, lSample_t &s, ray_t &wi) return true; } -bool sunLight_t::intersect(const ray_t &ray, PFLOAT &t, color_t &col, float &ipdf) const +bool sunLight_t::intersect(const ray_t &ray, float &t, color_t &col, float &ipdf) const { - PFLOAT cosine = ray.dir*direction; + float cosine = ray.dir*direction; if(cosine < cosAngle) return false; col = colPdf; t = -1; @@ -120,7 +120,7 @@ light_t *sunLight_t::factory(paraMap_t ¶ms,renderEnvironment_t &render) { point3d_t dir(0.0, 0.0, 1.0); color_t color(1.0); - CFLOAT power = 1.0; + float power = 1.0; float angle = 0.27; //angular (half-)size of the real sun; int samples = 4; bool lightEnabled = true; diff --git a/src/materials/beer.cc b/src/materials/beer.cc index bf6123ef..ecfe6d77 100755 --- a/src/materials/beer.cc +++ b/src/materials/beer.cc @@ -27,7 +27,7 @@ class beer_t: public volumeHandler_t beer_t::beer_t(const color_t &acol, double dist) { - const CFLOAT maxlog = log(1e38); + const float maxlog = log(1e38); sigma_a.R = (acol.R > 1e-38) ? -log(acol.R) : maxlog; sigma_a.G = (acol.G > 1e-38) ? -log(acol.G) : maxlog; sigma_a.B = (acol.B > 1e-38) ? -log(acol.B) : maxlog; @@ -41,7 +41,7 @@ bool beer_t::transmittance(const renderState_t &state, const ray_t &ray, color_t col = color_t( 0.f, 0.f, 0.f); return true; } - CFLOAT dist = ray.tmax; // maybe substract ray.tmin... + float dist = ray.tmax; // maybe substract ray.tmin... color_t be(-dist * sigma_a); col = color_t( fExp(be.getR()), fExp(be.getG()), fExp(be.getB()) ); return true; @@ -72,7 +72,7 @@ class sss_t: public beer_t static volumeHandler_t* factory(const paraMap_t ¶ms, renderEnvironment_t &env); protected: - PFLOAT dist_s; + float dist_s; color_t scatter_col; }; @@ -82,7 +82,7 @@ sss_t::sss_t(const color_t &a_col, const color_t &s_col, double dist): bool sss_t::scatter(const renderState_t &state, const ray_t &ray, ray_t &sRay, pSample_t &s) const { - PFLOAT dist = -dist_s * log(s.s1); + float dist = -dist_s * log(s.s1); if(dist >= ray.tmax) return false; sRay.from = ray.from + dist*ray.dir; sRay.dir = SampleSphere(s.s2, s.s3); diff --git a/src/materials/blend.cc b/src/materials/blend.cc index f721f0aa..fe877157 100755 --- a/src/materials/blend.cc +++ b/src/materials/blend.cc @@ -331,7 +331,7 @@ color_t blendMat_t::getTransparency(const renderState_t &state, const surfacePoi return col1; } -CFLOAT blendMat_t::getAlpha(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo)const +float blendMat_t::getAlpha(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo)const { if(isTransparent()) { diff --git a/src/materials/coatedglossy.cc b/src/materials/coatedglossy.cc index 43c7aa84..391e148c 100755 --- a/src/materials/coatedglossy.cc +++ b/src/materials/coatedglossy.cc @@ -39,7 +39,7 @@ __BEGIN_YAFRAY class coatedGlossyMat_t: public nodeMaterial_t { public: - coatedGlossyMat_t(const color_t &col, const color_t &dcol, const color_t &mirCol, float mirrorStrength, float reflect, float diff, PFLOAT ior, float expo, bool as_diff, visibility_t eVisibility=NORMAL_VISIBLE); + coatedGlossyMat_t(const color_t &col, const color_t &dcol, const color_t &mirCol, float mirrorStrength, float reflect, float diff, float ior, float expo, bool as_diff, visibility_t eVisibility=NORMAL_VISIBLE); virtual void initBSDF(const renderState_t &state, surfacePoint_t &sp, BSDF_t &bsdfTypes)const; virtual color_t eval(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo, const vector3d_t &wi, BSDF_t bsdfs, bool force_eval = false)const; virtual color_t sample(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo, vector3d_t &wi, sample_t &s, float &W)const; @@ -95,10 +95,10 @@ class coatedGlossyMat_t: public nodeMaterial_t shaderNode_t *mDiffuseReflShader; //!< Shader node for diffuse reflection strength (float) color_t gloss_color, diff_color, mirror_color; //!< color of glossy base float mMirrorStrength; //!< BSDF Specular reflection component strength when not textured - PFLOAT IOR; + float IOR; float exponent, exp_u, exp_v; float reflectivity; - CFLOAT mGlossy, mDiffuse; + float mGlossy, mDiffuse; bool as_diffuse, with_diffuse, anisotropic; BSDF_t specFlags, glossyFlags; BSDF_t cFlags[3]; @@ -107,7 +107,7 @@ class coatedGlossyMat_t: public nodeMaterial_t float orenA, orenB; }; -coatedGlossyMat_t::coatedGlossyMat_t(const color_t &col, const color_t &dcol, const color_t &mirCol, float mirrorStrength, float reflect, float diff, PFLOAT ior, float expo, bool as_diff, visibility_t eVisibility): +coatedGlossyMat_t::coatedGlossyMat_t(const color_t &col, const color_t &dcol, const color_t &mirCol, float mirrorStrength, float reflect, float diff, float ior, float expo, bool as_diff, visibility_t eVisibility): diffuseS(nullptr), glossyS(nullptr), glossyRefS(nullptr), bumpS(nullptr), iorS(nullptr), exponentS(nullptr), mMirrorShader(nullptr), mMirrorColorShader(nullptr), mSigmaOrenShader(nullptr), mDiffuseReflShader(nullptr), gloss_color(col), diff_color(dcol), mirror_color(mirCol), mMirrorStrength(mirrorStrength), IOR(ior), exponent(expo), reflectivity(reflect), mDiffuse(diff), as_diffuse(as_diff), with_diffuse(false), anisotropic(false) { @@ -230,7 +230,7 @@ color_t coatedGlossyMat_t::eval(const renderState_t &state, const surfacePoint_t { glossy = Kt * Blinn_D(H*N, (exponentS ? exponentS->getScalar(stack) : exponent)) * SchlickFresnel(cos_wi_H, dat->mGlossy) / ASDivisor(cos_wi_H, woN, wiN); } - col = (CFLOAT)glossy*(glossyS ? glossyS->getColor(stack) : gloss_color); + col = (float)glossy*(glossyS ? glossyS->getColor(stack) : gloss_color); } if(with_diffuse && diffuse_flag) { @@ -389,7 +389,7 @@ color_t coatedGlossyMat_t::sample(const renderState_t &state, const surfacePoint s.pdf += Blinn_Pdf(cosHN, cos_wo_H, (exponentS ? exponentS->getScalar(stack) : exponent)) * width[rcIndex[C_GLOSSY]]; glossy = Blinn_D(cosHN, (exponentS ? exponentS->getScalar(stack) : exponent)) * SchlickFresnel(cos_wo_H, dat->mGlossy) / ASDivisor(cos_wo_H, woN, wiN); } - scolor = (CFLOAT)glossy*Kt*(glossyS ? glossyS->getColor(stack) : gloss_color); + scolor = (float)glossy*Kt*(glossyS ? glossyS->getColor(stack) : gloss_color); } if(use[C_DIFFUSE]) diff --git a/src/materials/glass.cc b/src/materials/glass.cc index e519cf1d..b2dc0b5f 100755 --- a/src/materials/glass.cc +++ b/src/materials/glass.cc @@ -35,7 +35,7 @@ class glassMat_t: public nodeMaterial_t virtual float pdf(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo, const vector3d_t &wi, BSDF_t bsdfs)const {return 0.f;} virtual bool isTransparent() const { return fakeShadow; } virtual color_t getTransparency(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo)const; - virtual CFLOAT getAlpha(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo)const; + virtual float getAlpha(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo)const; virtual void getSpecular(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo, bool &refl, bool &refr, vector3d_t *const dir, color_t *const col)const; virtual float getMatIOR() const; @@ -72,8 +72,8 @@ class glassMat_t: public nodeMaterial_t float ior; bool absorb, disperse, fakeShadow; BSDF_t tmFlags; - PFLOAT dispersion_power; - PFLOAT CauchyA, CauchyB; + float dispersion_power; + float CauchyA, CauchyB; }; glassMat_t::glassMat_t(float IOR, color_t filtC, const color_t &srcol, double disp_pow, bool fakeS, visibility_t eVisibility): @@ -118,7 +118,7 @@ color_t glassMat_t::sample(const renderState_t &state, const surfacePoint_t &sp, } vector3d_t refdir, N; bool outside = sp.Ng*wo > 0; - PFLOAT cos_wo_N = sp.N*wo; + float cos_wo_N = sp.N*wo; if(outside) N = (cos_wo_N >= 0) ? sp.N : (sp.N - (1.00001*cos_wo_N)*wo).normalize(); else N = (cos_wo_N <= 0) ? sp.N : (sp.N - (1.00001*cos_wo_N)*wo).normalize(); s.pdf = 1.f; @@ -141,7 +141,7 @@ color_t glassMat_t::sample(const renderState_t &state, const surfacePoint_t &sp, if( refract(N, wo, refdir, cur_ior) ) { - CFLOAT Kr, Kt; + float Kr, Kt; fresnel(wo, N, cur_ior, Kr, Kt); float pKr = 0.01+0.99*Kr, pKt = 0.01+0.99*Kt; if( !(s.flags & BSDF_SPECULAR) || s.s1 < pKt) @@ -191,7 +191,7 @@ color_t glassMat_t::sample(const renderState_t &state, const surfacePoint_t &sp, if( refract(N, wo, refdir, cur_ior) ) { - CFLOAT Kr, Kt; + float Kr, Kt; fresnel(wo, N, cur_ior, Kr, Kt); float pKr = 0.01+0.99*Kr, pKt = 0.01+0.99*Kt; if(s.s1 < pKt && matches(s.flags, tmFlags)) @@ -245,13 +245,13 @@ color_t glassMat_t::getTransparency(const renderState_t &state, const surfacePoi { nodeStack_t stack(state.userdata); vector3d_t N = FACE_FORWARD(sp.Ng, sp.N, wo); - CFLOAT Kr, Kt; + float Kr, Kt; fresnel(wo, N, (iorS ? iorS->getScalar(stack):ior), Kr, Kt); return Kt*(filterColS ? filterColS->getColor(stack) : filterCol); } -CFLOAT glassMat_t::getAlpha(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo)const { - CFLOAT alpha = 1.0 - getTransparency(state, sp, wo).energy(); +float glassMat_t::getAlpha(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo)const { + float alpha = 1.0 - getTransparency(state, sp, wo).energy(); if (alpha < 0.0f) alpha = 0.0f; return alpha; } @@ -262,7 +262,7 @@ void glassMat_t::getSpecular(const renderState_t &state, const surfacePoint_t &s nodeStack_t stack(state.userdata); bool outside = sp.Ng*wo > 0; vector3d_t N; - PFLOAT cos_wo_N = sp.N*wo; + float cos_wo_N = sp.N*wo; if(outside) { N = (cos_wo_N >= 0) ? sp.N : (sp.N - (1.00001*cos_wo_N)*wo).normalize(); @@ -292,7 +292,7 @@ void glassMat_t::getSpecular(const renderState_t &state, const surfacePoint_t &s if( refract(N, wo, refdir, cur_ior) ) { - CFLOAT Kr, Kt; + float Kr, Kt; fresnel(wo, N, cur_ior, Kr, Kt); if(!state.chromatic || !disperse) { @@ -374,7 +374,7 @@ material_t* glassMat_t::factory(paraMap_t ¶ms, std::list< paraMap_t > ¶m color_t sigma(0.f); if(params.getParam("absorption_dist", dist)) { - const CFLOAT maxlog = log(1e38); + const float maxlog = log(1e38); sigma.R = (absorp.R > 1e-38) ? -log(absorp.R) : maxlog; sigma.G = (absorp.G > 1e-38) ? -log(absorp.G) : maxlog; sigma.B = (absorp.B > 1e-38) ? -log(absorp.B) : maxlog; diff --git a/src/materials/mask.cc b/src/materials/mask.cc index c5ce5780..b7bbbcfb 100755 --- a/src/materials/mask.cc +++ b/src/materials/mask.cc @@ -29,7 +29,7 @@ __BEGIN_YAFRAY -maskMat_t::maskMat_t(const material_t *m1, const material_t *m2, CFLOAT thresh, visibility_t eVisibility): +maskMat_t::maskMat_t(const material_t *m1, const material_t *m2, float thresh, visibility_t eVisibility): mat1(m1), mat2(m2), threshold(thresh) { mVisibility = eVisibility; @@ -43,7 +43,7 @@ void maskMat_t::initBSDF(const renderState_t &state, surfacePoint_t &sp, BSDF_t { nodeStack_t stack(state.userdata); evalNodes(state, sp, allNodes, stack); - CFLOAT val = mask->getScalar(stack); //mask->getFloat(sp.P); + float val = mask->getScalar(stack); //mask->getFloat(sp.P); bool mv = val > threshold; *(bool*)state.userdata = mv; state.userdata = PTR_ADD(state.userdata, sizeof(bool)); @@ -94,7 +94,7 @@ color_t maskMat_t::getTransparency(const renderState_t &state, const surfacePoin { nodeStack_t stack(state.userdata); evalNodes(state, sp, allNodes, stack); - CFLOAT val = mask->getScalar(stack); + float val = mask->getScalar(stack); bool mv = val > 0.5; if(mv) return mat2->getTransparency(state, sp, wo); else return mat1->getTransparency(state, sp, wo); @@ -121,10 +121,10 @@ color_t maskMat_t::emit(const renderState_t &state, const surfacePoint_t &sp, co return col; } -CFLOAT maskMat_t::getAlpha(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo)const +float maskMat_t::getAlpha(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo)const { bool mv = *(bool*)state.userdata; - CFLOAT alpha; + float alpha; state.userdata = PTR_ADD(state.userdata, sizeof(bool)); if(mv) alpha = mat2->getAlpha(state, sp, wo); else alpha = mat1->getAlpha(state, sp, wo); diff --git a/src/materials/shinydiffuse.cc b/src/materials/shinydiffuse.cc index 76f0cdc8..33c54491 100755 --- a/src/materials/shinydiffuse.cc +++ b/src/materials/shinydiffuse.cc @@ -184,11 +184,11 @@ void shinyDiffuseMat_t::initOrenNayar(double sigma) * @param N Surface normal * @note http://en.wikipedia.org/wiki/Oren-Nayar_reflectance_model */ -CFLOAT shinyDiffuseMat_t::OrenNayar(const vector3d_t &wi, const vector3d_t &wo, const vector3d_t &N, bool useTextureSigma, double textureSigma) const +float shinyDiffuseMat_t::OrenNayar(const vector3d_t &wi, const vector3d_t &wo, const vector3d_t &N, bool useTextureSigma, double textureSigma) const { - PFLOAT cos_ti = std::max(-1.f,std::min(1.f,N*wi)); - PFLOAT cos_to = std::max(-1.f,std::min(1.f,N*wo)); - CFLOAT maxcos_f = 0.f; + float cos_ti = std::max(-1.f,std::min(1.f,N*wi)); + float cos_to = std::max(-1.f,std::min(1.f,N*wo)); + float maxcos_f = 0.f; if(cos_ti < 0.9999f && cos_to < 0.9999f) { @@ -197,7 +197,7 @@ CFLOAT shinyDiffuseMat_t::OrenNayar(const vector3d_t &wi, const vector3d_t &wo, maxcos_f = std::max(0.f, v1*v2); } - CFLOAT sin_alpha, tan_beta; + float sin_alpha, tan_beta; if(cos_to >= cos_ti) { @@ -226,8 +226,8 @@ CFLOAT shinyDiffuseMat_t::OrenNayar(const vector3d_t &wi, const vector3d_t &wo, color_t shinyDiffuseMat_t::eval(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo, const vector3d_t &wl, BSDF_t bsdfs, bool force_eval)const { - PFLOAT cos_Ng_wo = sp.Ng*wo; - PFLOAT cos_Ng_wl = sp.Ng*wl; + float cos_Ng_wo = sp.Ng*wo; + float cos_Ng_wl = sp.Ng*wl; // face forward: vector3d_t N = FACE_FORWARD(sp.Ng, sp.N, wo); if(!(bsdfs & bsdfFlags & BSDF_DIFFUSE)) return color_t(0.f); @@ -281,7 +281,7 @@ color_t shinyDiffuseMat_t::emit(const renderState_t &state, const surfacePoint_t color_t shinyDiffuseMat_t::sample(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo, vector3d_t &wi, sample_t &s, float &W)const { float accumC[4]; - PFLOAT cos_Ng_wo = sp.Ng*wo, cos_Ng_wi, cos_N; + float cos_Ng_wo = sp.Ng*wo, cos_Ng_wi, cos_N; vector3d_t N = FACE_FORWARD(sp.Ng, sp.N, wo); SDDat_t *dat = (SDDat_t *)state.userdata; @@ -382,7 +382,7 @@ float shinyDiffuseMat_t::pdf(const renderState_t &state, const surfacePoint_t &s float pdf=0.f; float accumC[4]; - PFLOAT cos_Ng_wo = sp.Ng*wo, cos_Ng_wi; + float cos_Ng_wo = sp.Ng*wo, cos_Ng_wi; vector3d_t N = FACE_FORWARD(sp.Ng, sp.N, wo); float Kr; @@ -476,7 +476,7 @@ void shinyDiffuseMat_t::getSpecular(const renderState_t &state, const surfacePoi //Y_WARNING << sp.N << " | " << N << yendl; wi[0] = wo; wi[0].reflect(N); - PFLOAT cos_wi_Ng = wi[0]*Ng; + float cos_wi_Ng = wi[0]*Ng; if(cos_wi_Ng < 0.01) { wi[0] += (0.01-cos_wi_Ng)*Ng; @@ -523,7 +523,7 @@ color_t shinyDiffuseMat_t::getTransparency(const renderState_t &state, const sur return accum * tcol; } -CFLOAT shinyDiffuseMat_t::getAlpha(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo)const +float shinyDiffuseMat_t::getAlpha(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo)const { SDDat_t *dat = (SDDat_t *)state.userdata; nodeStack_t stack(dat->nodeStack); @@ -542,7 +542,7 @@ CFLOAT shinyDiffuseMat_t::getAlpha(const renderState_t &state, const surfacePoin else cur_ior_squared = mIOR_Squared; getFresnel(wo, N, Kr, cur_ior_squared); - CFLOAT refl = (1.f - dat->component[0]*Kr) * dat->component[1]; + float refl = (1.f - dat->component[0]*Kr) * dat->component[1]; return 1.f - refl; } return 1.f; @@ -553,7 +553,7 @@ material_t* shinyDiffuseMat_t::factory(paraMap_t ¶ms, std::list & /// Material Parameters color_t diffuseColor=1.f; color_t mirrorColor=1.f; - CFLOAT diffuseStrength=1.f; + float diffuseStrength=1.f; float transparencyStrength=0.f; float translucencyStrength=0.f; float mirrorStrength=0.f; diff --git a/src/materials/simple.cc b/src/materials/simple.cc index 5b5db79c..f122a29f 100755 --- a/src/materials/simple.cc +++ b/src/materials/simple.cc @@ -65,7 +65,7 @@ color_t lightMat_t::emit(const renderState_t &state, const surfacePoint_t &sp, c if(!state.includeLights) return color_t(0.f); if(doubleSided) return lightCol; - PFLOAT angle = wo*sp.N; + float angle = wo*sp.N; return (angle>0) ? lightCol : color_t(0.f); } @@ -82,7 +82,7 @@ material_t* lightMat_t::factory(paraMap_t ¶ms, std::list< paraMap_t > &epara params.getParam("color", col); params.getParam("power", power); params.getParam("double_sided", ds); - return new lightMat_t(col*(CFLOAT)power, ds); + return new lightMat_t(col*(float)power, ds); } extern "C" diff --git a/src/textures/basicnodes.cc b/src/textures/basicnodes.cc index de9eac94..a1418cfd 100755 --- a/src/textures/basicnodes.cc +++ b/src/textures/basicnodes.cc @@ -43,7 +43,7 @@ inline point3d_t tubemap(const point3d_t &p) { point3d_t res; res.y = p.z; - PFLOAT d = p.x*p.x + p.y*p.y; + float d = p.x*p.x + p.y*p.y; if (d>0) { res.z = 1.0/fSqrt(d); res.x = -atan2(p.x, p.y) * M_1_PI; @@ -56,7 +56,7 @@ inline point3d_t tubemap(const point3d_t &p) inline point3d_t spheremap(const point3d_t &p) { point3d_t res(0.f); - PFLOAT d = p.x*p.x + p.y*p.y + p.z*p.z; + float d = p.x*p.x + p.y*p.y + p.z*p.z; if (d>0) { res.z = fSqrt(d); if ((p.x!=0) && (p.y!=0)) res.x = -atan2(p.x, p.y) * M_1_PI; @@ -103,7 +103,7 @@ point3d_t textureMapper_t::doMapping(const point3d_t &p, const vector3d_t &N)con default: break; } // Texture axis mapping - PFLOAT texmap[4] = {0, texpt.x, texpt.y, texpt.z}; + float texmap[4] = {0, texpt.x, texpt.y, texpt.z}; texpt.x=texmap[map_x]; texpt.y=texmap[map_y]; texpt.z=texmap[map_z]; @@ -537,7 +537,7 @@ class screenNode_t: public mixNode_t f1 = 1.f - f2; colorA_t color = colorA_t(1.f) - (colorA_t(f1) + f2 * (1.f - cin2)) * (1.f - cin1); - CFLOAT scalar = 1.0 - (f1 + f2*(1.f - fin2)) * (1.f - fin1); + float scalar = 1.0 - (f1 + f2*(1.f - fin2)) * (1.f - fin1); stack[this->ID] = nodeResult_t(color, scalar); } }; @@ -616,7 +616,7 @@ class overlayNode_t: public mixNode_t color.G = (cin1.G < 0.5f) ? cin1.G * (f1 + 2.0f*f2*cin2.G) : 1.0 - (f1 + 2.0f*f2*(1.0 - cin2.G)) * (1.0 - cin1.G); color.B = (cin1.B < 0.5f) ? cin1.B * (f1 + 2.0f*f2*cin2.B) : 1.0 - (f1 + 2.0f*f2*(1.0 - cin2.B)) * (1.0 - cin1.B); color.A = (cin1.A < 0.5f) ? cin1.A * (f1 + 2.0f*f2*cin2.A) : 1.0 - (f1 + 2.0f*f2*(1.0 - cin2.A)) * (1.0 - cin1.A); - CFLOAT scalar = (fin1 < 0.5f) ? fin1 * (f1 + 2.0f*f2*fin2) : 1.0 - (f1 + 2.0f*f2*(1.0 - fin2)) * (1.0 - fin1); + float scalar = (fin1 < 0.5f) ? fin1 * (f1 + 2.0f*f2*fin2) : 1.0 - (f1 + 2.0f*f2*(1.0 - fin2)) * (1.0 - fin1); stack[this->ID] = nodeResult_t(color, scalar); } }; diff --git a/src/textures/basictex.cc b/src/textures/basictex.cc index f3315437..bf5ee7c3 100755 --- a/src/textures/basictex.cc +++ b/src/textures/basictex.cc @@ -36,7 +36,7 @@ noiseGenerator_t* newNoise(const std::string &ntype) // Clouds Texture //----------------------------------------------------------------------------------------- -textureClouds_t::textureClouds_t(int dep, PFLOAT sz, bool hd, +textureClouds_t::textureClouds_t(int dep, float sz, bool hd, const color_t &c1, const color_t &c2, const std::string &ntype, const std::string &btype) :depth(dep), size(sz), hard(hd), color1(c1), color2(c2) @@ -53,9 +53,9 @@ textureClouds_t::~textureClouds_t() nGen = nullptr; } -CFLOAT textureClouds_t::getFloat(const point3d_t &p) const +float textureClouds_t::getFloat(const point3d_t &p) const { - CFLOAT v = turbulence(nGen, p, depth, size, hard); + float v = turbulence(nGen, p, depth, size, hard); if (bias) { v *= v; if (bias==1) return -v; // !!! @@ -75,7 +75,7 @@ texture_t *textureClouds_t::factory(paraMap_t ¶ms, int depth = 2; std::string _ntype, _btype; const std::string *ntype = &_ntype, *btype=&_btype; - PFLOAT size = 1; + float size = 1; bool hard = false; params.getParam("noise_type", ntype); params.getParam("color1", color1); @@ -91,8 +91,8 @@ texture_t *textureClouds_t::factory(paraMap_t ¶ms, // Simple Marble Texture //----------------------------------------------------------------------------------------- -textureMarble_t::textureMarble_t(int oct, PFLOAT sz, const color_t &c1, const color_t &c2, - PFLOAT _turb, PFLOAT shp, bool hrd, const std::string &ntype, const std::string &shape) +textureMarble_t::textureMarble_t(int oct, float sz, const color_t &c1, const color_t &c2, + float _turb, float shp, bool hrd, const std::string &ntype, const std::string &shape) :octaves(oct), color1(c1), color2(c2), turb(_turb), size(sz), hard(hrd) { sharpness = 1.0; @@ -103,22 +103,22 @@ textureMarble_t::textureMarble_t(int oct, PFLOAT sz, const color_t &c1, const co else if (shape=="tri") wshape = TRI; } -CFLOAT textureMarble_t::getFloat(const point3d_t &p) const +float textureMarble_t::getFloat(const point3d_t &p) const { - PFLOAT w = (p.x + p.y + p.z)*5.0 + float w = (p.x + p.y + p.z)*5.0 + ((turb==0.0) ? 0.0 : turb*turbulence(nGen, p, octaves, size, hard)); switch (wshape) { case SAW: - w *= (PFLOAT)(0.5*M_1_PI); + w *= (float)(0.5*M_1_PI); w -= floor(w); break; case TRI: - w *= (PFLOAT)(0.5*M_1_PI); - w = std::fabs((PFLOAT)2.0*(w-floor(w))-(PFLOAT)1.0); + w *= (float)(0.5*M_1_PI); + w = std::fabs((float)2.0*(w-floor(w))-(float)1.0); break; default: case SIN: - w = (PFLOAT)0.5 + (PFLOAT)0.5*fSin(w); + w = (float)0.5 + (float)0.5*fSin(w); } return fPow(w, sharpness); } @@ -133,7 +133,7 @@ texture_t *textureMarble_t::factory(paraMap_t ¶ms, { color_t col1(0.0), col2(1.0); int oct = 2; - PFLOAT turb=1.0, shp=1.0, sz=1.0; + float turb=1.0, shp=1.0, sz=1.0; bool hrd = false; std::string _ntype, _shape; const std::string *ntype=&_ntype, *shape=&_shape; @@ -154,7 +154,7 @@ texture_t *textureMarble_t::factory(paraMap_t ¶ms, // Simple Wood Texture //----------------------------------------------------------------------------------------- -textureWood_t::textureWood_t(int oct, PFLOAT sz, const color_t &c1, const color_t &c2, PFLOAT _turb, +textureWood_t::textureWood_t(int oct, float sz, const color_t &c1, const color_t &c2, float _turb, bool hrd, const std::string &ntype, const std::string &wtype, const std::string &shape) :octaves(oct), color1(c1), color2(c2), turb(_turb), size(sz), hard(hrd) { @@ -165,9 +165,9 @@ textureWood_t::textureWood_t(int oct, PFLOAT sz, const color_t &c1, const color_ else if (shape=="tri") wshape = TRI; } -CFLOAT textureWood_t::getFloat(const point3d_t &p) const +float textureWood_t::getFloat(const point3d_t &p) const { - PFLOAT w; + float w; if (rings) w = fSqrt(p.x*p.x + p.y*p.y + p.z*p.z)*20.0; else @@ -175,16 +175,16 @@ CFLOAT textureWood_t::getFloat(const point3d_t &p) const w += (turb==0.0) ? 0.0 : turb*turbulence(nGen, p, octaves, size, hard); switch (wshape) { case SAW: - w *= (PFLOAT)(0.5*M_1_PI); + w *= (float)(0.5*M_1_PI); w -= floor(w); break; case TRI: - w *= (PFLOAT)(0.5*M_1_PI); - w = std::fabs((PFLOAT)2.0*(w-floor(w))-(PFLOAT)1.0); + w *= (float)(0.5*M_1_PI); + w = std::fabs((float)2.0*(w-floor(w))-(float)1.0); break; default: case SIN: - w = (PFLOAT)0.5 + (PFLOAT)0.5*fSin(w); + w = (float)0.5 + (float)0.5*fSin(w); } return w; } @@ -199,7 +199,7 @@ texture_t *textureWood_t::factory(paraMap_t ¶ms, { color_t col1(0.0), col2(1.0); int oct = 2; - PFLOAT turb=1.0, sz=1.0, old_rxy; + float turb=1.0, sz=1.0, old_rxy; bool hrd = false; std::string _ntype, _wtype, _shape; const std::string *ntype=&_ntype, *wtype=&_wtype, *shape=&_shape; @@ -230,7 +230,7 @@ colorA_t rgbCube_t::getColor(const point3d_t &p) const return col; } -CFLOAT rgbCube_t::getFloat(const point3d_t &p) const +float rgbCube_t::getFloat(const point3d_t &p) const { color_t col = color_t(p.x, p.y, p.z); col.clampRGB01(); @@ -249,9 +249,9 @@ texture_t* rgbCube_t::factory(paraMap_t ¶ms,renderEnvironment_t &render) textureVoronoi_t::textureVoronoi_t(const color_t &c1, const color_t &c2, int ct, - CFLOAT _w1, CFLOAT _w2, CFLOAT _w3, CFLOAT _w4, - PFLOAT mex, PFLOAT sz, - CFLOAT isc, const std::string &dname) + float _w1, float _w2, float _w3, float _w4, + float mex, float sz, + float isc, const std::string &dname) :w1(_w1), w2(_w2), w3(_w3), w4(_w4), size(sz), coltype(ct) { voronoi_t::dMetricType dm = voronoi_t::DIST_REAL; @@ -277,9 +277,9 @@ textureVoronoi_t::textureVoronoi_t(const color_t &c1, const color_t &c2, if (iscale!=0) iscale = isc/iscale; } -CFLOAT textureVoronoi_t::getFloat(const point3d_t &p) const +float textureVoronoi_t::getFloat(const point3d_t &p) const { - PFLOAT da[4]; + float da[4]; point3d_t pa[4]; vGen.getFeatures(p*size, da, pa); return iscale * std::fabs(w1*vGen.getDistance(0, da) + w2*vGen.getDistance(1, da) @@ -288,10 +288,10 @@ CFLOAT textureVoronoi_t::getFloat(const point3d_t &p) const colorA_t textureVoronoi_t::getColor(const point3d_t &p) const { - PFLOAT da[4]; + float da[4]; point3d_t pa[4]; vGen.getFeatures(p*size, da, pa); - CFLOAT inte = iscale * std::fabs(w1*vGen.getDistance(0, da) + w2*vGen.getDistance(1, da) + float inte = iscale * std::fabs(w1*vGen.getDistance(0, da) + w2*vGen.getDistance(1, da) + w3*vGen.getDistance(2, da) + w4*vGen.getDistance(3, da)); colorA_t col(0.0); if (coltype) { @@ -300,7 +300,7 @@ colorA_t textureVoronoi_t::getColor(const point3d_t &p) const col += aw3 * cellNoiseColor(vGen.getPoint(2, pa)); col += aw4 * cellNoiseColor(vGen.getPoint(3, pa)); if (coltype>=2) { - CFLOAT t1 = (vGen.getDistance(1, da) - vGen.getDistance(0, da))*10.0; + float t1 = (vGen.getDistance(1, da) - vGen.getDistance(0, da))*10.0; if (t1>1) t1=1; if (coltype==3) t1*=inte; else t1*=iscale; col *= t1; @@ -316,10 +316,10 @@ texture_t *textureVoronoi_t::factory(paraMap_t ¶ms, renderEnvironment_t &ren color_t col1(0.0), col2(1.0); std::string _cltype, _dname; const std::string *cltype=&_cltype, *dname=&_dname; - CFLOAT fw1=1, fw2=0, fw3=0, fw4=0; - PFLOAT mex=2.5; // minkovsky exponent - CFLOAT isc=1; // intensity scale - PFLOAT sz=1; // size + float fw1=1, fw2=0, fw3=0, fw4=0; + float mex=2.5; // minkovsky exponent + float isc=1; // intensity scale + float sz=1; // size int ct=0; // default "int" color type (intensity) params.getParam("color1", col1); @@ -349,8 +349,8 @@ texture_t *textureVoronoi_t::factory(paraMap_t ¶ms, renderEnvironment_t &ren //----------------------------------------------------------------------------------------- textureMusgrave_t::textureMusgrave_t(const color_t &c1, const color_t &c2, - PFLOAT H, PFLOAT lacu, PFLOAT octs, PFLOAT offs, PFLOAT gain, - PFLOAT _size, CFLOAT _iscale, + float H, float lacu, float octs, float offs, float gain, + float _size, float _iscale, const std::string &ntype, const std::string &mtype) :color1(c1), color2(c2), size(_size), iscale(_iscale) { @@ -379,7 +379,7 @@ textureMusgrave_t::~textureMusgrave_t() } } -CFLOAT textureMusgrave_t::getFloat(const point3d_t &p) const +float textureMusgrave_t::getFloat(const point3d_t &p) const { return iscale * (*mGen)(p*size); } @@ -394,7 +394,7 @@ texture_t *textureMusgrave_t::factory(paraMap_t ¶ms, renderEnvironment_t &re color_t col1(0.0), col2(1.0); std::string _ntype, _mtype; const std::string *ntype=&_ntype, *mtype=&_mtype; - PFLOAT H=1, lacu=2, octs=2, offs=1, gain=1, size=1, iscale=1; + float H=1, lacu=2, octs=2, offs=1, gain=1, size=1, iscale=1; params.getParam("color1", col1); params.getParam("color2", col2); @@ -418,7 +418,7 @@ texture_t *textureMusgrave_t::factory(paraMap_t ¶ms, renderEnvironment_t &re //----------------------------------------------------------------------------------------- textureDistortedNoise_t::textureDistortedNoise_t(const color_t &c1, const color_t &c2, - PFLOAT _distort, PFLOAT _size, + float _distort, float _size, const std::string &noiseb1, const std::string noiseb2) :color1(c1), color2(c2), distort(_distort), size(_size) { @@ -438,7 +438,7 @@ textureDistortedNoise_t::~textureDistortedNoise_t() } } -CFLOAT textureDistortedNoise_t::getFloat(const point3d_t &p) const +float textureDistortedNoise_t::getFloat(const point3d_t &p) const { // get a random vector and scale the randomization const point3d_t ofs(13.5, 13.5, 13.5); @@ -457,7 +457,7 @@ texture_t *textureDistortedNoise_t::factory(paraMap_t ¶ms, renderEnvironment color_t col1(0.0), col2(1.0); std::string _ntype1, _ntype2; const std::string *ntype1=&_ntype1, *ntype2=&_ntype2; - PFLOAT dist=1, size=1; + float dist=1, size=1; params.getParam("color1", col1); params.getParam("color2", col2); @@ -484,7 +484,7 @@ textureBlend_t::~textureBlend_t() { } -CFLOAT textureBlend_t::getFloat(const point3d_t &p) const +float textureBlend_t::getFloat(const point3d_t &p) const { float blend; // Transform -1..1 to 0..1 diff --git a/src/textures/imagetex.cc b/src/textures/imagetex.cc index 67aceb89..36c9a60a 100755 --- a/src/textures/imagetex.cc +++ b/src/textures/imagetex.cc @@ -171,7 +171,7 @@ bool textureImage_t::doMapping(point3d_t &texpt) const // repeat, only valid for REPEAT clipmode if (tex_clipmode==TCL_REPEAT) { if (xrepeat>1) { - texpt.x *= (PFLOAT)xrepeat; + texpt.x *= (float)xrepeat; if (mirrorX && int(ceilf(texpt.x)) % 2 == 0) { texpt.x = -texpt.x; @@ -179,7 +179,7 @@ bool textureImage_t::doMapping(point3d_t &texpt) const if (texpt.x>1.0) texpt.x -= int(texpt.x); else if (texpt.x<0.0) texpt.x += 1-int(texpt.x); } if (yrepeat>1) { - texpt.y *= (PFLOAT)yrepeat; + texpt.y *= (float)yrepeat; if (mirrorY && int(ceilf(texpt.y)) % 2 == 0) { texpt.y = -texpt.y; diff --git a/src/textures/layernode.cc b/src/textures/layernode.cc index 97123828..a55fc23b 100755 --- a/src/textures/layernode.cc +++ b/src/textures/layernode.cc @@ -3,7 +3,7 @@ __BEGIN_YAFRAY -layerNode_t::layerNode_t(unsigned tflag, CFLOAT col_fac, CFLOAT val_fac, CFLOAT def_val, colorA_t def_col, mix_modes mmod): +layerNode_t::layerNode_t(unsigned tflag, float col_fac, float val_fac, float def_val, colorA_t def_col, mix_modes mmod): input(0), upperLayer(0), texflag(tflag), colfac(col_fac), valfac(val_fac), default_val(def_val), default_col(def_col), mode(mmod), do_color(false), do_scalar(false), color_input(false) {} @@ -11,7 +11,7 @@ layerNode_t::layerNode_t(unsigned tflag, CFLOAT col_fac, CFLOAT val_fac, CFLOAT void layerNode_t::eval(nodeStack_t &stack, const renderState_t &state, const surfacePoint_t &sp)const { colorA_t rcol, texcolor; - CFLOAT rval, Tin=0.f, Ta=1.f, stencilTin = 1.f; + float rval, Tin=0.f, Ta=1.f, stencilTin = 1.f; // == get result of upper layer (or base values) == rcol = (upperLayer) ? upperLayer->getColor(stack) : upper_col; rval = (upperLayer) ? upperLayer->getScalar(stack) : upper_val; @@ -39,7 +39,7 @@ void layerNode_t::eval(nodeStack_t &stack, const renderState_t &state, const sur Tin = 1.f-Tin; } - CFLOAT fact; + float fact; if(texflag & TXF_STENCIL) { @@ -63,7 +63,7 @@ void layerNode_t::eval(nodeStack_t &stack, const renderState_t &state, const sur if(!TEX_RGB) texcolor = default_col; else Tin = Ta; - CFLOAT Tin_truncated_range; + float Tin_truncated_range; if(Tin>1.f) Tin_truncated_range=1.f; else if(Tin<0.f) Tin_truncated_range=0.f; @@ -104,8 +104,8 @@ void layerNode_t::eval(nodeStack_t &stack, const renderState_t &state, const sur void layerNode_t::evalDerivative(nodeStack_t &stack, const renderState_t &state, const surfacePoint_t &sp)const { colorA_t texcolor; - CFLOAT rdu=0.f, rdv=0.f, tdu, tdv; - CFLOAT stencilTin = 1.f; + float rdu=0.f, rdv=0.f, tdu, tdv; + float stencilTin = 1.f; // == get result of upper layer (or base values) == if(upperLayer) diff --git a/src/textures/noise.cc b/src/textures/noise.cc index 66bbe860..57fdba2e 100755 --- a/src/textures/noise.cc +++ b/src/textures/noise.cc @@ -158,10 +158,10 @@ static float hashvectf[768]= { //------------------------------------------------------------------------------------ // New Perlin noise -PFLOAT newPerlin_t::operator() (const point3d_t &pt) const +float newPerlin_t::operator() (const point3d_t &pt) const { - PFLOAT x=pt.x, y=pt.y, z=pt.z; - PFLOAT u=floor(x), v=floor(y), w=floor(z); + float x=pt.x, y=pt.y, z=pt.z; + float u=floor(x), v=floor(y), w=floor(z); int X=((int)u) & 255, Y=((int)v) & 255, Z=((int)w) & 255; // FIND UNIT CUBE THAT CONTAINS POINT x -= u; // FIND RELATIVE X,Y,Z y -= v; // OF POINT IN CUBE. @@ -171,7 +171,7 @@ PFLOAT newPerlin_t::operator() (const point3d_t &pt) const w = fade(z); int A=hash[X ]+Y, AA=hash[A]+Z, AB=hash[A+1]+Z, // HASH COORDINATES OF B=hash[X+1]+Y, BA=hash[B]+Z, BB=hash[B+1]+Z; // THE 8 CUBE CORNERS, - PFLOAT nv = lerp(w, lerp(v, lerp(u, grad(hash[AA ], x , y , z ), // AND ADD + float nv = lerp(w, lerp(v, lerp(u, grad(hash[AA ], x , y , z ), // AND ADD grad(hash[BA ], x-1, y , z )), // BLENDED lerp(u, grad(hash[AB ], x , y-1, z ), // RESULTS grad(hash[BB ], x-1, y-1, z ))), // FROM 8 @@ -295,7 +295,7 @@ static float stdp_g[512+2][3]= { r0 = t - (int)t; \ r1 = r0 - 1.0; -PFLOAT stdPerlin_t::operator() (const point3d_t &pt) const +float stdPerlin_t::operator() (const point3d_t &pt) const { int bx0, bx1, by0, by1, bz0, bz1, b00, b10, b01, b11; float rx0, rx1, ry0, ry1, rz0, rz1, *q, sx, sy, sz, a, b, c, d, t, u, v; @@ -349,25 +349,25 @@ PFLOAT stdPerlin_t::operator() (const point3d_t &pt) const } // distance metric function: -PFLOAT dist_RealF(PFLOAT x, PFLOAT y, PFLOAT z, PFLOAT e) { return fSqrt(x*x + y*y + z*z); } -PFLOAT dist_SquaredF(PFLOAT x, PFLOAT y, PFLOAT z, PFLOAT e) { return (x*x + y*y + z*z); } -PFLOAT dist_ManhattanF(PFLOAT x, PFLOAT y, PFLOAT z, PFLOAT e) { return (std::fabs(x) + std::fabs(y) + std::fabs(z)); } -PFLOAT dist_ChebychevF(PFLOAT x, PFLOAT y, PFLOAT z, PFLOAT e) +float dist_RealF(float x, float y, float z, float e) { return fSqrt(x*x + y*y + z*z); } +float dist_SquaredF(float x, float y, float z, float e) { return (x*x + y*y + z*z); } +float dist_ManhattanF(float x, float y, float z, float e) { return (std::fabs(x) + std::fabs(y) + std::fabs(z)); } +float dist_ChebychevF(float x, float y, float z, float e) { x = std::fabs(x); y = std::fabs(y); z = std::fabs(z); - PFLOAT t = (x>y)?x:y; + float t = (x>y)?x:y; return ((z>t)?z:t); } // minkovsky preset exponent 0.5 -PFLOAT dist_MinkovskyHF(PFLOAT x, PFLOAT y, PFLOAT z, PFLOAT e) +float dist_MinkovskyHF(float x, float y, float z, float e) { - PFLOAT d = fSqrt(std::fabs(x)) + fSqrt(std::fabs(y)) + fSqrt(std::fabs(z)); + float d = fSqrt(std::fabs(x)) + fSqrt(std::fabs(y)) + fSqrt(std::fabs(z)); return (d*d); } // minkovsky preset exponent 4 -PFLOAT dist_Minkovsky4F(PFLOAT x, PFLOAT y, PFLOAT z, PFLOAT e) +float dist_Minkovsky4F(float x, float y, float z, float e) { x *= x; y *= y; @@ -375,25 +375,25 @@ PFLOAT dist_Minkovsky4F(PFLOAT x, PFLOAT y, PFLOAT z, PFLOAT e) return fSqrt(fSqrt(x*x + y*y + z*z)); } // Minkovsky, general case, slow -PFLOAT dist_MinkovskyF(PFLOAT x, PFLOAT y, PFLOAT z, PFLOAT e) +float dist_MinkovskyF(float x, float y, float z, float e) { - return fPow(fPow(std::fabs(x), e) + fPow(std::fabs(y), e) + fPow(std::fabs(z), e), (PFLOAT)1.0/e); + return fPow(fPow(std::fabs(x), e) + fPow(std::fabs(y), e) + fPow(std::fabs(z), e), (float)1.0/e); } //------------------------------------------------------------------------------------ // Blender noise, similar to 'standard' perlin -PFLOAT blenderNoise_t::operator() (const point3d_t &pt) const +float blenderNoise_t::operator() (const point3d_t &pt) const { - //PFLOAT cn1, cn2, cn3, cn4, cn5, cn6, i, *h; - //PFLOAT ox, oy, oz, jx, jy, jz; - //PFLOAT n= 0.5; + //float cn1, cn2, cn3, cn4, cn5, cn6, i, *h; + //float ox, oy, oz, jx, jy, jz; + //float n= 0.5; float cn1, cn2, cn3, cn4, cn5, cn6, i, *h; float ox, oy, oz, jx, jy, jz; float n= 0.5; int ix, iy, iz, b00, b01, b10, b11, b20, b21; - PFLOAT x=pt.x, y=pt.y, z=pt.z; + float x=pt.x, y=pt.y, z=pt.z; ox= (x- (ix= (int)floor(x)) ); oy= (y- (iy= (int)floor(y)) ); oz= (z- (iz= (int)floor(z)) ); @@ -494,7 +494,7 @@ void voronoi_t::setDistM(dMetricType dm) } } -voronoi_t::voronoi_t(voronoiType vt, dMetricType dm, PFLOAT mex) +voronoi_t::voronoi_t(voronoiType vt, dMetricType dm, float mex) { vType = vt; dmType = dm; @@ -502,11 +502,11 @@ voronoi_t::voronoi_t(voronoiType vt, dMetricType dm, PFLOAT mex) setDistM(dmType); } -void voronoi_t::getFeatures(const point3d_t &pt, PFLOAT da[4], point3d_t pa[4]) const +void voronoi_t::getFeatures(const point3d_t &pt, float da[4], point3d_t pa[4]) const { int xx, yy, zz, xi, yi, zi; - //PFLOAT xd, yd, zd, d, *p; - //PFLOAT x=pt.x, y=pt.y, z=pt.z; + //float xd, yd, zd, d, *p; + //float x=pt.x, y=pt.y, z=pt.z; float xd, yd, zd, d, *p; float x=pt.x, y=pt.y, z=pt.z; xi = (int)(floor(x)); @@ -543,9 +543,9 @@ void voronoi_t::getFeatures(const point3d_t &pt, PFLOAT da[4], point3d_t pa[4]) } } -PFLOAT voronoi_t::operator() (const point3d_t &pt) const +float voronoi_t::operator() (const point3d_t &pt) const { - PFLOAT da[4]; + float da[4]; point3d_t pa[4]; getFeatures(pt, da, pa); switch (vType) { @@ -558,7 +558,7 @@ PFLOAT voronoi_t::operator() (const point3d_t &pt) const case V_F2F1: return da[1]-da[0]; case V_CRACKLE: { - PFLOAT t = 10.0*(da[1]-da[0]); + float t = 10.0*(da[1]-da[0]); return (t>1.0)?1.0:t; } default: @@ -568,14 +568,14 @@ PFLOAT voronoi_t::operator() (const point3d_t &pt) const } // Cell noise -PFLOAT cellNoise_t::operator() (const point3d_t &pt) const +float cellNoise_t::operator() (const point3d_t &pt) const { int xi = (int)(floor(pt.x)); int yi = (int)(floor(pt.y)); int zi = (int)(floor(pt.z)); unsigned int n = xi + yi*1301 + zi*314159; n ^= (n<<13); - return ((PFLOAT)(n*(n*n*15731 + 789221) + 1376312589) / 4294967296.0); + return ((float)(n*(n*n*15731 + 789221) + 1376312589) / 4294967296.0); } //------------------------------------------------------------------------------------ @@ -593,16 +593,16 @@ PFLOAT cellNoise_t::operator() (const point3d_t &pt) const * ``lacunarity'' is the gap between successive frequencies * ``octaves'' is the number of frequencies in the fBm */ -PFLOAT fBm_t::operator() (const point3d_t &pt) const +float fBm_t::operator() (const point3d_t &pt) const { - PFLOAT value=0, pwr=1, pwHL=fPow(lacunarity, -H); + float value=0, pwr=1, pwHL=fPow(lacunarity, -H); point3d_t tp(pt); for (int i=0; i<(int)octaves; i++) { value += getSignedNoise(nGen, tp) * pwr; pwr *= pwHL; tp *= lacunarity; } - PFLOAT rmd = octaves - floor(octaves); + float rmd = octaves - floor(octaves); if (rmd!=0.f) value += rmd * getSignedNoise(nGen, tp) * pwr; return value; } @@ -621,17 +621,17 @@ PFLOAT fBm_t::operator() (const point3d_t &pt) const /* this one is in fact rather confusing, * there seem to be errors in the original source code (in all three versions of proc.text&mod), * I modified it to something that made sense to me, so it might be wrong... */ -PFLOAT mFractal_t::operator() (const point3d_t &pt) const +float mFractal_t::operator() (const point3d_t &pt) const { - PFLOAT value=1, pwr=1, pwHL=fPow(lacunarity, -H); + float value=1, pwr=1, pwHL=fPow(lacunarity, -H); point3d_t tp(pt); for (int i=0; i<(int)octaves; i++) { - value *= (pwr*getSignedNoise(nGen, tp) + (PFLOAT)1.0); + value *= (pwr*getSignedNoise(nGen, tp) + (float)1.0); pwr *= pwHL; tp *= lacunarity; } - PFLOAT rmd = octaves - floor(octaves); - if (rmd!=(PFLOAT)0.0) value *= (rmd * getSignedNoise(nGen, tp) * pwr + (PFLOAT)1.0); + float rmd = octaves - floor(octaves); + if (rmd!=(float)0.0) value *= (rmd * getSignedNoise(nGen, tp) * pwr + (float)1.0); return value; } @@ -646,16 +646,16 @@ PFLOAT mFractal_t::operator() (const point3d_t &pt) const * ``octaves'' is the number of frequencies in the fBm * ``offset'' raises the terrain from `sea level' */ -PFLOAT heteroTerrain_t::operator() (const point3d_t &pt) const +float heteroTerrain_t::operator() (const point3d_t &pt) const { - PFLOAT pwHL = fPow(lacunarity, -H); - PFLOAT pwr = pwHL; // starts with i=1 instead of 0 + float pwHL = fPow(lacunarity, -H); + float pwr = pwHL; // starts with i=1 instead of 0 point3d_t tp(pt); // first unscaled octave of function; later octaves are scaled - PFLOAT value = offset + getSignedNoise(nGen, tp); + float value = offset + getSignedNoise(nGen, tp); tp *= lacunarity; - PFLOAT increment; + float increment; for (int i=1; i<(int)octaves; i++) { increment = (getSignedNoise(nGen, tp) + offset) * pwr * value; value += increment; @@ -663,8 +663,8 @@ PFLOAT heteroTerrain_t::operator() (const point3d_t &pt) const tp *= lacunarity; } - PFLOAT rmd = octaves - floor(octaves); - if (rmd!=(PFLOAT)0.0) { + float rmd = octaves - floor(octaves); + if (rmd!=(float)0.0) { increment = (getSignedNoise(nGen, tp) + offset) * pwr * value; value += rmd * increment; } @@ -680,27 +680,27 @@ PFLOAT heteroTerrain_t::operator() (const point3d_t &pt) const * H: 0.25 * offset: 0.7 */ -PFLOAT hybridMFractal_t::operator() (const point3d_t &pt) const +float hybridMFractal_t::operator() (const point3d_t &pt) const { - PFLOAT pwHL = fPow(lacunarity, -H); - PFLOAT pwr = pwHL; // starts with i=1 instead of 0 + float pwHL = fPow(lacunarity, -H); + float pwr = pwHL; // starts with i=1 instead of 0 point3d_t tp(pt); - PFLOAT result = getSignedNoise(nGen, tp) + offset; - PFLOAT weight = gain * result; + float result = getSignedNoise(nGen, tp) + offset; + float weight = gain * result; tp *= lacunarity; - for (int i=1; (weight>(PFLOAT)0.001) && (i<(int)octaves); i++) { - if (weight>(PFLOAT)1.0) weight=(PFLOAT)1.0; - PFLOAT signal = (getSignedNoise(nGen, tp) + offset) * pwr; + for (int i=1; (weight>(float)0.001) && (i<(int)octaves); i++) { + if (weight>(float)1.0) weight=(float)1.0; + float signal = (getSignedNoise(nGen, tp) + offset) * pwr; pwr *= pwHL; result += weight * signal; weight *= gain * signal; tp *= lacunarity; } - PFLOAT rmd = octaves - floor(octaves); - if (rmd!=(PFLOAT)0.0) result += rmd * ((getSignedNoise(nGen, tp) + offset) * pwr); + float rmd = octaves - floor(octaves); + if (rmd!=(float)0.0) result += rmd * ((getSignedNoise(nGen, tp) + offset) * pwr); return result; @@ -715,21 +715,21 @@ PFLOAT hybridMFractal_t::operator() (const point3d_t &pt) const * offset: 1.0 * gain: 2.0 */ -PFLOAT ridgedMFractal_t::operator() (const point3d_t &pt) const +float ridgedMFractal_t::operator() (const point3d_t &pt) const { - PFLOAT pwHL = fPow(lacunarity, -H); - PFLOAT pwr = pwHL; // starts with i=1 instead of 0 + float pwHL = fPow(lacunarity, -H); + float pwr = pwHL; // starts with i=1 instead of 0 point3d_t tp(pt); - PFLOAT signal = offset - std::fabs(getSignedNoise(nGen, tp)); + float signal = offset - std::fabs(getSignedNoise(nGen, tp)); signal *= signal; - PFLOAT result = signal; - PFLOAT weight = 1.0; + float result = signal; + float weight = 1.0; for(int i=1; i<(int)octaves; i++ ) { tp *= lacunarity; weight = signal * gain; - if (weight>(PFLOAT)1.0) weight=(PFLOAT)1.0; else if (weight<(PFLOAT)0.0) weight=(PFLOAT)0.0; + if (weight>(float)1.0) weight=(float)1.0; else if (weight<(float)0.0) weight=(float)0.0; signal = offset - std::fabs(getSignedNoise(nGen, tp)); signal *= signal; signal *= weight; @@ -755,9 +755,9 @@ colorA_t cellNoiseColor(const point3d_t &pt) } // turbulence function used by basic blocks -CFLOAT turbulence(const noiseGenerator_t* ngen, const point3d_t &pt, int oct, PFLOAT size, bool hard) +float turbulence(const noiseGenerator_t* ngen, const point3d_t &pt, int oct, float size, bool hard) { - PFLOAT val, amp=1, sum=0; + float val, amp=1, sum=0; point3d_t tp = ngen->offset(pt)*size; // only blendernoise adds offset for (int i=0;i<=oct;i++, amp*=0.5, tp*=2.0) { val = (*ngen)(tp); @@ -765,7 +765,7 @@ CFLOAT turbulence(const noiseGenerator_t* ngen, const point3d_t &pt, int oct, PF sum += amp*val; } - return sum*((PFLOAT)(1<> (unsigned char *data,color_t &c) { - c.R= ((CFLOAT) data[0])/((CFLOAT)255); - c.G= ((CFLOAT) data[1])/((CFLOAT)255); - c.B= ((CFLOAT) data[2])/((CFLOAT)255); + c.R= ((float) data[0])/((float)255); + c.G= ((float) data[1])/((float)255); + c.B= ((float) data[2])/((float)255); } void operator << (unsigned char *data,const color_t &c) { -// data[0]=(char) (((c.R<(CFLOAT)0) ? 0 : ((c.R>(CFLOAT)1) ? 255 : (((CFLOAT)255)*c.R) )) ); -// data[1]=(char) (((c.G<(CFLOAT)0) ? 0 : ((c.G>(CFLOAT)1) ? 255 : (((CFLOAT)255)*c.G) )) ); -// data[2]=(char) (((c.B<(CFLOAT)0) ? 0 : ((c.B>(CFLOAT)1) ? 255 : (((CFLOAT)255)*c.B) )) ); +// data[0]=(char) (((c.R<(float)0) ? 0 : ((c.R>(float)1) ? 255 : (((float)255)*c.R) )) ); +// data[1]=(char) (((c.G<(float)0) ? 0 : ((c.G>(float)1) ? 255 : (((float)255)*c.G) )) ); +// data[2]=(char) (((c.B<(float)0) ? 0 : ((c.B>(float)1) ? 255 : (((float)255)*c.B) )) ); data[0]= (c.R<0.f) ? 0 : ((c.R>=1.f) ? 255 : (unsigned char)(255.f*c.R) ); data[1]= (c.G<0.f) ? 0 : ((c.G>=1.f) ? 255 : (unsigned char)(255.f*c.G) ); data[2]= (c.B<0.f) ? 0 : ((c.B>=1.f) ? 255 : (unsigned char)(255.f*c.B) ); @@ -44,19 +44,19 @@ void operator << (unsigned char *data,const color_t &c) void operator >> (unsigned char *data,colorA_t &c) { - c.R = ((CFLOAT) data[0])/((CFLOAT)255); - c.G = ((CFLOAT) data[1])/((CFLOAT)255); - c.B = ((CFLOAT) data[2])/((CFLOAT)255); - c.A = ((CFLOAT) data[3])/((CFLOAT)255); + c.R = ((float) data[0])/((float)255); + c.G = ((float) data[1])/((float)255); + c.B = ((float) data[2])/((float)255); + c.A = ((float) data[3])/((float)255); } void operator << (unsigned char *data,const colorA_t &c) { -// data[0]=(char) (((c.R<(CFLOAT)0) ? 0 : ((c.R>(CFLOAT)1) ? 255 : (((CFLOAT)255)*c.R) )) ); -// data[1]=(char) (((c.G<(CFLOAT)0) ? 0 : ((c.G>(CFLOAT)1) ? 255 : (((CFLOAT)255)*c.G) )) ); -// data[2]=(char) (((c.B<(CFLOAT)0) ? 0 : ((c.B>(CFLOAT)1) ? 255 : (((CFLOAT)255)*c.B) )) ); -// data[3]=(char) (((c.A<(CFLOAT)0) ? 0 : ((c.A>(CFLOAT)1) ? 255 : (((CFLOAT)255)*c.A) )) ); +// data[0]=(char) (((c.R<(float)0) ? 0 : ((c.R>(float)1) ? 255 : (((float)255)*c.R) )) ); +// data[1]=(char) (((c.G<(float)0) ? 0 : ((c.G>(float)1) ? 255 : (((float)255)*c.G) )) ); +// data[2]=(char) (((c.B<(float)0) ? 0 : ((c.B>(float)1) ? 255 : (((float)255)*c.B) )) ); +// data[3]=(char) (((c.A<(float)0) ? 0 : ((c.A>(float)1) ? 255 : (((float)255)*c.A) )) ); data[0]= (c.R<0.f) ? 0 : ((c.R>=1.f) ? 255 : (unsigned char)(255.f*c.R) ); data[1]= (c.G<0.f) ? 0 : ((c.G>=1.f) ? 255 : (unsigned char)(255.f*c.G) ); data[2]= (c.B<0.f) ? 0 : ((c.B>=1.f) ? 255 : (unsigned char)(255.f*c.B) ); @@ -107,7 +107,7 @@ ostream & operator << (ostream & out,const colorA_t c) return out; } -color_t mix(const color_t &a,const color_t &b,CFLOAT point) +color_t mix(const color_t &a,const color_t &b,float point) { if(point<=0.0) return b; if(point>=1.0) return a; @@ -115,7 +115,7 @@ color_t mix(const color_t &a,const color_t &b,CFLOAT point) return ( a*point + (1-point)*b ); } -colorA_t mix(const colorA_t &a,const colorA_t &b,CFLOAT point) +colorA_t mix(const colorA_t &a,const colorA_t &b,float point) { if(point<=0.0) return b; if(point>=1.0) return a; @@ -125,17 +125,17 @@ colorA_t mix(const colorA_t &a,const colorA_t &b,CFLOAT point) color_t convergenceAccell(const color_t &cn_1,const color_t &cn0,const color_t &cn1) { - CFLOAT r=(cn1.R-2.0*cn0.R+cn_1.R); + float r=(cn1.R-2.0*cn0.R+cn_1.R); if(r!=0.0) r=cn1.R - ((cn1.R-cn0.R)*(cn1.R-cn0.R))/r; else r=cn1.R; - CFLOAT g=(cn1.G-2.0*cn0.G+cn_1.G); + float g=(cn1.G-2.0*cn0.G+cn_1.G); if(g!=0.0) g=cn1.G - ((cn1.G-cn0.G)*(cn1.G-cn0.G))/g; else g=cn1.G; - CFLOAT b=(cn1.B-2.0*cn0.B+cn_1.B); + float b=(cn1.B-2.0*cn0.B+cn_1.B); if(b!=0.0) b=cn1.B - ((cn1.B-cn0.B)*(cn1.B-cn0.B))/b; else @@ -146,7 +146,7 @@ color_t convergenceAccell(const color_t &cn_1,const color_t &cn0,const color_t & rgbe_t::rgbe_t(const color_t &s) { - CFLOAT v = s.getR(); + float v = s.getR(); if (s.getG() > v) v = s.getG(); if (s.getB() > v) v = s.getB(); if (v<1e-32f) diff --git a/src/yafraycore/gboundtree.h b/src/yafraycore/gboundtree.h index 5561cc57..ed42db72 100755 --- a/src/yafraycore/gboundtree.h +++ b/src/yafraycore/gboundtree.h @@ -55,7 +55,7 @@ gBoundTreeNode_t * buildGenericTree(const std::vector &v, //typedef typename std::vector::const_iterator vector_const_iterator; //FIXME DAVID remove if not needed if((v.size()<=dratio) || (skipX && skipY && skipZ)) return new gBoundTreeNode_t(v,calc_bound(v)); - PFLOAT lx,ly,lz; + float lx,ly,lz; bool usedX=false,usedY=false,usedZ=false; bound_t bound=calc_bound(v); lx=bound.longX(); @@ -65,30 +65,30 @@ gBoundTreeNode_t * buildGenericTree(const std::vector &v, bound_t bl,br; if(((lx>=ly) || skipY) && ((lx>=lz) || skipZ) && !skipX) { - PFLOAT media=0; + float media=0; for(auto i=v.begin();i!=v.end();++i) media+=get_pos(*i).x; - media/=(PFLOAT)v.size(); + media/=(float)v.size(); bl=bound;bl.setMaxX(media); br=bound;br.setMinX(media); usedX=true; } else if(((ly>=lx) || skipX) && ((ly>=lz) || skipZ) && !skipY) { - PFLOAT media=0; + float media=0; for(auto i=v.begin();i!=v.end();++i) media+=get_pos(*i).y; - media/=(PFLOAT)v.size(); + media/=(float)v.size(); bl=bound;bl.setMaxY(media); br=bound;br.setMinY(media); usedY=true; } else { - PFLOAT media=0; + float media=0; for(auto i=v.begin();i!=v.end();++i) media+=get_pos(*i).z; - media/=(PFLOAT)v.size(); + media/=(float)v.size(); bl=bound;bl.setMaxZ(media); br=bound;br.setMinZ(media); usedZ=true; @@ -151,7 +151,7 @@ class gObjectIterator_t const gBoundTreeNode_t *currN; const gBoundTreeNode_t *root; const D &dir; - PFLOAT dist; + float dist; bool end; CROSS cross; typename std::vector::const_iterator currT; @@ -304,13 +304,13 @@ class gBoundTree_t } ~gBoundTree_t(){ if(tree!=nullptr) delete tree; } - lookup(const point3d_t &P,const vector3d_t &N, std::vector &found, unsigned int K,PFLOAT &radius,PFLOAT mincos)const; + lookup(const point3d_t &P,const vector3d_t &N, std::vector &found, unsigned int K,float &radius,float mincos)const; private: gBoundTreeNode_t *tree; } template -gBoundTree_t::lookup(const point3d_t &P,const vector3d_t &N, std::vector &found, unsigned int K,PFLOAT &radius,PFLOAT mincos)const +gBoundTree_t::lookup(const point3d_t &P,const vector3d_t &N, std::vector &found, unsigned int K,float &radius,float mincos)const { foundPhoton_t temp; compareFound_f cfound; @@ -326,7 +326,7 @@ gBoundTree_t::lookup(const point3d_t &P,const vector3d_t &N, std::vectorposition()-P; - CFLOAT D=sep.length(); + float D=sep.length(); if((D>radius) || (((*i)->direction()*N)<=mincos)) continue; reached++; temp.photon=*i; @@ -349,7 +349,7 @@ gBoundTree_t::lookup(const point3d_t &P,const vector3d_t &N, std::vectorK) { - PFLOAT f=(PFLOAT)K/(PFLOAT)reached; + float f=(float)K/(float)reached; if(f<(0.7*0.7)) radius*=0.95; } if(radius>maxradius) radius=maxradius; diff --git a/src/yafraycore/hashgrid.cc b/src/yafraycore/hashgrid.cc index 4a737d7c..d9b1d786 100755 --- a/src/yafraycore/hashgrid.cc +++ b/src/yafraycore/hashgrid.cc @@ -74,10 +74,10 @@ void hashGrid_t::updateGrid() Y_VERBOSE<<"HashGrid: there are " << notused << " enties not used!"<resX(); diffRay_t c_ray; ray_t d_ray; - PFLOAT dx=0.5, dy=0.5, d1=1.0/(PFLOAT)n_samples; + float dx=0.5, dy=0.5, d1=1.0/(float)n_samples; float lens_u=0.5f, lens_v=0.5f; - PFLOAT wt, wt_dummy; + float wt, wt_dummy; random_t prng(offset*(x*a.Y+a.X)+123); renderState_t rstate(&prng); rstate.threadID = threadID; @@ -353,7 +353,7 @@ bool tiledIntegrator_t::renderTile(int numView, renderArea_t &a, int n_samples, colorPasses.reset_colors(); rstate.setDefaults(); rstate.pixelSample = pass_offs+sample; - rstate.time = addMod1((PFLOAT)sample*d1, toff);//(0.5+(PFLOAT)sample)*d1; + rstate.time = addMod1((float)sample*d1, toff);//(0.5+(float)sample)*d1; // the (1/n, Larcher&Pillichshammer-Seq.) only gives good coverage when total sample count is known // hence we use scrambled (Sobol, van-der-Corput) for multipass AA @@ -364,7 +364,7 @@ bool tiledIntegrator_t::renderTile(int numView, renderArea_t &a, int n_samples, } else if(n_samples > 1) { - dx = (0.5+(PFLOAT)sample)*d1; + dx = (0.5+(float)sample)*d1; dy = RI_LP(sample+rstate.samplingOffs); } diff --git a/src/yafraycore/kdtree.cc b/src/yafraycore/kdtree.cc index 5b54f4a2..3eacf231 100755 --- a/src/yafraycore/kdtree.cc +++ b/src/yafraycore/kdtree.cc @@ -152,20 +152,20 @@ triKdTree_t::~triKdTree_t() void triKdTree_t::pigeonMinCost(u_int32 nPrims, bound_t &nodeBound, u_int32 *primIdx, splitCost_t &split) { bin_t bin[ KD_BINS+1 ]; - PFLOAT d[3]; + float d[3]; d[0] = nodeBound.longX(); d[1] = nodeBound.longY(); d[2] = nodeBound.longZ(); split.oldCost = float(nPrims); - split.bestCost = std::numeric_limits::infinity(); + split.bestCost = std::numeric_limits::infinity(); float invTotalSA = 1.0f / (d[0]*d[1] + d[0]*d[2] + d[1]*d[2]); - PFLOAT t_low, t_up; + float t_low, t_up; int b_left, b_right; for(int axis=0;axis<3;axis++) { - PFLOAT s = KD_BINS/d[axis]; - PFLOAT min = nodeBound.a[axis]; + float s = KD_BINS/d[axis]; + float min = nodeBound.a[axis]; // pigeonhole sort: for(unsigned int i=0; i nodeBound.a[axis] && edget < nodeBound.g[axis]) { // Compute cost for split at _i_th edge @@ -301,12 +301,12 @@ void triKdTree_t::pigeonMinCost(u_int32 nPrims, bound_t &nodeBound, u_int32 *pri void triKdTree_t::minimalCost(u_int32 nPrims, bound_t &nodeBound, u_int32 *primIdx, const bound_t *pBounds, boundEdge *edges[3], splitCost_t &split) { - PFLOAT d[3]; + float d[3]; d[0] = nodeBound.longX(); d[1] = nodeBound.longY(); d[2] = nodeBound.longZ(); split.oldCost = float(nPrims); - split.bestCost = std::numeric_limits::infinity(); + split.bestCost = std::numeric_limits::infinity(); float invTotalSA = 1.0f / (d[0]*d[1] + d[0]*d[2] + d[1]*d[2]); int nEdge; @@ -357,7 +357,7 @@ void triKdTree_t::minimalCost(u_int32 nPrims, bound_t &nodeBound, u_int32 *primI //todo: early-out criteria: if l1 > l2*nPrims (l2 > l1*nPrims) => minimum is lowest (highest) edge! if(nPrims>5) { - PFLOAT edget = edges[axis][0].pos; + float edget = edges[axis][0].pos; float l1 = edget - nodeBound.a[axis]; float l2 = nodeBound.g[axis] - edget; if(l1 > l2*float(nPrims) && l2 > 0.f) @@ -394,7 +394,7 @@ void triKdTree_t::minimalCost(u_int32 nPrims, bound_t &nodeBound, u_int32 *primI for (int i = 0; i < nEdge; ++i) { if (edges[axis][i].end == UPPER_B) --nAbove; - PFLOAT edget = edges[axis][i].pos; + float edget = edges[axis][i].pos; if (edget > nodeBound.a[axis] && edget < nodeBound.g[axis]) { // Compute cost for split at _i_th edge @@ -533,7 +533,7 @@ int triKdTree_t::buildTree(u_int32 nPrims, bound_t &nodeBound, u_int32 *primNums } // Classify primitives with respect to split - PFLOAT splitPos; + float splitPos; int n0 = 0, n1 = 0; if(nPrims > 128) // we did pigeonhole { @@ -652,11 +652,11 @@ int triKdTree_t::buildTree(u_int32 nPrims, bound_t &nodeBound, u_int32 *primNums returns the closest hit within dist */ -bool triKdTree_t::Intersect(const ray_t &ray, PFLOAT dist, triangle_t **tr, PFLOAT &Z, intersectData_t &data) const +bool triKdTree_t::Intersect(const ray_t &ray, float dist, triangle_t **tr, float &Z, intersectData_t &data) const { Z=dist; - PFLOAT a, b, t; // entry/exit/splitting plane signed distance - PFLOAT t_hit; + float a, b, t; // entry/exit/splitting plane signed distance + float t_hit; if( !treeBound.cross(ray, a, b, dist) ) { return false; } @@ -691,7 +691,7 @@ bool triKdTree_t::Intersect(const ray_t &ray, PFLOAT dist, triangle_t **tr, PFLO while( !currNode->IsLeaf() ) { int axis = currNode->SplitAxis(); - PFLOAT splitVal = currNode->SplitPos(); + float splitVal = currNode->SplitPos(); if(stack[enPt].pb[axis] <= splitVal){ if(stack[exPt].pb[axis] <= splitVal) @@ -807,10 +807,10 @@ bool triKdTree_t::Intersect(const ray_t &ray, PFLOAT dist, triangle_t **tr, PFLO } -bool triKdTree_t::IntersectS(const ray_t &ray, PFLOAT dist, triangle_t **tr, PFLOAT shadow_bias) const +bool triKdTree_t::IntersectS(const ray_t &ray, float dist, triangle_t **tr, float shadow_bias) const { - PFLOAT a, b, t; // entry/exit/splitting plane signed distance - PFLOAT t_hit; + float a, b, t; // entry/exit/splitting plane signed distance + float t_hit; if (!treeBound.cross(ray, a, b, dist)) return false; @@ -846,7 +846,7 @@ bool triKdTree_t::IntersectS(const ray_t &ray, PFLOAT dist, triangle_t **tr, PFL while( !currNode->IsLeaf() ) { int axis = currNode->SplitAxis(); - PFLOAT splitVal = currNode->SplitPos(); + float splitVal = currNode->SplitPos(); if(stack[enPt].pb[axis] <= splitVal) { @@ -950,10 +950,10 @@ bool triKdTree_t::IntersectS(const ray_t &ray, PFLOAT dist, triangle_t **tr, PFL allow for transparent shadows. =============================================================*/ -bool triKdTree_t::IntersectTS(renderState_t &state, const ray_t &ray, int maxDepth, PFLOAT dist, triangle_t **tr, color_t &filt, PFLOAT shadow_bias) const +bool triKdTree_t::IntersectTS(renderState_t &state, const ray_t &ray, int maxDepth, float dist, triangle_t **tr, color_t &filt, float shadow_bias) const { - PFLOAT a, b, t; // entry/exit/splitting plane signed distance - PFLOAT t_hit; + float a, b, t; // entry/exit/splitting plane signed distance + float t_hit; if (!treeBound.cross(ray, a, b, dist)) return false; @@ -995,7 +995,7 @@ bool triKdTree_t::IntersectTS(renderState_t &state, const ray_t &ray, int maxDep while( !currNode->IsLeaf() ) { int axis = currNode->SplitAxis(); - PFLOAT splitVal = currNode->SplitPos(); + float splitVal = currNode->SplitPos(); if(stack[enPt].pb[axis] <= splitVal){ if(stack[exPt].pb[axis] <= splitVal) diff --git a/src/yafraycore/material.cc b/src/yafraycore/material.cc index 001ab43f..95e8d5b2 100755 --- a/src/yafraycore/material.cc +++ b/src/yafraycore/material.cc @@ -38,8 +38,8 @@ bool material_t::scatterPhoton(const renderState_t &state, const surfacePoint_t if(s.pdf > 1.0e-6f) { color_t cnew = s.lcol * s.alpha * scol * W; - CFLOAT new_max = cnew.maximum(); - CFLOAT old_max = s.lcol.maximum(); + float new_max = cnew.maximum(); + float old_max = s.lcol.maximum(); float prob = std::min(1.f, new_max/old_max); if(s.s3 <= prob && prob > 1e-4f) { @@ -71,7 +71,7 @@ color_t material_t::getReflectivity(const renderState_t &state, const surfacePoi } -void material_t::applyBump(surfacePoint_t &sp, PFLOAT dfdNU, PFLOAT dfdNV) const +void material_t::applyBump(surfacePoint_t &sp, float dfdNU, float dfdNV) const { sp.NU += dfdNU * sp.N; sp.NV += dfdNV * sp.N; diff --git a/src/yafraycore/matrix4.cc b/src/yafraycore/matrix4.cc index 2211c743..cb97a5f6 100755 --- a/src/yafraycore/matrix4.cc +++ b/src/yafraycore/matrix4.cc @@ -27,13 +27,13 @@ using namespace std; __BEGIN_YAFRAY -matrix4x4_t::matrix4x4_t(const PFLOAT init):_invalid(0) +matrix4x4_t::matrix4x4_t(const float init):_invalid(0) { for(int i=0;i<4;i++) for(int j=0;j<4;++j) { if(i==j) - matrix[i][j]=(PFLOAT)init; + matrix[i][j]=(float)init; else matrix[i][j]=0; } @@ -74,7 +74,7 @@ matrix4x4_t & matrix4x4_t::inverse() matrix4x4_t iden(1); for(int i=0;i<4;++i) { - PFLOAT max=0; + float max=0; int ci=0; for(int k=i;k<4;++k) { @@ -91,7 +91,7 @@ matrix4x4_t & matrix4x4_t::inverse() _invalid=1; } SWAP(matrix,i,ci);SWAP(iden,i,ci); - PFLOAT factor=matrix[i][i]; + float factor=matrix[i][i]; DIV(matrix,i,factor);DIV(iden,i,factor); for(int k=0;k<4;++k) { @@ -116,7 +116,7 @@ matrix4x4_t & matrix4x4_t::transpose() return *this; } -void matrix4x4_t::translate(PFLOAT dx,PFLOAT dy,PFLOAT dz) +void matrix4x4_t::translate(float dx,float dy,float dz) { matrix4x4_t aux(1); @@ -127,12 +127,12 @@ void matrix4x4_t::translate(PFLOAT dx,PFLOAT dy,PFLOAT dz) (*this)=aux*(*this); } -void matrix4x4_t::rotateZ(PFLOAT degrees) +void matrix4x4_t::rotateZ(float degrees) { - PFLOAT temp=degrees; - temp=fmod(temp,(PFLOAT)360.0); - if(temp<0) temp=((PFLOAT)360.0)-temp; - temp=temp*( M_PI/((PFLOAT)180)); + float temp=degrees; + temp=fmod(temp,(float)360.0); + if(temp<0) temp=((float)360.0)-temp; + temp=temp*( M_PI/((float)180)); matrix4x4_t aux(1); aux[0][0]=fCos(temp); @@ -143,12 +143,12 @@ void matrix4x4_t::rotateZ(PFLOAT degrees) (*this)=aux*(*this); } -void matrix4x4_t::rotateX(PFLOAT degrees) +void matrix4x4_t::rotateX(float degrees) { - PFLOAT temp=degrees; - temp=fmod(temp,(PFLOAT)360.0); - if(temp<0) temp=((PFLOAT)360.0)-temp; - temp=temp*( M_PI/((PFLOAT)180)); + float temp=degrees; + temp=fmod(temp,(float)360.0); + if(temp<0) temp=((float)360.0)-temp; + temp=temp*( M_PI/((float)180)); matrix4x4_t aux(1); aux[1][1]=fCos(temp); @@ -159,12 +159,12 @@ void matrix4x4_t::rotateX(PFLOAT degrees) (*this)=aux*(*this); } -void matrix4x4_t::rotateY(PFLOAT degrees) +void matrix4x4_t::rotateY(float degrees) { - PFLOAT temp=degrees; - temp=fmod(temp,(PFLOAT)360.0); - if(temp<0) temp=((PFLOAT)360.0)-temp; - temp=temp*( M_PI/((PFLOAT)180)); + float temp=degrees; + temp=fmod(temp,(float)360.0); + if(temp<0) temp=((float)360.0)-temp; + temp=temp*( M_PI/((float)180)); matrix4x4_t aux(1); aux[0][0]=fCos(temp); @@ -176,7 +176,7 @@ void matrix4x4_t::rotateY(PFLOAT degrees) } -void matrix4x4_t::scale(PFLOAT sx, PFLOAT sy, PFLOAT sz) +void matrix4x4_t::scale(float sx, float sy, float sz) { matrix[0][0]*=sx; matrix[1][0]*=sx; matrix[2][0]*=sx; matrix[0][1]*=sy; matrix[1][1]*=sy; matrix[2][1]*=sy; diff --git a/src/yafraycore/nodematerial.cc b/src/yafraycore/nodematerial.cc index 05d604b5..26c51e45 100755 --- a/src/yafraycore/nodematerial.cc +++ b/src/yafraycore/nodematerial.cc @@ -107,7 +107,7 @@ void nodeMaterial_t::evalBump(nodeStack_t &stack, const renderState_t &state, su { auto end=bumpNodes.end(); for(auto iter = bumpNodes.begin(); iter!=end; ++iter) (*iter)->evalDerivative(stack, state, sp); - CFLOAT du, dv; + float du, dv; bumpS->getDerivative(stack, du, dv); applyBump(sp, du, dv); } diff --git a/src/yafraycore/photon.cc b/src/yafraycore/photon.cc index 0f8b01b0..64f9e647 100755 --- a/src/yafraycore/photon.cc +++ b/src/yafraycore/photon.cc @@ -9,13 +9,13 @@ dirConverter_t::dirConverter_t() { for(int i=0;i<255;++i) { - PFLOAT angle=(PFLOAT)i * cInv255Ratio; + float angle=(float)i * cInv255Ratio; costheta[i]=fCos(angle); sintheta[i]=fSin(angle); } for(int i=0;i<256;++i) { - PFLOAT angle=(PFLOAT)i * cInv256Ratio; + float angle=(float)i * cInv256Ratio; cosphi[i]=fCos(angle); sinphi[i]=fSin(angle); } @@ -28,7 +28,7 @@ photonGather_t::photonGather_t(u_int32 mp, const point3d_t &P): p(P) foundPhotons = 0; } -void photonGather_t::operator()(const photon_t *photon, PFLOAT dist2, PFLOAT &maxDistSquared) const +void photonGather_t::operator()(const photon_t *photon, float dist2, float &maxDistSquared) const { // Do usual photon heap management if (foundPhotons < nLookup) { @@ -115,7 +115,7 @@ void photonMap_t::updateTree() else tree=0; } -int photonMap_t::gather(const point3d_t &P, foundPhoton_t *found, unsigned int K, PFLOAT &sqRadius) const +int photonMap_t::gather(const point3d_t &P, foundPhoton_t *found, unsigned int K, float &sqRadius) const { photonGather_t proc(K, P); proc.photons = found; @@ -123,10 +123,10 @@ int photonMap_t::gather(const point3d_t &P, foundPhoton_t *found, unsigned int K return proc.foundPhotons; } -const photon_t* photonMap_t::findNearest(const point3d_t &P, const vector3d_t &n, PFLOAT dist) const +const photon_t* photonMap_t::findNearest(const point3d_t &P, const vector3d_t &n, float dist) const { nearestPhoton_t proc(P, n); - //PFLOAT dist=std::numeric_limits::infinity(); //really bad idea... + //float dist=std::numeric_limits::infinity(); //really bad idea... tree->lookup(P, proc, dist); return proc.nearest; } diff --git a/src/yafraycore/ray_kdtree.cc b/src/yafraycore/ray_kdtree.cc index 39eafdef..4abfd8fa 100755 --- a/src/yafraycore/ray_kdtree.cc +++ b/src/yafraycore/ray_kdtree.cc @@ -169,20 +169,20 @@ template void kdTree_t::pigeonMinCost(u_int32 nPrims, bound_t &nodeBound, u_int32 *primIdx, splitCost_t &split) { bin_t bin[ KD_BINS+1 ]; - PFLOAT d[3]; + float d[3]; d[0] = nodeBound.longX(); d[1] = nodeBound.longY(); d[2] = nodeBound.longZ(); split.oldCost = float(nPrims); - split.bestCost = std::numeric_limits::infinity(); + split.bestCost = std::numeric_limits::infinity(); float invTotalSA = 1.0f / (d[0]*d[1] + d[0]*d[2] + d[1]*d[2]); - PFLOAT t_low, t_up; + float t_low, t_up; int b_left, b_right; for(int axis=0;axis<3;axis++) { - PFLOAT s = KD_BINS/d[axis]; - PFLOAT min = nodeBound.a[axis]; + float s = KD_BINS/d[axis]; + float min = nodeBound.a[axis]; // pigeonhole sort: for(unsigned int i=0; i::pigeonMinCost(u_int32 nPrims, bound_t &nodeBound, u_int32 *pri nBelow += bin[i].c_left; nAbove -= bin[i].c_right; // cost: - PFLOAT edget = bin[i].t; + float edget = bin[i].t; if (edget > nodeBound.a[axis] && edget < nodeBound.g[axis]) { // Compute cost for split at _i_th edge @@ -314,12 +314,12 @@ template void kdTree_t::minimalCost(u_int32 nPrims, bound_t &nodeBound, u_int32 *primIdx, const bound_t *pBounds, boundEdge *edges[3], splitCost_t &split) { - PFLOAT d[3]; + float d[3]; d[0] = nodeBound.longX(); d[1] = nodeBound.longY(); d[2] = nodeBound.longZ(); split.oldCost = float(nPrims); - split.bestCost = std::numeric_limits::infinity(); + split.bestCost = std::numeric_limits::infinity(); float invTotalSA = 1.0f / (d[0]*d[1] + d[0]*d[2] + d[1]*d[2]); int nEdge; @@ -370,7 +370,7 @@ void kdTree_t::minimalCost(u_int32 nPrims, bound_t &nodeBound, u_int32 *primI //todo: early-out criteria: if l1 > l2*nPrims (l2 > l1*nPrims) => minimum is lowest (highest) edge! if(nPrims>5) { - PFLOAT edget = edges[axis][0].pos; + float edget = edges[axis][0].pos; float l1 = edget - nodeBound.a[axis]; float l2 = nodeBound.g[axis] - edget; if(l1 > l2*float(nPrims) && l2 > 0.f) @@ -407,7 +407,7 @@ void kdTree_t::minimalCost(u_int32 nPrims, bound_t &nodeBound, u_int32 *primI for (int i = 0; i < nEdge; ++i) { if (edges[axis][i].end == UPPER_B) --nAbove; - PFLOAT edget = edges[axis][i].pos; + float edget = edges[axis][i].pos; if (edget > nodeBound.a[axis] && edget < nodeBound.g[axis]) { // Compute cost for split at _i_th edge @@ -563,7 +563,7 @@ int kdTree_t::buildTree(u_int32 nPrims, bound_t &nodeBound, u_int32 *primNums } // Classify primitives with respect to split - PFLOAT splitPos; + float splitPos; int n0 = 0, n1 = 0; if(nPrims > 128) // we did pigeonhole { @@ -688,12 +688,12 @@ int kdTree_t::buildTree(u_int32 nPrims, bound_t &nodeBound, u_int32 *primNums returns the closest hit within dist */ template -bool kdTree_t::Intersect(const ray_t &ray, PFLOAT dist, T **tr, PFLOAT &Z, intersectData_t &data) const +bool kdTree_t::Intersect(const ray_t &ray, float dist, T **tr, float &Z, intersectData_t &data) const { Z=dist; - PFLOAT a, b, t; // entry/exit/splitting plane signed distance - PFLOAT t_hit; + float a, b, t; // entry/exit/splitting plane signed distance + float t_hit; if (!treeBound.cross(ray, a, b, dist)) { return false; } @@ -730,7 +730,7 @@ bool kdTree_t::Intersect(const ray_t &ray, PFLOAT dist, T **tr, PFLOAT &Z, in while( !currNode->IsLeaf() ) { int axis = currNode->SplitAxis(); - PFLOAT splitVal = currNode->SplitPos(); + float splitVal = currNode->SplitPos(); if(stack[enPt].pb[axis] <= splitVal){ if(stack[exPt].pb[axis] <= splitVal) @@ -830,10 +830,10 @@ bool kdTree_t::Intersect(const ray_t &ray, PFLOAT dist, T **tr, PFLOAT &Z, in } template -bool kdTree_t::IntersectS(const ray_t &ray, PFLOAT dist, T **tr, PFLOAT shadow_bias) const +bool kdTree_t::IntersectS(const ray_t &ray, float dist, T **tr, float shadow_bias) const { - PFLOAT a, b, t; // entry/exit/splitting plane signed distance - PFLOAT t_hit; + float a, b, t; // entry/exit/splitting plane signed distance + float t_hit; if (!treeBound.cross(ray, a, b, dist)) return false; @@ -868,7 +868,7 @@ bool kdTree_t::IntersectS(const ray_t &ray, PFLOAT dist, T **tr, PFLOAT shado while( !currNode->IsLeaf() ) { int axis = currNode->SplitAxis(); - PFLOAT splitVal = currNode->SplitPos(); + float splitVal = currNode->SplitPos(); if(stack[enPt].pb[axis] <= splitVal){ if(stack[exPt].pb[axis] <= splitVal) @@ -962,10 +962,10 @@ bool kdTree_t::IntersectS(const ray_t &ray, PFLOAT dist, T **tr, PFLOAT shado =============================================================*/ template -bool kdTree_t::IntersectTS(renderState_t &state, const ray_t &ray, int maxDepth, PFLOAT dist, T **tr, color_t &filt, PFLOAT shadow_bias) const +bool kdTree_t::IntersectTS(renderState_t &state, const ray_t &ray, int maxDepth, float dist, T **tr, color_t &filt, float shadow_bias) const { - PFLOAT a, b, t; // entry/exit/splitting plane signed distance - PFLOAT t_hit; + float a, b, t; // entry/exit/splitting plane signed distance + float t_hit; if (!treeBound.cross(ray, a, b, dist)) return false; @@ -1006,7 +1006,7 @@ bool kdTree_t::IntersectTS(renderState_t &state, const ray_t &ray, int maxDep while( !currNode->IsLeaf() ) { int axis = currNode->SplitAxis(); - PFLOAT splitVal = currNode->SplitPos(); + float splitVal = currNode->SplitPos(); if(stack[enPt].pb[axis] <= splitVal){ if(stack[exPt].pb[axis] <= splitVal) diff --git a/src/yafraycore/renderpasses.cc b/src/yafraycore/renderpasses.cc index b4ac6454..5df69ba4 100755 --- a/src/yafraycore/renderpasses.cc +++ b/src/yafraycore/renderpasses.cc @@ -444,7 +444,7 @@ colorA_t colorPasses_t::probe_mult(const intPassTypes_t& intPassType, const colo else return colorA_t(0.f); } -colorPasses_t & colorPasses_t::operator *= (CFLOAT f) +colorPasses_t & colorPasses_t::operator *= (float f) { for(auto it = colVector.begin(); it != colVector.end(); ++it) { diff --git a/src/yafraycore/scene.cc b/src/yafraycore/scene.cc index 3e456777..efd1f0a1 100755 --- a/src/yafraycore/scene.cc +++ b/src/yafraycore/scene.cc @@ -93,7 +93,7 @@ int scene_t::getSignals() const return sig; } -void scene_t::getAAParameters(int &samples, int &passes, int &inc_samples, CFLOAT &threshold, float &resampled_floor, float &sample_multiplier_factor, float &light_sample_multiplier_factor, float &indirect_sample_multiplier_factor, bool &detect_color_noise, int &dark_detection_type, float &dark_threshold_factor, int &variance_edge_size, int &variance_pixels, float &clamp_samples, float &clamp_indirect) const +void scene_t::getAAParameters(int &samples, int &passes, int &inc_samples, float &threshold, float &resampled_floor, float &sample_multiplier_factor, float &light_sample_multiplier_factor, float &indirect_sample_multiplier_factor, bool &detect_color_noise, int &dark_detection_type, float &dark_threshold_factor, int &variance_edge_size, int &variance_pixels, float &clamp_samples, float &clamp_indirect) const { samples = AA_samples; passes = AA_passes; @@ -424,7 +424,7 @@ void scene_t::setNumThreadsPhotons(int threads_photons) #define prepareEdges(q, v1, v2) e1 = vertices[v1] - vertices[q]; \ e2 = vertices[v2] - vertices[q]; -bool scene_t::smoothMesh(objID_t id, PFLOAT angle) +bool scene_t::smoothMesh(objID_t id, float angle) { if( state.stack.front() != GEOMETRY ) return false; objData_t *odat; @@ -490,7 +490,7 @@ bool scene_t::smoothMesh(objID_t id, PFLOAT angle) } else if(angle>0.1)// angle dependant smoothing { - PFLOAT thresh = fCos(degToRad(angle)); + float thresh = fCos(degToRad(angle)); std::vector vnormals; std::vector vn_index; // create list of faces that include given vertex @@ -804,7 +804,7 @@ void scene_t::setAntialiasing(int numSamples, int numPasses, int incSamples, dou AA_samples = std::max(1, numSamples); AA_passes = numPasses; AA_inc_samples = (incSamples > 0) ? incSamples : AA_samples; - AA_threshold = (CFLOAT)threshold; + AA_threshold = (float)threshold; AA_resampled_floor = resampled_floor; AA_sample_multiplier_factor = sample_multiplier_factor; AA_light_sample_multiplier_factor = light_sample_multiplier_factor; @@ -936,9 +936,9 @@ bool scene_t::update() bool scene_t::intersect(const ray_t &ray, surfacePoint_t &sp) const { - PFLOAT dis, Z; + float dis, Z; intersectData_t data; - if(ray.tmax<0) dis=std::numeric_limits::infinity(); + if(ray.tmax<0) dis=std::numeric_limits::infinity(); else dis=ray.tmax; // intersect with tree: if(mode == 0) @@ -969,8 +969,8 @@ bool scene_t::isShadowed(renderState_t &state, const ray_t &ray, float &obj_inde ray_t sray(ray); sray.from += sray.dir * sray.tmin; sray.time = state.time; - PFLOAT dis; - if(ray.tmax<0) dis=std::numeric_limits::infinity(); + float dis; + if(ray.tmax<0) dis=std::numeric_limits::infinity(); else dis = sray.tmax - 2*sray.tmin; if(mode==0) { @@ -1001,8 +1001,8 @@ bool scene_t::isShadowed(renderState_t &state, const ray_t &ray, int maxDepth, c { ray_t sray(ray); sray.from += sray.dir * sray.tmin; - PFLOAT dis; - if(ray.tmax<0) dis=std::numeric_limits::infinity(); + float dis; + if(ray.tmax<0) dis=std::numeric_limits::infinity(); else dis = sray.tmax - 2*sray.tmin; filt = color_t(1.0); void *odat = state.userdata; diff --git a/src/yafraycore/spectrum.cc b/src/yafraycore/spectrum.cc index c3aa498f..671b58ae 100755 --- a/src/yafraycore/spectrum.cc +++ b/src/yafraycore/spectrum.cc @@ -3,7 +3,7 @@ __BEGIN_YAFRAY // CIE color matching function table, 1931, 2 degree -static CFLOAT CIE_XYZcolmat[471][4] = { +static float CIE_XYZcolmat[471][4] = { {360, 0.000129900000, 0.000003917000, 0.000606100000}, {361, 0.000145847000, 0.000004393581, 0.000680879200}, {362, 0.000163802100, 0.000004929604, 0.000765145600}, {363, 0.000184003700, 0.000005532136, 0.000860012400}, {364, 0.000206690200, 0.000006208245, 0.000966592800}, {365, 0.000232100000, 0.000006965000, 0.001086000000}, @@ -241,65 +241,65 @@ static CFLOAT CIE_XYZcolmat[471][4] = { {828, 0.000001439440, 0.000000519808, 0.000000000000}, {829, 0.000001341977, 0.000000484612, 0.000000000000}, {830, 0.000001251141, 0.000000451810, 0.000000000000}}; -void xyz_to_rgb(CFLOAT x, CFLOAT y, CFLOAT z, color_t &col) +void xyz_to_rgb(float x, float y, float z, color_t &col) { // xyz->RGB using CIE RGB colsys. (Illuminant E w.point) col.set(2.28783848734076f*x - 0.833367677835217f*y - 0.454470795871421f*z, -0.511651380743862f*x + 1.42275837632178f*y + 0.0888930017552939f*z, 0.00572040983140966f*x - 0.0159068485104036f*y + 1.0101864083734f*z); // correct if outside gamut - CFLOAT wt = col.minimum(); + float wt = col.minimum(); if (wt<0.f) col -= color_t(wt); } // spectrum color using CIE tables -void wl2rgb_fromCIE(CFLOAT wl, color_t &col) +void wl2rgb_fromCIE(float wl, color_t &col) { - CFLOAT fr = wl-360.f; + float fr = wl-360.f; int p1 = int(fr); if (p1<0) { col.black(); return; } int p2 = p1+1; if (p2>470) { col.black(); return; } fr -= floor(fr); - CFLOAT fr2 = 1.f-fr; - CFLOAT x = fr2*CIE_XYZcolmat[p1][1] + fr*CIE_XYZcolmat[p2][1]; - CFLOAT y = fr2*CIE_XYZcolmat[p1][2] + fr*CIE_XYZcolmat[p2][2]; - CFLOAT z = fr2*CIE_XYZcolmat[p1][3] + fr*CIE_XYZcolmat[p2][3]; + float fr2 = 1.f-fr; + float x = fr2*CIE_XYZcolmat[p1][1] + fr*CIE_XYZcolmat[p2][1]; + float y = fr2*CIE_XYZcolmat[p1][2] + fr*CIE_XYZcolmat[p2][2]; + float z = fr2*CIE_XYZcolmat[p1][3] + fr*CIE_XYZcolmat[p2][3]; xyz_to_rgb(x, y, z, col); } -color_t wl2XYZ(CFLOAT wl) +color_t wl2XYZ(float wl) { - CFLOAT fr = wl-360.f; + float fr = wl-360.f; int p1 = int(fr); if (p1<0) { return color_t(0.f); } int p2 = p1+1; if (p2>470) { return color_t(0.f); } fr -= floor(fr); - CFLOAT fr2 = 1.f-fr; - CFLOAT x = fr2*CIE_XYZcolmat[p1][1] + fr*CIE_XYZcolmat[p2][1]; - CFLOAT y = fr2*CIE_XYZcolmat[p1][2] + fr*CIE_XYZcolmat[p2][2]; - CFLOAT z = fr2*CIE_XYZcolmat[p1][3] + fr*CIE_XYZcolmat[p2][3]; + float fr2 = 1.f-fr; + float x = fr2*CIE_XYZcolmat[p1][1] + fr*CIE_XYZcolmat[p2][1]; + float y = fr2*CIE_XYZcolmat[p1][2] + fr*CIE_XYZcolmat[p2][2]; + float z = fr2*CIE_XYZcolmat[p1][3] + fr*CIE_XYZcolmat[p2][3]; return color_t(x, y, z); } // from various 'spectral composite model..' papers by Sun et al // approximation of CIE matching function by gaussians (only used for analysis in paper, not actual model) // slow but might be useful sometime -void approxSpectrum(CFLOAT wl, color_t &col) +void approxSpectrum(float wl, color_t &col) { - CFLOAT t1=wl-445.f, t2=wl-595.f, t3=wl-560.f, t4=wl-451.f; - CFLOAT x = 0.38f*exp(-t1*t1*1.3691796159e-3f) + 1.06f*exp(-t2*t2*4.3321698785e-4f); - CFLOAT y = exp(-t3*t3*2.7725887222e-4f), z = 1.8f*exp(-t4*t4*9.1655825529e-4f); + float t1=wl-445.f, t2=wl-595.f, t3=wl-560.f, t4=wl-451.f; + float x = 0.38f*exp(-t1*t1*1.3691796159e-3f) + 1.06f*exp(-t2*t2*4.3321698785e-4f); + float y = exp(-t3*t3*2.7725887222e-4f), z = 1.8f*exp(-t4*t4*9.1655825529e-4f); xyz_to_rgb(x, y, z, col); } // just a simple rainbow gradient, but perfect 1/3 sum, // could be useful for some things as a fast rough spectrum color approximation // p in range 0 to 1 -void fakeSpectrum(CFLOAT p, color_t &col) +void fakeSpectrum(float p, color_t &col) { - CFLOAT r=4.f*(p-0.75f), g=4.f*(p-0.5f), b=4.f*(p-0.25f); + float r=4.f*(p-0.75f), g=4.f*(p-0.5f), b=4.f*(p-0.25f); col.set(1.f-r*r, 1.f-g*g, 1.f-b*b); col.clampRGB0(); } @@ -307,14 +307,14 @@ void fakeSpectrum(CFLOAT p, color_t &col) // returns Cauchy coefficients for the reduced form equation n = A + B/lambda^2 // used to calculate dispersion curve, disp_pw is the refractive index difference Nf-nC // may not be quite correct or accurate -void CauchyCoefficients(PFLOAT IOR, PFLOAT disp_pw, PFLOAT &CauchyA, PFLOAT &CauchyB) +void CauchyCoefficients(float IOR, float disp_pw, float &CauchyA, float &CauchyB) { CauchyA = CauchyB = 0; if (disp_pw>0) { // Fraunhofer line wavelengths, Hydrogen F, Helium d, Hydrogen C - const PFLOAT lF2=486.13*486.13, ld2=587.56*587.56, lC2=656.27*656.27; - PFLOAT Vd = (IOR - 1.0) / disp_pw; // Abbe number + const float lF2=486.13*486.13, ld2=587.56*587.56, lC2=656.27*656.27; + float Vd = (IOR - 1.0) / disp_pw; // Abbe number CauchyB = (lC2 - lF2) * Vd; if (CauchyB!=0.0) CauchyB = (lF2 * lC2 * (IOR - 1.0)) / CauchyB; CauchyA = IOR - CauchyB/ld2; @@ -324,10 +324,10 @@ void CauchyCoefficients(PFLOAT IOR, PFLOAT disp_pw, PFLOAT &CauchyA, PFLOAT &Cau // returns IOR and color at specified wavelength (not called with actual wavelength, but number in 0-1 range) // for wl2rgb_fromCIE() & approxSpectrumRGB() range is 380nm to 780nm // but could shorten it to 400-700 maybe, 720-780 is quite dark anyway -PFLOAT getIORcolor(PFLOAT w, PFLOAT CauchyA, PFLOAT CauchyB, color_t &col) +float getIORcolor(float w, float CauchyA, float CauchyB, color_t &col) { - //PFLOAT wl = 400.0*w + 380.0; - PFLOAT wl = 300.0*w + 400.0; + //float wl = 400.0*w + 380.0; + float wl = 300.0*w + 400.0; wl2rgb_fromCIE(wl, col); col *= 2.214032659670777114f; // scale for CIE sys. equal energy, range 400-700 return CauchyA + CauchyB/(wl*wl); diff --git a/src/yafraycore/std_primitives.cc b/src/yafraycore/std_primitives.cc index 7258dbdd..c0027bcd 100755 --- a/src/yafraycore/std_primitives.cc +++ b/src/yafraycore/std_primitives.cc @@ -30,18 +30,18 @@ bound_t sphere_t::getBound() const return bound_t(center - r, center + r); } -bool sphere_t::intersect(const ray_t &ray, PFLOAT *t, intersectData_t &data) const +bool sphere_t::intersect(const ray_t &ray, float *t, intersectData_t &data) const { vector3d_t vf = ray.from - center; - PFLOAT ea = ray.dir*ray.dir; - PFLOAT eb = 2.0*(vf*ray.dir); - PFLOAT ec = vf*vf - radius*radius; - PFLOAT osc = eb*eb-4.0*ea*ec; + float ea = ray.dir*ray.dir; + float eb = 2.0*(vf*ray.dir); + float ec = vf*vf - radius*radius; + float osc = eb*eb-4.0*ea*ec; if(osc<0) return false; osc=fSqrt(osc); - PFLOAT sol1=(-eb-osc)/(2.0*ea); - PFLOAT sol2=(-eb+osc)/(2.0*ea); - PFLOAT sol=sol1; + float sol1=(-eb-osc)/(2.0*ea); + float sol2=(-eb+osc)/(2.0*ea); + float sol=sol1; if(sol < ray.tmin) { sol = sol2; diff --git a/src/yafraycore/surface.cc b/src/yafraycore/surface.cc index 38358a71..8cfe7c29 100755 --- a/src/yafraycore/surface.cc +++ b/src/yafraycore/surface.cc @@ -10,12 +10,12 @@ spDifferentials_t::spDifferentials_t(const surfacePoint_t &spoint, const diffRay { // Estimate screen-space change in \pt and $(u,v)$ // Compute auxiliary intersection points with plane - PFLOAT d = -(sp.N * vector3d_t(sp.P)); + float d = -(sp.N * vector3d_t(sp.P)); vector3d_t rxv(ray.xfrom); - PFLOAT tx = -((sp.N * rxv) + d) / (sp.N * ray.xdir); + float tx = -((sp.N * rxv) + d) / (sp.N * ray.xdir); point3d_t px = ray.xfrom + tx * ray.xdir; vector3d_t ryv(ray.yfrom); - PFLOAT ty = -((sp.N * ryv) + d) / (sp.N * ray.ydir); + float ty = -((sp.N * ryv) + d) / (sp.N * ray.ydir); point3d_t py = ray.yfrom + ty * ray.ydir; dPdx = px - sp.P; dPdy = py - sp.P; @@ -45,13 +45,13 @@ void spDifferentials_t::reflectedRay(const diffRay_t &in, diffRay_t &out) const // Normal dndy = bsdf->dgShading.dndu * bsdf->dgShading.dudy + // bsdf->dgShading.dndv * bsdf->dgShading.dvdy; vector3d_t dwodx = in.dir - in.xdir, dwody = in.dir - in.ydir; - PFLOAT dDNdx = (dwodx * sp.N); // + (out.dir * dndx); - PFLOAT dDNdy = (dwody * sp.N); // + (out.dir * dndy); + float dDNdx = (dwodx * sp.N); // + (out.dir * dndx); + float dDNdy = (dwody * sp.N); // + (out.dir * dndy); out.xdir = out.dir - dwodx + 2 * (/* (out.dir * sp.N) * dndx + */ dDNdx * sp.N); out.ydir = out.dir - dwody + 2 * (/* (out.dir * sp.N) * dndy + */ dDNdy * sp.N); } -void spDifferentials_t::refractedRay(const diffRay_t &in, diffRay_t &out, PFLOAT IOR) const +void spDifferentials_t::refractedRay(const diffRay_t &in, diffRay_t &out, float IOR) const { //RayDifferential rd(p, wi); out.hasDifferentials = true; @@ -63,18 +63,18 @@ void spDifferentials_t::refractedRay(const diffRay_t &in, diffRay_t &out, PFLOAT //Normal dndy = bsdf->dgShading.dndu * bsdf->dgShading.dudy + bsdf->dgShading.dndv * bsdf->dgShading.dvdy; vector3d_t dwodx = in.dir - in.xdir, dwody = in.dir - in.ydir; - PFLOAT dDNdx = (dwodx * sp.N); // + Dot(wo, dndx); - PFLOAT dDNdy = (dwody * sp.N); // + Dot(wo, dndy); + float dDNdx = (dwodx * sp.N); // + Dot(wo, dndx); + float dDNdy = (dwody * sp.N); // + Dot(wo, dndy); -// PFLOAT mu = IOR * (in.dir * sp.N) - (out.dir * sp.N); - PFLOAT dmudx = (IOR - (IOR*IOR*(in.dir * sp.N))/(out.dir * sp.N)) * dDNdx; - PFLOAT dmudy = (IOR - (IOR*IOR*(in.dir * sp.N))/(out.dir * sp.N)) * dDNdy; +// float mu = IOR * (in.dir * sp.N) - (out.dir * sp.N); + float dmudx = (IOR - (IOR*IOR*(in.dir * sp.N))/(out.dir * sp.N)) * dDNdx; + float dmudy = (IOR - (IOR*IOR*(in.dir * sp.N))/(out.dir * sp.N)) * dDNdy; out.xdir = out.dir + IOR * dwodx - (/* mu * dndx + */ dmudx * sp.N); out.ydir = out.dir + IOR * dwody - (/* mu * dndy + */ dmudy * sp.N); } -PFLOAT spDifferentials_t::projectedPixelArea() +float spDifferentials_t::projectedPixelArea() { return (dPdx ^ dPdy).length(); } diff --git a/src/yafraycore/vector3d.cc b/src/yafraycore/vector3d.cc index 8fe72d83..255a16d4 100755 --- a/src/yafraycore/vector3d.cc +++ b/src/yafraycore/vector3d.cc @@ -55,10 +55,10 @@ bool operator != ( const vector3d_t &a,const vector3d_t &b) return false; } -/* vector3d_t refract(const vector3d_t &n,const vector3d_t &v,PFLOAT IOR) +/* vector3d_t refract(const vector3d_t &n,const vector3d_t &v,float IOR) { vector3d_t N=n,I,T; - PFLOAT eta=IOR; + float eta=IOR; I=-v; if((v*n)<0) { @@ -70,8 +70,8 @@ bool operator != ( const vector3d_t &a,const vector3d_t &b) N=n; eta=1.0/IOR; } - PFLOAT IdotN = v*N; - PFLOAT k = 1 - eta*eta*(1 - IdotN*IdotN); + float IdotN = v*N; + float k = 1 - eta*eta*(1 - IdotN*IdotN); T= (k < 0) ? vector3d_t(0,0,0) : (eta*I + (eta*IdotN - sqrt(k))*N); T.normalize(); return T; @@ -109,7 +109,7 @@ bool refract(const vector3d_t &n,const vector3d_t &wi, vector3d_t &wo, float IOR void fresnel(const vector3d_t & I, const vector3d_t & n, float IOR, float &Kr, float &Kt) { - PFLOAT eta; + float eta; vector3d_t N; if((I*n)<0) @@ -123,13 +123,13 @@ void fresnel(const vector3d_t & I, const vector3d_t & n, float IOR, float &Kr, f eta=IOR; N=n; } - PFLOAT c=I*N; - PFLOAT g=eta*eta+c*c-1; + float c=I*N; + float g=eta*eta+c*c-1; if(g<=0) g=0; else g=fSqrt(g); - PFLOAT aux=c*(g+c); + float aux=c*(g+c); Kr=( ( 0.5*(g-c)*(g-c) )/( (g+c)*(g+c) ) ) * ( 1+ ((aux-1)*(aux-1))/( (aux+1)*(aux+1) ) ); @@ -141,20 +141,20 @@ void fresnel(const vector3d_t & I, const vector3d_t & n, float IOR, float &Kr, f // 'Faster' Schlick fresnel approximation, -void fast_fresnel(const vector3d_t & I, const vector3d_t & n, PFLOAT IORF, - CFLOAT &Kr, CFLOAT &Kt) +void fast_fresnel(const vector3d_t & I, const vector3d_t & n, float IORF, + float &Kr, float &Kt) { - PFLOAT t = 1 - (I*n); + float t = 1 - (I*n); //t = (t<0)?0:((t>1)?1:t); - PFLOAT t2 = t*t; + float t2 = t*t; Kr = IORF + (1 - IORF) * t2*t2*t; Kt = 1-Kr; } // P.Shirley's concentric disk algorithm, maps square to disk -void ShirleyDisk(PFLOAT r1, PFLOAT r2, PFLOAT &u, PFLOAT &v) +void ShirleyDisk(float r1, float r2, float &u, float &v) { - PFLOAT phi=0, r=0, a=2*r1-1, b=2*r2-1; + float phi=0, r=0, a=2*r1-1, b=2*r2-1; if (a>-b) { if (a>b) { // Reg.1 r = a; @@ -188,25 +188,25 @@ YAFRAYCORE_EXPORT int myseed=123212; vector3d_t randomVectorCone(const vector3d_t &D, const vector3d_t &U, const vector3d_t &V, - PFLOAT cosang, PFLOAT z1, PFLOAT z2) + float cosang, float z1, float z2) { - PFLOAT t1=M_2PI*z1, t2=1.0-(1.0-cosang)*z2; + float t1=M_2PI*z1, t2=1.0-(1.0-cosang)*z2; return (U*fCos(t1) + V*fSin(t1))*fSqrt(1.0-t2*t2) + D*t2; } -vector3d_t randomVectorCone(const vector3d_t &dir, PFLOAT cangle, PFLOAT r1, PFLOAT r2) +vector3d_t randomVectorCone(const vector3d_t &dir, float cangle, float r1, float r2) { vector3d_t u, v; createCS(dir, u, v); return randomVectorCone(dir, u, v, cangle, r1, r2); } -vector3d_t discreteVectorCone(const vector3d_t &dir, PFLOAT cangle, int sample, int square) +vector3d_t discreteVectorCone(const vector3d_t &dir, float cangle, int sample, int square) { - PFLOAT r1=(PFLOAT)(sample / square)/(PFLOAT)square; - PFLOAT r2=(PFLOAT)(sample % square)/(PFLOAT)square; - PFLOAT tt = M_2PI * r1; - PFLOAT ss = fAcos(1.0 - (1.0 - cangle)*r2); + float r1=(float)(sample / square)/(float)square; + float r2=(float)(sample % square)/(float)square; + float tt = M_2PI * r1; + float ss = fAcos(1.0 - (1.0 - cangle)*r2); vector3d_t vx(fCos(ss),fSin(ss)*fCos(tt),fSin(ss)*fSin(tt)); vector3d_t i(1,0,0),c; matrix4x4_t M(1); diff --git a/src/yafraycore/xmlparser.cc b/src/yafraycore/xmlparser.cc index adf8f62a..78bd809c 100755 --- a/src/yafraycore/xmlparser.cc +++ b/src/yafraycore/xmlparser.cc @@ -251,10 +251,10 @@ void parseParam(const char **attrs, parameter_t ¶m, xmlParser_t &parser) case 'y': p.y = atof(attrs[n+1]); type = TYPE_POINT; break; case 'z': p.z = atof(attrs[n+1]); type = TYPE_POINT; break; - case 'r': c.R = (CFLOAT)atof(attrs[n+1]); type = TYPE_COLOR; break; - case 'g': c.G = (CFLOAT)atof(attrs[n+1]); type = TYPE_COLOR; break; - case 'b': c.B = (CFLOAT)atof(attrs[n+1]); type = TYPE_COLOR; break; - case 'a': c.A = (CFLOAT)atof(attrs[n+1]); type = TYPE_COLOR; break; + case 'r': c.R = (float)atof(attrs[n+1]); type = TYPE_COLOR; break; + case 'g': c.G = (float)atof(attrs[n+1]); type = TYPE_COLOR; break; + case 'b': c.B = (float)atof(attrs[n+1]); type = TYPE_COLOR; break; + case 'a': c.A = (float)atof(attrs[n+1]); type = TYPE_COLOR; break; } } From e8585422f790d9fae0672c54ce123526453e1405 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Mon, 13 Jun 2016 18:19:08 +0100 Subject: [PATCH 085/124] Removed obsolete SVN versioning system. Replaced by more dynamic versioning system, linkable to automatically get git tags and faster to compile. Also, updated files so Python 3.5 is the default now --- CMakeConfig/GenConfHeaders.txt | 8 ++++---- CMakeConfig/UserConfig.template | 14 ++------------ CMakeConfig/templates/yaf_revision.h.cmake | 7 ------- CMakeConfig/templates/yaf_version.h.cmake | 11 +++++++++++ CMakeLists.txt | 7 +------ include/core_api/session.h | 3 ++- include/interface/yafrayinterface.h | 1 - include/yafray_constants.h | 1 - src/interface/yafrayinterface.cc | 6 +----- src/xml_loader/xml-loader.cc | 13 ++----------- src/yafraycore/environment.cc | 7 +------ src/yafraycore/imagefilm.cc | 7 +------ src/yafraycore/session.cc | 10 ++++++++++ 13 files changed, 35 insertions(+), 60 deletions(-) delete mode 100755 CMakeConfig/templates/yaf_revision.h.cmake create mode 100755 CMakeConfig/templates/yaf_version.h.cmake diff --git a/CMakeConfig/GenConfHeaders.txt b/CMakeConfig/GenConfHeaders.txt index f5e47194..4cba421f 100755 --- a/CMakeConfig/GenConfHeaders.txt +++ b/CMakeConfig/GenConfHeaders.txt @@ -1,10 +1,10 @@ # WARNING: Please don't change this file -if(NOT YAF_REVISION) - set(YAF_REVISION "None") -endif(NOT YAF_REVISION) +if(NOT YAFARAY_CORE_VERSION) + set(YAFARAY_CORE_VERSION "(devel)") +endif(NOT YAFARAY_CORE_VERSION) include(CheckIncludeFiles) check_include_files(unistd.h HAVE_UNISTD_H) configure_file(CMakeConfig/templates/yafray_config.h.cmake ${CMAKE_BINARY_DIR}/yafray_config.h) -configure_file(CMakeConfig/templates/yaf_revision.h.cmake ${CMAKE_BINARY_DIR}/yaf_revision.h) +configure_file(CMakeConfig/templates/yaf_version.h.cmake ${CMAKE_BINARY_DIR}/yaf_version.h) diff --git a/CMakeConfig/UserConfig.template b/CMakeConfig/UserConfig.template index d1d6cef5..e4111956 100755 --- a/CMakeConfig/UserConfig.template +++ b/CMakeConfig/UserConfig.template @@ -78,16 +78,6 @@ set(WITH_YAF_PY_BINDINGS ON) set(WITH_YAF_RUBY_BINDINGS OFF) -# # -# Enable release mode building of YafaRay # -# NOTE: This is only to build YafaRay releases, it controls the version number # -# shown in yafaray-xml and the "draw parameters" parameters badge # -# # -# Default: OFF # -# # - -set(BUILDRELEASE OFF) - # # # Enable debug build mode # # # @@ -242,10 +232,10 @@ set(DEBUG_BUILD OFF) # # # Use this variable to set the Python version you want to use for the bindings # # # -# Default: 2.6 # +# Default: 3.5 # # # -#set(YAF_PY_VERSION 3.1) +#set(YAF_PY_VERSION 3.5) ############################# Misc. Configurations ############################# # # diff --git a/CMakeConfig/templates/yaf_revision.h.cmake b/CMakeConfig/templates/yaf_revision.h.cmake deleted file mode 100755 index 0cfb627e..00000000 --- a/CMakeConfig/templates/yaf_revision.h.cmake +++ /dev/null @@ -1,7 +0,0 @@ -// Header file generated by CMake please don't change it -#ifndef Y_REV_H -#define Y_REV_H -#define YAF_SVN_REV "@YAF_REVISION@" -#define LIBPATH "@CMAKE_INSTALL_PREFIX@/@YAF_LIB_DIR@" -#define Y_PLUGINPATH "@CMAKE_INSTALL_PREFIX@/@YAF_PLUGIN_DIR@" -#endif diff --git a/CMakeConfig/templates/yaf_version.h.cmake b/CMakeConfig/templates/yaf_version.h.cmake new file mode 100755 index 00000000..15082623 --- /dev/null +++ b/CMakeConfig/templates/yaf_version.h.cmake @@ -0,0 +1,11 @@ +// Header file generated by CMake please don't change it + +// This preprocessor macro is set by cmake during building in file yaf_version.h.cmake +// For example: cmake -DYAFARAY_CORE_VERSION="v1.2.3" +// the intention is to link the YafaRay Core version to the git information obtained, for example with: +// cmake /yafaray/src/Core -DYAFARAY_CORE_VERSION=`git --git-dir=/yafaray/src/Core/.git describe --dirty --always --tags --long` + +#ifndef Y_VERSION_H +#define Y_VERSION_H +#define YAFARAY_CORE_VERSION "@YAFARAY_CORE_VERSION@" +#endif diff --git a/CMakeLists.txt b/CMakeLists.txt index 41ca22f7..6f04dc9f 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ project (yafaray) -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 3.5) set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMakeModules") set(CMAKE_COLOR_MAKEFILE ON) @@ -15,7 +15,6 @@ option(WITH_XML_LOADER "Build XML Loader" ON) option(WITH_YAF_PY_BINDINGS "Enable the YafaRay Python bindings" ON) option(WITH_YAF_RUBY_BINDINGS "Enable the YafaRay Ruby bindings" OFF) option(WITH_OSX_ADDON "Enable the use of blender's included python lib on OSX platforms" OFF) -option(BUILDRELEASE "Enable release mode building of YafaRay" OFF) option(DEBUG_BUILD "Enable debug build mode" OFF) option(FAST_MATH "Enable mathematic approximations to make code faster" ON) option(FAST_TRIG "Enable trigonometric approximations to make code faster" ON) @@ -242,10 +241,6 @@ if(YAF_USER_EXTRA_DEFS) add_definitions(${YAF_USER_EXTRA_DEFS}) endif(YAF_USER_EXTRA_DEFS) -if (BUILDRELEASE) - add_definitions(-DRELEASE) -endif (BUILDRELEASE) - # Paths and flags configuration if(NOT WIN32) diff --git a/include/core_api/session.h b/include/core_api/session.h index 2cd1146a..5df9e192 100755 --- a/include/core_api/session.h +++ b/include/core_api/session.h @@ -63,7 +63,8 @@ class YAFRAYCORE_EXPORT session_t bool isInteractive(); std::string getPathYafaRayXml(); std::string getPathImageOutput(); - + std::string getYafaRayCoreVersion(); + photonMap_t * causticMap = nullptr; photonMap_t * diffuseMap = nullptr; photonMap_t * radianceMap = nullptr; diff --git a/include/interface/yafrayinterface.h b/include/interface/yafrayinterface.h index befee809..5825d2af 100755 --- a/include/interface/yafrayinterface.h +++ b/include/interface/yafrayinterface.h @@ -3,7 +3,6 @@ #define Y_YAFRAYINTERFACE_H #include -#include #include #include #include diff --git a/include/yafray_constants.h b/include/yafray_constants.h index 544d76a3..56efbe94 100755 --- a/include/yafray_constants.h +++ b/include/yafray_constants.h @@ -5,7 +5,6 @@ #define __END_YAFRAY } #define PACKAGE "YafaRay" -#define VERSION "3.0.0-ALPHA7" #if (__GNUC__ > 3) #define GCC_HASCLASSVISIBILITY diff --git a/src/interface/yafrayinterface.cc b/src/interface/yafrayinterface.cc index b2467bf8..3405be28 100755 --- a/src/interface/yafrayinterface.cc +++ b/src/interface/yafrayinterface.cc @@ -392,11 +392,7 @@ std::string yafrayInterface_t::getImageFullNameFromFormat(const std::string &for char* yafrayInterface_t::getVersion() const { -#ifdef RELEASE - return (char*)std::string(VERSION).c_str(); -#else - return (char*)std::string(YAF_SVN_REV).c_str(); -#endif + return (char*)session.getYafaRayCoreVersion().c_str(); } void yafrayInterface_t::printDebug(const std::string &msg) diff --git a/src/xml_loader/xml-loader.cc b/src/xml_loader/xml-loader.cc index 3d96b86c..e7d0137a 100755 --- a/src/xml_loader/xml-loader.cc +++ b/src/xml_loader/xml-loader.cc @@ -15,7 +15,6 @@ #include #include #include -#include #include #include @@ -72,11 +71,9 @@ int main(int argc, char *argv[]) session.setPathYafaRayXml(boost::filesystem::system_complete(argv[0]).parent_path().string()); - std::string xmlLoaderVersion = "YafaRay XML loader version: " + std::string(VERSION); - cliParser_t parse(argc, argv, 2, 1, "You need to set at least a yafaray's valid XML file."); - parse.setAppName(xmlLoaderVersion, + parse.setAppName("YafaRay XML loader", "[OPTIONS]... [output filename]\n : A valid yafaray XML file\n[output filename] : The filename of the rendered image without extension.\n*Note: If output filename is ommited the name \"yafaray\" will be used instead."); parse.setOption("pp","plugin-path", false, "Path to load plugins."); @@ -84,12 +81,6 @@ int main(int argc, char *argv[]) parse.setOption("lvl","log-verbosity-level", false, "Set log/HTML files verbosity level, options are:\n \"mute\" (Prints nothing)\n \"error\" (Prints only errors)\n \"warning\" (Prints also warnings)\n \"params\" (Prints also render param messages)\n \"info\" (Prints also basic info messages)\n \"verbose\" (Prints additional info messages)\n \"debug\" (Prints debug messages if any)\n"); parse.parseCommandLine(); -#ifdef RELEASE - std::string version = std::string(VERSION); -#else - std::string version = std::string(YAF_SVN_REV); -#endif - renderEnvironment_t *env = new renderEnvironment_t(); // Plugin load @@ -149,7 +140,7 @@ int main(int argc, char *argv[]) if(parse.getFlag("v")) { - Y_INFO << xmlLoaderVersion << yendl << "Built with YafaRay version " << version << yendl; + Y_INFO << "YafaRay XML loader" << yendl << "Built with YafaRay Core version " << session.getYafaRayCoreVersion() << yendl; return 0; } diff --git a/src/yafraycore/environment.cc b/src/yafraycore/environment.cc index a4a0b0b2..5ce69b7f 100755 --- a/src/yafraycore/environment.cc +++ b/src/yafraycore/environment.cc @@ -40,7 +40,6 @@ #include #include #include -#include #include #include @@ -69,11 +68,7 @@ __BEGIN_YAFRAY renderEnvironment_t::renderEnvironment_t() { -#ifdef RELEASE - Y_INFO << PACKAGE << " (" << VERSION << ")" << " " << sysInfoGetOS() << sysInfoGetArchitecture() << sysInfoGetPlatform() << sysInfoGetCompiler() << yendl; -#else - Y_INFO << PACKAGE << " (" << YAF_SVN_REV << ")" << " " << sysInfoGetOS() << sysInfoGetArchitecture() << sysInfoGetPlatform() << sysInfoGetCompiler() << yendl; -#endif + Y_INFO << PACKAGE << " (" << session.getYafaRayCoreVersion() << ")" << " " << sysInfoGetOS() << sysInfoGetArchitecture() << sysInfoGetPlatform() << sysInfoGetCompiler() << yendl; object_factory["sphere"] = sphere_factory; output2 = nullptr; } diff --git a/src/yafraycore/imagefilm.cc b/src/yafraycore/imagefilm.cc index fe0ff511..b0af0ee7 100755 --- a/src/yafraycore/imagefilm.cc +++ b/src/yafraycore/imagefilm.cc @@ -28,7 +28,6 @@ #include #include -#include #include #include #include @@ -675,11 +674,7 @@ void imageFilm_t::flush(int numView, int flags, colorOutput_t *out) if(out1 == out2) out1 = nullptr; //if we are already flushing the secondary output (out2) as main output (out1), then disable out1 to avoid duplicated work -#ifdef RELEASE - std::string version = std::string(VERSION); -#else - std::string version = std::string(YAF_SVN_REV); -#endif + std::string version = session.getYafaRayCoreVersion(); std::stringstream ssBadge; diff --git a/src/yafraycore/session.cc b/src/yafraycore/session.cc index f6a04190..51a93d4b 100755 --- a/src/yafraycore/session.cc +++ b/src/yafraycore/session.cc @@ -22,6 +22,7 @@ #include #include #include +#include __BEGIN_YAFRAY @@ -198,5 +199,14 @@ std::string session_t::getPathImageOutput() } +std::string session_t::getYafaRayCoreVersion() +{ + // This preprocessor macro is set by cmake during building in file yaf_version.h.cmake + // For example: cmake -DYAFARAY_CORE_VERSION="v1.2.3" + // the intention is to link the YafaRay Core version to the git information obtained, for example with: + // cmake /yafaray/src/Core -DYAFARAY_CORE_VERSION=`git --git-dir=/yafaray/src/Core/.git describe --dirty --always --tags --long` + return YAFARAY_CORE_VERSION; +} + __END_YAFRAY From 17bc612d4494638aeaeebd95e6828b7b7b397647 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Mon, 13 Jun 2016 18:22:51 +0100 Subject: [PATCH 086/124] fixup: fixed mistake in the previous commit regarding default python version and the cmake version --- CMakeLists.txt | 2 +- CMakeModules/FindYafPythonLibs.cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f04dc9f..4c56b379 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ project (yafaray) -cmake_minimum_required (VERSION 3.5) +cmake_minimum_required (VERSION 2.6) set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMakeModules") set(CMAKE_COLOR_MAKEFILE ON) diff --git a/CMakeModules/FindYafPythonLibs.cmake b/CMakeModules/FindYafPythonLibs.cmake index c398cb71..13759db6 100755 --- a/CMakeModules/FindYafPythonLibs.cmake +++ b/CMakeModules/FindYafPythonLibs.cmake @@ -31,7 +31,7 @@ INCLUDE(CMakeFindFrameworks) CMAKE_FIND_FRAMEWORKS(Python) IF(NOT REQUIRED_PYTHON_VERSION) - SET(_CURRENT_VERSION 2.6) + SET(_CURRENT_VERSION 3.5) ELSE(NOT REQUIRED_PYTHON_VERSION) SET(_CURRENT_VERSION ${REQUIRED_PYTHON_VERSION}) ENDIF(NOT REQUIRED_PYTHON_VERSION) From e9c0f216d8ee9d9bc9346da2c1d957266823e0ca Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Mon, 13 Jun 2016 18:34:04 +0100 Subject: [PATCH 087/124] Small correction in the description of how to link the new versioning system with git tags --- CMakeConfig/templates/yaf_version.h.cmake | 2 +- src/yafraycore/session.cc | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeConfig/templates/yaf_version.h.cmake b/CMakeConfig/templates/yaf_version.h.cmake index 15082623..27c687b8 100755 --- a/CMakeConfig/templates/yaf_version.h.cmake +++ b/CMakeConfig/templates/yaf_version.h.cmake @@ -3,7 +3,7 @@ // This preprocessor macro is set by cmake during building in file yaf_version.h.cmake // For example: cmake -DYAFARAY_CORE_VERSION="v1.2.3" // the intention is to link the YafaRay Core version to the git information obtained, for example with: -// cmake /yafaray/src/Core -DYAFARAY_CORE_VERSION=`git --git-dir=/yafaray/src/Core/.git describe --dirty --always --tags --long` +// cmake /yafaray/src/Core -DYAFARAY_CORE_VERSION=`git --git-dir=/yafaray/src/Core/.git --work-tree=/yafaray/src/Core describe --dirty --always --tags --long` #ifndef Y_VERSION_H #define Y_VERSION_H diff --git a/src/yafraycore/session.cc b/src/yafraycore/session.cc index 51a93d4b..d97b4a75 100755 --- a/src/yafraycore/session.cc +++ b/src/yafraycore/session.cc @@ -204,7 +204,8 @@ std::string session_t::getYafaRayCoreVersion() // This preprocessor macro is set by cmake during building in file yaf_version.h.cmake // For example: cmake -DYAFARAY_CORE_VERSION="v1.2.3" // the intention is to link the YafaRay Core version to the git information obtained, for example with: - // cmake /yafaray/src/Core -DYAFARAY_CORE_VERSION=`git --git-dir=/yafaray/src/Core/.git describe --dirty --always --tags --long` + // cmake /yafaray/src/Core -DYAFARAY_CORE_VERSION=`git --git-dir=/yafaray/src/Core/.git --work-tree=/yafaray/src/Core describe --dirty --always --tags --long` + return YAFARAY_CORE_VERSION; } From 04b8069e2aada26299ffbf77ddbab477a8451ddd Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Tue, 14 Jun 2016 03:34:01 +0100 Subject: [PATCH 088/124] Updated LICENSES file --- LICENSES | 205 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 187 insertions(+), 18 deletions(-) diff --git a/LICENSES b/LICENSES index 2b830228..b9ce329e 100755 --- a/LICENSES +++ b/LICENSES @@ -1093,11 +1093,8 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -JPEG ----- - +JPEG (release 6b) +----------------- In plain English: 1. We don't promise that this software works. (But if you find any bugs, @@ -1114,7 +1111,7 @@ with respect to this software, its quality, accuracy, merchantability, or fitness for a particular purpose. This software is provided "AS IS", and you, its user, assume the entire risk as to its quality and accuracy. -This software is copyright (C) 1991-2012, Thomas G. Lane, Guido Vollbeding. +This software is copyright (C) 1991-1998, Thomas G. Lane. All Rights Reserved except as specified below. Permission is hereby granted to use, copy, modify, and distribute this @@ -1157,8 +1154,17 @@ the foregoing paragraphs do. The Unix configuration script "configure" was produced with GNU Autoconf. It is copyright by the Free Software Foundation but is freely distributable. The same holds for its supporting scripts (config.guess, config.sub, -ltmain.sh). Another support script, install-sh, is copyright by X Consortium -but is also freely distributable. +ltconfig, ltmain.sh). Another support script, install-sh, is copyright +by M.I.T. but is also freely distributable. + +It appears that the arithmetic coding option of the JPEG spec is covered by +patents owned by IBM, AT&T, and Mitsubishi. Hence arithmetic coding cannot +legally be used without obtaining one or more licenses. For this reason, +support for arithmetic coding has been removed from the free JPEG software. +(Since arithmetic coding provides only a marginal gain over the unpatented +Huffman mode, it is unlikely that very many implementations will support it.) +So far as we are aware, there are no patent restrictions on the remaining +code. The IJG distribution formerly included code to read and write GIF files. To avoid entanglement with the Unisys LZW patent, GIF reading support has @@ -1174,6 +1180,70 @@ We are required to state that +JPEG (release 9b) +----------------- +In plain English: + +1. We don't promise that this software works. (But if you find any bugs, + please let us know!) +2. You can use this software for whatever you want. You don't have to pay us. +3. You may not pretend that you wrote this software. If you use it in a + program, you must acknowledge somewhere in your documentation that + you've used the IJG code. + +In legalese: + +The authors make NO WARRANTY or representation, either express or implied, +with respect to this software, its quality, accuracy, merchantability, or +fitness for a particular purpose. This software is provided "AS IS", and you, +its user, assume the entire risk as to its quality and accuracy. + +This software is copyright (C) 1991-2016, Thomas G. Lane, Guido Vollbeding. +All Rights Reserved except as specified below. + +Permission is hereby granted to use, copy, modify, and distribute this +software (or portions thereof) for any purpose, without fee, subject to these +conditions: +(1) If any part of the source code for this software is distributed, then this +README file must be included, with this copyright and no-warranty notice +unaltered; and any additions, deletions, or changes to the original files +must be clearly indicated in accompanying documentation. +(2) If only executable code is distributed, then the accompanying +documentation must state that "this software is based in part on the work of +the Independent JPEG Group". +(3) Permission for use of this software is granted only if the user accepts +full responsibility for any undesirable consequences; the authors accept +NO LIABILITY for damages of any kind. + +These conditions apply to any software derived from or based on the IJG code, +not just to the unmodified library. If you use our work, you ought to +acknowledge us. + +Permission is NOT granted for the use of any IJG author's name or company name +in advertising or publicity relating to this software or products derived from +it. This software may be referred to only as "the Independent JPEG Group's +software". + +We specifically permit and encourage the use of this software as the basis of +commercial products, provided that all warranty or liability claims are +assumed by the product vendor. + + +The Unix configuration script "configure" was produced with GNU Autoconf. +It is copyright by the Free Software Foundation but is freely distributable. +The same holds for its supporting scripts (config.guess, config.sub, +ltmain.sh). Another support script, install-sh, is copyright by X Consortium +but is also freely distributable. + +The IJG distribution formerly included code to read and write GIF files. +To avoid entanglement with the Unisys LZW patent (now expired), GIF reading +support has been removed altogether, and the GIF writer has been simplified +to produce "uncompressed GIFs". This technique does not use the LZW +algorithm; the resulting GIF files are larger than usual, but are readable +by all standard GIF decoders. + + + LibICONV -------- @@ -1230,7 +1300,7 @@ library. If the library is modified by someone else and passed on, we want its recipients to know that what they have is not the original version, so that any problems introduced by others will not reflect on the original authors' reputations. - + Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that companies distributing free software will individually obtain patent licenses, thus in effect @@ -1277,7 +1347,7 @@ works together with the library. Note that it is possible for a library to be covered by the ordinary General Public License rather than by this special one. - + GNU LIBRARY GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION @@ -1324,7 +1394,7 @@ Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. - + 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 @@ -1382,7 +1452,7 @@ instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. - + Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. @@ -1433,7 +1503,7 @@ Library will still fall under Section 6.) distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. - + 6. As an exception to the Sections above, you may also compile or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work @@ -1487,7 +1557,7 @@ restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. - + 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined @@ -1528,7 +1598,7 @@ subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. - + 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or @@ -1580,7 +1650,7 @@ conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. - + 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is @@ -1614,7 +1684,7 @@ SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS - + Appendix: How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest @@ -1665,6 +1735,7 @@ That's all there is to it! LibPNG ------ + This copy of the libpng notices is provided for your convenience. In case of any discrepancy between this copy and the notices in the file png.h that is included in the libpng distribution, the latter shall prevail. @@ -1806,7 +1877,6 @@ THE SOFTWARE. - TIFF ---- Copyright (c) 1988-1997 Sam Leffler @@ -1897,6 +1967,105 @@ DEALINGS IN THE SOFTWARE. +OpenCV +------ +By downloading, copying, installing or using the software you agree to this license. +If you do not agree to this license, do not download, install, +copy or use the software. + + + License Agreement + For Open Source Computer Vision Library + (3-clause BSD License) + +Copyright (C) 2000-2015, Intel Corporation, all rights reserved. +Copyright (C) 2009-2011, Willow Garage Inc., all rights reserved. +Copyright (C) 2009-2015, NVIDIA Corporation, all rights reserved. +Copyright (C) 2010-2013, Advanced Micro Devices, Inc., all rights reserved. +Copyright (C) 2015, OpenCV Foundation, all rights reserved. +Copyright (C) 2015, Itseez Inc., all rights reserved. +Third party copyrights are property of their respective owners. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * Neither the names of the copyright holders nor the names of the contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +This software is provided by the copyright holders and contributors "as is" and +any express or implied warranties, including, but not limited to, the implied +warranties of merchantability and fitness for a particular purpose are disclaimed. +In no event shall copyright holders or contributors be liable for any direct, +indirect, incidental, special, exemplary, or consequential damages +(including, but not limited to, procurement of substitute goods or services; +loss of use, data, or profits; or business interruption) however caused +and on any theory of liability, whether in contract, strict liability, +or tort (including negligence or otherwise) arising in any way out of +the use of this software, even if advised of the possibility of such damage. + + + +Python (v3.x) +------------- +PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2 +-------------------------------------------- + +1. This LICENSE AGREEMENT is between the Python Software Foundation +("PSF"), and the Individual or Organization ("Licensee") accessing and +otherwise using this software ("Python") in source or binary form and +its associated documentation. + +2. Subject to the terms and conditions of this License Agreement, PSF hereby +grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce, +analyze, test, perform and/or display publicly, prepare derivative works, +distribute, and otherwise use Python alone or in any derivative version, +provided, however, that PSF's License Agreement and PSF's notice of copyright, +i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, +2011, 2012, 2013, 2014, 2015 Python Software Foundation; All Rights Reserved" +are retained in Python alone or in any derivative version prepared by Licensee. + +3. In the event Licensee prepares a derivative work that is based on +or incorporates Python or any part thereof, and wants to make +the derivative work available to others as provided herein, then +Licensee hereby agrees to include in any such work a brief summary of +the changes made to Python. + +4. PSF is making Python available to Licensee on an "AS IS" +basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR +IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND +DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS +FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT +INFRINGE ANY THIRD PARTY RIGHTS. + +5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON +FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS +A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON, +OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. + +6. This License Agreement will automatically terminate upon a material +breach of its terms and conditions. + +7. Nothing in this License Agreement shall be deemed to create any +relationship of agency, partnership, or joint venture between PSF and +Licensee. This License Agreement does not grant permission to use PSF +trademarks or trade name in a trademark sense to endorse or promote +products or services of Licensee, or any third party. + +8. By copying, installing or otherwise using Python, Licensee +agrees to be bound by the terms and conditions of this License +Agreement. + + + + mingw-std-threads ----------------- Copyright (c) 2016, Mega Limited From 5eb5581d038e5ed39ae96ac6a4e2de634a05247e Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Tue, 14 Jun 2016 05:11:25 +0100 Subject: [PATCH 089/124] Specify that the version shown is the Core version, to avoid mistakes with Plug-In and Exporters versions --- src/yafraycore/environment.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/yafraycore/environment.cc b/src/yafraycore/environment.cc index 5ce69b7f..01ca7d0f 100755 --- a/src/yafraycore/environment.cc +++ b/src/yafraycore/environment.cc @@ -68,7 +68,7 @@ __BEGIN_YAFRAY renderEnvironment_t::renderEnvironment_t() { - Y_INFO << PACKAGE << " (" << session.getYafaRayCoreVersion() << ")" << " " << sysInfoGetOS() << sysInfoGetArchitecture() << sysInfoGetPlatform() << sysInfoGetCompiler() << yendl; + Y_INFO << PACKAGE << " Core (" << session.getYafaRayCoreVersion() << ")" << " " << sysInfoGetOS() << sysInfoGetArchitecture() << sysInfoGetPlatform() << sysInfoGetCompiler() << yendl; object_factory["sphere"] = sphere_factory; output2 = nullptr; } From 370a429b0d031afdd4758655db8f085e40cc0627 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Tue, 14 Jun 2016 19:24:18 +0100 Subject: [PATCH 090/124] Image film loading: only loading film files with same base filename as .blend/frame (for multicomputer animation frames film addition). Also, fixed film files not found when using in yafaray-xml --- src/yafraycore/imagefilm.cc | 10 +++++++--- src/yafraycore/session.cc | 7 ++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/yafraycore/imagefilm.cc b/src/yafraycore/imagefilm.cc index b0af0ee7..52156dce 100755 --- a/src/yafraycore/imagefilm.cc +++ b/src/yafraycore/imagefilm.cc @@ -257,11 +257,15 @@ void imageFilm_t::init(int numPasses) node << std::setfill('0') << std::setw(4) << computerNode; filmPath += " - node " + node.str(); filmPath += ".film"; + + std::string baseImageFileName = boost::filesystem::path(session.getPathImageOutput()).stem().string(); - const std::string target_path( boost::filesystem::path(session.getPathImageOutput()).parent_path().string() ); - const std::regex filmFilter(".*\\.film$"); + std::string parentPath = boost::filesystem::path(session.getPathImageOutput()).parent_path().string(); + if(parentPath.empty()) parentPath = "."; //If parent path is empty, set the path to the current folder + const std::string target_path( parentPath ); + const std::regex filmFilter(baseImageFileName + ".*\\.film$"); std::vector filmFilesList; - + try { boost::filesystem::directory_iterator it_end; diff --git a/src/yafraycore/session.cc b/src/yafraycore/session.cc index d97b4a75..3c65886f 100755 --- a/src/yafraycore/session.cc +++ b/src/yafraycore/session.cc @@ -194,7 +194,12 @@ std::string session_t::getPathYafaRayXml() std::string session_t::getPathImageOutput() { - if(mPathImageOutput.empty()) return boost::filesystem::temp_directory_path().string()+"/yafaray"; //if no image output folder was specified, use the system temporary folder + if(mPathImageOutput.empty()) + { + std::string tempPathOutput = boost::filesystem::temp_directory_path().string()+"/yafaray"; + Y_WARNING << "Image output path not specified, setting to temporary folder: '" << tempPathOutput << "'" << yendl; + return tempPathOutput; //if no image output folder was specified, use the system temporary folder + } else return mPathImageOutput; } From b2f3e15a898eaf38de251c827aee1b35a3b962bd Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Tue, 14 Jun 2016 19:49:30 +0100 Subject: [PATCH 091/124] Fixed crash when using yafaray-xml --- src/yafraycore/integrator.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/yafraycore/integrator.cc b/src/yafraycore/integrator.cc index a1a360d2..23ed9a1f 100755 --- a/src/yafraycore/integrator.cc +++ b/src/yafraycore/integrator.cc @@ -171,7 +171,7 @@ bool tiledIntegrator_t::render(int numView, imageFilm_t *image) { passString.clear(); passString << "Combining ImageFilm files, skipping pass 1..."; - intpb->setTag(passString.str().c_str()); + if(intpb) intpb->setTag(passString.str().c_str()); } Y_INFO << integratorName << ": " << passString.str() << yendl; From e2b000aaea6cd1dafe4afa8f49a6403cca74eb3a Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Wed, 15 Jun 2016 20:41:13 +0100 Subject: [PATCH 092/124] Attempt to implement film reuse from RAM feature --- include/core_api/imagefilm.h | 49 +--- include/core_api/output.h | 1 + include/core_api/session.h | 31 ++- src/bindings/yafaray_v3_interface.i | 2 + src/integrators/photonintegr.cc | 4 + src/interface/yafrayinterface.cc | 3 + src/yafraycore/imagefilm.cc | 379 ++++++++++++++++++---------- src/yafraycore/integrator.cc | 1 + src/yafraycore/scene.cc | 2 + src/yafraycore/session.cc | 2 + 10 files changed, 299 insertions(+), 175 deletions(-) diff --git a/include/core_api/imagefilm.h b/include/core_api/imagefilm.h index 0a2608f5..27e59cbc 100755 --- a/include/core_api/imagefilm.h +++ b/include/core_api/imagefilm.h @@ -143,13 +143,13 @@ class YAFRAYCORE_EXPORT imageFilm_t void setAutoLoad(bool auto_load); bool imageFilmLoad(const std::string &filename, bool debugXMLformat); bool imageFilmSave(const std::string &filename, bool debugXMLformat); - + bool imageFilmLoadReuseCheckOk() const; + #if HAVE_FREETYPE void drawFontBitmap( FT_Bitmap_* bitmap, int x, int y); #endif protected: - std::vector imagePasses; //!< rgba color buffers for the render passes rgb2DImage_nw_t *densityImage; //!< storage for z-buffer channel rgba2DImage_nw_t *dpimage; //!< render parameters badge image tiledBitArray2D_t<3> *flags; //!< flags for adaptive AA sampling; @@ -187,6 +187,9 @@ class YAFRAYCORE_EXPORT imageFilm_t imageSpliter_t::tilesOrderType tilesOrder; bool premultAlpha; bool premultAlpha2; //For optional secondary file output + std::vector *> * imagePasses = nullptr; //!< pointer to rgba color buffers for the render passes + std::vector *> imagePassesPreview; //!< rgba color buffers dedicated for preview renders + bool imageFilmReused = false; int nPasses; double accumulated_image_area_flush_time; unsigned int baseSamplingOffset = 0; //Base sampling offset, in case of multi-computer rendering each should have a different offset so they don't "repeat" the same samples (user configurable) @@ -195,30 +198,11 @@ class YAFRAYCORE_EXPORT imageFilm_t bool autoSave; // If enabled, it will autosave the Image Film at the same time as the image files bool autoSaveBinary; //If enabled, it will autosave the Image Film in binary mode (faster, smaller but non-portable among systems) bool autoLoad; // If enabled, it will load the image film from a file before start rendering, might be useful to continue interrupted renders but it has to be used with care. If it does not match exactly the scene, bad results or even crashes could happen. - - struct filmload_check_t - { - int w, h, cx0, cx1, cy0, cy1; - size_t numPasses; - std::string filmStructureVersion; - friend class boost::serialization::access; - template void serialize(Archive & ar, const unsigned int version) - { - ar & BOOST_SERIALIZATION_NVP(w); - ar & BOOST_SERIALIZATION_NVP(h); - ar & BOOST_SERIALIZATION_NVP(cx0); - ar & BOOST_SERIALIZATION_NVP(cx1); - ar & BOOST_SERIALIZATION_NVP(cy0); - ar & BOOST_SERIALIZATION_NVP(cy1); - ar & BOOST_SERIALIZATION_NVP(numPasses); - ar & BOOST_SERIALIZATION_NVP(filmStructureVersion); - } - }; - + //IMPORTANT: change the FILM_STRUCTURE_VERSION string if there are significant changes in the film structure #define FILM_STRUCTURE_VERSION "1.0" - filmload_check_t filmload_check; + filmload_check_t & filmload_check; friend class boost::serialization::access; template void save(Archive & ar, const unsigned int version) const @@ -229,23 +213,11 @@ class YAFRAYCORE_EXPORT imageFilm_t ar & BOOST_SERIALIZATION_NVP(baseSamplingOffset); ar & BOOST_SERIALIZATION_NVP(computerNode); ar & BOOST_SERIALIZATION_NVP(imagePasses); - //ar & BOOST_SERIALIZATION_NVP(densityImage); - //ar & BOOST_SERIALIZATION_NVP(dpimage); - //ar & BOOST_SERIALIZATION_NVP(flags); - //ar & BOOST_SERIALIZATION_NVP(splitter); - //ar & BOOST_SERIALIZATION_NVP(nPass); } template void load(Archive & ar, const unsigned int version) { ar & BOOST_SERIALIZATION_NVP(filmload_check); - - if(filmload_check.filmStructureVersion != FILM_STRUCTURE_VERSION || filmload_check.w != w || filmload_check.h != h || filmload_check.cx0 != cx0 || filmload_check.cx1 != cx1 || filmload_check.cy0 != cy0 || filmload_check.cy1 != cy1 || filmload_check.numPasses != imagePasses.size()) - { - Y_WARNING << "imageFilm: loading imageFilm file failed because parameters are different. Expected: film structure version=" << FILM_STRUCTURE_VERSION << ",w="<getRenderPasses()->extPassesSize(); ++idx) + if(imagePasses) Y_DEBUG << "imagePasses->size() = " << imagePasses->size() << yendl; + + if(output->isPreview()) { - imagePasses.push_back(new rgba2DImage_t(width, height)); + imagePasses = &imagePassesPreview; //During preview renders (material preview, etc) we will use dedicated color buffers for the film to avoid overwriting the persistent (session) color buffers used for scene renders + + //Creation of the image buffers for the render passes + for(int idx = 0; idx < env->getRenderPasses()->extPassesSize(); ++idx) + { + imagePasses->push_back(new rgba2DImage_t(width, height)); + } } + else + { + imagePasses = &session.imagePasses; //During scene renders (material preview, etc) we will use the persistent (session) color buffers + + if(!imagePasses || imagePasses->empty()) + { + Y_DEBUG << "imagePasses EMPTY, re-generating" << yendl; + //Creation of the image buffers for the render passes + for(int idx = 0; idx < env->getRenderPasses()->extPassesSize(); ++idx) + { + imagePasses->push_back(new rgba2DImage_t(width, height)); + } + } + else if(imageFilmLoadReuseCheckOk()) + { + Y_DEBUG << "imagePasses NOT empty, resuming" << yendl; + imageFilmReused = true; + } + else + { + Y_DEBUG << "imagePasses not empty, but imageFilm reuse checks failed, re-generating" << yendl; + + //Deletion of the image buffers for the additional render passes + for(size_t idx = 0; idx < imagePasses->size(); ++idx) + { + delete((*imagePasses)[idx]); + } + imagePasses->clear(); + //Creation of the image buffers for the render passes + for(int idx = 0; idx < env->getRenderPasses()->extPassesSize(); ++idx) + { + imagePasses->push_back(new rgba2DImage_t(width, height)); + } + } + } densityImage = nullptr; estimateDensity = false; dpimage = nullptr; @@ -188,28 +231,41 @@ imageFilm_t::imageFilm_t (int width, int height, int xstart, int ystart, colorOu imageFilm_t::~imageFilm_t () { - //Deletion of the image buffers for the additional render passes - for(size_t idx = 0; idx < imagePasses.size(); ++idx) + if(output->isPreview()) { - delete(imagePasses[idx]); + //Deletion of the image buffers for the additional render passes + for(size_t idx = 0; idx < imagePasses->size(); ++idx) + { + delete((*imagePasses)[idx]); + } + imagePasses->clear(); } - imagePasses.clear(); - if(densityImage) delete densityImage; delete[] filterTable; if(splitter) delete splitter; if(dpimage) delete dpimage; if(pbar) delete pbar; //remove when pbar no longer created by imageFilm_t!! + imagePasses = nullptr; + + Y_DEBUG << "*** FILM DESTRUCTOR ***" << yendl; } void imageFilm_t::init(int numPasses) { - // Clear color buffers - for(size_t idx = 0; idx < imagePasses.size(); ++idx) + Y_DEBUG << "*** FILM INIT ***" << yendl; + if(!output->isPreview() && imageFilmReused && imageFilmLoadReuseCheckOk()) { - imagePasses[idx]->clear(); + Y_DEBUG << "ImageFilm reused: initialization skipped" << yendl; + session.setStatusRenderResumed(); + } + else + { + // Clear color buffers + for(size_t idx = 0; idx < imagePasses->size(); ++idx) + { + (*imagePasses)[idx]->clear(); + } } - // Clear density image if(estimateDensity) { @@ -237,125 +293,128 @@ void imageFilm_t::init(int numPasses) nPass = 1; nPasses = numPasses; - if(autoLoad) + if(!output->isPreview()) // Avoid executing the Film Load / Save operations and updating the film check values when we are just rendering a preview! { - std::stringstream passString; - passString << "Loading ImageFilm files"; - - Y_INFO << passString.str() << yendl; + if(autoLoad) + { + std::stringstream passString; + passString << "Loading ImageFilm files"; - std::string oldTag; + Y_INFO << passString.str() << yendl; - if(pbar) - { - oldTag = pbar->getTag(); - pbar->setTag(passString.str().c_str()); - } - - std::string filmPath = session.getPathImageOutput(); - std::stringstream node; - node << std::setfill('0') << std::setw(4) << computerNode; - filmPath += " - node " + node.str(); - filmPath += ".film"; - - std::string baseImageFileName = boost::filesystem::path(session.getPathImageOutput()).stem().string(); + std::string oldTag; - std::string parentPath = boost::filesystem::path(session.getPathImageOutput()).parent_path().string(); - if(parentPath.empty()) parentPath = "."; //If parent path is empty, set the path to the current folder - const std::string target_path( parentPath ); - const std::regex filmFilter(baseImageFileName + ".*\\.film$"); - std::vector filmFilesList; - - try - { - boost::filesystem::directory_iterator it_end; - for(boost::filesystem::directory_iterator it( target_path ); it != it_end; ++it) + if(pbar) { - if(!boost::filesystem::is_regular_file(it->status())) continue; - if(!std::regex_match(it->path().filename().string(), filmFilter)) continue; - filmFilesList.push_back(it->path().string()); + oldTag = pbar->getTag(); + pbar->setTag(passString.str().c_str()); } - std::sort(filmFilesList.begin(), filmFilesList.end()); + + std::string filmPath = session.getPathImageOutput(); + std::stringstream node; + node << std::setfill('0') << std::setw(4) << computerNode; + filmPath += " - node " + node.str(); + filmPath += ".film"; + + std::string baseImageFileName = boost::filesystem::path(session.getPathImageOutput()).stem().string(); - for(auto filmFile: filmFilesList) + std::string parentPath = boost::filesystem::path(session.getPathImageOutput()).parent_path().string(); + if(parentPath.empty()) parentPath = "."; //If parent path is empty, set the path to the current folder + const std::string target_path( parentPath ); + const std::regex filmFilter(baseImageFileName + ".*\\.film$"); + std::vector filmFilesList; + + try { - imageFilm_t *loadedFilm = new imageFilm_t(w, h, cx0, cy0, *output, 1.0, BOX, env); - loadedFilm->imageFilmLoad(filmFile, false); - - for(size_t idx=0; idxstatus())) continue; + if(!std::regex_match(it->path().filename().string(), filmFilter)) continue; + filmFilesList.push_back(it->path().string()); + } + std::sort(filmFilesList.begin(), filmFilesList.end()); + + for(auto filmFile: filmFilesList) { - for(int i=0; iimageFilmLoad(filmFile, false); + + for(size_t idx=0; idxsize(); ++idx) { - for(int j=0; jimagePasses))[idx]; + for(int i=0; iimagePasses[idx]; - (*imagePasses[idx])(i,j).col += (*loadedImageBuffer)(i,j).col; - (*imagePasses[idx])(i,j).weight += (*loadedImageBuffer)(i,j).weight; + for(int j=0; jsamplingOffset) samplingOffset = loadedFilm->samplingOffset; + if(baseSamplingOffset < loadedFilm->baseSamplingOffset) baseSamplingOffset = loadedFilm->baseSamplingOffset; + + delete loadedFilm; } - - if(samplingOffset < loadedFilm->samplingOffset) samplingOffset = loadedFilm->samplingOffset; - if(baseSamplingOffset < loadedFilm->baseSamplingOffset) baseSamplingOffset = loadedFilm->baseSamplingOffset; - - delete loadedFilm; } - } - catch(const boost::filesystem::filesystem_error& e) - { - Y_WARNING << "imageFilm: error during imageFilm loading process: \"" << e.what() << "\"" << yendl; + catch(const boost::filesystem::filesystem_error& e) + { + Y_WARNING << "imageFilm: error during imageFilm loading process: \"" << e.what() << "\"" << yendl; + } + + if(pbar) pbar->setTag(oldTag); } - if(pbar) pbar->setTag(oldTag); - } - - if(autoSave) //If the imageFilm is set to Auto Save, at the start rename the previous film file as a "backup" just in case the user has made a mistake and wants to get the previous film back - { - std::stringstream passString; - passString << "Creating backup of the previous ImageFilm file..."; + if(autoSave) //If the imageFilm is set to Auto Save, at the start rename the previous film file as a "backup" just in case the user has made a mistake and wants to get the previous film back. + { + std::stringstream passString; + passString << "Creating backup of the previous ImageFilm file..."; - Y_INFO << passString.str() << yendl; + Y_INFO << passString.str() << yendl; - std::string oldTag; + std::string oldTag; - if(pbar) - { - oldTag = pbar->getTag(); - pbar->setTag(passString.str().c_str()); - } - - std::string filmPath = session.getPathImageOutput(); - std::stringstream node; - node << std::setfill('0') << std::setw(4) << computerNode; - filmPath += " - node " + node.str(); - filmPath += ".film"; - std::string filmPathBackup = filmPath+"-previous.bak"; - - if(boost::filesystem::exists(filmPath)) - { - Y_VERBOSE << "imageFilm: Creating backup of previously saved film to: \"" << filmPathBackup << "\"" << yendl; - try - { - boost::filesystem::rename(filmPath, filmPathBackup); + if(pbar) + { + oldTag = pbar->getTag(); + pbar->setTag(passString.str().c_str()); } - catch(const boost::filesystem::filesystem_error& e) + + std::string filmPath = session.getPathImageOutput(); + std::stringstream node; + node << std::setfill('0') << std::setw(4) << computerNode; + filmPath += " - node " + node.str(); + filmPath += ".film"; + std::string filmPathBackup = filmPath+"-previous.bak"; + + if(boost::filesystem::exists(filmPath)) { - Y_WARNING << "imageFilm: error during imageFilm file backup \"" << e.what() << "\"" << yendl; + Y_VERBOSE << "imageFilm: Creating backup of previously saved film to: \"" << filmPathBackup << "\"" << yendl; + try + { + boost::filesystem::rename(filmPath, filmPathBackup); + } + catch(const boost::filesystem::filesystem_error& e) + { + Y_WARNING << "imageFilm: error during imageFilm file backup \"" << e.what() << "\"" << yendl; + } } + + if(pbar) pbar->setTag(oldTag); } - - if(pbar) pbar->setTag(oldTag); - } - //film load check data initialization - filmload_check.filmStructureVersion = FILM_STRUCTURE_VERSION; - filmload_check.w = w; - filmload_check.h = h; - filmload_check.cx0 = cx0; - filmload_check.cx1 = cx1; - filmload_check.cy0 = cy0; - filmload_check.cy1 = cy1; - filmload_check.numPasses = imagePasses.size(); + //film load check data initialization + filmload_check.filmStructureVersion = FILM_STRUCTURE_VERSION; + filmload_check.w = w; + filmload_check.h = h; + filmload_check.cx0 = cx0; + filmload_check.cx1 = cx1; + filmload_check.cy0 = cy0; + filmload_check.cy1 = cy1; + filmload_check.numPasses = imagePasses->size(); + } } int imageFilm_t::nextPass(int numView, bool adaptive_AA, std::string integratorName) @@ -386,7 +445,7 @@ int imageFilm_t::nextPass(int numView, bool adaptive_AA, std::string integratorN if(flags) flags->clear(); else flags = new tiledBitArray2D_t<3>(w, h, true); - std::vector colExtPasses(imagePasses.size(), colorA_t(0.f)); + std::vector colExtPasses(imagePasses->size(), colorA_t(0.f)); int variance_half_edge = AA_variance_edge_size / 2; float AA_thresh_scaled = AA_thesh; @@ -409,9 +468,9 @@ int imageFilm_t::nextPass(int numView, bool adaptive_AA, std::string integratorN { //We will only consider the Combined Pass (pass 0) for the AA additional sampling calculations. - if((*imagePasses.at(0))(x, y).weight <= 0.f) flags->setBit(x, y); //If after reloading ImageFiles there are pixels that were not yet rendered at all, make sure they are marked to be rendered in the next AA pass + if((*imagePasses->at(0))(x, y).weight <= 0.f) flags->setBit(x, y); //If after reloading ImageFiles there are pixels that were not yet rendered at all, make sure they are marked to be rendered in the next AA pass - colorA_t pixCol = (*imagePasses.at(0))(x, y).normalized(); + colorA_t pixCol = (*imagePasses->at(0))(x, y).normalized(); float pixColBri = pixCol.abscol2bri(); if(AA_dark_detection_type == DARK_DETECTION_LINEAR && AA_dark_threshold_factor > 0.f) @@ -423,19 +482,19 @@ int imageFilm_t::nextPass(int numView, bool adaptive_AA, std::string integratorN AA_thresh_scaled = dark_threshold_curve_interpolate(pixColBri); } - if(pixCol.colorDifference((*imagePasses.at(0))(x+1, y).normalized(), AA_detect_color_noise) >= AA_thresh_scaled) + if(pixCol.colorDifference((*imagePasses->at(0))(x+1, y).normalized(), AA_detect_color_noise) >= AA_thresh_scaled) { flags->setBit(x, y); flags->setBit(x+1, y); } - if(pixCol.colorDifference((*imagePasses.at(0))(x, y+1).normalized(), AA_detect_color_noise) >= AA_thresh_scaled) + if(pixCol.colorDifference((*imagePasses->at(0))(x, y+1).normalized(), AA_detect_color_noise) >= AA_thresh_scaled) { flags->setBit(x, y); flags->setBit(x, y+1); } - if(pixCol.colorDifference((*imagePasses.at(0))(x+1, y+1).normalized(), AA_detect_color_noise) >= AA_thresh_scaled) + if(pixCol.colorDifference((*imagePasses->at(0))(x+1, y+1).normalized(), AA_detect_color_noise) >= AA_thresh_scaled) { flags->setBit(x, y); flags->setBit(x+1, y+1); } - if(x > 0 && pixCol.colorDifference((*imagePasses.at(0))(x-1, y+1).normalized(), AA_detect_color_noise) >= AA_thresh_scaled) + if(x > 0 && pixCol.colorDifference((*imagePasses->at(0))(x-1, y+1).normalized(), AA_detect_color_noise) >= AA_thresh_scaled) { flags->setBit(x, y); flags->setBit(x-1, y+1); } @@ -452,8 +511,8 @@ int imageFilm_t::nextPass(int numView, bool adaptive_AA, std::string integratorN if(xi<0) xi = 0; else if(xi>=w-1) xi = w-2; - colorA_t cx0 = (*imagePasses.at(0))(xi, y).normalized(); - colorA_t cx1 = (*imagePasses.at(0))(xi+1, y).normalized(); + colorA_t cx0 = (*imagePasses->at(0))(xi, y).normalized(); + colorA_t cx1 = (*imagePasses->at(0))(xi+1, y).normalized(); if(cx0.colorDifference(cx1, AA_detect_color_noise) >= AA_thresh_scaled) ++variance_x; } @@ -464,8 +523,8 @@ int imageFilm_t::nextPass(int numView, bool adaptive_AA, std::string integratorN if(yi<0) yi = 0; else if(yi>=h-1) yi = h-2; - colorA_t cy0 = (*imagePasses.at(0))(x, yi).normalized(); - colorA_t cy1 = (*imagePasses.at(0))(x, yi+1).normalized(); + colorA_t cy0 = (*imagePasses->at(0))(x, yi).normalized(); + colorA_t cy1 = (*imagePasses->at(0))(x, yi+1).normalized(); if(cy0.colorDifference(cy1, AA_detect_color_noise) >= AA_thresh_scaled) ++variance_y; } @@ -502,9 +561,9 @@ int imageFilm_t::nextPass(int numView, bool adaptive_AA, std::string integratorN if(session.isInteractive() && showMask) { - for(size_t idx = 0; idx < imagePasses.size(); ++idx) + for(size_t idx = 0; idx < imagePasses->size(); ++idx) { - color_t pix = (*imagePasses[idx])(x, y).normalized(); + color_t pix = (*(*imagePasses)[idx])(x, y).normalized(); float pixColBri = pix.abscol2bri(); if(pix.R < pix.G && pix.R < pix.B) @@ -596,19 +655,19 @@ void imageFilm_t::finishArea(int numView, renderArea_t &a) int end_x = a.X+a.W-cx0, end_y = a.Y+a.H-cy0; - std::vector colExtPasses(imagePasses.size(), colorA_t(0.f)); + std::vector colExtPasses(imagePasses->size(), colorA_t(0.f)); for(int j=a.Y-cy0; jsize(); ++idx) { - colExtPasses[idx] = (*imagePasses[idx])(i, j).normalized(); + colExtPasses[idx] = (*(*imagePasses)[idx])(i, j).normalized(); if(env->getRenderPasses()->intPassTypeFromExtPassIndex(idx) == PASS_INT_AA_SAMPLES) { - colExtPasses[idx] = (*imagePasses[idx])(i, j).weight; + colExtPasses[idx] = (*(*imagePasses)[idx])(i, j).weight; } colExtPasses[idx].clampRGB0(); @@ -749,10 +808,10 @@ void imageFilm_t::flush(int numView, int flags, colorOutput_t *out) if(estimateDensity) multi = (float) (w * h) / (float) numSamples; - std::vector colExtPasses(imagePasses.size(), colorA_t(0.f)); + std::vector colExtPasses(imagePasses->size(), colorA_t(0.f)); std::vector colExtPasses2; //For secondary file output (when enabled) - if(out2) colExtPasses2.resize(imagePasses.size(), colorA_t(0.f)); + if(out2) colExtPasses2.resize(imagePasses->size(), colorA_t(0.f)); int outputDisplaceRenderedImageBadgeHeight = 0, out2DisplaceRenderedImageBadgeHeight = 0; @@ -764,14 +823,14 @@ void imageFilm_t::flush(int numView, int flags, colorOutput_t *out) { for(int i = 0; i < w; i++) { - for(size_t idx = 0; idx < imagePasses.size(); ++idx) + for(size_t idx = 0; idx < imagePasses->size(); ++idx) { - if(flags & IF_IMAGE) colExtPasses[idx] = (*imagePasses[idx])(i, j).normalized(); + if(flags & IF_IMAGE) colExtPasses[idx] = (*(*imagePasses)[idx])(i, j).normalized(); else colExtPasses[idx] = colorA_t(0.f); if(env->getRenderPasses()->intPassTypeFromExtPassIndex(idx) == PASS_INT_AA_SAMPLES) { - colExtPasses[idx] = (*imagePasses[idx])(i, j).weight; + colExtPasses[idx] = (*(*imagePasses)[idx])(i, j).weight; } if(estimateDensity && (flags & IF_DENSITYIMAGE) && idx == 0) colExtPasses[idx] += (*densityImage)(i, j) * multi; @@ -821,7 +880,7 @@ void imageFilm_t::flush(int numView, int flags, colorOutput_t *out) { for(int i = 0; i < w; i++) { - for(size_t idx = 0; idx < imagePasses.size(); ++idx) + for(size_t idx = 0; idx < imagePasses->size(); ++idx) { colorA_t &dpcol = (*dpimage)(i, j-badgeStartY); colExtPasses[idx] = colorA_t(dpcol, 1.f); @@ -841,7 +900,7 @@ void imageFilm_t::flush(int numView, int flags, colorOutput_t *out) { for(int i = 0; i < w; i++) { - for(size_t idx = 0; idx < imagePasses.size(); ++idx) + for(size_t idx = 0; idx < imagePasses->size(); ++idx) { colorA_t &dpcol = (*dpimage)(i, j-badgeStartY); colExtPasses2[idx] = colorA_t(dpcol, 1.f); @@ -978,13 +1037,13 @@ void imageFilm_t::addSample(colorPasses_t &colorPasses, int x, int y, float dx, float filterWt = filterTable[offset]; // update pixel values with filtered sample contribution - for(size_t idx = 0; idx < imagePasses.size(); ++idx) + for(size_t idx = 0; idx < imagePasses->size(); ++idx) { colorA_t col = colorPasses(env->getRenderPasses()->intPassTypeFromExtPassIndex(idx)); col.clampProportionalRGB(AA_clamp_samples); - pixel_t &pixel = (*imagePasses[idx])(i - cx0, j - cy0); + pixel_t &pixel = (*(*imagePasses)[idx])(i - cx0, j - cy0); if(premultAlpha) col.alphaPremultiply(); @@ -1414,4 +1473,58 @@ bool imageFilm_t::imageFilmSave(const std::string &filename, bool debugXMLformat return true; } + +bool imageFilm_t::imageFilmLoadReuseCheckOk() const +{ + bool checksOK = true; + + if(filmload_check.filmStructureVersion != FILM_STRUCTURE_VERSION) + { + checksOK = false; + Y_WARNING << "imageFilm: loading/reusing film check failed. Film structure version, expected=" << FILM_STRUCTURE_VERSION << ", in reused/loaded film=" << filmload_check.filmStructureVersion << yendl; + } + if(filmload_check.w != w) + { + checksOK = false; + Y_WARNING << "imageFilm: loading/reusing film check failed. Image width, expected=" << w << ", in reused/loaded film=" << filmload_check.w << yendl; + } + if(filmload_check.h != h) + { + checksOK = false; + Y_WARNING << "imageFilm: loading/reusing film check failed. Image height, expected=" << h << ", in reused/loaded film=" << filmload_check.h << yendl; + } + if(filmload_check.cx0 != cx0) + { + checksOK = false; + Y_WARNING << "imageFilm: loading/reusing film check failed. Border cx0, expected=" << cx0 << ", in reused/loaded film=" << filmload_check.cx0 << yendl; + } + if(filmload_check.cx1 != cx1) + { + checksOK = false; + Y_WARNING << "imageFilm: loading/reusing film check failed. Border cx1, expected=" << cx1 << ", in reused/loaded film=" << filmload_check.cx1 << yendl; + } + if(filmload_check.cy0 != cy0) + { + checksOK = false; + Y_WARNING << "imageFilm: loading/reusing film check failed. Border cy0, expected=" << cy0 << ", in reused/loaded film=" << filmload_check.cy0 << yendl; + } + if(filmload_check.cy1 != cy1) + { + checksOK = false; + Y_WARNING << "imageFilm: loading/reusing film check failed. Border cy1, expected=" << cy1 << ", in reused/loaded film=" << filmload_check.cy1 << yendl; + } + if(filmload_check.numPasses != (size_t) env->getRenderPasses()->extPassesSize()) + { + checksOK = false; + Y_WARNING << "imageFilm: loading/reusing film check failed. Number of render passes, expected=" << env->getRenderPasses()->extPassesSize() << ", in reused/loaded film=" << filmload_check.numPasses << yendl; + } + + if(!checksOK) Y_WARNING << "imageFilm: loading/reusing film failed because parameters are different. The film will be re-generated." << yendl; + + Y_DEBUG << "imageFilm: loading/reusing film check results=" << checksOK << ". Expected: film structure version=" << FILM_STRUCTURE_VERSION << ",w="<getRenderPasses()->extPassesSize()<<" .In Image File: film structure version="<getAAParameters(AA_samples, AA_passes, AA_inc_samples, AA_threshold, AA_resampled_floor, AA_sample_multiplier_factor, AA_light_sample_multiplier_factor, AA_indirect_sample_multiplier_factor, AA_detect_color_noise, AA_dark_detection_type, AA_dark_threshold_factor, AA_variance_edge_size, AA_variance_pixels, AA_clamp_samples, AA_clamp_indirect); diff --git a/src/yafraycore/scene.cc b/src/yafraycore/scene.cc index efd1f0a1..72a96b6d 100755 --- a/src/yafraycore/scene.cc +++ b/src/yafraycore/scene.cc @@ -47,6 +47,7 @@ __BEGIN_YAFRAY scene_t::scene_t(const renderEnvironment_t *render_environment): volIntegrator(nullptr), camera(nullptr), imageFilm(nullptr), tree(nullptr), vtree(nullptr), background(nullptr), surfIntegrator(nullptr), AA_samples(1), AA_passes(1), AA_threshold(0.05), nthreads(1), nthreads_photons(1), mode(1), signals(0), env(render_environment) { + Y_DEBUG << "*** SCENE CONSTRUCTOR ***" << yendl; state.changes = C_ALL; state.stack.push_front(READY); state.nextFreeID = std::numeric_limits::max(); @@ -66,6 +67,7 @@ scene_t::scene_t(const renderEnvironment_t *render_environment): volIntegrator( scene_t::~scene_t() { + Y_DEBUG << "*** SCENE DESTRUCTOR ***" << yendl; if(tree) delete tree; if(vtree) delete vtree; for(auto i = meshes.begin(); i != meshes.end(); ++i) diff --git a/src/yafraycore/session.cc b/src/yafraycore/session.cc index 3c65886f..45d602c4 100755 --- a/src/yafraycore/session.cc +++ b/src/yafraycore/session.cc @@ -38,6 +38,7 @@ session_t::session_t(const session_t&) //We need to redefine the copy constructo session_t::session_t() { + Y_DEBUG << "*** SESSION CONSTRUCTOR ***" << yendl; Y_VERBOSE << "Session:started" << yendl; #if defined(_WIN32) SetConsoleOutputCP(65001); //set Windows Console to UTF8 so the image path can be displayed correctly @@ -52,6 +53,7 @@ session_t::session_t() session_t::~session_t() { + Y_DEBUG << "*** SESSION DESTRUCTOR ***" << yendl; delete radianceMap; delete diffuseMap; delete causticMap; From 415f75136480cb1ad3ac96875bfe751bbd528ee7 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sat, 18 Jun 2016 17:24:02 +0100 Subject: [PATCH 093/124] Revert back all the Film Reuse changes. Too complex, too messy. To do this properly we would need very deep changes in YafaRay structure. Discarded for now --- include/core_api/imagefilm.h | 31 +++++-- include/core_api/session.h | 31 +------ src/integrators/photonintegr.cc | 4 - src/interface/yafrayinterface.cc | 3 - src/yafraycore/imagefilm.cc | 150 ++++++++++--------------------- src/yafraycore/integrator.cc | 1 - src/yafraycore/scene.cc | 2 - src/yafraycore/session.cc | 2 - 8 files changed, 72 insertions(+), 152 deletions(-) diff --git a/include/core_api/imagefilm.h b/include/core_api/imagefilm.h index 27e59cbc..38d77ea6 100755 --- a/include/core_api/imagefilm.h +++ b/include/core_api/imagefilm.h @@ -143,13 +143,14 @@ class YAFRAYCORE_EXPORT imageFilm_t void setAutoLoad(bool auto_load); bool imageFilmLoad(const std::string &filename, bool debugXMLformat); bool imageFilmSave(const std::string &filename, bool debugXMLformat); - bool imageFilmLoadReuseCheckOk() const; + bool imageFilmLoadCheckOk() const; #if HAVE_FREETYPE void drawFontBitmap( FT_Bitmap_* bitmap, int x, int y); #endif protected: + std::vector imagePasses; //!< rgba color buffers for the render passes rgb2DImage_nw_t *densityImage; //!< storage for z-buffer channel rgba2DImage_nw_t *dpimage; //!< render parameters badge image tiledBitArray2D_t<3> *flags; //!< flags for adaptive AA sampling; @@ -187,9 +188,6 @@ class YAFRAYCORE_EXPORT imageFilm_t imageSpliter_t::tilesOrderType tilesOrder; bool premultAlpha; bool premultAlpha2; //For optional secondary file output - std::vector *> * imagePasses = nullptr; //!< pointer to rgba color buffers for the render passes - std::vector *> imagePassesPreview; //!< rgba color buffers dedicated for preview renders - bool imageFilmReused = false; int nPasses; double accumulated_image_area_flush_time; unsigned int baseSamplingOffset = 0; //Base sampling offset, in case of multi-computer rendering each should have a different offset so they don't "repeat" the same samples (user configurable) @@ -198,11 +196,30 @@ class YAFRAYCORE_EXPORT imageFilm_t bool autoSave; // If enabled, it will autosave the Image Film at the same time as the image files bool autoSaveBinary; //If enabled, it will autosave the Image Film in binary mode (faster, smaller but non-portable among systems) bool autoLoad; // If enabled, it will load the image film from a file before start rendering, might be useful to continue interrupted renders but it has to be used with care. If it does not match exactly the scene, bad results or even crashes could happen. - + + struct filmload_check_t + { + int w, h, cx0, cx1, cy0, cy1; + size_t numPasses; + std::string filmStructureVersion; + friend class boost::serialization::access; + template void serialize(Archive & ar, const unsigned int version) + { + ar & BOOST_SERIALIZATION_NVP(w); + ar & BOOST_SERIALIZATION_NVP(h); + ar & BOOST_SERIALIZATION_NVP(cx0); + ar & BOOST_SERIALIZATION_NVP(cx1); + ar & BOOST_SERIALIZATION_NVP(cy0); + ar & BOOST_SERIALIZATION_NVP(cy1); + ar & BOOST_SERIALIZATION_NVP(numPasses); + ar & BOOST_SERIALIZATION_NVP(filmStructureVersion); + } + }; + //IMPORTANT: change the FILM_STRUCTURE_VERSION string if there are significant changes in the film structure #define FILM_STRUCTURE_VERSION "1.0" - filmload_check_t & filmload_check; + filmload_check_t filmload_check; friend class boost::serialization::access; template void save(Archive & ar, const unsigned int version) const @@ -217,7 +234,7 @@ class YAFRAYCORE_EXPORT imageFilm_t template void load(Archive & ar, const unsigned int version) { ar & BOOST_SERIALIZATION_NVP(filmload_check); - if(imageFilmLoadReuseCheckOk()) + if(imageFilmLoadCheckOk()) { ar & BOOST_SERIALIZATION_NVP(samplingOffset); ar & BOOST_SERIALIZATION_NVP(baseSamplingOffset); diff --git a/include/core_api/session.h b/include/core_api/session.h index 6e3a0905..5df9e192 100755 --- a/include/core_api/session.h +++ b/include/core_api/session.h @@ -27,39 +27,12 @@ #include #include #include -#include -#include -#include -#include -#include -#include #include #include __BEGIN_YAFRAY class photonMap_t; -class pixel_t; -template class generic2DBuffer_t; - -struct filmload_check_t -{ - int w, h, cx0, cx1, cy0, cy1; - size_t numPasses; - std::string filmStructureVersion; - friend class boost::serialization::access; - template void serialize(Archive & ar, const unsigned int version) - { - ar & BOOST_SERIALIZATION_NVP(w); - ar & BOOST_SERIALIZATION_NVP(h); - ar & BOOST_SERIALIZATION_NVP(cx0); - ar & BOOST_SERIALIZATION_NVP(cx1); - ar & BOOST_SERIALIZATION_NVP(cy0); - ar & BOOST_SERIALIZATION_NVP(cy1); - ar & BOOST_SERIALIZATION_NVP(numPasses); - ar & BOOST_SERIALIZATION_NVP(filmStructureVersion); - } -}; class YAFRAYCORE_EXPORT session_t { @@ -95,9 +68,7 @@ class YAFRAYCORE_EXPORT session_t photonMap_t * causticMap = nullptr; photonMap_t * diffuseMap = nullptr; photonMap_t * radianceMap = nullptr; - std::vector *> imagePasses; //!< rgba color buffers for the render passes - - filmload_check_t filmload_check; + std::mutex mutx; protected: diff --git a/src/integrators/photonintegr.cc b/src/integrators/photonintegr.cc index e1f37cf9..2bb97ba5 100755 --- a/src/integrators/photonintegr.cc +++ b/src/integrators/photonintegr.cc @@ -82,8 +82,6 @@ void photonIntegrator_t::preGatherWorker(preGatherData_t * gdata, float dsRad, i photonIntegrator_t::photonIntegrator_t(unsigned int dPhotons, unsigned int cPhotons, bool transpShad, int shadowDepth, float dsRad, float cRad) { - Y_DEBUG << "*** PHOTON INT CONSTRUCTOR ***" << yendl; - usePhotonCaustics = true; usePhotonDiffuse = true; type = SURFACE; @@ -103,8 +101,6 @@ photonIntegrator_t::photonIntegrator_t(unsigned int dPhotons, unsigned int cPhot photonIntegrator_t::~photonIntegrator_t() { // Empty - Y_DEBUG << "*** PHOTON INT DESTRUCTOR ***" << yendl; - } diff --git a/src/interface/yafrayinterface.cc b/src/interface/yafrayinterface.cc index f510ad2e..3405be28 100755 --- a/src/interface/yafrayinterface.cc +++ b/src/interface/yafrayinterface.cc @@ -51,7 +51,6 @@ void ctrl_c_handler(int signal) yafrayInterface_t::yafrayInterface_t(): scene(nullptr), film(nullptr), inputGamma(1.f), inputColorSpace(RAW_MANUAL_GAMMA) { - Y_DEBUG << "*** YAFRAY INTERFACE CONSTRUCTOR ***" << yendl; //handle CTRL+C events #ifdef WIN32 SetConsoleCtrlHandler(ctrl_c_handler, true); @@ -71,7 +70,6 @@ yafrayInterface_t::yafrayInterface_t(): scene(nullptr), film(nullptr), inputGamm yafrayInterface_t::~yafrayInterface_t() { - Y_DEBUG << "*** YAFRAY INTERFACE DESTRUCTOR ***" << yendl; Y_VERBOSE << "Interface: Deleting scene..." << yendl; if(scene) delete scene; Y_VERBOSE << "Interface: Deleting environment..." << yendl; @@ -120,7 +118,6 @@ void yafrayInterface_t::clearAll() bool yafrayInterface_t::startScene(int type) { - Y_DEBUG << "*** YAFRAY INTERFACE STARTSCENE ***" << yendl; if(scene) delete scene; scene = new scene_t(env); globalScene = scene; //for the CTRL+C handler diff --git a/src/yafraycore/imagefilm.cc b/src/yafraycore/imagefilm.cc index 27da75fd..53b4f6c9 100755 --- a/src/yafraycore/imagefilm.cc +++ b/src/yafraycore/imagefilm.cc @@ -126,61 +126,18 @@ imageFilm_t::imageFilm_t (int width, int height, int xstart, int ystart, colorOu flags(0), w(width), h(height), cx0(xstart), cy0(ystart), colorSpace(RAW_MANUAL_GAMMA), gamma(1.0), colorSpace2(RAW_MANUAL_GAMMA), gamma2(1.0), filterw(filterSize*0.5), output(&out), split(true), abort(false), saveEndPass(false), imageOutputPartialSaveTimeInterval(0.0), splitter(nullptr), pbar(nullptr), - env(e), showMask(showSamMask), tileSize(tSize), tilesOrder(tOrder), premultAlpha(pmA), premultAlpha2(false), filmload_check(session.filmload_check) + env(e), showMask(showSamMask), tileSize(tSize), tilesOrder(tOrder), premultAlpha(pmA), premultAlpha2(false) { - Y_DEBUG << "*** FILM CONSTRUCTOR ***" << yendl; cx1 = xstart + width; cy1 = ystart + height; filterTable = new float[FILTER_TABLE_SIZE * FILTER_TABLE_SIZE]; - if(imagePasses) Y_DEBUG << "imagePasses->size() = " << imagePasses->size() << yendl; - - if(output->isPreview()) + //Creation of the image buffers for the render passes + for(int idx = 0; idx < env->getRenderPasses()->extPassesSize(); ++idx) { - imagePasses = &imagePassesPreview; //During preview renders (material preview, etc) we will use dedicated color buffers for the film to avoid overwriting the persistent (session) color buffers used for scene renders - - //Creation of the image buffers for the render passes - for(int idx = 0; idx < env->getRenderPasses()->extPassesSize(); ++idx) - { - imagePasses->push_back(new rgba2DImage_t(width, height)); - } + imagePasses.push_back(new rgba2DImage_t(width, height)); } - else - { - imagePasses = &session.imagePasses; //During scene renders (material preview, etc) we will use the persistent (session) color buffers - - if(!imagePasses || imagePasses->empty()) - { - Y_DEBUG << "imagePasses EMPTY, re-generating" << yendl; - //Creation of the image buffers for the render passes - for(int idx = 0; idx < env->getRenderPasses()->extPassesSize(); ++idx) - { - imagePasses->push_back(new rgba2DImage_t(width, height)); - } - } - else if(imageFilmLoadReuseCheckOk()) - { - Y_DEBUG << "imagePasses NOT empty, resuming" << yendl; - imageFilmReused = true; - } - else - { - Y_DEBUG << "imagePasses not empty, but imageFilm reuse checks failed, re-generating" << yendl; - - //Deletion of the image buffers for the additional render passes - for(size_t idx = 0; idx < imagePasses->size(); ++idx) - { - delete((*imagePasses)[idx]); - } - imagePasses->clear(); - //Creation of the image buffers for the render passes - for(int idx = 0; idx < env->getRenderPasses()->extPassesSize(); ++idx) - { - imagePasses->push_back(new rgba2DImage_t(width, height)); - } - } - } densityImage = nullptr; estimateDensity = false; dpimage = nullptr; @@ -231,41 +188,28 @@ imageFilm_t::imageFilm_t (int width, int height, int xstart, int ystart, colorOu imageFilm_t::~imageFilm_t () { - if(output->isPreview()) + //Deletion of the image buffers for the additional render passes + for(size_t idx = 0; idx < imagePasses.size(); ++idx) { - //Deletion of the image buffers for the additional render passes - for(size_t idx = 0; idx < imagePasses->size(); ++idx) - { - delete((*imagePasses)[idx]); - } - imagePasses->clear(); + delete(imagePasses[idx]); } + imagePasses.clear(); + if(densityImage) delete densityImage; delete[] filterTable; if(splitter) delete splitter; if(dpimage) delete dpimage; if(pbar) delete pbar; //remove when pbar no longer created by imageFilm_t!! - imagePasses = nullptr; - - Y_DEBUG << "*** FILM DESTRUCTOR ***" << yendl; } void imageFilm_t::init(int numPasses) { - Y_DEBUG << "*** FILM INIT ***" << yendl; - if(!output->isPreview() && imageFilmReused && imageFilmLoadReuseCheckOk()) + // Clear color buffers + for(size_t idx = 0; idx < imagePasses.size(); ++idx) { - Y_DEBUG << "ImageFilm reused: initialization skipped" << yendl; - session.setStatusRenderResumed(); - } - else - { - // Clear color buffers - for(size_t idx = 0; idx < imagePasses->size(); ++idx) - { - (*imagePasses)[idx]->clear(); - } + imagePasses[idx]->clear(); } + // Clear density image if(estimateDensity) { @@ -293,7 +237,7 @@ void imageFilm_t::init(int numPasses) nPass = 1; nPasses = numPasses; - if(!output->isPreview()) // Avoid executing the Film Load / Save operations and updating the film check values when we are just rendering a preview! + if(!output->isPreview()) // Avoid doing the Film Load & Save operations and updating the film check values when we are just rendering a preview! { if(autoLoad) { @@ -340,15 +284,15 @@ void imageFilm_t::init(int numPasses) imageFilm_t *loadedFilm = new imageFilm_t(w, h, cx0, cy0, *output, 1.0, BOX, env); loadedFilm->imageFilmLoad(filmFile, false); - for(size_t idx=0; idxsize(); ++idx) + for(size_t idx=0; idximagePasses))[idx]; for(int i=0; iimagePasses[idx]; + (*imagePasses[idx])(i,j).col += (*loadedImageBuffer)(i,j).col; + (*imagePasses[idx])(i,j).weight += (*loadedImageBuffer)(i,j).weight; } } } @@ -366,7 +310,7 @@ void imageFilm_t::init(int numPasses) if(pbar) pbar->setTag(oldTag); } - + if(autoSave) //If the imageFilm is set to Auto Save, at the start rename the previous film file as a "backup" just in case the user has made a mistake and wants to get the previous film back. { std::stringstream passString; @@ -413,7 +357,7 @@ void imageFilm_t::init(int numPasses) filmload_check.cx1 = cx1; filmload_check.cy0 = cy0; filmload_check.cy1 = cy1; - filmload_check.numPasses = imagePasses->size(); + filmload_check.numPasses = imagePasses.size(); } } @@ -445,7 +389,7 @@ int imageFilm_t::nextPass(int numView, bool adaptive_AA, std::string integratorN if(flags) flags->clear(); else flags = new tiledBitArray2D_t<3>(w, h, true); - std::vector colExtPasses(imagePasses->size(), colorA_t(0.f)); + std::vector colExtPasses(imagePasses.size(), colorA_t(0.f)); int variance_half_edge = AA_variance_edge_size / 2; float AA_thresh_scaled = AA_thesh; @@ -468,9 +412,9 @@ int imageFilm_t::nextPass(int numView, bool adaptive_AA, std::string integratorN { //We will only consider the Combined Pass (pass 0) for the AA additional sampling calculations. - if((*imagePasses->at(0))(x, y).weight <= 0.f) flags->setBit(x, y); //If after reloading ImageFiles there are pixels that were not yet rendered at all, make sure they are marked to be rendered in the next AA pass + if((*imagePasses.at(0))(x, y).weight <= 0.f) flags->setBit(x, y); //If after reloading ImageFiles there are pixels that were not yet rendered at all, make sure they are marked to be rendered in the next AA pass - colorA_t pixCol = (*imagePasses->at(0))(x, y).normalized(); + colorA_t pixCol = (*imagePasses.at(0))(x, y).normalized(); float pixColBri = pixCol.abscol2bri(); if(AA_dark_detection_type == DARK_DETECTION_LINEAR && AA_dark_threshold_factor > 0.f) @@ -482,19 +426,19 @@ int imageFilm_t::nextPass(int numView, bool adaptive_AA, std::string integratorN AA_thresh_scaled = dark_threshold_curve_interpolate(pixColBri); } - if(pixCol.colorDifference((*imagePasses->at(0))(x+1, y).normalized(), AA_detect_color_noise) >= AA_thresh_scaled) + if(pixCol.colorDifference((*imagePasses.at(0))(x+1, y).normalized(), AA_detect_color_noise) >= AA_thresh_scaled) { flags->setBit(x, y); flags->setBit(x+1, y); } - if(pixCol.colorDifference((*imagePasses->at(0))(x, y+1).normalized(), AA_detect_color_noise) >= AA_thresh_scaled) + if(pixCol.colorDifference((*imagePasses.at(0))(x, y+1).normalized(), AA_detect_color_noise) >= AA_thresh_scaled) { flags->setBit(x, y); flags->setBit(x, y+1); } - if(pixCol.colorDifference((*imagePasses->at(0))(x+1, y+1).normalized(), AA_detect_color_noise) >= AA_thresh_scaled) + if(pixCol.colorDifference((*imagePasses.at(0))(x+1, y+1).normalized(), AA_detect_color_noise) >= AA_thresh_scaled) { flags->setBit(x, y); flags->setBit(x+1, y+1); } - if(x > 0 && pixCol.colorDifference((*imagePasses->at(0))(x-1, y+1).normalized(), AA_detect_color_noise) >= AA_thresh_scaled) + if(x > 0 && pixCol.colorDifference((*imagePasses.at(0))(x-1, y+1).normalized(), AA_detect_color_noise) >= AA_thresh_scaled) { flags->setBit(x, y); flags->setBit(x-1, y+1); } @@ -511,8 +455,8 @@ int imageFilm_t::nextPass(int numView, bool adaptive_AA, std::string integratorN if(xi<0) xi = 0; else if(xi>=w-1) xi = w-2; - colorA_t cx0 = (*imagePasses->at(0))(xi, y).normalized(); - colorA_t cx1 = (*imagePasses->at(0))(xi+1, y).normalized(); + colorA_t cx0 = (*imagePasses.at(0))(xi, y).normalized(); + colorA_t cx1 = (*imagePasses.at(0))(xi+1, y).normalized(); if(cx0.colorDifference(cx1, AA_detect_color_noise) >= AA_thresh_scaled) ++variance_x; } @@ -523,8 +467,8 @@ int imageFilm_t::nextPass(int numView, bool adaptive_AA, std::string integratorN if(yi<0) yi = 0; else if(yi>=h-1) yi = h-2; - colorA_t cy0 = (*imagePasses->at(0))(x, yi).normalized(); - colorA_t cy1 = (*imagePasses->at(0))(x, yi+1).normalized(); + colorA_t cy0 = (*imagePasses.at(0))(x, yi).normalized(); + colorA_t cy1 = (*imagePasses.at(0))(x, yi+1).normalized(); if(cy0.colorDifference(cy1, AA_detect_color_noise) >= AA_thresh_scaled) ++variance_y; } @@ -561,9 +505,9 @@ int imageFilm_t::nextPass(int numView, bool adaptive_AA, std::string integratorN if(session.isInteractive() && showMask) { - for(size_t idx = 0; idx < imagePasses->size(); ++idx) + for(size_t idx = 0; idx < imagePasses.size(); ++idx) { - color_t pix = (*(*imagePasses)[idx])(x, y).normalized(); + color_t pix = (*imagePasses[idx])(x, y).normalized(); float pixColBri = pix.abscol2bri(); if(pix.R < pix.G && pix.R < pix.B) @@ -655,19 +599,19 @@ void imageFilm_t::finishArea(int numView, renderArea_t &a) int end_x = a.X+a.W-cx0, end_y = a.Y+a.H-cy0; - std::vector colExtPasses(imagePasses->size(), colorA_t(0.f)); + std::vector colExtPasses(imagePasses.size(), colorA_t(0.f)); for(int j=a.Y-cy0; jsize(); ++idx) + for(size_t idx = 0; idx < imagePasses.size(); ++idx) { - colExtPasses[idx] = (*(*imagePasses)[idx])(i, j).normalized(); + colExtPasses[idx] = (*imagePasses[idx])(i, j).normalized(); if(env->getRenderPasses()->intPassTypeFromExtPassIndex(idx) == PASS_INT_AA_SAMPLES) { - colExtPasses[idx] = (*(*imagePasses)[idx])(i, j).weight; + colExtPasses[idx] = (*imagePasses[idx])(i, j).weight; } colExtPasses[idx].clampRGB0(); @@ -808,10 +752,10 @@ void imageFilm_t::flush(int numView, int flags, colorOutput_t *out) if(estimateDensity) multi = (float) (w * h) / (float) numSamples; - std::vector colExtPasses(imagePasses->size(), colorA_t(0.f)); + std::vector colExtPasses(imagePasses.size(), colorA_t(0.f)); std::vector colExtPasses2; //For secondary file output (when enabled) - if(out2) colExtPasses2.resize(imagePasses->size(), colorA_t(0.f)); + if(out2) colExtPasses2.resize(imagePasses.size(), colorA_t(0.f)); int outputDisplaceRenderedImageBadgeHeight = 0, out2DisplaceRenderedImageBadgeHeight = 0; @@ -823,14 +767,14 @@ void imageFilm_t::flush(int numView, int flags, colorOutput_t *out) { for(int i = 0; i < w; i++) { - for(size_t idx = 0; idx < imagePasses->size(); ++idx) + for(size_t idx = 0; idx < imagePasses.size(); ++idx) { - if(flags & IF_IMAGE) colExtPasses[idx] = (*(*imagePasses)[idx])(i, j).normalized(); + if(flags & IF_IMAGE) colExtPasses[idx] = (*imagePasses[idx])(i, j).normalized(); else colExtPasses[idx] = colorA_t(0.f); if(env->getRenderPasses()->intPassTypeFromExtPassIndex(idx) == PASS_INT_AA_SAMPLES) { - colExtPasses[idx] = (*(*imagePasses)[idx])(i, j).weight; + colExtPasses[idx] = (*imagePasses[idx])(i, j).weight; } if(estimateDensity && (flags & IF_DENSITYIMAGE) && idx == 0) colExtPasses[idx] += (*densityImage)(i, j) * multi; @@ -880,7 +824,7 @@ void imageFilm_t::flush(int numView, int flags, colorOutput_t *out) { for(int i = 0; i < w; i++) { - for(size_t idx = 0; idx < imagePasses->size(); ++idx) + for(size_t idx = 0; idx < imagePasses.size(); ++idx) { colorA_t &dpcol = (*dpimage)(i, j-badgeStartY); colExtPasses[idx] = colorA_t(dpcol, 1.f); @@ -900,7 +844,7 @@ void imageFilm_t::flush(int numView, int flags, colorOutput_t *out) { for(int i = 0; i < w; i++) { - for(size_t idx = 0; idx < imagePasses->size(); ++idx) + for(size_t idx = 0; idx < imagePasses.size(); ++idx) { colorA_t &dpcol = (*dpimage)(i, j-badgeStartY); colExtPasses2[idx] = colorA_t(dpcol, 1.f); @@ -1037,13 +981,13 @@ void imageFilm_t::addSample(colorPasses_t &colorPasses, int x, int y, float dx, float filterWt = filterTable[offset]; // update pixel values with filtered sample contribution - for(size_t idx = 0; idx < imagePasses->size(); ++idx) + for(size_t idx = 0; idx < imagePasses.size(); ++idx) { colorA_t col = colorPasses(env->getRenderPasses()->intPassTypeFromExtPassIndex(idx)); col.clampProportionalRGB(AA_clamp_samples); - pixel_t &pixel = (*(*imagePasses)[idx])(i - cx0, j - cy0); + pixel_t &pixel = (*imagePasses[idx])(i - cx0, j - cy0); if(premultAlpha) col.alphaPremultiply(); @@ -1474,7 +1418,7 @@ bool imageFilm_t::imageFilmSave(const std::string &filename, bool debugXMLformat } -bool imageFilm_t::imageFilmLoadReuseCheckOk() const +bool imageFilm_t::imageFilmLoadCheckOk() const { bool checksOK = true; diff --git a/src/yafraycore/integrator.cc b/src/yafraycore/integrator.cc index 143262ee..23ed9a1f 100755 --- a/src/yafraycore/integrator.cc +++ b/src/yafraycore/integrator.cc @@ -112,7 +112,6 @@ void tiledIntegrator_t::precalcDepths() bool tiledIntegrator_t::render(int numView, imageFilm_t *image) { - Y_DEBUG << "*** INTEGRATOR RENDER ***" << yendl; std::stringstream passString; imageFilm = image; scene->getAAParameters(AA_samples, AA_passes, AA_inc_samples, AA_threshold, AA_resampled_floor, AA_sample_multiplier_factor, AA_light_sample_multiplier_factor, AA_indirect_sample_multiplier_factor, AA_detect_color_noise, AA_dark_detection_type, AA_dark_threshold_factor, AA_variance_edge_size, AA_variance_pixels, AA_clamp_samples, AA_clamp_indirect); diff --git a/src/yafraycore/scene.cc b/src/yafraycore/scene.cc index 72a96b6d..efd1f0a1 100755 --- a/src/yafraycore/scene.cc +++ b/src/yafraycore/scene.cc @@ -47,7 +47,6 @@ __BEGIN_YAFRAY scene_t::scene_t(const renderEnvironment_t *render_environment): volIntegrator(nullptr), camera(nullptr), imageFilm(nullptr), tree(nullptr), vtree(nullptr), background(nullptr), surfIntegrator(nullptr), AA_samples(1), AA_passes(1), AA_threshold(0.05), nthreads(1), nthreads_photons(1), mode(1), signals(0), env(render_environment) { - Y_DEBUG << "*** SCENE CONSTRUCTOR ***" << yendl; state.changes = C_ALL; state.stack.push_front(READY); state.nextFreeID = std::numeric_limits::max(); @@ -67,7 +66,6 @@ scene_t::scene_t(const renderEnvironment_t *render_environment): volIntegrator( scene_t::~scene_t() { - Y_DEBUG << "*** SCENE DESTRUCTOR ***" << yendl; if(tree) delete tree; if(vtree) delete vtree; for(auto i = meshes.begin(); i != meshes.end(); ++i) diff --git a/src/yafraycore/session.cc b/src/yafraycore/session.cc index 45d602c4..3c65886f 100755 --- a/src/yafraycore/session.cc +++ b/src/yafraycore/session.cc @@ -38,7 +38,6 @@ session_t::session_t(const session_t&) //We need to redefine the copy constructo session_t::session_t() { - Y_DEBUG << "*** SESSION CONSTRUCTOR ***" << yendl; Y_VERBOSE << "Session:started" << yendl; #if defined(_WIN32) SetConsoleOutputCP(65001); //set Windows Console to UTF8 so the image path can be displayed correctly @@ -53,7 +52,6 @@ session_t::session_t() session_t::~session_t() { - Y_DEBUG << "*** SESSION DESTRUCTOR ***" << yendl; delete radianceMap; delete diffuseMap; delete causticMap; From c6fb9ce1a4b232b0c37fddd39b2b0c402affff51 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sat, 18 Jun 2016 19:44:24 +0100 Subject: [PATCH 094/124] Images/ImageFilm segregated autosave options, pending recoding all processing, internal enums, timers, counters, etc. Work in progress --- src/yafraycore/environment.cc | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/yafraycore/environment.cc b/src/yafraycore/environment.cc index 01ca7d0f..ddfbc9c9 100755 --- a/src/yafraycore/environment.cc +++ b/src/yafraycore/environment.cc @@ -531,12 +531,22 @@ imageFilm_t* renderEnvironment_t::createImageFilm(const paraMap_t ¶ms, color int tileSize = 32; bool premult = false; bool premult2 = false; + float partial_save_timer = 0.f; bool partial_save_each_pass = false; bool film_autosave = false; bool film_save_binary_format = true; bool film_load = false; - + + std::string images_autosave_interval_type_string = "none"; + int images_autosave_interval_passes = 1; + int images_autosave_interval_seconds = 300; + + std::string film_save_load_string = "none"; + std::string film_autosave_interval_type_string = "pass-interval"; + int film_autosave_interval_passes = 1; + int film_autosave_interval_seconds = 300; + params.getParam("color_space", color_space_string); params.getParam("gamma", gamma); params.getParam("color_space2", color_space_string2); @@ -557,7 +567,19 @@ imageFilm_t* renderEnvironment_t::createImageFilm(const paraMap_t ¶ms, color params.getParam("film_autosave", film_autosave); // If enabled, it will autosave the Image Film at the same time as the image files params.getParam("film_save_binary_format", film_save_binary_format); // If enabled, it will autosave the Image Film in binary format (faster, smaller, but not portable). Otherwise it will autosave in text format (portable but bigger and slower) params.getParam("film_load", film_load); // If enabled, it will load the image film from a file before start rendering, might be useful to continue interrupted renders but it has to be used with care. If it does not match exactly the scene, bad results or even crashes could happen + params.getParam("images_autosave_interval_type", images_autosave_interval_type_string); + params.getParam("images_autosave_interval_passes", images_autosave_interval_passes); + params.getParam("images_autosave_interval_seconds", images_autosave_interval_seconds); + + params.getParam("film_save_load", film_save_load_string); + params.getParam("film_autosave_interval_type", film_autosave_interval_type_string); + params.getParam("film_autosave_interval_passes", film_autosave_interval_passes); + params.getParam("film_autosave_interval_seconds", film_autosave_interval_seconds); + Y_DEBUG << "Images autosave: " << images_autosave_interval_type_string << ", " << images_autosave_interval_passes << ", " << images_autosave_interval_seconds << yendl; + + Y_DEBUG << "ImageFilm autosave: " << film_save_load_string << ", " << film_autosave_interval_type_string << ", " << film_autosave_interval_passes << ", " << film_autosave_interval_seconds << yendl; + if(color_space_string == "sRGB") color_space = SRGB; else if(color_space_string == "XYZ") color_space = XYZ_D65; else if(color_space_string == "LinearRGB") color_space = LINEAR_RGB; From a0dfa5c983c10594401a996b359a7b8b20b931b3 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sun, 19 Jun 2016 06:11:03 +0100 Subject: [PATCH 095/124] Image/Film saving, new parameters, first tests - work in progress --- include/core_api/imagefilm.h | 75 ++++++++++++++++++++++++----------- src/yafraycore/environment.cc | 73 ++++++++++++++++++---------------- src/yafraycore/imagefilm.cc | 44 +++++--------------- 3 files changed, 100 insertions(+), 92 deletions(-) diff --git a/include/core_api/imagefilm.h b/include/core_api/imagefilm.h index 38d77ea6..eae988b1 100755 --- a/include/core_api/imagefilm.h +++ b/include/core_api/imagefilm.h @@ -59,6 +59,20 @@ enum darkDetectionType_t DARK_DETECTION_CURVE, }; +enum autoSaveIntervalType_t +{ + AUTOSAVE_NONE, + AUTOSAVE_TIME_INTERVAL, + AUTOSAVE_PASS_INTERVAL, +}; + +enum filmFileSaveLoad_t +{ + FILM_FILE_NONE, + FILM_FILE_SAVE, + FILM_FILE_LOAD_SAVE, +}; + class YAFRAYCORE_EXPORT imageFilm_t { public: @@ -116,9 +130,6 @@ class YAFRAYCORE_EXPORT imageFilm_t void setPremult2(bool premult); /*! Sets the adaptative AA sampling threshold */ void setAAThreshold(float thresh){ AA_thesh=thresh; } - /*! Enables partial image saving during render every time_interval seconds. Time=0.0 (default) disables partial saving. */ - void setImageOutputPartialSaveTimeInterval(double time_interval){ imageOutputPartialSaveTimeInterval = time_interval; } - void setImageOutputPartialSaveEndPass(bool save_end_pass) { saveEndPass = save_end_pass; } /*! Sets a custom progress bar in the image film */ void setProgressBar(progressBar_t *pb); /*! The following methods set the strings used for the parameters badge rendering */ @@ -138,12 +149,19 @@ class YAFRAYCORE_EXPORT imageFilm_t void setComputerNode(unsigned int computer_node) { computerNode = computer_node; } void setBaseSamplingOffset(unsigned int offset) { baseSamplingOffset = offset; } void setSamplingOffset(unsigned int offset) { samplingOffset = offset; } - void setAutoSave(bool auto_save); - void setAutoSaveBinary(bool auto_save_binary); - void setAutoLoad(bool auto_load); - bool imageFilmLoad(const std::string &filename, bool debugXMLformat); - bool imageFilmSave(const std::string &filename, bool debugXMLformat); + bool imageFilmLoad(const std::string &filename, bool debugXMLformat = false); + bool imageFilmSave(const std::string &filename, bool debugXMLformat = false); bool imageFilmLoadCheckOk() const; + + void setImagesAutoSaveIntervalType(int interval_type) { imagesAutoSaveIntervalType = interval_type; } + void setImagesAutoSaveIntervalSeconds(double interval_seconds) { imagesAutoSaveIntervalSeconds = interval_seconds; } + void setImagesAutoSaveIntervalPasses(int interval_passes) { imagesAutoSaveIntervalPasses = interval_passes; } + + void setFilmFileSaveLoad(int film_file_save_load) { filmFileSaveLoad = film_file_save_load; } + void setFilmFileSaveBinaryFormat(bool binary_format) { filmFileSaveBinaryFormat = binary_format; } + void setFilmAutoSaveIntervalType(int interval_type) { filmAutoSaveIntervalType = interval_type; } + void setFilmAutoSaveIntervalSeconds(double interval_seconds) { filmAutoSaveIntervalSeconds = interval_seconds; } + void setFilmAutoSaveIntervalPasses(int interval_passes) { filmAutoSaveIntervalPasses = interval_passes; } #if HAVE_FREETYPE void drawFontBitmap( FT_Bitmap_* bitmap, int x, int y); @@ -153,15 +171,15 @@ class YAFRAYCORE_EXPORT imageFilm_t std::vector imagePasses; //!< rgba color buffers for the render passes rgb2DImage_nw_t *densityImage; //!< storage for z-buffer channel rgba2DImage_nw_t *dpimage; //!< render parameters badge image - tiledBitArray2D_t<3> *flags; //!< flags for adaptive AA sampling; + tiledBitArray2D_t<3> *flags = nullptr; //!< flags for adaptive AA sampling; int dpHeight; //!< height of the rendering parameters badge; int w, h, cx0, cx1, cy0, cy1; int area_cnt, completed_cnt; volatile int next_area; - colorSpaces_t colorSpace; - float gamma; - colorSpaces_t colorSpace2; //For optional secondary file output - float gamma2; //For optional secondary file output + colorSpaces_t colorSpace = RAW_MANUAL_GAMMA; + float gamma = 1.f; + colorSpaces_t colorSpace2 = RAW_MANUAL_GAMMA; //For optional secondary file output + float gamma2 = 1.f; //For optional secondary file output float AA_thesh; bool AA_detect_color_noise; int AA_dark_detection_type; @@ -174,29 +192,38 @@ class YAFRAYCORE_EXPORT imageFilm_t colorOutput_t *output; // Thread mutes for shared access std::mutex imageMutex, splitterMutex, outMutex, densityImageMutex; - bool split, abort; - bool saveEndPass; - double imageOutputPartialSaveTimeInterval; + bool split = true; + bool abort = false; bool estimateDensity; int numSamples; - imageSpliter_t *splitter; - progressBar_t *pbar; + imageSpliter_t *splitter = nullptr; + progressBar_t *pbar = nullptr; renderEnvironment_t *env; int nPass; bool showMask; int tileSize; imageSpliter_t::tilesOrderType tilesOrder; bool premultAlpha; - bool premultAlpha2; //For optional secondary file output + bool premultAlpha2 = false; //For optional secondary file output int nPasses; - double accumulated_image_area_flush_time; unsigned int baseSamplingOffset = 0; //Base sampling offset, in case of multi-computer rendering each should have a different offset so they don't "repeat" the same samples (user configurable) unsigned int samplingOffset = 0; //To ensure sampling after loading the image film continues and does not repeat already done samples unsigned int computerNode = 0; //Computer node in multi-computer render environments/render farms - bool autoSave; // If enabled, it will autosave the Image Film at the same time as the image files - bool autoSaveBinary; //If enabled, it will autosave the Image Film in binary mode (faster, smaller but non-portable among systems) - bool autoLoad; // If enabled, it will load the image film from a file before start rendering, might be useful to continue interrupted renders but it has to be used with care. If it does not match exactly the scene, bad results or even crashes could happen. - + + double accumulated_image_area_flush_time = 0.0; //Internal accumulated time used for Image or Film Time-Interval AutoSave feature + + //Options for AutoSaving output images + int imagesAutoSaveIntervalType = AUTOSAVE_NONE; + double imagesAutoSaveIntervalSeconds = 300.0; + int imagesAutoSaveIntervalPasses = 1; + + //Options for Saving/AutoSaving/Loading the internal imageFilm image buffers + int filmFileSaveLoad = FILM_FILE_NONE; + bool filmFileSaveBinaryFormat = true; + int filmAutoSaveIntervalType = AUTOSAVE_NONE; + double filmAutoSaveIntervalSeconds = 300.0; + int filmAutoSaveIntervalPasses = 1; + struct filmload_check_t { int w, h, cx0, cx1, cy0, cy1; diff --git a/src/yafraycore/environment.cc b/src/yafraycore/environment.cc index ddfbc9c9..fa3a5733 100755 --- a/src/yafraycore/environment.cc +++ b/src/yafraycore/environment.cc @@ -531,21 +531,17 @@ imageFilm_t* renderEnvironment_t::createImageFilm(const paraMap_t ¶ms, color int tileSize = 32; bool premult = false; bool premult2 = false; - - float partial_save_timer = 0.f; - bool partial_save_each_pass = false; - bool film_autosave = false; - bool film_save_binary_format = true; - bool film_load = false; - std::string images_autosave_interval_type_string = "none"; + int images_autosave_interval_type = AUTOSAVE_NONE; int images_autosave_interval_passes = 1; - int images_autosave_interval_seconds = 300; - + double images_autosave_interval_seconds = 300.0; std::string film_save_load_string = "none"; - std::string film_autosave_interval_type_string = "pass-interval"; + int film_save_load = FILM_FILE_NONE; + bool film_save_binary_format = true; + std::string film_autosave_interval_type_string = "none"; + int film_autosave_interval_type = AUTOSAVE_NONE; int film_autosave_interval_passes = 1; - int film_autosave_interval_seconds = 300; + double film_autosave_interval_seconds = 300.0; params.getParam("color_space", color_space_string); params.getParam("gamma", gamma); @@ -562,16 +558,11 @@ imageFilm_t* renderEnvironment_t::createImageFilm(const paraMap_t ¶ms, color params.getParam("tiles_order", tiles_order); // Order of the render buckets or tiles params.getParam("premult", premult); // Premultipy Alpha channel for better alpha antialiasing against bg params.getParam("premult2", premult2); // Premultipy Alpha channel for better alpha antialiasing against bg, for the optional secondary output - params.getParam("partial_save_timer", partial_save_timer); // Time for partially save image - params.getParam("partial_save_each_pass", partial_save_each_pass); // If enabled, it will autosave the image at the end of each pass - params.getParam("film_autosave", film_autosave); // If enabled, it will autosave the Image Film at the same time as the image files - params.getParam("film_save_binary_format", film_save_binary_format); // If enabled, it will autosave the Image Film in binary format (faster, smaller, but not portable). Otherwise it will autosave in text format (portable but bigger and slower) - params.getParam("film_load", film_load); // If enabled, it will load the image film from a file before start rendering, might be useful to continue interrupted renders but it has to be used with care. If it does not match exactly the scene, bad results or even crashes could happen params.getParam("images_autosave_interval_type", images_autosave_interval_type_string); params.getParam("images_autosave_interval_passes", images_autosave_interval_passes); params.getParam("images_autosave_interval_seconds", images_autosave_interval_seconds); - params.getParam("film_save_load", film_save_load_string); + params.getParam("film_save_binary_format", film_save_binary_format); // If enabled, it will autosave the Image Film in binary format (faster, smaller, but not portable). Otherwise it will autosave in text format (portable but bigger and slower) params.getParam("film_autosave_interval_type", film_autosave_interval_type_string); params.getParam("film_autosave_interval_passes", film_autosave_interval_passes); params.getParam("film_autosave_interval_seconds", film_autosave_interval_seconds); @@ -592,6 +583,18 @@ imageFilm_t* renderEnvironment_t::createImageFilm(const paraMap_t ¶ms, color else if(color_space_string2 == "Raw_Manual_Gamma") color_space2 = RAW_MANUAL_GAMMA; else color_space2 = SRGB; + if(images_autosave_interval_type_string == "pass-interval") images_autosave_interval_type = AUTOSAVE_PASS_INTERVAL; + else if(images_autosave_interval_type_string == "time-interval") images_autosave_interval_type = AUTOSAVE_TIME_INTERVAL; + else images_autosave_interval_type = AUTOSAVE_NONE; + + if(film_save_load_string == "load-save") film_save_load = FILM_FILE_LOAD_SAVE; + else if(film_save_load_string == "save") film_save_load = FILM_FILE_SAVE; + else film_save_load = FILM_FILE_NONE; + + if(film_autosave_interval_type_string == "pass-interval") film_autosave_interval_type = AUTOSAVE_PASS_INTERVAL; + else if(film_autosave_interval_type_string == "time-interval") film_autosave_interval_type = AUTOSAVE_TIME_INTERVAL; + else film_autosave_interval_type = AUTOSAVE_NONE; + output.initTilesPasses(camera_table.size(), renderPasses.extPassesSize()); imageFilm_t::filterType type=imageFilm_t::BOX; @@ -631,28 +634,28 @@ imageFilm_t* renderEnvironment_t::createImageFilm(const paraMap_t ¶ms, color film->setPremult2(premult2); - if(partial_save_each_pass) - { - Y_INFO_ENV << "Autosave partially rendered image at the end of each pass" << yendl; - film->setImageOutputPartialSaveTimeInterval(0.0); - film->setImageOutputPartialSaveEndPass(true); - } - else - { - Y_INFO_ENV << "Autosave partially rendered image using time interval = " << partial_save_timer << "s" << yendl; - if(partial_save_timer > 0.f) film->setImageOutputPartialSaveTimeInterval((double) partial_save_timer); - film->setImageOutputPartialSaveEndPass(false); - } + film->setImagesAutoSaveIntervalType(images_autosave_interval_type); + film->setImagesAutoSaveIntervalSeconds(images_autosave_interval_seconds); + film->setImagesAutoSaveIntervalPasses(images_autosave_interval_passes); - film->setAutoSave(film_autosave); - film->setAutoSaveBinary(film_save_binary_format); + film->setFilmFileSaveLoad(film_save_load); + film->setFilmFileSaveBinaryFormat(film_save_binary_format); + film->setFilmAutoSaveIntervalType(film_autosave_interval_type); + film->setFilmAutoSaveIntervalSeconds(film_autosave_interval_seconds); + film->setFilmAutoSaveIntervalPasses(film_autosave_interval_passes); - if(film_autosave && film_save_binary_format) Y_INFO_ENV << "Enabling imageFilm AutoSave feature in binary format (smaller, faster but not portable among systems)" << yendl; - if(film_autosave && !film_save_binary_format) Y_INFO_ENV << "Enabling imageFilm AutoSave feature in text format (portable among systems but bigger and slower)" << yendl; + if(images_autosave_interval_type == AUTOSAVE_PASS_INTERVAL) Y_INFO_ENV << "AutoSave partially rendered image every " << images_autosave_interval_passes << " passes" << yendl; + + if(images_autosave_interval_type == AUTOSAVE_TIME_INTERVAL) Y_INFO_ENV << "AutoSave partially rendered image every " << images_autosave_interval_seconds << " seconds" << yendl; - film->setAutoLoad(film_load); - if(film_load) Y_INFO_ENV << "Enabling imageFilm AutoLoad feature. It will load and combine all ImageFilm files (*.film) from the currently selected image output folder before start rendering, autodetecting each film format (binary/text) automatically. If they don't match exactly the scene, bad results could happen. Use WITH CARE!" << yendl; + if(film_save_load != FILM_FILE_NONE && film_save_binary_format) Y_INFO_ENV << "Enabling imageFilm file saving feature in binary format (smaller, faster but not portable among systems)" << yendl; + if(film_save_load != FILM_FILE_NONE && !film_save_binary_format) Y_INFO_ENV << "Enabling imageFilm file saving in text format (portable among systems but bigger and slower)" << yendl; + if(film_save_load == FILM_FILE_LOAD_SAVE) Y_INFO_ENV << "Enabling imageFilm Loading feature. It will load and combine the ImageFilm files from the currently selected image output folder before start rendering, autodetecting each film format (binary/text) automatically. If they don't match exactly the scene, bad results could happen. Use WITH CARE!" << yendl; + if(film_autosave_interval_type == AUTOSAVE_PASS_INTERVAL) Y_INFO_ENV << "AutoSave internal imageFilm every " << film_autosave_interval_passes << " passes" << yendl; + + if(film_autosave_interval_type == AUTOSAVE_TIME_INTERVAL) Y_INFO_ENV << "AutoSave internal imageFilm image every " << film_autosave_interval_seconds << " seconds" << yendl; + return film; } diff --git a/src/yafraycore/imagefilm.cc b/src/yafraycore/imagefilm.cc index 53b4f6c9..ea35fc6a 100755 --- a/src/yafraycore/imagefilm.cc +++ b/src/yafraycore/imagefilm.cc @@ -123,10 +123,8 @@ float Lanczos2(float dx, float dy) imageFilm_t::imageFilm_t (int width, int height, int xstart, int ystart, colorOutput_t &out, float filterSize, filterType filt, renderEnvironment_t *e, bool showSamMask, int tSize, imageSpliter_t::tilesOrderType tOrder, bool pmA): - flags(0), w(width), h(height), cx0(xstart), cy0(ystart), colorSpace(RAW_MANUAL_GAMMA), - gamma(1.0), colorSpace2(RAW_MANUAL_GAMMA), gamma2(1.0), filterw(filterSize*0.5), output(&out), - split(true), abort(false), saveEndPass(false), imageOutputPartialSaveTimeInterval(0.0), splitter(nullptr), pbar(nullptr), - env(e), showMask(showSamMask), tileSize(tSize), tilesOrder(tOrder), premultAlpha(pmA), premultAlpha2(false) + w(width), h(height), cx0(xstart), cy0(ystart), filterw(filterSize*0.5), output(&out), + env(e), showMask(showSamMask), tileSize(tSize), tilesOrder(tOrder), premultAlpha(pmA) { cx1 = xstart + width; cy1 = ystart + height; @@ -177,12 +175,7 @@ imageFilm_t::imageFilm_t (int width, int height, int xstart, int ystart, colorOu AA_dark_threshold_factor = 0.f; AA_variance_edge_size = 10; AA_variance_pixels = 0; - AA_clamp_samples = 0.f; - - autoSave = false; - autoSaveBinary = true; - autoLoad = false; - + AA_clamp_samples = 0.f; } imageFilm_t::~imageFilm_t () @@ -239,7 +232,7 @@ void imageFilm_t::init(int numPasses) if(!output->isPreview()) // Avoid doing the Film Load & Save operations and updating the film check values when we are just rendering a preview! { - if(autoLoad) + if(filmFileSaveLoad == FILM_FILE_LOAD_SAVE) { std::stringstream passString; passString << "Loading ImageFilm files"; @@ -311,7 +304,7 @@ void imageFilm_t::init(int numPasses) if(pbar) pbar->setTag(oldTag); } - if(autoSave) //If the imageFilm is set to Auto Save, at the start rename the previous film file as a "backup" just in case the user has made a mistake and wants to get the previous film back. + if(filmFileSaveLoad == FILM_FILE_LOAD_SAVE || filmFileSaveLoad == FILM_FILE_SAVE) //If the imageFilm is set to Save, at the start rename the previous film file as a "backup" just in case the user has made a mistake and wants to get the previous film back. { std::stringstream passString; passString << "Creating backup of the previous ImageFilm file..."; @@ -373,14 +366,14 @@ int imageFilm_t::nextPass(int numView, bool adaptive_AA, std::string integratorN { colorOutput_t *out2 = env->getOutput2(); - if(out2 && saveEndPass && session.renderInProgress()) + if(out2 && (imagesAutoSaveIntervalType == AUTOSAVE_PASS_INTERVAL) && (nPass % imagesAutoSaveIntervalPasses == 0) && session.renderInProgress()) { this->flush(numView, IF_ALL, out2); } } else { - if(output && saveEndPass && session.renderInProgress()) + if(output && (imagesAutoSaveIntervalType == AUTOSAVE_PASS_INTERVAL) && (nPass % imagesAutoSaveIntervalPasses == 0) && session.renderInProgress()) { this->flush(numView, IF_ALL, output); } @@ -637,7 +630,7 @@ void imageFilm_t::finishArea(int numView, renderArea_t &a) colorOutput_t *out2 = env->getOutput2(); - if(out2 && session.renderInProgress() && ((imageOutputPartialSaveTimeInterval > 0.f) && ((accumulated_image_area_flush_time > imageOutputPartialSaveTimeInterval) ||accumulated_image_area_flush_time == 0.0))) + if(out2 && session.renderInProgress() && (imagesAutoSaveIntervalType == AUTOSAVE_TIME_INTERVAL) && ((accumulated_image_area_flush_time > imagesAutoSaveIntervalSeconds) || accumulated_image_area_flush_time == 0.0)) { this->flush(numView, IF_ALL, out2); reset_accumulated_image_area_flush_time(); @@ -651,7 +644,7 @@ void imageFilm_t::finishArea(int numView, renderArea_t &a) if(accumulated_image_area_flush_time < 0.f) reset_accumulated_image_area_flush_time(); //to solve some strange very negative value when using yafaray-xml, race condition somewhere? gTimer.start("image_area_flush"); - if(session.renderInProgress() && (imageOutputPartialSaveTimeInterval > 0.f) && ((accumulated_image_area_flush_time > imageOutputPartialSaveTimeInterval) ||accumulated_image_area_flush_time == 0.0)) + if(session.renderInProgress() && (imagesAutoSaveIntervalType == AUTOSAVE_TIME_INTERVAL) && ((accumulated_image_area_flush_time > imagesAutoSaveIntervalSeconds) || accumulated_image_area_flush_time == 0.0)) { this->flush(numView, IF_ALL, output); reset_accumulated_image_area_flush_time(); @@ -896,7 +889,7 @@ void imageFilm_t::flush(int numView, int flags, colorOutput_t *out) if(pbar) pbar->setTag(oldTag); } - if(autoSave && (!session.isInteractive() || (session.isInteractive() && out2))) //only save film if the session is not interactive (i.e. yafaray-xml or render into file) or else if the session is interactive and we have secondary file output. We don't want to save the film in the material/lamp/world previews or if we don't have secondary file output (both cases interactive without out2) + if((filmFileSaveLoad == FILM_FILE_LOAD_SAVE || filmFileSaveLoad == FILM_FILE_SAVE) && (!session.isInteractive() || (session.isInteractive() && out2))) //only save film if the session is not interactive (i.e. yafaray-xml or render into file) or else if the session is interactive and we have secondary file output. We don't want to save the film in the material/lamp/world previews or if we don't have secondary file output (both cases interactive without out2) { std::stringstream passString; passString << "Saving internal ImageFilm file"; @@ -1313,21 +1306,6 @@ float imageFilm_t::dark_threshold_curve_interpolate(float pixel_brightness) else return 0.1000f; } -void imageFilm_t::setAutoSave(bool auto_save) -{ - autoSave = auto_save; -} - -void imageFilm_t::setAutoSaveBinary(bool auto_save_binary) -{ - autoSaveBinary = auto_save_binary; -} - -void imageFilm_t::setAutoLoad(bool auto_load) -{ - autoLoad = auto_load; -} - bool imageFilm_t::imageFilmLoad(const std::string &filename, bool debugXMLformat) { try @@ -1384,7 +1362,7 @@ bool imageFilm_t::imageFilmSave(const std::string &filename, bool debugXMLformat oa << BOOST_SERIALIZATION_NVP(*this); ofs.close(); } - else if(autoSaveBinary) + else if(filmFileSaveBinaryFormat) { Y_INFO << "imageFilm: Saving film to: \"" << filename << "\" in Binary (non portable) format" << yendl; boost::archive::binary_oarchive oa(ofs); From 25ece20dc0fbd9664ba0531561ba1b710672e06e Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sun, 19 Jun 2016 07:05:56 +0100 Subject: [PATCH 096/124] Film autosave pass interval segregated from images, pending time interval segregation --- include/core_api/imagefilm.h | 2 +- src/yafraycore/imagefilm.cc | 38 +++++++++++++++++++++++++++++++----- src/yafraycore/integrator.cc | 1 + 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/include/core_api/imagefilm.h b/include/core_api/imagefilm.h index eae988b1..5c5e0666 100755 --- a/include/core_api/imagefilm.h +++ b/include/core_api/imagefilm.h @@ -95,7 +95,7 @@ class YAFRAYCORE_EXPORT imageFilm_t /*! Prepare for next pass, i.e. reset area_cnt, check if pixels need resample... \param adaptive_AA if true, flag pixels to be resampled \param threshold color threshold for adaptive antialiasing */ - int nextPass(int numView, bool adaptive_AA, std::string integratorName); + int nextPass(int numView, bool adaptive_AA, std::string integratorName, bool skipNextPass = false); /*! Return the next area to be rendered CAUTION! This method MUST be threadsafe! \return false if no area is left to be handed out, true otherwise */ diff --git a/src/yafraycore/imagefilm.cc b/src/yafraycore/imagefilm.cc index ea35fc6a..53f4edad 100755 --- a/src/yafraycore/imagefilm.cc +++ b/src/yafraycore/imagefilm.cc @@ -354,18 +354,21 @@ void imageFilm_t::init(int numPasses) } } -int imageFilm_t::nextPass(int numView, bool adaptive_AA, std::string integratorName) +int imageFilm_t::nextPass(int numView, bool adaptive_AA, std::string integratorName, bool skipNextPass) { splitterMutex.lock(); next_area = 0; splitterMutex.unlock(); nPass++; - std::stringstream passString; + if(skipNextPass) return 0; + + std::stringstream passString; + + colorOutput_t *out2 = env->getOutput2(); + if(session.isInteractive()) { - colorOutput_t *out2 = env->getOutput2(); - if(out2 && (imagesAutoSaveIntervalType == AUTOSAVE_PASS_INTERVAL) && (nPass % imagesAutoSaveIntervalPasses == 0) && session.renderInProgress()) { this->flush(numView, IF_ALL, out2); @@ -379,6 +382,31 @@ int imageFilm_t::nextPass(int numView, bool adaptive_AA, std::string integratorN } } + if(session.renderInProgress() && !output->isPreview() && (filmFileSaveLoad == FILM_FILE_LOAD_SAVE || filmFileSaveLoad == FILM_FILE_SAVE) && (filmAutoSaveIntervalType == AUTOSAVE_PASS_INTERVAL) && (nPass % filmAutoSaveIntervalPasses == 0) && (!session.isInteractive() || (session.isInteractive() && out2))) //only save film here if the session is not interactive (i.e. yafaray-xml or render into file) or else if the session is interactive and we have secondary file output. We don't want to save the film in the material/lamp/world previews or if we don't have secondary file output (both cases interactive without out2) + { + std::stringstream passString; + passString << "AutoSaving internal ImageFilm file"; + + Y_INFO << passString.str() << yendl; + + std::string oldTag; + + if(pbar) + { + oldTag = pbar->getTag(); + pbar->setTag(passString.str().c_str()); + } + + std::string filmPath = session.getPathImageOutput(); + std::stringstream node; + node << std::setfill('0') << std::setw(4) << computerNode; + filmPath += " - node " + node.str(); + filmPath += ".film"; + this->imageFilmSave(filmPath, false); + + if(pbar) pbar->setTag(oldTag); + } + if(flags) flags->clear(); else flags = new tiledBitArray2D_t<3>(w, h, true); @@ -889,7 +917,7 @@ void imageFilm_t::flush(int numView, int flags, colorOutput_t *out) if(pbar) pbar->setTag(oldTag); } - if((filmFileSaveLoad == FILM_FILE_LOAD_SAVE || filmFileSaveLoad == FILM_FILE_SAVE) && (!session.isInteractive() || (session.isInteractive() && out2))) //only save film if the session is not interactive (i.e. yafaray-xml or render into file) or else if the session is interactive and we have secondary file output. We don't want to save the film in the material/lamp/world previews or if we don't have secondary file output (both cases interactive without out2) + if(session.renderFinished() && !output->isPreview() && (filmFileSaveLoad == FILM_FILE_LOAD_SAVE || filmFileSaveLoad == FILM_FILE_SAVE) && (!session.isInteractive() || (session.isInteractive() && out2))) //only save film here if the session is not interactive (i.e. yafaray-xml or render into file) or else if the session is interactive and we have secondary file output. We don't want to save the film in the material/lamp/world previews or if we don't have secondary file output (both cases interactive without out2) { std::stringstream passString; passString << "Saving internal ImageFilm file"; diff --git a/src/yafraycore/integrator.cc b/src/yafraycore/integrator.cc index 23ed9a1f..993ab766 100755 --- a/src/yafraycore/integrator.cc +++ b/src/yafraycore/integrator.cc @@ -214,6 +214,7 @@ bool tiledIntegrator_t::render(int numView, imageFilm_t *image) if(resampled_pixels <= 0.f && !AAthresholdChanged) { Y_INFO << integratorName << ": in previous pass there were 0 pixels to be resampled and the AA threshold did not change, so this pass resampling check and rendering will be skipped." << yendl; + imageFilm->nextPass(numView, true, integratorName, /*skipNextPass=*/true); } else { From 5fdf6f05cbcefe4494684e454f1348d11aa7b48a Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sun, 19 Jun 2016 08:01:43 +0100 Subject: [PATCH 097/124] Images/Film time interval autosave implemented with clearer code. Pending to improve the code encapsulation/readability in general --- include/core_api/imagefilm.h | 7 ++-- src/integrators/sppm.cc | 9 ++++- src/yafraycore/imagefilm.cc | 74 +++++++++++++++++++++++------------- src/yafraycore/integrator.cc | 9 ++++- 4 files changed, 66 insertions(+), 33 deletions(-) diff --git a/include/core_api/imagefilm.h b/include/core_api/imagefilm.h index 5c5e0666..3ee284ad 100755 --- a/include/core_api/imagefilm.h +++ b/include/core_api/imagefilm.h @@ -137,7 +137,6 @@ class YAFRAYCORE_EXPORT imageFilm_t void setAANoiseParams(bool detect_color_noise, int dark_detection_type, float dark_threshold_factor, int variance_edge_size, int variance_pixels, float clamp_samples); /*! Methods for rendering the parameters badge; Note that FreeType lib is needed to render text */ void drawRenderSettings(std::stringstream & ss); - void reset_accumulated_image_area_flush_time() { accumulated_image_area_flush_time = 0.0; } float dark_threshold_curve_interpolate(float pixel_brightness); int getWidth() const { return w; } int getHeight() const { return h; } @@ -156,12 +155,14 @@ class YAFRAYCORE_EXPORT imageFilm_t void setImagesAutoSaveIntervalType(int interval_type) { imagesAutoSaveIntervalType = interval_type; } void setImagesAutoSaveIntervalSeconds(double interval_seconds) { imagesAutoSaveIntervalSeconds = interval_seconds; } void setImagesAutoSaveIntervalPasses(int interval_passes) { imagesAutoSaveIntervalPasses = interval_passes; } + void resetImagesAutoSaveTimer() { imagesAutoSaveTimer = 0.0; } void setFilmFileSaveLoad(int film_file_save_load) { filmFileSaveLoad = film_file_save_load; } void setFilmFileSaveBinaryFormat(bool binary_format) { filmFileSaveBinaryFormat = binary_format; } void setFilmAutoSaveIntervalType(int interval_type) { filmAutoSaveIntervalType = interval_type; } void setFilmAutoSaveIntervalSeconds(double interval_seconds) { filmAutoSaveIntervalSeconds = interval_seconds; } void setFilmAutoSaveIntervalPasses(int interval_passes) { filmAutoSaveIntervalPasses = interval_passes; } + void resetFilmAutoSaveTimer() { filmAutoSaveTimer = 0.0; } #if HAVE_FREETYPE void drawFontBitmap( FT_Bitmap_* bitmap, int x, int y); @@ -210,18 +211,18 @@ class YAFRAYCORE_EXPORT imageFilm_t unsigned int samplingOffset = 0; //To ensure sampling after loading the image film continues and does not repeat already done samples unsigned int computerNode = 0; //Computer node in multi-computer render environments/render farms - double accumulated_image_area_flush_time = 0.0; //Internal accumulated time used for Image or Film Time-Interval AutoSave feature - //Options for AutoSaving output images int imagesAutoSaveIntervalType = AUTOSAVE_NONE; double imagesAutoSaveIntervalSeconds = 300.0; int imagesAutoSaveIntervalPasses = 1; + double imagesAutoSaveTimer = 0.0; //Internal timer for images AutoSave //Options for Saving/AutoSaving/Loading the internal imageFilm image buffers int filmFileSaveLoad = FILM_FILE_NONE; bool filmFileSaveBinaryFormat = true; int filmAutoSaveIntervalType = AUTOSAVE_NONE; double filmAutoSaveIntervalSeconds = 300.0; + double filmAutoSaveTimer = 0.0; //Internal timer for Film AutoSave int filmAutoSaveIntervalPasses = 1; struct filmload_check_t diff --git a/src/integrators/sppm.cc b/src/integrators/sppm.cc index a94a2b59..1e278162 100755 --- a/src/integrators/sppm.cc +++ b/src/integrators/sppm.cc @@ -86,8 +86,11 @@ bool SPPM::render(int numView, yafaray::imageFilm_t *image) gTimer.addEvent("rendert"); gTimer.start("rendert"); - imageFilm->reset_accumulated_image_area_flush_time(); - gTimer.addEvent("image_area_flush"); + imageFilm->resetImagesAutoSaveTimer(); + gTimer.addEvent("imagesAutoSaveTimer"); + + imageFilm->resetFilmAutoSaveTimer(); + gTimer.addEvent("filmAutoSaveTimer"); imageFilm->init(passNum); imageFilm->setAANoiseParams(AA_detect_color_noise, AA_dark_detection_type, AA_dark_threshold_factor, AA_variance_edge_size, AA_variance_pixels, AA_clamp_samples); @@ -139,6 +142,8 @@ bool SPPM::render(int numView, yafaray::imageFilm_t *image) } maxDepth = 0.f; gTimer.stop("rendert"); + gTimer.stop("imagesAutoSaveTimer"); + gTimer.stop("filmAutoSaveTimer"); session.setStatusRenderFinished(); Y_INFO << integratorName << ": Overall rendertime: "<< gTimer.getTime("rendert") << "s." << yendl; diff --git a/src/yafraycore/imagefilm.cc b/src/yafraycore/imagefilm.cc index 53f4edad..b6fdbaca 100755 --- a/src/yafraycore/imagefilm.cc +++ b/src/yafraycore/imagefilm.cc @@ -648,36 +648,58 @@ void imageFilm_t::finishArea(int numView, renderArea_t &a) } } - if(session.isInteractive()) + if(session.isInteractive()) output->flushArea(numView, a.X, a.Y, end_x+cx0, end_y+cy0, env->getRenderPasses()); + + if(session.renderInProgress() && !output->isPreview()) //avoid saving images/film if we are just rendering material/world/lights preview windows, etc { - output->flushArea(numView, a.X, a.Y, end_x+cx0, end_y+cy0, env->getRenderPasses()); - gTimer.stop("image_area_flush"); - accumulated_image_area_flush_time += gTimer.getTime("image_area_flush"); - if(accumulated_image_area_flush_time < 0.f) reset_accumulated_image_area_flush_time(); //to solve some strange very negative value when using yafaray-xml, race condition somewhere? - gTimer.start("image_area_flush"); + gTimer.stop("imagesAutoSaveTimer"); + imagesAutoSaveTimer += gTimer.getTime("imagesAutoSaveTimer"); + if(imagesAutoSaveTimer < 0.f) resetImagesAutoSaveTimer(); //to solve some strange very negative value when using yafaray-xml, race condition somewhere? + gTimer.start("imagesAutoSaveTimer"); + + gTimer.stop("filmAutoSaveTimer"); + filmAutoSaveTimer += gTimer.getTime("filmAutoSaveTimer"); + if(filmAutoSaveTimer < 0.f) resetFilmAutoSaveTimer(); //to solve some strange very negative value when using yafaray-xml, race condition somewhere? + gTimer.start("filmAutoSaveTimer"); colorOutput_t *out2 = env->getOutput2(); - - if(out2 && session.renderInProgress() && (imagesAutoSaveIntervalType == AUTOSAVE_TIME_INTERVAL) && ((accumulated_image_area_flush_time > imagesAutoSaveIntervalSeconds) || accumulated_image_area_flush_time == 0.0)) - { - this->flush(numView, IF_ALL, out2); - reset_accumulated_image_area_flush_time(); - } + + if((imagesAutoSaveIntervalType == AUTOSAVE_TIME_INTERVAL) && (imagesAutoSaveTimer > imagesAutoSaveIntervalSeconds)) + { + if(output && output->isImageOutput()) this->flush(numView, IF_ALL, output); + else if(out2 && out2->isImageOutput()) this->flush(numView, IF_ALL, out2); + resetImagesAutoSaveTimer(); + } + + if((filmFileSaveLoad == FILM_FILE_LOAD_SAVE || filmFileSaveLoad == FILM_FILE_SAVE) && (filmAutoSaveIntervalType == AUTOSAVE_TIME_INTERVAL) && (filmAutoSaveTimer > filmAutoSaveIntervalSeconds)) + { + if((output && output->isImageOutput()) || (out2 && out2->isImageOutput())) + { + std::stringstream passString; + passString << "AutoSaving internal ImageFilm file"; + + Y_INFO << passString.str() << yendl; + + std::string oldTag; + + if(pbar) + { + oldTag = pbar->getTag(); + pbar->setTag(passString.str().c_str()); + } + + std::string filmPath = session.getPathImageOutput(); + std::stringstream node; + node << std::setfill('0') << std::setw(4) << computerNode; + filmPath += " - node " + node.str(); + filmPath += ".film"; + this->imageFilmSave(filmPath, false); + + if(pbar) pbar->setTag(oldTag); + } + resetFilmAutoSaveTimer(); + } } - - else - { - gTimer.stop("image_area_flush"); - accumulated_image_area_flush_time += gTimer.getTime("image_area_flush"); - if(accumulated_image_area_flush_time < 0.f) reset_accumulated_image_area_flush_time(); //to solve some strange very negative value when using yafaray-xml, race condition somewhere? - gTimer.start("image_area_flush"); - - if(session.renderInProgress() && (imagesAutoSaveIntervalType == AUTOSAVE_TIME_INTERVAL) && ((accumulated_image_area_flush_time > imagesAutoSaveIntervalSeconds) || accumulated_image_area_flush_time == 0.0)) - { - this->flush(numView, IF_ALL, output); - reset_accumulated_image_area_flush_time(); - } - } if(pbar) { diff --git a/src/yafraycore/integrator.cc b/src/yafraycore/integrator.cc index 993ab766..e32f40a4 100755 --- a/src/yafraycore/integrator.cc +++ b/src/yafraycore/integrator.cc @@ -161,8 +161,11 @@ bool tiledIntegrator_t::render(int numView, imageFilm_t *image) gTimer.addEvent("rendert"); gTimer.start("rendert"); - imageFilm->reset_accumulated_image_area_flush_time(); - gTimer.addEvent("image_area_flush"); + imageFilm->resetImagesAutoSaveTimer(); + gTimer.addEvent("imagesAutoSaveTimer"); + + imageFilm->resetFilmAutoSaveTimer(); + gTimer.addEvent("filmAutoSaveTimer"); imageFilm->init(AA_passes); imageFilm->setAANoiseParams(AA_detect_color_noise, AA_dark_detection_type, AA_dark_threshold_factor, AA_variance_edge_size, AA_variance_pixels, AA_clamp_samples); @@ -243,6 +246,8 @@ bool tiledIntegrator_t::render(int numView, imageFilm_t *image) } maxDepth = 0.f; gTimer.stop("rendert"); + gTimer.stop("imagesAutoSaveTimer"); + gTimer.stop("filmAutoSaveTimer"); session.setStatusRenderFinished(); Y_INFO << integratorName << ": Overall rendertime: " << gTimer.getTime("rendert") << "s" << yendl; From d1c87d0e335ed1473166642510a03d92b201c3d5 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sun, 19 Jun 2016 09:33:09 +0100 Subject: [PATCH 098/124] Images/Film AutoSave - improved encapsulation and fixed autosave pass interval counting. Pending to make the code still more clear in general --- include/core_api/imagefilm.h | 6 +- src/yafraycore/imagefilm.cc | 127 ++++++++++++++--------------------- 2 files changed, 55 insertions(+), 78 deletions(-) diff --git a/include/core_api/imagefilm.h b/include/core_api/imagefilm.h index 3ee284ad..bb1bd73b 100755 --- a/include/core_api/imagefilm.h +++ b/include/core_api/imagefilm.h @@ -148,8 +148,8 @@ class YAFRAYCORE_EXPORT imageFilm_t void setComputerNode(unsigned int computer_node) { computerNode = computer_node; } void setBaseSamplingOffset(unsigned int offset) { baseSamplingOffset = offset; } void setSamplingOffset(unsigned int offset) { samplingOffset = offset; } - bool imageFilmLoad(const std::string &filename, bool debugXMLformat = false); - bool imageFilmSave(const std::string &filename, bool debugXMLformat = false); + bool imageFilmLoad(const std::string &filename); + bool imageFilmSave(const std::string tagText = ""); bool imageFilmLoadCheckOk() const; void setImagesAutoSaveIntervalType(int interval_type) { imagesAutoSaveIntervalType = interval_type; } @@ -216,6 +216,7 @@ class YAFRAYCORE_EXPORT imageFilm_t double imagesAutoSaveIntervalSeconds = 300.0; int imagesAutoSaveIntervalPasses = 1; double imagesAutoSaveTimer = 0.0; //Internal timer for images AutoSave + int imagesAutoSavePassCounter = 0; //Internal counter for images AutoSave //Options for Saving/AutoSaving/Loading the internal imageFilm image buffers int filmFileSaveLoad = FILM_FILE_NONE; @@ -223,6 +224,7 @@ class YAFRAYCORE_EXPORT imageFilm_t int filmAutoSaveIntervalType = AUTOSAVE_NONE; double filmAutoSaveIntervalSeconds = 300.0; double filmAutoSaveTimer = 0.0; //Internal timer for Film AutoSave + int filmAutoSavePassCounter = 0; //Internal counter for Film AutoSave int filmAutoSaveIntervalPasses = 1; struct filmload_check_t diff --git a/src/yafraycore/imagefilm.cc b/src/yafraycore/imagefilm.cc index b6fdbaca..ec2167b4 100755 --- a/src/yafraycore/imagefilm.cc +++ b/src/yafraycore/imagefilm.cc @@ -275,7 +275,7 @@ void imageFilm_t::init(int numPasses) for(auto filmFile: filmFilesList) { imageFilm_t *loadedFilm = new imageFilm_t(w, h, cx0, cy0, *output, 1.0, BOX, env); - loadedFilm->imageFilmLoad(filmFile, false); + loadedFilm->imageFilmLoad(filmFile); for(size_t idx=0; idxgetOutput2(); + Y_DEBUG << "nPass = " << nPass << yendl; + if(session.isInteractive()) { - if(out2 && (imagesAutoSaveIntervalType == AUTOSAVE_PASS_INTERVAL) && (nPass % imagesAutoSaveIntervalPasses == 0) && session.renderInProgress()) + if(out2 && (imagesAutoSaveIntervalType == AUTOSAVE_PASS_INTERVAL) && (imagesAutoSavePassCounter >= imagesAutoSaveIntervalPasses) && session.renderInProgress()) { this->flush(numView, IF_ALL, out2); + imagesAutoSavePassCounter = 0; } } else { - if(output && (imagesAutoSaveIntervalType == AUTOSAVE_PASS_INTERVAL) && (nPass % imagesAutoSaveIntervalPasses == 0) && session.renderInProgress()) + if(output && (imagesAutoSaveIntervalType == AUTOSAVE_PASS_INTERVAL) && (imagesAutoSavePassCounter >= imagesAutoSaveIntervalPasses) && session.renderInProgress()) { this->flush(numView, IF_ALL, output); + imagesAutoSavePassCounter = 0; } } - if(session.renderInProgress() && !output->isPreview() && (filmFileSaveLoad == FILM_FILE_LOAD_SAVE || filmFileSaveLoad == FILM_FILE_SAVE) && (filmAutoSaveIntervalType == AUTOSAVE_PASS_INTERVAL) && (nPass % filmAutoSaveIntervalPasses == 0) && (!session.isInteractive() || (session.isInteractive() && out2))) //only save film here if the session is not interactive (i.e. yafaray-xml or render into file) or else if the session is interactive and we have secondary file output. We don't want to save the film in the material/lamp/world previews or if we don't have secondary file output (both cases interactive without out2) + if(session.renderInProgress() && !output->isPreview() && (filmFileSaveLoad == FILM_FILE_LOAD_SAVE || filmFileSaveLoad == FILM_FILE_SAVE) && (filmAutoSaveIntervalType == AUTOSAVE_PASS_INTERVAL) && (filmAutoSavePassCounter >= filmAutoSaveIntervalPasses) && (!session.isInteractive() || (session.isInteractive() && out2))) //only save film here if the session is not interactive (i.e. yafaray-xml or render into file) or else if the session is interactive and we have secondary file output. We don't want to save the film in the material/lamp/world previews or if we don't have secondary file output (both cases interactive without out2) { - std::stringstream passString; - passString << "AutoSaving internal ImageFilm file"; - - Y_INFO << passString.str() << yendl; - - std::string oldTag; - - if(pbar) - { - oldTag = pbar->getTag(); - pbar->setTag(passString.str().c_str()); - } - - std::string filmPath = session.getPathImageOutput(); - std::stringstream node; - node << std::setfill('0') << std::setw(4) << computerNode; - filmPath += " - node " + node.str(); - filmPath += ".film"; - this->imageFilmSave(filmPath, false); - - if(pbar) pbar->setTag(oldTag); + imageFilmSave("AutoSaving internal ImageFilm file"); + filmAutoSavePassCounter = 0; } @@ -675,27 +662,7 @@ void imageFilm_t::finishArea(int numView, renderArea_t &a) { if((output && output->isImageOutput()) || (out2 && out2->isImageOutput())) { - std::stringstream passString; - passString << "AutoSaving internal ImageFilm file"; - - Y_INFO << passString.str() << yendl; - - std::string oldTag; - - if(pbar) - { - oldTag = pbar->getTag(); - pbar->setTag(passString.str().c_str()); - } - - std::string filmPath = session.getPathImageOutput(); - std::stringstream node; - node << std::setfill('0') << std::setw(4) << computerNode; - filmPath += " - node " + node.str(); - filmPath += ".film"; - this->imageFilmSave(filmPath, false); - - if(pbar) pbar->setTag(oldTag); + imageFilmSave("AutoSaving internal ImageFilm file"); } resetFilmAutoSaveTimer(); } @@ -941,27 +908,7 @@ void imageFilm_t::flush(int numView, int flags, colorOutput_t *out) if(session.renderFinished() && !output->isPreview() && (filmFileSaveLoad == FILM_FILE_LOAD_SAVE || filmFileSaveLoad == FILM_FILE_SAVE) && (!session.isInteractive() || (session.isInteractive() && out2))) //only save film here if the session is not interactive (i.e. yafaray-xml or render into file) or else if the session is interactive and we have secondary file output. We don't want to save the film in the material/lamp/world previews or if we don't have secondary file output (both cases interactive without out2) { - std::stringstream passString; - passString << "Saving internal ImageFilm file"; - - Y_INFO << passString.str() << yendl; - - std::string oldTag; - - if(pbar) - { - oldTag = pbar->getTag(); - pbar->setTag(passString.str().c_str()); - } - - std::string filmPath = session.getPathImageOutput(); - std::stringstream node; - node << std::setfill('0') << std::setw(4) << computerNode; - filmPath += " - node " + node.str(); - filmPath += ".film"; - this->imageFilmSave(filmPath, false); - - if(pbar) pbar->setTag(oldTag); + imageFilmSave(); } if(session.renderFinished()) @@ -1356,8 +1303,10 @@ float imageFilm_t::dark_threshold_curve_interpolate(float pixel_brightness) else return 0.1000f; } -bool imageFilm_t::imageFilmLoad(const std::string &filename, bool debugXMLformat) +bool imageFilm_t::imageFilmLoad(const std::string &filename) { + bool debugXMLformat = false; //Enable only for debugging purposes + try { std::ifstream ifs(filename, std::fstream::binary); @@ -1399,29 +1348,51 @@ bool imageFilm_t::imageFilmLoad(const std::string &filename, bool debugXMLformat } } -bool imageFilm_t::imageFilmSave(const std::string &filename, bool debugXMLformat) +bool imageFilm_t::imageFilmSave(const std::string tagText) { + bool debugXMLformat = false; //Enable only for debugging purposes + + std::stringstream passString; + if(tagText.empty()) passString << "Saving internal ImageFilm file"; + else passString << tagText; + + Y_INFO << passString.str() << yendl; + + std::string oldTag; + + if(pbar) + { + oldTag = pbar->getTag(); + pbar->setTag(passString.str().c_str()); + } + + std::string filmPath = session.getPathImageOutput(); + std::stringstream node; + node << std::setfill('0') << std::setw(4) << computerNode; + filmPath += " - node " + node.str(); + filmPath += ".film"; + try { - std::ofstream ofs(filename+".tmp", std::fstream::binary); + std::ofstream ofs(filmPath+".tmp", std::fstream::binary); if(debugXMLformat) { - Y_INFO << "imageFilm: Saving film to: \"" << filename << "\" in XML format" << yendl; + Y_INFO << "imageFilm: Saving film to: \"" << filmPath << "\" in XML format" << yendl; boost::archive::xml_oarchive oa(ofs); oa << BOOST_SERIALIZATION_NVP(*this); ofs.close(); } else if(filmFileSaveBinaryFormat) { - Y_INFO << "imageFilm: Saving film to: \"" << filename << "\" in Binary (non portable) format" << yendl; + Y_INFO << "imageFilm: Saving film to: \"" << filmPath << "\" in Binary (non portable) format" << yendl; boost::archive::binary_oarchive oa(ofs); oa << BOOST_SERIALIZATION_NVP(*this); ofs.close(); } else { - Y_INFO << "imageFilm: Saving film to: \"" << filename << "\" in Text format" << yendl; + Y_INFO << "imageFilm: Saving film to: \"" << filmPath << "\" in Text format" << yendl; boost::archive::text_oarchive oa(ofs); oa << BOOST_SERIALIZATION_NVP(*this); ofs.close(); @@ -1429,19 +1400,23 @@ bool imageFilm_t::imageFilmSave(const std::string &filename, bool debugXMLformat Y_VERBOSE << "imageFilm: Film saved to file." << yendl; } catch(std::exception& ex){ - Y_WARNING << "imageFilm: error '" << ex.what() << "' while saving ImageFilm file: '" << filename << "'" << yendl; + Y_WARNING << "imageFilm: error '" << ex.what() << "' while saving ImageFilm file: '" << filmPath << "'" << yendl; + if(pbar) pbar->setTag(oldTag); return false; } try { - boost::filesystem::copy_file(filename+".tmp", filename, boost::filesystem::copy_option::overwrite_if_exists); - boost::filesystem::remove(filename+".tmp"); + boost::filesystem::copy_file(filmPath+".tmp", filmPath, boost::filesystem::copy_option::overwrite_if_exists); + boost::filesystem::remove(filmPath+".tmp"); } catch(const boost::filesystem::filesystem_error& e) { Y_WARNING << "imageFilm: file operation error \"" << e.what() << yendl; } + + if(pbar) pbar->setTag(oldTag); + return true; } From a7319bb3131be3391958a1b3a3ef631f38b85f59 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sun, 19 Jun 2016 12:47:14 +0100 Subject: [PATCH 099/124] Images/Film Load/Save/Autosave: Final better encapsulated version and fixes for the time interval autosaving --- include/core_api/imagefilm.h | 7 +- src/yafraycore/imagefilm.cc | 319 +++++++++++++++++++---------------- src/yafraycore/integrator.cc | 8 - 3 files changed, 175 insertions(+), 159 deletions(-) diff --git a/include/core_api/imagefilm.h b/include/core_api/imagefilm.h index bb1bd73b..1eb4f690 100755 --- a/include/core_api/imagefilm.h +++ b/include/core_api/imagefilm.h @@ -148,8 +148,13 @@ class YAFRAYCORE_EXPORT imageFilm_t void setComputerNode(unsigned int computer_node) { computerNode = computer_node; } void setBaseSamplingOffset(unsigned int offset) { baseSamplingOffset = offset; } void setSamplingOffset(unsigned int offset) { samplingOffset = offset; } + + std::string getFilmPath() const; bool imageFilmLoad(const std::string &filename); - bool imageFilmSave(const std::string tagText = ""); + void imageFilmLoadAllInFolder(); + bool imageFilmSave(); + void imageFilmFileBackup() const; + void imageFilmUpdateCheckInfo(); bool imageFilmLoadCheckOk() const; void setImagesAutoSaveIntervalType(int interval_type) { imagesAutoSaveIntervalType = interval_type; } diff --git a/src/yafraycore/imagefilm.cc b/src/yafraycore/imagefilm.cc index ec2167b4..e72d1a51 100755 --- a/src/yafraycore/imagefilm.cc +++ b/src/yafraycore/imagefilm.cc @@ -230,127 +230,22 @@ void imageFilm_t::init(int numPasses) nPass = 1; nPasses = numPasses; + imagesAutoSavePassCounter = 0; + filmAutoSavePassCounter = 0; + resetImagesAutoSaveTimer(); + resetFilmAutoSaveTimer(); + gTimer.addEvent("imagesAutoSaveTimer"); + gTimer.addEvent("filmAutoSaveTimer"); + gTimer.start("imagesAutoSaveTimer"); + gTimer.start("filmAutoSaveTimer"); + if(!output->isPreview()) // Avoid doing the Film Load & Save operations and updating the film check values when we are just rendering a preview! { - if(filmFileSaveLoad == FILM_FILE_LOAD_SAVE) - { - std::stringstream passString; - passString << "Loading ImageFilm files"; - - Y_INFO << passString.str() << yendl; - - std::string oldTag; - - if(pbar) - { - oldTag = pbar->getTag(); - pbar->setTag(passString.str().c_str()); - } - - std::string filmPath = session.getPathImageOutput(); - std::stringstream node; - node << std::setfill('0') << std::setw(4) << computerNode; - filmPath += " - node " + node.str(); - filmPath += ".film"; - - std::string baseImageFileName = boost::filesystem::path(session.getPathImageOutput()).stem().string(); - - std::string parentPath = boost::filesystem::path(session.getPathImageOutput()).parent_path().string(); - if(parentPath.empty()) parentPath = "."; //If parent path is empty, set the path to the current folder - const std::string target_path( parentPath ); - const std::regex filmFilter(baseImageFileName + ".*\\.film$"); - std::vector filmFilesList; - - try - { - boost::filesystem::directory_iterator it_end; - for(boost::filesystem::directory_iterator it( target_path ); it != it_end; ++it) - { - if(!boost::filesystem::is_regular_file(it->status())) continue; - if(!std::regex_match(it->path().filename().string(), filmFilter)) continue; - filmFilesList.push_back(it->path().string()); - } - std::sort(filmFilesList.begin(), filmFilesList.end()); - - for(auto filmFile: filmFilesList) - { - imageFilm_t *loadedFilm = new imageFilm_t(w, h, cx0, cy0, *output, 1.0, BOX, env); - loadedFilm->imageFilmLoad(filmFile); - - for(size_t idx=0; idximagePasses[idx]; - (*imagePasses[idx])(i,j).col += (*loadedImageBuffer)(i,j).col; - (*imagePasses[idx])(i,j).weight += (*loadedImageBuffer)(i,j).weight; - } - } - } - - if(samplingOffset < loadedFilm->samplingOffset) samplingOffset = loadedFilm->samplingOffset; - if(baseSamplingOffset < loadedFilm->baseSamplingOffset) baseSamplingOffset = loadedFilm->baseSamplingOffset; - - delete loadedFilm; - } - } - catch(const boost::filesystem::filesystem_error& e) - { - Y_WARNING << "imageFilm: error during imageFilm loading process: \"" << e.what() << "\"" << yendl; - } - - if(pbar) pbar->setTag(oldTag); - } + if(filmFileSaveLoad == FILM_FILE_LOAD_SAVE) imageFilmLoadAllInFolder(); //Load all the existing Film in the images output folder, combining them together. It will load only the Film files with the same "base name" as the output image film (including file name, computer node name and frame) to allow adding samples to animations. - if(filmFileSaveLoad == FILM_FILE_LOAD_SAVE || filmFileSaveLoad == FILM_FILE_SAVE) //If the imageFilm is set to Save, at the start rename the previous film file as a "backup" just in case the user has made a mistake and wants to get the previous film back. - { - std::stringstream passString; - passString << "Creating backup of the previous ImageFilm file..."; - - Y_INFO << passString.str() << yendl; - - std::string oldTag; - - if(pbar) - { - oldTag = pbar->getTag(); - pbar->setTag(passString.str().c_str()); - } + if(filmFileSaveLoad == FILM_FILE_LOAD_SAVE || filmFileSaveLoad == FILM_FILE_SAVE) imageFilmFileBackup(); //If the imageFilm is set to Save, at the start rename the previous film file as a "backup" just in case the user has made a mistake and wants to get the previous film back. - std::string filmPath = session.getPathImageOutput(); - std::stringstream node; - node << std::setfill('0') << std::setw(4) << computerNode; - filmPath += " - node " + node.str(); - filmPath += ".film"; - std::string filmPathBackup = filmPath+"-previous.bak"; - - if(boost::filesystem::exists(filmPath)) - { - Y_VERBOSE << "imageFilm: Creating backup of previously saved film to: \"" << filmPathBackup << "\"" << yendl; - try - { - boost::filesystem::rename(filmPath, filmPathBackup); - } - catch(const boost::filesystem::filesystem_error& e) - { - Y_WARNING << "imageFilm: error during imageFilm file backup \"" << e.what() << "\"" << yendl; - } - } - - if(pbar) pbar->setTag(oldTag); - } - - //film load check data initialization - filmload_check.filmStructureVersion = FILM_STRUCTURE_VERSION; - filmload_check.w = w; - filmload_check.h = h; - filmload_check.cx0 = cx0; - filmload_check.cx1 = cx1; - filmload_check.cy0 = cy0; - filmload_check.cy1 = cy1; - filmload_check.numPasses = imagePasses.size(); + imageFilmUpdateCheckInfo(); //film load check data initialization. Make sure this is done after the Film Load operation (if any). } } @@ -367,34 +262,29 @@ int imageFilm_t::nextPass(int numView, bool adaptive_AA, std::string integratorN std::stringstream passString; - colorOutput_t *out2 = env->getOutput2(); + Y_DEBUG << "nPass=" << nPass << " imagesAutoSavePassCounter="<clear(); else flags = new tiledBitArray2D_t<3>(w, h, true); std::vector colExtPasses(imagePasses.size(), colorA_t(0.f)); @@ -653,6 +543,7 @@ void imageFilm_t::finishArea(int numView, renderArea_t &a) if((imagesAutoSaveIntervalType == AUTOSAVE_TIME_INTERVAL) && (imagesAutoSaveTimer > imagesAutoSaveIntervalSeconds)) { + Y_DEBUG << "imagesAutoSaveTimer="<isImageOutput()) this->flush(numView, IF_ALL, output); else if(out2 && out2->isImageOutput()) this->flush(numView, IF_ALL, out2); resetImagesAutoSaveTimer(); @@ -660,9 +551,10 @@ void imageFilm_t::finishArea(int numView, renderArea_t &a) if((filmFileSaveLoad == FILM_FILE_LOAD_SAVE || filmFileSaveLoad == FILM_FILE_SAVE) && (filmAutoSaveIntervalType == AUTOSAVE_TIME_INTERVAL) && (filmAutoSaveTimer > filmAutoSaveIntervalSeconds)) { + Y_DEBUG << "filmAutoSaveTimer="<isImageOutput()) || (out2 && out2->isImageOutput())) { - imageFilmSave("AutoSaving internal ImageFilm file"); + imageFilmSave(); } resetFilmAutoSaveTimer(); } @@ -688,6 +580,8 @@ void imageFilm_t::flush(int numView, int flags, colorOutput_t *out) colorOutput_t *out1 = out ? out : output; colorOutput_t *out2 = env->getOutput2(); + + if(out1->isPreview()) out2 = nullptr; //disable secondary file output when rendering a Preview (material preview, etc) if(out1 == out2) out1 = nullptr; //if we are already flushing the secondary output (out2) as main output (out1), then disable out1 to avoid duplicated work @@ -906,13 +800,19 @@ void imageFilm_t::flush(int numView, int flags, colorOutput_t *out) if(pbar) pbar->setTag(oldTag); } - if(session.renderFinished() && !output->isPreview() && (filmFileSaveLoad == FILM_FILE_LOAD_SAVE || filmFileSaveLoad == FILM_FILE_SAVE) && (!session.isInteractive() || (session.isInteractive() && out2))) //only save film here if the session is not interactive (i.e. yafaray-xml or render into file) or else if the session is interactive and we have secondary file output. We don't want to save the film in the material/lamp/world previews or if we don't have secondary file output (both cases interactive without out2) - { - imageFilmSave(); - } - if(session.renderFinished()) { + if(!output->isPreview() && (filmFileSaveLoad == FILM_FILE_LOAD_SAVE || filmFileSaveLoad == FILM_FILE_SAVE)) + { + if((output && output->isImageOutput()) || (out2 && out2->isImageOutput())) + { + imageFilmSave(); + } + } + + gTimer.stop("imagesAutoSaveTimer"); + gTimer.stop("filmAutoSaveTimer"); + yafLog.clearMemoryLog(); outMutex.unlock(); Y_VERBOSE << "imageFilm: Done." << yendl; @@ -1303,6 +1203,16 @@ float imageFilm_t::dark_threshold_curve_interpolate(float pixel_brightness) else return 0.1000f; } +std::string imageFilm_t::getFilmPath() const +{ + std::string filmPath = session.getPathImageOutput(); + std::stringstream node; + node << std::setfill('0') << std::setw(4) << computerNode; + filmPath += " - node " + node.str(); + filmPath += ".film"; + return filmPath; +} + bool imageFilm_t::imageFilmLoad(const std::string &filename) { bool debugXMLformat = false; //Enable only for debugging purposes @@ -1348,13 +1258,81 @@ bool imageFilm_t::imageFilmLoad(const std::string &filename) } } -bool imageFilm_t::imageFilmSave(const std::string tagText) +void imageFilm_t::imageFilmLoadAllInFolder() +{ + std::stringstream passString; + passString << "Loading ImageFilm files"; + + Y_INFO << passString.str() << yendl; + + std::string oldTag; + + if(pbar) + { + oldTag = pbar->getTag(); + pbar->setTag(passString.str().c_str()); + } + + std::string filmPath = getFilmPath(); + + std::string baseImageFileName = boost::filesystem::path(session.getPathImageOutput()).stem().string(); + + std::string parentPath = boost::filesystem::path(session.getPathImageOutput()).parent_path().string(); + if(parentPath.empty()) parentPath = "."; //If parent path is empty, set the path to the current folder + const std::string target_path( parentPath ); + const std::regex filmFilter(baseImageFileName + ".*\\.film$"); + std::vector filmFilesList; + + try + { + boost::filesystem::directory_iterator it_end; + for(boost::filesystem::directory_iterator it( target_path ); it != it_end; ++it) + { + if(!boost::filesystem::is_regular_file(it->status())) continue; + if(!std::regex_match(it->path().filename().string(), filmFilter)) continue; + filmFilesList.push_back(it->path().string()); + } + std::sort(filmFilesList.begin(), filmFilesList.end()); + + for(auto filmFile: filmFilesList) + { + imageFilm_t *loadedFilm = new imageFilm_t(w, h, cx0, cy0, *output, 1.0, BOX, env); + loadedFilm->imageFilmLoad(filmFile); + + for(size_t idx=0; idximagePasses[idx]; + (*imagePasses[idx])(i,j).col += (*loadedImageBuffer)(i,j).col; + (*imagePasses[idx])(i,j).weight += (*loadedImageBuffer)(i,j).weight; + } + } + } + + if(samplingOffset < loadedFilm->samplingOffset) samplingOffset = loadedFilm->samplingOffset; + if(baseSamplingOffset < loadedFilm->baseSamplingOffset) baseSamplingOffset = loadedFilm->baseSamplingOffset; + + delete loadedFilm; + } + } + catch(const boost::filesystem::filesystem_error& e) + { + Y_WARNING << "imageFilm: error during imageFilm loading process: \"" << e.what() << "\"" << yendl; + } + + if(pbar) pbar->setTag(oldTag); +} + + +bool imageFilm_t::imageFilmSave() { bool debugXMLformat = false; //Enable only for debugging purposes std::stringstream passString; - if(tagText.empty()) passString << "Saving internal ImageFilm file"; - else passString << tagText; + passString << "Saving internal ImageFilm file"; Y_INFO << passString.str() << yendl; @@ -1366,11 +1344,7 @@ bool imageFilm_t::imageFilmSave(const std::string tagText) pbar->setTag(passString.str().c_str()); } - std::string filmPath = session.getPathImageOutput(); - std::stringstream node; - node << std::setfill('0') << std::setw(4) << computerNode; - filmPath += " - node " + node.str(); - filmPath += ".film"; + std::string filmPath = getFilmPath(); try { @@ -1420,6 +1394,51 @@ bool imageFilm_t::imageFilmSave(const std::string tagText) return true; } +void imageFilm_t::imageFilmFileBackup() const +{ + std::stringstream passString; + passString << "Creating backup of the previous ImageFilm file..."; + + Y_INFO << passString.str() << yendl; + + std::string oldTag; + + if(pbar) + { + oldTag = pbar->getTag(); + pbar->setTag(passString.str().c_str()); + } + + std::string filmPath = getFilmPath(); + std::string filmPathBackup = filmPath+"-previous.bak"; + + if(boost::filesystem::exists(filmPath)) + { + Y_VERBOSE << "imageFilm: Creating backup of previously saved film to: \"" << filmPathBackup << "\"" << yendl; + try + { + boost::filesystem::rename(filmPath, filmPathBackup); + } + catch(const boost::filesystem::filesystem_error& e) + { + Y_WARNING << "imageFilm: error during imageFilm file backup \"" << e.what() << "\"" << yendl; + } + } + + if(pbar) pbar->setTag(oldTag); +} + +void imageFilm_t::imageFilmUpdateCheckInfo() +{ + filmload_check.filmStructureVersion = FILM_STRUCTURE_VERSION; + filmload_check.w = w; + filmload_check.h = h; + filmload_check.cx0 = cx0; + filmload_check.cx1 = cx1; + filmload_check.cy0 = cy0; + filmload_check.cy1 = cy1; + filmload_check.numPasses = imagePasses.size(); +} bool imageFilm_t::imageFilmLoadCheckOk() const { diff --git a/src/yafraycore/integrator.cc b/src/yafraycore/integrator.cc index e32f40a4..8163e710 100755 --- a/src/yafraycore/integrator.cc +++ b/src/yafraycore/integrator.cc @@ -161,12 +161,6 @@ bool tiledIntegrator_t::render(int numView, imageFilm_t *image) gTimer.addEvent("rendert"); gTimer.start("rendert"); - imageFilm->resetImagesAutoSaveTimer(); - gTimer.addEvent("imagesAutoSaveTimer"); - - imageFilm->resetFilmAutoSaveTimer(); - gTimer.addEvent("filmAutoSaveTimer"); - imageFilm->init(AA_passes); imageFilm->setAANoiseParams(AA_detect_color_noise, AA_dark_detection_type, AA_dark_threshold_factor, AA_variance_edge_size, AA_variance_pixels, AA_clamp_samples); @@ -246,8 +240,6 @@ bool tiledIntegrator_t::render(int numView, imageFilm_t *image) } maxDepth = 0.f; gTimer.stop("rendert"); - gTimer.stop("imagesAutoSaveTimer"); - gTimer.stop("filmAutoSaveTimer"); session.setStatusRenderFinished(); Y_INFO << integratorName << ": Overall rendertime: " << gTimer.getTime("rendert") << "s" << yendl; From 30f2c38e16e0c9fd96cba48424faae87a0c5c71c Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sun, 19 Jun 2016 13:26:47 +0100 Subject: [PATCH 100/124] OpenCV3: first tests --- CMakeLists.txt | 3 + CMakeModules/FindOpenCV.cmake | 287 ++++++++++++++++++++++++++++++ include/core_api/session.h | 3 + src/image_handlers/CMakeLists.txt | 12 +- src/image_handlers/jpgHandler.cc | 30 +++- 5 files changed, 326 insertions(+), 9 deletions(-) create mode 100644 CMakeModules/FindOpenCV.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c56b379..d3a34c28 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,6 +69,9 @@ endif(YAF_USER_EXTRA_LIBS) FIND_PACKAGE(Boost COMPONENTS system filesystem serialization locale REQUIRED) INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIR} ) +FIND_PACKAGE(OpenCV COMPONENTS core imgproc photo REQUIRED) +INCLUDE_DIRECTORIES( ${OpenCV_INCLUDE_DIR} ) + find_package(ZLIB REQUIRED) find_package(LibXml2 REQUIRED) diff --git a/CMakeModules/FindOpenCV.cmake b/CMakeModules/FindOpenCV.cmake new file mode 100644 index 00000000..27b383b8 --- /dev/null +++ b/CMakeModules/FindOpenCV.cmake @@ -0,0 +1,287 @@ +########################################################### +# Find OpenCV Library +# See http://sourceforge.net/projects/opencvlibrary/ +#---------------------------------------------------------- +# +## 1: Setup: +# The following variables are optionally searched for defaults +# OpenCV_DIR: Base directory of OpenCv tree to use. +# +## 2: Variable +# The following are set after configuration is done: +# +# OpenCV_FOUND +# OpenCV_LIBS +# OpenCV_INCLUDE_DIR +# OpenCV_VERSION (OpenCV_VERSION_MAJOR, OpenCV_VERSION_MINOR, OpenCV_VERSION_PATCH) +# +# +# Deprecated variable are used to maintain backward compatibility with +# the script of Jan Woetzel (2006/09): www.mip.informatik.uni-kiel.de/~jw +# OpenCV_INCLUDE_DIRS +# OpenCV_LIBRARIES +# OpenCV_LINK_DIRECTORIES +# +## 3: Version +# +# 2010/04/07 Benoit Rat, Correct a bug when OpenCVConfig.cmake is not found. +# 2010/03/24 Benoit Rat, Add compatibility for when OpenCVConfig.cmake is not found. +# 2010/03/22 Benoit Rat, Creation of the script. +# +# +# tested with: +# - OpenCV 2.1: MinGW, MSVC2008 +# - OpenCV 2.0: MinGW, MSVC2008, GCC4 +# +# +## 4: Licence: +# +# LGPL 2.1 : GNU Lesser General Public License Usage +# Alternatively, this file may be used under the terms of the GNU Lesser + +# General Public License version 2.1 as published by the Free Software +# Foundation and appearing in the file LICENSE.LGPL included in the +# packaging of this file. Please review the following information to +# ensure the GNU Lesser General Public License version 2.1 requirements +# will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +# +#---------------------------------------------------------- + + +find_path(OpenCV_DIR "OpenCVConfig.cmake" DOC "Root directory of OpenCV") + +set(OpenCV_configScript "${OpenCV_DIR}/OpenCVConfig.cmake") + +if(NOT EXISTS "${OpenCV_DIR}") + if(NOT WIN32) + include(FindPkgConfig) + if(PKG_CONFIG_FOUND) + pkg_check_modules(OPENCV_PKGCONF opencv) + set(OpenCV_DIR ${OPENCV_PKGCONF_PREFIX}) + if(EXISTS "${OpenCV_DIR}") + set(OpenCV_configScript_DIR "${OpenCV_DIR}/share/opencv") + if(EXISTS "${OpenCV_configScript_DIR}") + set(OpenCV_configScript "${OpenCV_configScript_DIR}/OpenCVConfig.cmake") + endif(EXISTS "${OpenCV_configScript_DIR}") + endif(EXISTS "${OpenCV_DIR}") + endif(PKG_CONFIG_FOUND) + endif(NOT WIN32) +endif(NOT EXISTS "${OpenCV_DIR}") + + +##==================================================== +## Find OpenCV libraries +##---------------------------------------------------- +if(EXISTS "${OpenCV_DIR}") + + #When its possible to use the Config script use it. + if(EXISTS "${OpenCV_configScript}") + + ## Include the standard CMake script + include("${OpenCV_configScript}") + + ## Search for a specific version + if(WIN32 OR NOT PKG_CONFIG_FOUND) + set(CVLIB_SUFFIX "${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}") + endif(WIN32 OR NOT PKG_CONFIG_FOUND) + + ##Boris:TODO: check for correct OpenCV version in pkg-config case !!! + + + #Otherwise it try to guess it. + else(EXISTS "${OpenCV_configScript}") + + + find_path(OpenCV_INCLUDE_DIR "cv.h" PATHS "${OpenCV_DIR}" PATH_SUFFIXES "include" "include/opencv" DOC "") + if(EXISTS ${OpenCV_INCLUDE_DIR}) + include_directories(${OpenCV_INCLUDE_DIR}) + endif(EXISTS ${OpenCV_INCLUDE_DIR}) + + if(NOT EXISTS ${VERSION_FILE_DIR}) #may alreay be in cache + + #Find OpenCV version by looking at cvver.h or core/version.hpp + find_path(VERSION_FILE_DIR "version.hpp" PATHS "${OpenCV_DIR}" PATH_SUFFIXES "include" "include/opencv" "include/opencv2" "include/opencv2/core" DOC "") + if(NOT EXISTS ${VERSION_FILE_DIR}) + find_path(VERSION_FILE_DIR "cvver.h" PATHS "${OpenCV_DIR}" PATH_SUFFIXES "include" "include/opencv" DOC "") + if(NOT EXISTS ${VERSION_FILE_DIR}) + message(FATAL_ERROR "OpenCV version file not found") + else(NOT EXISTS ${VERSION_FILE_DIR}) + set(VERSION_FILE ${VERSION_FILE_DIR}/cvver.h) + endif(NOT EXISTS ${VERSION_FILE_DIR}) + + else(NOT EXISTS ${VERSION_FILE_DIR}) + set(VERSION_FILE ${VERSION_FILE_DIR}/version.hpp) + + endif(NOT EXISTS ${VERSION_FILE_DIR}) + + #file(STRINGS ${OpenCV_INCLUDE_DIR}/cvver.h OpenCV_VERSIONS_TMP REGEX "^#define CV_[A-Z]+_VERSION[ \t]+[0-9]+$") + file(STRINGS ${VERSION_FILE} OpenCV_VERSIONS_TMP REGEX "^#define CV_[A-Z]+_VERSION[ \t]+[0-9]+$") + + string(REGEX REPLACE ".*#define CV_MAJOR_VERSION[ \t]+([0-9]+).*" "\\1" OpenCV_VERSION_MAJOR ${OpenCV_VERSIONS_TMP}) + string(REGEX REPLACE ".*#define CV_MINOR_VERSION[ \t]+([0-9]+).*" "\\1" OpenCV_VERSION_MINOR ${OpenCV_VERSIONS_TMP}) + string(REGEX REPLACE ".*#define CV_SUBMINOR_VERSION[ \t]+([0-9]+).*" "\\1" OpenCV_VERSION_PATCH ${OpenCV_VERSIONS_TMP}) + set(OpenCV_VERSION ${OpenCV_VERSION_MAJOR}.${OpenCV_VERSION_MINOR}.${OpenCV_VERSION_PATCH} CACHE STRING "" FORCE) + + if(WIN32 OR NOT PKG_CONFIG_FOUND) + set(CVLIB_SUFFIX "${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}") + endif(WIN32 OR NOT PKG_CONFIG_FOUND) + + ##Boris:TODO: check for correct OpenCV version in pklg-config case !!! + + + endif(NOT EXISTS ${VERSION_FILE_DIR}) + + if(${OpenCV_VERSION} VERSION_GREATER 2.1.0) + set(OPENCV_LIB_COMPONENTS calib3d contrib core features2d flann gpu highgui imgproc legacy ml objdetect video) + + #Add parent directory of ${OpenCV_INCLUDE_DIR} to ${OpenCV_INCLUDE_DIR} itself + #to be able to do both + #include and #include + get_filename_component(PARENT_DIR ${OpenCV_INCLUDE_DIR} PATH) + set(OpenCV_INCLUDE_DIR "${OpenCV_INCLUDE_DIR};${PARENT_DIR}") + + else(${OpenCV_VERSION} VERSION_GREATER 2.1.0) + set(OPENCV_LIB_COMPONENTS cxcore cv ml highgui cvaux) + endif(${OpenCV_VERSION} VERSION_GREATER 2.1.0) + + endif(EXISTS "${OpenCV_configScript}") + + + if(${OpenCV_VERSION} VERSION_GREATER 2.1.0) + + set(CVLIB_SUFFIX ".${OpenCV_VERSION}") + + ## Initiate the variable before the loop + set(OpenCV_LIBS "") + set(OpenCV_FOUND_TMP true) + + ## Loop over each components + foreach(__CVLIB ${OPENCV_LIB_COMPONENTS}) + + find_library(OpenCV_${__CVLIB}_LIBRARY_DEBUG NAMES "${__CVLIB}${CVLIB_SUFFIX}d" "lib${__CVLIB}${CVLIB_SUFFIX}d" PATHS "${OpenCV_DIR}/lib" NO_DEFAULT_PATH) + find_library(OpenCV_${__CVLIB}_LIBRARY_RELEASE NAMES "${__CVLIB}${CVLIB_SUFFIX}" "lib${__CVLIB}${CVLIB_SUFFIX}" "opencv_${__CVLIB}${CVLIB_SUFFIX}" "opencv_${__CVLIB}" "${__CVLIB}" PATHS "${OpenCV_DIR}/lib" NO_DEFAULT_PATH) + + #On MacOSX libraries are named: libopencv_${__CVLIB}${CVLIB_SUFFIX}.dylib + #On Linux libraries are named: libopencv_${__CVLIB}.so${CVLIB_SUFFIX} + # but with pkg-config ${OPENCV_LIB_COMPONENTS} are already prefixed with opencv_ ? + + #we add: "opencv_${__CVLIB}${CVLIB_SUFFIX}" for MacOSX + #we add: "${__CVLIB}" for linux (but version is not checked !) + + + #Remove the cache value + set(OpenCV_${__CVLIB}_LIBRARY "" CACHE STRING "" FORCE) + + #both debug/release + if(OpenCV_${__CVLIB}_LIBRARY_DEBUG AND OpenCV_${__CVLIB}_LIBRARY_RELEASE) + set(OpenCV_${__CVLIB}_LIBRARY debug ${OpenCV_${__CVLIB}_LIBRARY_DEBUG} optimized ${OpenCV_${__CVLIB}_LIBRARY_RELEASE} CACHE STRING "" FORCE) + + #only debug + elseif(OpenCV_${__CVLIB}_LIBRARY_DEBUG) + set(OpenCV_${__CVLIB}_LIBRARY ${OpenCV_${__CVLIB}_LIBRARY_DEBUG} CACHE STRING "" FORCE) + + #only release + elseif(OpenCV_${__CVLIB}_LIBRARY_RELEASE) + set(OpenCV_${__CVLIB}_LIBRARY ${OpenCV_${__CVLIB}_LIBRARY_RELEASE} CACHE STRING "" FORCE) + + #no library found + else() + set(OpenCV_FOUND_TMP false) + + endif() + + + #Add to the general list + if(OpenCV_${__CVLIB}_LIBRARY) + set(OpenCV_LIBS ${OpenCV_LIBS} ${OpenCV_${__CVLIB}_LIBRARY}) + endif(OpenCV_${__CVLIB}_LIBRARY) + + endforeach(__CVLIB) + + + set(OpenCV_FOUND ${OpenCV_FOUND_TMP} CACHE BOOL "" FORCE) + + + else(${OpenCV_VERSION} VERSION_GREATER 2.1.0) + + + ## Initiate the variable before the loop + set(OpenCV_LIBS "") + set(OpenCV_FOUND_TMP true) + + ## Loop over each components + foreach(__CVLIB ${OPENCV_LIB_COMPONENTS}) + + find_library(OpenCV_${__CVLIB}_LIBRARY_DEBUG NAMES "${__CVLIB}${CVLIB_SUFFIX}d" "lib${__CVLIB}${CVLIB_SUFFIX}d" PATHS "${OpenCV_DIR}/lib" NO_DEFAULT_PATH) + find_library(OpenCV_${__CVLIB}_LIBRARY_RELEASE NAMES "${__CVLIB}${CVLIB_SUFFIX}" "lib${__CVLIB}${CVLIB_SUFFIX}" PATHS "${OpenCV_DIR}/lib" NO_DEFAULT_PATH) + + + + #Remove the cache value + set(OpenCV_${__CVLIB}_LIBRARY "" CACHE STRING "" FORCE) + + #both debug/release + if(OpenCV_${__CVLIB}_LIBRARY_DEBUG AND OpenCV_${__CVLIB}_LIBRARY_RELEASE) + set(OpenCV_${__CVLIB}_LIBRARY debug ${OpenCV_${__CVLIB}_LIBRARY_DEBUG} optimized ${OpenCV_${__CVLIB}_LIBRARY_RELEASE} CACHE STRING "" FORCE) + + #only debug + elseif(OpenCV_${__CVLIB}_LIBRARY_DEBUG) + set(OpenCV_${__CVLIB}_LIBRARY ${OpenCV_${__CVLIB}_LIBRARY_DEBUG} CACHE STRING "" FORCE) + + #only release + elseif(OpenCV_${__CVLIB}_LIBRARY_RELEASE) + set(OpenCV_${__CVLIB}_LIBRARY ${OpenCV_${__CVLIB}_LIBRARY_RELEASE} CACHE STRING "" FORCE) + + #no library found + else() + set(OpenCV_FOUND_TMP false) + + endif() + + #Add to the general list + if(OpenCV_${__CVLIB}_LIBRARY) + set(OpenCV_LIBS ${OpenCV_LIBS} ${OpenCV_${__CVLIB}_LIBRARY}) + endif(OpenCV_${__CVLIB}_LIBRARY) + + + endforeach(__CVLIB) + + + set(OpenCV_FOUND ${OpenCV_FOUND_TMP} CACHE BOOL "" FORCE) + + endif(${OpenCV_VERSION} VERSION_GREATER 2.1.0) + + +else(EXISTS "${OpenCV_DIR}") + set(ERR_MSG "Please specify OpenCV directory using OpenCV_DIR env. variable") +endif(EXISTS "${OpenCV_DIR}") +##==================================================== + +##==================================================== +## Print message +##---------------------------------------------------- +if(NOT OpenCV_FOUND) + # make FIND_PACKAGE friendly + if(NOT OpenCV_FIND_QUIETLY) + if(OpenCV_FIND_REQUIRED) + message(FATAL_ERROR "OpenCV required but some headers or libs not found. ${ERR_MSG}") + else(OpenCV_FIND_REQUIRED) + message(STATUS "WARNING: OpenCV was not found. ${ERR_MSG}") + endif(OpenCV_FIND_REQUIRED) + endif(NOT OpenCV_FIND_QUIETLY) +endif(NOT OpenCV_FOUND) +##==================================================== + + +##==================================================== +## Backward compatibility +##---------------------------------------------------- +if(OpenCV_FOUND) + option(OpenCV_BACKWARD_COMPA "Add some variable to make this script compatible with the other version of FindOpenCV.cmake" false) + if(OpenCV_BACKWARD_COMPA) + find_path(OpenCV_INCLUDE_DIRS "cv.h" PATHS "${OpenCV_DIR}" PATH_SUFFIXES "include" "include/opencv" DOC "Include directory") + find_path(OpenCV_INCLUDE_DIR "cv.h" PATHS "${OpenCV_DIR}" PATH_SUFFIXES "include" "include/opencv" DOC "Include directory") + set(OpenCV_LIBRARIES "${OpenCV_LIBS}" CACHE STRING "" FORCE) + endif(OpenCV_BACKWARD_COMPA) +endif(OpenCV_FOUND) +##==================================================== diff --git a/include/core_api/session.h b/include/core_api/session.h index 5df9e192..a9647c94 100755 --- a/include/core_api/session.h +++ b/include/core_api/session.h @@ -27,6 +27,9 @@ #include #include #include + +#include + #include #include diff --git a/src/image_handlers/CMakeLists.txt b/src/image_handlers/CMakeLists.txt index 459128e0..8c5737b5 100755 --- a/src/image_handlers/CMakeLists.txt +++ b/src/image_handlers/CMakeLists.txt @@ -20,29 +20,29 @@ add_definitions(-DBUILDING_YAFRAYPLUGIN) if(WITH_OpenEXR) add_library(exrHandler SHARED exrHandler.cc) -target_link_libraries(exrHandler yafaray_v3_core ${OPENEXR_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(exrHandler yafaray_v3_core ${OPENEXR_LIBRARIES} ${Boost_LIBRARIES} ${OpenCV_LIBRARIES}) endif(WITH_OpenEXR) if(WITH_JPEG) add_library(jpgHandler SHARED jpgHandler.cc) -target_link_libraries(jpgHandler yafaray_v3_core ${JPEG_LIBRARY}) +target_link_libraries(jpgHandler yafaray_v3_core ${JPEG_LIBRARY} ${OpenCV_LIBRARIES}) endif(WITH_JPEG) if(WITH_PNG) add_library(pngHandler SHARED pngHandler.cc) -target_link_libraries(pngHandler yafaray_v3_core ${PNG_LIBRARIES}) +target_link_libraries(pngHandler yafaray_v3_core ${PNG_LIBRARIES} ${OpenCV_LIBRARIES}) endif(WITH_PNG) if(WITH_TIFF) add_library(tifHandler SHARED tifHandler.cc) -target_link_libraries(tifHandler yafaray_v3_core -Wl,-undefined -Wl,dynamic_lookup ${TIFF_LIBRARY}) +target_link_libraries(tifHandler yafaray_v3_core -Wl,-undefined -Wl,dynamic_lookup ${TIFF_LIBRARY} ${OpenCV_LIBRARIES}) endif(WITH_TIFF) add_library(tgaHandler SHARED tgaHandler.cc) -target_link_libraries(tgaHandler yafaray_v3_core) +target_link_libraries(tgaHandler yafaray_v3_core ${OpenCV_LIBRARIES}) add_library(hdrHandler SHARED hdrHandler.cc) -target_link_libraries(hdrHandler yafaray_v3_core) +target_link_libraries(hdrHandler yafaray_v3_core ${OpenCV_LIBRARIES}) if(WITH_OpenEXR) install (TARGETS exrHandler ${YAF_TARGET_TYPE} DESTINATION ${YAF_PLUGIN_DIR}) diff --git a/src/image_handlers/jpgHandler.cc b/src/image_handlers/jpgHandler.cc index 56e49dc2..df435163 100755 --- a/src/image_handlers/jpgHandler.cc +++ b/src/image_handlers/jpgHandler.cc @@ -177,6 +177,30 @@ bool jpgHandler_t::saveToFile(const std::string &name, int imagePassNumber) scanline = new yByte[ m_width * 3 ]; + cv::Mat A(m_height, m_width, CV_8UC3); + cv::Mat B(m_height, m_width, CV_8UC3); + cv::Mat_ _A = A; + cv::Mat_ _B = B; + + for(y = 0; y < m_height; y++) + { + for (x = 0; x < m_width; x++) + { + ix = x * 3; + colorA_t &col = (*imagePasses.at(imagePassNumber))(x, y); + col.clampRGBA01(); + _A(y, x)[2] = (col.getR() * 255); + _A(y, x)[0] = (col.getG() * 255); + _A(y, x)[1] = (col.getB() * 255); + } + } + + //cv::blur(A, B, cv::Size(10,10)); + //cv::imwrite("/home/ARCHIVOS/VirtualBox/compartir/opencv_render/opencv - 001blur.png", B); + + cv::fastNlMeansDenoisingColored(A, B, 3, 60); + //cv::imwrite("/home/ARCHIVOS/VirtualBox/compartir/opencv_render/opencv - 001denoise.png", B); + for(y = 0; y < m_height; y++) { for (x = 0; x < m_width; x++) @@ -184,9 +208,9 @@ bool jpgHandler_t::saveToFile(const std::string &name, int imagePassNumber) ix = x * 3; colorA_t &col = (*imagePasses.at(imagePassNumber))(x, y); col.clampRGBA01(); - scanline[ix] = (yByte)(col.getR() * 255); - scanline[ix+1] = (yByte)(col.getG() * 255); - scanline[ix+2] = (yByte)(col.getB() * 255); + scanline[ix] = (yByte) _B(y, x)[2]; + scanline[ix+1] = (yByte) _B(y, x)[0]; + scanline[ix+2] = (yByte) _B(y, x)[1]; } jpeg_write_scanlines(&info, &scanline, 1); From 1a8e73a0a2d067213b2c1039a1bb7a210ebd61ce Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sun, 19 Jun 2016 17:31:07 +0100 Subject: [PATCH 101/124] OpenCV: Denoise added for JPG and PNG images --- include/core_api/imagehandler.h | 8 ++- include/yafraycore/imageOutput.h | 2 + src/bindings/yafaray_v3_interface.i | 19 +++++- src/image_handlers/exrHandler.cc | 19 ++++-- src/image_handlers/hdrHandler.cc | 15 ++++- src/image_handlers/jpgHandler.cc | 89 ++++++++++++++++++----------- src/image_handlers/pngHandler.cc | 78 +++++++++++++++++++++---- src/image_handlers/tgaHandler.cc | 15 ++++- src/image_handlers/tifHandler.cc | 15 ++++- src/yafraycore/imageOutput.cc | 81 ++++++++++++-------------- 10 files changed, 231 insertions(+), 110 deletions(-) diff --git a/include/core_api/imagehandler.h b/include/core_api/imagehandler.h index 3070dc9e..d6ebb92f 100755 --- a/include/core_api/imagehandler.h +++ b/include/core_api/imagehandler.h @@ -48,7 +48,7 @@ class YAFRAYCORE_EXPORT imageHandler_t public: imageHandler_t():m_width(0), m_height(0), m_hasAlpha(false), m_textureOptimization(TEX_OPTIMIZATION_OPTIMIZED), rgbaOptimizedBuffer(nullptr), rgbaCompressedBuffer(nullptr), rgbOptimizedBuffer(nullptr), rgbCompressedBuffer(nullptr), m_MultiLayer(false) {}; - virtual void initForOutput(int width, int height, const renderPasses_t *renderPasses, bool withAlpha = false, bool multi_layer = false) = 0; + virtual void initForOutput(int width, int height, const renderPasses_t *renderPasses, bool denoiseEnabled, int denoiseHLum, int denoiseHCol, bool withAlpha = false, bool multi_layer = false) = 0; virtual ~imageHandler_t() {}; virtual bool loadFromFile(const std::string &name) = 0; virtual bool loadFromMemory(const yByte *data, size_t size) {return false; } @@ -62,6 +62,7 @@ class YAFRAYCORE_EXPORT imageHandler_t virtual bool isMultiLayer() { return m_MultiLayer; } int getTextureOptimization() { return m_textureOptimization; } void setTextureOptimization(int texture_optimization) { m_textureOptimization = texture_optimization; } + virtual bool denoiseEnabled() { return m_Denoise; } protected: std::string handlerName; @@ -74,7 +75,10 @@ class YAFRAYCORE_EXPORT imageHandler_t rgbaCompressedImage_nw_t *rgbaCompressedBuffer; //!< compressed RGBA (24bit/pixel) LOSSY! with alpha buffer rgbOptimizedImage_nw_t *rgbOptimizedBuffer; //!< optimized RGB (24bit/pixel) without alpha buffer rgbCompressedImage_nw_t *rgbCompressedBuffer; //!< compressed RGB (16bit/pixel) LOSSY! without alpha buffer - bool m_MultiLayer; + bool m_MultiLayer = false; + bool m_Denoise = false; + int m_DenoiseHLum = 3; + int m_DenoiseHCol = 3; }; diff --git a/include/yafraycore/imageOutput.h b/include/yafraycore/imageOutput.h index a5e574de..750fe259 100755 --- a/include/yafraycore/imageOutput.h +++ b/include/yafraycore/imageOutput.h @@ -40,6 +40,8 @@ class YAFRAYCORE_EXPORT imageOutput_t : public colorOutput_t virtual void flush(int numView, const renderPasses_t *renderPasses); virtual void flushArea(int numView, int x0, int y0, int x1, int y1, const renderPasses_t *renderPasses) {} // not used by images... yet virtual bool isImageOutput() { return true; } + void saveImageFile(std::string filename, int idx); + void saveImageFileMultiChannel(std::string filename, const renderPasses_t *renderPasses); private: imageHandler_t *image; diff --git a/src/bindings/yafaray_v3_interface.i b/src/bindings/yafaray_v3_interface.i index 8e2bb1df..4559f582 100755 --- a/src/bindings/yafaray_v3_interface.i +++ b/src/bindings/yafaray_v3_interface.i @@ -593,24 +593,39 @@ namespace yafaray class imageHandler_t { public: - virtual void initForOutput(int width, int height, const renderPasses_t *renderPasses, bool withAlpha = false, bool multi_layer = false) = 0; + imageHandler_t():m_width(0), m_height(0), m_hasAlpha(false), m_textureOptimization(TEX_OPTIMIZATION_OPTIMIZED), rgbaOptimizedBuffer(nullptr), rgbaCompressedBuffer(nullptr), rgbOptimizedBuffer(nullptr), rgbCompressedBuffer(nullptr), m_MultiLayer(false) {}; + + virtual void initForOutput(int width, int height, const renderPasses_t *renderPasses, bool denoiseEnabled, int denoiseHLum, int denoiseHCol, bool withAlpha = false, bool multi_layer = false) = 0; virtual ~imageHandler_t() {}; virtual bool loadFromFile(const std::string &name) = 0; virtual bool loadFromMemory(const yByte *data, size_t size) {return false; } virtual bool saveToFile(const std::string &name, int imagePassNumber = 0) = 0; + virtual bool saveToFileMultiChannel(const std::string &name, const renderPasses_t *renderPasses) { return false; }; virtual void putPixel(int x, int y, const colorA_t &rgba, int imagePassNumber = 0) = 0; virtual colorA_t getPixel(int x, int y, int imagePassNumber = 0) = 0; virtual int getWidth() { return m_width; } virtual int getHeight() { return m_height; } virtual bool isHDR() { return false; } + virtual bool isMultiLayer() { return m_MultiLayer; } + int getTextureOptimization() { return m_textureOptimization; } + void setTextureOptimization(int texture_optimization) { m_textureOptimization = texture_optimization; } + virtual bool denoiseEnabled() { return m_Denoise; } protected: std::string handlerName; int m_width; int m_height; bool m_hasAlpha; + int m_textureOptimization; std::vector imagePasses; //!< rgba color buffers for the additional render passes - rgba2DImage_nw_t *m_rgba; + rgbaOptimizedImage_nw_t *rgbaOptimizedBuffer; //!< optimized RGBA (32bit/pixel) with alpha buffer + rgbaCompressedImage_nw_t *rgbaCompressedBuffer; //!< compressed RGBA (24bit/pixel) LOSSY! with alpha buffer + rgbOptimizedImage_nw_t *rgbOptimizedBuffer; //!< optimized RGB (24bit/pixel) without alpha buffer + rgbCompressedImage_nw_t *rgbCompressedBuffer; //!< compressed RGB (16bit/pixel) LOSSY! without alpha buffer + bool m_MultiLayer = false; + bool m_Denoise = false; + int m_DenoiseHLum = 3; + int m_DenoiseHCol = 3; }; // Outputs diff --git a/src/image_handlers/exrHandler.cc b/src/image_handlers/exrHandler.cc index a5161bb8..561b3b11 100755 --- a/src/image_handlers/exrHandler.cc +++ b/src/image_handlers/exrHandler.cc @@ -45,12 +45,12 @@ class exrHandler_t: public imageHandler_t { public: exrHandler_t(); - void initForOutput(int width, int height, const renderPasses_t *renderPasses, bool withAlpha = false, bool multi_layer = false); + void initForOutput(int width, int height, const renderPasses_t *renderPasses, bool denoiseEnabled, int denoiseHLum, int denoiseHCol, bool withAlpha = false, bool multi_layer = false); void initForInput(); ~exrHandler_t(); bool loadFromFile(const std::string &name); bool saveToFile(const std::string &name, int imagePassNumber = 0); - bool saveToFileMultiChannel(const std::string &name, const renderPasses_t *renderPasses); + bool saveToFileMultiChannel(const std::string &name, bool denoise, const renderPasses_t *renderPasses); void putPixel(int x, int y, const colorA_t &rgba, int imagePassNumber = 0); colorA_t getPixel(int x, int y, int imagePassNumber = 0); static imageHandler_t *factory(paraMap_t ¶ms, renderEnvironment_t &render); @@ -65,12 +65,15 @@ exrHandler_t::exrHandler_t() handlerName = "EXRHandler"; } -void exrHandler_t::initForOutput(int width, int height, const renderPasses_t *renderPasses, bool withAlpha, bool multi_layer) +void exrHandler_t::initForOutput(int width, int height, const renderPasses_t *renderPasses, bool denoiseEnabled, int denoiseHLum, int denoiseHCol, bool withAlpha, bool multi_layer) { m_width = width; m_height = height; m_hasAlpha = withAlpha; m_MultiLayer = multi_layer; + m_Denoise = denoiseEnabled; + m_DenoiseHLum = denoiseHLum; + m_DenoiseHCol = denoiseHCol; m_halfrgba.resize(renderPasses->extPassesSize()); @@ -136,7 +139,7 @@ bool exrHandler_t::saveToFile(const std::string &name, int imagePassNumber) } } -bool exrHandler_t::saveToFileMultiChannel(const std::string &name, const renderPasses_t *renderPasses) +bool exrHandler_t::saveToFileMultiChannel(const std::string &name, bool denoise, const renderPasses_t *renderPasses) { std::string extPassName; @@ -309,6 +312,9 @@ imageHandler_t *exrHandler_t::factory(paraMap_t ¶ms,renderEnvironment_t &ren bool withAlpha = false; bool forOutput = true; bool multiLayer = false; + bool denoiseEnabled = false; + int denoiseHLum = 3; + int denoiseHCol = 3; params.getParam("pixel_type", pixtype); params.getParam("compression", compression); @@ -317,13 +323,16 @@ imageHandler_t *exrHandler_t::factory(paraMap_t ¶ms,renderEnvironment_t &ren params.getParam("alpha_channel", withAlpha); params.getParam("for_output", forOutput); params.getParam("img_multilayer", multiLayer); + params.getParam("denoiseEnabled", denoiseEnabled); + params.getParam("denoiseHLum", denoiseHLum); + params.getParam("denoiseHCol", denoiseHCol); imageHandler_t *ih = new exrHandler_t(); if(forOutput) { if(yafLog.getUseParamsBadge()) height += yafLog.getBadgeHeight(); - ih->initForOutput(width, height, render.getRenderPasses(), withAlpha, multiLayer); + ih->initForOutput(width, height, render.getRenderPasses(), denoiseEnabled, denoiseHLum, denoiseHCol, withAlpha, multiLayer); } return ih; diff --git a/src/image_handlers/hdrHandler.cc b/src/image_handlers/hdrHandler.cc index b66388b5..1c573470 100755 --- a/src/image_handlers/hdrHandler.cc +++ b/src/image_handlers/hdrHandler.cc @@ -42,7 +42,7 @@ class hdrHandler_t: public imageHandler_t public: hdrHandler_t(); ~hdrHandler_t(); - void initForOutput(int width, int height, const renderPasses_t *renderPasses, bool withAlpha = false, bool multi_layer = false); + void initForOutput(int width, int height, const renderPasses_t *renderPasses, bool denoiseEnabled, int denoiseHLum, int denoiseHCol, bool withAlpha = false, bool multi_layer = false); bool loadFromFile(const std::string &name); bool saveToFile(const std::string &name, int imagePassNumber = 0); void putPixel(int x, int y, const colorA_t &rgba, int imagePassNumber = 0); @@ -79,12 +79,15 @@ hdrHandler_t::~hdrHandler_t() } } -void hdrHandler_t::initForOutput(int width, int height, const renderPasses_t *renderPasses, bool withAlpha, bool multi_layer) +void hdrHandler_t::initForOutput(int width, int height, const renderPasses_t *renderPasses, bool denoiseEnabled, int denoiseHLum, int denoiseHCol, bool withAlpha, bool multi_layer) { m_width = width; m_height = height; m_hasAlpha = withAlpha; m_MultiLayer = multi_layer; + m_Denoise = denoiseEnabled; + m_DenoiseHLum = denoiseHLum; + m_DenoiseHCol = denoiseHCol; imagePasses.resize(renderPasses->extPassesSize()); @@ -589,18 +592,24 @@ imageHandler_t *hdrHandler_t::factory(paraMap_t ¶ms,renderEnvironment_t &ren int height = 0; bool withAlpha = false; bool forOutput = true; + bool denoiseEnabled = false; + int denoiseHLum = 3; + int denoiseHCol = 3; params.getParam("width", width); params.getParam("height", height); params.getParam("alpha_channel", withAlpha); params.getParam("for_output", forOutput); + params.getParam("denoiseEnabled", denoiseEnabled); + params.getParam("denoiseHLum", denoiseHLum); + params.getParam("denoiseHCol", denoiseHCol); imageHandler_t *ih = new hdrHandler_t(); if(forOutput) { if(yafLog.getUseParamsBadge()) height += yafLog.getBadgeHeight(); - ih->initForOutput(width, height, render.getRenderPasses(), withAlpha, false); + ih->initForOutput(width, height, render.getRenderPasses(), denoiseEnabled, denoiseHLum, denoiseHCol, withAlpha, false); } return ih; diff --git a/src/image_handlers/jpgHandler.cc b/src/image_handlers/jpgHandler.cc index df435163..b22bef81 100755 --- a/src/image_handlers/jpgHandler.cc +++ b/src/image_handlers/jpgHandler.cc @@ -69,7 +69,7 @@ class jpgHandler_t: public imageHandler_t public: jpgHandler_t(); ~jpgHandler_t(); - void initForOutput(int width, int height, const renderPasses_t *renderPasses, bool withAlpha = false, bool multi_layer = false); + void initForOutput(int width, int height, const renderPasses_t *renderPasses, bool denoiseEnabled, int denoiseHLum, int denoiseHCol, bool withAlpha = false, bool multi_layer = false); bool loadFromFile(const std::string &name); bool saveToFile(const std::string &name, int imagePassNumber = 0); void putPixel(int x, int y, const colorA_t &rgba, int imagePassNumber = 0); @@ -90,12 +90,15 @@ jpgHandler_t::jpgHandler_t() rgbCompressedBuffer = nullptr; } -void jpgHandler_t::initForOutput(int width, int height, const renderPasses_t *renderPasses, bool withAlpha, bool multi_layer) +void jpgHandler_t::initForOutput(int width, int height, const renderPasses_t *renderPasses, bool denoiseEnabled, int denoiseHLum, int denoiseHCol, bool withAlpha, bool multi_layer) { m_width = width; m_height = height; m_hasAlpha = withAlpha; m_MultiLayer = multi_layer; + m_Denoise = denoiseEnabled; + m_DenoiseHLum = denoiseHLum; + m_DenoiseHCol = denoiseHCol; imagePasses.resize(renderPasses->extPassesSize()); @@ -177,45 +180,57 @@ bool jpgHandler_t::saveToFile(const std::string &name, int imagePassNumber) scanline = new yByte[ m_width * 3 ]; - cv::Mat A(m_height, m_width, CV_8UC3); - cv::Mat B(m_height, m_width, CV_8UC3); - cv::Mat_ _A = A; - cv::Mat_ _B = B; - - for(y = 0; y < m_height; y++) + if(m_Denoise) { - for (x = 0; x < m_width; x++) + cv::Mat A(m_height, m_width, CV_8UC3); + cv::Mat B(m_height, m_width, CV_8UC3); + cv::Mat_ _A = A; + cv::Mat_ _B = B; + + for(y = 0; y < m_height; y++) { - ix = x * 3; - colorA_t &col = (*imagePasses.at(imagePassNumber))(x, y); - col.clampRGBA01(); - _A(y, x)[2] = (col.getR() * 255); - _A(y, x)[0] = (col.getG() * 255); - _A(y, x)[1] = (col.getB() * 255); + for (x = 0; x < m_width; x++) + { + colorA_t &col = (*imagePasses.at(imagePassNumber))(x, y); + col.clampRGBA01(); + _A(y, x)[0] = (col.getR() * 255); + _A(y, x)[1] = (col.getG() * 255); + _A(y, x)[2] = (col.getB() * 255); + } } - } - - //cv::blur(A, B, cv::Size(10,10)); - //cv::imwrite("/home/ARCHIVOS/VirtualBox/compartir/opencv_render/opencv - 001blur.png", B); - cv::fastNlMeansDenoisingColored(A, B, 3, 60); - //cv::imwrite("/home/ARCHIVOS/VirtualBox/compartir/opencv_render/opencv - 001denoise.png", B); - - for(y = 0; y < m_height; y++) - { - for (x = 0; x < m_width; x++) + cv::fastNlMeansDenoisingColored(A, B, m_DenoiseHLum, m_DenoiseHCol, 7, 21); + + for(y = 0; y < m_height; y++) { - ix = x * 3; - colorA_t &col = (*imagePasses.at(imagePassNumber))(x, y); - col.clampRGBA01(); - scanline[ix] = (yByte) _B(y, x)[2]; - scanline[ix+1] = (yByte) _B(y, x)[0]; - scanline[ix+2] = (yByte) _B(y, x)[1]; - } + for (x = 0; x < m_width; x++) + { + ix = x * 3; + scanline[ix] = (yByte) _B(y, x)[0]; + scanline[ix+1] = (yByte) _B(y, x)[1]; + scanline[ix+2] = (yByte) _B(y, x)[2]; + } - jpeg_write_scanlines(&info, &scanline, 1); + jpeg_write_scanlines(&info, &scanline, 1); + } } + else + { + for(y = 0; y < m_height; y++) + { + for (x = 0; x < m_width; x++) + { + ix = x * 3; + colorA_t &col = (*imagePasses.at(imagePassNumber))(x, y); + col.clampRGBA01(); + scanline[ix] = (yByte) (col.getR() * 255); + scanline[ix+1] = (yByte) (col.getG() * 255); + scanline[ix+2] = (yByte) (col.getB() * 255); + } + jpeg_write_scanlines(&info, &scanline, 1); + } + } delete [] scanline; jpeg_finish_compress(&info); @@ -424,18 +439,24 @@ imageHandler_t *jpgHandler_t::factory(paraMap_t ¶ms, renderEnvironment_t &re int height = 0; bool withAlpha = false; bool forOutput = true; + bool denoiseEnabled = false; + int denoiseHLum = 3; + int denoiseHCol = 3; params.getParam("width", width); params.getParam("height", height); params.getParam("alpha_channel", withAlpha); params.getParam("for_output", forOutput); + params.getParam("denoiseEnabled", denoiseEnabled); + params.getParam("denoiseHLum", denoiseHLum); + params.getParam("denoiseHCol", denoiseHCol); imageHandler_t *ih = new jpgHandler_t(); if(forOutput) { if(yafLog.getUseParamsBadge()) height += yafLog.getBadgeHeight(); - ih->initForOutput(width, height, render.getRenderPasses(), withAlpha, false); + ih->initForOutput(width, height, render.getRenderPasses(), denoiseEnabled, denoiseHLum, denoiseHCol, withAlpha, false); } return ih; diff --git a/src/image_handlers/pngHandler.cc b/src/image_handlers/pngHandler.cc index fb59a88f..a4667f91 100755 --- a/src/image_handlers/pngHandler.cc +++ b/src/image_handlers/pngHandler.cc @@ -45,7 +45,7 @@ class pngHandler_t: public imageHandler_t public: pngHandler_t(); ~pngHandler_t(); - void initForOutput(int width, int height, const renderPasses_t *renderPasses, bool withAlpha = false, bool multi_layer = false); + void initForOutput(int width, int height, const renderPasses_t *renderPasses, bool denoiseEnabled, int denoiseHLum, int denoiseHCol, bool withAlpha = false, bool multi_layer = false); bool loadFromFile(const std::string &name); bool loadFromMemory(const yByte *data, size_t size); bool saveToFile(const std::string &name, int imagePassNumber = 0); @@ -74,12 +74,15 @@ pngHandler_t::pngHandler_t() rgbaCompressedBuffer = nullptr; } -void pngHandler_t::initForOutput(int width, int height, const renderPasses_t *renderPasses, bool withAlpha, bool multi_layer) +void pngHandler_t::initForOutput(int width, int height, const renderPasses_t *renderPasses, bool denoiseEnabled, int denoiseHLum, int denoiseHCol, bool withAlpha, bool multi_layer) { m_width = width; m_height = height; m_hasAlpha = withAlpha; m_MultiLayer = multi_layer; + m_Denoise = denoiseEnabled; + m_DenoiseHLum = denoiseHLum; + m_DenoiseHCol = denoiseHCol; imagePasses.resize(renderPasses->extPassesSize()); @@ -162,23 +165,66 @@ bool pngHandler_t::saveToFile(const std::string &name, int imagePassNumber) { rowPointers[i] = new yByte[ m_width * channels ]; } + + Y_DEBUG << "m_Denoise="<initForOutput(width, height, render.getRenderPasses(), withAlpha, false); + ih->initForOutput(width, height, render.getRenderPasses(), denoiseEnabled, denoiseHLum, denoiseHCol, withAlpha, false); } return ih; diff --git a/src/image_handlers/tifHandler.cc b/src/image_handlers/tifHandler.cc index 0777c36a..277255ce 100755 --- a/src/image_handlers/tifHandler.cc +++ b/src/image_handlers/tifHandler.cc @@ -39,7 +39,7 @@ class tifHandler_t: public imageHandler_t public: tifHandler_t(); ~tifHandler_t(); - void initForOutput(int width, int height, const renderPasses_t *renderPasses, bool withAlpha = false, bool multi_layer = false); + void initForOutput(int width, int height, const renderPasses_t *renderPasses, bool denoiseEnabled, int denoiseHLum, int denoiseHCol, bool withAlpha = false, bool multi_layer = false); bool loadFromFile(const std::string &name); bool saveToFile(const std::string &name, int imagePassNumber = 0); void putPixel(int x, int y, const colorA_t &rgba, int imagePassNumber = 0); @@ -62,12 +62,15 @@ tifHandler_t::tifHandler_t() rgbaCompressedBuffer = nullptr; } -void tifHandler_t::initForOutput(int width, int height, const renderPasses_t *renderPasses, bool withAlpha, bool multi_layer) +void tifHandler_t::initForOutput(int width, int height, const renderPasses_t *renderPasses, bool denoiseEnabled, int denoiseHLum, int denoiseHCol, bool withAlpha, bool multi_layer) { m_width = width; m_height = height; m_hasAlpha = withAlpha; m_MultiLayer = multi_layer; + m_Denoise = denoiseEnabled; + m_DenoiseHLum = denoiseHLum; + m_DenoiseHCol = denoiseHCol; imagePasses.resize(renderPasses->extPassesSize()); @@ -257,18 +260,24 @@ imageHandler_t *tifHandler_t::factory(paraMap_t ¶ms, renderEnvironment_t &re int height = 0; bool withAlpha = false; bool forOutput = true; + bool denoiseEnabled = false; + int denoiseHLum = 3; + int denoiseHCol = 3; params.getParam("width", width); params.getParam("height", height); params.getParam("alpha_channel", withAlpha); params.getParam("for_output", forOutput); + params.getParam("denoiseEnabled", denoiseEnabled); + params.getParam("denoiseHLum", denoiseHLum); + params.getParam("denoiseHCol", denoiseHCol); imageHandler_t *ih = new tifHandler_t(); if(forOutput) { if(yafLog.getUseParamsBadge()) height += yafLog.getBadgeHeight(); - ih->initForOutput(width, height, render.getRenderPasses(), withAlpha, false); + ih->initForOutput(width, height, render.getRenderPasses(), denoiseEnabled, denoiseHLum, denoiseHCol, withAlpha, false); } return ih; diff --git a/src/yafraycore/imageOutput.cc b/src/yafraycore/imageOutput.cc index 6d29cffb..dac19b31 100755 --- a/src/yafraycore/imageOutput.cc +++ b/src/yafraycore/imageOutput.cc @@ -92,32 +92,13 @@ void imageOutput_t::flush(int numView, const renderPasses_t *renderPasses) { if(numView == 0) { - image->saveToFile(fname+".tmp", 0); //This should not be necessary but Blender API seems to be limited and the API "load_from_file" function does not work (yet) with multilayer EXR, so I have to generate this extra combined pass file so it's displayed in the Blender window. - try - { - boost::filesystem::copy_file(fname+".tmp", fname, boost::filesystem::copy_option::overwrite_if_exists); - boost::filesystem::remove(fname+".tmp"); - } - catch(const boost::filesystem::filesystem_error& e) - { - Y_WARNING << "Output: file operation error \"" << e.what() << yendl; - } + saveImageFile(fname, 0); //This should not be necessary but Blender API seems to be limited and the API "load_from_file" function does not work (yet) with multilayer EXR, so I have to generate this extra combined pass file so it's displayed in the Blender window. } fnamePass = path + base_name + " [" + "multilayer" + "]"+ ext; - - image->saveToFileMultiChannel(fnamePass+".tmp", renderPasses); - try - { - boost::filesystem::copy_file(fnamePass+".tmp", fnamePass, boost::filesystem::copy_option::overwrite_if_exists); - boost::filesystem::remove(fnamePass+".tmp"); - } - catch(const boost::filesystem::filesystem_error& e) - { - Y_WARNING << "Output: file operation error \"" << e.what() << yendl; - } + saveImageFileMultiChannel(fnamePass, renderPasses); - yafLog.setImagePath(fnamePass); //to show the image in the HTML log output + yafLog.setImagePath(fnamePass); //to show the image in the HTML log output } else { @@ -127,35 +108,15 @@ void imageOutput_t::flush(int numView, const renderPasses_t *renderPasses) if(numView == 0 && idx == 0) { - image->saveToFile(fname+".tmp", idx); //default image filename, when not using views nor passes and for reloading into Blender - try - { - boost::filesystem::copy_file(fname+".tmp", fname, boost::filesystem::copy_option::overwrite_if_exists); - boost::filesystem::remove(fname+".tmp"); - } - catch(const boost::filesystem::filesystem_error& e) - { - Y_WARNING << "Output: file operation error \"" << e.what() << yendl; - } - - yafLog.setImagePath(fname); //to show the image in the HTML log output + saveImageFile(fname, idx); //default image filename, when not using views nor passes and for reloading into Blender } if(passName != "not found" && (renderPasses->extPassesSize()>=2 || renderPasses->view_names.size() >= 2)) { fnamePass = path + base_name + " [pass " + passName + "]"+ ext; - image->saveToFile(fnamePass+".tmp", idx); - try - { - boost::filesystem::copy_file(fnamePass+".tmp", fnamePass, boost::filesystem::copy_option::overwrite_if_exists); - boost::filesystem::remove(fnamePass+".tmp"); - } - catch(const boost::filesystem::filesystem_error& e) - { - Y_WARNING << "Output: file operation error \"" << e.what() << yendl; - } - - if(idx == 0) yafLog.setImagePath(fnamePass); //to show the image in the HTML log output + saveImageFile(fnamePass, idx); + + if(idx == 0) yafLog.setImagePath(fnamePass); //to show the image in the HTML log output } } } @@ -192,5 +153,33 @@ void imageOutput_t::flush(int numView, const renderPasses_t *renderPasses) } } + +void imageOutput_t::saveImageFile(std::string filename, int idx) +{ + image->saveToFile(filename+".tmp", idx); + try + { + boost::filesystem::copy_file(filename+".tmp", filename, boost::filesystem::copy_option::overwrite_if_exists); + boost::filesystem::remove(filename+".tmp"); + } + catch(const boost::filesystem::filesystem_error& e) + { + Y_WARNING << "Output: file operation error \"" << e.what() << yendl; + } +} + +void imageOutput_t::saveImageFileMultiChannel(std::string filename, const renderPasses_t *renderPasses) +{ + image->saveToFileMultiChannel(filename+".tmp", renderPasses); + try + { + boost::filesystem::copy_file(filename+".tmp", filename, boost::filesystem::copy_option::overwrite_if_exists); + boost::filesystem::remove(filename+".tmp"); + } + catch(const boost::filesystem::filesystem_error& e) + { + Y_WARNING << "Output: file operation error \"" << e.what() << yendl; + } +} __END_YAFRAY From c8974fc7970886d13288c39389df2d900df964ba Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sun, 19 Jun 2016 19:45:53 +0100 Subject: [PATCH 102/124] OpenCV Denoise: added TGA and TIFF formats --- src/image_handlers/exrHandler.cc | 9 ++-- src/image_handlers/hdrHandler.cc | 9 ++-- src/image_handlers/tgaHandler.cc | 74 ++++++++++++++++++++++----- src/image_handlers/tifHandler.cc | 85 +++++++++++++++++++++++++------- 4 files changed, 137 insertions(+), 40 deletions(-) diff --git a/src/image_handlers/exrHandler.cc b/src/image_handlers/exrHandler.cc index 561b3b11..f3cc2ed5 100755 --- a/src/image_handlers/exrHandler.cc +++ b/src/image_handlers/exrHandler.cc @@ -323,10 +323,11 @@ imageHandler_t *exrHandler_t::factory(paraMap_t ¶ms,renderEnvironment_t &ren params.getParam("alpha_channel", withAlpha); params.getParam("for_output", forOutput); params.getParam("img_multilayer", multiLayer); - params.getParam("denoiseEnabled", denoiseEnabled); - params.getParam("denoiseHLum", denoiseHLum); - params.getParam("denoiseHCol", denoiseHCol); - +/* //Denoise is not available for HDR/EXR images + * params.getParam("denoiseEnabled", denoiseEnabled); + * params.getParam("denoiseHLum", denoiseHLum); + * params.getParam("denoiseHCol", denoiseHCol); + */ imageHandler_t *ih = new exrHandler_t(); if(forOutput) diff --git a/src/image_handlers/hdrHandler.cc b/src/image_handlers/hdrHandler.cc index 1c573470..75127e13 100755 --- a/src/image_handlers/hdrHandler.cc +++ b/src/image_handlers/hdrHandler.cc @@ -600,10 +600,11 @@ imageHandler_t *hdrHandler_t::factory(paraMap_t ¶ms,renderEnvironment_t &ren params.getParam("height", height); params.getParam("alpha_channel", withAlpha); params.getParam("for_output", forOutput); - params.getParam("denoiseEnabled", denoiseEnabled); - params.getParam("denoiseHLum", denoiseHLum); - params.getParam("denoiseHCol", denoiseHCol); - +/* //Denoise is not available for HDR/EXR images + * params.getParam("denoiseEnabled", denoiseEnabled); + * params.getParam("denoiseHLum", denoiseHLum); + * params.getParam("denoiseHCol", denoiseHCol); + */ imageHandler_t *ih = new hdrHandler_t(); if(forOutput) diff --git a/src/image_handlers/tgaHandler.cc b/src/image_handlers/tgaHandler.cc index 17bfee64..db8c996e 100755 --- a/src/image_handlers/tgaHandler.cc +++ b/src/image_handlers/tgaHandler.cc @@ -154,27 +154,75 @@ bool tgaHandler_t::saveToFile(const std::string &name, int imagePassNumber) { fwrite(&header, sizeof(tgaHeader_t), 1, fp); fwrite(imageId.c_str(), (size_t)header.idLength, 1, fp); - - for (int y = 0; y < m_height; y++) + + if(m_Denoise) { - for (int x = 0; x < m_width; x++) + cv::Mat A(m_height, m_width, CV_8UC3); + cv::Mat B(m_height, m_width, CV_8UC3); + cv::Mat_ _A = A; + cv::Mat_ _B = B; + + for (int y = 0; y < m_height; y++) + { + for (int x = 0; x < m_width; x++) + { + colorA_t &col = (*imagePasses.at(imagePassNumber))(x, y); + col.clampRGBA01(); + _A(y, x)[0] = (col.getR() * 255); + _A(y, x)[1] = (col.getG() * 255); + _A(y, x)[2] = (col.getB() * 255); + } + } + + cv::fastNlMeansDenoisingColored(A, B, m_DenoiseHLum, m_DenoiseHCol, 7, 21); + + for (int y = 0; y < m_height; y++) { - (*imagePasses.at(imagePassNumber))(x, y).clampRGBA01(); - if(!m_hasAlpha) + for (int x = 0; x < m_width; x++) { - tgaPixelRGB_t rgb; - rgb = (color_t)(*imagePasses.at(imagePassNumber))(x, y); - fwrite(&rgb, sizeof(tgaPixelRGB_t), 1, fp); + if(!m_hasAlpha) + { + tgaPixelRGB_t rgb; + rgb.R = (yByte) _B(y, x)[0]; + rgb.G = (yByte) _B(y, x)[1]; + rgb.B = (yByte) _B(y, x)[2]; + fwrite(&rgb, sizeof(tgaPixelRGB_t), 1, fp); + } + else + { + colorA_t &col = (*imagePasses.at(imagePassNumber))(x, y); + tgaPixelRGBA_t rgba; + rgba.R = (yByte) _B(y, x)[0]; + rgba.G = (yByte) _B(y, x)[1]; + rgba.B = (yByte) _B(y, x)[2]; + rgba.A = (*imagePasses.at(imagePassNumber))(x, y).A; + fwrite(&rgba, sizeof(tgaPixelRGBA_t), 1, fp); + } } - else + } + } + else + { + for (int y = 0; y < m_height; y++) + { + for (int x = 0; x < m_width; x++) { - tgaPixelRGBA_t rgba; - rgba = (*imagePasses.at(imagePassNumber))(x, y); - fwrite(&rgba, sizeof(tgaPixelRGBA_t), 1, fp); + (*imagePasses.at(imagePassNumber))(x, y).clampRGBA01(); + if(!m_hasAlpha) + { + tgaPixelRGB_t rgb; + rgb = (color_t)(*imagePasses.at(imagePassNumber))(x, y); + fwrite(&rgb, sizeof(tgaPixelRGB_t), 1, fp); + } + else + { + tgaPixelRGBA_t rgba; + rgba = (*imagePasses.at(imagePassNumber))(x, y); + fwrite(&rgba, sizeof(tgaPixelRGBA_t), 1, fp); + } } } } - fwrite(&footer, sizeof(tgaFooter_t), 1, fp); fileUnicodeClose(fp); } diff --git a/src/image_handlers/tifHandler.cc b/src/image_handlers/tifHandler.cc index 277255ce..327fca5e 100755 --- a/src/image_handlers/tifHandler.cc +++ b/src/image_handlers/tifHandler.cc @@ -151,28 +151,75 @@ bool tifHandler_t::saveToFile(const std::string &name, int imagePassNumber) TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(out, bytesPerScanline)); - for (int y = 0; y < m_height; y++) - { - for(int x = 0; x < m_width; x++) - { - int ix = x * channels; - colorA_t &col = (*imagePasses.at(imagePassNumber))(x, y); - col.clampRGBA01(); - scanline[ix] = (yByte)(col.getR() * 255.f); - scanline[ix+1] = (yByte)(col.getG() * 255.f); - scanline[ix+2] = (yByte)(col.getB() * 255.f); - if(m_hasAlpha) scanline[ix+3] = (yByte)(col.getA() * 255.f); - } - - if(TIFFWriteScanline(out, scanline, y, 0) < 0) + if(m_Denoise) + { + cv::Mat A(m_height, m_width, CV_8UC3); + cv::Mat B(m_height, m_width, CV_8UC3); + cv::Mat_ _A = A; + cv::Mat_ _B = B; + + for (int y = 0; y < m_height; y++) { - Y_ERROR << handlerName << ": An error occurred while writing TIFF file" << yendl; - TIFFClose(out); - _TIFFfree(scanline); + for(int x = 0; x < m_width; x++) + { + colorA_t &col = (*imagePasses.at(imagePassNumber))(x, y); + col.clampRGBA01(); + _A(y, x)[0] = (col.getR() * 255); + _A(y, x)[1] = (col.getG() * 255); + _A(y, x)[2] = (col.getB() * 255); + } + } - return false; + cv::fastNlMeansDenoisingColored(A, B, m_DenoiseHLum, m_DenoiseHCol, 7, 21); + + for (int y = 0; y < m_height; y++) + { + for(int x = 0; x < m_width; x++) + { + int ix = x * channels; + colorA_t &col = (*imagePasses.at(imagePassNumber))(x, y); + col.clampRGBA01(); + scanline[ix] = (yByte) _B(y, x)[0]; + scanline[ix+1] = (yByte) _B(y, x)[1]; + scanline[ix+2] = (yByte) _B(y, x)[2]; + if(m_hasAlpha) scanline[ix+3] = (yByte)(col.getA() * 255.f); + } + + if(TIFFWriteScanline(out, scanline, y, 0) < 0) + { + Y_ERROR << handlerName << ": An error occurred while writing TIFF file" << yendl; + TIFFClose(out); + _TIFFfree(scanline); + + return false; + } } - } + } + else + { + for (int y = 0; y < m_height; y++) + { + for(int x = 0; x < m_width; x++) + { + int ix = x * channels; + colorA_t &col = (*imagePasses.at(imagePassNumber))(x, y); + col.clampRGBA01(); + scanline[ix] = (yByte)(col.getR() * 255.f); + scanline[ix+1] = (yByte)(col.getG() * 255.f); + scanline[ix+2] = (yByte)(col.getB() * 255.f); + if(m_hasAlpha) scanline[ix+3] = (yByte)(col.getA() * 255.f); + } + + if(TIFFWriteScanline(out, scanline, y, 0) < 0) + { + Y_ERROR << handlerName << ": An error occurred while writing TIFF file" << yendl; + TIFFClose(out); + _TIFFfree(scanline); + + return false; + } + } + } TIFFClose(out); _TIFFfree(scanline); From 30250ce1ee6135cc910bcbe5b1ca1672fb159dc8 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sun, 19 Jun 2016 20:21:48 +0100 Subject: [PATCH 103/124] Denoise: improved logging and badge. Also added back the AA threshold that was missing --- include/core_api/imagehandler.h | 7 +++++++ include/core_api/output.h | 1 + include/yafraycore/imageOutput.h | 7 ++++++- src/image_handlers/exrHandler.cc | 8 ++++---- src/image_handlers/hdrHandler.cc | 4 ++-- src/image_handlers/jpgHandler.cc | 8 ++++---- src/image_handlers/pngHandler.cc | 4 ++-- src/image_handlers/tgaHandler.cc | 4 ++-- src/image_handlers/tifHandler.cc | 4 ++-- src/yafraycore/imagefilm.cc | 4 ++++ src/yafraycore/integrator.cc | 12 ++++++++---- 11 files changed, 42 insertions(+), 21 deletions(-) diff --git a/include/core_api/imagehandler.h b/include/core_api/imagehandler.h index d6ebb92f..46ac2b3c 100755 --- a/include/core_api/imagehandler.h +++ b/include/core_api/imagehandler.h @@ -63,6 +63,13 @@ class YAFRAYCORE_EXPORT imageHandler_t int getTextureOptimization() { return m_textureOptimization; } void setTextureOptimization(int texture_optimization) { m_textureOptimization = texture_optimization; } virtual bool denoiseEnabled() { return m_Denoise; } + std::string getDenoiseParams() const + { + if(!m_Denoise) return ""; + std::stringstream paramString; + paramString << "| Image file denoise=on (hLuminance=" << m_DenoiseHLum << ", hCrominance=" << m_DenoiseHCol << ")" << yendl; + return paramString.str(); + } protected: std::string handlerName; diff --git a/include/core_api/output.h b/include/core_api/output.h index 5e0cd464..214f01a2 100755 --- a/include/core_api/output.h +++ b/include/core_api/output.h @@ -44,6 +44,7 @@ class colorOutput_t virtual void highliteArea(int numView, int x0, int y0, int x1, int y1){}; virtual bool isImageOutput() { return false; } virtual bool isPreview() { return false; } + virtual std::string getDenoiseParams() const { return ""; } }; __END_YAFRAY diff --git a/include/yafraycore/imageOutput.h b/include/yafraycore/imageOutput.h index 750fe259..e8a67e1a 100755 --- a/include/yafraycore/imageOutput.h +++ b/include/yafraycore/imageOutput.h @@ -40,9 +40,14 @@ class YAFRAYCORE_EXPORT imageOutput_t : public colorOutput_t virtual void flush(int numView, const renderPasses_t *renderPasses); virtual void flushArea(int numView, int x0, int y0, int x1, int y1, const renderPasses_t *renderPasses) {} // not used by images... yet virtual bool isImageOutput() { return true; } + virtual std::string getDenoiseParams() const + { + if(image) return image->getDenoiseParams(); + else return ""; + } void saveImageFile(std::string filename, int idx); void saveImageFileMultiChannel(std::string filename, const renderPasses_t *renderPasses); - + private: imageHandler_t *image; std::string fname; diff --git a/src/image_handlers/exrHandler.cc b/src/image_handlers/exrHandler.cc index f3cc2ed5..60678929 100755 --- a/src/image_handlers/exrHandler.cc +++ b/src/image_handlers/exrHandler.cc @@ -97,8 +97,8 @@ bool exrHandler_t::saveToFile(const std::string &name, int imagePassNumber) { std::string nameWithoutTmp = name; nameWithoutTmp.erase(nameWithoutTmp.length()-4); - if(session.renderInProgress()) Y_INFO << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << nameWithoutTmp << "\"..." << yendl; - else Y_INFO << handlerName << ": Saving RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << nameWithoutTmp << "\"..." << yendl; + if(session.renderInProgress()) Y_INFO << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << nameWithoutTmp << "\"... " << getDenoiseParams() << yendl; + else Y_INFO << handlerName << ": Saving RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << nameWithoutTmp << "\"... " << getDenoiseParams() << yendl; int chan_size = sizeof(half); const int num_colchan = 4; @@ -146,8 +146,8 @@ bool exrHandler_t::saveToFileMultiChannel(const std::string &name, bool denoise, std::string nameWithoutTmp = name; nameWithoutTmp.erase(nameWithoutTmp.length()-4); - if(session.renderInProgress()) Y_INFO << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") Multilayer EXR" << " file as \"" << nameWithoutTmp << "\"..." << yendl; - else Y_INFO << handlerName << ": Saving Multilayer EXR" << " file as \"" << nameWithoutTmp << "\"..." << yendl; + if(session.renderInProgress()) Y_INFO << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") Multilayer EXR" << " file as \"" << nameWithoutTmp << "\"... " << getDenoiseParams() << yendl; + else Y_INFO << handlerName << ": Saving Multilayer EXR" << " file as \"" << nameWithoutTmp << "\"... " << getDenoiseParams() << yendl; int chan_size = sizeof(half); const int num_colchan = 4; diff --git a/src/image_handlers/hdrHandler.cc b/src/image_handlers/hdrHandler.cc index 75127e13..ce261eec 100755 --- a/src/image_handlers/hdrHandler.cc +++ b/src/image_handlers/hdrHandler.cc @@ -453,8 +453,8 @@ bool hdrHandler_t::saveToFile(const std::string &name, int imagePassNumber) { std::string nameWithoutTmp = name; nameWithoutTmp.erase(nameWithoutTmp.length()-4); - if(session.renderInProgress()) Y_INFO << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") RGBE file as \"" << nameWithoutTmp << "\"..." << yendl; - else Y_INFO << handlerName << ": Saving RGBE file as \"" << nameWithoutTmp << "\"..." << yendl; + if(session.renderInProgress()) Y_INFO << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") RGBE file as \"" << nameWithoutTmp << "\"... " << getDenoiseParams() << yendl; + else Y_INFO << handlerName << ": Saving RGBE file as \"" << nameWithoutTmp << "\"... " << getDenoiseParams() << yendl; if (m_hasAlpha) Y_VERBOSE << handlerName << ": Ignoring alpha channel." << yendl; writeHeader(file); diff --git a/src/image_handlers/jpgHandler.cc b/src/image_handlers/jpgHandler.cc index b22bef81..ddd548f4 100755 --- a/src/image_handlers/jpgHandler.cc +++ b/src/image_handlers/jpgHandler.cc @@ -143,8 +143,8 @@ bool jpgHandler_t::saveToFile(const std::string &name, int imagePassNumber) { std::string nameWithoutTmp = name; nameWithoutTmp.erase(nameWithoutTmp.length()-4); - if(session.renderInProgress()) Y_INFO << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") RGB" << " file as \"" << nameWithoutTmp << "\"..." << yendl; - else Y_INFO << handlerName << ": Saving RGB" << " file as \"" << nameWithoutTmp << "\"..." << yendl; + if(session.renderInProgress()) Y_INFO << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") RGB" << " file as \"" << nameWithoutTmp << "\"... " << getDenoiseParams() << yendl; + else Y_INFO << handlerName << ": Saving RGB" << " file as \"" << nameWithoutTmp << "\"... " << getDenoiseParams() << yendl; struct jpeg_compress_struct info; struct jpgErrorManager jerr; @@ -241,8 +241,8 @@ bool jpgHandler_t::saveToFile(const std::string &name, int imagePassNumber) if(m_hasAlpha) { std::string alphaname = name.substr(0, name.size() - 4) + "_alpha.jpg"; - if(session.renderInProgress()) Y_INFO << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") Alpha channel as \"" << alphaname << "\"..." << yendl; - else Y_INFO << handlerName << ": Saving Alpha channel as \"" << alphaname << "\"..." << yendl; + if(session.renderInProgress()) Y_INFO << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") Alpha channel as \"" << alphaname << "\"... " << getDenoiseParams() << yendl; + else Y_INFO << handlerName << ": Saving Alpha channel as \"" << alphaname << "\"... " << getDenoiseParams() << yendl; fp = fileUnicodeOpen(alphaname, "wb"); diff --git a/src/image_handlers/pngHandler.cc b/src/image_handlers/pngHandler.cc index a4667f91..481886fd 100755 --- a/src/image_handlers/pngHandler.cc +++ b/src/image_handlers/pngHandler.cc @@ -133,8 +133,8 @@ bool pngHandler_t::saveToFile(const std::string &name, int imagePassNumber) { std::string nameWithoutTmp = name; nameWithoutTmp.erase(nameWithoutTmp.length()-4); - if(session.renderInProgress()) Y_INFO << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << nameWithoutTmp << "\"..." << yendl; - else Y_INFO << handlerName << ": Saving RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << nameWithoutTmp << "\"..." << yendl; + if(session.renderInProgress()) Y_INFO << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << nameWithoutTmp << "\"... " << getDenoiseParams() << yendl; + else Y_INFO << handlerName << ": Saving RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << nameWithoutTmp << "\"... " << getDenoiseParams() << yendl; png_structp pngPtr; png_infop infoPtr; diff --git a/src/image_handlers/tgaHandler.cc b/src/image_handlers/tgaHandler.cc index db8c996e..82ba2504 100755 --- a/src/image_handlers/tgaHandler.cc +++ b/src/image_handlers/tgaHandler.cc @@ -132,8 +132,8 @@ bool tgaHandler_t::saveToFile(const std::string &name, int imagePassNumber) { std::string nameWithoutTmp = name; nameWithoutTmp.erase(nameWithoutTmp.length()-4); - if(session.renderInProgress()) Y_INFO << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") " << ((m_hasAlpha) ? "RGBA" : "RGB" ) << " file as \"" << nameWithoutTmp << "\"..." << yendl; - else Y_INFO << handlerName << ": Saving " << ((m_hasAlpha) ? "RGBA" : "RGB" ) << " file as \"" << nameWithoutTmp << "\"..." << yendl; + if(session.renderInProgress()) Y_INFO << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") " << ((m_hasAlpha) ? "RGBA" : "RGB" ) << " file as \"" << nameWithoutTmp << "\"... " << getDenoiseParams() << yendl; + else Y_INFO << handlerName << ": Saving " << ((m_hasAlpha) ? "RGBA" : "RGB" ) << " file as \"" << nameWithoutTmp << "\"... " << getDenoiseParams() << yendl; std::string imageId = "Image rendered with YafaRay"; tgaHeader_t header; diff --git a/src/image_handlers/tifHandler.cc b/src/image_handlers/tifHandler.cc index 327fca5e..65dccea2 100755 --- a/src/image_handlers/tifHandler.cc +++ b/src/image_handlers/tifHandler.cc @@ -121,8 +121,8 @@ bool tifHandler_t::saveToFile(const std::string &name, int imagePassNumber) { std::string nameWithoutTmp = name; nameWithoutTmp.erase(nameWithoutTmp.length()-4); - if(session.renderInProgress()) Y_INFO << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << nameWithoutTmp << "\"..." << yendl; - else Y_INFO << handlerName << ": Saving RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << nameWithoutTmp << "\"..." << yendl; + if(session.renderInProgress()) Y_INFO << handlerName << ": Autosaving partial render (" << RoundFloatPrecision(session.currentPassPercent(), 0.01) << "% of pass " << session.currentPass() << " of " << session.totalPasses() << ") RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << nameWithoutTmp << "\"... " << getDenoiseParams() << yendl; + else Y_INFO << handlerName << ": Saving RGB" << ( m_hasAlpha ? "A" : "" ) << " file as \"" << nameWithoutTmp << "\"... " << getDenoiseParams() << yendl; #if defined(_WIN32) std::wstring wname = utf8_to_wutf16(name); diff --git a/src/yafraycore/imagefilm.cc b/src/yafraycore/imagefilm.cc index e72d1a51..849d1daa 100755 --- a/src/yafraycore/imagefilm.cc +++ b/src/yafraycore/imagefilm.cc @@ -631,9 +631,13 @@ void imageFilm_t::flush(int numView, int flags, colorOutput_t *out) if(yafLog.getDrawRenderSettings()) ssBadge << " | " << yafLog.getRenderSettings(); if(yafLog.getDrawAANoiseSettings()) ssBadge << "\n" << yafLog.getAANoiseSettings(); + if(output && output->isImageOutput()) ssBadge << " " << output->getDenoiseParams(); + else if(out2 && out2->isImageOutput()) ssBadge << " " << out2->getDenoiseParams(); ssLog << " | " << yafLog.getRenderSettings(); ssLog << "\n" << yafLog.getAANoiseSettings(); + if(output && output->isImageOutput()) ssLog << " " << output->getDenoiseParams(); + else if(out2 && out2->isImageOutput()) ssLog << " " << out2->getDenoiseParams(); if(yafLog.getUseParamsBadge()) { diff --git a/src/yafraycore/integrator.cc b/src/yafraycore/integrator.cc index 8163e710..4d8ce91c 100755 --- a/src/yafraycore/integrator.cc +++ b/src/yafraycore/integrator.cc @@ -120,8 +120,9 @@ bool tiledIntegrator_t::render(int numView, imageFilm_t *image) aaSettings << " passes=" << AA_passes; aaSettings << " samples=" << AA_samples << " inc_samples=" << AA_inc_samples << " resamp.floor=" << AA_resampled_floor << "\nsample.mul=" << AA_sample_multiplier_factor << " light.sam.mul=" << AA_light_sample_multiplier_factor << " ind.sam.mul=" << AA_indirect_sample_multiplier_factor << "\ncol.noise=" << AA_detect_color_noise; - if(AA_dark_detection_type == DARK_DETECTION_LINEAR) aaSettings << " dark.thr(lin),fac=" << AA_dark_threshold_factor; - else if(AA_dark_detection_type == DARK_DETECTION_CURVE) aaSettings << " dark.thr(curve)"; + if(AA_dark_detection_type == DARK_DETECTION_LINEAR) aaSettings << " AA thr(lin)=" << AA_threshold << ",dark_fac=" << AA_dark_threshold_factor; + else if(AA_dark_detection_type == DARK_DETECTION_CURVE) aaSettings << " AA.thr(curve)"; + else aaSettings << " AA thr=" << AA_threshold; aaSettings << " var.edge=" << AA_variance_edge_size << " var.pix=" << AA_variance_pixels << " clamp=" << AA_clamp_samples << " ind.clamp=" << AA_clamp_indirect; @@ -145,8 +146,11 @@ bool tiledIntegrator_t::render(int numView, imageFilm_t *image) Y_VERBOSE << "AA_light_sample_multiplier_factor: "<< AA_light_sample_multiplier_factor << yendl; Y_VERBOSE << "AA_indirect_sample_multiplier_factor: "<< AA_indirect_sample_multiplier_factor << yendl; Y_VERBOSE << "AA_detect_color_noise: "<< AA_detect_color_noise << yendl; - if(AA_dark_detection_type == DARK_DETECTION_LINEAR) Y_VERBOSE << "AA_dark_threshold (linear), factor: "<< AA_dark_threshold_factor << yendl; - if(AA_dark_detection_type == DARK_DETECTION_CURVE) Y_VERBOSE << "AA_dark_threshold (curve)" << yendl; + + if(AA_dark_detection_type == DARK_DETECTION_LINEAR) Y_VERBOSE << "AA_threshold (linear): " << AA_threshold << ", dark factor: "<< AA_dark_threshold_factor << yendl; + else if(AA_dark_detection_type == DARK_DETECTION_CURVE) Y_VERBOSE << "AA_threshold (curve)" << yendl; + else Y_VERBOSE << "AA threshold:" << AA_threshold << yendl; + Y_VERBOSE << "AA_variance_edge_size: "<< AA_variance_edge_size << yendl; Y_VERBOSE << "AA_variance_pixels: "<< AA_variance_pixels << yendl; Y_VERBOSE << "AA_clamp_samples: "<< AA_clamp_samples << yendl; From 5a104fd571e27d7747463938813c5620ba1d57a0 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Wed, 22 Jun 2016 21:43:49 +0100 Subject: [PATCH 104/124] OpenCV Denoise: add new parameter "Mix" to keep part of the original "noisy" image to prevent Banding artifacts in fully de-noised images --- include/core_api/imagehandler.h | 5 +++-- src/bindings/yafaray_v3_interface.i | 2 +- src/image_handlers/exrHandler.cc | 9 ++++++--- src/image_handlers/hdrHandler.cc | 9 ++++++--- src/image_handlers/jpgHandler.cc | 15 +++++++++------ src/image_handlers/pngHandler.cc | 15 +++++++++------ src/image_handlers/tgaHandler.cc | 21 ++++++++++++--------- src/image_handlers/tifHandler.cc | 15 +++++++++------ 8 files changed, 55 insertions(+), 36 deletions(-) diff --git a/include/core_api/imagehandler.h b/include/core_api/imagehandler.h index 46ac2b3c..73d48a0b 100755 --- a/include/core_api/imagehandler.h +++ b/include/core_api/imagehandler.h @@ -48,7 +48,7 @@ class YAFRAYCORE_EXPORT imageHandler_t public: imageHandler_t():m_width(0), m_height(0), m_hasAlpha(false), m_textureOptimization(TEX_OPTIMIZATION_OPTIMIZED), rgbaOptimizedBuffer(nullptr), rgbaCompressedBuffer(nullptr), rgbOptimizedBuffer(nullptr), rgbCompressedBuffer(nullptr), m_MultiLayer(false) {}; - virtual void initForOutput(int width, int height, const renderPasses_t *renderPasses, bool denoiseEnabled, int denoiseHLum, int denoiseHCol, bool withAlpha = false, bool multi_layer = false) = 0; + virtual void initForOutput(int width, int height, const renderPasses_t *renderPasses, bool denoiseEnabled, int denoiseHLum, int denoiseHCol, float denoiseMix, bool withAlpha = false, bool multi_layer = false) = 0; virtual ~imageHandler_t() {}; virtual bool loadFromFile(const std::string &name) = 0; virtual bool loadFromMemory(const yByte *data, size_t size) {return false; } @@ -67,7 +67,7 @@ class YAFRAYCORE_EXPORT imageHandler_t { if(!m_Denoise) return ""; std::stringstream paramString; - paramString << "| Image file denoise=on (hLuminance=" << m_DenoiseHLum << ", hCrominance=" << m_DenoiseHCol << ")" << yendl; + paramString << "| Image file denoise enabled [mix=" << m_DenoiseMix << ", h(Luminance)=" << m_DenoiseHLum << ", h(Chrominance)=" << m_DenoiseHCol << "]" << yendl; return paramString.str(); } @@ -86,6 +86,7 @@ class YAFRAYCORE_EXPORT imageHandler_t bool m_Denoise = false; int m_DenoiseHLum = 3; int m_DenoiseHCol = 3; + float m_DenoiseMix = 0.8f; //!< Mix factor between the de-noised image and the original "noisy" image to avoid banding artifacts in images with all noise removed. }; diff --git a/src/bindings/yafaray_v3_interface.i b/src/bindings/yafaray_v3_interface.i index 4559f582..439d2521 100755 --- a/src/bindings/yafaray_v3_interface.i +++ b/src/bindings/yafaray_v3_interface.i @@ -595,7 +595,7 @@ namespace yafaray public: imageHandler_t():m_width(0), m_height(0), m_hasAlpha(false), m_textureOptimization(TEX_OPTIMIZATION_OPTIMIZED), rgbaOptimizedBuffer(nullptr), rgbaCompressedBuffer(nullptr), rgbOptimizedBuffer(nullptr), rgbCompressedBuffer(nullptr), m_MultiLayer(false) {}; - virtual void initForOutput(int width, int height, const renderPasses_t *renderPasses, bool denoiseEnabled, int denoiseHLum, int denoiseHCol, bool withAlpha = false, bool multi_layer = false) = 0; + virtual void initForOutput(int width, int height, const renderPasses_t *renderPasses, bool denoiseEnabled, int denoiseHLum, int denoiseHCol, float denoiseMix, bool withAlpha = false, bool multi_layer = false) = 0; virtual ~imageHandler_t() {}; virtual bool loadFromFile(const std::string &name) = 0; virtual bool loadFromMemory(const yByte *data, size_t size) {return false; } diff --git a/src/image_handlers/exrHandler.cc b/src/image_handlers/exrHandler.cc index 60678929..4a3db9a2 100755 --- a/src/image_handlers/exrHandler.cc +++ b/src/image_handlers/exrHandler.cc @@ -45,7 +45,7 @@ class exrHandler_t: public imageHandler_t { public: exrHandler_t(); - void initForOutput(int width, int height, const renderPasses_t *renderPasses, bool denoiseEnabled, int denoiseHLum, int denoiseHCol, bool withAlpha = false, bool multi_layer = false); + void initForOutput(int width, int height, const renderPasses_t *renderPasses, bool denoiseEnabled, int denoiseHLum, int denoiseHCol, float denoiseMix, bool withAlpha = false, bool multi_layer = false); void initForInput(); ~exrHandler_t(); bool loadFromFile(const std::string &name); @@ -65,7 +65,7 @@ exrHandler_t::exrHandler_t() handlerName = "EXRHandler"; } -void exrHandler_t::initForOutput(int width, int height, const renderPasses_t *renderPasses, bool denoiseEnabled, int denoiseHLum, int denoiseHCol, bool withAlpha, bool multi_layer) +void exrHandler_t::initForOutput(int width, int height, const renderPasses_t *renderPasses, bool denoiseEnabled, int denoiseHLum, int denoiseHCol, float denoiseMix, bool withAlpha, bool multi_layer) { m_width = width; m_height = height; @@ -74,6 +74,7 @@ void exrHandler_t::initForOutput(int width, int height, const renderPasses_t *re m_Denoise = denoiseEnabled; m_DenoiseHLum = denoiseHLum; m_DenoiseHCol = denoiseHCol; + m_DenoiseMix = denoiseMix; m_halfrgba.resize(renderPasses->extPassesSize()); @@ -315,6 +316,7 @@ imageHandler_t *exrHandler_t::factory(paraMap_t ¶ms,renderEnvironment_t &ren bool denoiseEnabled = false; int denoiseHLum = 3; int denoiseHCol = 3; + float denoiseMix = 0.8f; params.getParam("pixel_type", pixtype); params.getParam("compression", compression); @@ -327,13 +329,14 @@ imageHandler_t *exrHandler_t::factory(paraMap_t ¶ms,renderEnvironment_t &ren * params.getParam("denoiseEnabled", denoiseEnabled); * params.getParam("denoiseHLum", denoiseHLum); * params.getParam("denoiseHCol", denoiseHCol); + * params.getParam("denoiseMix", denoiseMix); */ imageHandler_t *ih = new exrHandler_t(); if(forOutput) { if(yafLog.getUseParamsBadge()) height += yafLog.getBadgeHeight(); - ih->initForOutput(width, height, render.getRenderPasses(), denoiseEnabled, denoiseHLum, denoiseHCol, withAlpha, multiLayer); + ih->initForOutput(width, height, render.getRenderPasses(), denoiseEnabled, denoiseHLum, denoiseHCol, denoiseMix, withAlpha, multiLayer); } return ih; diff --git a/src/image_handlers/hdrHandler.cc b/src/image_handlers/hdrHandler.cc index ce261eec..a28dff03 100755 --- a/src/image_handlers/hdrHandler.cc +++ b/src/image_handlers/hdrHandler.cc @@ -42,7 +42,7 @@ class hdrHandler_t: public imageHandler_t public: hdrHandler_t(); ~hdrHandler_t(); - void initForOutput(int width, int height, const renderPasses_t *renderPasses, bool denoiseEnabled, int denoiseHLum, int denoiseHCol, bool withAlpha = false, bool multi_layer = false); + void initForOutput(int width, int height, const renderPasses_t *renderPasses, bool denoiseEnabled, int denoiseHLum, int denoiseHCol, float denoiseMix, bool withAlpha = false, bool multi_layer = false); bool loadFromFile(const std::string &name); bool saveToFile(const std::string &name, int imagePassNumber = 0); void putPixel(int x, int y, const colorA_t &rgba, int imagePassNumber = 0); @@ -79,7 +79,7 @@ hdrHandler_t::~hdrHandler_t() } } -void hdrHandler_t::initForOutput(int width, int height, const renderPasses_t *renderPasses, bool denoiseEnabled, int denoiseHLum, int denoiseHCol, bool withAlpha, bool multi_layer) +void hdrHandler_t::initForOutput(int width, int height, const renderPasses_t *renderPasses, bool denoiseEnabled, int denoiseHLum, int denoiseHCol, float denoiseMix, bool withAlpha, bool multi_layer) { m_width = width; m_height = height; @@ -88,6 +88,7 @@ void hdrHandler_t::initForOutput(int width, int height, const renderPasses_t *re m_Denoise = denoiseEnabled; m_DenoiseHLum = denoiseHLum; m_DenoiseHCol = denoiseHCol; + m_DenoiseMix = denoiseMix; imagePasses.resize(renderPasses->extPassesSize()); @@ -595,6 +596,7 @@ imageHandler_t *hdrHandler_t::factory(paraMap_t ¶ms,renderEnvironment_t &ren bool denoiseEnabled = false; int denoiseHLum = 3; int denoiseHCol = 3; + float denoiseMix = 0.8f; params.getParam("width", width); params.getParam("height", height); @@ -604,13 +606,14 @@ imageHandler_t *hdrHandler_t::factory(paraMap_t ¶ms,renderEnvironment_t &ren * params.getParam("denoiseEnabled", denoiseEnabled); * params.getParam("denoiseHLum", denoiseHLum); * params.getParam("denoiseHCol", denoiseHCol); + * params.getParam("denoiseMix", denoiseMix); */ imageHandler_t *ih = new hdrHandler_t(); if(forOutput) { if(yafLog.getUseParamsBadge()) height += yafLog.getBadgeHeight(); - ih->initForOutput(width, height, render.getRenderPasses(), denoiseEnabled, denoiseHLum, denoiseHCol, withAlpha, false); + ih->initForOutput(width, height, render.getRenderPasses(), denoiseEnabled, denoiseHLum, denoiseHCol, denoiseMix, withAlpha, false); } return ih; diff --git a/src/image_handlers/jpgHandler.cc b/src/image_handlers/jpgHandler.cc index ddd548f4..129f8af0 100755 --- a/src/image_handlers/jpgHandler.cc +++ b/src/image_handlers/jpgHandler.cc @@ -69,7 +69,7 @@ class jpgHandler_t: public imageHandler_t public: jpgHandler_t(); ~jpgHandler_t(); - void initForOutput(int width, int height, const renderPasses_t *renderPasses, bool denoiseEnabled, int denoiseHLum, int denoiseHCol, bool withAlpha = false, bool multi_layer = false); + void initForOutput(int width, int height, const renderPasses_t *renderPasses, bool denoiseEnabled, int denoiseHLum, int denoiseHCol, float denoiseMix, bool withAlpha = false, bool multi_layer = false); bool loadFromFile(const std::string &name); bool saveToFile(const std::string &name, int imagePassNumber = 0); void putPixel(int x, int y, const colorA_t &rgba, int imagePassNumber = 0); @@ -90,7 +90,7 @@ jpgHandler_t::jpgHandler_t() rgbCompressedBuffer = nullptr; } -void jpgHandler_t::initForOutput(int width, int height, const renderPasses_t *renderPasses, bool denoiseEnabled, int denoiseHLum, int denoiseHCol, bool withAlpha, bool multi_layer) +void jpgHandler_t::initForOutput(int width, int height, const renderPasses_t *renderPasses, bool denoiseEnabled, int denoiseHLum, int denoiseHCol, float denoiseMix, bool withAlpha, bool multi_layer) { m_width = width; m_height = height; @@ -99,6 +99,7 @@ void jpgHandler_t::initForOutput(int width, int height, const renderPasses_t *re m_Denoise = denoiseEnabled; m_DenoiseHLum = denoiseHLum; m_DenoiseHCol = denoiseHCol; + m_DenoiseMix = denoiseMix; imagePasses.resize(renderPasses->extPassesSize()); @@ -206,9 +207,9 @@ bool jpgHandler_t::saveToFile(const std::string &name, int imagePassNumber) for (x = 0; x < m_width; x++) { ix = x * 3; - scanline[ix] = (yByte) _B(y, x)[0]; - scanline[ix+1] = (yByte) _B(y, x)[1]; - scanline[ix+2] = (yByte) _B(y, x)[2]; + scanline[ix] = (yByte) (m_DenoiseMix * _B(y, x)[0] + (1.f-m_DenoiseMix) * _A(y, x)[0]); + scanline[ix+1] = (yByte) (m_DenoiseMix * _B(y, x)[1] + (1.f-m_DenoiseMix) * _A(y, x)[1]); + scanline[ix+2] = (yByte) (m_DenoiseMix * _B(y, x)[2] + (1.f-m_DenoiseMix) * _A(y, x)[2]); } jpeg_write_scanlines(&info, &scanline, 1); @@ -442,6 +443,7 @@ imageHandler_t *jpgHandler_t::factory(paraMap_t ¶ms, renderEnvironment_t &re bool denoiseEnabled = false; int denoiseHLum = 3; int denoiseHCol = 3; + float denoiseMix = 0.8f; params.getParam("width", width); params.getParam("height", height); @@ -450,13 +452,14 @@ imageHandler_t *jpgHandler_t::factory(paraMap_t ¶ms, renderEnvironment_t &re params.getParam("denoiseEnabled", denoiseEnabled); params.getParam("denoiseHLum", denoiseHLum); params.getParam("denoiseHCol", denoiseHCol); + params.getParam("denoiseMix", denoiseMix); imageHandler_t *ih = new jpgHandler_t(); if(forOutput) { if(yafLog.getUseParamsBadge()) height += yafLog.getBadgeHeight(); - ih->initForOutput(width, height, render.getRenderPasses(), denoiseEnabled, denoiseHLum, denoiseHCol, withAlpha, false); + ih->initForOutput(width, height, render.getRenderPasses(), denoiseEnabled, denoiseHLum, denoiseHCol, denoiseMix, withAlpha, false); } return ih; diff --git a/src/image_handlers/pngHandler.cc b/src/image_handlers/pngHandler.cc index 481886fd..31ffdba7 100755 --- a/src/image_handlers/pngHandler.cc +++ b/src/image_handlers/pngHandler.cc @@ -45,7 +45,7 @@ class pngHandler_t: public imageHandler_t public: pngHandler_t(); ~pngHandler_t(); - void initForOutput(int width, int height, const renderPasses_t *renderPasses, bool denoiseEnabled, int denoiseHLum, int denoiseHCol, bool withAlpha = false, bool multi_layer = false); + void initForOutput(int width, int height, const renderPasses_t *renderPasses, bool denoiseEnabled, int denoiseHLum, int denoiseHCol, float denoiseMix, bool withAlpha = false, bool multi_layer = false); bool loadFromFile(const std::string &name); bool loadFromMemory(const yByte *data, size_t size); bool saveToFile(const std::string &name, int imagePassNumber = 0); @@ -74,7 +74,7 @@ pngHandler_t::pngHandler_t() rgbaCompressedBuffer = nullptr; } -void pngHandler_t::initForOutput(int width, int height, const renderPasses_t *renderPasses, bool denoiseEnabled, int denoiseHLum, int denoiseHCol, bool withAlpha, bool multi_layer) +void pngHandler_t::initForOutput(int width, int height, const renderPasses_t *renderPasses, bool denoiseEnabled, int denoiseHLum, int denoiseHCol, float denoiseMix, bool withAlpha, bool multi_layer) { m_width = width; m_height = height; @@ -83,6 +83,7 @@ void pngHandler_t::initForOutput(int width, int height, const renderPasses_t *re m_Denoise = denoiseEnabled; m_DenoiseHLum = denoiseHLum; m_DenoiseHCol = denoiseHCol; + m_DenoiseMix = denoiseMix; imagePasses.resize(renderPasses->extPassesSize()); @@ -199,9 +200,9 @@ bool pngHandler_t::saveToFile(const std::string &name, int imagePassNumber) int i = x * channels; - rowPointers[y][i] = (yByte) _B(y, x)[0]; - rowPointers[y][i+1] = (yByte) _B(y, x)[1]; - rowPointers[y][i+2] = (yByte) _B(y, x)[2]; + rowPointers[y][i] = (yByte) (m_DenoiseMix * _B(y, x)[0] + (1.f-m_DenoiseMix) * _A(y, x)[0]); + rowPointers[y][i+1] = (yByte) (m_DenoiseMix * _B(y, x)[1] + (1.f-m_DenoiseMix) * _A(y, x)[1]); + rowPointers[y][i+2] = (yByte) (m_DenoiseMix * _B(y, x)[2] + (1.f-m_DenoiseMix) * _A(y, x)[2]); if(m_hasAlpha) rowPointers[y][i+3] = (yByte)(color.getA() * 255.f); } } @@ -561,6 +562,7 @@ imageHandler_t *pngHandler_t::factory(paraMap_t ¶ms, renderEnvironment_t &re bool denoiseEnabled = false; int denoiseHLum = 3; int denoiseHCol = 3; + float denoiseMix = 0.8f; params.getParam("width", width); params.getParam("height", height); @@ -569,6 +571,7 @@ imageHandler_t *pngHandler_t::factory(paraMap_t ¶ms, renderEnvironment_t &re params.getParam("denoiseEnabled", denoiseEnabled); params.getParam("denoiseHLum", denoiseHLum); params.getParam("denoiseHCol", denoiseHCol); + params.getParam("denoiseMix", denoiseMix); Y_DEBUG << "denoiseEnabled="<initForOutput(width, height, render.getRenderPasses(), denoiseEnabled, denoiseHLum, denoiseHCol, withAlpha, false); + ih->initForOutput(width, height, render.getRenderPasses(), denoiseEnabled, denoiseHLum, denoiseHCol, denoiseMix, withAlpha, false); } return ih; diff --git a/src/image_handlers/tifHandler.cc b/src/image_handlers/tifHandler.cc index 65dccea2..a86f980f 100755 --- a/src/image_handlers/tifHandler.cc +++ b/src/image_handlers/tifHandler.cc @@ -39,7 +39,7 @@ class tifHandler_t: public imageHandler_t public: tifHandler_t(); ~tifHandler_t(); - void initForOutput(int width, int height, const renderPasses_t *renderPasses, bool denoiseEnabled, int denoiseHLum, int denoiseHCol, bool withAlpha = false, bool multi_layer = false); + void initForOutput(int width, int height, const renderPasses_t *renderPasses, bool denoiseEnabled, int denoiseHLum, int denoiseHCol, float denoiseMix, bool withAlpha = false, bool multi_layer = false); bool loadFromFile(const std::string &name); bool saveToFile(const std::string &name, int imagePassNumber = 0); void putPixel(int x, int y, const colorA_t &rgba, int imagePassNumber = 0); @@ -62,7 +62,7 @@ tifHandler_t::tifHandler_t() rgbaCompressedBuffer = nullptr; } -void tifHandler_t::initForOutput(int width, int height, const renderPasses_t *renderPasses, bool denoiseEnabled, int denoiseHLum, int denoiseHCol, bool withAlpha, bool multi_layer) +void tifHandler_t::initForOutput(int width, int height, const renderPasses_t *renderPasses, bool denoiseEnabled, int denoiseHLum, int denoiseHCol, float denoiseMix, bool withAlpha, bool multi_layer) { m_width = width; m_height = height; @@ -71,6 +71,7 @@ void tifHandler_t::initForOutput(int width, int height, const renderPasses_t *re m_Denoise = denoiseEnabled; m_DenoiseHLum = denoiseHLum; m_DenoiseHCol = denoiseHCol; + m_DenoiseMix = denoiseMix; imagePasses.resize(renderPasses->extPassesSize()); @@ -179,9 +180,9 @@ bool tifHandler_t::saveToFile(const std::string &name, int imagePassNumber) int ix = x * channels; colorA_t &col = (*imagePasses.at(imagePassNumber))(x, y); col.clampRGBA01(); - scanline[ix] = (yByte) _B(y, x)[0]; - scanline[ix+1] = (yByte) _B(y, x)[1]; - scanline[ix+2] = (yByte) _B(y, x)[2]; + scanline[ix] = (yByte) (m_DenoiseMix * _B(y, x)[0] + (1.f-m_DenoiseMix) * _A(y, x)[0]); + scanline[ix+1] = (yByte) (m_DenoiseMix * _B(y, x)[1] + (1.f-m_DenoiseMix) * _A(y, x)[1]); + scanline[ix+2] = (yByte) (m_DenoiseMix * _B(y, x)[2] + (1.f-m_DenoiseMix) * _A(y, x)[2]); if(m_hasAlpha) scanline[ix+3] = (yByte)(col.getA() * 255.f); } @@ -310,6 +311,7 @@ imageHandler_t *tifHandler_t::factory(paraMap_t ¶ms, renderEnvironment_t &re bool denoiseEnabled = false; int denoiseHLum = 3; int denoiseHCol = 3; + float denoiseMix = 0.8f; params.getParam("width", width); params.getParam("height", height); @@ -318,13 +320,14 @@ imageHandler_t *tifHandler_t::factory(paraMap_t ¶ms, renderEnvironment_t &re params.getParam("denoiseEnabled", denoiseEnabled); params.getParam("denoiseHLum", denoiseHLum); params.getParam("denoiseHCol", denoiseHCol); + params.getParam("denoiseMix", denoiseMix); imageHandler_t *ih = new tifHandler_t(); if(forOutput) { if(yafLog.getUseParamsBadge()) height += yafLog.getBadgeHeight(); - ih->initForOutput(width, height, render.getRenderPasses(), denoiseEnabled, denoiseHLum, denoiseHCol, withAlpha, false); + ih->initForOutput(width, height, render.getRenderPasses(), denoiseEnabled, denoiseHLum, denoiseHCol, denoiseMix, withAlpha, false); } return ih; From 20a3af48e2293e579ba240d848264a203c9c9ad8 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Thu, 23 Jun 2016 05:34:13 +0100 Subject: [PATCH 105/124] IES files: added check to ensure the file is actually an IES file and avoid hanging YafaRay if the user chooses the wrong file --- CMakeModules/FindOpenCV.cmake | 0 include/utilities/iesUtils.h | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+) mode change 100644 => 100755 CMakeModules/FindOpenCV.cmake diff --git a/CMakeModules/FindOpenCV.cmake b/CMakeModules/FindOpenCV.cmake old mode 100644 new mode 100755 diff --git a/include/utilities/iesUtils.h b/include/utilities/iesUtils.h index 1fd1c24f..a23f6200 100755 --- a/include/utilities/iesUtils.h +++ b/include/utilities/iesUtils.h @@ -157,6 +157,31 @@ bool IESData_t::parseIESFile(const std::string iesFile) return false; } + //get length of file: + fin.seekg (0, fin.end); + int length = fin.tellg(); + fin.seekg (0, fin.beg); + + if (length < 7) + { + Y_ERROR << "IES Parser: file is too small, only " << length << " bytes long." << yendl; + return false; + } + + //check header is correct + char ies_check_characters[7]; + fin.get(ies_check_characters, 7); + Y_DEBUG << "std::string(ies_check_characters)=" << std::string(ies_check_characters) << yendl; + + if (std::string(ies_check_characters) != "IESNA:") + { + Y_ERROR << "IES Parser: wrong file format, first characters are not \"IESNA:\"" << yendl; + return false; + } + + //rewind file to beginning again + fin.seekg (0, fin.beg); + string line; string dummy; From 1d79543aa0d9e53aad2a1a7ec9c28a8c7c2f171d Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sat, 25 Jun 2016 18:05:33 +0100 Subject: [PATCH 106/124] Updated documentation for ALPHA9. Also updated and extended the LICENSES file --- LICENSES | 214 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 187 insertions(+), 27 deletions(-) diff --git a/LICENSES b/LICENSES index b9ce329e..5a1f6b91 100755 --- a/LICENSES +++ b/LICENSES @@ -7,6 +7,7 @@ YAFARAY LICENSES YafaRay Blender Exporter code ------------------------------ +http://www.yafaray.org/ https://github.com/YafaRay/Blender-Exporter GNU GENERAL PUBLIC LICENSE @@ -66,7 +67,7 @@ patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. - + GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION @@ -121,7 +122,7 @@ above, provided that you also meet all of these conditions: License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) - + These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in @@ -179,7 +180,7 @@ access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. - + 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is @@ -236,7 +237,7 @@ impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. - + 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License @@ -289,7 +290,7 @@ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS - + How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest @@ -352,10 +353,9 @@ Public License instead of this License. - - YafaRay Core code ----------------- +http://www.yafaray.org/ https://github.com/YafaRay/Core This program called YAFARAY was originally written by Alejandro Conty @@ -430,7 +430,7 @@ modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. - + Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a @@ -486,7 +486,7 @@ modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. - + GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION @@ -533,7 +533,7 @@ Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. - + 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 @@ -591,7 +591,7 @@ instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. - + Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. @@ -642,7 +642,7 @@ Library will still fall under Section 6.) distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. - + 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work @@ -704,7 +704,7 @@ restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. - + 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined @@ -745,7 +745,7 @@ subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. - + 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or @@ -797,7 +797,7 @@ conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. - + 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is @@ -831,7 +831,7 @@ SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS - + How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest @@ -879,13 +879,15 @@ That's all there is to it! - DEPENDENCIES LICENSES ===================== FreeType -------- +https://www.freetype.org +http://download.savannah.gnu.org/releases/freetype/freetype-2.4.0.tar.gz + The FreeType Project LICENSE ---------------------------- @@ -1057,6 +1059,9 @@ Legal Terms OpenEXR and ILMBase ------------------- +http://www.openexr.com/downloads.html +http://download.savannah.nongnu.org/releases/openexr/ilmbase-2.2.0.tar.gz +http://download.savannah.nongnu.org/releases/openexr/openexr-2.2.0.tar.gz Copyright (c) 2006, Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. Portions contributed and copyright held by @@ -1095,6 +1100,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. JPEG (release 6b) ----------------- +http://www.ijg.org/files/jpegsrc.v6b.tar.gz + +LEGAL ISSUES +============ + In plain English: 1. We don't promise that this software works. (But if you find any bugs, @@ -1179,9 +1189,13 @@ We are required to state that CompuServe Incorporated." - -JPEG (release 9b) +JPEG (release 8d) ----------------- +http://www.ijg.org/files/jpegsrc.v8d.tar.gz + +LEGAL ISSUES +============ + In plain English: 1. We don't promise that this software works. (But if you find any bugs, @@ -1198,7 +1212,7 @@ with respect to this software, its quality, accuracy, merchantability, or fitness for a particular purpose. This software is provided "AS IS", and you, its user, assume the entire risk as to its quality and accuracy. -This software is copyright (C) 1991-2016, Thomas G. Lane, Guido Vollbeding. +This software is copyright (C) 1991-2012, Thomas G. Lane, Guido Vollbeding. All Rights Reserved except as specified below. Permission is hereby granted to use, copy, modify, and distribute this @@ -1229,6 +1243,15 @@ commercial products, provided that all warranty or liability claims are assumed by the product vendor. +ansi2knr.c is included in this distribution by permission of L. Peter Deutsch, +sole proprietor of its copyright holder, Aladdin Enterprises of Menlo Park, CA. +ansi2knr.c is NOT covered by the above copyright and conditions, but instead +by the usual distribution terms of the Free Software Foundation; principally, +that you must include source code if you redistribute it. (See the file +ansi2knr.c for full details.) However, since ansi2knr.c is not needed as part +of any program generated from the IJG code, this does not limit you more than +the foregoing paragraphs do. + The Unix configuration script "configure" was produced with GNU Autoconf. It is copyright by the Free Software Foundation but is freely distributable. The same holds for its supporting scripts (config.guess, config.sub, @@ -1236,16 +1259,22 @@ ltmain.sh). Another support script, install-sh, is copyright by X Consortium but is also freely distributable. The IJG distribution formerly included code to read and write GIF files. -To avoid entanglement with the Unisys LZW patent (now expired), GIF reading -support has been removed altogether, and the GIF writer has been simplified -to produce "uncompressed GIFs". This technique does not use the LZW -algorithm; the resulting GIF files are larger than usual, but are readable -by all standard GIF decoders. +To avoid entanglement with the Unisys LZW patent, GIF reading support has +been removed altogether, and the GIF writer has been simplified to produce +"uncompressed GIFs". This technique does not use the LZW algorithm; the +resulting GIF files are larger than usual, but are readable by all standard +GIF decoders. + +We are required to state that + "The Graphics Interchange Format(c) is the Copyright property of + CompuServe Incorporated. GIF(sm) is a Service Mark property of + CompuServe Incorporated." LibICONV -------- +http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz GNU LIBRARY GENERAL PUBLIC LICENSE Version 2, June 1991 @@ -1734,7 +1763,8 @@ That's all there is to it! LibPNG ------ - +http://downloads.sourceforge.net/project/libpng/libpng12/1.2.56/libpng-1.2.56.tar.xz +http://sourceforge.net/projects/libpng/files/libpng16/older-releases/1.6.3/libpng-1.6.3.tar.gz This copy of the libpng notices is provided for your convenience. In case of any discrepancy between this copy and the notices in the file png.h that is @@ -1851,6 +1881,8 @@ July 18, 2013 LibXML2 ------- +git://git.gnome.org/libxml2 + Except where otherwise noted in the source code (e.g. the files hash.c, list.c and the trio files, which are covered by a similar licence but with different Copyright notices) all the files are: @@ -1879,6 +1911,8 @@ THE SOFTWARE. TIFF ---- +ftp://ftp.remotesensing.org/pub/libtiff/tiff-4.0.3.zip + Copyright (c) 1988-1997 Sam Leffler Copyright (c) 1991-1997 Silicon Graphics, Inc. @@ -1905,6 +1939,8 @@ OF THIS SOFTWARE. ZLIB ---- +http://zlib.net/zlib-1.2.8.tar.xz + Copyright notice: (C) 1995-2013 Jean-loup Gailly and Mark Adler @@ -1941,6 +1977,9 @@ the FAQ for more information on the distribution of modified source versions. BOOST ----- +http://opencv.org/ +https://sourceforge.net/projects/boost/files/boost/1.61.0/boost_1_61_0.tar.bz2 + Boost Software License - Version 1.0 - August 17th, 2003 Permission is hereby granted, free of charge, to any person or organization @@ -1969,6 +2008,9 @@ DEALINGS IN THE SOFTWARE. OpenCV ------ +http://opencv.org/ +https://github.com/itseez/opencv + By downloading, copying, installing or using the software you agree to this license. If you do not agree to this license, do not download, install, copy or use the software. @@ -2015,6 +2057,9 @@ the use of this software, even if advised of the possibility of such damage. Python (v3.x) ------------- +https://www.python.org +https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tar.xz + PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2 -------------------------------------------- @@ -2065,9 +2110,10 @@ Agreement. - mingw-std-threads ----------------- +https://github.com/meganz/mingw-std-threads + Copyright (c) 2016, Mega Limited All rights reserved. @@ -2091,3 +2137,117 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + +libstdc++ (used for some YafaRay builds, typically linux gcc or Windows MinGW) +------------------------------------------------------------------------------- +https://gcc.gnu.org/libstdc++ +https://gcc.gnu.org/onlinedocs/libstdc++/manual/license.html + +License + +There are two licenses affecting GNU libstdc++: one for the code, and one for the documentation. + +There is a license section in the FAQ regarding common questions. If you have more questions, ask the FSF or the gcc mailing list. +The Code: GPL + +The source code is distributed under the GNU General Public License version 3, with the addition under section 7 of an exception described in the โ€œGCC Runtime Library Exception, version 3.1โ€ as follows (or see the file COPYING.RUNTIME): + + +GCC RUNTIME LIBRARY EXCEPTION + +Version 3.1, 31 March 2009 + +Copyright (C) 2009 Free Software Foundation, Inc. + +Everyone is permitted to copy and distribute verbatim copies of this +license document, but changing it is not allowed. + +This GCC Runtime Library Exception ("Exception") is an additional +permission under section 7 of the GNU General Public License, version +3 ("GPLv3"). It applies to a given file (the "Runtime Library") that +bears a notice placed by the copyright holder of the file stating that +the file is governed by GPLv3 along with this Exception. + +When you use GCC to compile a program, GCC may combine portions of +certain GCC header files and runtime libraries with the compiled +program. The purpose of this Exception is to allow compilation of +non-GPL (including proprietary) programs to use, in this way, the +header files and runtime libraries covered by this Exception. + +0. Definitions. + +A file is an "Independent Module" if it either requires the Runtime +Library for execution after a Compilation Process, or makes use of an +interface provided by the Runtime Library, but is not otherwise based +on the Runtime Library. + +"GCC" means a version of the GNU Compiler Collection, with or without +modifications, governed by version 3 (or a specified later version) of +the GNU General Public License (GPL) with the option of using any +subsequent versions published by the FSF. + +"GPL-compatible Software" is software whose conditions of propagation, +modification and use would permit combination with GCC in accord with +the license of GCC. + +"Target Code" refers to output from any compiler for a real or virtual +target processor architecture, in executable form or suitable for +input to an assembler, loader, linker and/or execution +phase. Notwithstanding that, Target Code does not include data in any +format that is used as a compiler intermediate representation, or used +for producing a compiler intermediate representation. + +The "Compilation Process" transforms code entirely represented in +non-intermediate languages designed for human-written code, and/or in +Java Virtual Machine byte code, into Target Code. Thus, for example, +use of source code generators and preprocessors need not be considered +part of the Compilation Process, since the Compilation Process can be +understood as starting with the output of the generators or +preprocessors. + +A Compilation Process is "Eligible" if it is done using GCC, alone or +with other GPL-compatible software, or if it is done without using any +work based on GCC. For example, using non-GPL-compatible Software to +optimize any GCC intermediate representations would not qualify as an +Eligible Compilation Process. + +1. Grant of Additional Permission. + +You have permission to propagate a work of Target Code formed by +combining the Runtime Library with Independent Modules, even if such +propagation would otherwise violate the terms of GPLv3, provided that +all Target Code was generated by Eligible Compilation Processes. You +may then convey such a combination under terms of your choice, +consistent with the licensing of the Independent Modules. + +2. No Weakening of GCC Copyleft. + +The availability of this Exception does not imply any general +presumption that third-party software is unaffected by the copyleft +requirements of the license of GCC. + + + +LLVM / libc++ (used for some YafaRay builds, typically MacOSX) +-------------------------------------------------------------- +http://llvm.org/docs/DeveloperPolicy.html#license + +License + +We intend to keep LLVM perpetually open source and to use a liberal open source license. As a contributor to the project, you agree that any contributions be licensed under the terms of the corresponding subproject. All of the code in LLVM is available under the University of Illinois/NCSA Open Source License, which boils down to this: + + You can freely distribute LLVM. + You must retain the copyright notice if you redistribute LLVM. + Binaries derived from LLVM must reproduce the copyright notice (e.g. in an included readme file). + You canโ€™t use our names to promote your LLVM derived products. + Thereโ€™s no warranty on LLVM at all. + +We believe this fosters the widest adoption of LLVM because it allows commercial products to be derived from LLVM with few restrictions and without a requirement for making any derived works also open source (i.e. LLVMโ€™s license is not a โ€œcopyleftโ€ license like the GPL). We suggest that you read the License if further clarification is needed. + +In addition to the UIUC license, the runtime library components of LLVM (compiler_rt, libc++, and libclc) are also licensed under the MIT License, which does not contain the binary redistribution clause. As a user of these runtime libraries, it means that you can choose to use the code under either license (and thus donโ€™t need the binary redistribution clause), and as a contributor to the code that you agree that any contributions to these libraries be licensed under both licenses. We feel that this is important for runtime libraries, because they are implicitly linked into applications and therefore should not subject those applications to the binary redistribution clause. This also means that it is ok to move code from (e.g.) libc++ to the LLVM core without concern, but that code cannot be moved from the LLVM core to libc++ without the copyright ownerโ€™s permission. + +Note that the LLVM Project does distribute dragonegg, which is GPL. This means that anything โ€œlinkedโ€ into dragonegg must itself be compatible with the GPL, and must be releasable under the terms of the GPL. This implies that any code linked into dragonegg and distributed to others may be subject to the viral aspects of the GPL (for example, a proprietary code generator linked into dragonegg must be made available under the GPL). This is not a problem for code already distributed under a more liberal license (like the UIUC license), and GPL-containing subprojects are kept in separate SVN repositories whose LICENSE.txt files specifically indicate that they contain GPL code. + +We have no plans to change the license of LLVM. If you have questions or comments about the license, please contact the LLVM Developer's Mailing List. From 94b099f91ef89e7a072c55c86121c6b61f86fdf9 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sun, 26 Jun 2016 07:26:16 +0100 Subject: [PATCH 107/124] Fixed missing image name / link in the text/HTML logs when using yafaray-xml --- src/yafraycore/imageOutput.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/yafraycore/imageOutput.cc b/src/yafraycore/imageOutput.cc index dac19b31..84d7ea32 100755 --- a/src/yafraycore/imageOutput.cc +++ b/src/yafraycore/imageOutput.cc @@ -109,6 +109,7 @@ void imageOutput_t::flush(int numView, const renderPasses_t *renderPasses) if(numView == 0 && idx == 0) { saveImageFile(fname, idx); //default image filename, when not using views nor passes and for reloading into Blender + yafLog.setImagePath(fname); //to show the image in the HTML log output } if(passName != "not found" && (renderPasses->extPassesSize()>=2 || renderPasses->view_names.size() >= 2)) From c0e8258d9d2d8a8686d373b9e7dcfb020ed7134d Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sun, 26 Jun 2016 11:09:04 +0200 Subject: [PATCH 108/124] Changes to allow building in MacOSX, typedef conflict between libtiff and opencv2 headers --- src/image_handlers/tifHandler.cc | 54 +++++++++++++++++--------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/src/image_handlers/tifHandler.cc b/src/image_handlers/tifHandler.cc index a86f980f..fd413ce6 100755 --- a/src/image_handlers/tifHandler.cc +++ b/src/image_handlers/tifHandler.cc @@ -27,7 +27,9 @@ #include #include -#include +namespace libtiff { + #include +} __BEGIN_YAFRAY @@ -127,9 +129,9 @@ bool tifHandler_t::saveToFile(const std::string &name, int imagePassNumber) #if defined(_WIN32) std::wstring wname = utf8_to_wutf16(name); - TIFF *out = TIFFOpenW(wname.c_str(), "w"); //Windows needs the path in UTF16 (unicode) so we have to convert the UTF8 path to UTF16 + libtiff::TIFF *out = libtiff::TIFFOpenW(wname.c_str(), "w"); //Windows needs the path in UTF16 (unicode) so we have to convert the UTF8 path to UTF16 #else - TIFF *out = TIFFOpen(name.c_str(), "w"); + libtiff::TIFF *out = libtiff::TIFFOpen(name.c_str(), "w"); #endif int channels; @@ -138,19 +140,19 @@ bool tifHandler_t::saveToFile(const std::string &name, int imagePassNumber) if(m_hasAlpha) channels = 4; else channels = 3; - TIFFSetField(out, TIFFTAG_IMAGEWIDTH, m_width); - TIFFSetField(out, TIFFTAG_IMAGELENGTH, m_height); - TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, channels); - TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 8); - TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); - TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); - TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); + libtiff::TIFFSetField(out, TIFFTAG_IMAGEWIDTH, m_width); + libtiff::TIFFSetField(out, TIFFTAG_IMAGELENGTH, m_height); + libtiff::TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, channels); + libtiff::TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 8); + libtiff::TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); + libtiff::TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); + libtiff::TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); bytesPerScanline = channels * m_width; - yByte *scanline = (yByte*)_TIFFmalloc(bytesPerScanline); + yByte *scanline = (yByte*)libtiff::_TIFFmalloc(bytesPerScanline); - TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(out, bytesPerScanline)); + libtiff::TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, libtiff::TIFFDefaultStripSize(out, bytesPerScanline)); if(m_Denoise) { @@ -186,11 +188,11 @@ bool tifHandler_t::saveToFile(const std::string &name, int imagePassNumber) if(m_hasAlpha) scanline[ix+3] = (yByte)(col.getA() * 255.f); } - if(TIFFWriteScanline(out, scanline, y, 0) < 0) + if(libtiff::TIFFWriteScanline(out, scanline, y, 0) < 0) { Y_ERROR << handlerName << ": An error occurred while writing TIFF file" << yendl; - TIFFClose(out); - _TIFFfree(scanline); + libtiff::TIFFClose(out); + libtiff::_TIFFfree(scanline); return false; } @@ -214,16 +216,16 @@ bool tifHandler_t::saveToFile(const std::string &name, int imagePassNumber) if(TIFFWriteScanline(out, scanline, y, 0) < 0) { Y_ERROR << handlerName << ": An error occurred while writing TIFF file" << yendl; - TIFFClose(out); - _TIFFfree(scanline); + libtiff::TIFFClose(out); + libtiff::_TIFFfree(scanline); return false; } } } - TIFFClose(out); - _TIFFfree(scanline); + libtiff::TIFFClose(out); + libtiff::_TIFFfree(scanline); Y_VERBOSE << handlerName << ": Done." << yendl; @@ -232,13 +234,13 @@ bool tifHandler_t::saveToFile(const std::string &name, int imagePassNumber) bool tifHandler_t::loadFromFile(const std::string &name) { - uint32 w, h; + libtiff::uint32 w, h; #if defined(_WIN32) std::wstring wname = utf8_to_wutf16(name); - TIFF *tif = TIFFOpenW(wname.c_str(), "r"); //Windows needs the path in UTF16 (unicode) so we have to convert the UTF8 path to UTF16 + libtiff::TIFF *tif = libtiff::TIFFOpenW(wname.c_str(), "r"); //Windows needs the path in UTF16 (unicode) so we have to convert the UTF8 path to UTF16 #else - TIFF *tif = TIFFOpen(name.c_str(), "r"); + libtiff::TIFF *tif = libtiff::TIFFOpen(name.c_str(), "r"); #endif Y_INFO << handlerName << ": Loading image \"" << name << "\"..." << yendl; @@ -247,9 +249,9 @@ bool tifHandler_t::loadFromFile(const std::string &name) TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w); TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h); - uint32 *tiffData = (uint32*)_TIFFmalloc(w * h * sizeof(uint32)); + libtiff::uint32 *tiffData = (libtiff::uint32*)libtiff::_TIFFmalloc(w * h * sizeof(libtiff::uint32)); - if(!TIFFReadRGBAImage(tif, w, h, tiffData, 0)) + if(!libtiff::TIFFReadRGBAImage(tif, w, h, tiffData, 0)) { Y_ERROR << handlerName << ": Error reading TIFF file" << yendl; return false; @@ -293,9 +295,9 @@ bool tifHandler_t::loadFromFile(const std::string &name) } } - _TIFFfree(tiffData); + libtiff::_TIFFfree(tiffData); - TIFFClose(tif); + libtiff::TIFFClose(tif); Y_VERBOSE << handlerName << ": Done." << yendl; From 0abbf6f5a2427ba6dff68da9ed0f3eb130e8c31e Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sun, 3 Jul 2016 12:12:50 +0200 Subject: [PATCH 109/124] World Background: SmartIBL As requested in http://yafaray.org/node/566 and http://yafaray.org/node/727 When using IBL we typically suffer from fireflies caused by random sampling getting sometimes samples from the (very bright) sun. It has been suggested to use the SmartIBL technique, blurring the World Texture to reduce fireflies. However that also blurs reflections, which is a no-no. I've implemented SmartIBL by adding a new Blur parameter to the World IBL. This only works with Image Textures. This blur parameter only affects the lighting, but not the reflections, etc. The higher the value, the less noise. However higher values will also cause slowdown in the initial blurring process and the scene lighting will not be as realistic. So, use with care! --- include/core_api/background.h | 4 +- include/core_api/texture.h | 10 +- include/textures/basictex.h | 16 ++-- include/textures/imagetex.h | 14 ++- src/backgrounds/darksky.cc | 8 +- src/backgrounds/gradientback.cc | 8 +- src/backgrounds/sunsky.cc | 8 +- src/backgrounds/textureback.cc | 41 ++++++--- src/integrators/SkyIntegrator.cc | 2 +- src/integrators/bidirpath.cc | 2 +- src/integrators/directlight.cc | 2 +- src/integrators/pathtracer.cc | 4 +- src/integrators/photonintegr.cc | 4 +- src/integrators/sppm.cc | 2 +- src/lights/bglight.cc | 12 +-- src/lights/bgportallight.cc | 10 +- src/textures/CMakeLists.txt | 2 +- src/textures/basictex.cc | 16 ++-- src/textures/imagetex.cc | 152 +++++++++++++++++++++++++------ 19 files changed, 216 insertions(+), 101 deletions(-) diff --git a/include/core_api/background.h b/include/core_api/background.h index d6b7eaaf..0f00a9e4 100755 --- a/include/core_api/background.h +++ b/include/core_api/background.h @@ -15,8 +15,8 @@ class YAFRAYCORE_EXPORT background_t { public: //! get the background color for a given ray - virtual color_t operator() (const ray_t &ray, renderState_t &state, bool filtered=false) const=0; - virtual color_t eval(const ray_t &ray, bool filtered=false) const=0; + virtual color_t operator() (const ray_t &ray, renderState_t &state, bool from_postprocessed=false) const=0; + virtual color_t eval(const ray_t &ray, bool from_postprocessed=false) const=0; /*! get the light source representing background lighting. \return the light source that reproduces background lighting, or nullptr if background shall only be sampled from BSDFs diff --git a/include/core_api/texture.h b/include/core_api/texture.h index 7e652b8f..6376bc9b 100755 --- a/include/core_api/texture.h +++ b/include/core_api/texture.h @@ -15,15 +15,17 @@ class YAFRAYCORE_EXPORT texture_t z for discrete textures) are unused on getColor and getFloat calls */ virtual bool isThreeD() const { return true; } virtual bool isNormalmap() const { return false; } - virtual colorA_t getColor(const point3d_t &p) const = 0; - virtual colorA_t getColor(int x, int y, int z) const { return colorA_t(0.f); } - virtual colorA_t getRawColor(const point3d_t &p) const { return getColor(p); } - virtual colorA_t getRawColor(int x, int y, int z) const { return getColor(x, y, z); } + virtual colorA_t getColor(const point3d_t &p, bool from_postprocessed=false) const = 0; + virtual colorA_t getColor(int x, int y, int z, bool from_postprocessed=false) const { return colorA_t(0.f); } + virtual colorA_t getRawColor(const point3d_t &p, bool from_postprocessed=false) const { return getColor(p, from_postprocessed); } + virtual colorA_t getRawColor(int x, int y, int z, bool from_postprocessed=false) const { return getColor(x, y, z, from_postprocessed); } virtual float getFloat(const point3d_t &p) const { return getRawColor(p).col2bri(); } virtual float getFloat(int x, int y, int z) const { return getRawColor(x, y, z).col2bri(); } /* gives the number of values in each dimension for discrete textures */ virtual void resolution(int &x, int &y, int &z) const { x=0, y=0, z=0; } virtual void getInterpolationStep(float &step) const { step = 0.f; }; + virtual void postProcessedCreate() { }; + virtual void postProcessedBlur(float blur_factor) { }; virtual ~texture_t() {} }; diff --git a/include/textures/basictex.h b/include/textures/basictex.h index 8551d08e..dfd3151e 100755 --- a/include/textures/basictex.h +++ b/include/textures/basictex.h @@ -15,7 +15,7 @@ class textureClouds_t : public texture_t const color_t &c1, const color_t &c2, const std::string &ntype, const std::string &btype); virtual ~textureClouds_t(); - virtual colorA_t getColor(const point3d_t &p) const; + virtual colorA_t getColor(const point3d_t &p, bool from_postprocessed=false) const; virtual float getFloat(const point3d_t &p) const; virtual void getInterpolationStep(float &step) const { step = size; }; @@ -43,7 +43,7 @@ class textureMarble_t : public texture_t } } - virtual colorA_t getColor(const point3d_t &p) const; + virtual colorA_t getColor(const point3d_t &p, bool from_postprocessed=false) const; virtual float getFloat(const point3d_t &p) const; virtual void getInterpolationStep(float &step) const { step = size; }; @@ -71,7 +71,7 @@ class textureWood_t : public texture_t } } - virtual colorA_t getColor(const point3d_t &p) const; + virtual colorA_t getColor(const point3d_t &p, bool from_postprocessed=false) const; virtual float getFloat(const point3d_t &p) const; virtual void getInterpolationStep(float &step) const { step = size; }; @@ -96,7 +96,7 @@ class textureVoronoi_t : public texture_t float isc, const std::string &dname); virtual ~textureVoronoi_t() {} - virtual colorA_t getColor(const point3d_t &p) const; + virtual colorA_t getColor(const point3d_t &p, bool from_postprocessed=false) const; virtual float getFloat(const point3d_t &p) const; virtual void getInterpolationStep(float &step) const { step = size; }; @@ -121,7 +121,7 @@ class textureMusgrave_t : public texture_t const std::string &ntype, const std::string &mtype); virtual ~textureMusgrave_t(); - virtual colorA_t getColor(const point3d_t &p) const; + virtual colorA_t getColor(const point3d_t &p, bool from_postprocessed=false) const; virtual float getFloat(const point3d_t &p) const; virtual void getInterpolationStep(float &step) const { step = size; }; @@ -143,7 +143,7 @@ class textureDistortedNoise_t : public texture_t const std::string &noiseb1, const std::string noiseb2); virtual ~textureDistortedNoise_t(); - virtual colorA_t getColor(const point3d_t &p) const; + virtual colorA_t getColor(const point3d_t &p, bool from_postprocessed=false) const; virtual float getFloat(const point3d_t &p) const; virtual void getInterpolationStep(float &step) const { step = size; }; @@ -164,7 +164,7 @@ class rgbCube_t : public texture_t { public: rgbCube_t(){} - virtual colorA_t getColor(const point3d_t &p) const; + virtual colorA_t getColor(const point3d_t &p, bool from_postprocessed=false) const; virtual float getFloat(const point3d_t &p) const; static texture_t *factory(paraMap_t ¶ms,renderEnvironment_t &render); @@ -177,7 +177,7 @@ class textureBlend_t : public texture_t textureBlend_t(const std::string &stype); virtual ~textureBlend_t(); - virtual colorA_t getColor(const point3d_t &p) const; + virtual colorA_t getColor(const point3d_t &p, bool from_postprocessed=false) const; virtual float getFloat(const point3d_t &p) const; static texture_t *factory(paraMap_t ¶ms, renderEnvironment_t &render); diff --git a/include/textures/imagetex.h b/include/textures/imagetex.h index 56c9d788..7363e548 100755 --- a/include/textures/imagetex.h +++ b/include/textures/imagetex.h @@ -27,6 +27,7 @@ #include #include #include +#include __BEGIN_YAFRAY @@ -54,17 +55,19 @@ class textureImage_t : public texture_t virtual bool discrete() const { return true; } virtual bool isThreeD() const { return false; } virtual bool isNormalmap() const { return normalmap; } - virtual colorA_t getColor(const point3d_t &sp) const; - virtual colorA_t getColor(int x, int y, int z) const; - virtual colorA_t getRawColor(const point3d_t &p) const; - virtual colorA_t getRawColor(int x, int y, int z) const; + virtual colorA_t getColor(const point3d_t &sp, bool from_postprocessed=false) const; + virtual colorA_t getColor(int x, int y, int z, bool from_postprocessed=false) const; + virtual colorA_t getRawColor(const point3d_t &p, bool from_postprocessed=false) const; + virtual colorA_t getRawColor(int x, int y, int z, bool from_postprocessed=false) const; virtual void resolution(int &x, int &y, int &z) const; + virtual void postProcessedCreate(); + virtual void postProcessedBlur(float blur_factor); static texture_t *factory(paraMap_t ¶ms,renderEnvironment_t &render); protected: void setCrop(float minx, float miny, float maxx, float maxy); bool doMapping(point3d_t &texp) const; - colorA_t interpolateImage(const point3d_t &p) const; + colorA_t interpolateImage(const point3d_t &p, bool from_postprocessed=false) const; bool use_alpha, calc_alpha, normalmap; bool cropx, cropy, checker_odd, checker_even, rot90; @@ -78,6 +81,7 @@ class textureImage_t : public texture_t float gamma; bool mirrorX; bool mirrorY; + rgba2DImage_nw_t * postProcessedImage = nullptr; //!< rgba color buffer for post-processed image (not linear, still in the original image color space) }; /*static inline colorA_t cubicInterpolate(const colorA_t &c1, const colorA_t &c2, diff --git a/src/backgrounds/darksky.cc b/src/backgrounds/darksky.cc index c876ee63..ad877323 100755 --- a/src/backgrounds/darksky.cc +++ b/src/backgrounds/darksky.cc @@ -32,8 +32,8 @@ class darkSkyBackground_t: public background_t public: darkSkyBackground_t(const point3d_t dir, float turb, float pwr, float skyBright, bool clamp, float av, float bv, float cv, float dv, float ev, float altitude, bool night, float exp, bool genc, ColorSpaces cs, bool ibl, bool shoot_caustics); - virtual color_t operator() (const ray_t &ray, renderState_t &state, bool filtered=false) const; - virtual color_t eval(const ray_t &ray, bool filtered=false) const; + virtual color_t operator() (const ray_t &ray, renderState_t &state, bool from_postprocessed=false) const; + virtual color_t eval(const ray_t &ray, bool from_postprocessed=false) const; virtual ~darkSkyBackground_t(); static background_t *factory(paraMap_t &,renderEnvironment_t &); bool hasIBL() { return withIBL; } @@ -240,13 +240,13 @@ inline color_t darkSkyBackground_t::getSkyCol(const ray_t &ray) const return skyCol * skyBrightness; } -color_t darkSkyBackground_t::operator() (const ray_t &ray, renderState_t &state, bool filtered) const +color_t darkSkyBackground_t::operator() (const ray_t &ray, renderState_t &state, bool from_postprocessed) const { color_t ret = getSkyCol(ray); return ret; } -color_t darkSkyBackground_t::eval(const ray_t &ray, bool filtered) const +color_t darkSkyBackground_t::eval(const ray_t &ray, bool from_postprocessed) const { color_t ret = getSkyCol(ray) * power; return ret; diff --git a/src/backgrounds/gradientback.cc b/src/backgrounds/gradientback.cc index bc84416f..54f0d924 100755 --- a/src/backgrounds/gradientback.cc +++ b/src/backgrounds/gradientback.cc @@ -32,8 +32,8 @@ class gradientBackground_t: public background_t { public: gradientBackground_t(color_t gzcol, color_t ghcol, color_t szcol, color_t shcol, bool ibl, bool shoot_caustics); - virtual color_t operator() (const ray_t &ray, renderState_t &state, bool filtered=false) const; - virtual color_t eval(const ray_t &ray, bool filtered=false) const; + virtual color_t operator() (const ray_t &ray, renderState_t &state, bool from_postprocessed=false) const; + virtual color_t eval(const ray_t &ray, bool from_postprocessed=false) const; virtual ~gradientBackground_t(); static background_t *factory(paraMap_t &,renderEnvironment_t &); bool hasIBL() { return withIBL; } @@ -56,12 +56,12 @@ gradientBackground_t::~gradientBackground_t() // Empty } -color_t gradientBackground_t::operator() (const ray_t &ray, renderState_t &state, bool filtered) const +color_t gradientBackground_t::operator() (const ray_t &ray, renderState_t &state, bool from_postprocessed) const { return eval(ray); } -color_t gradientBackground_t::eval(const ray_t &ray, bool filtered) const +color_t gradientBackground_t::eval(const ray_t &ray, bool from_postprocessed) const { color_t color; diff --git a/src/backgrounds/sunsky.cc b/src/backgrounds/sunsky.cc index 0a06dda1..8757a5e4 100755 --- a/src/backgrounds/sunsky.cc +++ b/src/backgrounds/sunsky.cc @@ -39,8 +39,8 @@ class sunskyBackground_t: public background_t { public: sunskyBackground_t(const point3d_t dir, float turb, float a_var, float b_var, float c_var, float d_var, float e_var, float pwr, bool ibl, bool shoot_caustics); - virtual color_t operator() (const ray_t &ray, renderState_t &state, bool filtered=false) const; - virtual color_t eval(const ray_t &ray, bool filtered=false) const; + virtual color_t operator() (const ray_t &ray, renderState_t &state, bool from_postprocessed=false) const; + virtual color_t eval(const ray_t &ray, bool from_postprocessed=false) const; virtual ~sunskyBackground_t(); static background_t *factory(paraMap_t &,renderEnvironment_t &); bool hasIBL() { return withIBL; } @@ -192,12 +192,12 @@ inline color_t sunskyBackground_t::getSkyCol(const ray_t &ray) const return skycolor; } -color_t sunskyBackground_t::operator() (const ray_t &ray, renderState_t &state, bool filtered) const +color_t sunskyBackground_t::operator() (const ray_t &ray, renderState_t &state, bool from_postprocessed) const { return power * getSkyCol(ray); } -color_t sunskyBackground_t::eval(const ray_t &ray, bool filtered) const +color_t sunskyBackground_t::eval(const ray_t &ray, bool from_postprocessed) const { return power * getSkyCol(ray); } diff --git a/src/backgrounds/textureback.cc b/src/backgrounds/textureback.cc index 6d74faf5..42b5b51c 100755 --- a/src/backgrounds/textureback.cc +++ b/src/backgrounds/textureback.cc @@ -40,9 +40,9 @@ class textureBackground_t: public background_t angular }; - textureBackground_t(const texture_t *texture, PROJECTION proj, float bpower, float rot, bool ibl, bool shoot_caustics); - virtual color_t operator() (const ray_t &ray, renderState_t &state, bool filtered=false) const; - virtual color_t eval(const ray_t &ray, bool filtered=false) const; + textureBackground_t(const texture_t *texture, PROJECTION proj, float bpower, float rot, bool ibl, float ibl_blur, bool shoot_caustics); + virtual color_t operator() (const ray_t &ray, renderState_t &state, bool from_postprocessed=false) const; + virtual color_t eval(const ray_t &ray, bool from_postprocessed=false) const; virtual ~textureBackground_t(); static background_t *factory(paraMap_t &,renderEnvironment_t &); bool hasIBL() { return withIBL; } @@ -55,6 +55,7 @@ class textureBackground_t: public background_t float rotation; float sin_r, cos_r; bool withIBL; + float IBL_Blur; bool shootCaustic; bool shootDiffuse; }; @@ -63,8 +64,8 @@ class constBackground_t: public background_t { public: constBackground_t(color_t col, bool ibl, bool shoot_caustics); - virtual color_t operator() (const ray_t &ray, renderState_t &state, bool filtered=false) const; - virtual color_t eval(const ray_t &ray, bool filtered=false) const; + virtual color_t operator() (const ray_t &ray, renderState_t &state, bool from_postprocessed=false) const; + virtual color_t eval(const ray_t &ray, bool from_postprocessed=false) const; virtual ~constBackground_t(); static background_t *factory(paraMap_t ¶ms,renderEnvironment_t &render); bool hasIBL() { return withIBL; } @@ -77,8 +78,8 @@ class constBackground_t: public background_t }; -textureBackground_t::textureBackground_t(const texture_t *texture, PROJECTION proj, float bpower, float rot, bool ibl, bool shoot_caustics): - tex(texture), project(proj), power(bpower), withIBL(ibl), shootCaustic(shoot_caustics) +textureBackground_t::textureBackground_t(const texture_t *texture, PROJECTION proj, float bpower, float rot, bool ibl, float ibl_blur, bool shoot_caustics): + tex(texture), project(proj), power(bpower), withIBL(ibl), IBL_Blur(ibl_blur), shootCaustic(shoot_caustics) { rotation = 2.0f * rot / 360.f; sin_r = fSin(M_PI*rotation); @@ -90,12 +91,12 @@ textureBackground_t::~textureBackground_t() // Empty } -color_t textureBackground_t::operator() (const ray_t &ray, renderState_t &state, bool filtered) const +color_t textureBackground_t::operator() (const ray_t &ray, renderState_t &state, bool from_postprocessed) const { - return eval(ray); + return eval(ray, from_postprocessed); } -color_t textureBackground_t::eval(const ray_t &ray, bool filtered) const +color_t textureBackground_t::eval(const ray_t &ray, bool from_postprocessed) const { float u = 0.f, v = 0.f; @@ -116,7 +117,7 @@ color_t textureBackground_t::eval(const ray_t &ray, bool filtered) const if (u > 1.f) u -= 2.f; } - color_t ret = tex->getColor(point3d_t(u, v, 0.f)); + color_t ret = tex->getColor(point3d_t(u, v, 0.f), from_postprocessed); float minComponent = 1.0e-5f; @@ -129,12 +130,13 @@ color_t textureBackground_t::eval(const ray_t &ray, bool filtered) const background_t* textureBackground_t::factory(paraMap_t ¶ms,renderEnvironment_t &render) { - const texture_t *tex=nullptr; + texture_t *tex=nullptr; const std::string *texname=nullptr; const std::string *mapping=nullptr; PROJECTION pr = spherical; float power = 1.0, rot=0.0; bool IBL = false; + float IBL_blur = 0.f; int IBL_sam = 16; bool caust = true; bool diffuse = true; @@ -156,6 +158,7 @@ background_t* textureBackground_t::factory(paraMap_t ¶ms,renderEnvironment_t if(*mapping == "probe" || *mapping == "angular") pr = angular; } params.getParam("ibl", IBL); + params.getParam("smartibl_blur", IBL_blur); params.getParam("ibl_samples", IBL_sam); params.getParam("power", power); params.getParam("rotation", rot); @@ -163,7 +166,7 @@ background_t* textureBackground_t::factory(paraMap_t ¶ms,renderEnvironment_t params.getParam("shoot_diffuse", diffuse); params.getParam("cast_shadows", castShadows); - background_t *texBG = new textureBackground_t(tex, pr, power, rot, IBL, caust); + background_t *texBG = new textureBackground_t(tex, pr, power, rot, IBL, IBL_blur, caust); if(IBL) { @@ -174,6 +177,14 @@ background_t* textureBackground_t::factory(paraMap_t ¶ms,renderEnvironment_t bgp["shoot_diffuse"] = diffuse; bgp["abs_intersect"] = false; //this used to be (pr == angular); but that caused the IBL light to be in the wrong place (see http://www.yafaray.org/node/714) I don't understand why this was set that way, we should keep an eye on this. bgp["cast_shadows"] = castShadows; + + if(IBL_blur > 0.f) + { + Y_INFO << "TextureBackground: starting background SmartIBL blurring with IBL Blur factor=" << IBL_blur << yendl; + tex->postProcessedCreate(); + tex->postProcessedBlur(IBL_blur); + Y_VERBOSE << "TextureBackground: background SmartIBL blurring done." << yendl; + } light_t *bglight = render.createLight("textureBackground_bgLight", bgp); @@ -198,12 +209,12 @@ constBackground_t::~constBackground_t() // Empty } -color_t constBackground_t::operator() (const ray_t &ray, renderState_t &state, bool filtered) const +color_t constBackground_t::operator() (const ray_t &ray, renderState_t &state, bool from_postprocessed) const { return color; } -color_t constBackground_t::eval(const ray_t &ray, bool filtered) const +color_t constBackground_t::eval(const ray_t &ray, bool from_postprocessed) const { return color; } diff --git a/src/integrators/SkyIntegrator.cc b/src/integrators/SkyIntegrator.cc index 2463488d..02a40031 100755 --- a/src/integrators/SkyIntegrator.cc +++ b/src/integrators/SkyIntegrator.cc @@ -178,7 +178,7 @@ class YAFRAYPLUGIN_EXPORT SkyIntegrator : public volumeIntegrator_t { float y = sin(theta) * sin(phi); vector3d_t w(x, y, z); ray_t bgray(point3d_t(0, 0, 0), w, 0, 1, 0); - color_t L_s = background->eval(bgray, false); + color_t L_s = background->eval(bgray); float b_r_angular = b_r * 3 / (2 * M_PI * 8) * (1.0f + (w * (-ray.dir)) * (w * (-ray.dir))); float K = 0.67f; float angle = fAcos(w * (ray.dir)); diff --git a/src/integrators/bidirpath.cc b/src/integrators/bidirpath.cc index 7a3b2d50..52179140 100755 --- a/src/integrators/bidirpath.cc +++ b/src/integrators/bidirpath.cc @@ -447,7 +447,7 @@ colorA_t biDirIntegrator_t::integrate(renderState_t &state, diffRay_t &ray, colo { if(background && !transpRefractedBackground) { - col += colorPasses.probe_set(PASS_INT_ENV, (*background)(ray, state, false), state.raylevel == 0); + col += colorPasses.probe_set(PASS_INT_ENV, (*background)(ray, state), state.raylevel == 0); } } diff --git a/src/integrators/directlight.cc b/src/integrators/directlight.cc index d73572c9..22cc9ccf 100755 --- a/src/integrators/directlight.cc +++ b/src/integrators/directlight.cc @@ -185,7 +185,7 @@ colorA_t directLighting_t::integrate(renderState_t &state, diffRay_t &ray, color { if(background && !transpRefractedBackground) { - col += colorPasses.probe_set(PASS_INT_ENV, (*background)(ray, state, false), state.raylevel == 0); + col += colorPasses.probe_set(PASS_INT_ENV, (*background)(ray, state), state.raylevel == 0); } } diff --git a/src/integrators/pathtracer.cc b/src/integrators/pathtracer.cc index 783e1ccc..2f6a147a 100755 --- a/src/integrators/pathtracer.cc +++ b/src/integrators/pathtracer.cc @@ -282,7 +282,7 @@ colorA_t pathIntegrator_t::integrate(renderState_t &state, diffRay_t &ray, color { if((caustic && background && background->hasIBL() && background->shootsCaustic())) { - pathCol += throughput * (*background)(pRay, state); + pathCol += throughput * (*background)(pRay, state, true); } break; } @@ -340,7 +340,7 @@ colorA_t pathIntegrator_t::integrate(renderState_t &state, diffRay_t &ray, color { if(background && !transpRefractedBackground) { - col += colorPasses.probe_set(PASS_INT_ENV, (*background)(ray, state, false), state.raylevel == 0); + col += colorPasses.probe_set(PASS_INT_ENV, (*background)(ray, state), state.raylevel == 0); } } diff --git a/src/integrators/photonintegr.cc b/src/integrators/photonintegr.cc index 2bb97ba5..040fb6c9 100755 --- a/src/integrators/photonintegr.cc +++ b/src/integrators/photonintegr.cc @@ -1229,7 +1229,7 @@ color_t photonIntegrator_t::finalGathering(renderState_t &state, const surfacePo { if(caustic && background && background->hasIBL() && background->shootsCaustic()) { - pathCol += throughput * (*background)(pRay, state); + pathCol += throughput * (*background)(pRay, state, true); } break; } @@ -1417,7 +1417,7 @@ colorA_t photonIntegrator_t::integrate(renderState_t &state, diffRay_t &ray, col { if(background && !transpRefractedBackground) { - col += colorPasses.probe_set(PASS_INT_ENV, (*background)(ray, state, false), state.raylevel == 0); + col += colorPasses.probe_set(PASS_INT_ENV, (*background)(ray, state), state.raylevel == 0); } } diff --git a/src/integrators/sppm.cc b/src/integrators/sppm.cc index 1e278162..daff0872 100755 --- a/src/integrators/sppm.cc +++ b/src/integrators/sppm.cc @@ -1296,7 +1296,7 @@ GatherInfo SPPM::traceGatherRay(yafaray::renderState_t &state, yafaray::diffRay_ { if(background && !transpRefractedBackground) { - gInfo.constantRandiance += colorPasses.probe_set(PASS_INT_ENV, (*background)(ray, state, false), state.raylevel == 0); + gInfo.constantRandiance += colorPasses.probe_set(PASS_INT_ENV, (*background)(ray, state), state.raylevel == 0); } } diff --git a/src/lights/bglight.cc b/src/lights/bglight.cc index 2960d664..46b0781b 100755 --- a/src/lights/bglight.cc +++ b/src/lights/bglight.cc @@ -102,7 +102,7 @@ void bgLight_t::init(scene_t &scene) invSpheremap(fx, fy, ray.dir); - fu[x] = background->eval(ray).energy() * sintheta; + fu[x] = background->eval(ray, true).energy() * sintheta; } uDist[y] = new pdf1D_t(fu, nu); @@ -191,7 +191,7 @@ bool bgLight_t::illumSample(const surfacePoint_t &sp, lSample_t &s, ray_t &wi) c invSpheremap(u, v, wi.dir); - s.col = background->eval(wi); + s.col = background->eval(wi, true); return true; } @@ -208,14 +208,14 @@ bool bgLight_t::intersect(const ray_t &ray, float &t, color_t &col, float &ipdf) invSpheremap(u, v, tr.dir); - col = background->eval(tr); + col = background->eval(tr, true); return true; } color_t bgLight_t::totalEnergy() const { - color_t energy = background->eval(ray_t(point3d_t(0,0,0), vector3d_t(0.5, 0.5, 0.5))) * worldPIFactor; + color_t energy = background->eval(ray_t(point3d_t(0,0,0), vector3d_t(0.5, 0.5, 0.5)), true) * worldPIFactor; return energy; } @@ -228,7 +228,7 @@ color_t bgLight_t::emitPhoton(float s1, float s2, float s3, float s4, ray_t &ray sample_dir(s3, s4, ray.dir, ipdf, true); - pcol = background->eval(ray); + pcol = background->eval(ray, true); ray.dir = -ray.dir; createCS(ray.dir, U, V); @@ -250,7 +250,7 @@ color_t bgLight_t::emitSample(vector3d_t &wo, lSample_t &s) const sample_dir(s.s1, s.s2, wo, s.dirPdf, true); - pcol = background->eval(ray_t(point3d_t(0,0,0), wo)); + pcol = background->eval(ray_t(point3d_t(0,0,0), wo), true); wo = -wo; createCS(wo, U, V); diff --git a/src/lights/bgportallight.cc b/src/lights/bgportallight.cc index fc1a9a25..48fb1142 100755 --- a/src/lights/bgportallight.cc +++ b/src/lights/bgportallight.cc @@ -120,7 +120,7 @@ color_t bgPortalLight_t::totalEnergy() const for(int i=0; i<1000; ++i) //exaggerated? { wo.dir = SampleSphere( ((float)i+0.5f)/1000.f, RI_vdC(i) ); - col = bg->eval(wo); + col = bg->eval(wo, true); for(int j=0; jgetNormal(); //not 100% sure about sign yet... @@ -153,7 +153,7 @@ bool bgPortalLight_t::illumSample(const surfacePoint_t &sp, lSample_t &s, ray_t wi.tmax = dist; wi.dir = ldir; - s.col = bg->eval(wi) * power; + s.col = bg->eval(wi, true) * power; // pdf = distance^2 / area * cos(norm, ldir); s.pdf = dist_sqr*M_PI / (area * cos_angle); s.flags = flags; @@ -174,7 +174,7 @@ color_t bgPortalLight_t::emitPhoton(float s1, float s2, float s3, float s4, ray_ ray.dir = SampleCosHemisphere(normal, du, dv, s1, s2); ray_t r2(ray.from, -ray.dir); - return bg->eval(r2); + return bg->eval(r2, true); } color_t bgPortalLight_t::emitSample(vector3d_t &wo, lSample_t &s) const @@ -190,7 +190,7 @@ color_t bgPortalLight_t::emitSample(vector3d_t &wo, lSample_t &s) const s.flags = flags; ray_t r2(s.sp->P, -wo); - return bg->eval(r2); + return bg->eval(r2, true); } bool bgPortalLight_t::intersect(const ray_t &ray, float &t, color_t &col, float &ipdf) const @@ -209,7 +209,7 @@ bool bgPortalLight_t::intersect(const ray_t &ray, float &t, color_t &col, float if(cos_angle <= 0) return false; float idist_sqr = 1.f / (t*t); ipdf = idist_sqr * area * cos_angle * (1.f/M_PI); - col = bg->eval(ray) * power; + col = bg->eval(ray, true) * power; return true; } diff --git a/src/textures/CMakeLists.txt b/src/textures/CMakeLists.txt index 28798ca0..3261cf40 100755 --- a/src/textures/CMakeLists.txt +++ b/src/textures/CMakeLists.txt @@ -4,7 +4,7 @@ add_definitions(-DBUILDING_YAFRAYPLUGIN) set(basictex_SRCS basictex.cc noise.cc imagetex.cc) add_library(basictex SHARED ${basictex_SRCS}) -target_link_libraries(basictex yafaray_v3_core) +target_link_libraries(basictex yafaray_v3_core ${OpenCV_LIBRARIES}) add_library(basicnodes SHARED basicnodes.cc layernode.cc) target_link_libraries(basicnodes yafaray_v3_core) diff --git a/src/textures/basictex.cc b/src/textures/basictex.cc index bf5ee7c3..61574f71 100755 --- a/src/textures/basictex.cc +++ b/src/textures/basictex.cc @@ -63,7 +63,7 @@ float textureClouds_t::getFloat(const point3d_t &p) const return v; } -colorA_t textureClouds_t::getColor(const point3d_t &p) const +colorA_t textureClouds_t::getColor(const point3d_t &p, bool from_postprocessed) const { return color1 + getFloat(p)*(color2 - color1); } @@ -123,7 +123,7 @@ float textureMarble_t::getFloat(const point3d_t &p) const return fPow(w, sharpness); } -colorA_t textureMarble_t::getColor(const point3d_t &p) const +colorA_t textureMarble_t::getColor(const point3d_t &p, bool from_postprocessed) const { return color1 + getFloat(p)*(color2 - color1); } @@ -189,7 +189,7 @@ float textureWood_t::getFloat(const point3d_t &p) const return w; } -colorA_t textureWood_t::getColor(const point3d_t &p) const +colorA_t textureWood_t::getColor(const point3d_t &p, bool from_postprocessed) const { return color1 + getFloat(p)*(color2 - color1); } @@ -223,7 +223,7 @@ texture_t *textureWood_t::factory(paraMap_t ¶ms, /* even simpler RGB cube, goes r in x, g in y and b in z inside the unit cube. */ //----------------------------------------------------------------------------------------- -colorA_t rgbCube_t::getColor(const point3d_t &p) const +colorA_t rgbCube_t::getColor(const point3d_t &p, bool from_postprocessed) const { colorA_t col = colorA_t(p.x, p.y, p.z); col.clampRGB01(); @@ -286,7 +286,7 @@ float textureVoronoi_t::getFloat(const point3d_t &p) const + w3*vGen.getDistance(2, da) + w4*vGen.getDistance(3, da)); } -colorA_t textureVoronoi_t::getColor(const point3d_t &p) const +colorA_t textureVoronoi_t::getColor(const point3d_t &p, bool from_postprocessed) const { float da[4]; point3d_t pa[4]; @@ -384,7 +384,7 @@ float textureMusgrave_t::getFloat(const point3d_t &p) const return iscale * (*mGen)(p*size); } -colorA_t textureMusgrave_t::getColor(const point3d_t &p) const +colorA_t textureMusgrave_t::getColor(const point3d_t &p, bool from_postprocessed) const { return color1 + getFloat(p)*(color2 - color1); } @@ -447,7 +447,7 @@ float textureDistortedNoise_t::getFloat(const point3d_t &p) const return getSignedNoise(nGen2, tp+rv*distort); // distorted-domain noise } -colorA_t textureDistortedNoise_t::getColor(const point3d_t &p) const +colorA_t textureDistortedNoise_t::getColor(const point3d_t &p, bool from_postprocessed) const { return color1 + getFloat(p)*(color2 - color1); } @@ -495,7 +495,7 @@ float textureBlend_t::getFloat(const point3d_t &p) const return blend; } -colorA_t textureBlend_t::getColor(const point3d_t &p) const +colorA_t textureBlend_t::getColor(const point3d_t &p, bool from_postprocessed) const { // TODO: colorband return colorA_t(1.0,1.0,1.0,1.0); diff --git a/src/textures/imagetex.cc b/src/textures/imagetex.cc index 36c9a60a..6ca26144 100755 --- a/src/textures/imagetex.cc +++ b/src/textures/imagetex.cc @@ -34,6 +34,12 @@ textureImage_t::textureImage_t(imageHandler_t *ih, interpolationType intp, float textureImage_t::~textureImage_t() { + if(postProcessedImage) + { + delete postProcessedImage; + postProcessedImage = nullptr; + } + // Here we simply clear the pointer, yafaray's core will handle the memory cleanup image = nullptr; } @@ -45,7 +51,7 @@ void textureImage_t::resolution(int &x, int &y, int &z) const z=0; } -colorA_t textureImage_t::interpolateImage(const point3d_t &p) const +colorA_t textureImage_t::interpolateImage(const point3d_t &p, bool from_postprocessed) const { int x, y, x2, y2; @@ -64,7 +70,9 @@ colorA_t textureImage_t::interpolateImage(const point3d_t &p) const x = std::max(0, std::min(resx-1, (int)xf)); y = std::max(0, std::min(resy-1, (int)yf)); - colorA_t c1 = image->getPixel(x, y); + colorA_t c1; + if(from_postprocessed && postProcessedImage) c1 = (*postProcessedImage)(x, y); + else c1 = image->getPixel(x, y); if (intp_type == INTP_NONE) return c1; @@ -72,10 +80,19 @@ colorA_t textureImage_t::interpolateImage(const point3d_t &p) const x2 = std::min(resx-1, x+1); y2 = std::min(resy-1, y+1); - - c2 = image->getPixel(x2, y); - c3 = image->getPixel(x, y2); - c4 = image->getPixel(x2, y2); + + if(from_postprocessed && postProcessedImage) + { + c2 = (*postProcessedImage)(x2, y); + c3 = (*postProcessedImage)(x, y2); + c4 = (*postProcessedImage)(x2, y2); + } + else + { + c2 = image->getPixel(x2, y); + c3 = image->getPixel(x, y2); + c4 = image->getPixel(x2, y2); + } float dx = xf - floor(xf); float dy = yf - floor(yf); @@ -97,19 +114,37 @@ colorA_t textureImage_t::interpolateImage(const point3d_t &p) const int y0 = std::max(0, y-1); int y3 = std::min(resy-1, y2+1); - c0 = image->getPixel(x0, y0); - c5 = image->getPixel(x, y0); - c6 = image->getPixel(x2, y0); - c7 = image->getPixel(x3, y0); - c8 = image->getPixel(x0, y); - c9 = image->getPixel(x3, y); - cA = image->getPixel(x0, y2); - cB = image->getPixel(x3, y2); - cC = image->getPixel(x0, y3); - cD = image->getPixel(x, y3); - cE = image->getPixel(x2, y3); - cF = image->getPixel(x3, y3); - + if(from_postprocessed && postProcessedImage) + { + c0 = (*postProcessedImage)(x0, y0); + c5 = (*postProcessedImage)(x, y0); + c6 = (*postProcessedImage)(x2, y0); + c7 = (*postProcessedImage)(x3, y0); + c8 = (*postProcessedImage)(x0, y); + c9 = (*postProcessedImage)(x3, y); + cA = (*postProcessedImage)(x0, y2); + cB = (*postProcessedImage)(x3, y2); + cC = (*postProcessedImage)(x0, y3); + cD = (*postProcessedImage)(x, y3); + cE = (*postProcessedImage)(x2, y3); + cF = (*postProcessedImage)(x3, y3); + } + else + { + c0 = image->getPixel(x0, y0); + c5 = image->getPixel(x, y0); + c6 = image->getPixel(x2, y0); + c7 = image->getPixel(x3, y0); + c8 = image->getPixel(x0, y); + c9 = image->getPixel(x3, y); + cA = image->getPixel(x0, y2); + cB = image->getPixel(x3, y2); + cC = image->getPixel(x0, y3); + cD = image->getPixel(x, y3); + cE = image->getPixel(x2, y3); + cF = image->getPixel(x3, y3); + } + c0 = CubicInterpolate(c0, c5, c6, c7, dx); c8 = CubicInterpolate(c8, c1, c2, c9, dx); cA = CubicInterpolate(cA, c3, c4, cB, dx); @@ -120,14 +155,14 @@ colorA_t textureImage_t::interpolateImage(const point3d_t &p) const return c0; } -colorA_t textureImage_t::getColor(const point3d_t &p) const +colorA_t textureImage_t::getColor(const point3d_t &p, bool from_postprocessed) const { - colorA_t ret = getRawColor(p); + colorA_t ret = getRawColor(p, from_postprocessed); ret.linearRGB_from_ColorSpace(colorSpace, gamma); return ret; } -colorA_t textureImage_t::getRawColor(const point3d_t &p) const +colorA_t textureImage_t::getRawColor(const point3d_t &p, bool from_postprocessed) const { point3d_t p1 = point3d_t(p.x, -p.y, p.z); colorA_t ret(0.f); @@ -136,19 +171,19 @@ colorA_t textureImage_t::getRawColor(const point3d_t &p) const if(outside) return ret; - ret = interpolateImage(p1); + ret = interpolateImage(p1, from_postprocessed); return ret; } -colorA_t textureImage_t::getColor(int x, int y, int z) const +colorA_t textureImage_t::getColor(int x, int y, int z, bool from_postprocessed) const { - colorA_t ret = getRawColor(x, y, z); + colorA_t ret = getRawColor(x, y, z, from_postprocessed); ret.linearRGB_from_ColorSpace(colorSpace, gamma); return ret; } -colorA_t textureImage_t::getRawColor(int x, int y, int z) const +colorA_t textureImage_t::getRawColor(int x, int y, int z, bool from_postprocessed) const { int resx=image->getWidth(); int resy=image->getHeight(); @@ -160,7 +195,8 @@ colorA_t textureImage_t::getRawColor(int x, int y, int z) const colorA_t c1(0.f); - return image->getPixel(x, y); + if(from_postprocessed && postProcessedImage) return (*postProcessedImage)(x, y); + else return image->getPixel(x, y); } bool textureImage_t::doMapping(point3d_t &texpt) const @@ -247,6 +283,68 @@ void textureImage_t::setCrop(float minx, float miny, float maxx, float maxy) cropy = ((cropminy!=0.0) || (cropmaxy!=1.0)); } +void textureImage_t::postProcessedCreate() +{ + int w=0, h=0, z=0; + resolution(w, h, z); + + postProcessedImage = new rgba2DImage_nw_t(w, h); +} + +void textureImage_t::postProcessedBlur(float blur_factor) +{ + if(!postProcessedImage) return; + + int w=0, h=0, z=0; + resolution(w, h, z); + + cv::Mat A(h, w, CV_32FC4); + cv::Mat B(h, w, CV_32FC4); + cv::Mat_ _A = A; + cv::Mat_ _B = B; + + for(int y = 0; y < h; y++) + { + for(int x = 0; x < w; x++) + { + colorA_t color = image->getPixel(x,y); + color.linearRGB_from_ColorSpace(colorSpace, gamma); + + _A(y, x)[0] = color.getR(); + _A(y, x)[1] = color.getG(); + _A(y, x)[2] = color.getB(); + _A(y, x)[3] = color.getA(); + } + } + + int blurSize = (int) ceil(std::min(w,h) * blur_factor); + if(blurSize % 2 == 0) blurSize += 1; + + cv::GaussianBlur(A, B, cv::Size(blurSize,blurSize),0.0); //Important, sizes must be odd! + + for(int y = 0; y < h; y++) + { + for(int x = 0; x < w; x++) + { + (*postProcessedImage)(x,y).R = _B(y, x)[0]; + (*postProcessedImage)(x,y).G = _B(y, x)[1]; + (*postProcessedImage)(x,y).B = _B(y, x)[2]; + (*postProcessedImage)(x,y).A = _B(y, x)[3]; + + (*postProcessedImage)(x,y).ColorSpace_from_linearRGB(colorSpace, gamma); + } + } + + for(int i=0; igetPixel(i,j) * colorA_t(1.f,0.f,0.f,1.f); + } + } + +} + int string2cliptype(const std::string *clipname) { // default "repeat" From 22c90750df782c52d189758d08e46817e8963d0e Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Mon, 4 Jul 2016 15:28:19 +0200 Subject: [PATCH 110/124] Textures: added Color controls (intensity, contrast, saturation, etc) As requested in http://www.yafaray.org/node/334 I've added color controls to the textures (all YafaRay supported types) to be able to control the intensity, contrast, saturation, etc, in a similar way as Blender internal does. Unfortunately still no color ramps (yet) --- include/core_api/color.h | 44 ++++++++++ include/core_api/texture.h | 118 ++++++++++++++++++++++++++- src/textures/basictex.cc | 159 +++++++++++++++++++++++++++++++------ src/textures/imagetex.cc | 18 ++++- 4 files changed, 309 insertions(+), 30 deletions(-) diff --git a/include/core_api/color.h b/include/core_api/color.h index 27a11737..cf3e9f1e 100755 --- a/include/core_api/color.h +++ b/include/core_api/color.h @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -133,6 +134,8 @@ class YAFRAYCORE_EXPORT color_t void linearRGB_from_ColorSpace(colorSpaces_t colorSpace, float gamma); void ColorSpace_from_linearRGB(colorSpaces_t colorSpace, float gamma); + void rgb_to_hsv(float & h, float & s, float &v); + void hsv_to_rgb(const float & h, const float & s, const float &v); // protected: float R, G, B; @@ -492,6 +495,47 @@ inline float colorA_t::colorDifference(colorA_t color2, bool useRGBcomponents) return colorDifference; } +inline void color_t::rgb_to_hsv(float & h, float & s, float &v) +{ + //HSV-RGB Based on https://en.wikipedia.org/wiki/HSL_and_HSV#Converting_to_RGB + + float R1 = std::max(R, 0.f); + float G1 = std::max(G, 0.f); + float B1 = std::max(B, 0.f); + + v = std::max(std::max(R1,G1),B1); + float m = std::min(std::min(R1,G1),B1); + float C = v - m; + + if(std::fabs(C) < 1.0e-6f) { h = 0.f; s = 0.f; } + else if(v == R1) { h = std::fmod((G1-B1)/C, 6.f); s = C / std::max(v, 1.0e-6f); } + else if(v == G1) { h = ((B1-R1)/C) + 2.f; s = C / std::max(v, 1.0e-6f); } + else if(v == B1) { h = ((R1-G1)/C) + 4.f; s = C / std::max(v, 1.0e-6f); } + else { h = 0.f; s = 0.f; v = 0.f; } + + if(h < 0.f) h += 6.f; +} + +inline void color_t::hsv_to_rgb(const float & h, const float & s, const float &v) +{ + //RGB-HSV Based on https://en.wikipedia.org/wiki/HSL_and_HSV#Converting_to_RGB + float C = v * s; + float X = C * (1.f - std::fabs(std::fmod(h, 2.f) - 1.f)); + float m = v - C; + float R1 = 0.f, G1 = 0.f, B1 = 0.f; + + if(h >= 0.f && h < 1.f) { R1 = C; G1 = X; B1 = 0.f; } + else if(h >= 1.f && h < 2.f) { R1 = X; G1 = C; B1 = 0.f; } + else if(h >= 2.f && h < 3.f) { R1 = 0.f; G1 = C; B1 = X; } + else if(h >= 3.f && h < 4.f) { R1 = 0.f; G1 = X; B1 = C; } + else if(h >= 4.f && h < 5.f) { R1 = X; G1 = 0.f; B1 = C; } + else if(h >= 5.f && h < 6.f) { R1 = C; G1 = 0.f; B1 = X; } + + R = R1 + m; + G = G1 + m; + B = B1 + m; +} + __END_YAFRAY #endif // Y_COLOR_H diff --git a/include/core_api/texture.h b/include/core_api/texture.h index 6376bc9b..8cb0cdd6 100755 --- a/include/core_api/texture.h +++ b/include/core_api/texture.h @@ -19,14 +19,27 @@ class YAFRAYCORE_EXPORT texture_t virtual colorA_t getColor(int x, int y, int z, bool from_postprocessed=false) const { return colorA_t(0.f); } virtual colorA_t getRawColor(const point3d_t &p, bool from_postprocessed=false) const { return getColor(p, from_postprocessed); } virtual colorA_t getRawColor(int x, int y, int z, bool from_postprocessed=false) const { return getColor(x, y, z, from_postprocessed); } - virtual float getFloat(const point3d_t &p) const { return getRawColor(p).col2bri(); } - virtual float getFloat(int x, int y, int z) const { return getRawColor(x, y, z).col2bri(); } + virtual float getFloat(const point3d_t &p) const { return applyAdjustmentsFloat(getRawColor(p).col2bri()); } + virtual float getFloat(int x, int y, int z) const { return applyAdjustmentsFloat(getRawColor(x, y, z).col2bri()); } /* gives the number of values in each dimension for discrete textures */ virtual void resolution(int &x, int &y, int &z) const { x=0, y=0, z=0; } virtual void getInterpolationStep(float &step) const { step = 0.f; }; virtual void postProcessedCreate() { }; virtual void postProcessedBlur(float blur_factor) { }; + void setAdjustments(float intensity, float contrast, float saturation, bool clamp, float factor_red, float factor_green, float factor_blue); + colorA_t applyAdjustmentsColor(const colorA_t & texCol) const; + float applyAdjustmentsFloat(float texFloat) const; virtual ~texture_t() {} + + protected: + float adj_intensity = 1.f; + float adj_contrast = 1.f; + float adj_saturation = 1.f; + bool adj_clamp = false; + float adj_mult_factor_red = 1.f; + float adj_mult_factor_green = 1.f; + float adj_mult_factor_blue = 1.f; + bool adjustments_set = false; }; inline void angmap(const point3d_t &p, float &u, float &v) @@ -87,6 +100,107 @@ inline void invSpheremap(float u, float v, vector3d_t &p) p.z = -costheta; } +inline void texture_t::setAdjustments(float intensity, float contrast, float saturation, bool clamp, float factor_red, float factor_green, float factor_blue) +{ + adj_intensity = intensity; adj_contrast = contrast; adj_saturation = saturation; adj_clamp = clamp; + adj_mult_factor_red = factor_red; adj_mult_factor_green = factor_green; adj_mult_factor_blue = factor_blue; + + std::stringstream adjustments_stream; + + if(intensity != 1.f) + { + adjustments_stream << " intensity=" << intensity; + adjustments_set = true; + } + if(contrast != 1.f) + { + adjustments_stream << " contrast=" << contrast; + adjustments_set = true; + } + if(saturation != 1.f) + { + adjustments_stream << " saturation=" << saturation; + adjustments_set = true; + } + if(factor_red != 1.f) + { + adjustments_stream << " factor_red=" << factor_red; + adjustments_set = true; + } + if(factor_green != 1.f) + { + adjustments_stream << " factor_green=" << factor_green; + adjustments_set = true; + } + if(factor_blue != 1.f) + { + adjustments_stream << " factor_blue=" << factor_blue; + adjustments_set = true; + } + if(clamp) + { + adjustments_stream << " clamping=true"; + adjustments_set = true; + } + + if(adjustments_set) + { + Y_VERBOSE << "Texture: modified texture adjustment values:" << adjustments_stream.str() << yendl; + } +} + +inline colorA_t texture_t::applyAdjustmentsColor(const colorA_t & texCol) const +{ + if(!adjustments_set) return texCol; + + colorA_t ret = texCol; + + if(adj_intensity != 1.f || adj_contrast != 1.f) + { + ret.R = (texCol.R-0.5f) * adj_contrast + adj_intensity-0.5f; + ret.G = (texCol.G-0.5f) * adj_contrast + adj_intensity-0.5f; + ret.B = (texCol.B-0.5f) * adj_contrast + adj_intensity-0.5f; + } + + if(adj_mult_factor_red != 1.f) ret.R *= adj_mult_factor_red; + if(adj_mult_factor_green != 1.f) ret.G *= adj_mult_factor_green; + if(adj_mult_factor_blue != 1.f) ret.B *= adj_mult_factor_blue; + + if(adj_clamp) ret.clampRGB01(); + + if(adj_saturation != 1.f) + { + float h = 0.f, s = 0.f, v = 0.f; + ret.rgb_to_hsv(h, s, v); + s *= adj_saturation; + ret.hsv_to_rgb(h, s, v); + if(adj_clamp) ret.clampRGB01(); + } + + return ret; +} + +inline float texture_t::applyAdjustmentsFloat(float texFloat) const +{ + if(adj_intensity == 1.f && adj_contrast == 1.f) return texFloat; + + float ret = texFloat; + + if(adj_intensity != 1.f || adj_contrast != 1.f) + { + ret = (texFloat-0.5f) * adj_contrast + adj_intensity-0.5f; + } + + if(adj_clamp) + { + if(ret < 0.f) ret = 0.f; + else if(ret > 1.f) ret = 1.f; + } + + return ret; +} + + __END_YAFRAY #endif // Y_TEXTURE_H diff --git a/src/textures/basictex.cc b/src/textures/basictex.cc index 61574f71..f349a971 100755 --- a/src/textures/basictex.cc +++ b/src/textures/basictex.cc @@ -60,12 +60,14 @@ float textureClouds_t::getFloat(const point3d_t &p) const v *= v; if (bias==1) return -v; // !!! } - return v; + return applyAdjustmentsFloat(v); } colorA_t textureClouds_t::getColor(const point3d_t &p, bool from_postprocessed) const { - return color1 + getFloat(p)*(color2 - color1); + colorA_t result = color1 + getFloat(p)*(color2 - color1); + + return result; } texture_t *textureClouds_t::factory(paraMap_t ¶ms, @@ -77,6 +79,9 @@ texture_t *textureClouds_t::factory(paraMap_t ¶ms, const std::string *ntype = &_ntype, *btype=&_btype; float size = 1; bool hard = false; + float intensity = 1.f, contrast = 1.f, saturation = 1.f, factor_red = 1.f, factor_green = 1.f, factor_blue = 1.f; + bool clamp = false; + params.getParam("noise_type", ntype); params.getParam("color1", color1); params.getParam("color2", color2); @@ -84,7 +89,18 @@ texture_t *textureClouds_t::factory(paraMap_t ¶ms, params.getParam("size", size); params.getParam("hard", hard); params.getParam("bias", btype); - return new textureClouds_t(depth, size, hard, color1, color2, *ntype, *btype); + + params.getParam("adj_mult_factor_red", factor_red); + params.getParam("adj_mult_factor_green", factor_green); + params.getParam("adj_mult_factor_blue", factor_blue); + params.getParam("adj_intensity", intensity); + params.getParam("adj_contrast", contrast); + params.getParam("adj_saturation", saturation); + params.getParam("adj_clamp", clamp); + + textureClouds_t * tex = new textureClouds_t(depth, size, hard, color1, color2, *ntype, *btype); + tex->setAdjustments(intensity, contrast, saturation, clamp, factor_red, factor_green, factor_blue); + return tex; } //----------------------------------------------------------------------------------------- @@ -120,12 +136,14 @@ float textureMarble_t::getFloat(const point3d_t &p) const case SIN: w = (float)0.5 + (float)0.5*fSin(w); } - return fPow(w, sharpness); + return applyAdjustmentsFloat(fPow(w, sharpness)); } colorA_t textureMarble_t::getColor(const point3d_t &p, bool from_postprocessed) const { - return color1 + getFloat(p)*(color2 - color1); + colorA_t result = color1 + getFloat(p)*(color2 - color1); + + return result; } texture_t *textureMarble_t::factory(paraMap_t ¶ms, @@ -137,6 +155,9 @@ texture_t *textureMarble_t::factory(paraMap_t ¶ms, bool hrd = false; std::string _ntype, _shape; const std::string *ntype=&_ntype, *shape=&_shape; + float intensity = 1.f, contrast = 1.f, saturation = 1.f, factor_red = 1.f, factor_green = 1.f, factor_blue = 1.f; + bool clamp = false; + params.getParam("noise_type", ntype); params.getParam("color1", col1); params.getParam("color2", col2); @@ -146,7 +167,17 @@ texture_t *textureMarble_t::factory(paraMap_t ¶ms, params.getParam("size", sz); params.getParam("hard", hrd); params.getParam("shape", shape); - return new textureMarble_t(oct, sz, col1, col2, turb, shp, hrd, *ntype, *shape); + params.getParam("adj_mult_factor_red", factor_red); + params.getParam("adj_mult_factor_green", factor_green); + params.getParam("adj_mult_factor_blue", factor_blue); + params.getParam("adj_intensity", intensity); + params.getParam("adj_contrast", contrast); + params.getParam("adj_saturation", saturation); + params.getParam("adj_clamp", clamp); + + textureMarble_t * tex = new textureMarble_t(oct, sz, col1, col2, turb, shp, hrd, *ntype, *shape); + tex->setAdjustments(intensity, contrast, saturation, clamp, factor_red, factor_green, factor_blue); + return tex; } @@ -186,12 +217,14 @@ float textureWood_t::getFloat(const point3d_t &p) const case SIN: w = (float)0.5 + (float)0.5*fSin(w); } - return w; + return applyAdjustmentsFloat(w); } colorA_t textureWood_t::getColor(const point3d_t &p, bool from_postprocessed) const { - return color1 + getFloat(p)*(color2 - color1); + colorA_t result = color1 + getFloat(p)*(color2 - color1); + + return result; } texture_t *textureWood_t::factory(paraMap_t ¶ms, @@ -203,6 +236,9 @@ texture_t *textureWood_t::factory(paraMap_t ¶ms, bool hrd = false; std::string _ntype, _wtype, _shape; const std::string *ntype=&_ntype, *wtype=&_wtype, *shape=&_shape; + float intensity = 1.f, contrast = 1.f, saturation = 1.f, factor_red = 1.f, factor_green = 1.f, factor_blue = 1.f; + bool clamp = false; + params.getParam("noise_type", ntype); params.getParam("color1", col1); params.getParam("color2", col2); @@ -213,10 +249,20 @@ texture_t *textureWood_t::factory(paraMap_t ¶ms, params.getParam("wood_type", wtype); params.getParam("shape", shape); + params.getParam("adj_mult_factor_red", factor_red); + params.getParam("adj_mult_factor_green", factor_green); + params.getParam("adj_mult_factor_blue", factor_blue); + params.getParam("adj_intensity", intensity); + params.getParam("adj_contrast", contrast); + params.getParam("adj_saturation", saturation); + params.getParam("adj_clamp", clamp); + if (params.getParam("ringscale_x", old_rxy) || params.getParam("ringscale_y", old_rxy)) Y_WARNING << "TextureWood: 'ringscale_x' and 'ringscale_y' are obsolete, use 'size' instead" << yendl; - return new textureWood_t(oct, sz, col1, col2, turb, hrd, *ntype, *wtype, *shape); + textureWood_t * tex = new textureWood_t(oct, sz, col1, col2, turb, hrd, *ntype, *wtype, *shape); + tex->setAdjustments(intensity, contrast, saturation, clamp, factor_red, factor_green, factor_blue); + return tex; } //----------------------------------------------------------------------------------------- @@ -227,20 +273,34 @@ colorA_t rgbCube_t::getColor(const point3d_t &p, bool from_postprocessed) const { colorA_t col = colorA_t(p.x, p.y, p.z); col.clampRGB01(); - return col; + + if(adjustments_set) return applyAdjustmentsColor(col); + else return col; } float rgbCube_t::getFloat(const point3d_t &p) const { color_t col = color_t(p.x, p.y, p.z); col.clampRGB01(); - return col.energy(); + return applyAdjustmentsFloat(col.energy()); } texture_t* rgbCube_t::factory(paraMap_t ¶ms,renderEnvironment_t &render) { - // has no params (yet)... - return new rgbCube_t(); + float intensity = 1.f, contrast = 1.f, saturation = 1.f, factor_red = 1.f, factor_green = 1.f, factor_blue = 1.f; + bool clamp = false; + + params.getParam("adj_mult_factor_red", factor_red); + params.getParam("adj_mult_factor_green", factor_green); + params.getParam("adj_mult_factor_blue", factor_blue); + params.getParam("adj_intensity", intensity); + params.getParam("adj_contrast", contrast); + params.getParam("adj_saturation", saturation); + params.getParam("adj_clamp", clamp); + + rgbCube_t * tex = new rgbCube_t(); + tex->setAdjustments(intensity, contrast, saturation, clamp, factor_red, factor_green, factor_blue); + return tex; } //----------------------------------------------------------------------------------------- @@ -282,8 +342,8 @@ float textureVoronoi_t::getFloat(const point3d_t &p) const float da[4]; point3d_t pa[4]; vGen.getFeatures(p*size, da, pa); - return iscale * std::fabs(w1*vGen.getDistance(0, da) + w2*vGen.getDistance(1, da) - + w3*vGen.getDistance(2, da) + w4*vGen.getDistance(3, da)); + return applyAdjustmentsFloat(iscale * std::fabs(w1*vGen.getDistance(0, da) + w2*vGen.getDistance(1, da) + + w3*vGen.getDistance(2, da) + w4*vGen.getDistance(3, da))); } colorA_t textureVoronoi_t::getColor(const point3d_t &p, bool from_postprocessed) const @@ -308,7 +368,8 @@ colorA_t textureVoronoi_t::getColor(const point3d_t &p, bool from_postprocessed) else col *= iscale; } else col.set(inte, inte, inte, inte); - return col; + + return applyAdjustmentsColor(col); } texture_t *textureVoronoi_t::factory(paraMap_t ¶ms, renderEnvironment_t &render) @@ -321,6 +382,8 @@ texture_t *textureVoronoi_t::factory(paraMap_t ¶ms, renderEnvironment_t &ren float isc=1; // intensity scale float sz=1; // size int ct=0; // default "int" color type (intensity) + float intensity = 1.f, contrast = 1.f, saturation = 1.f, factor_red = 1.f, factor_green = 1.f, factor_blue = 1.f; + bool clamp = false; params.getParam("color1", col1); params.getParam("color2", col2); @@ -341,7 +404,17 @@ texture_t *textureVoronoi_t::factory(paraMap_t ¶ms, renderEnvironment_t &ren params.getParam("distance_metric", dname); - return new textureVoronoi_t(col1, col2, ct, fw1, fw2, fw3, fw4, mex, sz, isc, *dname); + params.getParam("adj_mult_factor_red", factor_red); + params.getParam("adj_mult_factor_green", factor_green); + params.getParam("adj_mult_factor_blue", factor_blue); + params.getParam("adj_intensity", intensity); + params.getParam("adj_contrast", contrast); + params.getParam("adj_saturation", saturation); + params.getParam("adj_clamp", clamp); + + textureVoronoi_t * tex = new textureVoronoi_t(col1, col2, ct, fw1, fw2, fw3, fw4, mex, sz, isc, *dname); + tex->setAdjustments(intensity, contrast, saturation, clamp, factor_red, factor_green, factor_blue); + return tex; } //----------------------------------------------------------------------------------------- @@ -381,12 +454,14 @@ textureMusgrave_t::~textureMusgrave_t() float textureMusgrave_t::getFloat(const point3d_t &p) const { - return iscale * (*mGen)(p*size); + return applyAdjustmentsFloat(iscale * (*mGen)(p*size)); } colorA_t textureMusgrave_t::getColor(const point3d_t &p, bool from_postprocessed) const { - return color1 + getFloat(p)*(color2 - color1); + colorA_t result = color1 + getFloat(p)*(color2 - color1); + + return result; } texture_t *textureMusgrave_t::factory(paraMap_t ¶ms, renderEnvironment_t &render) @@ -395,6 +470,8 @@ texture_t *textureMusgrave_t::factory(paraMap_t ¶ms, renderEnvironment_t &re std::string _ntype, _mtype; const std::string *ntype=&_ntype, *mtype=&_mtype; float H=1, lacu=2, octs=2, offs=1, gain=1, size=1, iscale=1; + float intensity = 1.f, contrast = 1.f, saturation = 1.f, factor_red = 1.f, factor_green = 1.f, factor_blue = 1.f; + bool clamp = false; params.getParam("color1", col1); params.getParam("color2", col2); @@ -409,8 +486,18 @@ texture_t *textureMusgrave_t::factory(paraMap_t ¶ms, renderEnvironment_t &re params.getParam("gain", gain); params.getParam("size", size); params.getParam("intensity", iscale); + + params.getParam("adj_mult_factor_red", factor_red); + params.getParam("adj_mult_factor_green", factor_green); + params.getParam("adj_mult_factor_blue", factor_blue); + params.getParam("adj_intensity", intensity); + params.getParam("adj_contrast", contrast); + params.getParam("adj_saturation", saturation); + params.getParam("adj_clamp", clamp); - return new textureMusgrave_t(col1, col2, H, lacu, octs, offs, gain, size, iscale, *ntype, *mtype); + textureMusgrave_t * tex = new textureMusgrave_t(col1, col2, H, lacu, octs, offs, gain, size, iscale, *ntype, *mtype); + tex->setAdjustments(intensity, contrast, saturation, clamp, factor_red, factor_green, factor_blue); + return tex; } //----------------------------------------------------------------------------------------- @@ -444,12 +531,14 @@ float textureDistortedNoise_t::getFloat(const point3d_t &p) const const point3d_t ofs(13.5, 13.5, 13.5); point3d_t tp(p*size); point3d_t rv(getSignedNoise(nGen1, tp+ofs), getSignedNoise(nGen1, tp), getSignedNoise(nGen1, tp-ofs)); - return getSignedNoise(nGen2, tp+rv*distort); // distorted-domain noise + return applyAdjustmentsFloat(getSignedNoise(nGen2, tp+rv*distort)); // distorted-domain noise } colorA_t textureDistortedNoise_t::getColor(const point3d_t &p, bool from_postprocessed) const { - return color1 + getFloat(p)*(color2 - color1); + colorA_t result = color1 + getFloat(p)*(color2 - color1); + + return result; } texture_t *textureDistortedNoise_t::factory(paraMap_t ¶ms, renderEnvironment_t &render) @@ -458,6 +547,8 @@ texture_t *textureDistortedNoise_t::factory(paraMap_t ¶ms, renderEnvironment std::string _ntype1, _ntype2; const std::string *ntype1=&_ntype1, *ntype2=&_ntype2; float dist=1, size=1; + float intensity = 1.f, contrast = 1.f, saturation = 1.f, factor_red = 1.f, factor_green = 1.f, factor_blue = 1.f; + bool clamp = false; params.getParam("color1", col1); params.getParam("color2", col2); @@ -468,7 +559,17 @@ texture_t *textureDistortedNoise_t::factory(paraMap_t ¶ms, renderEnvironment params.getParam("distort", dist); params.getParam("size", size); - return new textureDistortedNoise_t(col1, col2, dist, size, *ntype1, *ntype2); + params.getParam("adj_mult_factor_red", factor_red); + params.getParam("adj_mult_factor_green", factor_green); + params.getParam("adj_mult_factor_blue", factor_blue); + params.getParam("adj_intensity", intensity); + params.getParam("adj_contrast", contrast); + params.getParam("adj_saturation", saturation); + params.getParam("adj_clamp", clamp); + + textureDistortedNoise_t * tex = new textureDistortedNoise_t(col1, col2, dist, size, *ntype1, *ntype2); + tex->setAdjustments(intensity, contrast, saturation, clamp, factor_red, factor_green, factor_blue); + return tex; } //----------------------------------------------------------------------------------------- @@ -492,13 +593,15 @@ float textureBlend_t::getFloat(const point3d_t &p) const // Clipping to 0..1 blend = std::max(0.f, std::min(blend, 1.f)); - return blend; + return applyAdjustmentsFloat(blend); } colorA_t textureBlend_t::getColor(const point3d_t &p, bool from_postprocessed) const { // TODO: colorband - return colorA_t(1.0,1.0,1.0,1.0); + colorA_t result = colorA_t(1.0,1.0,1.0,1.0); + + return applyAdjustmentsColor(result); } texture_t *textureBlend_t::factory(paraMap_t ¶ms, renderEnvironment_t &render) @@ -506,11 +609,15 @@ texture_t *textureBlend_t::factory(paraMap_t ¶ms, renderEnvironment_t &rende std::string _stype; const std::string *stype=&_stype; //bool invertXY = false; + float intensity = 1.f, contrast = 1.f, saturation = 1.f, factor_red = 1.f, factor_green = 1.f, factor_blue = 1.f; + bool clamp = false; params.getParam("stype", _stype); //params.getParam("invertXY", invertXY); - return new textureBlend_t(*stype); + textureBlend_t * tex = new textureBlend_t(*stype); + tex->setAdjustments(intensity, contrast, saturation, clamp, factor_red, factor_green, factor_blue); + return tex; } extern "C" diff --git a/src/textures/imagetex.cc b/src/textures/imagetex.cc index 6ca26144..75a58f62 100755 --- a/src/textures/imagetex.cc +++ b/src/textures/imagetex.cc @@ -159,7 +159,8 @@ colorA_t textureImage_t::getColor(const point3d_t &p, bool from_postprocessed) c { colorA_t ret = getRawColor(p, from_postprocessed); ret.linearRGB_from_ColorSpace(colorSpace, gamma); - return ret; + + return applyAdjustmentsColor(ret); } colorA_t textureImage_t::getRawColor(const point3d_t &p, bool from_postprocessed) const @@ -180,7 +181,8 @@ colorA_t textureImage_t::getColor(int x, int y, int z, bool from_postprocessed) { colorA_t ret = getRawColor(x, y, z, from_postprocessed); ret.linearRGB_from_ColorSpace(colorSpace, gamma); - return ret; + + return applyAdjustmentsColor(ret); } colorA_t textureImage_t::getRawColor(int x, int y, int z, bool from_postprocessed) const @@ -468,6 +470,8 @@ texture_t *textureImage_t::factory(paraMap_t ¶ms, renderEnvironment_t &rende const std::string *clipmode=0; bool mirror_x = false; bool mirror_y = false; + float intensity = 1.f, contrast = 1.f, saturation = 1.f, factor_red = 1.f, factor_green = 1.f, factor_blue = 1.f; + bool clamp = false; params.getParam("xrepeat", xrep); params.getParam("yrepeat", yrep); @@ -485,6 +489,14 @@ texture_t *textureImage_t::factory(paraMap_t ¶ms, renderEnvironment_t &rende params.getParam("mirror_x", mirror_x); params.getParam("mirror_y", mirror_y); + params.getParam("adj_mult_factor_red", factor_red); + params.getParam("adj_mult_factor_green", factor_green); + params.getParam("adj_mult_factor_blue", factor_blue); + params.getParam("adj_intensity", intensity); + params.getParam("adj_contrast", contrast); + params.getParam("adj_saturation", saturation); + params.getParam("adj_clamp", clamp); + tex->xrepeat = xrep; tex->yrepeat = yrep; tex->rot90 = rot90; @@ -499,6 +511,8 @@ texture_t *textureImage_t::factory(paraMap_t ¶ms, renderEnvironment_t &rende tex->mirrorX = mirror_x; tex->mirrorY = mirror_y; + tex->setAdjustments(intensity, contrast, saturation, clamp, factor_red, factor_green, factor_blue); + return tex; } From 06231f3118dd100b5b5773285f4defba4a720852 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Mon, 4 Jul 2016 20:37:44 +0200 Subject: [PATCH 111/124] Texture color controls: changing clamp method to avoid clamping HDRI upper values. This is the method Blender uses, I believe. --- include/core_api/texture.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/core_api/texture.h b/include/core_api/texture.h index 8cb0cdd6..8d749a33 100755 --- a/include/core_api/texture.h +++ b/include/core_api/texture.h @@ -166,7 +166,7 @@ inline colorA_t texture_t::applyAdjustmentsColor(const colorA_t & texCol) const if(adj_mult_factor_green != 1.f) ret.G *= adj_mult_factor_green; if(adj_mult_factor_blue != 1.f) ret.B *= adj_mult_factor_blue; - if(adj_clamp) ret.clampRGB01(); + if(adj_clamp) ret.clampRGB0(); if(adj_saturation != 1.f) { @@ -174,7 +174,7 @@ inline colorA_t texture_t::applyAdjustmentsColor(const colorA_t & texCol) const ret.rgb_to_hsv(h, s, v); s *= adj_saturation; ret.hsv_to_rgb(h, s, v); - if(adj_clamp) ret.clampRGB01(); + if(adj_clamp) ret.clampRGB0(); } return ret; From 9234095696c015f2edf8f26841a671a6dcc83ccc Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Tue, 5 Jul 2016 14:03:35 +0200 Subject: [PATCH 112/124] New Color Ramp for textures As requested in http://www.yafaray.org/node/334 color ramps can be very useful to create interesting and procedural textures for materials For now, only RGB ramps and Linear and Constant are implemented. Ramps don't work with Image textures. --- include/core_api/color_ramp.h | 91 +++++++++++++++++++++++++ include/core_api/texture.h | 9 ++- include/materials/blendmat.h | 1 + include/materials/maskmat.h | 1 + include/materials/microfacet.h | 1 + include/materials/roughglass.h | 1 + include/materials/shinydiff.h | 1 + src/materials/coatedglossy.cc | 2 +- src/materials/glass.cc | 2 +- src/materials/glossy.cc | 2 +- src/materials/roughglass.cc | 1 + src/textures/basictex.cc | 119 ++++++++++++++++++++++++++------- src/yafraycore/CMakeLists.txt | 2 +- src/yafraycore/color_ramp.cc | 76 +++++++++++++++++++++ 14 files changed, 279 insertions(+), 30 deletions(-) create mode 100755 include/core_api/color_ramp.h create mode 100755 src/yafraycore/color_ramp.cc diff --git a/include/core_api/color_ramp.h b/include/core_api/color_ramp.h new file mode 100755 index 00000000..4e887fc2 --- /dev/null +++ b/include/core_api/color_ramp.h @@ -0,0 +1,91 @@ +/**************************************************************************** + * + * color_ramp.h: Color Ramps api + * This is part of the yafray package + * Copyright (C) 2016 David Bluecame + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +#ifndef Y_COLOR_RAMP_H +#define Y_COLOR_RAMP_H + +#include + +#include +#include +#include +#include +#include + +__BEGIN_YAFRAY + +enum color_ramp_mode_t +{ + C_RAMP_RGB, + C_RAMP_HSV, //Not yet supported + C_RAMP_HSL //Not yet supported +}; + +enum color_ramp_interpolation_t +{ + C_RAMP_CONSTANT, + C_RAMP_LINEAR, + C_RAMP_BSPLINE, //Not yet supported + C_RAMP_CARDINAL, //Not yet supported + C_RAMP_EASE //Not yet supported +}; + +enum color_ramp_hue_interpolation_t +{ + C_RAMP_HUE_NEAR, //Not yet supported + C_RAMP_HUE_FAR, //Not yet supported + C_RAMP_HUE_CLOCKWISE, //Not yet supported + C_RAMP_HUE_COUNTERCLOCKWISE //Not yet supported +}; + +class YAFRAYCORE_EXPORT color_ramp_item_t +{ + friend class color_ramp_t; + + public: + color_ramp_item_t(float pos) : position(pos) {} + color_ramp_item_t(const colorA_t & col, float pos) : color(col), position(pos) {} + bool operator < (const color_ramp_item_t& item) const { return (position < item.position); } + bool operator > (const color_ramp_item_t& item) const { return (position > item.position); } + + protected: + colorA_t color = colorA_t(0.f, 0.f, 0.f, 1.f); + float position = 0.f; +}; + +class YAFRAYCORE_EXPORT color_ramp_t +{ + public: + color_ramp_t(int mode, int interpolation, int hue_interpolation); + color_ramp_t(std::string modeStr, std::string interpolationStr, std::string hue_interpolationStr); + void add_item(const colorA_t & color, float position); + colorA_t get_color_interpolated(float pos) const; + + protected: + int ramp_mode = C_RAMP_RGB; + int ramp_interpolation = C_RAMP_LINEAR; + int ramp_hue_interpolation = C_RAMP_HUE_NEAR; + std::vector ramp; +}; + +__END_YAFRAY + +#endif // Y_COLOR_RAMP_H diff --git a/include/core_api/texture.h b/include/core_api/texture.h index 8d749a33..71a0fe82 100755 --- a/include/core_api/texture.h +++ b/include/core_api/texture.h @@ -3,6 +3,7 @@ #include #include "surface.h" +#include __BEGIN_YAFRAY @@ -28,8 +29,10 @@ class YAFRAYCORE_EXPORT texture_t virtual void postProcessedBlur(float blur_factor) { }; void setAdjustments(float intensity, float contrast, float saturation, bool clamp, float factor_red, float factor_green, float factor_blue); colorA_t applyAdjustmentsColor(const colorA_t & texCol) const; - float applyAdjustmentsFloat(float texFloat) const; - virtual ~texture_t() {} + float applyAdjustmentsFloat(float texFloat) const; + void colorRampCreate(std::string modeStr, std::string interpolationStr, std::string hue_interpolationStr) { color_ramp = new color_ramp_t(modeStr, interpolationStr, hue_interpolationStr); } + void colorRampAddItem(colorA_t color, float position) { color_ramp->add_item(color, position); } + virtual ~texture_t() { if(color_ramp) { delete color_ramp; color_ramp = nullptr; } } protected: float adj_intensity = 1.f; @@ -40,6 +43,7 @@ class YAFRAYCORE_EXPORT texture_t float adj_mult_factor_green = 1.f; float adj_mult_factor_blue = 1.f; bool adjustments_set = false; + color_ramp_t * color_ramp = nullptr; }; inline void angmap(const point3d_t &p, float &u, float &v) @@ -200,7 +204,6 @@ inline float texture_t::applyAdjustmentsFloat(float texFloat) const return ret; } - __END_YAFRAY #endif // Y_TEXTURE_H diff --git a/include/materials/blendmat.h b/include/materials/blendmat.h index 2cc3cc25..72006f53 100755 --- a/include/materials/blendmat.h +++ b/include/materials/blendmat.h @@ -5,6 +5,7 @@ #include #include #include +#include __BEGIN_YAFRAY diff --git a/include/materials/maskmat.h b/include/materials/maskmat.h index d4b2ca35..954f59a3 100755 --- a/include/materials/maskmat.h +++ b/include/materials/maskmat.h @@ -3,6 +3,7 @@ #include #include +#include __BEGIN_YAFRAY diff --git a/include/materials/microfacet.h b/include/materials/microfacet.h index 37c396ec..9dac1abb 100755 --- a/include/materials/microfacet.h +++ b/include/materials/microfacet.h @@ -4,6 +4,7 @@ #include #include +#include __BEGIN_YAFRAY diff --git a/include/materials/roughglass.h b/include/materials/roughglass.h index 2690a6f8..33d5bf94 100755 --- a/include/materials/roughglass.h +++ b/include/materials/roughglass.h @@ -3,6 +3,7 @@ #define Y_ROUGHGLASS_H #include +#include __BEGIN_YAFRAY diff --git a/include/materials/shinydiff.h b/include/materials/shinydiff.h index 0d684506..658bc9ed 100755 --- a/include/materials/shinydiff.h +++ b/include/materials/shinydiff.h @@ -5,6 +5,7 @@ #include #include #include +#include __BEGIN_YAFRAY diff --git a/src/materials/coatedglossy.cc b/src/materials/coatedglossy.cc index 391e148c..cf82d7f9 100755 --- a/src/materials/coatedglossy.cc +++ b/src/materials/coatedglossy.cc @@ -23,7 +23,7 @@ #include #include #include - +#include __BEGIN_YAFRAY diff --git a/src/materials/glass.cc b/src/materials/glass.cc index b2dc0b5f..68f96e51 100755 --- a/src/materials/glass.cc +++ b/src/materials/glass.cc @@ -21,7 +21,7 @@ #include #include #include - +#include __BEGIN_YAFRAY diff --git a/src/materials/glossy.cc b/src/materials/glossy.cc index 5fa7cae1..d5c8cdf1 100755 --- a/src/materials/glossy.cc +++ b/src/materials/glossy.cc @@ -23,7 +23,7 @@ #include #include #include - +#include __BEGIN_YAFRAY diff --git a/src/materials/roughglass.cc b/src/materials/roughglass.cc index 5db26aae..b9d06161 100755 --- a/src/materials/roughglass.cc +++ b/src/materials/roughglass.cc @@ -22,6 +22,7 @@ #include #include #include +#include #include __BEGIN_YAFRAY diff --git a/src/textures/basictex.cc b/src/textures/basictex.cc index f349a971..eeab780f 100755 --- a/src/textures/basictex.cc +++ b/src/textures/basictex.cc @@ -32,6 +32,46 @@ noiseGenerator_t* newNoise(const std::string &ntype) return new newPerlin_t(); } +void textureReadColorRamp(const paraMap_t ¶ms, texture_t * tex) +{ + std::string modeStr, interpolationStr, hue_interpolationStr; + int ramp_num_items = 0; + params.getParam("ramp_color_mode", modeStr); + params.getParam("ramp_hue_interpolation", hue_interpolationStr); + params.getParam("ramp_interpolation", interpolationStr); + params.getParam("ramp_num_items", ramp_num_items); + + if(ramp_num_items > 0) + { + tex->colorRampCreate(modeStr, interpolationStr, hue_interpolationStr); + + for(int i = 0; i < ramp_num_items; ++i) + { + std::stringstream paramName; + colorA_t color(0.f, 0.f, 0.f, 1.f); + float alpha = 1.f; + float position = 0.f; + paramName << "ramp_item_" << i << "_color"; + params.getParam(paramName.str(), color); + paramName.str(""); + paramName.clear(); + + paramName << "ramp_item_" << i << "_alpha"; + params.getParam(paramName.str(), alpha); + paramName.str(""); + paramName.clear(); + color.A = alpha; + + paramName << "ramp_item_" << i << "_position"; + params.getParam(paramName.str(), position); + paramName.str(""); + paramName.clear(); + tex->colorRampAddItem(color, position); + } + } +} + + //----------------------------------------------------------------------------------------- // Clouds Texture //----------------------------------------------------------------------------------------- @@ -65,9 +105,8 @@ float textureClouds_t::getFloat(const point3d_t &p) const colorA_t textureClouds_t::getColor(const point3d_t &p, bool from_postprocessed) const { - colorA_t result = color1 + getFloat(p)*(color2 - color1); - - return result; + if(!color_ramp) return color1 + getFloat(p)*(color2 - color1); + else return color_ramp->get_color_interpolated(getFloat(p)); } texture_t *textureClouds_t::factory(paraMap_t ¶ms, @@ -81,6 +120,7 @@ texture_t *textureClouds_t::factory(paraMap_t ¶ms, bool hard = false; float intensity = 1.f, contrast = 1.f, saturation = 1.f, factor_red = 1.f, factor_green = 1.f, factor_blue = 1.f; bool clamp = false; + bool use_color_ramp = false; params.getParam("noise_type", ntype); params.getParam("color1", color1); @@ -98,8 +138,13 @@ texture_t *textureClouds_t::factory(paraMap_t ¶ms, params.getParam("adj_saturation", saturation); params.getParam("adj_clamp", clamp); + params.getParam("use_color_ramp", use_color_ramp); + textureClouds_t * tex = new textureClouds_t(depth, size, hard, color1, color2, *ntype, *btype); tex->setAdjustments(intensity, contrast, saturation, clamp, factor_red, factor_green, factor_blue); + + if(use_color_ramp) textureReadColorRamp(params, tex); + return tex; } @@ -141,9 +186,8 @@ float textureMarble_t::getFloat(const point3d_t &p) const colorA_t textureMarble_t::getColor(const point3d_t &p, bool from_postprocessed) const { - colorA_t result = color1 + getFloat(p)*(color2 - color1); - - return result; + if(!color_ramp) return color1 + getFloat(p)*(color2 - color1); + else return color_ramp->get_color_interpolated(getFloat(p)); } texture_t *textureMarble_t::factory(paraMap_t ¶ms, @@ -157,6 +201,7 @@ texture_t *textureMarble_t::factory(paraMap_t ¶ms, const std::string *ntype=&_ntype, *shape=&_shape; float intensity = 1.f, contrast = 1.f, saturation = 1.f, factor_red = 1.f, factor_green = 1.f, factor_blue = 1.f; bool clamp = false; + bool use_color_ramp = false; params.getParam("noise_type", ntype); params.getParam("color1", col1); @@ -175,8 +220,12 @@ texture_t *textureMarble_t::factory(paraMap_t ¶ms, params.getParam("adj_saturation", saturation); params.getParam("adj_clamp", clamp); + params.getParam("use_color_ramp", use_color_ramp); + textureMarble_t * tex = new textureMarble_t(oct, sz, col1, col2, turb, shp, hrd, *ntype, *shape); tex->setAdjustments(intensity, contrast, saturation, clamp, factor_red, factor_green, factor_blue); + if(use_color_ramp) textureReadColorRamp(params, tex); + return tex; } @@ -222,9 +271,8 @@ float textureWood_t::getFloat(const point3d_t &p) const colorA_t textureWood_t::getColor(const point3d_t &p, bool from_postprocessed) const { - colorA_t result = color1 + getFloat(p)*(color2 - color1); - - return result; + if(!color_ramp) return color1 + getFloat(p)*(color2 - color1); + else return color_ramp->get_color_interpolated(getFloat(p)); } texture_t *textureWood_t::factory(paraMap_t ¶ms, @@ -238,6 +286,7 @@ texture_t *textureWood_t::factory(paraMap_t ¶ms, const std::string *ntype=&_ntype, *wtype=&_wtype, *shape=&_shape; float intensity = 1.f, contrast = 1.f, saturation = 1.f, factor_red = 1.f, factor_green = 1.f, factor_blue = 1.f; bool clamp = false; + bool use_color_ramp = false; params.getParam("noise_type", ntype); params.getParam("color1", col1); @@ -257,11 +306,15 @@ texture_t *textureWood_t::factory(paraMap_t ¶ms, params.getParam("adj_saturation", saturation); params.getParam("adj_clamp", clamp); + params.getParam("use_color_ramp", use_color_ramp); + if (params.getParam("ringscale_x", old_rxy) || params.getParam("ringscale_y", old_rxy)) Y_WARNING << "TextureWood: 'ringscale_x' and 'ringscale_y' are obsolete, use 'size' instead" << yendl; textureWood_t * tex = new textureWood_t(oct, sz, col1, col2, turb, hrd, *ntype, *wtype, *shape); tex->setAdjustments(intensity, contrast, saturation, clamp, factor_red, factor_green, factor_blue); + if(use_color_ramp) textureReadColorRamp(params, tex); + return tex; } @@ -289,6 +342,7 @@ texture_t* rgbCube_t::factory(paraMap_t ¶ms,renderEnvironment_t &render) { float intensity = 1.f, contrast = 1.f, saturation = 1.f, factor_red = 1.f, factor_green = 1.f, factor_blue = 1.f; bool clamp = false; + bool use_color_ramp = false; params.getParam("adj_mult_factor_red", factor_red); params.getParam("adj_mult_factor_green", factor_green); @@ -297,9 +351,13 @@ texture_t* rgbCube_t::factory(paraMap_t ¶ms,renderEnvironment_t &render) params.getParam("adj_contrast", contrast); params.getParam("adj_saturation", saturation); params.getParam("adj_clamp", clamp); + + params.getParam("use_color_ramp", use_color_ramp); rgbCube_t * tex = new rgbCube_t(); tex->setAdjustments(intensity, contrast, saturation, clamp, factor_red, factor_green, factor_blue); + if(use_color_ramp) textureReadColorRamp(params, tex); + return tex; } @@ -354,7 +412,8 @@ colorA_t textureVoronoi_t::getColor(const point3d_t &p, bool from_postprocessed) float inte = iscale * std::fabs(w1*vGen.getDistance(0, da) + w2*vGen.getDistance(1, da) + w3*vGen.getDistance(2, da) + w4*vGen.getDistance(3, da)); colorA_t col(0.0); - if (coltype) { + if(color_ramp) return color_ramp->get_color_interpolated(inte); + else if (coltype) { col += aw1 * cellNoiseColor(vGen.getPoint(0, pa)); col += aw2 * cellNoiseColor(vGen.getPoint(1, pa)); col += aw3 * cellNoiseColor(vGen.getPoint(2, pa)); @@ -366,10 +425,9 @@ colorA_t textureVoronoi_t::getColor(const point3d_t &p, bool from_postprocessed) col *= t1; } else col *= iscale; + return applyAdjustmentsColor(col); } - else col.set(inte, inte, inte, inte); - - return applyAdjustmentsColor(col); + else return colorA_t(inte, inte, inte, inte); } texture_t *textureVoronoi_t::factory(paraMap_t ¶ms, renderEnvironment_t &render) @@ -384,6 +442,7 @@ texture_t *textureVoronoi_t::factory(paraMap_t ¶ms, renderEnvironment_t &ren int ct=0; // default "int" color type (intensity) float intensity = 1.f, contrast = 1.f, saturation = 1.f, factor_red = 1.f, factor_green = 1.f, factor_blue = 1.f; bool clamp = false; + bool use_color_ramp = false; params.getParam("color1", col1); params.getParam("color2", col2); @@ -412,8 +471,12 @@ texture_t *textureVoronoi_t::factory(paraMap_t ¶ms, renderEnvironment_t &ren params.getParam("adj_saturation", saturation); params.getParam("adj_clamp", clamp); + params.getParam("use_color_ramp", use_color_ramp); + textureVoronoi_t * tex = new textureVoronoi_t(col1, col2, ct, fw1, fw2, fw3, fw4, mex, sz, isc, *dname); tex->setAdjustments(intensity, contrast, saturation, clamp, factor_red, factor_green, factor_blue); + if(use_color_ramp) textureReadColorRamp(params, tex); + return tex; } @@ -459,9 +522,8 @@ float textureMusgrave_t::getFloat(const point3d_t &p) const colorA_t textureMusgrave_t::getColor(const point3d_t &p, bool from_postprocessed) const { - colorA_t result = color1 + getFloat(p)*(color2 - color1); - - return result; + if(!color_ramp) return color1 + getFloat(p)*(color2 - color1); + else return color_ramp->get_color_interpolated(getFloat(p)); } texture_t *textureMusgrave_t::factory(paraMap_t ¶ms, renderEnvironment_t &render) @@ -472,6 +534,7 @@ texture_t *textureMusgrave_t::factory(paraMap_t ¶ms, renderEnvironment_t &re float H=1, lacu=2, octs=2, offs=1, gain=1, size=1, iscale=1; float intensity = 1.f, contrast = 1.f, saturation = 1.f, factor_red = 1.f, factor_green = 1.f, factor_blue = 1.f; bool clamp = false; + bool use_color_ramp = false; params.getParam("color1", col1); params.getParam("color2", col2); @@ -494,9 +557,13 @@ texture_t *textureMusgrave_t::factory(paraMap_t ¶ms, renderEnvironment_t &re params.getParam("adj_contrast", contrast); params.getParam("adj_saturation", saturation); params.getParam("adj_clamp", clamp); + + params.getParam("use_color_ramp", use_color_ramp); textureMusgrave_t * tex = new textureMusgrave_t(col1, col2, H, lacu, octs, offs, gain, size, iscale, *ntype, *mtype); tex->setAdjustments(intensity, contrast, saturation, clamp, factor_red, factor_green, factor_blue); + if(use_color_ramp) textureReadColorRamp(params, tex); + return tex; } @@ -536,9 +603,8 @@ float textureDistortedNoise_t::getFloat(const point3d_t &p) const colorA_t textureDistortedNoise_t::getColor(const point3d_t &p, bool from_postprocessed) const { - colorA_t result = color1 + getFloat(p)*(color2 - color1); - - return result; + if(!color_ramp) return color1 + getFloat(p)*(color2 - color1); + else return color_ramp->get_color_interpolated(getFloat(p)); } texture_t *textureDistortedNoise_t::factory(paraMap_t ¶ms, renderEnvironment_t &render) @@ -549,6 +615,7 @@ texture_t *textureDistortedNoise_t::factory(paraMap_t ¶ms, renderEnvironment float dist=1, size=1; float intensity = 1.f, contrast = 1.f, saturation = 1.f, factor_red = 1.f, factor_green = 1.f, factor_blue = 1.f; bool clamp = false; + bool use_color_ramp = false; params.getParam("color1", col1); params.getParam("color2", col2); @@ -567,8 +634,12 @@ texture_t *textureDistortedNoise_t::factory(paraMap_t ¶ms, renderEnvironment params.getParam("adj_saturation", saturation); params.getParam("adj_clamp", clamp); + params.getParam("use_color_ramp", use_color_ramp); + textureDistortedNoise_t * tex = new textureDistortedNoise_t(col1, col2, dist, size, *ntype1, *ntype2); tex->setAdjustments(intensity, contrast, saturation, clamp, factor_red, factor_green, factor_blue); + if(use_color_ramp) textureReadColorRamp(params, tex); + return tex; } @@ -598,10 +669,8 @@ float textureBlend_t::getFloat(const point3d_t &p) const colorA_t textureBlend_t::getColor(const point3d_t &p, bool from_postprocessed) const { - // TODO: colorband - colorA_t result = colorA_t(1.0,1.0,1.0,1.0); - - return applyAdjustmentsColor(result); + if(!color_ramp) return colorA_t(1.f); + else return color_ramp->get_color_interpolated(getFloat(p)); } texture_t *textureBlend_t::factory(paraMap_t ¶ms, renderEnvironment_t &render) @@ -611,12 +680,16 @@ texture_t *textureBlend_t::factory(paraMap_t ¶ms, renderEnvironment_t &rende //bool invertXY = false; float intensity = 1.f, contrast = 1.f, saturation = 1.f, factor_red = 1.f, factor_green = 1.f, factor_blue = 1.f; bool clamp = false; + bool use_color_ramp = false; params.getParam("stype", _stype); + params.getParam("use_color_ramp", use_color_ramp); //params.getParam("invertXY", invertXY); textureBlend_t * tex = new textureBlend_t(*stype); tex->setAdjustments(intensity, contrast, saturation, clamp, factor_red, factor_green, factor_blue); + if(use_color_ramp) textureReadColorRamp(params, tex); + return tex; } diff --git a/src/yafraycore/CMakeLists.txt b/src/yafraycore/CMakeLists.txt index b0c5ddd7..90a550af 100755 --- a/src/yafraycore/CMakeLists.txt +++ b/src/yafraycore/CMakeLists.txt @@ -1,6 +1,6 @@ include_directories(${YAF_INCLUDE_DIRS} ${LIBXML2_INCLUDE_DIR} ${OPENEXR_INCLUDE_DIRS} ${FREETYPE_INCLUDE_DIRS}) -set(YF_CORE_SOURCES bound.cc yafsystem.cc environment.cc console.cc color_console.cc +set(YF_CORE_SOURCES bound.cc yafsystem.cc environment.cc console.cc color_console.cc color_ramp.cc sysinfo.cc logging.cc session.cc faure_tables.cc std_primitives.cc color.cc renderpasses.cc matrix4.cc object3d.cc timer.cc kdtree.cc ray_kdtree.cc hashgrid.cc tribox3_d.cc triclip.cc scene.cc imagefilm.cc imagesplitter.cc material.cc nodematerial.cc diff --git a/src/yafraycore/color_ramp.cc b/src/yafraycore/color_ramp.cc new file mode 100755 index 00000000..0bc0d515 --- /dev/null +++ b/src/yafraycore/color_ramp.cc @@ -0,0 +1,76 @@ +/**************************************************************************** + * + * color_ramp.cc: Color ramp type and operators implementation + * This is part of the yafray package + * Copyright (C) 2016 David Bluecame + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +#include +#include +#include + +#include + +__BEGIN_YAFRAY + +color_ramp_t::color_ramp_t(int mode, int interpolation, int hue_interpolation):ramp_mode(mode), ramp_interpolation(interpolation), ramp_hue_interpolation(hue_interpolation) {} + +color_ramp_t::color_ramp_t(std::string modeStr, std::string interpolationStr, std::string hue_interpolationStr) +{ + ramp_mode = C_RAMP_RGB; //Other modes not supported yet + ramp_hue_interpolation = C_RAMP_HUE_NEAR; //Other modes not supported yet + + if(interpolationStr == "CONSTANT") ramp_interpolation = C_RAMP_CONSTANT; + else ramp_interpolation = C_RAMP_LINEAR; //Other modes not supported yet +} + +void color_ramp_t::add_item(const colorA_t & color, float position) +{ + ramp.push_back(color_ramp_item_t(color, position)); + std::sort(ramp.begin(), ramp.end()); +} + +colorA_t interpolation_linear(float pos, const colorA_t & col1, float pos1, const colorA_t & col2, float pos2) +{ + if(pos == pos1 || pos1 == pos2) return col1; + else if(pos == pos2) return col2; + + colorA_t diffCol21 = col2 - col1; + float diffPos21 = pos2 - pos1; + float diffPos = pos - pos1; + + return col1 + ((diffPos / diffPos21) * diffCol21); +} + +colorA_t color_ramp_t::get_color_interpolated(float pos) const +{ + colorA_t result; + if(pos < 0.f) result = ramp.front().color; + else if(pos > 1.f) result = ramp.back().color; + else + { + auto item_current = std::lower_bound(ramp.begin(), ramp.end(), pos); + auto item_previous = std::prev(item_current); + + if(ramp_interpolation == C_RAMP_CONSTANT) result = item_current->color; + else result = interpolation_linear(pos, item_current->color, item_current->position, item_previous->color, item_previous->position); + } + return result; +} + + +__END_YAFRAY From cd21d728d6d4cc727975f0a5726e5c69aab7ee4b Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Tue, 5 Jul 2016 15:10:01 +0200 Subject: [PATCH 113/124] Texture color controls: added Hue control --- include/core_api/texture.h | 25 +++++++++++++++++++----- src/textures/basictex.cc | 39 ++++++++++++++++++++++---------------- src/textures/imagetex.cc | 5 +++-- 3 files changed, 46 insertions(+), 23 deletions(-) diff --git a/include/core_api/texture.h b/include/core_api/texture.h index 71a0fe82..c2333108 100755 --- a/include/core_api/texture.h +++ b/include/core_api/texture.h @@ -27,7 +27,7 @@ class YAFRAYCORE_EXPORT texture_t virtual void getInterpolationStep(float &step) const { step = 0.f; }; virtual void postProcessedCreate() { }; virtual void postProcessedBlur(float blur_factor) { }; - void setAdjustments(float intensity, float contrast, float saturation, bool clamp, float factor_red, float factor_green, float factor_blue); + void setAdjustments(float intensity, float contrast, float saturation, float hue, bool clamp, float factor_red, float factor_green, float factor_blue); colorA_t applyAdjustmentsColor(const colorA_t & texCol) const; float applyAdjustmentsFloat(float texFloat) const; void colorRampCreate(std::string modeStr, std::string interpolationStr, std::string hue_interpolationStr) { color_ramp = new color_ramp_t(modeStr, interpolationStr, hue_interpolationStr); } @@ -38,6 +38,7 @@ class YAFRAYCORE_EXPORT texture_t float adj_intensity = 1.f; float adj_contrast = 1.f; float adj_saturation = 1.f; + float adj_hue = 0.f; bool adj_clamp = false; float adj_mult_factor_red = 1.f; float adj_mult_factor_green = 1.f; @@ -104,10 +105,16 @@ inline void invSpheremap(float u, float v, vector3d_t &p) p.z = -costheta; } -inline void texture_t::setAdjustments(float intensity, float contrast, float saturation, bool clamp, float factor_red, float factor_green, float factor_blue) +inline void texture_t::setAdjustments(float intensity, float contrast, float saturation, float hue, bool clamp, float factor_red, float factor_green, float factor_blue) { - adj_intensity = intensity; adj_contrast = contrast; adj_saturation = saturation; adj_clamp = clamp; - adj_mult_factor_red = factor_red; adj_mult_factor_green = factor_green; adj_mult_factor_blue = factor_blue; + adj_intensity = intensity; + adj_contrast = contrast; + adj_saturation = saturation; + adj_hue = hue; + adj_clamp = clamp; + adj_mult_factor_red = factor_red; + adj_mult_factor_green = factor_green; + adj_mult_factor_blue = factor_blue; std::stringstream adjustments_stream; @@ -126,6 +133,11 @@ inline void texture_t::setAdjustments(float intensity, float contrast, float sat adjustments_stream << " saturation=" << saturation; adjustments_set = true; } + if(hue != 0.f) + { + adjustments_stream << " hue=" << hue; + adjustments_set = true; + } if(factor_red != 1.f) { adjustments_stream << " factor_red=" << factor_red; @@ -172,11 +184,14 @@ inline colorA_t texture_t::applyAdjustmentsColor(const colorA_t & texCol) const if(adj_clamp) ret.clampRGB0(); - if(adj_saturation != 1.f) + if(adj_saturation != 1.f || adj_hue != 0.f) { float h = 0.f, s = 0.f, v = 0.f; ret.rgb_to_hsv(h, s, v); s *= adj_saturation; + h += adj_hue; + if(h < 0.f) h += 6.f; + else if(h > 6.f) h -= 6.f; ret.hsv_to_rgb(h, s, v); if(adj_clamp) ret.clampRGB0(); } diff --git a/src/textures/basictex.cc b/src/textures/basictex.cc index eeab780f..2d4791b6 100755 --- a/src/textures/basictex.cc +++ b/src/textures/basictex.cc @@ -118,7 +118,7 @@ texture_t *textureClouds_t::factory(paraMap_t ¶ms, const std::string *ntype = &_ntype, *btype=&_btype; float size = 1; bool hard = false; - float intensity = 1.f, contrast = 1.f, saturation = 1.f, factor_red = 1.f, factor_green = 1.f, factor_blue = 1.f; + float intensity = 1.f, contrast = 1.f, saturation = 1.f, hue = 0.f, factor_red = 1.f, factor_green = 1.f, factor_blue = 1.f; bool clamp = false; bool use_color_ramp = false; @@ -136,12 +136,13 @@ texture_t *textureClouds_t::factory(paraMap_t ¶ms, params.getParam("adj_intensity", intensity); params.getParam("adj_contrast", contrast); params.getParam("adj_saturation", saturation); + params.getParam("adj_hue", hue); params.getParam("adj_clamp", clamp); params.getParam("use_color_ramp", use_color_ramp); textureClouds_t * tex = new textureClouds_t(depth, size, hard, color1, color2, *ntype, *btype); - tex->setAdjustments(intensity, contrast, saturation, clamp, factor_red, factor_green, factor_blue); + tex->setAdjustments(intensity, contrast, saturation, hue, clamp, factor_red, factor_green, factor_blue); if(use_color_ramp) textureReadColorRamp(params, tex); @@ -199,7 +200,7 @@ texture_t *textureMarble_t::factory(paraMap_t ¶ms, bool hrd = false; std::string _ntype, _shape; const std::string *ntype=&_ntype, *shape=&_shape; - float intensity = 1.f, contrast = 1.f, saturation = 1.f, factor_red = 1.f, factor_green = 1.f, factor_blue = 1.f; + float intensity = 1.f, contrast = 1.f, saturation = 1.f, hue = 0.f, factor_red = 1.f, factor_green = 1.f, factor_blue = 1.f; bool clamp = false; bool use_color_ramp = false; @@ -218,12 +219,13 @@ texture_t *textureMarble_t::factory(paraMap_t ¶ms, params.getParam("adj_intensity", intensity); params.getParam("adj_contrast", contrast); params.getParam("adj_saturation", saturation); + params.getParam("adj_hue", hue); params.getParam("adj_clamp", clamp); params.getParam("use_color_ramp", use_color_ramp); textureMarble_t * tex = new textureMarble_t(oct, sz, col1, col2, turb, shp, hrd, *ntype, *shape); - tex->setAdjustments(intensity, contrast, saturation, clamp, factor_red, factor_green, factor_blue); + tex->setAdjustments(intensity, contrast, saturation, hue, clamp, factor_red, factor_green, factor_blue); if(use_color_ramp) textureReadColorRamp(params, tex); return tex; @@ -284,7 +286,7 @@ texture_t *textureWood_t::factory(paraMap_t ¶ms, bool hrd = false; std::string _ntype, _wtype, _shape; const std::string *ntype=&_ntype, *wtype=&_wtype, *shape=&_shape; - float intensity = 1.f, contrast = 1.f, saturation = 1.f, factor_red = 1.f, factor_green = 1.f, factor_blue = 1.f; + float intensity = 1.f, contrast = 1.f, saturation = 1.f, hue = 0.f, factor_red = 1.f, factor_green = 1.f, factor_blue = 1.f; bool clamp = false; bool use_color_ramp = false; @@ -304,6 +306,7 @@ texture_t *textureWood_t::factory(paraMap_t ¶ms, params.getParam("adj_intensity", intensity); params.getParam("adj_contrast", contrast); params.getParam("adj_saturation", saturation); + params.getParam("adj_hue", hue); params.getParam("adj_clamp", clamp); params.getParam("use_color_ramp", use_color_ramp); @@ -312,7 +315,7 @@ texture_t *textureWood_t::factory(paraMap_t ¶ms, Y_WARNING << "TextureWood: 'ringscale_x' and 'ringscale_y' are obsolete, use 'size' instead" << yendl; textureWood_t * tex = new textureWood_t(oct, sz, col1, col2, turb, hrd, *ntype, *wtype, *shape); - tex->setAdjustments(intensity, contrast, saturation, clamp, factor_red, factor_green, factor_blue); + tex->setAdjustments(intensity, contrast, saturation, hue, clamp, factor_red, factor_green, factor_blue); if(use_color_ramp) textureReadColorRamp(params, tex); return tex; @@ -340,7 +343,7 @@ float rgbCube_t::getFloat(const point3d_t &p) const texture_t* rgbCube_t::factory(paraMap_t ¶ms,renderEnvironment_t &render) { - float intensity = 1.f, contrast = 1.f, saturation = 1.f, factor_red = 1.f, factor_green = 1.f, factor_blue = 1.f; + float intensity = 1.f, contrast = 1.f, saturation = 1.f, hue = 0.f, factor_red = 1.f, factor_green = 1.f, factor_blue = 1.f; bool clamp = false; bool use_color_ramp = false; @@ -350,12 +353,13 @@ texture_t* rgbCube_t::factory(paraMap_t ¶ms,renderEnvironment_t &render) params.getParam("adj_intensity", intensity); params.getParam("adj_contrast", contrast); params.getParam("adj_saturation", saturation); + params.getParam("adj_hue", hue); params.getParam("adj_clamp", clamp); params.getParam("use_color_ramp", use_color_ramp); rgbCube_t * tex = new rgbCube_t(); - tex->setAdjustments(intensity, contrast, saturation, clamp, factor_red, factor_green, factor_blue); + tex->setAdjustments(intensity, contrast, saturation, hue, clamp, factor_red, factor_green, factor_blue); if(use_color_ramp) textureReadColorRamp(params, tex); return tex; @@ -440,7 +444,7 @@ texture_t *textureVoronoi_t::factory(paraMap_t ¶ms, renderEnvironment_t &ren float isc=1; // intensity scale float sz=1; // size int ct=0; // default "int" color type (intensity) - float intensity = 1.f, contrast = 1.f, saturation = 1.f, factor_red = 1.f, factor_green = 1.f, factor_blue = 1.f; + float intensity = 1.f, contrast = 1.f, saturation = 1.f, hue = 0.f, factor_red = 1.f, factor_green = 1.f, factor_blue = 1.f; bool clamp = false; bool use_color_ramp = false; @@ -469,12 +473,13 @@ texture_t *textureVoronoi_t::factory(paraMap_t ¶ms, renderEnvironment_t &ren params.getParam("adj_intensity", intensity); params.getParam("adj_contrast", contrast); params.getParam("adj_saturation", saturation); + params.getParam("adj_hue", hue); params.getParam("adj_clamp", clamp); params.getParam("use_color_ramp", use_color_ramp); textureVoronoi_t * tex = new textureVoronoi_t(col1, col2, ct, fw1, fw2, fw3, fw4, mex, sz, isc, *dname); - tex->setAdjustments(intensity, contrast, saturation, clamp, factor_red, factor_green, factor_blue); + tex->setAdjustments(intensity, contrast, saturation, hue, clamp, factor_red, factor_green, factor_blue); if(use_color_ramp) textureReadColorRamp(params, tex); return tex; @@ -532,7 +537,7 @@ texture_t *textureMusgrave_t::factory(paraMap_t ¶ms, renderEnvironment_t &re std::string _ntype, _mtype; const std::string *ntype=&_ntype, *mtype=&_mtype; float H=1, lacu=2, octs=2, offs=1, gain=1, size=1, iscale=1; - float intensity = 1.f, contrast = 1.f, saturation = 1.f, factor_red = 1.f, factor_green = 1.f, factor_blue = 1.f; + float intensity = 1.f, contrast = 1.f, saturation = 1.f, hue = 0.f, factor_red = 1.f, factor_green = 1.f, factor_blue = 1.f; bool clamp = false; bool use_color_ramp = false; @@ -556,12 +561,13 @@ texture_t *textureMusgrave_t::factory(paraMap_t ¶ms, renderEnvironment_t &re params.getParam("adj_intensity", intensity); params.getParam("adj_contrast", contrast); params.getParam("adj_saturation", saturation); + params.getParam("adj_hue", hue); params.getParam("adj_clamp", clamp); params.getParam("use_color_ramp", use_color_ramp); textureMusgrave_t * tex = new textureMusgrave_t(col1, col2, H, lacu, octs, offs, gain, size, iscale, *ntype, *mtype); - tex->setAdjustments(intensity, contrast, saturation, clamp, factor_red, factor_green, factor_blue); + tex->setAdjustments(intensity, contrast, saturation, hue, clamp, factor_red, factor_green, factor_blue); if(use_color_ramp) textureReadColorRamp(params, tex); return tex; @@ -613,7 +619,7 @@ texture_t *textureDistortedNoise_t::factory(paraMap_t ¶ms, renderEnvironment std::string _ntype1, _ntype2; const std::string *ntype1=&_ntype1, *ntype2=&_ntype2; float dist=1, size=1; - float intensity = 1.f, contrast = 1.f, saturation = 1.f, factor_red = 1.f, factor_green = 1.f, factor_blue = 1.f; + float intensity = 1.f, contrast = 1.f, saturation = 1.f, hue = 0.f, factor_red = 1.f, factor_green = 1.f, factor_blue = 1.f; bool clamp = false; bool use_color_ramp = false; @@ -632,12 +638,13 @@ texture_t *textureDistortedNoise_t::factory(paraMap_t ¶ms, renderEnvironment params.getParam("adj_intensity", intensity); params.getParam("adj_contrast", contrast); params.getParam("adj_saturation", saturation); + params.getParam("adj_hue", hue); params.getParam("adj_clamp", clamp); params.getParam("use_color_ramp", use_color_ramp); textureDistortedNoise_t * tex = new textureDistortedNoise_t(col1, col2, dist, size, *ntype1, *ntype2); - tex->setAdjustments(intensity, contrast, saturation, clamp, factor_red, factor_green, factor_blue); + tex->setAdjustments(intensity, contrast, saturation, hue, clamp, factor_red, factor_green, factor_blue); if(use_color_ramp) textureReadColorRamp(params, tex); return tex; @@ -678,7 +685,7 @@ texture_t *textureBlend_t::factory(paraMap_t ¶ms, renderEnvironment_t &rende std::string _stype; const std::string *stype=&_stype; //bool invertXY = false; - float intensity = 1.f, contrast = 1.f, saturation = 1.f, factor_red = 1.f, factor_green = 1.f, factor_blue = 1.f; + float intensity = 1.f, contrast = 1.f, saturation = 1.f, hue = 0.f, factor_red = 1.f, factor_green = 1.f, factor_blue = 1.f; bool clamp = false; bool use_color_ramp = false; @@ -687,7 +694,7 @@ texture_t *textureBlend_t::factory(paraMap_t ¶ms, renderEnvironment_t &rende //params.getParam("invertXY", invertXY); textureBlend_t * tex = new textureBlend_t(*stype); - tex->setAdjustments(intensity, contrast, saturation, clamp, factor_red, factor_green, factor_blue); + tex->setAdjustments(intensity, contrast, saturation, hue, clamp, factor_red, factor_green, factor_blue); if(use_color_ramp) textureReadColorRamp(params, tex); return tex; diff --git a/src/textures/imagetex.cc b/src/textures/imagetex.cc index 75a58f62..b160ade1 100755 --- a/src/textures/imagetex.cc +++ b/src/textures/imagetex.cc @@ -470,7 +470,7 @@ texture_t *textureImage_t::factory(paraMap_t ¶ms, renderEnvironment_t &rende const std::string *clipmode=0; bool mirror_x = false; bool mirror_y = false; - float intensity = 1.f, contrast = 1.f, saturation = 1.f, factor_red = 1.f, factor_green = 1.f, factor_blue = 1.f; + float intensity = 1.f, contrast = 1.f, saturation = 1.f, hue = 0.f, factor_red = 1.f, factor_green = 1.f, factor_blue = 1.f; bool clamp = false; params.getParam("xrepeat", xrep); @@ -495,6 +495,7 @@ texture_t *textureImage_t::factory(paraMap_t ¶ms, renderEnvironment_t &rende params.getParam("adj_intensity", intensity); params.getParam("adj_contrast", contrast); params.getParam("adj_saturation", saturation); + params.getParam("adj_hue", hue); params.getParam("adj_clamp", clamp); tex->xrepeat = xrep; @@ -511,7 +512,7 @@ texture_t *textureImage_t::factory(paraMap_t ¶ms, renderEnvironment_t &rende tex->mirrorX = mirror_x; tex->mirrorY = mirror_y; - tex->setAdjustments(intensity, contrast, saturation, clamp, factor_red, factor_green, factor_blue); + tex->setAdjustments(intensity, contrast, saturation, hue, clamp, factor_red, factor_green, factor_blue); return tex; } From 6dee5466be2a936ae7f56c900d263eaaa12e28da Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sun, 10 Jul 2016 22:48:03 +0200 Subject: [PATCH 114/124] New IBL parameter IBL_clamp_sampling to reduce IBL sampling noise (at the expense of realism and inexact overall lighting) --- include/core_api/light.h | 3 +++ src/backgrounds/textureback.cc | 9 +++++++++ src/lights/bglight.cc | 2 ++ src/lights/bgportallight.cc | 2 ++ 4 files changed, 16 insertions(+) diff --git a/include/core_api/light.h b/include/core_api/light.h index 70be95b2..a179890e 100755 --- a/include/core_api/light.h +++ b/include/core_api/light.h @@ -70,6 +70,8 @@ class light_t bool shootsDiffuseP() const { return lShootDiffuse; } //! checks if the light is a photon-only light (only shoots photons, not illuminating) bool photonOnly() const { return lPhotonOnly; } + //! sets clampIntersect value to reduce noise at the expense of realism and inexact overall lighting + void setClampIntersect(float clamp) { lClampIntersect = clamp; } light_t(): flags(LIGHT_NONE),lLightEnabled(true),lCastShadows(true),lShootCaustic(true),lShootDiffuse(true),lPhotonOnly(false) {} light_t(LIGHTF_t _flags): flags(_flags) {} @@ -83,6 +85,7 @@ class light_t bool lShootCaustic; //!setBackground(texBG); + if(IBL_clamp_sampling > 0.f) + { + Y_INFO << "TextureBackground: using IBL sampling clamp=" << IBL_clamp_sampling << yendl; + + bglight->setClampIntersect(IBL_clamp_sampling); + } + if(bglight) render.getScene()->addLight(bglight); } diff --git a/src/lights/bglight.cc b/src/lights/bglight.cc index 46b0781b..fcff35a7 100755 --- a/src/lights/bglight.cc +++ b/src/lights/bglight.cc @@ -209,6 +209,8 @@ bool bgLight_t::intersect(const ray_t &ray, float &t, color_t &col, float &ipdf) invSpheremap(u, v, tr.dir); col = background->eval(tr, true); + + col.clampProportionalRGB(lClampIntersect); //trick to reduce light sampling noise at the expense of realism and inexact overall light. 0.f disables clamping return true; } diff --git a/src/lights/bgportallight.cc b/src/lights/bgportallight.cc index 48fb1142..c7b26ce2 100755 --- a/src/lights/bgportallight.cc +++ b/src/lights/bgportallight.cc @@ -211,6 +211,8 @@ bool bgPortalLight_t::intersect(const ray_t &ray, float &t, color_t &col, float ipdf = idist_sqr * area * cos_angle * (1.f/M_PI); col = bg->eval(ray, true) * power; + col.clampProportionalRGB(lClampIntersect); //trick to reduce light sampling noise at the expense of realism and inexact overall light. 0.f disables clamping + return true; } From 71a7d1a812663e0b7d454e72c7228a95d15be81c Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Mon, 11 Jul 2016 07:11:58 +0200 Subject: [PATCH 115/124] Change texture hue adjustment to be shown as an angle --- include/core_api/texture.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/core_api/texture.h b/include/core_api/texture.h index c2333108..028248f4 100755 --- a/include/core_api/texture.h +++ b/include/core_api/texture.h @@ -110,7 +110,7 @@ inline void texture_t::setAdjustments(float intensity, float contrast, float sat adj_intensity = intensity; adj_contrast = contrast; adj_saturation = saturation; - adj_hue = hue; + adj_hue = hue / 60.f; //The value of the hue offset parameter is in degrees, but internally the HSV hue works in "units" where each unit is 60 degrees adj_clamp = clamp; adj_mult_factor_red = factor_red; adj_mult_factor_green = factor_green; @@ -135,7 +135,7 @@ inline void texture_t::setAdjustments(float intensity, float contrast, float sat } if(hue != 0.f) { - adjustments_stream << " hue=" << hue; + adjustments_stream << " hue offset=" << hue << "ยบ"; adjustments_set = true; } if(factor_red != 1.f) From 260f5c5c2000aec453dc56691a8b4294a3d9edd1 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Mon, 11 Jul 2016 08:23:01 +0200 Subject: [PATCH 116/124] Color Ramps: added HSV ramps --- include/core_api/color.h | 4 +-- include/core_api/color_ramp.h | 12 +++---- src/yafraycore/color_ramp.cc | 68 +++++++++++++++++++++++++++++++---- 3 files changed, 70 insertions(+), 14 deletions(-) diff --git a/include/core_api/color.h b/include/core_api/color.h index cf3e9f1e..ea2d24f0 100755 --- a/include/core_api/color.h +++ b/include/core_api/color.h @@ -134,7 +134,7 @@ class YAFRAYCORE_EXPORT color_t void linearRGB_from_ColorSpace(colorSpaces_t colorSpace, float gamma); void ColorSpace_from_linearRGB(colorSpaces_t colorSpace, float gamma); - void rgb_to_hsv(float & h, float & s, float &v); + void rgb_to_hsv(float & h, float & s, float &v) const; void hsv_to_rgb(const float & h, const float & s, const float &v); // protected: @@ -495,7 +495,7 @@ inline float colorA_t::colorDifference(colorA_t color2, bool useRGBcomponents) return colorDifference; } -inline void color_t::rgb_to_hsv(float & h, float & s, float &v) +inline void color_t::rgb_to_hsv(float & h, float & s, float &v) const { //HSV-RGB Based on https://en.wikipedia.org/wiki/HSL_and_HSV#Converting_to_RGB diff --git a/include/core_api/color_ramp.h b/include/core_api/color_ramp.h index 4e887fc2..f0b0f740 100755 --- a/include/core_api/color_ramp.h +++ b/include/core_api/color_ramp.h @@ -35,8 +35,8 @@ __BEGIN_YAFRAY enum color_ramp_mode_t { C_RAMP_RGB, - C_RAMP_HSV, //Not yet supported - C_RAMP_HSL //Not yet supported + C_RAMP_HSV, + C_RAMP_HSL //Not yet supported, using HSV instead }; enum color_ramp_interpolation_t @@ -50,10 +50,10 @@ enum color_ramp_interpolation_t enum color_ramp_hue_interpolation_t { - C_RAMP_HUE_NEAR, //Not yet supported - C_RAMP_HUE_FAR, //Not yet supported - C_RAMP_HUE_CLOCKWISE, //Not yet supported - C_RAMP_HUE_COUNTERCLOCKWISE //Not yet supported + C_RAMP_HUE_NEAR, + C_RAMP_HUE_FAR, + C_RAMP_HUE_CLOCKWISE, + C_RAMP_HUE_COUNTERCLOCKWISE }; class YAFRAYCORE_EXPORT color_ramp_item_t diff --git a/src/yafraycore/color_ramp.cc b/src/yafraycore/color_ramp.cc index 0bc0d515..ca861c92 100755 --- a/src/yafraycore/color_ramp.cc +++ b/src/yafraycore/color_ramp.cc @@ -31,11 +31,20 @@ color_ramp_t::color_ramp_t(int mode, int interpolation, int hue_interpolation):r color_ramp_t::color_ramp_t(std::string modeStr, std::string interpolationStr, std::string hue_interpolationStr) { - ramp_mode = C_RAMP_RGB; //Other modes not supported yet - ramp_hue_interpolation = C_RAMP_HUE_NEAR; //Other modes not supported yet - - if(interpolationStr == "CONSTANT") ramp_interpolation = C_RAMP_CONSTANT; + Y_DEBUG << "modeStr='"<color; - else result = interpolation_linear(pos, item_current->color, item_current->position, item_previous->color, item_previous->position); + if(ramp_mode == C_RAMP_RGB) + { + if(ramp_interpolation == C_RAMP_CONSTANT) result = item_current->color; + else result = interpolation_linear(pos, item_current->color, item_current->position, item_previous->color, item_previous->position); + } + else if(ramp_mode == C_RAMP_HSV || ramp_mode == C_RAMP_HSL) //HSL not yet supported, using HSV instead + { + float pos1 = item_current->position; + float pos2 = item_previous->position; + float h1=0.f, s1=0.f, v1=0.f, a1=0.f; + float h2=0.f, s2=0.f, v2=0.f, a2=0.f; + float h=0.f, s=0.f, v=0.f, a=0.f; + + item_current->color.rgb_to_hsv(h1, s1, v1); + a1 = item_current->color.A; + + item_previous->color.rgb_to_hsv(h2, s2, v2); + a2 = item_previous->color.A; + + s = interpolation_linear(pos, s1, pos1, s2, pos2); + v = interpolation_linear(pos, v1, pos1, v2, pos2); + a = interpolation_linear(pos, a1, pos1, a2, pos2); + + if(ramp_hue_interpolation == C_RAMP_HUE_CLOCKWISE && h1 < h2) h1 += 6.f; + else if(ramp_hue_interpolation == C_RAMP_HUE_COUNTERCLOCKWISE && h1 > h2) h2 += 6.f; + else if(ramp_hue_interpolation == C_RAMP_HUE_NEAR && h1 < h2 && (h2 - h1) > 3.f) h1 += 6.f; + else if(ramp_hue_interpolation == C_RAMP_HUE_NEAR && h1 > h2 && (h2 - h1) < -3.f) h2 += 6.f; + else if(ramp_hue_interpolation == C_RAMP_HUE_FAR && h1 < h2 && (h2 - h1) < 3.f) h1 += 6.f; + else if(ramp_hue_interpolation == C_RAMP_HUE_FAR && h1 > h2 && (h2 - h1) > -3.f) h2 += 6.f; + + h = interpolation_linear(pos, h1, pos1, h2, pos2); + + if(h < 0.f) h += 6.f; + else if(h > 6.f) h -= 6.f; + result.hsv_to_rgb(h, s, v); + result.A = a; + } } return result; } From 0de637e0da50c7e88441ffbd440c9a89c18880c2 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Mon, 11 Jul 2016 10:11:35 +0200 Subject: [PATCH 117/124] Texture Color Ramps - HSL ramps implemented --- include/core_api/color.h | 65 ++++++++++++++++++++++++++++++------ src/yafraycore/color_ramp.cc | 36 ++++++++++++++++++-- 2 files changed, 89 insertions(+), 12 deletions(-) diff --git a/include/core_api/color.h b/include/core_api/color.h index ea2d24f0..51cd2c69 100755 --- a/include/core_api/color.h +++ b/include/core_api/color.h @@ -134,9 +134,11 @@ class YAFRAYCORE_EXPORT color_t void linearRGB_from_ColorSpace(colorSpaces_t colorSpace, float gamma); void ColorSpace_from_linearRGB(colorSpaces_t colorSpace, float gamma); - void rgb_to_hsv(float & h, float & s, float &v) const; - void hsv_to_rgb(const float & h, const float & s, const float &v); - + void rgb_to_hsv(float & h, float & s, float & v) const; + void hsv_to_rgb(const float & h, const float & s, const float & v); + void rgb_to_hsl(float & h, float & s, float & l) const; + void hsl_to_rgb(const float & h, const float & s, const float & l); + // protected: float R, G, B; @@ -495,7 +497,7 @@ inline float colorA_t::colorDifference(colorA_t color2, bool useRGBcomponents) return colorDifference; } -inline void color_t::rgb_to_hsv(float & h, float & s, float &v) const +inline void color_t::rgb_to_hsv(float & h, float & s, float & v) const { //HSV-RGB Based on https://en.wikipedia.org/wiki/HSL_and_HSV#Converting_to_RGB @@ -503,20 +505,21 @@ inline void color_t::rgb_to_hsv(float & h, float & s, float &v) const float G1 = std::max(G, 0.f); float B1 = std::max(B, 0.f); - v = std::max(std::max(R1,G1),B1); + float M = std::max(std::max(R1,G1),B1); float m = std::min(std::min(R1,G1),B1); - float C = v - m; + float C = M - m; + v = M; if(std::fabs(C) < 1.0e-6f) { h = 0.f; s = 0.f; } - else if(v == R1) { h = std::fmod((G1-B1)/C, 6.f); s = C / std::max(v, 1.0e-6f); } - else if(v == G1) { h = ((B1-R1)/C) + 2.f; s = C / std::max(v, 1.0e-6f); } - else if(v == B1) { h = ((R1-G1)/C) + 4.f; s = C / std::max(v, 1.0e-6f); } + else if(M == R1) { h = std::fmod((G1-B1)/C, 6.f); s = C / std::max(v, 1.0e-6f); } + else if(M == G1) { h = ((B1-R1)/C) + 2.f; s = C / std::max(v, 1.0e-6f); } + else if(M == B1) { h = ((R1-G1)/C) + 4.f; s = C / std::max(v, 1.0e-6f); } else { h = 0.f; s = 0.f; v = 0.f; } if(h < 0.f) h += 6.f; } -inline void color_t::hsv_to_rgb(const float & h, const float & s, const float &v) +inline void color_t::hsv_to_rgb(const float & h, const float & s, const float & v) { //RGB-HSV Based on https://en.wikipedia.org/wiki/HSL_and_HSV#Converting_to_RGB float C = v * s; @@ -536,6 +539,48 @@ inline void color_t::hsv_to_rgb(const float & h, const float & s, const float &v B = B1 + m; } +inline void color_t::rgb_to_hsl(float & h, float & s, float & l) const +{ + //hsl-RGB Based on https://en.wikipedia.org/wiki/HSL_and_hsl#Converting_to_RGB + + float R1 = std::max(R, 0.f); + float G1 = std::max(G, 0.f); + float B1 = std::max(B, 0.f); + + float M = std::max(std::max(R1,G1),B1); + float m = std::min(std::min(R1,G1),B1); + float C = M - m; + l = 0.5f * (M + m); + + if(std::fabs(C) < 1.0e-6f) { h = 0.f; s = 0.f; } + else if(M == R1) { h = std::fmod((G1-B1)/C, 6.f); s = C / std::max((1.f - std::fabs((2.f * l) - 1)), 1.0e-6f); } + else if(M == G1) { h = ((B1-R1)/C) + 2.f; s = C / std::max((1.f - std::fabs((2.f * l) - 1)), 1.0e-6f); } + else if(M == B1) { h = ((R1-G1)/C) + 4.f; s = C / std::max((1.f - std::fabs((2.f * l) - 1)), 1.0e-6f); } + else { h = 0.f; s = 0.f; l = 0.f; } + + if(h < 0.f) h += 6.f; +} + +inline void color_t::hsl_to_rgb(const float & h, const float & s, const float & l) +{ + //RGB-hsl Based on https://en.wikipedia.org/wiki/HSL_and_hsl#Converting_to_RGB + float C = (1.f - std::fabs((2.f * l) - 1.f)) * s; + float X = C * (1.f - std::fabs(std::fmod(h, 2.f) - 1.f)); + float m = l - 0.5f * C; + float R1 = 0.f, G1 = 0.f, B1 = 0.f; + + if(h >= 0.f && h < 1.f) { R1 = C; G1 = X; B1 = 0.f; } + else if(h >= 1.f && h < 2.f) { R1 = X; G1 = C; B1 = 0.f; } + else if(h >= 2.f && h < 3.f) { R1 = 0.f; G1 = C; B1 = X; } + else if(h >= 3.f && h < 4.f) { R1 = 0.f; G1 = X; B1 = C; } + else if(h >= 4.f && h < 5.f) { R1 = X; G1 = 0.f; B1 = C; } + else if(h >= 5.f && h < 6.f) { R1 = C; G1 = 0.f; B1 = X; } + + R = R1 + m; + G = G1 + m; + B = B1 + m; +} + __END_YAFRAY #endif // Y_COLOR_H diff --git a/src/yafraycore/color_ramp.cc b/src/yafraycore/color_ramp.cc index ca861c92..5c527bdc 100755 --- a/src/yafraycore/color_ramp.cc +++ b/src/yafraycore/color_ramp.cc @@ -34,7 +34,7 @@ color_ramp_t::color_ramp_t(std::string modeStr, std::string interpolationStr, st Y_DEBUG << "modeStr='"<color; else result = interpolation_linear(pos, item_current->color, item_current->position, item_previous->color, item_previous->position); } - else if(ramp_mode == C_RAMP_HSV || ramp_mode == C_RAMP_HSL) //HSL not yet supported, using HSV instead + else if(ramp_mode == C_RAMP_HSV) { float pos1 = item_current->position; float pos2 = item_previous->position; @@ -124,6 +124,38 @@ colorA_t color_ramp_t::get_color_interpolated(float pos) const result.hsv_to_rgb(h, s, v); result.A = a; } + else if(ramp_mode == C_RAMP_HSL) + { + float pos1 = item_current->position; + float pos2 = item_previous->position; + float h1=0.f, s1=0.f, l1=0.f, a1=0.f; + float h2=0.f, s2=0.f, l2=0.f, a2=0.f; + float h=0.f, s=0.f, l=0.f, a=0.f; + + item_current->color.rgb_to_hsl(h1, s1, l1); + a1 = item_current->color.A; + + item_previous->color.rgb_to_hsl(h2, s2, l2); + a2 = item_previous->color.A; + + s = interpolation_linear(pos, s1, pos1, s2, pos2); + l = interpolation_linear(pos, l1, pos1, l2, pos2); + a = interpolation_linear(pos, a1, pos1, a2, pos2); + + if(ramp_hue_interpolation == C_RAMP_HUE_CLOCKWISE && h1 < h2) h1 += 6.f; + else if(ramp_hue_interpolation == C_RAMP_HUE_COUNTERCLOCKWISE && h1 > h2) h2 += 6.f; + else if(ramp_hue_interpolation == C_RAMP_HUE_NEAR && h1 < h2 && (h2 - h1) > 3.f) h1 += 6.f; + else if(ramp_hue_interpolation == C_RAMP_HUE_NEAR && h1 > h2 && (h2 - h1) < -3.f) h2 += 6.f; + else if(ramp_hue_interpolation == C_RAMP_HUE_FAR && h1 < h2 && (h2 - h1) < 3.f) h1 += 6.f; + else if(ramp_hue_interpolation == C_RAMP_HUE_FAR && h1 > h2 && (h2 - h1) > -3.f) h2 += 6.f; + + h = interpolation_linear(pos, h1, pos1, h2, pos2); + + if(h < 0.f) h += 6.f; + else if(h > 6.f) h -= 6.f; + result.hsv_to_rgb(h, s, l); + result.A = a; + } } return result; } From a265aed5bbae9197fb507df265a90ac9edd1292d Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Mon, 11 Jul 2016 18:48:58 +0200 Subject: [PATCH 118/124] Blend Texture: implemented all progressions and X/Y flip --- include/textures/basictex.h | 16 ++++++++- src/textures/basictex.cc | 72 ++++++++++++++++++++++++++++++++----- 2 files changed, 78 insertions(+), 10 deletions(-) diff --git a/include/textures/basictex.h b/include/textures/basictex.h index dfd3151e..942861e5 100755 --- a/include/textures/basictex.h +++ b/include/textures/basictex.h @@ -170,17 +170,31 @@ class rgbCube_t : public texture_t static texture_t *factory(paraMap_t ¶ms,renderEnvironment_t &render); }; +enum blendProgressionType_t +{ + TEX_BLEND_LINEAR, + TEX_BLEND_QUADRATIC, + TEX_BLEND_EASING, + TEX_BLEND_DIAGONAL, + TEX_BLEND_SPHERICAL, + TEX_BLEND_QUADRATIC_SPHERE, + TEX_BLEND_RADIAL, +}; class textureBlend_t : public texture_t { public: - textureBlend_t(const std::string &stype); + textureBlend_t(const std::string &stype, bool use_flip_axis); virtual ~textureBlend_t(); virtual colorA_t getColor(const point3d_t &p, bool from_postprocessed=false) const; virtual float getFloat(const point3d_t &p) const; static texture_t *factory(paraMap_t ¶ms, renderEnvironment_t &render); + + protected: + int blendProgressionType = TEX_BLEND_LINEAR; + bool m_use_flip_axis = false; }; __END_YAFRAY diff --git a/src/textures/basictex.cc b/src/textures/basictex.cc index 2d4791b6..d836879f 100755 --- a/src/textures/basictex.cc +++ b/src/textures/basictex.cc @@ -654,9 +654,19 @@ texture_t *textureDistortedNoise_t::factory(paraMap_t ¶ms, renderEnvironment // Blend Texture //----------------------------------------------------------------------------------------- -textureBlend_t::textureBlend_t(const std::string &stype) + +textureBlend_t::textureBlend_t(const std::string &stype, bool use_flip_axis) { - // TODO: Blend Types + m_use_flip_axis = use_flip_axis; + + if(stype == "lin") blendProgressionType = TEX_BLEND_LINEAR; + else if(stype == "quad") blendProgressionType = TEX_BLEND_QUADRATIC; + else if(stype == "ease") blendProgressionType = TEX_BLEND_EASING; + else if(stype == "diag") blendProgressionType = TEX_BLEND_DIAGONAL; + else if(stype == "sphere") blendProgressionType = TEX_BLEND_SPHERICAL; + else if(stype == "halo" || stype == "quad_sphere") blendProgressionType = TEX_BLEND_QUADRATIC_SPHERE; + else if(stype == "radial") blendProgressionType = TEX_BLEND_RADIAL; + else blendProgressionType = TEX_BLEND_LINEAR; } textureBlend_t::~textureBlend_t() @@ -665,12 +675,56 @@ textureBlend_t::~textureBlend_t() float textureBlend_t::getFloat(const point3d_t &p) const { - float blend; - // Transform -1..1 to 0..1 - blend = 0.5 * ( p.x + 1. ); + float blend = 0.f; + + float coord1 = p.x; + float coord2 = p.y; + + if(m_use_flip_axis) + { + coord1 = p.y; + coord2 = p.x; + } + + if(blendProgressionType == TEX_BLEND_QUADRATIC) + { + // Transform -1..1 to 0..1 + blend = 0.5f * ( coord1 + 1.f ); + if(blend < 0.f) blend = 0.f; + else blend *= blend; + } + else if(blendProgressionType == TEX_BLEND_EASING) + { + blend = 0.5f * ( coord1 + 1.f ); + if(blend <= 0.f) blend = 0.f; + else if(blend >= 1.f) blend = 1.f; + else + { + blend = (3.f * blend * blend - 2.f * blend * blend * blend); + } + } + else if(blendProgressionType == TEX_BLEND_DIAGONAL) + { + blend = 0.25f * (2.f + coord1 + coord2); + } + else if(blendProgressionType == TEX_BLEND_SPHERICAL || blendProgressionType == TEX_BLEND_QUADRATIC_SPHERE) + { + blend = 1.f - fSqrt(coord1 * coord1 + coord2 * coord2 + p.z * p.z); + if(blend < 0.f) blend = 0.f; + if(blendProgressionType == TEX_BLEND_QUADRATIC_SPHERE) blend *= blend; + } + else if(blendProgressionType == TEX_BLEND_RADIAL) + { + blend = (atan2f(coord2, coord1) / (float)(2.f * M_PI) + 0.5f); + } + else //linear by default + { + // Transform -1..1 to 0..1 + blend = 0.5f * ( coord1 + 1.f ); + } // Clipping to 0..1 blend = std::max(0.f, std::min(blend, 1.f)); - + return applyAdjustmentsFloat(blend); } @@ -684,16 +738,16 @@ texture_t *textureBlend_t::factory(paraMap_t ¶ms, renderEnvironment_t &rende { std::string _stype; const std::string *stype=&_stype; - //bool invertXY = false; float intensity = 1.f, contrast = 1.f, saturation = 1.f, hue = 0.f, factor_red = 1.f, factor_green = 1.f, factor_blue = 1.f; bool clamp = false; bool use_color_ramp = false; + bool use_flip_axis = false; params.getParam("stype", _stype); params.getParam("use_color_ramp", use_color_ramp); - //params.getParam("invertXY", invertXY); + params.getParam("use_flip_axis", use_flip_axis); - textureBlend_t * tex = new textureBlend_t(*stype); + textureBlend_t * tex = new textureBlend_t(*stype, use_flip_axis); tex->setAdjustments(intensity, contrast, saturation, hue, clamp, factor_red, factor_green, factor_blue); if(use_color_ramp) textureReadColorRamp(params, tex); From 70c4dccd3f73ed1e1d57dd7899d25f2e871e987f Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Mon, 11 Jul 2016 22:19:15 +0200 Subject: [PATCH 119/124] Texture Color Adjustments: modified to be able to apply color adjustments to the output of the Texture Ramp calculations. More powerful and flexible than Blender Internal, for example. --- include/core_api/texture.h | 33 ++++++++++++++++++++------ src/textures/basictex.cc | 48 +++++++++++++++++++------------------- src/textures/imagetex.cc | 4 ++-- 3 files changed, 52 insertions(+), 33 deletions(-) diff --git a/include/core_api/texture.h b/include/core_api/texture.h index 028248f4..9b9bbd8c 100755 --- a/include/core_api/texture.h +++ b/include/core_api/texture.h @@ -20,16 +20,18 @@ class YAFRAYCORE_EXPORT texture_t virtual colorA_t getColor(int x, int y, int z, bool from_postprocessed=false) const { return colorA_t(0.f); } virtual colorA_t getRawColor(const point3d_t &p, bool from_postprocessed=false) const { return getColor(p, from_postprocessed); } virtual colorA_t getRawColor(int x, int y, int z, bool from_postprocessed=false) const { return getColor(x, y, z, from_postprocessed); } - virtual float getFloat(const point3d_t &p) const { return applyAdjustmentsFloat(getRawColor(p).col2bri()); } - virtual float getFloat(int x, int y, int z) const { return applyAdjustmentsFloat(getRawColor(x, y, z).col2bri()); } + virtual float getFloat(const point3d_t &p) const { return applyIntensityContrastAdjustments(getRawColor(p).col2bri()); } + virtual float getFloat(int x, int y, int z) const { return applyIntensityContrastAdjustments(getRawColor(x, y, z).col2bri()); } /* gives the number of values in each dimension for discrete textures */ virtual void resolution(int &x, int &y, int &z) const { x=0, y=0, z=0; } virtual void getInterpolationStep(float &step) const { step = 0.f; }; virtual void postProcessedCreate() { }; virtual void postProcessedBlur(float blur_factor) { }; void setAdjustments(float intensity, float contrast, float saturation, float hue, bool clamp, float factor_red, float factor_green, float factor_blue); - colorA_t applyAdjustmentsColor(const colorA_t & texCol) const; - float applyAdjustmentsFloat(float texFloat) const; + colorA_t applyAdjustments(const colorA_t & texCol) const; + colorA_t applyIntensityContrastAdjustments(const colorA_t & texCol) const; + float applyIntensityContrastAdjustments(float texFloat) const; + colorA_t applyColorAdjustments(const colorA_t & texCol) const; void colorRampCreate(std::string modeStr, std::string interpolationStr, std::string hue_interpolationStr) { color_ramp = new color_ramp_t(modeStr, interpolationStr, hue_interpolationStr); } void colorRampAddItem(colorA_t color, float position) { color_ramp->add_item(color, position); } virtual ~texture_t() { if(color_ramp) { delete color_ramp; color_ramp = nullptr; } } @@ -165,7 +167,13 @@ inline void texture_t::setAdjustments(float intensity, float contrast, float sat } } -inline colorA_t texture_t::applyAdjustmentsColor(const colorA_t & texCol) const +inline colorA_t texture_t::applyAdjustments(const colorA_t & texCol) const +{ + if(!adjustments_set) return texCol; + else return applyColorAdjustments(applyIntensityContrastAdjustments(texCol)); +} + +inline colorA_t texture_t::applyIntensityContrastAdjustments(const colorA_t & texCol) const { if(!adjustments_set) return texCol; @@ -178,6 +186,17 @@ inline colorA_t texture_t::applyAdjustmentsColor(const colorA_t & texCol) const ret.B = (texCol.B-0.5f) * adj_contrast + adj_intensity-0.5f; } + if(adj_clamp) ret.clampRGB0(); + + return ret; +} + +inline colorA_t texture_t::applyColorAdjustments(const colorA_t & texCol) const +{ + if(!adjustments_set) return texCol; + + colorA_t ret = texCol; + if(adj_mult_factor_red != 1.f) ret.R *= adj_mult_factor_red; if(adj_mult_factor_green != 1.f) ret.G *= adj_mult_factor_green; if(adj_mult_factor_blue != 1.f) ret.B *= adj_mult_factor_blue; @@ -199,9 +218,9 @@ inline colorA_t texture_t::applyAdjustmentsColor(const colorA_t & texCol) const return ret; } -inline float texture_t::applyAdjustmentsFloat(float texFloat) const +inline float texture_t::applyIntensityContrastAdjustments(float texFloat) const { - if(adj_intensity == 1.f && adj_contrast == 1.f) return texFloat; + if(!adjustments_set) return texFloat; float ret = texFloat; diff --git a/src/textures/basictex.cc b/src/textures/basictex.cc index d836879f..0e161eee 100755 --- a/src/textures/basictex.cc +++ b/src/textures/basictex.cc @@ -100,13 +100,13 @@ float textureClouds_t::getFloat(const point3d_t &p) const v *= v; if (bias==1) return -v; // !!! } - return applyAdjustmentsFloat(v); + return applyIntensityContrastAdjustments(v); } colorA_t textureClouds_t::getColor(const point3d_t &p, bool from_postprocessed) const { - if(!color_ramp) return color1 + getFloat(p)*(color2 - color1); - else return color_ramp->get_color_interpolated(getFloat(p)); + if(!color_ramp) return applyColorAdjustments(color1 + getFloat(p)*(color2 - color1)); + else return applyColorAdjustments(color_ramp->get_color_interpolated(getFloat(p))); } texture_t *textureClouds_t::factory(paraMap_t ¶ms, @@ -182,13 +182,13 @@ float textureMarble_t::getFloat(const point3d_t &p) const case SIN: w = (float)0.5 + (float)0.5*fSin(w); } - return applyAdjustmentsFloat(fPow(w, sharpness)); + return applyIntensityContrastAdjustments(fPow(w, sharpness)); } colorA_t textureMarble_t::getColor(const point3d_t &p, bool from_postprocessed) const { - if(!color_ramp) return color1 + getFloat(p)*(color2 - color1); - else return color_ramp->get_color_interpolated(getFloat(p)); + if(!color_ramp) return applyColorAdjustments(color1 + getFloat(p)*(color2 - color1)); + else return applyColorAdjustments(color_ramp->get_color_interpolated(getFloat(p))); } texture_t *textureMarble_t::factory(paraMap_t ¶ms, @@ -268,13 +268,13 @@ float textureWood_t::getFloat(const point3d_t &p) const case SIN: w = (float)0.5 + (float)0.5*fSin(w); } - return applyAdjustmentsFloat(w); + return applyIntensityContrastAdjustments(w); } colorA_t textureWood_t::getColor(const point3d_t &p, bool from_postprocessed) const { - if(!color_ramp) return color1 + getFloat(p)*(color2 - color1); - else return color_ramp->get_color_interpolated(getFloat(p)); + if(!color_ramp) return applyColorAdjustments(color1 + getFloat(p)*(color2 - color1)); + else return applyColorAdjustments(color_ramp->get_color_interpolated(getFloat(p))); } texture_t *textureWood_t::factory(paraMap_t ¶ms, @@ -330,7 +330,7 @@ colorA_t rgbCube_t::getColor(const point3d_t &p, bool from_postprocessed) const colorA_t col = colorA_t(p.x, p.y, p.z); col.clampRGB01(); - if(adjustments_set) return applyAdjustmentsColor(col); + if(adjustments_set) return applyAdjustments(col); else return col; } @@ -338,7 +338,7 @@ float rgbCube_t::getFloat(const point3d_t &p) const { color_t col = color_t(p.x, p.y, p.z); col.clampRGB01(); - return applyAdjustmentsFloat(col.energy()); + return applyIntensityContrastAdjustments(col.energy()); } texture_t* rgbCube_t::factory(paraMap_t ¶ms,renderEnvironment_t &render) @@ -404,7 +404,7 @@ float textureVoronoi_t::getFloat(const point3d_t &p) const float da[4]; point3d_t pa[4]; vGen.getFeatures(p*size, da, pa); - return applyAdjustmentsFloat(iscale * std::fabs(w1*vGen.getDistance(0, da) + w2*vGen.getDistance(1, da) + return applyIntensityContrastAdjustments(iscale * std::fabs(w1*vGen.getDistance(0, da) + w2*vGen.getDistance(1, da) + w3*vGen.getDistance(2, da) + w4*vGen.getDistance(3, da))); } @@ -416,7 +416,7 @@ colorA_t textureVoronoi_t::getColor(const point3d_t &p, bool from_postprocessed) float inte = iscale * std::fabs(w1*vGen.getDistance(0, da) + w2*vGen.getDistance(1, da) + w3*vGen.getDistance(2, da) + w4*vGen.getDistance(3, da)); colorA_t col(0.0); - if(color_ramp) return color_ramp->get_color_interpolated(inte); + if(color_ramp) return applyColorAdjustments(color_ramp->get_color_interpolated(inte)); else if (coltype) { col += aw1 * cellNoiseColor(vGen.getPoint(0, pa)); col += aw2 * cellNoiseColor(vGen.getPoint(1, pa)); @@ -429,9 +429,9 @@ colorA_t textureVoronoi_t::getColor(const point3d_t &p, bool from_postprocessed) col *= t1; } else col *= iscale; - return applyAdjustmentsColor(col); + return applyAdjustments(col); } - else return colorA_t(inte, inte, inte, inte); + else return applyColorAdjustments(colorA_t(inte, inte, inte, inte)); } texture_t *textureVoronoi_t::factory(paraMap_t ¶ms, renderEnvironment_t &render) @@ -522,13 +522,13 @@ textureMusgrave_t::~textureMusgrave_t() float textureMusgrave_t::getFloat(const point3d_t &p) const { - return applyAdjustmentsFloat(iscale * (*mGen)(p*size)); + return applyIntensityContrastAdjustments(iscale * (*mGen)(p*size)); } colorA_t textureMusgrave_t::getColor(const point3d_t &p, bool from_postprocessed) const { - if(!color_ramp) return color1 + getFloat(p)*(color2 - color1); - else return color_ramp->get_color_interpolated(getFloat(p)); + if(!color_ramp) return applyColorAdjustments(color1 + getFloat(p)*(color2 - color1)); + else return applyColorAdjustments(color_ramp->get_color_interpolated(getFloat(p))); } texture_t *textureMusgrave_t::factory(paraMap_t ¶ms, renderEnvironment_t &render) @@ -604,13 +604,13 @@ float textureDistortedNoise_t::getFloat(const point3d_t &p) const const point3d_t ofs(13.5, 13.5, 13.5); point3d_t tp(p*size); point3d_t rv(getSignedNoise(nGen1, tp+ofs), getSignedNoise(nGen1, tp), getSignedNoise(nGen1, tp-ofs)); - return applyAdjustmentsFloat(getSignedNoise(nGen2, tp+rv*distort)); // distorted-domain noise + return applyIntensityContrastAdjustments(getSignedNoise(nGen2, tp+rv*distort)); // distorted-domain noise } colorA_t textureDistortedNoise_t::getColor(const point3d_t &p, bool from_postprocessed) const { - if(!color_ramp) return color1 + getFloat(p)*(color2 - color1); - else return color_ramp->get_color_interpolated(getFloat(p)); + if(!color_ramp) return applyColorAdjustments(color1 + getFloat(p)*(color2 - color1)); + else return applyColorAdjustments(color_ramp->get_color_interpolated(getFloat(p))); } texture_t *textureDistortedNoise_t::factory(paraMap_t ¶ms, renderEnvironment_t &render) @@ -725,13 +725,13 @@ float textureBlend_t::getFloat(const point3d_t &p) const // Clipping to 0..1 blend = std::max(0.f, std::min(blend, 1.f)); - return applyAdjustmentsFloat(blend); + return applyIntensityContrastAdjustments(blend); } colorA_t textureBlend_t::getColor(const point3d_t &p, bool from_postprocessed) const { - if(!color_ramp) return colorA_t(1.f); - else return color_ramp->get_color_interpolated(getFloat(p)); + if(!color_ramp) return applyColorAdjustments(color_t(getFloat(p))); + else return applyColorAdjustments(color_ramp->get_color_interpolated(getFloat(p))); } texture_t *textureBlend_t::factory(paraMap_t ¶ms, renderEnvironment_t &render) diff --git a/src/textures/imagetex.cc b/src/textures/imagetex.cc index b160ade1..a1597efb 100755 --- a/src/textures/imagetex.cc +++ b/src/textures/imagetex.cc @@ -160,7 +160,7 @@ colorA_t textureImage_t::getColor(const point3d_t &p, bool from_postprocessed) c colorA_t ret = getRawColor(p, from_postprocessed); ret.linearRGB_from_ColorSpace(colorSpace, gamma); - return applyAdjustmentsColor(ret); + return applyAdjustments(ret); } colorA_t textureImage_t::getRawColor(const point3d_t &p, bool from_postprocessed) const @@ -182,7 +182,7 @@ colorA_t textureImage_t::getColor(int x, int y, int z, bool from_postprocessed) colorA_t ret = getRawColor(x, y, z, from_postprocessed); ret.linearRGB_from_ColorSpace(colorSpace, gamma); - return applyAdjustmentsColor(ret); + return applyAdjustments(ret); } colorA_t textureImage_t::getRawColor(int x, int y, int z, bool from_postprocessed) const From 623f07ffe1239459b33d7194c920a440b863c644 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Mon, 11 Jul 2016 22:48:43 +0200 Subject: [PATCH 120/124] CMake: add "-DEBUG" automatically to the version string when building a debug version, to avoid releasing/testing debug builds by mistake --- CMakeConfig/GenConfHeaders.txt | 3 +++ CMakeConfig/templates/yaf_version.h.cmake | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeConfig/GenConfHeaders.txt b/CMakeConfig/GenConfHeaders.txt index 4cba421f..4156c188 100755 --- a/CMakeConfig/GenConfHeaders.txt +++ b/CMakeConfig/GenConfHeaders.txt @@ -3,6 +3,9 @@ if(NOT YAFARAY_CORE_VERSION) set(YAFARAY_CORE_VERSION "(devel)") endif(NOT YAFARAY_CORE_VERSION) +if(DEBUG_BUILD STREQUAL "ON") + set(DEBUG "-DEBUG") +endif(DEBUG_BUILD STREQUAL "ON") include(CheckIncludeFiles) check_include_files(unistd.h HAVE_UNISTD_H) diff --git a/CMakeConfig/templates/yaf_version.h.cmake b/CMakeConfig/templates/yaf_version.h.cmake index 27c687b8..48e07a08 100755 --- a/CMakeConfig/templates/yaf_version.h.cmake +++ b/CMakeConfig/templates/yaf_version.h.cmake @@ -7,5 +7,5 @@ #ifndef Y_VERSION_H #define Y_VERSION_H -#define YAFARAY_CORE_VERSION "@YAFARAY_CORE_VERSION@" +#define YAFARAY_CORE_VERSION "@YAFARAY_CORE_VERSION@@DEBUG@" #endif From 195169e9d7078d490d522d41f541468025713189 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Tue, 12 Jul 2016 09:58:11 +0200 Subject: [PATCH 121/124] Texture nodes - make code more clear. (do_scalar<0) is confusing, weird and always false anyway, so I've removed it --- include/core_api/shader.h | 2 +- src/textures/layernode.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/core_api/shader.h b/include/core_api/shader.h index 16d19582..11509c7d 100755 --- a/include/core_api/shader.h +++ b/include/core_api/shader.h @@ -150,7 +150,7 @@ inline color_t texture_rgb_blend(const color_t &tex, const color_t &out, float f } -inline float texture_value_blend(float tex, float out, float fact, float facg, mix_modes blendtype, bool flip) +inline float texture_value_blend(float tex, float out, float fact, float facg, mix_modes blendtype, bool flip=false) { fact *= facg; float facm = 1.f-fact; diff --git a/src/textures/layernode.cc b/src/textures/layernode.cc index a55fc23b..2d87b634 100755 --- a/src/textures/layernode.cc +++ b/src/textures/layernode.cc @@ -89,7 +89,7 @@ void layerNode_t::eval(nodeStack_t &stack, const renderState_t &state, const sur } } - rval = texture_value_blend(default_val, rval, Tin, stencilTin * valfac, mode, (do_scalar<0)); + rval = texture_value_blend(default_val, rval, Tin, stencilTin * valfac, mode); if(rval<0.f) rval=0.f; } rcol.A = stencilTin; From 8c92ea656067d322d3ef2fd2e301c89f5784eaf1 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Tue, 12 Jul 2016 13:28:26 +0200 Subject: [PATCH 122/124] ImageFilm tile splitter: a bit more clever tile subdivision --- src/yafraycore/imagesplitter.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/yafraycore/imagesplitter.cc b/src/yafraycore/imagesplitter.cc index 68e62fcf..852cec48 100755 --- a/src/yafraycore/imagesplitter.cc +++ b/src/yafraycore/imagesplitter.cc @@ -43,13 +43,15 @@ imageSpliter_t::imageSpliter_t(int w, int h, int x0,int y0, int bsize, tilesOrde for(size_t rn=0; rnregions_raw.size()-nthreads) blocksize2 = std::max(4, blocksize / 4); + else if(rn<=regions_raw.size()-nthreads) blocksize2 = std::max(4, blocksize / 2); int nx2, ny2; nx2 = (regions_raw[rn].w+blocksize2-1)/blocksize2; ny2 = (regions_raw[rn].h+blocksize2-1)/blocksize2; From 2fb51effe0aea4809dd39254c79b014c198c9705 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Tue, 12 Jul 2016 14:55:22 +0200 Subject: [PATCH 123/124] Badge/Logging: add Tile Size to the badge AA information --- include/core_api/imagefilm.h | 1 + src/yafraycore/environment.cc | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/core_api/imagefilm.h b/include/core_api/imagefilm.h index 1eb4f690..119c8dd1 100755 --- a/include/core_api/imagefilm.h +++ b/include/core_api/imagefilm.h @@ -140,6 +140,7 @@ class YAFRAYCORE_EXPORT imageFilm_t float dark_threshold_curve_interpolate(float pixel_brightness); int getWidth() const { return w; } int getHeight() const { return h; } + int getTileSize() const { return tileSize; } int getCurrentPass() const { return nPass; } int getNumPasses() const { return nPasses; } unsigned int getComputerNode() const { return computerNode; } diff --git a/src/yafraycore/environment.cc b/src/yafraycore/environment.cc index fa3a5733..d2de9cb5 100755 --- a/src/yafraycore/environment.cc +++ b/src/yafraycore/environment.cc @@ -862,7 +862,7 @@ bool renderEnvironment_t::setupScene(scene_t &scene, const paraMap_t ¶ms, co params.getParam("filter_type", name); // AA filter type std::stringstream aaSettings; - aaSettings << "AA Settings (" << ((name)?*name:"box") << "):"; + aaSettings << "AA Settings (" << ((name)?*name:"box") << "): Tile size=" << film->getTileSize(); yafLog.appendAANoiseSettings(aaSettings.str()); if(AA_dark_detection_type_string == "linear") AA_dark_detection_type = DARK_DETECTION_LINEAR; From d53dd1a4005483503c04e1afc1c7ac2fd7ab0e1d Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Tue, 12 Jul 2016 16:35:00 +0200 Subject: [PATCH 124/124] Swig: updated public interface --- src/bindings/yafaray_v3_interface.i | 82 +++++++++-------------------- 1 file changed, 26 insertions(+), 56 deletions(-) diff --git a/src/bindings/yafaray_v3_interface.i b/src/bindings/yafaray_v3_interface.i index 439d2521..cbea77f6 100755 --- a/src/bindings/yafaray_v3_interface.i +++ b/src/bindings/yafaray_v3_interface.i @@ -584,10 +584,14 @@ namespace yafaray { public: virtual ~colorOutput_t() {}; + virtual void initTilesPasses(int totalViews, int numExtPasses) {}; virtual bool putPixel(int numView, int x, int y, const renderPasses_t *renderPasses, const std::vector &colExtPasses, bool alpha = true)=0; virtual void flush(int numView, const renderPasses_t *renderPasses)=0; virtual void flushArea(int numView, int x0, int y0, int x1, int y1, const renderPasses_t *renderPasses)=0; virtual void highliteArea(int numView, int x0, int y0, int x1, int y1){}; + virtual bool isImageOutput() { return false; } + virtual bool isPreview() { return false; } + virtual std::string getDenoiseParams() const { return ""; } }; class imageHandler_t @@ -610,22 +614,13 @@ namespace yafaray int getTextureOptimization() { return m_textureOptimization; } void setTextureOptimization(int texture_optimization) { m_textureOptimization = texture_optimization; } virtual bool denoiseEnabled() { return m_Denoise; } - - protected: - std::string handlerName; - int m_width; - int m_height; - bool m_hasAlpha; - int m_textureOptimization; - std::vector imagePasses; //!< rgba color buffers for the additional render passes - rgbaOptimizedImage_nw_t *rgbaOptimizedBuffer; //!< optimized RGBA (32bit/pixel) with alpha buffer - rgbaCompressedImage_nw_t *rgbaCompressedBuffer; //!< compressed RGBA (24bit/pixel) LOSSY! with alpha buffer - rgbOptimizedImage_nw_t *rgbOptimizedBuffer; //!< optimized RGB (24bit/pixel) without alpha buffer - rgbCompressedImage_nw_t *rgbCompressedBuffer; //!< compressed RGB (16bit/pixel) LOSSY! without alpha buffer - bool m_MultiLayer = false; - bool m_Denoise = false; - int m_DenoiseHLum = 3; - int m_DenoiseHCol = 3; + std::string getDenoiseParams() const + { + if(!m_Denoise) return ""; + std::stringstream paramString; + paramString << "| Image file denoise enabled [mix=" << m_DenoiseMix << ", h(Luminance)=" << m_DenoiseHLum << ", h(Chrominance)=" << m_DenoiseHCol << "]" << yendl; + return paramString.str(); + } }; // Outputs @@ -638,12 +633,15 @@ namespace yafaray virtual ~imageOutput_t(); virtual bool putPixel(int numView, int x, int y, const renderPasses_t *renderPasses, const std::vector &colExtPasses, bool alpha = true); virtual void flush(int numView, const renderPasses_t *renderPasses); - virtual void flushArea(int numView, int x0, int y0, int x1, int y1, const renderPasses_t *renderPasses) {}; // not used by images... yet - private: - imageHandler_t *image; - std::string fname; - float bX; - float bY; + virtual void flushArea(int numView, int x0, int y0, int x1, int y1, const renderPasses_t *renderPasses) {} // not used by images... yet + virtual bool isImageOutput() { return true; } + virtual std::string getDenoiseParams() const + { + if(image) return image->getDenoiseParams(); + else return ""; + } + void saveImageFile(std::string filename, int idx); + void saveImageFileMultiChannel(std::string filename, const renderPasses_t *renderPasses); }; class memoryIO_t : public colorOutput_t @@ -654,9 +652,6 @@ namespace yafaray void flush(int numView, const renderPasses_t *renderPasses); virtual void flushArea(int numView, int x0, int y0, int x1, int y1, const renderPasses_t *renderPasses) {}; // no tiled file format used...yet virtual ~memoryIO_t(); - protected: - int sizex, sizey; - float* imageMem; }; // Utility classes @@ -687,17 +682,12 @@ namespace yafaray void setVal(int row, int col, float val) { matrix[row][col] = val; - }; + } float getVal(int row, int col) { return matrix[row][col]; - }; - - protected: - - float matrix[4][4]; - int _invalid; + } }; // Interfaces @@ -788,16 +778,6 @@ namespace yafaray void setInputColorSpace(std::string color_space_string, float gammaVal); void setOutput2(colorOutput_t *out2); - - protected: - paraMap_t *params; - std::list *eparams; //! for materials that need to define a whole shader tree etc. - paraMap_t *cparams; //! just a pointer to the current paramMap, either params or a eparams element - renderEnvironment_t *env; - scene_t *scene; - imageFilm_t *film; - float inputGamma; - colorSpaces_t inputColorSpace; }; class xmlInterface_t: public yafrayInterface_t @@ -806,6 +786,7 @@ namespace yafaray xmlInterface_t(); // directly related to scene_t: virtual void loadPlugins(const char *path); + virtual bool setLoggingAndBadgeSettings(); virtual bool setupRenderPasses(); //!< setup render passes information virtual bool startGeometry(); virtual bool endGeometry(); @@ -834,23 +815,12 @@ namespace yafaray virtual VolumeRegion* createVolumeRegion (const char* name); virtual unsigned int createObject (const char* name); virtual void clearAll(); //!< clear the whole environment + scene, i.e. free (hopefully) all memory. - virtual void render(colorOutput_t &output); //!< render the scene... + virtual void render(colorOutput_t &output, progressBar_t *pb = nullptr); //!< render the scene... virtual bool startScene(int type=0); //!< start a new scene; Must be called before any of the scene_t related callbacks! + virtual void setOutfile(const char *fname); - void xmlInterface_t::setXMLColorSpace(std::string color_space_string, float gammaVal); - protected: - void writeParamMap(const paraMap_t &pmap, int indent=1); - void writeParamList(int indent); - std::map materials; - std::ofstream xmlFile; - std::string xmlName; - const material_t *last_mat; - size_t nmat; - int n_uvs; - unsigned int nextObj; - float XMLGamma; - colorSpaces_t XMLColorSpace; + void setXMLColorSpace(std::string color_space_string, float gammaVal); }; }