├── .gitignore ├── AUTHORS.md ├── CHANGELOG.md ├── CMakeConfig ├── CPackConfig.txt ├── GenConfHeaders.txt ├── UserConfig.template └── templates │ └── yafray_config.h.cmake ├── CMakeLists.txt ├── CMakeModules ├── FindOpenEXR.cmake ├── FindYafPythonLibs.cmake ├── FindYafSWIG.cmake └── UseYafSWIG.cmake ├── CODING.md ├── INSTALL.md ├── LICENSES ├── README.md ├── building └── linux │ ├── OpenSUSE Leap 42.1 building - Blender AddOn.txt │ ├── OpenSUSE Leap 42.1 building - Standalone.txt │ ├── YafaRay Debian Testing building - Blender AddOn.txt │ ├── YafaRay Debian Testing building - Standalone.txt │ ├── YafaRay Ubuntu 16.04 building - Blender AddOn.txt │ ├── YafaRay Ubuntu 16.04 building - Standalone.txt │ ├── YafaRay Ubuntu 16.10 building - Blender AddOn.txt │ └── YafaRay Ubuntu 16.10 building - Standalone.txt ├── include ├── cameras │ ├── angularCamera.h │ ├── architectCamera.h │ ├── equirectangularCamera.h │ ├── orthographicCamera.h │ └── perspectiveCamera.h ├── core_api │ ├── background.h │ ├── bound.h │ ├── camera.h │ ├── color.h │ ├── color_console.h │ ├── color_ramp.h │ ├── dynamic_library.h │ ├── environment.h │ ├── file.h │ ├── imagefilm.h │ ├── imagehandler.h │ ├── imagesplitter.h │ ├── integrator.h │ ├── light.h │ ├── logging.h │ ├── material.h │ ├── matrix4.h │ ├── mcintegrator.h │ ├── object3d.h │ ├── output.h │ ├── params.h │ ├── primitive.h │ ├── ray.h │ ├── renderpasses.h │ ├── scene.h │ ├── session.h │ ├── shader.h │ ├── surface.h │ ├── sysinfo.h │ ├── texture.h │ ├── tiledintegrator.h │ ├── vector3d.h │ └── volume.h ├── gui │ └── yafqtapi.h ├── integrators │ ├── bidirpath.h │ ├── directlight.h │ ├── integr_utils.h │ ├── pathtracer.h │ ├── photonintegr.h │ └── sppm.h ├── interface │ ├── xmlinterface.h │ └── yafrayinterface.h ├── lights │ ├── arealight.h │ ├── bglight.h │ ├── bgportallight.h │ └── meshlight.h ├── materials │ ├── blendmat.h │ ├── maskmat.h │ ├── microfacet.h │ ├── roughglass.h │ └── shinydiff.h ├── resources │ ├── guifont.h │ ├── qtanim │ │ ├── 00001.h │ │ ├── 00002.h │ │ ├── 00003.h │ │ ├── 00004.h │ │ ├── 00005.h │ │ ├── 00006.h │ │ ├── 00007.h │ │ ├── 00008.h │ │ ├── 00009.h │ │ ├── 00010.h │ │ ├── 00011.h │ │ ├── 00012.h │ │ ├── 00013.h │ │ ├── 00014.h │ │ ├── 00015.h │ │ ├── 00016.h │ │ ├── 00017.h │ │ ├── 00018.h │ │ ├── 00019.h │ │ ├── 00020.h │ │ ├── 00021.h │ │ ├── 00022.h │ │ ├── 00023.h │ │ ├── 00024.h │ │ ├── 00025.h │ │ ├── 00026.h │ │ ├── 00027.h │ │ ├── 00028.h │ │ ├── 00029.h │ │ ├── 00030.h │ │ ├── 00031.h │ │ ├── 00032.h │ │ ├── 00033.h │ │ ├── 00034.h │ │ ├── 00035.h │ │ ├── 00036.h │ │ ├── 00037.h │ │ ├── 00038.h │ │ ├── 00039.h │ │ ├── 00040.h │ │ ├── 00041.h │ │ ├── 00042.h │ │ ├── 00043.h │ │ ├── 00044.h │ │ ├── 00045.h │ │ ├── 00046.h │ │ ├── 00047.h │ │ ├── 00048.h │ │ ├── 00049.h │ │ └── 00050.h │ ├── toolbar_alpha_icon.h │ ├── toolbar_cancel_icon.h │ ├── toolbar_colorbuffer_icon.h │ ├── toolbar_drawparams_icon.h │ ├── toolbar_quit_icon.h │ ├── toolbar_render_icon.h │ ├── toolbar_save_as_icon.h │ ├── toolbar_savedepth_icon.h │ ├── toolbar_show_alpha_icon.h │ ├── toolbar_z_buffer_icon.h │ ├── toolbar_zoomin_icon.h │ ├── toolbar_zoomout_icon.h │ ├── yafLogoTiny.h │ └── yafarayicon.h ├── textures │ ├── basicnodes.h │ ├── basictex.h │ ├── imagetex.h │ ├── layernode.h │ └── noise.h ├── utilities │ ├── ColorConv.h │ ├── buffer.h │ ├── console_utils.h │ ├── curveUtils.h │ ├── geometry.h │ ├── iesUtils.h │ ├── image_buffers.h │ ├── interpolation.h │ ├── mathOptimizations.h │ ├── math_utils.h │ ├── mcqmc.h │ ├── sample_utils.h │ ├── spectralData.h │ ├── stringUtils.h │ ├── threadUtils.h │ ├── tiled_array.h │ ├── winunistd.h │ └── y_alloc.h ├── yafray_constants.h └── yafraycore │ ├── hashgrid.h │ ├── imageOutput.h │ ├── kdtree.h │ ├── memoryIO.h │ ├── meshtypes.h │ ├── monitor.h │ ├── nodematerial.h │ ├── photon.h │ ├── pkdtree.h │ ├── ray_kdtree.h │ ├── scr_halton.h │ ├── spectrum.h │ ├── std_primitives.h │ ├── timer.h │ ├── triangle.h │ └── xmlparser.h ├── src ├── CMakeLists.txt ├── backgrounds │ ├── CMakeLists.txt │ ├── darksky.cc │ ├── gradientback.cc │ ├── sunsky.cc │ ├── sunspectrum.cc │ └── textureback.cc ├── bindings │ ├── CMakeLists.txt │ ├── yafaray_v3_interface.i │ └── yafqt.i ├── cameras │ ├── CMakeLists.txt │ ├── angularCamera.cc │ ├── architectCamera.cc │ ├── equirectangularCamera.cc │ ├── orthographicCamera.cc │ └── perspectiveCamera.cc ├── gui │ ├── CMakeLists.txt │ ├── animworking.cc │ ├── animworking.h │ ├── events.cc │ ├── events.h │ ├── mywindow.cc │ ├── mywindow.h │ ├── qtoutput.cc │ ├── qtoutput.h │ ├── qtprogress.cc │ ├── qtprogress.h │ ├── renderwidget.cc │ ├── renderwidget.h │ ├── windowbase.ui │ ├── worker.cc │ └── worker.h ├── image_handlers │ ├── CMakeLists.txt │ ├── exrHandler.cc │ ├── hdrHandler.cc │ ├── hdrUtils.h │ ├── jpgHandler.cc │ ├── pngHandler.cc │ ├── pngUtils.h │ ├── tgaHandler.cc │ ├── tgaUtils.h │ └── tifHandler.cc ├── integrators │ ├── CMakeLists.txt │ ├── DebugIntegrator.cc │ ├── EmissionIntegrator.cc │ ├── EmptyVolumeIntegrator.cc │ ├── SingleScatterIntegrator.cc │ ├── SkyIntegrator.cc │ ├── bidirpath.cc │ ├── directlight.cc │ ├── pathtracer.cc │ ├── photonintegr.cc │ └── sppm.cc ├── interface │ ├── CMakeLists.txt │ ├── xmlinterface.cc │ └── yafrayinterface.cc ├── lights │ ├── CMakeLists.txt │ ├── arealight.cc │ ├── bglight.cc │ ├── bgportallight.cc │ ├── directional.cc │ ├── iesLight.cc │ ├── meshlight.cc │ ├── pointlight.cc │ ├── spherelight.cc │ ├── spotlight.cc │ └── sunlight.cc ├── materials │ ├── CMakeLists.txt │ ├── beer.cc │ ├── blend.cc │ ├── coatedglossy.cc │ ├── glass.cc │ ├── glossy.cc │ ├── mask.cc │ ├── roughglass.cc │ ├── shinydiffuse.cc │ └── simple.cc ├── textures │ ├── CMakeLists.txt │ ├── basicnodes.cc │ ├── basictex.cc │ ├── imagetex.cc │ ├── layernode.cc │ └── noise.cc ├── volumes │ ├── CMakeLists.txt │ ├── ExpDensityVolume.cc │ ├── GridVolume.cc │ ├── NoiseVolume.cc │ ├── SkyVolume.cc │ └── UniformVolume.cc ├── xml_loader │ ├── CMakeLists.txt │ └── xml-loader.cc └── yafraycore │ ├── CMakeLists.txt │ ├── bound.cc │ ├── color.cc │ ├── color_console.cc │ ├── color_ramp.cc │ ├── console.cc │ ├── dynamic_library.cc │ ├── environment.cc │ ├── faure_tables.cc │ ├── file.cc │ ├── gboundtree.h │ ├── hashgrid.cc │ ├── imageOutput.cc │ ├── imagefilm.cc │ ├── imagehandler.cc │ ├── imagesplitter.cc │ ├── integrator.cc │ ├── kdtree.cc │ ├── logging.cc │ ├── material.cc │ ├── matrix4.cc │ ├── mcintegrator.cc │ ├── memoryIO.cc │ ├── nodematerial.cc │ ├── object3d.cc │ ├── photon.cc │ ├── ray_kdtree.cc │ ├── renderpasses.cc │ ├── scene.cc │ ├── session.cc │ ├── spectrum.cc │ ├── std_primitives.cc │ ├── surface.cc │ ├── sysinfo.cc │ ├── timer.cc │ ├── triangle.cc │ ├── tribox3_d.cc │ ├── triclip.cc │ ├── vector3d.cc │ ├── volume.cc │ └── xmlparser.cc └── tests └── test01 ├── test01 - expected render result.png ├── test01.xml ├── test01_tex.exr ├── test01_tex.hdr ├── test01_tex.jpg ├── test01_tex.png ├── test01_tex.tga └── test01_tex.tif /.gitignore: -------------------------------------------------------------------------------- 1 | .* 2 | !/.gitignore 3 | -------------------------------------------------------------------------------- /AUTHORS.md: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # This is a rough list of the contributors to YafaRay and is still in # 3 | # progress, so if you know someone is missing please let us know # 4 | ############################################################################### 5 | 6 | Developers for Yafray (up to version 0.0.9): 7 | Alejandro Conty Estévez (jandro) 8 | Alfredo Greef (eshlo) 9 | 10 | Developers for YafaRay (name change after refactor): 11 | Mathias Wein (Lynx) 12 | Bert Buchholz (bert) 13 | Michele Castigliego (subcomandante) 14 | Gustavo Boiko (boiko) 15 | Rodrigo Placencia (DarkTide) 16 | David Bluecame 17 | -------------------------------------------------------------------------------- /CMakeConfig/GenConfHeaders.txt: -------------------------------------------------------------------------------- 1 | # WARNING: Please don't change this file 2 | if(NOT YAFARAY_CORE_VERSION) 3 | if(GIT_FOUND) 4 | execute_process(COMMAND ${GIT_EXECUTABLE} describe --dirty --always --tags WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE YAFARAY_CORE_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) 5 | endif(GIT_FOUND) 6 | if(NOT YAFARAY_CORE_VERSION) 7 | set(YAFARAY_CORE_VERSION "devel") 8 | endif(NOT YAFARAY_CORE_VERSION) 9 | endif(NOT YAFARAY_CORE_VERSION) 10 | 11 | if(DEBUG_BUILD STREQUAL "ON") 12 | set(DEBUG "-DEBUG") 13 | endif(DEBUG_BUILD STREQUAL "ON") 14 | 15 | 16 | include(CheckIncludeFiles) 17 | check_include_files(unistd.h HAVE_UNISTD_H) 18 | 19 | set(YAFARAY_BUILD_COMPILER "${CMAKE_CXX_COMPILER_ID}") #-${CMAKE_CXX_COMPILER_VERSION}") 20 | if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") 21 | set(YAFARAY_BUILD_COMPILER "GCC") #To avoid confusion, just name it GCC and not GNU when GCC is used 22 | endif(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") 23 | 24 | 25 | if(MINGW) 26 | set(YAFARAY_BUILD_PLATFORM "MinGW") 27 | endif(MINGW) 28 | 29 | if(CMAKE_SIZEOF_VOID_P EQUAL 8) 30 | set(YAFARAY_BUILD_ARCHITECTURE "64bit") 31 | elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) 32 | set(YAFARAY_BUILD_ARCHITECTURE "32bit") 33 | endif() 34 | 35 | set(YAFARAY_BUILD_OS "${CMAKE_SYSTEM_NAME}") 36 | 37 | 38 | configure_file(CMakeConfig/templates/yafray_config.h.cmake ${CMAKE_BINARY_DIR}/yafray_config.h) 39 | -------------------------------------------------------------------------------- /CMakeConfig/templates/yafray_config.h.cmake: -------------------------------------------------------------------------------- 1 | #pragma once 2 | // Header file generated by CMake please don't change it 3 | 4 | // These preprocessor macros are set by cmake during building in file yafray_config.h.cmake 5 | // They contain information about how the YafaRay package was built, CMake options used, compiler flags, etc 6 | 7 | #ifndef Y_CONFIG_H 8 | #define Y_CONFIG_H 9 | 10 | // Some important ray tracing parameters set in CMake 11 | #define MIN_RAYDIST @YAF_MIN_RAY_DIST@ 12 | #define YAF_SHADOW_BIAS @YAF_SHADOW_BIAS@ 13 | 14 | // CMake checks for the unistd.h header file 15 | #cmakedefine HAVE_UNISTD_H 1 16 | 17 | // The YafaRay version displayed in the logs/badges can be set manually using a CMake variable as follows: 18 | // For example: cmake -DYAFARAY_CORE_VERSION="v1.2.3" 19 | // If the version is not manually set, it will use the information obtained from the latest Git commit/tag. 20 | #define YAFARAY_BUILD_VERSION std::string("@YAFARAY_CORE_VERSION@@DEBUG@") 21 | 22 | // The directory where the plugins reside can be set in the YAF_RUNTIME_SEARCH_PLUGIN_DIR CMake variable. Otherwise it will try to find it automatically during runtime (if it can) 23 | #define YAFARAY_BUILD_SEARCH_PLUGIN_DIR std::string("@YAF_RUNTIME_SEARCH_PLUGIN_DIR@") 24 | 25 | // Several YafaRay build informative variables 26 | #define YAFARAY_BUILD_ARCHITECTURE std::string("@YAFARAY_BUILD_ARCHITECTURE@") 27 | #define YAFARAY_BUILD_COMPILER std::string("@YAFARAY_BUILD_COMPILER@") 28 | #define YAFARAY_BUILD_OS std::string("@YAFARAY_BUILD_OS@") 29 | #define YAFARAY_BUILD_PLATFORM std::string("@YAFARAY_BUILD_PLATFORM@") 30 | 31 | 32 | #endif 33 | 34 | -------------------------------------------------------------------------------- /CMakeModules/FindOpenEXR.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Try to find OpenEXR's libraries, and include path. 3 | # Once done this will define: 4 | # 5 | # OPENEXR_FOUND = OpenEXR found. 6 | # OPENEXR_INCLUDE_DIRS = OpenEXR include directories. 7 | # OPENEXR_LIBRARIES = libraries that are needed to use OpenEXR. 8 | # 9 | 10 | INCLUDE(FindZLIB) 11 | 12 | 13 | IF(ZLIB_FOUND) 14 | 15 | SET(LIBRARY_DIRS 16 | /usr/lib 17 | /usr/local/lib 18 | /sw/lib 19 | /opt/local/lib 20 | $ENV{PROGRAM_FILES}/OpenEXR/lib/static) 21 | 22 | FIND_PATH(OPENEXR_INCLUDE_PATH ImfRgbaFile.h 23 | PATH_SUFFIXES OpenEXR 24 | /usr/include 25 | /usr/local/include 26 | /sw/include 27 | /opt/local/include) 28 | 29 | FIND_LIBRARY(OPENEXR_HALF_LIBRARY 30 | NAMES Half 31 | PATHS ${LIBRARY_DIRS}) 32 | 33 | FIND_LIBRARY(OPENEXR_IEX_LIBRARY 34 | NAMES Iex 35 | PATHS ${LIBRARY_DIRS}) 36 | 37 | FIND_LIBRARY(OPENEXR_IMATH_LIBRARY 38 | NAMES Imath 39 | PATHS ${LIBRARY_DIRS}) 40 | 41 | FIND_LIBRARY(OPENEXR_ILMIMF_LIBRARY 42 | NAMES IlmImf 43 | PATHS ${LIBRARY_DIRS}) 44 | 45 | FIND_LIBRARY(OPENEXR_ILMTHREAD_LIBRARY 46 | NAMES IlmThread 47 | PATHS ${LIBRARY_DIRS}) 48 | 49 | ENDIF(ZLIB_FOUND) 50 | 51 | #MESSAGE(STATUS ${OPENEXR_IMATH_LIBRARY} ${OPENEXR_ILMIMF_LIBRARY} ${OPENEXR_IEX_LIBRARY} ${OPENEXR_HALF_LIBRARY} ${OPENEXR_ILMTHREAD_LIBRARY} ${ZLIB_LIBRARY}) 52 | 53 | IF (OPENEXR_INCLUDE_PATH AND OPENEXR_IMATH_LIBRARY AND OPENEXR_ILMIMF_LIBRARY AND OPENEXR_IEX_LIBRARY AND OPENEXR_HALF_LIBRARY) 54 | SET(OPENEXR_FOUND TRUE) 55 | SET(OPENEXR_INCLUDE_DIRS ${OPENEXR_INCLUDE_PATH} CACHE STRING "The include paths needed to use OpenEXR") 56 | SET(OPENEXR_LIBRARIES ${OPENEXR_IMATH_LIBRARY} ${OPENEXR_ILMIMF_LIBRARY} ${OPENEXR_IEX_LIBRARY} ${OPENEXR_HALF_LIBRARY} ${ZLIB_LIBRARY} CACHE STRING "The libraries needed to use OpenEXR") 57 | 58 | IF(OPENEXR_ILMTHREAD_LIBRARY) 59 | SET(OPENEXR_LIBRARIES ${OPENEXR_LIBRARIES} ${OPENEXR_ILMTHREAD_LIBRARY}) 60 | ENDIF(OPENEXR_ILMTHREAD_LIBRARY) 61 | ENDIF (OPENEXR_INCLUDE_PATH AND OPENEXR_IMATH_LIBRARY AND OPENEXR_ILMIMF_LIBRARY AND OPENEXR_IEX_LIBRARY AND OPENEXR_HALF_LIBRARY) 62 | 63 | IF(OPENEXR_FOUND) 64 | IF(NOT OPENEXR_FIND_QUIETLY) 65 | MESSAGE(STATUS "Found OpenEXR: ${OPENEXR_ILMIMF_LIBRARY}") 66 | ENDIF(NOT OPENEXR_FIND_QUIETLY) 67 | ELSE(OPENEXR_FOUND) 68 | IF(OPENEXR_FIND_REQUIRED) 69 | MESSAGE(FATAL_ERROR "Could not find OpenEXR library") 70 | ENDIF(OPENEXR_FIND_REQUIRED) 71 | ENDIF(OPENEXR_FOUND) 72 | 73 | MARK_AS_ADVANCED( 74 | OPENEXR_INCLUDE_DIRS 75 | OPENEXR_LIBRARIES 76 | OPENEXR_ILMIMF_LIBRARY 77 | OPENEXR_IMATH_LIBRARY 78 | OPENEXR_IEX_LIBRARY 79 | OPENEXR_HALF_LIBRARY) 80 | -------------------------------------------------------------------------------- /CMakeModules/FindYafSWIG.cmake: -------------------------------------------------------------------------------- 1 | # - Find SWIG 2 | # This module finds an installed SWIG. It sets the following variables: 3 | # SWIG_FOUND - set to true if SWIG is found 4 | # SWIG_DIR - the directory where swig is installed 5 | # SWIG_EXECUTABLE - the path to the swig executable 6 | # SWIG_VERSION - the version number of the swig executable 7 | # 8 | # All informations are collected from the SWIG_EXECUTABLE so the 9 | # version to be found can be changed from the command line by 10 | # means of setting SWIG_EXECUTABLE 11 | # 12 | 13 | #============================================================================= 14 | # Copyright 2004-2009 Kitware, Inc. 15 | # 16 | # Distributed under the OSI-approved BSD License (the "License"); 17 | # see accompanying file Copyright.txt for details. 18 | # 19 | # This software is distributed WITHOUT ANY WARRANTY; without even the 20 | # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 21 | # See the License for more information. 22 | #============================================================================= 23 | # (To distributed this file outside of CMake, substitute the full 24 | # License text for the above reference.) 25 | 26 | SET(SWIG_FOUND FALSE) 27 | 28 | IF(NOT SWIG_EXECUTABLE) 29 | FIND_PROGRAM(SWIG_EXECUTABLE swig) 30 | ENDIF(NOT SWIG_EXECUTABLE) 31 | 32 | IF(SWIG_EXECUTABLE) 33 | MESSAGE("Using SWIG executables: ${SWIG_EXECUTABLE}") 34 | EXECUTE_PROCESS(COMMAND ${SWIG_EXECUTABLE} -swiglib 35 | OUTPUT_VARIABLE SWIG_swiglib_output 36 | ERROR_VARIABLE SWIG_swiglib_error 37 | RESULT_VARIABLE SWIG_swiglib_result) 38 | 39 | IF(SWIG_swiglib_result) 40 | IF(SWIG_FIND_REQUIRED) 41 | MESSAGE(SEND_ERROR "Command \"${SWIG_EXECUTABLE} -swiglib\" failed with output:\n${SWIG_swiglib_error}") 42 | ELSE(SWIG_FIND_REQUIRED) 43 | MESSAGE(STATUS "Command \"${SWIG_EXECUTABLE} -swiglib\" failed with output:\n${SWIG_swiglib_error}") 44 | ENDIF(SWIG_FIND_REQUIRED) 45 | ELSE(SWIG_swiglib_result) 46 | STRING(REGEX REPLACE "[\n\r]+" ";" SWIG_swiglib_output ${SWIG_swiglib_output}) 47 | # force the path to be computed each time in case SWIG_EXECUTABLE has changed. 48 | SET(SWIG_DIR SWIG_DIR-NOTFOUND) 49 | FIND_PATH(SWIG_DIR swig.swg PATHS ${SWIG_swiglib_output} NO_CMAKE_FIND_ROOT_PATH) 50 | IF(SWIG_DIR) 51 | SET(SWIG_FOUND 1) 52 | SET(SWIG_USE_FILE ${CMAKE_SOURCE_DIR}/CMakeModules/UseYafSWIG.cmake) 53 | EXECUTE_PROCESS(COMMAND ${SWIG_EXECUTABLE} -version 54 | OUTPUT_VARIABLE SWIG_version_output 55 | ERROR_VARIABLE SWIG_version_output 56 | RESULT_VARIABLE SWIG_version_result) 57 | IF(SWIG_version_result) 58 | MESSAGE(SEND_ERROR "Command \"${SWIG_EXECUTABLE} -version\" failed with output:\n${SWIG_version_output}") 59 | ELSE(SWIG_version_result) 60 | STRING(REGEX REPLACE ".*SWIG Version[^0-9.]*\([0-9.]+\).*" "\\1" 61 | SWIG_version_output "${SWIG_version_output}") 62 | SET(SWIG_VERSION ${SWIG_version_output} CACHE STRING "Swig version" FORCE) 63 | ENDIF(SWIG_version_result) 64 | ENDIF(SWIG_DIR) 65 | ENDIF(SWIG_swiglib_result) 66 | ENDIF(SWIG_EXECUTABLE) 67 | 68 | IF(NOT SWIG_FOUND) 69 | IF(NOT SWIG_FIND_QUIETLY) 70 | IF(SWIG_FIND_REQUIRED) 71 | MESSAGE(FATAL_ERROR "SWIG was not found. Please specify Swig executable location") 72 | ELSE(SWIG_FIND_REQUIRED) 73 | MESSAGE(STATUS "SWIG was not found. Please specify Swig executable location") 74 | ENDIF(SWIG_FIND_REQUIRED) 75 | ENDIF(NOT SWIG_FIND_QUIETLY) 76 | ENDIF(NOT SWIG_FOUND) 77 | -------------------------------------------------------------------------------- /CODING.md: -------------------------------------------------------------------------------- 1 | some coding conventions: 2 | 3 | * headers in include/core_api shall not include headers from other 4 | YafRay include dirs. 5 | * headers in include/core_api shall not use HAVE_* options 6 | (like '#if HAVE_EXR') 7 | * plugins using headers other than core_api ones need to have all 8 | libs added to their build environment for all HAVE_* options they 9 | pull in (directly or indirectly!) 10 | * interface functions shall not have arguments or return types which 11 | depend on configurable typedefines (such as float, PLOAT and float) 12 | * use doxygen comments to document non-obvious types, classes, interfaces 13 | and functions and their usage. 14 | 15 | ## formatting 16 | * use tabs, not spaces 17 | * recommended tab width is 4 18 | * 80 character terminals are from last century... 19 | everyone should be able to view at least 120 character long lines 20 | 21 | -------------------------------------------------------------------------------- /INSTALL.md: -------------------------------------------------------------------------------- 1 | libYafaRay uses CMake for the building process in Linux, Windows and MacOSX systems. 2 | 3 | See directory "building" for example procedures to build libYafaRay 4 | 5 | Dependencies: 6 | * Optional, depending on options selected in CMake: 7 | * meganz/mingw-std-threads 8 | * \>=zlib-1.2.8 9 | * \>=libxml2-2.9.1 10 | * \>=opencv-3.1.0 11 | * \>=freetype-2.4.0 12 | * \>=libpng-1.2.56 13 | * \>=jpeg-6b 14 | * \>=tiff-4.0.3 15 | * \>=ilmbase-2.2.0 16 | * \>=openexr-2.2.0 17 | * \>=python-3.5 18 | * \>=ruby-2.2 19 | * \>=qt-5 20 | 21 | Notes about dependencies: 22 | * ZLib is needed if LibXML2, libPNG or OpenEXR are used. 23 | * LibXML2 is used to allow import of XML files (usually by building YafaRay XML Loader) 24 | * OpenCV is used to do some image processing, most importantly texture mipmaps for Trilinear or EWA interpolations. 25 | * Python is used only if the Python bindings are built (for example for the Blender Exporter) 26 | * Ruby is used if the Ruby bindings are built (for example to create the Sketchup plugin) 27 | * Qt is optional, used for the Sketchup plugin for example 28 | 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | DESCRIPTION 2 | ----------- 3 | libYafaRay is a free open-source montecarlo raytracing engine released under the LGPL 2.1 license. Raytracing is a rendering technique for generating realistic images by tracing the path of light through a 3D scene. 4 | 5 | For more information, see: www.yafaray.org 6 | 7 | 8 | SOURCE CODE 9 | ----------- 10 | libYafaRay source code is hosted in GitHub: https://github.com/YafaRay/libYafaRay 11 | 12 | 13 | BUG REPORTS / FEATURE REQUESTS 14 | ------------------------------ 15 | Please use the GitHub bug tracking system to report bugs in libYafaRay instead of the YafaRay website bug tracking. 16 | 17 | * GitHub bug tracking (preferred): https://github.com/YafaRay/libYafaRay/issues 18 | 19 | * YafaRay website bug tracking: http://www.yafaray.org/development/bugtracker/yafaray 20 | 21 | 22 | Thank you. 23 | 24 | YafaRay development Team. 25 | -------------------------------------------------------------------------------- /building/linux/OpenSUSE Leap 42.1 building - Blender AddOn.txt: -------------------------------------------------------------------------------- 1 | # OpenSUSE Leap 42.1 YafaRay Blender Add-On building procedure (only valid for YafaRay v3.1.2 or higher) 2 | # NOTE: This procedure generates a "yafaray_v3" folder that can be installed in the Blender Add-Ons folder 3 | # However, this only works for the Blender included in the distro (currently 2.75 in OpenSUSE Leap 42.1). 4 | # When using this yafaray_v3 folder with the Blender downloaded from www.blender.org there might be 5 | # conflicts with the Blender EXR, PNG and JPEG libraries. 6 | 7 | # INSTALLING DEVEL TOOLS 8 | sudo zypper install -y nano git cmake autoconf gcc gcc-c++ cpp swig 9 | 10 | # INSTALLING LIBRARY DEPENDENCIES 11 | sudo zypper install -y python3-devel zlib-devel libpng12-devel freetype2-devel libxml2-devel libtiff-devel libjpeg62-devel opencv-devel openexr-devel 12 | 13 | # INSTALLING BLENDER 14 | sudo zypper install -y blender 15 | 16 | # DOWNLOADING YAFARAY AND SETTING UP FOLDERS 17 | mkdir -p $HOME/yafa-dev/src $HOME/yafa-dev/make $HOME/yafa-dev/build 18 | cd $HOME/yafa-dev/src 19 | git clone https://github.com/YafaRay/Blender-Exporter 20 | git clone https://github.com/YafaRay/Core 21 | 22 | # CREATE UserConfig.txt FILE WITH YAFARAY BUILDING OPTIONS. Execute the entire block below until (including) EOF 23 | 24 | cat <$HOME/yafa-dev/make/UserConfig.txt 25 | #################################################################### 26 | # UserConfig File to build for OpenSuse Leap 42.1 Blender Add-On 27 | #################################################################### 28 | # WARNING: DON'T TOUCH THE NEXT LINE 29 | set(YAF_USER_CONFIG ON) 30 | #################################################################### 31 | 32 | set(DEBUG_BUILD OFF) 33 | set(USER_INSTALL_PREFIX "$HOME/yafa-dev/build/yafaray_v3/") 34 | set(BLENDER_ADDON ON) 35 | set(YAF_PY_VERSION 3.4) 36 | set(BLENDER_EXPORTER_PATH "$HOME/yafa-dev/src/Blender-Exporter") 37 | #################################################################### 38 | EOF 39 | 40 | 41 | # BUILDING YAFARAY 42 | cd $HOME/yafa-dev/make 43 | cmake $HOME/yafa-dev/src/Core 44 | # Note: "-j9" uses 9 threads in this example for speeding up the building process. It can be changed to "-j" depending on the number of cores of the processor used for building YafaRay. 45 | make -j9 46 | make install -j9 47 | 48 | # TEST IN BLENDER 49 | mkdir -p $HOME/.config/blender/2.75/scripts/addons 50 | cp -R $HOME/yafa-dev/build/yafaray_v3 $HOME/.config/blender/2.75/scripts/addons/yafaray_v3 51 | blender $HOME/yafa-dev/build/yafaray_v3/tests/test01/test01.blend 52 | 53 | # In Blender, go to File->User Preferences->AddOns-->YafaRay v3 and enable it. Then, click save settings and close the User Preferences window. 54 | 55 | # Now you should be able to render the test01.blend file. 56 | -------------------------------------------------------------------------------- /building/linux/OpenSUSE Leap 42.1 building - Standalone.txt: -------------------------------------------------------------------------------- 1 | # OpenSUSE Leap 42.1 YafaRay Standalone building procedure (only valid for YafaRay v3.1.2 or higher) 2 | # NOTE: This procedure generates a "yafaray_v3" folder that can be used by 3rd party software, or by 3 | # executing yafaray_v3/bin/yafaray-xml to render a YafaRay XML scene file 4 | 5 | # INSTALLING DEVEL TOOLS 6 | sudo zypper install -y nano git cmake autoconf gcc gcc-c++ cpp swig 7 | 8 | # INSTALLING LIBRARY DEPENDENCIES 9 | sudo zypper install -y python3-devel zlib-devel libpng12-devel freetype2-devel libxml2-devel libtiff-devel libjpeg62-devel opencv-devel openexr-devel 10 | 11 | # DOWNLOADING YAFARAY AND SETTING UP FOLDERS 12 | mkdir -p $HOME/yafa-dev/src $HOME/yafa-dev/make $HOME/yafa-dev/build 13 | cd $HOME/yafa-dev/src 14 | git clone https://github.com/YafaRay/Core 15 | 16 | # CREATE UserConfig.txt FILE WITH YAFARAY BUILDING OPTIONS. Execute the entire block below until (including) EOF 17 | 18 | cat <$HOME/yafa-dev/make/UserConfig.txt 19 | #################################################################### 20 | # UserConfig File to build for OpenSuse Leap 42.1 Standalone 21 | #################################################################### 22 | # WARNING: DON'T TOUCH THE NEXT LINE 23 | set(YAF_USER_CONFIG ON) 24 | #################################################################### 25 | 26 | set(DEBUG_BUILD OFF) 27 | set(USER_INSTALL_PREFIX "$HOME/yafa-dev/build/yafaray_v3/") 28 | set(BLENDER_ADDON OFF) 29 | set(YAF_PY_VERSION 3.4) 30 | #################################################################### 31 | EOF 32 | 33 | 34 | # BUILDING YAFARAY 35 | cd $HOME/yafa-dev/make 36 | cmake $HOME/yafa-dev/src/Core 37 | # Note: "-j9" uses 9 threads in this example for speeding up the building process. It can be changed to "-j" depending on the number of cores of the processor used for building YafaRay. 38 | make -j9 39 | make install -j9 40 | 41 | # TESTING YAFARAY 42 | cd $HOME/yafa-dev/build/yafaray_v3/share/yafaray/tests/test01/ 43 | $HOME/yafa-dev/build/yafaray_v3/bin/yafaray-xml -f png test01.xml test01_render 44 | -------------------------------------------------------------------------------- /building/linux/YafaRay Debian Testing building - Blender AddOn.txt: -------------------------------------------------------------------------------- 1 | # Debian Testing version - YafaRay Blender Add-On building procedure (only valid for YafaRay v3.1.2 or higher) 2 | # NOTE: This procedure generates a "yafaray_v3" folder that can be installed in the Blender Add-Ons folder 3 | # However, this only works for the Blender included in the distro (currently 2.77 in Debian Testing) 4 | # When using this yafaray_v3 folder with the Blender downloaded from www.blender.org there might be 5 | # conflicts with the Blender EXR, PNG and JPEG libraries. 6 | 7 | # INSTALLING DEVEL TOOLS 8 | sudo apt-get install -y git cmake cmake-curses-gui autoconf gcc g++ cpp swig 9 | 10 | # INSTALLING BLENDER 11 | sudo apt-get install -y blender 12 | 13 | # INSTALLING LIBRARY DEPENDENCIES 14 | sudo apt-get install -y python3-dev zlib1g-dev libpng-dev libfreetype6-dev libxml2-dev libtiff5-dev libjpeg-dev libopencv-dev libopenexr-dev 15 | 16 | # DOWNLOADING YAFARAY AND SETTING UP FOLDERS 17 | mkdir -p $HOME/yafa-dev/src $HOME/yafa-dev/make $HOME/yafa-dev/build 18 | cd $HOME/yafa-dev/src 19 | git clone https://github.com/YafaRay/Blender-Exporter 20 | git clone https://github.com/YafaRay/Core 21 | 22 | # CREATE UserConfig.txt FILE WITH YAFARAY BUILDING OPTIONS. Execute the entire block below until (including) EOF 23 | 24 | cat <$HOME/yafa-dev/make/UserConfig.txt 25 | #################################################################### 26 | # UserConfig File to build for Debian Testing Blender Add-On 27 | #################################################################### 28 | # WARNING: DON'T TOUCH THE NEXT LINE 29 | set(YAF_USER_CONFIG ON) 30 | #################################################################### 31 | 32 | set(DEBUG_BUILD OFF) 33 | set(USER_INSTALL_PREFIX "$HOME/yafa-dev/build/yafaray_v3/") 34 | set(BLENDER_ADDON ON) 35 | set(YAF_PY_VERSION 3.5) 36 | set(BLENDER_EXPORTER_PATH "$HOME/yafa-dev/src/Blender-Exporter") 37 | #################################################################### 38 | EOF 39 | 40 | 41 | # BUILDING YAFARAY 42 | cd $HOME/yafa-dev/make 43 | cmake $HOME/yafa-dev/src/Core 44 | # Note: "-j9" uses 9 threads in this example for speeding up the building process. It can be changed to "-j" depending on the number of cores of the processor used for building YafaRay. 45 | make -j9 46 | make install -j9 47 | 48 | # TEST IN BLENDER 49 | mkdir -p $HOME/.config/blender/2.77/scripts/addons 50 | cp -R $HOME/yafa-dev/build/yafaray_v3 $HOME/.config/blender/2.77/scripts/addons/yafaray_v3 51 | blender $HOME/yafa-dev/build/yafaray_v3/tests/test01/test01.blend 52 | 53 | # In Blender, go to File->User Preferences->AddOns-->YafaRay v3 and enable it. Then, click save settings and close the User Preferences window. 54 | 55 | # Now you should be able to render the test01.blend file. 56 | -------------------------------------------------------------------------------- /building/linux/YafaRay Debian Testing building - Standalone.txt: -------------------------------------------------------------------------------- 1 | # Debian Testing version - YafaRay Standalone building procedure (only valid for YafaRay v3.1.2 or higher) 2 | # NOTE: This procedure generates a "yafaray_v3" folder that can be used by 3rd party software, or by 3 | # executing yafaray_v3/bin/yafaray-xml to render a YafaRay XML scene file 4 | 5 | # INSTALLING DEVEL TOOLS 6 | sudo apt-get install -y git cmake cmake-curses-gui autoconf gcc g++ cpp swig 7 | 8 | # INSTALLING LIBRARY DEPENDENCIES 9 | sudo apt-get install -y python3-dev zlib1g-dev libpng-dev libfreetype6-dev libxml2-dev libtiff5-dev libjpeg-dev libopencv-dev libopenexr-dev 10 | 11 | # DOWNLOADING YAFARAY AND SETTING UP FOLDERS 12 | mkdir -p $HOME/yafa-dev/src $HOME/yafa-dev/make $HOME/yafa-dev/build 13 | cd $HOME/yafa-dev/src 14 | git clone https://github.com/YafaRay/Core 15 | 16 | # CREATE UserConfig.txt FILE WITH YAFARAY BUILDING OPTIONS. Execute the entire block below until (including) EOF 17 | 18 | cat <$HOME/yafa-dev/make/UserConfig.txt 19 | #################################################################### 20 | # UserConfig File to build for Debian Testing Standalone 21 | #################################################################### 22 | # WARNING: DON'T TOUCH THE NEXT LINE 23 | set(YAF_USER_CONFIG ON) 24 | #################################################################### 25 | 26 | set(DEBUG_BUILD OFF) 27 | set(USER_INSTALL_PREFIX "$HOME/yafa-dev/build/yafaray_v3/") 28 | set(BLENDER_ADDON OFF) 29 | set(YAF_PY_VERSION 3.5) 30 | #################################################################### 31 | EOF 32 | 33 | 34 | # BUILDING YAFARAY 35 | cd $HOME/yafa-dev/make 36 | cmake $HOME/yafa-dev/src/Core 37 | # Note: "-j9" uses 9 threads in this example for speeding up the building process. It can be changed to "-j" depending on the number of cores of the processor used for building YafaRay. 38 | make -j9 39 | make install -j9 40 | 41 | # TESTING YAFARAY 42 | cd $HOME/yafa-dev/build/yafaray_v3/share/yafaray/tests/test01/ 43 | $HOME/yafa-dev/build/yafaray_v3/bin/yafaray-xml -f png test01.xml test01_render 44 | -------------------------------------------------------------------------------- /building/linux/YafaRay Ubuntu 16.04 building - Blender AddOn.txt: -------------------------------------------------------------------------------- 1 | # UBUNTU 16.04 YafaRay Blender Add-On building procedure (only valid for YafaRay v3.1.2 or higher) 2 | # NOTE: This procedure generates a "yafaray_v3" folder that can be installed in the Blender Add-Ons folder 3 | # However, this only works for the Blender included in the distro (currently 2.76). When using this 4 | # yafaray_v3 folder with the Blender downloaded from www.blender.org there might be conflicts with the 5 | # Blender EXR, PNG and JPEG libraries. 6 | 7 | # INSTALLING DEVEL TOOLS 8 | sudo apt-get install -y git cmake cmake-curses-gui autoconf gcc g++ cpp swig 9 | 10 | # INSTALLING BLENDER 11 | sudo apt-get install -y blender 12 | 13 | # INSTALLING LIBRARY DEPENDENCIES 14 | sudo apt-get install -y python3-dev zlib1g-dev libpng-dev libfreetype6-dev libxml2-dev libtiff5-dev libopencv-dev libjpeg-dev libopenexr-dev 15 | 16 | # DOWNLOADING YAFARAY AND SETTING UP FOLDERS 17 | mkdir -p $HOME/yafa-dev/src $HOME/yafa-dev/make $HOME/yafa-dev/build 18 | cd $HOME/yafa-dev/src 19 | git clone https://github.com/YafaRay/Blender-Exporter 20 | git clone https://github.com/YafaRay/Core 21 | 22 | # CREATE UserConfig.txt FILE WITH YAFARAY BUILDING OPTIONS. Execute the entire block below until (including) EOF 23 | 24 | cat <$HOME/yafa-dev/make/UserConfig.txt 25 | #################################################################### 26 | # UserConfig File to build for Ubuntu 16.04 Blender Add-On 27 | #################################################################### 28 | # WARNING: DON'T TOUCH THE NEXT LINE 29 | set(YAF_USER_CONFIG ON) 30 | #################################################################### 31 | 32 | set(DEBUG_BUILD OFF) 33 | set(USER_INSTALL_PREFIX "$HOME/yafa-dev/build/yafaray_v3/") 34 | set(BLENDER_ADDON ON) 35 | set(YAF_PY_VERSION 3.5) 36 | set(BLENDER_EXPORTER_PATH "$HOME/yafa-dev/src/Blender-Exporter") 37 | #################################################################### 38 | EOF 39 | 40 | # BUILDING YAFARAY 41 | cd $HOME/yafa-dev/make 42 | cmake $HOME/yafa-dev/src/Core 43 | # Note: "-j9" uses 9 threads in this example for speeding up the building process. It can be changed to "-j" depending on the number of cores of the processor used for building YafaRay. 44 | make -j9 45 | make install -j9 46 | 47 | # TEST IN BLENDER 48 | mkdir -p $HOME/.config/blender/2.76/scripts/addons 49 | cp -R $HOME/yafa-dev/build/yafaray_v3 $HOME/.config/blender/2.76/scripts/addons/yafaray_v3 50 | blender $HOME/yafa-dev/build/yafaray_v3/tests/test01/test01.blend 51 | 52 | # In Blender, go to File->User Preferences->AddOns-->YafaRay v3 and enable it. Then, click save settings and close the User Preferences window. 53 | 54 | # Now you should be able to render the test01.blend file. 55 | -------------------------------------------------------------------------------- /building/linux/YafaRay Ubuntu 16.04 building - Standalone.txt: -------------------------------------------------------------------------------- 1 | # UBUNTU 16.04 YafaRay Standalone building procedure (only valid for YafaRay v3.1.2 or higher) 2 | # NOTE: This procedure generates a "yafaray_v3" folder that can be used by 3rd party software, or by 3 | # executing yafaray_v3/bin/yafaray-xml to render a YafaRay XML scene file 4 | 5 | # INSTALLING DEVEL TOOLS 6 | sudo apt-get install -y git cmake cmake-curses-gui autoconf gcc g++ cpp swig 7 | 8 | # INSTALLING LIBRARY DEPENDENCIES 9 | sudo apt-get install -y python3-dev zlib1g-dev libpng-dev libfreetype6-dev libxml2-dev libtiff5-dev libopencv-dev libjpeg-dev libopenexr-dev 10 | 11 | # DOWNLOADING YAFARAY AND SETTING UP FOLDERS 12 | mkdir -p $HOME/yafa-dev/src $HOME/yafa-dev/make $HOME/yafa-dev/build 13 | cd $HOME/yafa-dev/src 14 | git clone https://github.com/YafaRay/Core 15 | 16 | # CREATE UserConfig.txt FILE WITH YAFARAY BUILDING OPTIONS. Execute the entire block below until (including) EOF 17 | 18 | cat <$HOME/yafa-dev/make/UserConfig.txt 19 | #################################################################### 20 | # UserConfig File to build for Ubuntu 16.04 Standalone 21 | #################################################################### 22 | # WARNING: DON'T TOUCH THE NEXT LINE 23 | set(YAF_USER_CONFIG ON) 24 | #################################################################### 25 | 26 | set(DEBUG_BUILD OFF) 27 | set(USER_INSTALL_PREFIX "$HOME/yafa-dev/build/yafaray_v3/") 28 | set(BLENDER_ADDON OFF) 29 | set(YAF_PY_VERSION 3.5) 30 | #################################################################### 31 | EOF 32 | 33 | 34 | # BUILDING YAFARAY 35 | cd $HOME/yafa-dev/make 36 | cmake $HOME/yafa-dev/src/Core 37 | # Note: "-j9" uses 9 threads in this example for speeding up the building process. It can be changed to "-j" depending on the number of cores of the processor used for building YafaRay. 38 | make -j9 39 | make install -j9 40 | 41 | # TESTING YAFARAY 42 | cd $HOME/yafa-dev/build/yafaray_v3/share/yafaray/tests/test01/ 43 | $HOME/yafa-dev/build/yafaray_v3/bin/yafaray-xml -f png test01.xml test01_render 44 | -------------------------------------------------------------------------------- /building/linux/YafaRay Ubuntu 16.10 building - Blender AddOn.txt: -------------------------------------------------------------------------------- 1 | # UBUNTU 16.10 YafaRay Blender Add-On building procedure (only valid for YafaRay v3.1.2 or higher) 2 | # NOTE: This procedure generates a "yafaray_v3" folder that can be installed in the Blender Add-Ons folder 3 | # However, this only works for the Blender included in the distro (currently 2.77). When using this 4 | # yafaray_v3 folder with the Blender downloaded from www.blender.org there might be conflicts with the 5 | # Blender EXR, PNG and JPEG libraries. 6 | 7 | # INSTALLING DEVEL TOOLS 8 | sudo apt-get install -y git cmake cmake-curses-gui autoconf gcc g++ cpp swig 9 | 10 | # INSTALLING BLENDER 11 | sudo apt-get install -y blender 12 | 13 | # INSTALLING LIBRARY DEPENDENCIES 14 | sudo apt-get install -y python3-dev zlib1g-dev libpng-dev libfreetype6-dev libxml2-dev libtiff5-dev libopencv-dev libjpeg-dev libopenexr-dev 15 | 16 | # DOWNLOADING YAFARAY AND SETTING UP FOLDERS 17 | mkdir -p $HOME/yafa-dev/src $HOME/yafa-dev/make $HOME/yafa-dev/build 18 | cd $HOME/yafa-dev/src 19 | git clone https://github.com/YafaRay/Blender-Exporter 20 | git clone https://github.com/YafaRay/Core 21 | 22 | # CREATE UserConfig.txt FILE WITH YAFARAY BUILDING OPTIONS. Execute the entire block below until (including) EOF 23 | 24 | cat <$HOME/yafa-dev/make/UserConfig.txt 25 | #################################################################### 26 | # UserConfig File to build for Ubuntu 16.10 Blender Add-On 27 | #################################################################### 28 | # WARNING: DON'T TOUCH THE NEXT LINE 29 | set(YAF_USER_CONFIG ON) 30 | #################################################################### 31 | 32 | set(DEBUG_BUILD OFF) 33 | set(USER_INSTALL_PREFIX "$HOME/yafa-dev/build/yafaray_v3/") 34 | set(BLENDER_ADDON ON) 35 | set(YAF_PY_VERSION 3.5) 36 | set(BLENDER_EXPORTER_PATH "$HOME/yafa-dev/src/Blender-Exporter") 37 | #################################################################### 38 | EOF 39 | 40 | # BUILDING YAFARAY 41 | cd $HOME/yafa-dev/make 42 | cmake $HOME/yafa-dev/src/Core 43 | # Note: "-j9" uses 9 threads in this example for speeding up the building process. It can be changed to "-j" depending on the number of cores of the processor used for building YafaRay. 44 | make -j9 45 | make install -j9 46 | 47 | # TEST IN BLENDER 48 | mkdir -p $HOME/.config/blender/2.77/scripts/addons 49 | cp -R $HOME/yafa-dev/build/yafaray_v3 $HOME/.config/blender/2.77/scripts/addons/yafaray_v3 50 | blender $HOME/yafa-dev/build/yafaray_v3/tests/test01/test01.blend 51 | 52 | # In Blender, go to File->User Preferences->AddOns-->YafaRay v3 and enable it. Then, click save settings and close the User Preferences window. 53 | 54 | # Now you should be able to render the test01.blend file. 55 | -------------------------------------------------------------------------------- /building/linux/YafaRay Ubuntu 16.10 building - Standalone.txt: -------------------------------------------------------------------------------- 1 | # UBUNTU 16.10 YafaRay Standalone building procedure (only valid for YafaRay v3.1.2 or higher) 2 | # NOTE: This procedure generates a "yafaray_v3" folder that can be used by 3rd party software, or by 3 | # executing yafaray_v3/bin/yafaray-xml to render a YafaRay XML scene file 4 | 5 | # INSTALLING DEVEL TOOLS 6 | sudo apt-get install -y git cmake cmake-curses-gui autoconf gcc g++ cpp swig 7 | 8 | # INSTALLING LIBRARY DEPENDENCIES 9 | sudo apt-get install -y python3-dev zlib1g-dev libpng-dev libfreetype6-dev libxml2-dev libtiff5-dev libopencv-dev libjpeg-dev libopenexr-dev 10 | 11 | # DOWNLOADING YAFARAY AND SETTING UP FOLDERS 12 | mkdir -p $HOME/yafa-dev/src $HOME/yafa-dev/make $HOME/yafa-dev/build 13 | cd $HOME/yafa-dev/src 14 | git clone https://github.com/YafaRay/Core 15 | 16 | # CREATE UserConfig.txt FILE WITH YAFARAY BUILDING OPTIONS. Execute the entire block below until (including) EOF 17 | 18 | cat <$HOME/yafa-dev/make/UserConfig.txt 19 | #################################################################### 20 | # UserConfig File to build for Ubuntu 16.10 Standalone 21 | #################################################################### 22 | # WARNING: DON'T TOUCH THE NEXT LINE 23 | set(YAF_USER_CONFIG ON) 24 | #################################################################### 25 | 26 | set(DEBUG_BUILD OFF) 27 | set(USER_INSTALL_PREFIX "$HOME/yafa-dev/build/yafaray_v3/") 28 | set(BLENDER_ADDON OFF) 29 | set(YAF_PY_VERSION 3.5) 30 | #################################################################### 31 | EOF 32 | 33 | 34 | # BUILDING YAFARAY 35 | cd $HOME/yafa-dev/make 36 | cmake $HOME/yafa-dev/src/Core 37 | # Note: "-j9" uses 9 threads in this example for speeding up the building process. It can be changed to "-j" depending on the number of cores of the processor used for building YafaRay. 38 | make -j9 39 | make install -j9 40 | 41 | # TESTING YAFARAY 42 | cd $HOME/yafa-dev/build/yafaray_v3/share/yafaray/tests/test01/ 43 | $HOME/yafa-dev/build/yafaray_v3/bin/yafaray-xml -f png test01.xml test01_render 44 | -------------------------------------------------------------------------------- /include/cameras/angularCamera.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef Y_ANGULARCAMERA_H 4 | #define Y_ANGULARCAMERA_H 5 | 6 | #include 7 | #include 8 | 9 | __BEGIN_YAFRAY 10 | 11 | class paraMap_t; 12 | class renderEnvironment_t; 13 | 14 | enum class AngularProjection : int //Fish Eye Projections as defined in https://en.wikipedia.org/wiki/Fisheye_lens 15 | { 16 | Equidistant = 0, //Default and used traditionally in YafaRay 17 | Orthographic = 1, //Orthographic projection where the centre of the image is enlarged/more defined at the cost of much more distorted edges 18 | Stereographic = 2, 19 | EquisolidAngle = 3, 20 | Rectilinear = 4, 21 | }; 22 | 23 | class angularCam_t: public camera_t 24 | { 25 | public: 26 | angularCam_t(const point3d_t &pos, const point3d_t &look, const point3d_t &up, 27 | int _resx, int _resy, float aspect, float angle, float max_angle, bool circ, const AngularProjection &projection, 28 | float const near_clip_distance = 0.0f, float const far_clip_distance = 1e6f); 29 | virtual void setAxis(const vector3d_t &vx, const vector3d_t &vy, const vector3d_t &vz); 30 | virtual ray_t shootRay(float px, float py, float lu, float lv, float &wt) const; 31 | virtual point3d_t screenproject(const point3d_t &p) const; 32 | 33 | static camera_t* factory(paraMap_t ¶ms, renderEnvironment_t &render); 34 | protected: 35 | float aspect; 36 | float focal_length; 37 | float max_radius; 38 | bool circular; 39 | AngularProjection projection; 40 | }; 41 | 42 | 43 | __END_YAFRAY 44 | 45 | #endif // Y_ANGULARCAMERA_H 46 | -------------------------------------------------------------------------------- /include/cameras/architectCamera.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef Y_ARCHITECTCAMERA_H 4 | #define Y_ARCHITECTCAMERA_H 5 | 6 | #include 7 | #include 8 | 9 | __BEGIN_YAFRAY 10 | 11 | class paraMap_t; 12 | class renderEnvironment_t; 13 | 14 | class architectCam_t: public perspectiveCam_t 15 | { 16 | public: 17 | architectCam_t(const point3d_t &pos, const point3d_t &look, const point3d_t &up, 18 | int _resx, int _resy, float aspect=1, 19 | float df=1, float ap=0, float dofd=0, bokehType bt=BK_DISK1, bkhBiasType bbt=BB_NONE, float bro=0, 20 | float const near_clip_distance = 0.0f, float const far_clip_distance = 1e6f); 21 | virtual ~architectCam_t(); 22 | virtual void setAxis(const vector3d_t &vx, const vector3d_t &vy, const vector3d_t &vz); 23 | virtual point3d_t screenproject(const point3d_t &p) const; 24 | 25 | static camera_t* factory(paraMap_t ¶ms, renderEnvironment_t &render); 26 | }; 27 | 28 | __END_YAFRAY 29 | 30 | #endif // Y_ARCHITECTCAMERA_H 31 | -------------------------------------------------------------------------------- /include/cameras/equirectangularCamera.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef Y_EQUIRECTANGULARCAMERA_H 4 | #define Y_EQUIRECTANGULARCAMERA_H 5 | 6 | #include 7 | #include 8 | 9 | __BEGIN_YAFRAY 10 | 11 | class paraMap_t; 12 | class renderEnvironment_t; 13 | 14 | 15 | class equirectangularCam_t: public camera_t 16 | { 17 | public: 18 | equirectangularCam_t(const point3d_t &pos, const point3d_t &look, const point3d_t &up, 19 | int _resx, int _resy, float aspect, 20 | float const near_clip_distance = 0.0f, float const far_clip_distance = 1e6f); 21 | virtual void setAxis(const vector3d_t &vx, const vector3d_t &vy, const vector3d_t &vz); 22 | virtual ray_t shootRay(float px, float py, float lu, float lv, float &wt) const; 23 | virtual point3d_t screenproject(const point3d_t &p) const; 24 | 25 | static camera_t* factory(paraMap_t ¶ms, renderEnvironment_t &render); 26 | protected: 27 | float aspect; 28 | }; 29 | 30 | 31 | __END_YAFRAY 32 | 33 | #endif // Y_EQUIRECTANGULARCAMERA_H 34 | -------------------------------------------------------------------------------- /include/cameras/orthographicCamera.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef Y_ORTHOGRAPHICCAMERA_H 4 | #define Y_ORTHOGRAPHICCAMERA_H 5 | 6 | #include 7 | #include 8 | 9 | __BEGIN_YAFRAY 10 | 11 | class paraMap_t; 12 | class renderEnvironment_t; 13 | 14 | class orthoCam_t: public camera_t 15 | { 16 | public: 17 | orthoCam_t(const point3d_t &pos, const point3d_t &look, const point3d_t &up, 18 | int _resx, int _resy, float aspect, float scale, 19 | float const near_clip_distance = 0.0f, float const far_clip_distance = 1e6f); 20 | virtual void setAxis(const vector3d_t &vx, const vector3d_t &vy, const vector3d_t &vz); 21 | virtual ray_t shootRay(float px, float py, float lu, float lv, float &wt) const; 22 | virtual point3d_t screenproject(const point3d_t &p) const; 23 | 24 | static camera_t* factory(paraMap_t ¶ms, renderEnvironment_t &render); 25 | protected: 26 | float scale; 27 | point3d_t pos; 28 | }; 29 | 30 | __END_YAFRAY 31 | 32 | #endif // Y_ORTHOGRAPHICCAMERA_H 33 | -------------------------------------------------------------------------------- /include/cameras/perspectiveCamera.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef Y_PERSPECTIVECAMERA_H 4 | #define Y_PERSPECTIVECAMERA_H 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | __BEGIN_YAFRAY 11 | 12 | class paraMap_t; 13 | class renderEnvironment_t; 14 | 15 | class perspectiveCam_t: public camera_t 16 | { 17 | public: 18 | enum bokehType {BK_DISK1, BK_DISK2, BK_TRI=3, BK_SQR, BK_PENTA, BK_HEXA, BK_RING}; 19 | enum bkhBiasType {BB_NONE, BB_CENTER, BB_EDGE}; 20 | perspectiveCam_t(const point3d_t &pos, const point3d_t &look, const point3d_t &up, 21 | int _resx, int _resy, float aspect=1, 22 | float df=1, float ap=0, float dofd=0, bokehType bt=BK_DISK1, bkhBiasType bbt=BB_NONE, float bro=0, 23 | float const near_clip_distance = 0.0f, float const far_clip_distance = 1e6f); 24 | virtual ~perspectiveCam_t(); 25 | virtual void setAxis(const vector3d_t &vx, const vector3d_t &vy, const vector3d_t &vz); 26 | virtual ray_t shootRay(float px, float py, float lu, float lv, float &wt) const; 27 | virtual bool sampleLense() const; 28 | virtual point3d_t screenproject(const point3d_t &p) const; 29 | 30 | virtual bool project(const ray_t &wo, float lu, float lv, float &u, float &v, float &pdf) const; 31 | 32 | static camera_t* factory(paraMap_t ¶ms, renderEnvironment_t &render); 33 | protected: 34 | void biasDist(float &r) const; 35 | void sampleTSD(float r1, float r2, float &u, float &v) const; 36 | void getLensUV(float r1, float r2, float &u, float &v) const; 37 | 38 | bokehType bkhtype; 39 | bkhBiasType bkhbias; 40 | vector3d_t dof_up, dof_rt; 41 | float aperture; 42 | float focal_distance, dof_distance; 43 | float fdist; 44 | float A_pix; 45 | std::vector LS; 46 | }; 47 | 48 | __END_YAFRAY 49 | 50 | #endif // Y_PERSPECTIVECAMERA_H 51 | -------------------------------------------------------------------------------- /include/core_api/background.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef Y_BACKGROUND_H 4 | #define Y_BACKGROUND_H 5 | 6 | #include 7 | 8 | __BEGIN_YAFRAY 9 | 10 | struct renderState_t; 11 | class light_t; 12 | class color_t; 13 | class ray_t; 14 | 15 | class YAFRAYCORE_EXPORT background_t 16 | { 17 | public: 18 | //! get the background color for a given ray 19 | virtual color_t operator() (const ray_t &ray, renderState_t &state, bool from_postprocessed=false) const=0; 20 | virtual color_t eval(const ray_t &ray, bool from_postprocessed=false) const=0; 21 | /*! get the light source representing background lighting. 22 | \return the light source that reproduces background lighting, or nullptr if background 23 | shall only be sampled from BSDFs 24 | */ 25 | virtual bool hasIBL() { return false; } 26 | virtual bool shootsCaustic() { return false; } 27 | virtual ~background_t() {}; 28 | }; 29 | 30 | __END_YAFRAY 31 | 32 | #endif // Y_BACKGROUND_H 33 | -------------------------------------------------------------------------------- /include/core_api/color_console.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | /**************************************************************************** 3 | * color_console.h: A console coloring utility 4 | * This is part of the yafray package 5 | * Copyright (C) 2010 Rodrigo Placencia Vazquez 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #ifndef Y_COLOR_CONSOLE_H 23 | #define Y_COLOR_CONSOLE_H 24 | 25 | #include 26 | #include 27 | 28 | __BEGIN_YAFRAY 29 | 30 | typedef unsigned int yColor; 31 | 32 | enum 33 | { 34 | #if !defined(_WIN32) 35 | Black, 36 | Red, 37 | Green, 38 | Yellow, 39 | Blue, 40 | Magenta, 41 | Cyan, 42 | White, 43 | Default 44 | #else 45 | Black = 0x0000, 46 | Red = 0x0004, 47 | Green = 0x0002, 48 | Yellow = Red | Green, 49 | Blue = 0x0001, 50 | Magenta = Blue | Red, 51 | Cyan = Blue | Green, 52 | White = Red | Green | Blue, 53 | Default = 0xFFFF 54 | #endif 55 | }; 56 | 57 | struct YAFRAYCORE_EXPORT setColor 58 | { 59 | setColor() : fgCol(Default), bgCol(Default), intense(false) {} 60 | setColor(yColor fgColor, yColor bgColor, bool intensecolor = false) 61 | { 62 | #ifdef _WIN32 63 | fgCol = fgColor; 64 | bgCol = (bgColor != Default) ? bgColor << 4 : Default; 65 | #else 66 | fgCol = (fgColor != Default) ? fgColor + 30 : Default; 67 | bgCol = (bgColor != Default) ? bgColor + 40 : Default; 68 | #endif 69 | intense = intensecolor; 70 | } 71 | setColor(yColor fgColor, bool intensecolor = false) 72 | { 73 | #ifdef _WIN32 74 | fgCol = fgColor; 75 | #else 76 | fgCol = (fgColor != Default) ? fgColor + 30 : Default; 77 | #endif 78 | bgCol = Default; 79 | intense = intensecolor; 80 | } 81 | 82 | yColor fgCol; 83 | yColor bgCol; 84 | bool intense; 85 | }; 86 | 87 | 88 | YAFRAYCORE_EXPORT std::ostream &operator<<(std::ostream& o, const setColor& c); 89 | 90 | __END_YAFRAY 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /include/core_api/color_ramp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | /**************************************************************************** 3 | * 4 | * color_ramp.h: Color Ramps api 5 | * This is part of the yafray package 6 | * Copyright (C) 2016 David Bluecame 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this library; if not, write to the Free Software 20 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | * 22 | */ 23 | #ifndef Y_COLOR_RAMP_H 24 | #define Y_COLOR_RAMP_H 25 | 26 | #include 27 | #include 28 | 29 | __BEGIN_YAFRAY 30 | 31 | enum color_ramp_mode_t 32 | { 33 | C_RAMP_RGB, 34 | C_RAMP_HSV, 35 | C_RAMP_HSL //Not yet supported, using HSV instead 36 | }; 37 | 38 | enum color_ramp_interpolation_t 39 | { 40 | C_RAMP_CONSTANT, 41 | C_RAMP_LINEAR, 42 | C_RAMP_BSPLINE, //Not yet supported 43 | C_RAMP_CARDINAL, //Not yet supported 44 | C_RAMP_EASE //Not yet supported 45 | }; 46 | 47 | enum color_ramp_hue_interpolation_t 48 | { 49 | C_RAMP_HUE_NEAR, 50 | C_RAMP_HUE_FAR, 51 | C_RAMP_HUE_CLOCKWISE, 52 | C_RAMP_HUE_COUNTERCLOCKWISE 53 | }; 54 | 55 | class YAFRAYCORE_EXPORT color_ramp_item_t 56 | { 57 | friend class color_ramp_t; 58 | 59 | public: 60 | color_ramp_item_t(float pos) : position(pos) {} 61 | color_ramp_item_t(const colorA_t & col, float pos) : color(col), position(pos) {} 62 | bool operator < (const color_ramp_item_t& item) const { return (position < item.position); } 63 | bool operator > (const color_ramp_item_t& item) const { return (position > item.position); } 64 | 65 | protected: 66 | colorA_t color = colorA_t(0.f, 0.f, 0.f, 1.f); 67 | float position = 0.f; 68 | }; 69 | 70 | class YAFRAYCORE_EXPORT color_ramp_t 71 | { 72 | public: 73 | color_ramp_t(int mode, int interpolation, int hue_interpolation); 74 | color_ramp_t(std::string modeStr, std::string interpolationStr, std::string hue_interpolationStr); 75 | void add_item(const colorA_t & color, float position); 76 | colorA_t get_color_interpolated(float pos) const; 77 | 78 | protected: 79 | int ramp_mode = C_RAMP_RGB; 80 | int ramp_interpolation = C_RAMP_LINEAR; 81 | int ramp_hue_interpolation = C_RAMP_HUE_NEAR; 82 | std::vector ramp; 83 | }; 84 | 85 | __END_YAFRAY 86 | 87 | #endif // Y_COLOR_RAMP_H 88 | -------------------------------------------------------------------------------- /include/core_api/dynamic_library.h: -------------------------------------------------------------------------------- 1 | #ifndef __YAFSYSTEM_H 2 | #define __YAFSYSTEM_H 3 | 4 | #include 5 | 6 | #ifdef WIN32 7 | #include 8 | #include 9 | #endif 10 | 11 | #include 12 | #include 13 | 14 | __BEGIN_YAFRAY 15 | 16 | class YAFRAYCORE_EXPORT dynamicLoadedLibrary_t 17 | { 18 | public: 19 | dynamicLoadedLibrary_t(); 20 | dynamicLoadedLibrary_t(const std::string &library); 21 | dynamicLoadedLibrary_t(const dynamicLoadedLibrary_t &src); 22 | ~dynamicLoadedLibrary_t(); 23 | 24 | bool isOpen(); 25 | void* getSymbol(const char *name); 26 | 27 | protected: 28 | 29 | void open(const std::string &library); 30 | void close(); 31 | void addReference() { (*refcount)++; }; 32 | void removeReference() { (*refcount)--; }; 33 | bool isUsed()const {return ((*refcount)>0);}; 34 | 35 | 36 | int *refcount; 37 | #ifdef WIN32 38 | HINSTANCE handle; 39 | #else 40 | void *handle; 41 | #endif 42 | }; 43 | 44 | __END_YAFRAY 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /include/core_api/imagesplitter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef Y_IMAGESPLITTER_H 4 | #define Y_IMAGESPLITTER_H 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | __BEGIN_YAFRAY 12 | 13 | struct renderArea_t 14 | { 15 | renderArea_t(int x,int y,int w,int h):X(x),Y(y),W(w),H(h), 16 | realX(x),realY(y),realW(w),realH(h),resample(w*h) 17 | {}; 18 | renderArea_t() {}; 19 | 20 | void set(int x,int y,int w,int h) 21 | { 22 | realX=X=x; 23 | realY=Y=y; 24 | realW=W=w; 25 | realH=H=h; 26 | // image.resize(w*h); 27 | // depth.resize(w*h); 28 | resample.resize(w*h); 29 | } 30 | void setReal(int x,int y,int w,int h) 31 | { 32 | realX=x; 33 | realY=y; 34 | realW=w; 35 | realH=h; 36 | } 37 | bool checkResample(float threshold); 38 | // bool out(colorOutput_t &o); 39 | 40 | // colorA_t & imagePixel(int x,int y) {return image[(y-Y)*W+(x-X)];}; 41 | // float & depthPixel(int x,int y) {return depth[(y-Y)*W+(x-X)];}; 42 | bool resamplePixel(int x,int y) {return resample[(y-Y)*W+(x-X)];}; 43 | 44 | int X,Y,W,H,realX,realY,realW,realH; 45 | int sx0, sx1, sy0, sy1; //!< safe area, i.e. region unaffected by samples outside (needs to be set by ImageFilm_t) 46 | // std::vector image; 47 | // std::vector depth; 48 | std::vector resample; 49 | }; 50 | 51 | /*! Splits the image to be rendered into pieces, e.g. "buckets" for 52 | different threads. 53 | CAUTION! Some methods need to be thread save! 54 | */ 55 | class imageSpliter_t 56 | { 57 | public: 58 | enum tilesOrderType { LINEAR, RANDOM, CENTRE_RANDOM }; 59 | imageSpliter_t() {}; 60 | imageSpliter_t(int w, int h, int x0,int y0, int bsize, tilesOrderType torder, int nthreads); 61 | /* return the n-th area to be rendered. 62 | \return false if n is out of range, true otherwise 63 | */ 64 | bool getArea(int n, renderArea_t &area); 65 | 66 | bool empty()const {return regions.empty();}; 67 | int size()const {return regions.size();}; 68 | 69 | protected: 70 | friend class imageSpliterCentreSorter_t; 71 | struct region_t 72 | { 73 | int x,y,w,h; 74 | // int rx,ry,rw,rh; 75 | }; 76 | int width,height,blocksize; 77 | std::vector regions; 78 | tilesOrderType tilesorder; 79 | }; 80 | 81 | class imageSpliterCentreSorter_t { 82 | int imageW, imageH, imageX0, imageY0; 83 | public: 84 | 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) {} 85 | bool operator()(imageSpliter_t::region_t const & a, imageSpliter_t::region_t const & b) const 86 | { 87 | 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)); 88 | } 89 | }; 90 | 91 | 92 | __END_YAFRAY 93 | 94 | #endif // Y_IMAGESPLITTER_H 95 | -------------------------------------------------------------------------------- /include/core_api/integrator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | /**************************************************************************** 3 | * integrator.h: the interface definition for light integrators 4 | * This is part of the yafray package 5 | * Copyright (C) 2006 Mathias Wein (Lynx) 6 | * Copyright (C) 2010 Rodrigo Placencia (DarkTide) 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this library; if not, write to the Free Software 20 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | */ 22 | 23 | #ifndef Y_INTEGRATOR_H 24 | #define Y_INTEGRATOR_H 25 | 26 | #include 27 | #include 28 | 29 | __BEGIN_YAFRAY 30 | 31 | /*! Integrate the incoming light scattered by the surfaces 32 | hit by a given ray 33 | */ 34 | 35 | class scene_t; 36 | class progressBar_t; 37 | class imageFilm_t; 38 | struct renderArea_t; 39 | class colorA_t; 40 | struct renderState_t; 41 | class ray_t; 42 | class diffRay_t; 43 | class colorPasses_t; 44 | 45 | 46 | class YAFRAYCORE_EXPORT integrator_t 47 | { 48 | public: 49 | integrator_t() { scene = nullptr; intpb = nullptr; } 50 | //! this MUST be called before any other member function! 51 | void setScene(scene_t *s) { scene=s; } 52 | /*! do whatever is required to render the image, if suitable for integrating whole image */ 53 | virtual bool render(int numView, imageFilm_t *imageFilm) { return false; } 54 | virtual void setProgressBar(progressBar_t *pb) { intpb = pb; } 55 | virtual std::string getShortName() const { return integratorShortName; } 56 | virtual std::string getName() const { return integratorName; } 57 | virtual ~integrator_t() {} 58 | enum TYPE { SURFACE, VOLUME }; 59 | TYPE integratorType(){ return type; } 60 | 61 | protected: 62 | TYPE type; 63 | scene_t *scene; 64 | progressBar_t *intpb; 65 | std::string integratorName; 66 | std::string integratorShortName; 67 | }; 68 | 69 | class YAFRAYCORE_EXPORT surfaceIntegrator_t: public integrator_t 70 | { 71 | public: 72 | /*! gets called before the scene rendering (i.e. before first call to integrate) 73 | \return false when preprocessing could not be done properly, true otherwise */ 74 | virtual bool preprocess() { return true; }; 75 | /*! allow the integrator to do some cleanup when an image is done 76 | (possibly also important for multiframe rendering in the future) */ 77 | virtual void cleanup() {} 78 | virtual colorA_t integrate(renderState_t &state, diffRay_t &ray, colorPasses_t &colPasses, int additionalDepth = 0) const = 0; 79 | protected: 80 | surfaceIntegrator_t() {} //don't use... 81 | }; 82 | 83 | class YAFRAYCORE_EXPORT volumeIntegrator_t: public integrator_t 84 | { 85 | public: 86 | volumeIntegrator_t() {} 87 | virtual colorA_t transmittance(renderState_t &state, ray_t &ray) const = 0; 88 | virtual colorA_t integrate(renderState_t &state, ray_t &ray, colorPasses_t &colPasses, int additionalDepth = 0) const = 0; 89 | virtual bool preprocess() { return true; } 90 | 91 | protected: 92 | }; 93 | 94 | __END_YAFRAY 95 | 96 | #endif // Y_INTEGRATOR_H 97 | -------------------------------------------------------------------------------- /include/core_api/output.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | /**************************************************************************** 3 | * 4 | * output.h: Output base class 5 | * This is part of the yafray package 6 | * Copyright (C) 2002 Alejandro Conty Estévez 7 | * Modifyed by Rodrigo Placencia Vazquez (2009) 8 | * 9 | * This library is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU Lesser General Public 11 | * License as published by the Free Software Foundation; either 12 | * version 2.1 of the License, or (at your option) any later version. 13 | * 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | * Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public 20 | * License along with this library; if not, write to the Free Software 21 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | * 23 | */ 24 | #ifndef Y_COUTPUT_H 25 | #define Y_COUTPUT_H 26 | 27 | #include "yafray_constants.h" 28 | #include 29 | #include 30 | 31 | __BEGIN_YAFRAY 32 | 33 | class renderPasses_t; 34 | class colorA_t; 35 | 36 | /*! Base class for rendering output containers */ 37 | 38 | class colorOutput_t 39 | { 40 | public: 41 | virtual ~colorOutput_t() {}; 42 | virtual void initTilesPasses(int totalViews, int numExtPasses) {}; 43 | virtual bool putPixel(int numView, int x, int y, const renderPasses_t *renderPasses, int idx, const colorA_t &color, bool alpha = true)=0; 44 | virtual bool putPixel(int numView, int x, int y, const renderPasses_t *renderPasses, const std::vector &colExtPasses, bool alpha = true)=0; 45 | virtual void flush(int numView, const renderPasses_t *renderPasses)=0; 46 | virtual void flushArea(int numView, int x0, int y0, int x1, int y1, const renderPasses_t *renderPasses)=0; 47 | virtual void highliteArea(int numView, int x0, int y0, int x1, int y1){}; 48 | virtual bool isImageOutput() { return false; } 49 | virtual bool isPreview() { return false; } 50 | virtual std::string getDenoiseParams() const { return ""; } 51 | }; 52 | 53 | __END_YAFRAY 54 | 55 | #endif // Y_COUTPUT_H 56 | -------------------------------------------------------------------------------- /include/core_api/primitive.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef Y_PRIMITIVE_H 4 | #define Y_PRIMITIVE_H 5 | 6 | #include 7 | #include "surface.h" 8 | #include "bound.h" 9 | #include "ray.h" 10 | 11 | __BEGIN_YAFRAY 12 | 13 | class triangleObject_t; 14 | class material_t; 15 | 16 | class YAFRAYCORE_EXPORT primitive_t 17 | { 18 | public: 19 | /*! return the object bound in global ("world") coordinates */ 20 | virtual bound_t getBound() const = 0; 21 | /*! a possibly more precise check to find out if the primitve really 22 | intersects the bound of interest, given that the primitive's bound does. 23 | used e.g. for optimized kd-tree construction */ 24 | virtual bool intersectsBound(exBound_t &b) const { return true; }; 25 | /*! indicate if the object has a clipping implementation */ 26 | virtual bool clippingSupport() const { return false; } 27 | /*! calculate the overlapping box of given bound and primitive 28 | \return: false:=doesn't overlap bound; true:=valid clip exists */ 29 | virtual bool clipToBound(double bound[2][3], int axis, bound_t &clipped, void *d_old, void *d_new) const {return false;} 30 | /*! basic ray primitive interection for raytracing. 31 | This should NOT skip intersections outside of [tmin,tmax], unless negative. 32 | The caller decides wether t matters or not. 33 | \return false if ray misses primitive, true otherwise 34 | \param t set this to raydepth where hit occurs */ 35 | virtual bool intersect(const ray_t &ray, float *t, intersectData_t &data) const = 0; 36 | /* fill in surfacePoint_t */ 37 | virtual void getSurface(surfacePoint_t &sp, const point3d_t &hit, intersectData_t &data) const = 0; 38 | /* return the material */ 39 | virtual const material_t* getMaterial() const = 0; 40 | virtual ~primitive_t(){}; 41 | }; 42 | 43 | __END_YAFRAY 44 | 45 | #endif // Y_PRIMITIVE_H 46 | -------------------------------------------------------------------------------- /include/core_api/ray.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef Y_RAY_H 4 | #define Y_RAY_H 5 | 6 | #include 7 | #include "vector3d.h" 8 | 9 | __BEGIN_YAFRAY 10 | 11 | class ray_t 12 | { 13 | public: 14 | ray_t(): tmin(0), tmax(-1.0), time(0.0) {} 15 | ray_t(const point3d_t &f, const vector3d_t &d, float start=0.0, float end=-1.0, float ftime=0.0): 16 | from(f), dir(d), tmin(start), tmax(end), time(ftime) { } 17 | 18 | point3d_t from; 19 | vector3d_t dir; 20 | mutable float tmin, tmax; 21 | float time; //!< relative frame time (values between [0;1]) at which ray was generated 22 | }; 23 | 24 | class diffRay_t: public ray_t 25 | { 26 | public: 27 | diffRay_t(): ray_t(), hasDifferentials(false) {} 28 | diffRay_t(const ray_t &r): ray_t(r), hasDifferentials(false) {} 29 | diffRay_t(const point3d_t &f, const vector3d_t &d, float start=0.0, float end=-1.0, float ftime=0.0): 30 | ray_t(f, d, start, end, ftime), hasDifferentials(false) {} 31 | bool hasDifferentials; 32 | point3d_t xfrom, yfrom; 33 | vector3d_t xdir, ydir; 34 | }; 35 | 36 | __END_YAFRAY 37 | 38 | #endif //Y_RAY_H 39 | -------------------------------------------------------------------------------- /include/core_api/session.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | /**************************************************************************** 3 | * session.h: YafaRay Session control 4 | * This is part of the yafray package 5 | * Copyright (C) 2016 David Bluecame 6 | * Session control and persistent objects between renders 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this library; if not, write to the Free Software 20 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | */ 22 | 23 | #ifndef Y_SESSION_H 24 | #define Y_SESSION_H 25 | 26 | #include 27 | #include 28 | 29 | __BEGIN_YAFRAY 30 | 31 | class photonMap_t; 32 | 33 | class YAFRAYCORE_EXPORT session_t 34 | { 35 | public: 36 | session_t(); 37 | session_t(const session_t&); //customizing copy constructor so we can use a std::mutex as a class member (not copiable) 38 | 39 | ~session_t(); 40 | 41 | void setStatusRenderStarted(); 42 | void setStatusRenderResumed(); 43 | void setStatusRenderFinished(); 44 | void setStatusRenderAborted(); 45 | void setStatusTotalPasses(int total_passes); 46 | void setStatusCurrentPass(int current_pass); 47 | void setStatusCurrentPassPercent(float current_pass_percent); 48 | void setInteractive(bool interactive); 49 | void setPathYafaRayXml(std::string path); 50 | void setPathImageOutput(std::string path); 51 | void setDifferentialRaysEnabled(bool value) { mRayDifferentialsEnabled = value; } 52 | 53 | bool renderInProgress(); 54 | bool renderResumed(); 55 | bool renderFinished(); 56 | bool renderAborted(); 57 | bool getDifferentialRaysEnabled() const { return mRayDifferentialsEnabled; } 58 | 59 | int totalPasses(); 60 | int currentPass(); 61 | float currentPassPercent(); 62 | bool isInteractive(); 63 | std::string getPathYafaRayXml(); 64 | std::string getPathImageOutput(); 65 | 66 | photonMap_t * causticMap = nullptr; 67 | photonMap_t * diffuseMap = nullptr; 68 | photonMap_t * radianceMap = nullptr; 69 | 70 | std::mutex mutx; 71 | 72 | protected: 73 | bool mRenderInProgress = false; 74 | bool mRenderFinished = false; 75 | bool mRenderResumed = false; 76 | bool mRenderAborted = false; 77 | bool mRayDifferentialsEnabled = false; //!< By default, disable ray differential calculations. Only if at least one texture uses them, then enable differentials. This should avoid the (many) extra calculations when they are not necessary. 78 | int mTotalPasses = 0; 79 | int mCurrentPass = 0; 80 | float mCurrentPassPercent = 0.f; 81 | bool mInteractive = false; 82 | std::string mPathYafaRayXml; 83 | std::string mPathImageOutput; 84 | }; 85 | 86 | extern YAFRAYCORE_EXPORT session_t session; 87 | 88 | __END_YAFRAY 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /include/core_api/sysinfo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | /**************************************************************************** 3 | * sysinfo.h: runtime system information 4 | * This is part of the yafray package 5 | * Copyright (C) 2020 David Bluecame 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #ifndef Y_SYSINFO_H 23 | #define Y_SYSINFO_H 24 | 25 | #include 26 | 27 | __BEGIN_YAFRAY 28 | 29 | class YAFRAYCORE_EXPORT sysInfo_t 30 | { 31 | public: 32 | int getNumSystemThreads() const; 33 | }; 34 | 35 | __END_YAFRAY 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /include/core_api/volume.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef Y_VOLUMETRIC_H 4 | #define Y_VOLUMETRIC_H 5 | 6 | #include 7 | #include "bound.h" 8 | #include "color.h" 9 | #include 10 | 11 | __BEGIN_YAFRAY 12 | 13 | struct renderState_t; 14 | struct pSample_t; 15 | class light_t; 16 | class ray_t; 17 | 18 | class volumeHandler_t 19 | { 20 | public: 21 | virtual bool transmittance(const renderState_t &state, const ray_t &ray, color_t &col) const=0; 22 | virtual bool scatter(const renderState_t &state, const ray_t &ray, ray_t &sRay, pSample_t &s) const=0; 23 | virtual ~volumeHandler_t(){} 24 | }; 25 | 26 | class YAFRAYCORE_EXPORT VolumeRegion { 27 | public: 28 | VolumeRegion() {} 29 | VolumeRegion(color_t sa, color_t ss, color_t le, float gg, point3d_t pmin, point3d_t pmax, int attgridScale) { 30 | bBox = bound_t(pmin, pmax); 31 | s_a = sa; 32 | s_s = ss; 33 | l_e = le; 34 | g = gg; 35 | haveS_a = (s_a.energy() > 1e-4f); 36 | haveS_s = (s_s.energy() > 1e-4f); 37 | haveL_e = (l_e.energy() > 1e-4f); 38 | attGridX = 8 * attgridScale; 39 | attGridY = 8 * attgridScale; 40 | attGridZ = 8 * attgridScale; 41 | } 42 | 43 | virtual ~VolumeRegion(){} 44 | 45 | virtual color_t sigma_a(const point3d_t &p, const vector3d_t &v) = 0; 46 | virtual color_t sigma_s(const point3d_t &p, const vector3d_t &v) = 0; 47 | virtual color_t emission(const point3d_t &p, const vector3d_t &v) = 0; 48 | virtual color_t sigma_t(const point3d_t &p, const vector3d_t &v) { 49 | return sigma_a(p, v) + sigma_s(p, v); 50 | } 51 | 52 | float attenuation(const point3d_t p, light_t *l); 53 | 54 | // w_l: dir *from* the light, w_s: direction, into which should be scattered 55 | virtual float p(const vector3d_t &w_l, const vector3d_t &w_s) { 56 | float k = 1.55f * g - .55f * g * g * g; 57 | float kcostheta = k * (w_l * w_s); 58 | return 1.f / (4.f * M_PI) * (1.f - k * k) / ((1.f - kcostheta) * (1.f - kcostheta)); 59 | } 60 | 61 | virtual color_t tau(const ray_t &ray, float step, float offset) = 0; 62 | 63 | bool intersect(const ray_t &ray, float& t0, float& t1) { 64 | return bBox.cross(ray, t0, t1, 10000.f); 65 | } 66 | 67 | bound_t getBB() { return bBox; } 68 | 69 | std::map attenuationGridMap; 70 | int attGridX, attGridY, attGridZ; // FIXME: un-hardcode 71 | 72 | protected: 73 | bound_t bBox; 74 | color_t s_a, s_s, l_e; 75 | bool haveS_a, haveS_s, haveL_e; 76 | float g; 77 | // TODO: add transform for BB 78 | }; 79 | 80 | class YAFRAYCORE_EXPORT DensityVolume : public VolumeRegion { 81 | public: 82 | DensityVolume() {} 83 | DensityVolume(color_t sa, color_t ss, color_t le, float gg, point3d_t pmin, point3d_t pmax, int attgridScale) : 84 | VolumeRegion(sa, ss, le, gg, pmin, pmax, attgridScale) {} 85 | 86 | virtual ~DensityVolume(){} 87 | 88 | virtual float Density(point3d_t p) = 0; 89 | 90 | virtual color_t tau(const ray_t &ray, float stepSize, float offset); 91 | 92 | color_t sigma_a(const point3d_t &p, const vector3d_t &v) { 93 | if (!haveS_a) return color_t(0.f); 94 | if (bBox.includes(p)) { 95 | return s_a * Density(p); 96 | } 97 | else 98 | return color_t(0.f); 99 | 100 | } 101 | 102 | color_t sigma_s(const point3d_t &p, const vector3d_t &v) { 103 | if (!haveS_s) return color_t(0.f); 104 | if (bBox.includes(p)) { 105 | return s_s * Density(p); 106 | } 107 | else 108 | return color_t(0.f); 109 | } 110 | 111 | color_t emission(const point3d_t &p, const vector3d_t &v) { 112 | if (!haveL_e) return color_t(0.f); 113 | if (bBox.includes(p)) { 114 | return l_e * Density(p); 115 | } 116 | else 117 | return color_t(0.f); 118 | } 119 | 120 | }; 121 | 122 | 123 | 124 | __END_YAFRAY 125 | 126 | #endif // Y_VOLUMETRIC_H 127 | -------------------------------------------------------------------------------- /include/gui/yafqtapi.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef Y_QTAPI_H 4 | #define Y_QTAPI_H 5 | 6 | #ifdef BUILDING_QTPLUGIN 7 | #define YAFARAY_QT_EXPORT YF_EXPORT 8 | #else 9 | #define YAFARAY_QT_EXPORT YF_IMPORT 10 | #endif 11 | #include 12 | #include 13 | 14 | namespace yafaray 15 | { 16 | class yafrayInterface_t; 17 | } 18 | 19 | struct YAFARAY_QT_EXPORT Settings { 20 | bool autoSave; 21 | bool autoSaveAlpha; 22 | bool closeAfterFinish; 23 | std::string fileName; 24 | }; 25 | 26 | extern "C" 27 | { 28 | YAFARAY_QT_EXPORT void initGui(); 29 | YAFARAY_QT_EXPORT int createRenderWidget(yafaray::yafrayInterface_t *interf, int xsize, int ysize, int bStartX, int bStartY, Settings settings); 30 | } 31 | 32 | #endif // Y_QTAPI_H 33 | 34 | -------------------------------------------------------------------------------- /include/integrators/bidirpath.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef Y_BIDIRPATH_H 4 | #define Y_BIDIRPATH_H 5 | 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | __BEGIN_YAFRAY 16 | 17 | 18 | __END_YAFRAY 19 | 20 | #endif // BIDIRPATH 21 | -------------------------------------------------------------------------------- /include/integrators/directlight.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef Y_DIRECTLIGHT_H 4 | #define Y_DIRECTLIGHT_H 5 | 6 | #include 7 | 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #include 17 | #include 18 | 19 | __BEGIN_YAFRAY 20 | 21 | class YAFRAYPLUGIN_EXPORT directLighting_t: public mcIntegrator_t 22 | { 23 | public: 24 | directLighting_t(bool transpShad=false, int shadowDepth=4, int rayDepth=6); 25 | virtual bool preprocess(); 26 | virtual colorA_t integrate(renderState_t &state, diffRay_t &ray, colorPasses_t &colorPasses, int additionalDepth = 0) const; 27 | static integrator_t* factory(paraMap_t ¶ms, renderEnvironment_t &render); 28 | }; 29 | 30 | __END_YAFRAY 31 | 32 | #endif // DIRECTLIGHT 33 | -------------------------------------------------------------------------------- /include/integrators/integr_utils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | /**************************************************************************** 3 | * integr_utils.h: API for light integrator utilities 4 | * This is part of the yafray package 5 | * Copyright (C) 2006 Mathias Wein 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #ifndef Y_INTEGR_UTILS_H 23 | #define Y_INTEGR_UTILS_H 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | __BEGIN_YAFRAY 31 | 32 | class photonMap_t; 33 | 34 | //from common.cc 35 | 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); 36 | color_t estimatePhotons(renderState_t &state, const surfacePoint_t &sp, const photonMap_t &map, const vector3d_t &wo, int nSearch, float radius); 37 | 38 | 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"); 39 | 40 | __END_YAFRAY 41 | 42 | #endif // Y_INTEGR_UTILS_H 43 | -------------------------------------------------------------------------------- /include/integrators/pathtracer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef Y_PATHTRACER_H 4 | #define Y_PATHTRACER_H 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include 21 | 22 | #include 23 | #include 24 | 25 | __BEGIN_YAFRAY 26 | 27 | class YAFRAYPLUGIN_EXPORT pathIntegrator_t: public mcIntegrator_t 28 | { 29 | public: 30 | pathIntegrator_t(bool transpShad=false, int shadowDepth=4); 31 | virtual bool preprocess(); 32 | virtual colorA_t integrate(renderState_t &state, diffRay_t &ray, colorPasses_t &colorPasses, int additionalDepth = 0) const; 33 | static integrator_t* factory(paraMap_t ¶ms, renderEnvironment_t &render); 34 | enum { NONE, PATH, PHOTON, BOTH }; 35 | protected: 36 | bool traceCaustics; //!< use path tracing for caustics (determined by causticType) 37 | bool no_recursive; 38 | float invNPaths; 39 | int causticType; 40 | int russianRouletteMinBounces; //!< minimum number of bounces where russian roulette is not applied. Afterwards russian roulette will be used until the maximum selected bounces. If min_bounces >= max_bounces, then no russian roulette takes place 41 | }; 42 | 43 | __END_YAFRAY 44 | 45 | #endif // PATHTRACER 46 | -------------------------------------------------------------------------------- /include/integrators/photonintegr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef Y_PHOTONINTEGR_H 4 | #define Y_PHOTONINTEGR_H 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | __BEGIN_YAFRAY 29 | 30 | struct preGatherData_t 31 | { 32 | preGatherData_t(photonMap_t *dm): diffuseMap(dm), fetched(0) {} 33 | photonMap_t *diffuseMap; 34 | 35 | std::vector rad_points; 36 | std::vector radianceVec; 37 | progressBar_t *pbar; 38 | volatile int fetched; 39 | std::mutex mutx; 40 | }; 41 | 42 | class YAFRAYPLUGIN_EXPORT photonIntegrator_t: public mcIntegrator_t 43 | { 44 | public: 45 | photonIntegrator_t(unsigned int dPhotons, unsigned int cPhotons, bool transpShad=false, int shadowDepth = 4, float dsRad = 0.1f, float cRad = 0.01f); 46 | ~photonIntegrator_t(); 47 | virtual bool preprocess(); 48 | virtual colorA_t integrate(renderState_t &state, diffRay_t &ray, colorPasses_t &colorPasses, int additionalDepth = 0) const; 49 | static integrator_t* factory(paraMap_t ¶ms, renderEnvironment_t &render); 50 | virtual void preGatherWorker(preGatherData_t * gdata, float dsRad, int nSearch); 51 | 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); 52 | 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); 53 | virtual void photonMapKdTreeWorker(photonMap_t * photonMap); 54 | 55 | protected: 56 | color_t finalGathering(renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo, colorPasses_t &colorPasses) const; 57 | 58 | void enableCaustics(const bool caustics) { usePhotonCaustics = caustics; } 59 | void enableDiffuse(const bool diffuse) { usePhotonDiffuse = diffuse; } 60 | 61 | bool usePhotonDiffuse; //!< enable/disable diffuse photon processing 62 | bool finalGather, showMap; 63 | bool prepass; 64 | unsigned int nDiffusePhotons; 65 | int nDiffuseSearch; 66 | int gatherBounces; 67 | float dsRadius; //!< diffuse search radius 68 | float lookupRad; //!< square radius to lookup radiance photons, as infinity is no such good idea ;) 69 | float gatherDist; //!< minimum distance to terminate path tracing (unless gatherBounces is reached) 70 | friend class prepassWorker_t; 71 | }; 72 | 73 | __END_YAFRAY 74 | 75 | #endif // Y_PHOTONINTEGR_H 76 | -------------------------------------------------------------------------------- /include/interface/xmlinterface.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef Y_XMLINTERFACE_H 4 | #define Y_XMLINTERFACE_H 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | __BEGIN_YAFRAY 12 | 13 | class YAFRAYPLUGIN_EXPORT xmlInterface_t: public yafrayInterface_t 14 | { 15 | public: 16 | xmlInterface_t(); 17 | // directly related to scene_t: 18 | virtual void loadPlugins(const char *path); 19 | virtual bool setLoggingAndBadgeSettings(); 20 | virtual bool setupRenderPasses(); //!< setup render passes information 21 | virtual bool startGeometry(); 22 | virtual bool endGeometry(); 23 | virtual unsigned int getNextFreeID(); 24 | virtual bool startTriMesh(unsigned int id, int vertices, int triangles, bool hasOrco, bool hasUV=false, int type=0, int obj_pass_index=0); 25 | virtual bool startTriMeshPtr(unsigned int *id, int vertices, int triangles, bool hasOrco, bool hasUV=false, int type=0, int obj_pass_index=0); 26 | virtual bool startCurveMesh(unsigned int id, int vertices, int obj_pass_index=0); 27 | virtual bool endTriMesh(); 28 | virtual bool addInstance(unsigned int baseObjectId, matrix4x4_t objToWorld); 29 | virtual bool endCurveMesh(const material_t *mat, float strandStart, float strandEnd, float strandShape); 30 | virtual int addVertex(double x, double y, double z); //!< add vertex to mesh; returns index to be used for addTriangle 31 | virtual int addVertex(double x, double y, double z, double ox, double oy, double oz); //!< add vertex with Orco to mesh; returns index to be used for addTriangle 32 | virtual void addNormal(double nx, double ny, double nz); //!< add vertex normal to mesh; the vertex that will be attached to is the last one inserted by addVertex method 33 | virtual bool addTriangle(int a, int b, int c, const material_t *mat); 34 | virtual bool addTriangle(int a, int b, int c, int uv_a, int uv_b, int uv_c, const material_t *mat); 35 | virtual int addUV(float u, float v); 36 | virtual bool smoothMesh(unsigned int id, double angle); 37 | 38 | // functions directly related to renderEnvironment_t 39 | virtual light_t* createLight (const char* name); 40 | virtual texture_t* createTexture (const char* name); 41 | virtual material_t* createMaterial (const char* name); 42 | virtual camera_t* createCamera (const char* name); 43 | virtual background_t* createBackground (const char* name); 44 | virtual integrator_t* createIntegrator (const char* name); 45 | virtual VolumeRegion* createVolumeRegion (const char* name); 46 | virtual unsigned int createObject (const char* name); 47 | virtual void clearAll(); //!< clear the whole environment + scene, i.e. free (hopefully) all memory. 48 | virtual void render(colorOutput_t &output, progressBar_t *pb = nullptr); //!< render the scene... 49 | virtual bool startScene(int type=0); //!< start a new scene; Must be called before any of the scene_t related callbacks! 50 | 51 | virtual void setOutfile(const char *fname); 52 | 53 | void setXMLColorSpace(std::string color_space_string, float gammaVal); 54 | 55 | protected: 56 | void writeParamMap(const paraMap_t &pmap, int indent=1); 57 | void writeParamList(int indent); 58 | 59 | std::map materials; 60 | std::ofstream xmlFile; 61 | std::string xmlName; 62 | const material_t *last_mat; 63 | size_t nmat; 64 | int n_uvs; 65 | unsigned int nextObj; 66 | float XMLGamma; 67 | colorSpaces_t XMLColorSpace; 68 | }; 69 | 70 | typedef xmlInterface_t * xmlInterfaceConstructor(); 71 | 72 | __END_YAFRAY 73 | 74 | #endif // Y_XMLINTERFACE_H 75 | -------------------------------------------------------------------------------- /include/lights/arealight.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef Y_AREALIGHT_H 4 | #define Y_AREALIGHT_H 5 | 6 | #include 7 | #include 8 | 9 | __BEGIN_YAFRAY 10 | 11 | class areaLight_t : public light_t 12 | { 13 | public: 14 | areaLight_t(const point3d_t &c, const vector3d_t &v1, const vector3d_t &v2, 15 | const color_t &col, float inte, int nsam, bool bLightEnabled=true, bool bCastShadows=true); 16 | ~areaLight_t(); 17 | virtual void init(scene_t &scene); 18 | virtual color_t totalEnergy() const; 19 | virtual color_t emitPhoton(float s1, float s2, float s3, float s4, ray_t &ray, float &ipdf) const; 20 | virtual color_t emitSample(vector3d_t &wo, lSample_t &s) const; 21 | virtual bool diracLight() const { return false; } 22 | virtual bool illumSample(const surfacePoint_t &sp, lSample_t &s, ray_t &wi) const; 23 | virtual bool illuminate(const surfacePoint_t &sp, color_t &col, ray_t &wi)const { return false; } 24 | virtual bool canIntersect() const{ return true; } 25 | virtual bool intersect(const ray_t &ray, float &t, color_t &col, float &ipdf) const; 26 | virtual float illumPdf(const surfacePoint_t &sp, const surfacePoint_t &sp_light) const; 27 | virtual void emitPdf(const surfacePoint_t &sp, const vector3d_t &wi, float &areaPdf, float &dirPdf, float &cos_wo) const; 28 | virtual int nSamples() const { return samples; } 29 | static light_t *factory(paraMap_t ¶ms, renderEnvironment_t &render); 30 | protected: 31 | point3d_t corner, c2, c3, c4; 32 | vector3d_t toX,toY, normal, fnormal; 33 | vector3d_t du, dv; //!< directions for hemisampler (emitting photons) 34 | color_t color; //!< includes intensity amplification! so... 35 | int samples; 36 | unsigned int objID; 37 | float intensity; //!< ...this is actually redundant. 38 | float area, invArea; 39 | }; 40 | 41 | __END_YAFRAY 42 | 43 | #endif //Y_AREALIGHT_H 44 | -------------------------------------------------------------------------------- /include/lights/bglight.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | /**************************************************************************** 3 | * bglight.h: a light source using the background 4 | * This is part of the yafray package 5 | * Copyright (C) 2006 Mathias Wein 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #ifndef Y_BACKGROUNDLIGHT_H 23 | #define Y_BACKGROUNDLIGHT_H 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | __BEGIN_YAFRAY 30 | 31 | class background_t; 32 | class pdf1D_t; 33 | 34 | class bgLight_t : public light_t 35 | { 36 | public: 37 | bgLight_t(int sampl, bool invertIntersect = false, bool bLightEnabled=true, bool bCastShadows=true); 38 | virtual ~bgLight_t(); 39 | virtual void init(scene_t &scene); 40 | virtual color_t totalEnergy() const; 41 | virtual color_t emitPhoton(float s1, float s2, float s3, float s4, ray_t &ray, float &ipdf) const; 42 | virtual color_t emitSample(vector3d_t &wo, lSample_t &s) const; 43 | virtual bool diracLight() const { return false; } 44 | virtual bool illumSample(const surfacePoint_t &sp, lSample_t &s, ray_t &wi) const; 45 | virtual bool illuminate(const surfacePoint_t &sp, color_t &col, ray_t &wi)const { return false; } 46 | virtual float illumPdf(const surfacePoint_t &sp, const surfacePoint_t &sp_light) const; 47 | virtual void emitPdf(const surfacePoint_t &sp, const vector3d_t &wo, float &areaPdf, float &dirPdf, float &cos_wo) const; 48 | virtual int nSamples() const { return samples; } 49 | virtual bool canIntersect() const{ return true; } 50 | virtual bool intersect(const ray_t &ray, float &t, color_t &col, float &ipdf) const; 51 | static light_t *factory(paraMap_t ¶ms, renderEnvironment_t &render); 52 | 53 | protected: 54 | void sample_dir(float s1, float s2, vector3d_t &dir, float &pdf, bool inv = false) const; 55 | float dir_pdf(const vector3d_t dir) const; 56 | float CalcFromSample(float s1, float s2, float &u, float &v, bool inv = false) const; 57 | float CalcFromDir(const vector3d_t &dir, float &u, float &v, bool inv = false) const; 58 | pdf1D_t **uDist, *vDist; 59 | int samples; 60 | point3d_t worldCenter; 61 | float worldRadius; 62 | float aPdf, iaPdf; 63 | float worldPIFactor; 64 | bool absInter; 65 | }; 66 | 67 | __END_YAFRAY 68 | 69 | #endif // Y_BACKGROUNDLIGHT_H 70 | -------------------------------------------------------------------------------- /include/lights/bgportallight.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | /**************************************************************************** 3 | * bgportallight.h: a light source using a triangle mesh as portal 4 | * This is part of the yafray package 5 | * Copyright (C) 2006 Mathias Wein 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #ifndef Y_BGPORTALLIGHT_H 23 | #define Y_BGPORTALLIGHT_H 24 | 25 | #include 26 | #include 27 | 28 | __BEGIN_YAFRAY 29 | 30 | class triangleObject_t; 31 | class triangle_t; 32 | class pdf1D_t; 33 | class paraMap_t; 34 | class renderEnvironment_t; 35 | class triKdTree_t; 36 | class background_t; 37 | 38 | class bgPortalLight_t : public light_t 39 | { 40 | public: 41 | bgPortalLight_t(unsigned int msh, int sampl, float pow, bool bLightEnabled=true, bool bCastShadows=true); 42 | virtual ~bgPortalLight_t(); 43 | virtual void init(scene_t &scene); 44 | virtual color_t totalEnergy() const; 45 | virtual color_t emitPhoton(float s1, float s2, float s3, float s4, ray_t &ray, float &ipdf) const; 46 | virtual color_t emitSample(vector3d_t &wo, lSample_t &s) const; 47 | virtual bool diracLight() const { return false; } 48 | //virtual bool illumSample(const surfacePoint_t &sp, float s1, float s2, color_t &col, float &ipdf, ray_t &wi) const; 49 | virtual bool illumSample(const surfacePoint_t &sp, lSample_t &s, ray_t &wi) const; 50 | virtual bool illuminate(const surfacePoint_t &sp, color_t &col, ray_t &wi)const { return false; } 51 | virtual int nSamples() const { return samples; } 52 | virtual bool canIntersect() const{ return tree!=0 /* false */ ; } 53 | virtual bool intersect(const ray_t &ray, float &t, color_t &col, float &ipdf) const; 54 | virtual float illumPdf(const surfacePoint_t &sp, const surfacePoint_t &sp_light) const; 55 | virtual void emitPdf(const surfacePoint_t &sp, const vector3d_t &wi, float &areaPdf, float &dirPdf, float &cos_wo) const; 56 | static light_t *factory(paraMap_t ¶ms, renderEnvironment_t &render); 57 | protected: 58 | void initIS(); 59 | void sampleSurface(point3d_t &p, vector3d_t &n, float u, float v) const; 60 | unsigned int objID; 61 | pdf1D_t *areaDist; 62 | const triangle_t **tris; 63 | int samples; 64 | int nTris; //!< gives the array size of uDist 65 | float area, invArea; 66 | float power; 67 | triangleObject_t *mesh; 68 | triKdTree_t *tree; 69 | background_t *bg; 70 | point3d_t worldCenter; 71 | float aPdf; 72 | }; 73 | 74 | __END_YAFRAY 75 | 76 | #endif // Y_BACKGROUNDLIGHT_H 77 | -------------------------------------------------------------------------------- /include/lights/meshlight.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | /**************************************************************************** 3 | * meshlight.h: a light source using a triangle mesh as shape 4 | * This is part of the yafray package 5 | * Copyright (C) 2006 Mathias Wein 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #ifndef Y_MESHLIGHT_H 23 | #define Y_MESHLIGHT_H 24 | 25 | #include 26 | 27 | __BEGIN_YAFRAY 28 | 29 | class triangleObject_t; 30 | class triangle_t; 31 | class pdf1D_t; 32 | class paraMap_t; 33 | class renderEnvironment_t; 34 | class triKdTree_t; 35 | 36 | class meshLight_t : public light_t 37 | { 38 | public: 39 | meshLight_t(unsigned int msh, const color_t &col, int sampl, bool dbl_s=false, bool bLightEnabled=true, bool bCastShadows=true); 40 | virtual ~meshLight_t(); 41 | virtual void init(scene_t &scene); 42 | virtual color_t totalEnergy() const; 43 | virtual color_t emitPhoton(float s1, float s2, float s3, float s4, ray_t &ray, float &ipdf) const; 44 | virtual color_t emitSample(vector3d_t &wo, lSample_t &s) const; 45 | virtual bool diracLight() const { return false; } 46 | virtual bool illumSample(const surfacePoint_t &sp, lSample_t &s, ray_t &wi) const; 47 | virtual bool illuminate(const surfacePoint_t &sp, color_t &col, ray_t &wi)const { return false; } 48 | virtual int nSamples() const { return samples; } 49 | virtual bool canIntersect() const{ return tree!=0 /* false */ ; } 50 | virtual bool intersect(const ray_t &ray, float &t, color_t &col, float &ipdf) const; 51 | virtual float illumPdf(const surfacePoint_t &sp, const surfacePoint_t &sp_light) const; 52 | virtual void emitPdf(const surfacePoint_t &sp, const vector3d_t &wi, float &areaPdf, float &dirPdf, float &cos_wo) const; 53 | static light_t *factory(paraMap_t ¶ms, renderEnvironment_t &render); 54 | protected: 55 | void initIS(); 56 | void sampleSurface(point3d_t &p, vector3d_t &n, float u, float v) const; 57 | unsigned int objID; 58 | bool doubleSided; 59 | color_t color; 60 | pdf1D_t *areaDist; 61 | const triangle_t **tris; 62 | int samples; 63 | int nTris; //!< gives the array size of uDist 64 | float area, invArea; 65 | triangleObject_t *mesh; 66 | triKdTree_t *tree; 67 | //debug stuff: 68 | int *stats; 69 | }; 70 | 71 | __END_YAFRAY 72 | 73 | #endif // Y_BACKGROUNDLIGHT_H 74 | -------------------------------------------------------------------------------- /include/materials/blendmat.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef Y_BLENDMAT_H 4 | #define Y_BLENDMAT_H 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | __BEGIN_YAFRAY 13 | 14 | /*! A material that blends the properties of two materials 15 | note: if both materials have specular reflection or specular transmission 16 | components, recursive raytracing will not work properly! 17 | Sampling will still work, but possibly be inefficient 18 | Outdated info... DarkTide 19 | */ 20 | 21 | class blendMat_t: public nodeMaterial_t 22 | { 23 | public: 24 | blendMat_t(const material_t *m1, const material_t *m2, float blendv, visibility_t eVisibility=NORMAL_VISIBLE); 25 | virtual ~blendMat_t(); 26 | virtual void initBSDF(const renderState_t &state, surfacePoint_t &sp, BSDF_t &bsdfTypes)const; 27 | virtual color_t eval(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo, const vector3d_t &wl, BSDF_t bsdfs, bool force_eval = false)const; 28 | 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; 29 | virtual color_t sample(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo, vector3d_t *const dir, color_t &tcol, sample_t &s, float *const W)const; 30 | virtual float pdf(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo, const vector3d_t &wi, BSDF_t bsdfs)const; 31 | virtual float getMatIOR ()const; 32 | virtual bool isTransparent() const; 33 | virtual color_t getTransparency(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo)const; 34 | virtual color_t emit(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo)const; 35 | virtual void getSpecular(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo, 36 | bool &reflect, bool &refract, vector3d_t *const dir, color_t *const col)const; 37 | virtual float getAlpha(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo)const; 38 | virtual bool scatterPhoton(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wi, vector3d_t &wo, pSample_t &s) const; 39 | virtual const volumeHandler_t* getVolumeHandler(bool inside)const; 40 | 41 | static material_t* factory(paraMap_t ¶ms, std::list &eparams, renderEnvironment_t &render); 42 | protected: 43 | const material_t *mat1, *mat2; 44 | shaderNode_t *blendS = nullptr; //!< the shader node used for blending the materials 45 | shaderNode_t *mWireFrameShader = nullptr; //!< Shader node for wireframe shading (float) 46 | float blendVal; 47 | float minThres; 48 | float maxThres; 49 | size_t mmem1; 50 | bool recalcBlend; 51 | float blendedIOR; 52 | mutable BSDF_t mat1Flags, mat2Flags; 53 | private: 54 | void getBlendVal(const renderState_t &state, const surfacePoint_t &sp, float &val, float &ival) const; 55 | }; 56 | 57 | 58 | __END_YAFRAY 59 | 60 | #endif // Y_BLENDMAT_H 61 | -------------------------------------------------------------------------------- /include/materials/maskmat.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef Y_MASKMAT_H 4 | #define Y_MASKMAT_H 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | __BEGIN_YAFRAY 11 | 12 | class texture_t; 13 | class renderEnvironment_t; 14 | 15 | class maskMat_t: public nodeMaterial_t 16 | { 17 | public: 18 | maskMat_t(const material_t *m1, const material_t *m2, float thresh, visibility_t eVisibility=NORMAL_VISIBLE); 19 | virtual void initBSDF(const renderState_t &state, surfacePoint_t &sp, BSDF_t &bsdfTypes)const; 20 | 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; 21 | 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 | virtual float pdf(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo, const vector3d_t &wi, BSDF_t bsdfs)const; 23 | virtual bool isTransparent() const; 24 | virtual color_t getTransparency(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo)const; 25 | virtual void getSpecular(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo, 26 | bool &reflect, bool &refract, vector3d_t *const dir, color_t *const col)const; 27 | virtual color_t emit(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo)const; 28 | virtual float getAlpha(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo)const; 29 | static material_t* factory(paraMap_t &, std::list< paraMap_t > &, renderEnvironment_t &); 30 | 31 | protected: 32 | const material_t *mat1; 33 | const material_t *mat2; 34 | shaderNode_t* mask; 35 | float threshold; 36 | //const texture_t *mask; 37 | }; 38 | 39 | __END_YAFRAY 40 | 41 | #endif // Y_MASKMAT_H 42 | -------------------------------------------------------------------------------- /include/materials/roughglass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef Y_ROUGHGLASS_H 4 | #define Y_ROUGHGLASS_H 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | __BEGIN_YAFRAY 11 | 12 | class roughGlassMat_t: public nodeMaterial_t 13 | { 14 | public: 15 | roughGlassMat_t(float IOR, color_t filtC, const color_t &srcol, bool fakeS, float alpha, float disp_pow, visibility_t eVisibility=NORMAL_VISIBLE); 16 | virtual void initBSDF(const renderState_t &state, surfacePoint_t &sp, unsigned int &bsdfTypes) const; 17 | 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; 18 | virtual color_t sample(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo, vector3d_t *const dir, color_t &tcol, sample_t &s, float *const W)const; 19 | 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 { return 0.f; } 20 | 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; } 21 | virtual bool isTransparent() const { return fakeShadow; } 22 | virtual color_t getTransparency(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo) const; 23 | virtual float getAlpha(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo) const; 24 | virtual float getMatIOR() const; 25 | static material_t* factory(paraMap_t &, std::list< paraMap_t > &, renderEnvironment_t &); 26 | virtual color_t getGlossyColor(const renderState_t &state) const 27 | { 28 | nodeStack_t stack(state.userdata); 29 | return (mirColS ? mirColS->getColor(stack) : specRefCol); 30 | } 31 | virtual color_t getTransColor(const renderState_t &state) const 32 | { 33 | nodeStack_t stack(state.userdata); 34 | return (filterColS ? filterColS->getColor(stack) : filterCol); 35 | } 36 | virtual color_t getMirrorColor(const renderState_t &state) const 37 | { 38 | nodeStack_t stack(state.userdata); 39 | return (mirColS ? mirColS->getColor(stack) : specRefCol); 40 | } 41 | 42 | protected: 43 | shaderNode_t* bumpS = nullptr; 44 | shaderNode_t *mirColS = nullptr; 45 | shaderNode_t *roughnessS = nullptr; 46 | shaderNode_t *iorS = nullptr; 47 | shaderNode_t *filterColS = nullptr; 48 | shaderNode_t *mWireFrameShader = nullptr; //!< Shader node for wireframe shading (float) 49 | color_t filterCol, specRefCol; 50 | color_t beer_sigma_a; 51 | float ior; 52 | float a2; 53 | float a; 54 | bool absorb = false, disperse = false, fakeShadow; 55 | float dispersion_power; 56 | float CauchyA, CauchyB; 57 | }; 58 | 59 | __END_YAFRAY 60 | 61 | #endif // Y_ROUGHGLASS_H 62 | -------------------------------------------------------------------------------- /include/textures/layernode.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef Y_LAYERNODE_H 4 | #define Y_LAYERNODE_H 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | __BEGIN_YAFRAY 11 | 12 | // texture flag 13 | #define TXF_RGBTOINT 1 14 | #define TXF_STENCIL 2 15 | #define TXF_NEGATIVE 4 16 | #define TXF_ALPHAMIX 8 17 | 18 | class layerNode_t: public shaderNode_t 19 | { 20 | public: 21 | layerNode_t(unsigned tflag, float col_fac, float var_fac, float def_val, colorA_t def_col, mix_modes mmod); 22 | virtual void eval(nodeStack_t &stack, const renderState_t &state, const surfacePoint_t &sp)const; 23 | virtual void eval(nodeStack_t &stack, const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo, const vector3d_t &wi)const; 24 | virtual void evalDerivative(nodeStack_t &stack, const renderState_t &state, const surfacePoint_t &sp)const; 25 | virtual bool isViewDependant() const; 26 | virtual bool configInputs(const paraMap_t ¶ms, const nodeFinder_t &find); 27 | //virtual void getDerivative(const surfacePoint_t &sp, float &du, float &dv)const; 28 | virtual bool getDependencies(std::vector &dep) const; 29 | static shaderNode_t* factory(const paraMap_t ¶ms,renderEnvironment_t &render); 30 | protected: 31 | const shaderNode_t *input, *upperLayer; 32 | unsigned int texflag; 33 | float colfac; 34 | float valfac; 35 | float default_val, upper_val; 36 | colorA_t default_col, upper_col; 37 | mix_modes mode; 38 | bool do_color, do_scalar, color_input, use_alpha; 39 | }; 40 | 41 | 42 | 43 | __END_YAFRAY 44 | 45 | #endif // Y_LAYERNODE_H 46 | -------------------------------------------------------------------------------- /include/utilities/geometry.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef GEOMETRY_H 4 | #define GEOMETRY_H 5 | 6 | #include 7 | #include 8 | 9 | __BEGIN_YAFRAY 10 | 11 | struct Plane 12 | { 13 | vector3d_t p; 14 | vector3d_t n; 15 | }; 16 | 17 | inline float ray_plane_intersection(ray_t const& ray, Plane const& plane) 18 | { 19 | return plane.n * (plane.p - vector3d_t(ray.from)) / (ray.dir * plane.n); 20 | } 21 | 22 | __END_YAFRAY 23 | 24 | #endif // GEOMETRY_H 25 | -------------------------------------------------------------------------------- /include/utilities/interpolation.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | /**************************************************************************** 3 | * interpolation.h: Some interpolation algorithms 4 | * This is part of the yafaray package 5 | * Copyright (C) 2009 Bert Buchholz 6 | * Split into a header and some speedups by Rodrigo Placencia 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this library; if not, write to the Free Software 20 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | */ 22 | 23 | #ifndef INTERPOLATION_H 24 | #define INTERPOLATION_H 25 | 26 | __BEGIN_YAFRAY 27 | 28 | // Algorithms from: http://local.wasp.uwa.edu.au/~pbourke/miscellaneous/interpolation/ 29 | 30 | template 31 | inline static T lerp( 32 | T const& y1, T const& y2, 33 | double alpha) 34 | { 35 | return y1 * alpha + y2 * (1.0 - alpha); 36 | } 37 | 38 | inline static double CosineInterpolate( 39 | double y1,double y2, 40 | double mu) 41 | { 42 | double mu2; 43 | 44 | mu2 = (1 - fCos(mu * M_PI)) * 0.5f; 45 | return ( y1 * (1 - mu2) + y2 * mu2); 46 | } 47 | 48 | template 49 | inline T CubicInterpolate( 50 | const T &y0, const T &y1, 51 | const T &y2, const T &y3, 52 | double mu) 53 | { 54 | T a0,a1,a2,a3,mu2; 55 | 56 | mu2 = mu*mu; 57 | a0 = y3 - y2 - y0 + y1; 58 | a1 = y0 - y1 - a0; 59 | a2 = y2 - y0; 60 | a3 = y1; 61 | 62 | return (a0*mu*mu2+a1*mu2+a2*mu+a3); 63 | } 64 | 65 | __END_YAFRAY 66 | 67 | #endif //INTERPOLATION_H 68 | -------------------------------------------------------------------------------- /include/utilities/math_utils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef Y_MATHUTIL_H 4 | #define Y_MATHUTIL_H 5 | 6 | #include 7 | 8 | //#if ( defined(__i386__) || defined(_M_IX86) || defined(_X86_) ) 9 | //#define FAST_INT 1 10 | #define _doublemagicroundeps (.5-1.4e-11) 11 | //almost .5f = .5f - 1e^(number of exp bit) 12 | #define _doublemagic double (6755399441055744.0) 13 | //2^52 * 1.5, uses limited precision to floor 14 | //#endif 15 | 16 | 17 | inline int Round2Int(double val) { 18 | #ifdef FAST_INT 19 | val = val + _doublemagic; 20 | return ((long*)&val)[0]; 21 | #else 22 | // #warning "using slow rounding" 23 | return int (val+_doublemagicroundeps); 24 | #endif 25 | } 26 | 27 | inline int Float2Int(double val) { 28 | #ifdef FAST_INT 29 | return (val<0) ? Round2Int(val+_doublemagicroundeps) : 30 | Round2Int(val-_doublemagicroundeps); 31 | #else 32 | // #warning "using slow rounding" 33 | return (int)val; 34 | #endif 35 | } 36 | 37 | inline int Floor2Int(double val) { 38 | #ifdef FAST_INT 39 | return Round2Int(val - _doublemagicroundeps); 40 | #else 41 | // #warning "using slow rounding" 42 | return (int)std::floor(val); 43 | #endif 44 | } 45 | 46 | inline int Ceil2Int(double val) { 47 | #ifdef FAST_INT 48 | return Round2Int(val + _doublemagicroundeps); 49 | #else 50 | // #warning "using slow rounding" 51 | return (int)std::ceil(val); 52 | #endif 53 | } 54 | 55 | inline double RoundFloatPrecision(double val, double precision) //To round, for example 3.2384764 to 3.24 use precision 0.01 56 | { 57 | if(precision <= 0.0) return 0.0; 58 | else return std::round(val / precision) * precision; 59 | } 60 | 61 | inline bool isValidFloat(float value) //To check a float is not a NaN for example, even while using --fast-math compile flag 62 | { 63 | return (value >= std::numeric_limits::lowest() && value <= std::numeric_limits::max()); 64 | } 65 | 66 | #endif // Y_MATHUTIL_H 67 | -------------------------------------------------------------------------------- /include/utilities/threadUtils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | /**************************************************************************** 3 | * 4 | * threadUtils.h: Thread Utilities api 5 | * This is part of the yafray package 6 | * Copyright (C) 2016 David Bluecame 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this library; if not, write to the Free Software 20 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | * 22 | */ 23 | 24 | #ifndef Y_THREADUTILS_H 25 | #define Y_THREADUTILS_H 26 | 27 | #if defined(_WIN32) && defined(__MINGW32__) && defined(HAVE_MINGW_STD_THREADS) //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 28 | #undef _GLIBCXX_HAS_GTHREADS 29 | #include 30 | #include 31 | #include 32 | #include 33 | #else 34 | #include 35 | #include 36 | #include 37 | #endif 38 | 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /include/utilities/winunistd.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef Yafray_win32_unistd_h 4 | #define Yafray_win32_unistd_h 5 | 6 | 7 | int getopt(int argc, char *argv[], char *opstring) ; 8 | /* static (global) variables that are specified as exported by getopt() */ 9 | extern char *optarg; /* pointer to the start of the option argument */ 10 | extern int optind; /* number of the next argv[] to be evaluated */ 11 | extern int opterr; /* non-zero if a question mark should be returned */ 12 | 13 | 14 | #endif -------------------------------------------------------------------------------- /include/yafray_constants.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef Y_CONSTANTS_H 4 | #define Y_CONSTANTS_H 5 | 6 | #define __BEGIN_YAFRAY namespace yafaray { 7 | #define __END_YAFRAY } 8 | 9 | #define PACKAGE "YafaRay" 10 | 11 | #if (__GNUC__ > 3) 12 | #define GCC_HASCLASSVISIBILITY 13 | #endif 14 | 15 | // define symbol export and import attributes 16 | #ifdef _WIN32 17 | #define YF_EXPORT __declspec(dllexport) 18 | #define YF_IMPORT __declspec(dllimport) 19 | #else 20 | #ifdef GCC_HASCLASSVISIBILITY 21 | #define YF_EXPORT __attribute__ ((visibility("default"))) 22 | #define YF_IMPORT __attribute__ ((visibility("default"))) 23 | #else 24 | #define YF_EXPORT 25 | #define YF_IMPORT 26 | #endif 27 | #endif 28 | 29 | // automatic macros that switch between import and export, depending on compiler environment 30 | #ifdef BUILDING_YAFRAYCORE 31 | #define YAFRAYCORE_EXPORT YF_EXPORT 32 | #else 33 | #define YAFRAYCORE_EXPORT YF_IMPORT 34 | #endif 35 | 36 | #ifdef BUILDING_YAFRAYPLUGIN 37 | #define YAFRAYPLUGIN_EXPORT YF_EXPORT 38 | #else 39 | #define YAFRAYPLUGIN_EXPORT YF_IMPORT 40 | #endif 41 | 42 | #endif // Y_CONSTANTS_H 43 | -------------------------------------------------------------------------------- /include/yafraycore/hashgrid.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __Y_HASHGRID_H 4 | #define __Y_HASHGRID_H 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | __BEGIN_YAFRAY 12 | 13 | class photon_t; 14 | struct foundPhoton_t; 15 | class bound_t; 16 | class point3d_t; 17 | 18 | 19 | class YAFRAYCORE_EXPORT hashGrid_t 20 | { 21 | public: 22 | hashGrid_t(){hashGrid = nullptr;} 23 | 24 | hashGrid_t(double _cellSize, unsigned int _gridSize, bound_t _bBox); 25 | 26 | void setParm(double _cellSize, unsigned int _gridSize, bound_t _bBox); 27 | 28 | void clear(); //remove all the photons in the grid; 29 | 30 | void updateGrid(); //build the hashgrid 31 | 32 | void pushPhoton(photon_t &p); 33 | 34 | unsigned int gather(const point3d_t &P, foundPhoton_t *found, unsigned int K, float radius); 35 | 36 | private: 37 | unsigned int Hash(const int ix, const int iy, const int iz) { 38 | return (unsigned int)((ix * 73856093) ^ (iy * 19349663) ^ (iz * 83492791)) % gridSize; 39 | } 40 | 41 | public: 42 | double cellSize, invcellSize; 43 | unsigned int gridSize; 44 | bound_t bBox; 45 | std::vectorphotons; 46 | std::list **hashGrid; 47 | }; 48 | 49 | 50 | __END_YAFRAY 51 | #endif 52 | -------------------------------------------------------------------------------- /include/yafraycore/imageOutput.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | /**************************************************************************** 3 | * 4 | * imageOutput.h: generic color output based on imageHandlers 5 | * This is part of the yafray package 6 | * Copyright (C) 2010 Rodrigo Placencia Vazquez 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this library; if not, write to the Free Software 20 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | * 22 | */ 23 | 24 | #ifndef Y_IMAGE_OUTPUT_H 25 | #define Y_IMAGE_OUTPUT_H 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | __BEGIN_YAFRAY 32 | 33 | class renderPasses_t; 34 | 35 | class YAFRAYCORE_EXPORT imageOutput_t : public colorOutput_t 36 | { 37 | public: 38 | imageOutput_t(imageHandler_t *handle, const std::string &name, int bx, int by); 39 | imageOutput_t(); //!< Dummy initializer 40 | virtual ~imageOutput_t(); 41 | virtual bool putPixel(int numView, int x, int y, const renderPasses_t *renderPasses, int idx, const colorA_t &color, bool alpha = true); 42 | virtual bool putPixel(int numView, int x, int y, const renderPasses_t *renderPasses, const std::vector &colExtPasses, bool alpha = true); 43 | virtual void flush(int numView, const renderPasses_t *renderPasses); 44 | virtual void flushArea(int numView, int x0, int y0, int x1, int y1, const renderPasses_t *renderPasses) {} // not used by images... yet 45 | virtual bool isImageOutput() { return true; } 46 | virtual std::string getDenoiseParams() const 47 | { 48 | if(image) return image->getDenoiseParams(); 49 | else return ""; 50 | } 51 | void saveImageFile(std::string filename, int idx); 52 | void saveImageFileMultiChannel(std::string filename, const renderPasses_t *renderPasses); 53 | 54 | private: 55 | imageHandler_t *image; 56 | std::string fname; 57 | float bX; 58 | float bY; 59 | }; 60 | 61 | __END_YAFRAY 62 | 63 | #endif // Y_IMAGE_OUTPUT_H 64 | 65 | -------------------------------------------------------------------------------- /include/yafraycore/memoryIO.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef Y_MEMORYIO_H 4 | #define Y_MEMORYIO_H 5 | 6 | #include 7 | #include 8 | 9 | __BEGIN_YAFRAY 10 | 11 | class renderPasses_t; 12 | 13 | class YAFRAYCORE_EXPORT memoryIO_t : public colorOutput_t 14 | { 15 | public: 16 | memoryIO_t(int resx, int resy, float* iMem); 17 | virtual bool putPixel(int numView, int x, int y, const renderPasses_t *renderPasses, int idx, const colorA_t &color, bool alpha = true); 18 | virtual bool putPixel(int numView, int x, int y, const renderPasses_t *renderPasses, const std::vector &colExtPasses, bool alpha = true); 19 | void flush(int numView, const renderPasses_t *renderPasses); 20 | virtual void flushArea(int numView, int x0, int y0, int x1, int y1, const renderPasses_t *renderPasses) {}; // no tiled file format used...yet 21 | virtual ~memoryIO_t(); 22 | protected: 23 | int sizex, sizey; 24 | float* imageMem; 25 | }; 26 | 27 | 28 | __END_YAFRAY 29 | 30 | #endif // Y_MEMORYIO_H 31 | -------------------------------------------------------------------------------- /include/yafraycore/monitor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef Y_MONITOR_H 4 | #define Y_MONITOR_H 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | __BEGIN_YAFRAY 11 | //! Progress bar abstract class with pure virtual members 12 | class YAFRAYCORE_EXPORT progressBar_t 13 | { 14 | public: 15 | virtual ~progressBar_t(){} 16 | //! initialize (or reset) the monitor, give the total number of steps that can occur 17 | virtual void init(int totalSteps = 100) = 0; 18 | //! update the montior, increment by given number of steps; init has to be called before the first update. 19 | virtual void update(int steps = 1) = 0; 20 | //! finish progress bar. It could output some summary, simply disappear from GUI or whatever... 21 | virtual void done() = 0; 22 | //! method to pass some informative text to the progress bar in case needed 23 | virtual void setTag(const char* text) = 0; 24 | virtual void setTag(std::string text) = 0; 25 | virtual std::string getTag() const = 0; 26 | virtual float getPercent() const = 0; 27 | virtual float getTotalSteps() const = 0; 28 | std::mutex mutx; 29 | }; 30 | 31 | /*! the default console progress bar (implemented in console.cc) 32 | */ 33 | class YAFRAYCORE_EXPORT ConsoleProgressBar_t : public progressBar_t 34 | { 35 | public: 36 | ConsoleProgressBar_t(int cwidth = 80); 37 | virtual void init(int totalSteps); 38 | virtual void update(int steps=1); 39 | virtual void done(); 40 | virtual void setTag(const char* text) { tag = std::string(text); }; 41 | virtual void setTag(std::string text) { tag = text; }; 42 | virtual std::string getTag() const { return tag; } 43 | virtual float getPercent() const; 44 | virtual float getTotalSteps() const { return nSteps; } 45 | 46 | protected: 47 | int width, totalBarLen; 48 | int lastBarLen; 49 | int nSteps; 50 | int doneSteps; 51 | std::string tag; 52 | }; 53 | 54 | 55 | __END_YAFRAY 56 | 57 | #endif // Y_MONITOR_H 58 | -------------------------------------------------------------------------------- /include/yafraycore/nodematerial.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef Y_SHADERMAT_H 4 | #define Y_SHADERMAT_H 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | __BEGIN_YAFRAY 11 | 12 | class renderEnvironment_t; 13 | 14 | enum nodeType_e { VIEW_DEP=1, VIEW_INDEP=1<<1 }; 15 | 16 | class YAFRAYCORE_EXPORT nodeMaterial_t: public material_t 17 | { 18 | public: 19 | nodeMaterial_t(): reqNodeMem(0){} 20 | protected: 21 | /*! load nodes from parameter map list */ 22 | bool loadNodes(const std::list ¶msList, renderEnvironment_t &render); 23 | /** parse node shaders to fill nodeList */ 24 | void parseNodes(const paraMap_t ¶ms, std::vector &roots, std::map &nodeList); 25 | /* put nodes in evaluation order in "allSorted" given all root nodes; 26 | sets reqNodeMem to the amount of memory the node stack requires for evaluation of all nodes */ 27 | void solveNodesOrder(const std::vector &roots); 28 | void getNodeList(const shaderNode_t *root, std::vector &nodes); 29 | void evalNodes(const renderState_t &state, const surfacePoint_t &sp, const std::vector &nodes, nodeStack_t &stack)const 30 | { 31 | auto end=nodes.end(); 32 | for(auto iter = nodes.begin(); iter!=end; ++iter) (*iter)->eval(stack, state, sp); 33 | } 34 | void evalBump(nodeStack_t &stack, const renderState_t &state, surfacePoint_t &sp, const shaderNode_t *bumpS)const; 35 | /*! filter out nodes with specific properties */ 36 | void filterNodes(const std::vector &input, std::vector &output, int flags); 37 | virtual ~nodeMaterial_t(); 38 | 39 | std::vector allNodes, allSorted, allViewdep, allViewindep, bumpNodes; 40 | std::map mShadersTable; 41 | size_t reqNodeMem; 42 | }; 43 | 44 | __END_YAFRAY 45 | 46 | #endif // Y_SHADERMAT_H 47 | -------------------------------------------------------------------------------- /include/yafraycore/scr_halton.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef Y_SCRHALTON_H 4 | #define Y_SCRHALTON_H 5 | 6 | #include 7 | 8 | extern YAFRAYCORE_EXPORT const int* faure[]; 9 | 10 | __BEGIN_YAFRAY 11 | 12 | const int prims[50] = { 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 13 | 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 14 | 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 15 | 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 16 | 173, 179, 181, 191, 193, 197, 199, 211, 223, 227 }; 17 | 18 | const double invPrims[50] = { 1.000000000,0.500000000,0.333333333,0.200000000,0.142857143, 19 | 0.090909091,0.076923077,0.058823529,0.052631579,0.043478261, 20 | 0.034482759,0.032258065,0.027027027,0.024390244,0.023255814, 21 | 0.021276596,0.018867925,0.016949153,0.016393443,0.014925373, 22 | 0.014084507,0.013698630,0.012658228,0.012048193,0.011235955, 23 | 0.010309278,0.009900990,0.009708738,0.009345794,0.009174312, 24 | 0.008849558,0.007874016,0.007633588,0.007299270,0.007194245, 25 | 0.006711409,0.006622517,0.006369427,0.006134969,0.005988024, 26 | 0.005780347,0.005586592,0.005524862,0.005235602,0.005181347, 27 | 0.005076142,0.005025126,0.004739336,0.004484305,0.004405286 }; 28 | 29 | /** Low Discrepancy Halton sampling */ 30 | // dim MUST NOT be larger than 50! Above that, random numbers may be 31 | // the better choice anyway, not even scrambling is realiable at high dimensions. 32 | inline double scrHalton(int dim, unsigned int n) 33 | { 34 | double value = 0.0; 35 | if(dim < 50) 36 | { 37 | const int *sigma = faure[dim]; 38 | unsigned int base = prims[dim]; 39 | double f, factor, dn = (double)n; 40 | 41 | f = factor = invPrims[dim]; 42 | while (n>0) { 43 | value += double(sigma[n % base]) * factor; 44 | dn *= f; 45 | n = (unsigned int)dn; 46 | factor *= f; 47 | } 48 | } 49 | else 50 | { 51 | value = (double)ourRandom(); 52 | } 53 | return std::max(1.0e-36, std::min(1.0, value)); //A minimum value very small 1.0e-36 is set to avoid issues with pdf1D sampling in the Sample function with s2=0.f Hopefully in practice the numerical difference between 0.f and 1.0e-36 will not be significant enough to cause other issues. 54 | } 55 | 56 | __END_YAFRAY 57 | 58 | #endif // Y_SCRHALTON_H 59 | -------------------------------------------------------------------------------- /include/yafraycore/spectrum.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef Y_SPECTRUM_H 4 | #define Y_SPECTRUM_H 5 | 6 | #include 7 | #include 8 | 9 | __BEGIN_YAFRAY 10 | 11 | YAFRAYCORE_EXPORT void wl2rgb_fromCIE(float wl, color_t &col); 12 | //YAFRAYCORE_EXPORT void approxSpectrumRGB(float wl, color_t &col); 13 | //YAFRAYCORE_EXPORT void fakeSpectrum(float p, color_t &col); 14 | YAFRAYCORE_EXPORT void CauchyCoefficients(float IOR, float disp_pw, float &CauchyA, float &CauchyB); 15 | YAFRAYCORE_EXPORT float getIORcolor(float w, float CauchyA, float CauchyB, color_t &col); 16 | YAFRAYCORE_EXPORT color_t wl2XYZ(float wl); 17 | 18 | static inline float getIOR(float w, float CauchyA, float CauchyB) 19 | { 20 | float wl = 300.0*w + 400.0; 21 | return CauchyA + CauchyB/(wl*wl); 22 | } 23 | 24 | static inline void wl2rgb(float w, color_t &wl_col) 25 | { 26 | float wl = 300.0*w + 400.0; 27 | wl2rgb_fromCIE(wl, wl_col); 28 | wl_col *= 2.214032659670777114f; 29 | } 30 | 31 | __END_YAFRAY 32 | 33 | #endif // Y_SPECTRUM_H 34 | -------------------------------------------------------------------------------- /include/yafraycore/std_primitives.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | #ifndef Y_STD_PRIMITIVE_H 5 | #define Y_STD_PRIMITIVE_H 6 | 7 | #include 8 | #include 9 | 10 | __BEGIN_YAFRAY 11 | 12 | class renderEnvironment_t; 13 | class paraMap_t; 14 | class object3d_t; 15 | 16 | class YAFRAYCORE_EXPORT sphere_t: public primitive_t 17 | { 18 | public: 19 | sphere_t(point3d_t centr, float rad, const material_t *m): center(centr), radius(rad), material(m) {} 20 | virtual bound_t getBound() const; 21 | virtual bool intersectsBound(exBound_t &b) const { return true; }; 22 | //virtual bool clippingSupport() const { return false; } 23 | //virtual bool clipToBound(double bound[2][3], int axis, bound_t &clipped, void *d_old, void *d_new) const {return false;} 24 | virtual bool intersect(const ray_t &ray, float *t, intersectData_t &data) const; 25 | virtual void getSurface(surfacePoint_t &sp, const point3d_t &hit, intersectData_t &data) const; 26 | virtual const material_t* getMaterial() const { return material; } 27 | virtual const triangleObject_t* getMesh() const { return nullptr; } 28 | protected: 29 | point3d_t center; 30 | float radius; 31 | const material_t *material; 32 | }; 33 | 34 | object3d_t* sphere_factory(paraMap_t ¶ms, renderEnvironment_t &env); 35 | 36 | __END_YAFRAY 37 | 38 | #endif //Y_STD_PRIMITIVE_H 39 | -------------------------------------------------------------------------------- /include/yafraycore/timer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef Y_TIMER_H 4 | #define Y_TIMER_H 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #ifndef _WIN32 12 | extern "C" struct timeval; 13 | #include 14 | #endif 15 | 16 | __BEGIN_YAFRAY 17 | 18 | class YAFRAYCORE_EXPORT timer_t 19 | { 20 | public: 21 | bool addEvent(const std::string &name); 22 | bool start(const std::string &name); 23 | bool stop(const std::string &name); 24 | bool reset(const std::string &name); 25 | double getTime(const std::string &name); 26 | double getTimeNotStopping(const std::string &name); 27 | 28 | static void splitTime(double t, double *secs, int *mins=nullptr, int *hours=nullptr, int *days=nullptr); 29 | 30 | protected: 31 | bool includes(const std::string &label)const; 32 | 33 | struct tdata_t 34 | { 35 | tdata_t():started(false), stopped(false) {}; 36 | clock_t start, finish; 37 | #ifndef WIN32 38 | timeval tvs, tvf; 39 | #endif 40 | bool started, stopped; 41 | }; 42 | std::map events; 43 | }; 44 | 45 | // global timer object, defined in timer.cc 46 | extern YAFRAYCORE_EXPORT timer_t gTimer; 47 | 48 | __END_YAFRAY 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(APPLE) 2 | SET(CMAKE_INSTALL_RPATH @loader_path) 3 | else(APPLE) 4 | SET(CMAKE_INSTALL_RPATH "$ORIGIN/:$ORIGIN/../:$ORIGIN/../lib/") 5 | endif(APPLE) 6 | 7 | add_subdirectory(yafraycore) 8 | add_subdirectory(backgrounds) 9 | add_subdirectory(cameras) 10 | add_subdirectory(image_handlers) 11 | add_subdirectory(integrators) 12 | add_subdirectory(interface) 13 | add_subdirectory(lights) 14 | add_subdirectory(materials) 15 | add_subdirectory(textures) 16 | add_subdirectory(volumes) 17 | 18 | if(WITH_XML_LOADER) 19 | add_subdirectory(xml_loader) 20 | endif(WITH_XML_LOADER) 21 | 22 | if(WITH_QT) 23 | add_subdirectory(gui) 24 | endif(WITH_QT) 25 | 26 | add_subdirectory(bindings) 27 | -------------------------------------------------------------------------------- /src/backgrounds/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${YAF_INCLUDE_DIRS}) 2 | 3 | add_definitions(-DBUILDING_YAFRAYPLUGIN) 4 | 5 | add_library(sunsky SHARED sunsky.cc sunspectrum.cc) 6 | target_link_libraries(sunsky yafaray_v3_core) 7 | 8 | add_library(textureback SHARED textureback.cc) 9 | target_link_libraries(textureback yafaray_v3_core) 10 | 11 | add_library(gradientback SHARED gradientback.cc) 12 | target_link_libraries(gradientback yafaray_v3_core) 13 | 14 | add_library(SunSky2 SHARED darksky.cc) 15 | target_link_libraries(SunSky2 yafaray_v3_core) 16 | 17 | install (TARGETS gradientback textureback sunsky SunSky2 ${YAF_TARGET_TYPE} DESTINATION ${YAF_PLUGIN_DIR}) 18 | -------------------------------------------------------------------------------- /src/bindings/yafqt.i: -------------------------------------------------------------------------------- 1 | #if defined(SWIGRUBY) 2 | %module yafqt_ruby 3 | #else 4 | %module yafqt 5 | #endif 6 | 7 | %include "cpointer.i" 8 | %pointer_functions(float, floatp); 9 | %pointer_functions(int, intp); 10 | %pointer_functions(unsigned int, uintp); 11 | 12 | %include "carrays.i" 13 | %array_functions(float, floatArray); 14 | 15 | %include "std_string.i" 16 | 17 | %{ 18 | #include 19 | #include 20 | %} 21 | 22 | struct Settings { 23 | bool autoSave; 24 | bool autoSaveAlpha; 25 | bool closeAfterFinish; 26 | std::string fileName; 27 | }; 28 | 29 | void initGui(); 30 | int createRenderWidget(yafaray::yafrayInterface_t *interf, int xsize, int ysize, int bStartX, int bStartY, Settings settings); 31 | 32 | -------------------------------------------------------------------------------- /src/cameras/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${YAF_INCLUDE_DIRS}) 2 | 3 | add_definitions(-DBUILDING_YAFRAYPLUGIN) 4 | 5 | add_library(perspectiveCamera SHARED perspectiveCamera.cc architectCamera.cc) 6 | target_link_libraries(perspectiveCamera yafaray_v3_core) 7 | 8 | add_library(orthographicCamera SHARED orthographicCamera.cc) 9 | target_link_libraries(orthographicCamera yafaray_v3_core) 10 | 11 | add_library(angularCamera SHARED angularCamera.cc) 12 | target_link_libraries(angularCamera yafaray_v3_core) 13 | 14 | add_library(equirectangularCamera SHARED equirectangularCamera.cc) 15 | target_link_libraries(equirectangularCamera yafaray_v3_core) 16 | 17 | install (TARGETS perspectiveCamera orthographicCamera angularCamera equirectangularCamera ${YAF_TARGET_TYPE} DESTINATION ${YAF_PLUGIN_DIR}) 18 | -------------------------------------------------------------------------------- /src/gui/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${YAF_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) 2 | 3 | if (EMBED_FONT_QT) 4 | add_definitions(-DYAFQT_EMBEDED_FONT) 5 | endif (EMBED_FONT_QT) 6 | 7 | add_definitions(-DBUILDING_QTPLUGIN) 8 | 9 | cmake_policy(SET CMP0020 NEW) 10 | cmake_policy(SET CMP0028 NEW) 11 | set(CMAKE_AUTOMOC ON) 12 | set(CMAKE_AUTOUIC ON) 13 | 14 | set(YAF_QT_CC animworking.cc events.cc mywindow.cc qtoutput.cc qtprogress.cc renderwidget.cc worker.cc) 15 | set(YAF_QT_H_MOC animworking.h mywindow.h renderwidget.h worker.h) 16 | set(YAF_QT_UI windowbase.ui) 17 | 18 | add_library(yafarayqt SHARED ${YAF_QT_CC} ${YAF_QT_MOC_CC} ${YAF_QT_UI_H} ${YAF_QT_UI_CC}) 19 | target_link_libraries(yafarayqt Qt5::Core Qt5::Widgets yafaray_v3_core) 20 | install (TARGETS yafarayqt ${YAF_TARGET_TYPE} DESTINATION ${YAF_LIB_DIR}) 21 | -------------------------------------------------------------------------------- /src/gui/animworking.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * animworking.h: a widget to show something is being processed 3 | * This is part of the yafray package 4 | * Copyright (C) 2009 Gustavo Pichorim Boiko 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | 22 | #ifndef ANIMWORKING_H 23 | #define ANIMWORKING_H 24 | 25 | #include 26 | #include 27 | 28 | #define topFrame 50 29 | 30 | class AnimWorking : public QWidget 31 | { 32 | Q_OBJECT 33 | 34 | public: 35 | AnimWorking(QWidget *parent = 0); 36 | ~AnimWorking(); 37 | protected: 38 | void paintEvent(QPaintEvent *e); 39 | void timerEvent(QTimerEvent *e); 40 | private: 41 | std::vector mSprites; 42 | size_t mActFrame; 43 | int m_timerId; 44 | }; 45 | 46 | #endif // ANIMWORKING_H 47 | -------------------------------------------------------------------------------- /src/gui/events.cc: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * events.cc: custom events to enable thread communication to the UI 3 | * This is part of the yafray package 4 | * Copyright (C) 2009 Gustavo Pichorim Boiko 5 | * Copyright (C) 2009 Rodrigo Placencia Vazquez 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #include "events.h" 23 | 24 | GuiUpdateEvent::GuiUpdateEvent(const QRect &rect, bool fullUpdate) 25 | : QEvent((QEvent::Type)GuiUpdate), m_rect(rect), m_full(fullUpdate) 26 | { 27 | } 28 | 29 | GuiAreaHighliteEvent::GuiAreaHighliteEvent(const QRect &rect) 30 | : QEvent((QEvent::Type)GuiAreaHighlite), m_rect(rect) 31 | { 32 | } 33 | 34 | ProgressUpdateEvent::ProgressUpdateEvent(int progress, int min, int max) 35 | : QEvent((QEvent::Type)ProgressUpdate), m_progress(progress), m_min(min), m_max(max) 36 | { 37 | } 38 | 39 | ProgressUpdateTagEvent::ProgressUpdateTagEvent(const char *tag) 40 | : QEvent((QEvent::Type)ProgressUpdateTag), m_tag(tag) 41 | { 42 | } 43 | -------------------------------------------------------------------------------- /src/gui/events.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * events.h: custom events to enable thread communication to the UI 3 | * This is part of the yafray package 4 | * Copyright (C) 2009 Gustavo Pichorim Boiko 5 | * Copyright (C) 2009 Rodrigo Placencia Vazquez 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #ifndef EVENTS_H 23 | #define EVENTS_H 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | enum CustomEvents 30 | { 31 | GuiUpdate = QEvent::User, 32 | GuiAreaHighlite, 33 | ProgressUpdate, 34 | ProgressUpdateTag 35 | }; 36 | 37 | // this event is just to trigger an update in a widget from 38 | // outside the main thread 39 | class GuiUpdateEvent : public QEvent 40 | { 41 | public: 42 | GuiUpdateEvent(const QRect &rect, bool fullUpdate = false); 43 | inline QRect rect() { return m_rect; } 44 | inline bool fullUpdate() { return m_full; } 45 | private: 46 | QRect m_rect; 47 | bool m_full; 48 | }; 49 | 50 | class GuiAreaHighliteEvent : public QEvent 51 | { 52 | public: 53 | GuiAreaHighliteEvent(const QRect &rect); 54 | inline QRect rect() { return m_rect; } 55 | private: 56 | QRect m_rect; 57 | }; 58 | 59 | class ProgressUpdateEvent : public QEvent 60 | { 61 | public: 62 | ProgressUpdateEvent(int progress, int min = -1, int max = -1); 63 | inline int progress() { return m_progress; } 64 | inline int min() { return m_min; } 65 | inline int max() { return m_max; } 66 | private: 67 | int m_progress; 68 | int m_min; 69 | int m_max; 70 | }; 71 | 72 | class ProgressUpdateTagEvent : public QEvent 73 | { 74 | public: 75 | ProgressUpdateTagEvent(const char *tag); 76 | inline QString &tag() { return m_tag; } 77 | private: 78 | QString m_tag; 79 | }; 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /src/gui/mywindow.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * mywindow.h: main window of the yafray UI 3 | * This is part of the yafray package 4 | * Copyright (C) 2008 Gustavo Pichorim Boiko 5 | * Copyright (C) 2009 Rodrigo Placencia Vazquez 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | 23 | #ifndef MYWINDOW_H 24 | #define MYWINDOW_H 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | 32 | namespace Ui 33 | { 34 | class WindowBase; 35 | } 36 | 37 | namespace yafaray 38 | { 39 | class yafrayInterface_t; 40 | } 41 | 42 | class AnimWorking; 43 | class QtOutput; 44 | class RenderWidget; 45 | class Worker; 46 | class QErrorMessage; 47 | 48 | class MainWindow : public QMainWindow 49 | { 50 | Q_OBJECT 51 | public: 52 | MainWindow(yafaray::yafrayInterface_t *env, int resx, int resy, int bStartX, int bStartY, Settings settings); 53 | ~MainWindow(); 54 | 55 | virtual bool event(QEvent *e); 56 | void adjustWindow(); 57 | 58 | protected: 59 | virtual bool eventFilter(QObject *obj, QEvent* event); 60 | virtual void keyPressEvent(QKeyEvent* event); 61 | void closeEvent(QCloseEvent *e); 62 | bool closeUnsaved(); 63 | bool saveDlg(); 64 | 65 | public slots: 66 | void slotRender(); 67 | void slotFinished(); 68 | void slotEnableDisable(bool enable = true); 69 | void slotSaveAs(); 70 | void slotCancel(); 71 | void setAlpha(bool checked); 72 | void showColor(bool checked); 73 | void showAlpha(bool checked); 74 | //FIXME: void showDepth(bool checked); 75 | void setAskSave(bool checked); 76 | //FIXME: void setSaveDepth(bool checked); 77 | void setDrawParams(bool checked); 78 | void zoomIn(); 79 | void zoomOut(); 80 | 81 | private: 82 | Ui::WindowBase *m_ui; 83 | RenderWidget *m_render; 84 | QtOutput *m_output; 85 | Worker *m_worker; 86 | yafaray::yafrayInterface_t *interf; 87 | QString m_outputPath; 88 | QString m_lastPath; 89 | int res_x, res_y, b_x, b_y; 90 | std::string fileName; 91 | bool autoClose; // if true, rendering gets saved to fileName after finish and GUI gets closed (for animation) 92 | bool autoSave; // if true, rendering gets saved to fileName after finish but GUI stays opened 93 | bool autoSaveAlpha; // if true, the automatically saved image contains no alpha channel 94 | bool saveWithAlpha; 95 | bool saveWithDepth; 96 | bool useDrawParams; 97 | QTime timeMeasure; // time measure for the render 98 | AnimWorking* anim; 99 | bool renderSaved; 100 | bool renderCancelled; 101 | bool use_zbuf; 102 | bool askUnsaved; 103 | }; 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /src/gui/qtoutput.cc: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * qtoutput.cc: a Qt color output for yafray 3 | * This is part of the yafray package 4 | * Copyright (C) 2008 Gustavo Pichorim Boiko 5 | * Copyright (C) 2009 Rodrigo Placencia Vazquez 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #include "qtoutput.h" 23 | #include "events.h" 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | QtOutput::QtOutput(RenderWidget *render): renderBuffer(render) 30 | { 31 | } 32 | 33 | void QtOutput::setRenderSize(const QSize &s) 34 | { 35 | renderBuffer->setup(s); 36 | } 37 | 38 | /*==================================== 39 | / colorOutput_t implementations 40 | =====================================*/ 41 | 42 | bool QtOutput::putPixel(int numView, int x, int y, const yafaray::renderPasses_t *renderPasses, int idx, const yafaray::colorA_t &color, bool alpha) 43 | { 44 | int r = std::max(0,std::min(255, (int)(color.R * 255.f))); 45 | int g = std::max(0,std::min(255, (int)(color.G * 255.f))); 46 | int b = std::max(0,std::min(255, (int)(color.B * 255.f))); 47 | QRgb aval = Qt::white; 48 | //QRgb zval = Qt::black; 49 | QRgb rgb = qRgb(r, g, b); 50 | 51 | if (alpha) 52 | { 53 | int a = std::max(0,std::min(255, (int)(color.A * 255.f))); 54 | aval = qRgb(a, a, a); 55 | } 56 | 57 | renderBuffer->setPixel(x, y, rgb, aval, alpha); 58 | 59 | return true; 60 | } 61 | 62 | bool QtOutput::putPixel(int numView, int x, int y, const yafaray::renderPasses_t *renderPasses, const std::vector &colExtPasses, bool alpha) 63 | { 64 | int r = std::max(0,std::min(255, (int)(colExtPasses.at(0).R * 255.f))); 65 | int g = std::max(0,std::min(255, (int)(colExtPasses.at(0).G * 255.f))); 66 | int b = std::max(0,std::min(255, (int)(colExtPasses.at(0).B * 255.f))); 67 | QRgb aval = Qt::white; 68 | //QRgb zval = Qt::black; 69 | QRgb rgb = qRgb(r, g, b); 70 | 71 | if (alpha) 72 | { 73 | int a = std::max(0,std::min(255, (int)(colExtPasses.at(0).A * 255.f))); 74 | aval = qRgb(a, a, a); 75 | } 76 | 77 | renderBuffer->setPixel(x, y, rgb, aval, alpha); 78 | 79 | return true; 80 | } 81 | 82 | void QtOutput::flush(int numView, const yafaray::renderPasses_t *renderPasses) 83 | { 84 | QCoreApplication::postEvent(renderBuffer, new GuiUpdateEvent(QRect(), true)); 85 | } 86 | 87 | void QtOutput::flushArea(int numView, int x0, int y0, int x1, int y1, const yafaray::renderPasses_t *renderPasses) 88 | { 89 | QCoreApplication::postEvent(renderBuffer, new GuiUpdateEvent(QRect(x0,y0,x1-x0,y1-y0))); 90 | } 91 | 92 | void QtOutput::highliteArea(int numView, int x0, int y0, int x1, int y1) 93 | { 94 | QCoreApplication::postEvent(renderBuffer, new GuiAreaHighliteEvent(QRect(x0,y0,x1-x0,y1-y0))); 95 | } 96 | -------------------------------------------------------------------------------- /src/gui/qtoutput.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * qtoutput.h: a Qt color output for yafray 3 | * This is part of the yafray package 4 | * Copyright (C) 2008 Gustavo Pichorim Boiko 5 | * Copyright (C) 2009 Rodrigo Placencia Vazquez 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #ifndef Y_QTOUTPUT_H 23 | #define Y_QTOUTPUT_H 24 | 25 | #include 26 | #include "renderwidget.h" 27 | #include 28 | 29 | class QWidget; 30 | 31 | class QtOutput: public yafaray::colorOutput_t 32 | { 33 | public: 34 | QtOutput(RenderWidget *render); 35 | ~QtOutput() {} 36 | 37 | void setRenderSize(const QSize &s); 38 | 39 | // inherited from yafaray::colorOutput_t 40 | virtual bool putPixel(int numView, int x, int y, const yafaray::renderPasses_t *renderPasses, int idx, const yafaray::colorA_t &color, bool alpha = true); 41 | virtual bool putPixel(int numView, int x, int y, const yafaray::renderPasses_t *renderPasses, const std::vector &colExtPasses, bool alpha = true); 42 | virtual void flush(int numView, const yafaray::renderPasses_t *renderPasses); 43 | virtual void flushArea(int numView, int x0, int y0, int x1, int y1, const yafaray::renderPasses_t *renderPasses); 44 | virtual void highliteArea(int numView, int x0, int y0, int x1, int y1); 45 | 46 | private: 47 | RenderWidget *renderBuffer; 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/gui/qtprogress.cc: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * progressbar.h: A progress updater for the yafray GUI 3 | * This is part of the yafray package 4 | * Copyright (C) 2009 Gustavo Pichorim Boiko 5 | * Copyright (C) 2009 Rodrigo Placencia Vazquez 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #include "qtprogress.h" 23 | #include "events.h" 24 | #include "mywindow.h" 25 | #include 26 | 27 | QtProgress::QtProgress(MainWindow *window, int cwidth) 28 | : yafaray::ConsoleProgressBar_t(cwidth), m_win(window), m_currentStep(0), m_totalSteps(0) 29 | { 30 | 31 | } 32 | 33 | QtProgress::~QtProgress() 34 | { 35 | } 36 | 37 | void QtProgress::init(int totalSteps) 38 | { 39 | m_currentStep = 0; 40 | m_totalSteps = totalSteps; 41 | QCoreApplication::postEvent(m_win, new ProgressUpdateEvent(0, 0, totalSteps)); 42 | 43 | //yafaray::ConsoleProgressBar_t::init(totalSteps); 44 | } 45 | 46 | void QtProgress::update(int steps) 47 | { 48 | m_currentStep += steps; 49 | QCoreApplication::postEvent(m_win, new ProgressUpdateEvent(m_currentStep)); 50 | 51 | //yafaray::ConsoleProgressBar_t::update(steps); 52 | } 53 | 54 | void QtProgress::done() 55 | { 56 | m_currentStep = m_totalSteps; 57 | QCoreApplication::postEvent(m_win, new ProgressUpdateEvent(m_currentStep)); 58 | 59 | //yafaray::ConsoleProgressBar_t::done(); 60 | } 61 | 62 | void QtProgress::setTag(const char *tag) 63 | { 64 | QCoreApplication::postEvent(m_win, new ProgressUpdateTagEvent(tag)); 65 | 66 | //yafaray::ConsoleProgressBar_t::done(); 67 | } 68 | -------------------------------------------------------------------------------- /src/gui/qtprogress.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * progressbar.h: A progress updater for the yafray GUI 3 | * This is part of the yafray package 4 | * Copyright (C) 2009 Gustavo Pichorim Boiko 5 | * Copyright (C) 2009 Rodrigo Placencia Vazquez 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #ifndef QTPROGRESS_H 23 | #define QTPROGRESS_H 24 | 25 | #include 26 | 27 | class MainWindow; 28 | 29 | class QtProgress : public yafaray::ConsoleProgressBar_t 30 | { 31 | public: 32 | QtProgress(MainWindow *window, int cwidth = 80); 33 | virtual ~QtProgress(); 34 | virtual void init(int totalSteps); 35 | virtual void update(int steps=1); 36 | virtual void setTag(const char *tag); 37 | virtual void done(); 38 | private: 39 | MainWindow *m_win; 40 | int m_currentStep; 41 | int m_totalSteps; 42 | }; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/gui/renderwidget.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * renderwidget.h: the widget for displaying the render output 3 | * This is part of the yafray package 4 | * Copyright (C) 2008 Gustavo Pichorim Boiko 5 | * Copyright (C) 2009 Rodrigo Placencia Vazquez 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #ifndef Y_RENDERWIDGET_H 23 | #define Y_RENDERWIDGET_H 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | class RenderWidget: public QLabel 34 | { 35 | Q_OBJECT 36 | public: 37 | 38 | RenderWidget(QScrollArea *parent = 0, bool use_zbuffer = false); 39 | ~RenderWidget(); 40 | 41 | void setup(const QSize &s); 42 | private: 43 | void initBuffers(); 44 | public: 45 | void setRenderBorderStart(const QPoint &start) { borderStart = start; } 46 | 47 | void startRendering(); 48 | bool isRendering() { return rendering; } 49 | void finishRendering(); 50 | 51 | void setPixel(int x, int y, QRgb color, QRgb alpha, bool withAlpha); 52 | 53 | void paintColorBuffer(); 54 | void paintAlpha(); 55 | 56 | private: 57 | void zoom(float f, QPoint mPos); 58 | public: 59 | void zoomIn(QPoint mPos); 60 | void zoomOut(QPoint mPos); 61 | 62 | bool event(QEvent *e); 63 | protected: 64 | virtual void paintEvent(QPaintEvent *e); 65 | virtual void wheelEvent(QWheelEvent* evt); 66 | virtual void mousePressEvent(QMouseEvent *e); 67 | virtual void mouseReleaseEvent(QMouseEvent *e); 68 | virtual void mouseMoveEvent(QMouseEvent *e); 69 | 70 | private: 71 | bool use_zbuf; 72 | bool rendering; 73 | bool panning; 74 | 75 | QPoint borderStart; 76 | QSize imageSize; 77 | float scaleFactor; 78 | 79 | QPoint panPos; 80 | QPoint barPos; 81 | QScrollArea *owner; 82 | QScrollBar *hBar; 83 | QScrollBar *vBar; 84 | 85 | QPixmap pix; 86 | QMutex bufferMutex; 87 | 88 | QImage colorBuffer; 89 | QImage alphaChannel; 90 | QImage *activeBuffer; 91 | }; 92 | 93 | #endif 94 | 95 | -------------------------------------------------------------------------------- /src/gui/worker.cc: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * worker.cc: a thread for running the rendering process 3 | * This is part of the yafray package 4 | * Copyright (C) 2008-2009 Gustavo Pichorim Boiko 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | #include "worker.h" 22 | #include "qtoutput.h" 23 | #include "qtprogress.h" 24 | #include "mywindow.h" 25 | 26 | #include 27 | 28 | Worker::Worker(yafaray::yafrayInterface_t *env, MainWindow *win, QtOutput *output) 29 | : QThread(), m_env(env), m_output(output), m_win(win) 30 | { 31 | } 32 | 33 | void Worker::run() 34 | { 35 | m_env->render(*m_output, new QtProgress(m_win)); 36 | } 37 | -------------------------------------------------------------------------------- /src/gui/worker.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * worker.h: a thread for doing the rendering process 3 | * This is part of the yafray package 4 | * Copyright (C) 2008 Gustavo Pichorim Boiko 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | #ifndef WORKER_H 22 | #define WORKER_H 23 | 24 | #include 25 | #include 26 | 27 | class QtOutput; 28 | class MainWindow; 29 | namespace yafaray 30 | { 31 | class yafrayInterface_t; 32 | class render_t; 33 | class paraMap_t; 34 | class scene_t; 35 | } 36 | 37 | 38 | class Worker : public QThread 39 | { 40 | Q_OBJECT 41 | public: 42 | Worker(yafaray::yafrayInterface_t *env, MainWindow *w, QtOutput *output); 43 | void run(); 44 | private: 45 | yafaray::yafrayInterface_t *m_env; 46 | QtOutput *m_output; 47 | MainWindow *m_win; 48 | bool m_valid; 49 | }; 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /src/image_handlers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${YAF_INCLUDE_DIRS}) 2 | include_directories(SYSTEM ${ZLIB_INCLUDE_DIR}) 3 | 4 | if(WITH_OpenEXR) 5 | include_directories(SYSTEM ${OPENEXR_INCLUDE_DIRS}) 6 | endif(WITH_OpenEXR) 7 | 8 | if(WITH_JPEG) 9 | include_directories(SYSTEM ${JPEG_INCLUDE_DIR}) 10 | endif(WITH_JPEG) 11 | 12 | if(WITH_PNG) 13 | include_directories(SYSTEM ${PNG_INCLUDE_DIR}) 14 | endif(WITH_PNG) 15 | 16 | if(WITH_TIFF) 17 | include_directories(SYSTEM ${TIFF_INCLUDE_DIR}) 18 | endif(WITH_TIFF) 19 | 20 | add_definitions(-DBUILDING_YAFRAYPLUGIN) 21 | 22 | if(WITH_OpenEXR) 23 | add_library(exrHandler SHARED exrHandler.cc) 24 | target_link_libraries(exrHandler yafaray_v3_core ${OPENEXR_LIBRARIES} ${OpenCV_LIBRARIES}) 25 | endif(WITH_OpenEXR) 26 | 27 | if(WITH_JPEG) 28 | add_library(jpgHandler SHARED jpgHandler.cc) 29 | target_link_libraries(jpgHandler yafaray_v3_core ${JPEG_LIBRARY} ${OpenCV_LIBRARIES}) 30 | endif(WITH_JPEG) 31 | 32 | if(WITH_PNG) 33 | add_library(pngHandler SHARED pngHandler.cc) 34 | target_link_libraries(pngHandler yafaray_v3_core ${PNG_LIBRARIES} ${OpenCV_LIBRARIES}) 35 | endif(WITH_PNG) 36 | 37 | if(WITH_TIFF) 38 | add_library(tifHandler SHARED tifHandler.cc) 39 | target_link_libraries(tifHandler yafaray_v3_core -Wl,-undefined -Wl,dynamic_lookup ${TIFF_LIBRARY} ${OpenCV_LIBRARIES}) 40 | endif(WITH_TIFF) 41 | 42 | add_library(tgaHandler SHARED tgaHandler.cc) 43 | target_link_libraries(tgaHandler yafaray_v3_core ${OpenCV_LIBRARIES}) 44 | 45 | add_library(hdrHandler SHARED hdrHandler.cc) 46 | target_link_libraries(hdrHandler yafaray_v3_core ${OpenCV_LIBRARIES}) 47 | 48 | if(WITH_OpenEXR) 49 | install (TARGETS exrHandler ${YAF_TARGET_TYPE} DESTINATION ${YAF_PLUGIN_DIR}) 50 | endif(WITH_OpenEXR) 51 | 52 | if(WITH_JPEG) 53 | install (TARGETS jpgHandler ${YAF_TARGET_TYPE} DESTINATION ${YAF_PLUGIN_DIR}) 54 | endif(WITH_JPEG) 55 | 56 | if(WITH_PNG) 57 | install (TARGETS pngHandler ${YAF_TARGET_TYPE} DESTINATION ${YAF_PLUGIN_DIR}) 58 | endif(WITH_PNG) 59 | 60 | if(WITH_TIFF) 61 | install (TARGETS tifHandler ${YAF_TARGET_TYPE} DESTINATION ${YAF_PLUGIN_DIR}) 62 | endif(WITH_TIFF) 63 | 64 | install (TARGETS tgaHandler hdrHandler ${YAF_TARGET_TYPE} DESTINATION ${YAF_PLUGIN_DIR}) 65 | 66 | -------------------------------------------------------------------------------- /src/image_handlers/hdrUtils.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * hdrUtils.h: Radiance RGBE format utilities 4 | * This is part of the yafray package 5 | * Copyright (C) 2010 George Laskowsky Ziguilinsky (Glaskows) 6 | * Rodrigo Placencia Vazquez (DarkTide) 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this library; if not, write to the Free Software 20 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | * 22 | */ 23 | 24 | #include 25 | #include 26 | 27 | __BEGIN_YAFRAY 28 | 29 | #pragma pack(push, 1) 30 | 31 | struct rgbeHeader_t 32 | { 33 | rgbeHeader_t() 34 | { 35 | programType = "RADIANCE"; 36 | exposure = 1.0f; 37 | yFirst = true; 38 | } 39 | 40 | float exposure; // in an image corresponds to watts/steradian/m^2. Defaults to 1.0 41 | std::string programType; // A string that usually contains "RADIANCE" 42 | int min[2], max[2], step[2]; // Image boundaries and iteration stepping 43 | bool yFirst; // Indicates if the image scanlines are saved starting by y axis (Default: true) 44 | }; 45 | 46 | struct rgbePixel_t 47 | { 48 | rgbePixel_t &operator = (const color_t &c) 49 | { 50 | int e; 51 | float v = c.maximum(); 52 | 53 | if (v < 1e-32) 54 | { 55 | R = G = B = E = 0; 56 | } 57 | else 58 | { 59 | v = frexp(v, &e) * 255.9999 / v; 60 | R = (yByte) (c.getR() * v); 61 | G = (yByte) (c.getG() * v); 62 | B = (yByte) (c.getB() * v); 63 | E = (yByte) (e + 128); 64 | } 65 | 66 | return *this; 67 | } 68 | 69 | rgbePixel_t &operator = (const rgbePixel_t &c) 70 | { 71 | R = c.R; 72 | G = c.G; 73 | B = c.B; 74 | E = c.E; 75 | 76 | return *this; 77 | } 78 | 79 | yByte &operator [] (int i) 80 | { 81 | return (&R)[i]; 82 | } 83 | 84 | colorA_t getRGBA() const 85 | { 86 | float f; 87 | 88 | if(E) 89 | { /*nonzero pixel*/ 90 | f = fLdexp(1.0, E - (int) (128+8)); 91 | return colorA_t(f * R, f * G, f * B, 1.0f); 92 | } 93 | 94 | return colorA_t(0.f, 0.f, 0.f, 1.0f); 95 | } 96 | 97 | bool isORLEDesc() 98 | { 99 | return ((R == 1) && (G == 1) && (B == 1)); 100 | } 101 | 102 | bool isARLEDesc() 103 | { 104 | return ((R == 2) && (G == 2) && ((int)(B << 8 | E) < 0x8000)); 105 | } 106 | 107 | int getORLECount(int rshift) 108 | { 109 | return ((int)E << rshift); 110 | } 111 | 112 | int getARLECount() 113 | { 114 | return ((int)(B << 8 | E)); 115 | } 116 | 117 | void setScanlineStart(int w) 118 | { 119 | R = 2; 120 | G = 2; 121 | B = w >> 8; 122 | E = w & 0xFF; 123 | } 124 | 125 | yByte R; 126 | yByte G; 127 | yByte B; 128 | yByte E; 129 | }; 130 | 131 | #pragma pack(pop) 132 | 133 | __END_YAFRAY 134 | -------------------------------------------------------------------------------- /src/image_handlers/pngUtils.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * pngUtils.h: Portable Network Graphics format utilities 4 | * This is part of the yafray package 5 | * Copyright (C) 2010 Rodrigo Placencia Vazquez 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | * 21 | */ 22 | 23 | __BEGIN_YAFRAY 24 | 25 | #define inv8 0.00392156862745098039 // 1 / 255 26 | #define inv16 0.00001525902189669642 // 1 / 65535 27 | 28 | class pngDataReader_t 29 | { 30 | public: 31 | 32 | pngDataReader_t(const yByte *d, size_t s):size(s), cursor(0) 33 | { 34 | data = new yByte[size]; 35 | for(size_t i = 0;i size) return 0; 50 | size_t i; 51 | 52 | for(i = 0;i < s && cursor < size;cursor++, i++) 53 | { 54 | buf[i] = data[cursor]; 55 | } 56 | 57 | return i; 58 | } 59 | 60 | private: 61 | yByte *data; 62 | size_t size; 63 | size_t cursor; 64 | }; 65 | 66 | void readFromMem(png_structp pngPtr, png_bytep buffer, png_size_t bytesToRead) 67 | { 68 | pngDataReader_t *img = (pngDataReader_t*) png_get_io_ptr(pngPtr); 69 | 70 | if(img == nullptr) png_error(pngPtr, "The image data pointer is null!!"); 71 | 72 | if(img->read((yByte*)buffer, (size_t)bytesToRead) < bytesToRead) png_warning(pngPtr, "EOF Found while reading image data"); 73 | } 74 | 75 | __END_YAFRAY 76 | -------------------------------------------------------------------------------- /src/integrators/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${YAF_INCLUDE_DIRS}) 2 | 3 | add_definitions(-DBUILDING_YAFRAYPLUGIN) 4 | 5 | add_library(directlight SHARED directlight.cc) 6 | target_link_libraries(directlight yafaray_v3_core) 7 | 8 | add_library(photonmap SHARED photonintegr.cc) 9 | target_link_libraries(photonmap yafaray_v3_core) 10 | 11 | add_library(pathtrace SHARED pathtracer.cc) 12 | target_link_libraries(pathtrace yafaray_v3_core) 13 | 14 | add_library(bidirpath SHARED bidirpath.cc) 15 | target_link_libraries(bidirpath yafaray_v3_core) 16 | 17 | add_library(EmissionIntegrator SHARED EmissionIntegrator.cc) 18 | target_link_libraries(EmissionIntegrator yafaray_v3_core) 19 | 20 | add_library(SingleScatterIntegrator SHARED SingleScatterIntegrator.cc) 21 | target_link_libraries(SingleScatterIntegrator yafaray_v3_core) 22 | 23 | add_library(EmptyVolumeIntegrator SHARED EmptyVolumeIntegrator.cc) 24 | target_link_libraries(EmptyVolumeIntegrator yafaray_v3_core) 25 | 26 | add_library(DebugIntegrator SHARED DebugIntegrator.cc) 27 | target_link_libraries(DebugIntegrator yafaray_v3_core) 28 | 29 | add_library(SkyIntegrator SHARED SkyIntegrator.cc) 30 | target_link_libraries(SkyIntegrator yafaray_v3_core) 31 | 32 | add_library(sppm SHARED sppm.cc) 33 | target_link_libraries(sppm yafaray_v3_core) 34 | 35 | install (TARGETS directlight photonmap pathtrace bidirpath sppm 36 | EmissionIntegrator SingleScatterIntegrator EmptyVolumeIntegrator DebugIntegrator SkyIntegrator 37 | ${YAF_TARGET_TYPE} DESTINATION ${YAF_PLUGIN_DIR}) 38 | -------------------------------------------------------------------------------- /src/integrators/EmissionIntegrator.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | __BEGIN_YAFRAY 18 | 19 | class YAFRAYPLUGIN_EXPORT EmissionIntegrator : public volumeIntegrator_t 20 | { 21 | public: 22 | EmissionIntegrator() {} 23 | 24 | // optical thickness, absorption, attenuation, extinction 25 | virtual colorA_t transmittance(renderState_t &state, ray_t &ray) const 26 | { 27 | colorA_t result(1.f); 28 | 29 | std::vector listVR = scene->getVolumes(); 30 | 31 | 32 | for (unsigned int i = 0; i < listVR.size(); i++) 33 | { 34 | result *= listVR.at(i)->tau(ray, 0, 0); 35 | } 36 | 37 | result = colorA_t(fExp(-result.getR()), fExp(-result.getG()), fExp(-result.getB())); 38 | 39 | return result; 40 | } 41 | 42 | // emission part 43 | virtual colorA_t integrate(renderState_t &state, ray_t &ray, colorPasses_t &colorPasses, int additionalDepth /*=0*/) const 44 | { 45 | float t0 = 0.f, t1 = 0.f; 46 | int N = 10; // samples + 1 on the ray inside the volume 47 | 48 | colorA_t result(0.f); 49 | 50 | bool hit = ray.tmax > 0.f; 51 | 52 | std::vector listVR = scene->getVolumes(); 53 | 54 | for (unsigned int i = 0; i < listVR.size(); i++) 55 | { 56 | VolumeRegion* vr = listVR.at(i); 57 | 58 | if (!vr->intersect(ray, t0, t1)) continue; 59 | 60 | if (hit && ray.tmax < t0) continue; 61 | 62 | if (hit && ray.tmax < t1) 63 | { 64 | t1 = ray.tmax; 65 | } 66 | 67 | float step = (t1 - t0) / (float)N; // length between two sample points 68 | --N; 69 | float pos = t0 + 0.5 * step; 70 | point3d_t p(ray.from); 71 | color_t Tr(1.f); 72 | 73 | for (int i = 0; i < N; ++i) 74 | { 75 | ray_t stepRay(ray.from + (ray.dir * pos), ray.dir, 0, step, 0); 76 | color_t stepTau = vr->tau(stepRay, 0, 0); 77 | Tr *= colorA_t(fExp(-stepTau.getR()), fExp(-stepTau.getG()), fExp(-stepTau.getB())); 78 | result += Tr * vr->emission(stepRay.from, stepRay.dir); 79 | pos += step; 80 | } 81 | 82 | result *= step; 83 | } 84 | 85 | return result; 86 | } 87 | 88 | static integrator_t* factory(paraMap_t ¶ms, renderEnvironment_t &render) 89 | { 90 | EmissionIntegrator* inte = new EmissionIntegrator(); 91 | return inte; 92 | } 93 | 94 | }; 95 | 96 | extern "C" 97 | { 98 | 99 | YAFRAYPLUGIN_EXPORT void registerPlugin(renderEnvironment_t &render) 100 | { 101 | render.registerFactory("EmissionIntegrator", EmissionIntegrator::factory); 102 | } 103 | 104 | } 105 | 106 | __END_YAFRAY 107 | -------------------------------------------------------------------------------- /src/integrators/EmptyVolumeIntegrator.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | __BEGIN_YAFRAY 14 | 15 | // for removing all participating media effects 16 | 17 | class YAFRAYPLUGIN_EXPORT EmptyVolumeIntegrator : public volumeIntegrator_t { 18 | public: 19 | EmptyVolumeIntegrator() {} 20 | 21 | virtual colorA_t transmittance(renderState_t &state, ray_t &ray) const { 22 | return color_t(1.f); 23 | } 24 | 25 | virtual colorA_t integrate(renderState_t &state, ray_t &ray, colorPasses_t &colorPasses, int additionalDepth /*=0*/) const { 26 | return colorA_t(0.f); 27 | } 28 | 29 | static integrator_t* factory(paraMap_t ¶ms, renderEnvironment_t &render) 30 | { 31 | return new EmptyVolumeIntegrator(); 32 | } 33 | 34 | }; 35 | 36 | extern "C" 37 | { 38 | 39 | YAFRAYPLUGIN_EXPORT void registerPlugin(renderEnvironment_t &render) 40 | { 41 | render.registerFactory("none", EmptyVolumeIntegrator::factory); 42 | } 43 | 44 | } 45 | 46 | __END_YAFRAY 47 | -------------------------------------------------------------------------------- /src/interface/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${YAF_INCLUDE_DIRS}) 2 | 3 | add_definitions(-DBUILDING_YAFRAYPLUGIN) 4 | 5 | add_library(yafaray_v3_plugin SHARED yafrayinterface.cc xmlinterface.cc) 6 | target_link_libraries(yafaray_v3_plugin yafaray_v3_core) 7 | 8 | if(APPLE) # set rpath - Jens 9 | add_custom_command(TARGET yafaray_v3_plugin POST_BUILD COMMAND install_name_tool -add_rpath @loader_path/ libyafaray_v3_plugin.dylib) 10 | endif(APPLE) 11 | 12 | install (TARGETS yafaray_v3_plugin ${YAF_TARGET_TYPE} DESTINATION ${YAF_LIB_DIR}) 13 | -------------------------------------------------------------------------------- /src/lights/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${YAF_INCLUDE_DIRS}) 2 | 3 | add_definitions(-DBUILDING_YAFRAYPLUGIN) 4 | 5 | add_library(sunlight SHARED sunlight.cc) 6 | target_link_libraries(sunlight yafaray_v3_core) 7 | 8 | add_library(pointlight SHARED pointlight.cc) 9 | target_link_libraries(pointlight yafaray_v3_core) 10 | 11 | add_library(directional SHARED directional.cc) 12 | target_link_libraries(directional yafaray_v3_core) 13 | 14 | add_library(spotlight SHARED spotlight.cc) 15 | target_link_libraries(spotlight yafaray_v3_core) 16 | 17 | add_library(arealight SHARED arealight.cc meshlight.cc bgportallight.cc) 18 | target_link_libraries(arealight yafaray_v3_core) 19 | 20 | add_library(spherelight SHARED spherelight.cc) 21 | target_link_libraries(spherelight yafaray_v3_core) 22 | 23 | add_library(ieslight SHARED iesLight.cc) 24 | target_link_libraries(ieslight yafaray_v3_core) 25 | 26 | add_library(bglight SHARED bglight.cc) 27 | target_link_libraries(bglight yafaray_v3_core) 28 | 29 | install (TARGETS sunlight pointlight directional spotlight arealight spherelight ieslight bglight 30 | ${YAF_TARGET_TYPE} DESTINATION ${YAF_PLUGIN_DIR}) 31 | -------------------------------------------------------------------------------- /src/materials/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${YAF_INCLUDE_DIRS}) 2 | 3 | add_definitions(-DBUILDING_YAFRAYPLUGIN) 4 | 5 | add_library(glass SHARED glass.cc) 6 | target_link_libraries(glass yafaray_v3_core) 7 | 8 | add_library(roughglass SHARED roughglass.cc) 9 | target_link_libraries(roughglass yafaray_v3_core) 10 | 11 | add_library(blend SHARED blend.cc) 12 | target_link_libraries(blend yafaray_v3_core) 13 | 14 | add_library(glossy SHARED glossy.cc) 15 | target_link_libraries(glossy yafaray_v3_core) 16 | 17 | add_library(shinydiffuse SHARED shinydiffuse.cc) 18 | target_link_libraries(shinydiffuse yafaray_v3_core) 19 | 20 | add_library(coatedglossy SHARED coatedglossy.cc) 21 | target_link_libraries(coatedglossy yafaray_v3_core) 22 | 23 | add_library(simple SHARED simple.cc mask.cc) 24 | target_link_libraries(simple yafaray_v3_core) 25 | 26 | add_library(volumetric SHARED beer.cc) 27 | target_link_libraries(volumetric yafaray_v3_core) 28 | 29 | install (TARGETS glass roughglass blend glossy shinydiffuse coatedglossy simple volumetric 30 | ${YAF_TARGET_TYPE} DESTINATION ${YAF_PLUGIN_DIR}) 31 | -------------------------------------------------------------------------------- /src/materials/beer.cc: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | __BEGIN_YAFRAY 9 | 10 | 11 | class beer_t: public volumeHandler_t 12 | { 13 | public: 14 | beer_t(const color_t &sigma): sigma_a(sigma) {}; 15 | beer_t(const color_t &acol, double dist); 16 | virtual bool transmittance(const renderState_t &state, const ray_t &ray, color_t &col) const; 17 | virtual bool scatter(const renderState_t &state, const ray_t &ray, ray_t &sRay, pSample_t &s) const; 18 | virtual color_t getSubSurfaceColor(const renderState_t &state) const 19 | { 20 | return sigma_a; 21 | } 22 | 23 | static volumeHandler_t* factory(const paraMap_t ¶ms, renderEnvironment_t &env); 24 | protected: 25 | color_t sigma_a; 26 | }; 27 | 28 | 29 | beer_t::beer_t(const color_t &acol, double dist) 30 | { 31 | const float maxlog = log(1e38); 32 | sigma_a.R = (acol.R > 1e-38) ? -log(acol.R) : maxlog; 33 | sigma_a.G = (acol.G > 1e-38) ? -log(acol.G) : maxlog; 34 | sigma_a.B = (acol.B > 1e-38) ? -log(acol.B) : maxlog; 35 | if (dist!=0.f) sigma_a *= 1.f/dist; 36 | } 37 | 38 | bool beer_t::transmittance(const renderState_t &state, const ray_t &ray, color_t &col) const 39 | { 40 | if(ray.tmax < 0.f || ray.tmax > 1e30f) //infinity check... 41 | { 42 | col = color_t( 0.f, 0.f, 0.f); 43 | return true; 44 | } 45 | float dist = ray.tmax; // maybe substract ray.tmin... 46 | color_t be(-dist * sigma_a); 47 | col = color_t( fExp(be.getR()), fExp(be.getG()), fExp(be.getB()) ); 48 | return true; 49 | } 50 | 51 | bool beer_t::scatter(const renderState_t &state, const ray_t &ray, ray_t &sRay, pSample_t &s) const 52 | { 53 | return false; 54 | } 55 | 56 | volumeHandler_t* beer_t::factory(const paraMap_t ¶ms, renderEnvironment_t &env) 57 | { 58 | color_t a_col(0.5f); 59 | double dist=1.f; 60 | params.getParam("absorption_col", a_col); 61 | params.getParam("absorption_dist", dist); 62 | return new beer_t(a_col, dist); 63 | } 64 | 65 | //============================ 66 | 67 | class sss_t: public beer_t 68 | { 69 | public: 70 | sss_t(const color_t &a_col, const color_t &s_col, double dist); 71 | //virtual bool transmittance(const renderState_t &state, const ray_t &ray, color_t &col) const { return false; }; 72 | virtual bool scatter(const renderState_t &state, const ray_t &ray, ray_t &sRay, pSample_t &s) const; 73 | 74 | static volumeHandler_t* factory(const paraMap_t ¶ms, renderEnvironment_t &env); 75 | protected: 76 | float dist_s; 77 | color_t scatter_col; 78 | }; 79 | 80 | sss_t::sss_t(const color_t &a_col, const color_t &s_col, double dist): 81 | beer_t(a_col, dist), dist_s(dist), scatter_col(s_col) 82 | {} 83 | 84 | bool sss_t::scatter(const renderState_t &state, const ray_t &ray, ray_t &sRay, pSample_t &s) const 85 | { 86 | float dist = -dist_s * log(s.s1); 87 | if(dist >= ray.tmax) return false; 88 | sRay.from = ray.from + dist*ray.dir; 89 | sRay.dir = SampleSphere(s.s2, s.s3); 90 | s.color = scatter_col; 91 | return true; 92 | } 93 | 94 | volumeHandler_t* sss_t::factory(const paraMap_t ¶ms, renderEnvironment_t &env) 95 | { 96 | color_t a_col(0.5f), s_col(0.8f); 97 | double dist=1.f; 98 | params.getParam("absorption_col", a_col); 99 | params.getParam("absorption_dist", dist); 100 | params.getParam("scatter_col", s_col); 101 | return new sss_t(a_col, s_col, dist); 102 | } 103 | 104 | extern "C" 105 | { 106 | YAFRAYPLUGIN_EXPORT void registerPlugin(renderEnvironment_t &render) 107 | { 108 | render.registerFactory("beer", beer_t::factory); 109 | render.registerFactory("sss", sss_t::factory); 110 | } 111 | } 112 | 113 | __END_YAFRAY 114 | -------------------------------------------------------------------------------- /src/textures/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${YAF_INCLUDE_DIRS}) 2 | 3 | add_definitions(-DBUILDING_YAFRAYPLUGIN) 4 | 5 | set(basictex_SRCS basictex.cc noise.cc imagetex.cc) 6 | add_library(basictex SHARED ${basictex_SRCS}) 7 | target_link_libraries(basictex yafaray_v3_core ${OpenCV_LIBRARIES}) 8 | 9 | add_library(basicnodes SHARED basicnodes.cc layernode.cc) 10 | target_link_libraries(basicnodes yafaray_v3_core) 11 | 12 | install (TARGETS basictex basicnodes ${YAF_TARGET_TYPE} DESTINATION ${YAF_PLUGIN_DIR}) 13 | -------------------------------------------------------------------------------- /src/volumes/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${YAF_INCLUDE_DIRS}) 2 | 3 | add_definitions(-DBUILDING_YAFRAYPLUGIN) 4 | 5 | add_library(UniformVolume SHARED UniformVolume.cc) 6 | target_link_libraries(UniformVolume yafaray_v3_core) 7 | 8 | add_library(ExpDensityVolume SHARED ExpDensityVolume.cc) 9 | target_link_libraries(ExpDensityVolume yafaray_v3_core) 10 | 11 | add_library(NoiseVolume SHARED NoiseVolume.cc) 12 | target_link_libraries(NoiseVolume yafaray_v3_core) 13 | 14 | add_library(GridVolume SHARED GridVolume.cc) 15 | target_link_libraries(GridVolume yafaray_v3_core) 16 | 17 | add_library(SkyVolume SHARED SkyVolume.cc) 18 | target_link_libraries(SkyVolume yafaray_v3_core) 19 | 20 | install (TARGETS UniformVolume ExpDensityVolume NoiseVolume SkyVolume 21 | ${YAF_TARGET_TYPE} DESTINATION ${YAF_PLUGIN_DIR}) 22 | -------------------------------------------------------------------------------- /src/volumes/ExpDensityVolume.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | __BEGIN_YAFRAY 12 | 13 | struct renderState_t; 14 | struct pSample_t; 15 | 16 | class ExpDensityVolume : public DensityVolume { 17 | public: 18 | 19 | ExpDensityVolume(color_t sa, color_t ss, color_t le, float gg, point3d_t pmin, point3d_t pmax, int attgridScale, float aa, float bb) : 20 | DensityVolume(sa, ss, le, gg, pmin, pmax, attgridScale) { 21 | a = aa; 22 | b = bb; 23 | Y_VERBOSE << "ExpDensityVolume vol: " << s_a << " " << s_s << " " << l_e << " " << a << " " << b << yendl; 24 | } 25 | 26 | virtual float Density(point3d_t p); 27 | 28 | static VolumeRegion* factory(paraMap_t ¶ms, renderEnvironment_t &render); 29 | 30 | protected: 31 | float a, b; 32 | }; 33 | 34 | float ExpDensityVolume::Density(point3d_t p) { 35 | float height = p.z - bBox.a.z; 36 | return a * fExp(-b * height); 37 | } 38 | 39 | VolumeRegion* ExpDensityVolume::factory(paraMap_t ¶ms,renderEnvironment_t &render) 40 | { 41 | float ss = .1f; 42 | float sa = .1f; 43 | float le = .0f; 44 | float g = .0f; 45 | float a = 1.f; 46 | float b = 1.f; 47 | float min[] = {0, 0, 0}; 48 | float max[] = {0, 0, 0}; 49 | int attSc = 1; 50 | 51 | params.getParam("sigma_s", ss); 52 | params.getParam("sigma_a", sa); 53 | params.getParam("l_e", le); 54 | params.getParam("g", g); 55 | params.getParam("a", a); 56 | params.getParam("b", b); 57 | params.getParam("minX", min[0]); 58 | params.getParam("minY", min[1]); 59 | params.getParam("minZ", min[2]); 60 | params.getParam("maxX", max[0]); 61 | params.getParam("maxY", max[1]); 62 | params.getParam("maxZ", max[2]); 63 | params.getParam("attgridScale", attSc); 64 | 65 | ExpDensityVolume *vol = new ExpDensityVolume(color_t(sa), color_t(ss), color_t(le), g, 66 | point3d_t(min[0], min[1], min[2]), point3d_t(max[0], max[1], max[2]), attSc, a, b); 67 | return vol; 68 | } 69 | 70 | extern "C" 71 | { 72 | YAFRAYPLUGIN_EXPORT void registerPlugin(renderEnvironment_t &render) 73 | { 74 | render.registerFactory("ExpDensityVolume", ExpDensityVolume::factory); 75 | } 76 | } 77 | 78 | __END_YAFRAY 79 | -------------------------------------------------------------------------------- /src/volumes/NoiseVolume.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | __BEGIN_YAFRAY 15 | 16 | struct renderState_t; 17 | struct pSample_t; 18 | 19 | class NoiseVolume : public DensityVolume { 20 | public: 21 | 22 | NoiseVolume(color_t sa, color_t ss, color_t le, float gg, float cov, float sharp, float dens, 23 | point3d_t pmin, point3d_t pmax, int attgridScale, texture_t* noise) : 24 | DensityVolume(sa, ss, le, gg, pmin, pmax, attgridScale) { 25 | texDistNoise = noise; 26 | cover = cov; 27 | sharpness = sharp * sharp; 28 | density = dens; 29 | } 30 | 31 | virtual float Density(point3d_t p); 32 | 33 | static VolumeRegion* factory(paraMap_t ¶ms, renderEnvironment_t &render); 34 | 35 | protected: 36 | 37 | texture_t* texDistNoise; 38 | float cover; 39 | float sharpness; 40 | float density; 41 | }; 42 | 43 | float NoiseVolume::Density(const point3d_t p) { 44 | float d = texDistNoise->getColor(p * 0.1f).energy(); 45 | 46 | d = 1.0f / (1.0f + fExp(sharpness * (1.0f - cover - d))); 47 | d *= density; 48 | 49 | return d; 50 | } 51 | 52 | VolumeRegion* NoiseVolume::factory(paraMap_t ¶ms,renderEnvironment_t &render) 53 | { 54 | float ss = .1f; 55 | float sa = .1f; 56 | float le = .0f; 57 | float g = .0f; 58 | float cov = 1.0f; 59 | float sharp = 1.0f; 60 | float dens = 1.0f; 61 | float min[] = {0, 0, 0}; 62 | float max[] = {0, 0, 0}; 63 | int attSc = 1; 64 | const std::string *texName = nullptr; 65 | 66 | params.getParam("sigma_s", ss); 67 | params.getParam("sigma_a", sa); 68 | params.getParam("l_e", le); 69 | params.getParam("g", g); 70 | params.getParam("sharpness", sharp); 71 | params.getParam("density", dens); 72 | params.getParam("cover", cov); 73 | params.getParam("minX", min[0]); 74 | params.getParam("minY", min[1]); 75 | params.getParam("minZ", min[2]); 76 | params.getParam("maxX", max[0]); 77 | params.getParam("maxY", max[1]); 78 | params.getParam("maxZ", max[2]); 79 | params.getParam("attgridScale", attSc); 80 | params.getParam("texture", texName); 81 | 82 | if (!texName) 83 | { 84 | Y_VERBOSE << "NoiseVolume: Noise texture not set, the volume region won't be created." << yendl; 85 | return nullptr; 86 | } 87 | 88 | texture_t* noise = render.getTexture(*texName); 89 | 90 | if(!noise) 91 | { 92 | Y_VERBOSE << "NoiseVolume: Noise texture '" << *texName << "' couldn't be found, the volume region won't be created." << yendl; 93 | return nullptr; 94 | } 95 | 96 | NoiseVolume *vol = new NoiseVolume(color_t(sa), color_t(ss), color_t(le), g, cov, sharp, dens, 97 | point3d_t(min[0], min[1], min[2]), point3d_t(max[0], max[1], max[2]), attSc, noise); 98 | return vol; 99 | } 100 | 101 | extern "C" 102 | { 103 | YAFRAYPLUGIN_EXPORT void registerPlugin(renderEnvironment_t &render) 104 | { 105 | render.registerFactory("NoiseVolume", NoiseVolume::factory); 106 | } 107 | } 108 | 109 | __END_YAFRAY 110 | -------------------------------------------------------------------------------- /src/volumes/UniformVolume.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | __BEGIN_YAFRAY 12 | 13 | struct renderState_t; 14 | struct pSample_t; 15 | 16 | class UniformVolume : public VolumeRegion { 17 | public: 18 | 19 | UniformVolume(color_t sa, color_t ss, color_t le, float gg, point3d_t pmin, point3d_t pmax, int attgridScale) : 20 | VolumeRegion(sa, ss, le, gg, pmin, pmax, attgridScale) { 21 | Y_VERBOSE << "UniformVolume: Vol.[" << s_a << ", " << s_s << ", " << l_e << ", " << pmin << ", " << pmax << ", " << attgridScale << "]" << yendl; 22 | } 23 | 24 | virtual color_t sigma_a(const point3d_t &p, const vector3d_t &v); 25 | virtual color_t sigma_s(const point3d_t &p, const vector3d_t &v); 26 | virtual color_t emission(const point3d_t &p, const vector3d_t &v); 27 | virtual color_t tau(const ray_t &ray, float step, float offset); 28 | 29 | static VolumeRegion* factory(paraMap_t ¶ms, renderEnvironment_t &render); 30 | }; 31 | 32 | color_t UniformVolume::sigma_a(const point3d_t &p, const vector3d_t &v) { 33 | if (!haveS_a) return color_t(0.f); 34 | if (bBox.includes(p)) { 35 | return s_a; 36 | } 37 | else 38 | return color_t(0.f); 39 | 40 | } 41 | 42 | color_t UniformVolume::sigma_s(const point3d_t &p, const vector3d_t &v) { 43 | if (!haveS_s) return color_t(0.f); 44 | if (bBox.includes(p)) { 45 | return s_s; 46 | } 47 | else 48 | return color_t(0.f); 49 | } 50 | 51 | color_t UniformVolume::tau(const ray_t &ray, float step, float offset) { 52 | float t0 = -1, t1 = -1; 53 | 54 | // ray doesn't hit the BB 55 | if (!intersect(ray, t0, t1)) { 56 | return color_t(0.f); 57 | } 58 | 59 | if (ray.tmax < t0 && ! (ray.tmax < 0)) return color_t(0.f); 60 | 61 | if (ray.tmax < t1 && ! (ray.tmax < 0)) t1 = ray.tmax; 62 | 63 | // t0 < 0 means, ray.from is in the volume 64 | if (t0 < 0.f) t0 = 0.f; 65 | 66 | // distance travelled in the volume 67 | float dist = t1 - t0; 68 | 69 | return dist * (s_s + s_a); 70 | } 71 | 72 | color_t UniformVolume::emission(const point3d_t &p, const vector3d_t &v) { 73 | if (!haveL_e) return color_t(0.f); 74 | if (bBox.includes(p)) { 75 | return l_e; 76 | } 77 | else 78 | return color_t(0.f); 79 | } 80 | 81 | VolumeRegion* UniformVolume::factory(paraMap_t ¶ms,renderEnvironment_t &render) 82 | { 83 | float ss = .1f; 84 | float sa = .1f; 85 | float le = .0f; 86 | float g = .0f; 87 | float min[] = {0, 0, 0}; 88 | float max[] = {0, 0, 0}; 89 | int attSc = 5; 90 | 91 | params.getParam("sigma_s", ss); 92 | params.getParam("sigma_a", sa); 93 | params.getParam("l_e", le); 94 | params.getParam("g", g); 95 | params.getParam("minX", min[0]); 96 | params.getParam("minY", min[1]); 97 | params.getParam("minZ", min[2]); 98 | params.getParam("maxX", max[0]); 99 | params.getParam("maxY", max[1]); 100 | params.getParam("maxZ", max[2]); 101 | params.getParam("attgridScale", attSc); 102 | 103 | UniformVolume *vol = new UniformVolume(color_t(sa), color_t(ss), color_t(le), g, 104 | point3d_t(min[0], min[1], min[2]), point3d_t(max[0], max[1], max[2]), attSc); 105 | return vol; 106 | } 107 | 108 | extern "C" 109 | { 110 | YAFRAYPLUGIN_EXPORT void registerPlugin(renderEnvironment_t &render) 111 | { 112 | render.registerFactory("UniformVolume", UniformVolume::factory); 113 | } 114 | } 115 | 116 | __END_YAFRAY 117 | -------------------------------------------------------------------------------- /src/xml_loader/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${YAF_INCLUDE_DIRS}) 2 | 3 | add_executable(yafaray-xml xml-loader.cc) 4 | target_link_libraries(yafaray-xml yafaray_v3_core) 5 | 6 | install (TARGETS yafaray-xml RUNTIME DESTINATION ${YAF_BIN_DIR}) 7 | -------------------------------------------------------------------------------- /src/yafraycore/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${YAF_INCLUDE_DIRS}) 2 | include_directories(SYSTEM ${LIBXML2_INCLUDE_DIR} ${OPENEXR_INCLUDE_DIRS} 3 | ${FREETYPE_INCLUDE_DIRS}) 4 | set(YF_CORE_SOURCES bound.cc dynamic_library.cc file.cc environment.cc console.cc color_console.cc color_ramp.cc 5 | sysinfo.cc logging.cc session.cc faure_tables.cc std_primitives.cc color.cc renderpasses.cc 6 | matrix4.cc object3d.cc timer.cc kdtree.cc ray_kdtree.cc hashgrid.cc tribox3_d.cc 7 | triclip.cc scene.cc imagefilm.cc imagesplitter.cc material.cc nodematerial.cc 8 | triangle.cc vector3d.cc photon.cc xmlparser.cc spectrum.cc volume.cc 9 | surface.cc integrator.cc mcintegrator.cc 10 | imageOutput.cc memoryIO.cc imagehandler.cc ${headers}) 11 | 12 | add_definitions(-DBUILDING_YAFRAYCORE) 13 | 14 | add_library(yafaray_v3_core SHARED ${YF_CORE_SOURCES}) 15 | 16 | set (DLLOAD_LIB ${CMAKE_DL_LIBS}) 17 | 18 | if(APPLE) # set rpath - Jens 19 | add_custom_command(TARGET yafaray_v3_core POST_BUILD COMMAND install_name_tool -add_rpath @loader_path/ libyafaray_v3_core.dylib) 20 | endif(APPLE) 21 | 22 | target_link_libraries(yafaray_v3_core ${DLLOAD_LIB} ${OPENEXR_LIBRARIES} ${LIBXML2_LIBRARIES} ${FREETYPE_LIBRARIES} ${OpenCV_LIBRARIES}) 23 | 24 | install (TARGETS yafaray_v3_core ${YAF_TARGET_TYPE} DESTINATION ${YAF_LIB_DIR}) 25 | -------------------------------------------------------------------------------- /src/yafraycore/bound.cc: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | __BEGIN_YAFRAY 6 | 7 | bound_t::bound_t(const bound_t &r,const bound_t &l) 8 | { 9 | float minx=std::min(r.a.x,l.a.x); 10 | float miny=std::min(r.a.y,l.a.y); 11 | float minz=std::min(r.a.z,l.a.z); 12 | float maxx=std::max(r.g.x,l.g.x); 13 | float maxy=std::max(r.g.y,l.g.y); 14 | float maxz=std::max(r.g.z,l.g.z); 15 | a.set(minx,miny,minz); 16 | g.set(maxx,maxy,maxz); 17 | } 18 | 19 | float bound_t::vol() const 20 | { 21 | float ret=(g.y-a.y)*(g.x-a.x)*(g.z-a.z); 22 | 23 | return ret; 24 | } 25 | 26 | __END_YAFRAY 27 | -------------------------------------------------------------------------------- /src/yafraycore/color_console.cc: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * color_console.cc: A console coloring utility 3 | * This is part of the yafray package 4 | * Copyright (C) 2010 Rodrigo Placencia Vazquez 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | #include 22 | 23 | #ifdef _WIN32 24 | #include 25 | #endif 26 | 27 | __BEGIN_YAFRAY 28 | 29 | std::ostream &operator << (std::ostream& o, const setColor& c) 30 | { 31 | #if !defined(_WIN32) 32 | o << "\033[" << (int)c.intense; 33 | if(c.fgCol != Default) o << ';' << c.fgCol; 34 | if(c.bgCol != Default) o << ';' << c.bgCol; 35 | return (o << 'm'); 36 | #else 37 | static WORD origAttr = 0; 38 | 39 | if(origAttr == 0) 40 | { 41 | CONSOLE_SCREEN_BUFFER_INFO info; 42 | if(GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &info)) 43 | { 44 | origAttr = info.wAttributes; 45 | } 46 | } 47 | 48 | yColor newFgCol = (c.fgCol != Default) ? (c.fgCol | ((WORD)c.intense << 3)) : (origAttr & 0x0F); 49 | yColor newBgCol = (c.bgCol != Default) ? c.bgCol : (origAttr & 0xF0); 50 | 51 | SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), newBgCol | newFgCol); 52 | #endif 53 | return o; 54 | } 55 | 56 | __END_YAFRAY 57 | 58 | -------------------------------------------------------------------------------- /src/yafraycore/console.cc: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | //#include 7 | //#include 8 | //#include 9 | 10 | #ifdef _MSC_VER 11 | #include 12 | #endif 13 | 14 | __BEGIN_YAFRAY 15 | 16 | #define printBar(progEmpty, progFull, per) \ 17 | std::cout << "\r"; \ 18 | if(yafLog.getConsoleLogColorsEnabled()) std::cout << setColor(Green); \ 19 | std::cout << "Progress: "; \ 20 | if(yafLog.getConsoleLogColorsEnabled()) std::cout << setColor(Red, true); \ 21 | std::cout << "["; \ 22 | if(yafLog.getConsoleLogColorsEnabled()) std::cout << setColor(Green, true); \ 23 | std::cout << std::string(progFull, '#') << std::string(progEmpty, ' '); \ 24 | if(yafLog.getConsoleLogColorsEnabled()) std::cout << setColor(Red, true); \ 25 | std::cout << "] "; \ 26 | if(yafLog.getConsoleLogColorsEnabled()) std::cout << setColor(); \ 27 | std::cout << "("; \ 28 | if(yafLog.getConsoleLogColorsEnabled()) std::cout << setColor(Yellow, true); \ 29 | std::cout << per << "%"; \ 30 | if(yafLog.getConsoleLogColorsEnabled()) std::cout << setColor(); \ 31 | std::cout << ")" << std::flush 32 | 33 | ConsoleProgressBar_t::ConsoleProgressBar_t(int cwidth): width(cwidth), nSteps(0), doneSteps(0) 34 | { 35 | totalBarLen = width - 22; 36 | } 37 | 38 | void ConsoleProgressBar_t::init(int totalSteps) 39 | { 40 | nSteps=totalSteps; 41 | doneSteps = 0; 42 | lastBarLen = 0; 43 | printBar(totalBarLen, 0, 0); 44 | } 45 | 46 | void ConsoleProgressBar_t::update(int steps) 47 | { 48 | doneSteps += steps; 49 | float progress = (float) std::min(doneSteps, nSteps) / (float) nSteps; 50 | int barLen = std::min(totalBarLen, (int)(totalBarLen*progress)); 51 | if(!(barLen >= 0)) barLen = 0; 52 | if(barLen > lastBarLen) 53 | { 54 | printBar(totalBarLen-barLen, barLen, (int) (100 * progress)); 55 | } 56 | lastBarLen = barLen; 57 | } 58 | 59 | void ConsoleProgressBar_t::done() 60 | { 61 | printBar(0, totalBarLen, 100) << yendl; 62 | } 63 | 64 | float ConsoleProgressBar_t::getPercent() const 65 | { 66 | float progress = 0.f; 67 | if(nSteps != 0) progress = 100.f * RoundFloatPrecision((float) std::min(doneSteps, nSteps) / (float) nSteps, 0.01); 68 | return progress; 69 | } 70 | 71 | __END_YAFRAY 72 | -------------------------------------------------------------------------------- /src/yafraycore/dynamic_library.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifndef WIN32 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #endif 10 | 11 | #include 12 | 13 | using namespace std; 14 | 15 | __BEGIN_YAFRAY 16 | 17 | #ifdef WIN32 18 | 19 | void dynamicLoadedLibrary_t::open(const std::string &lib) 20 | { 21 | handle = LoadLibrary(lib.c_str()); 22 | 23 | if (handle == nullptr) { 24 | DWORD err_code = GetLastError(); 25 | const size_t err_buf_size = 64000; 26 | char err_buf[err_buf_size] = {0}; 27 | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, err_code, 0, err_buf, err_buf_size, 0); 28 | 29 | cerr << "failed to open " << lib << ", LoadLibrary error: "; 30 | cerr << err_buf << " (" << err_code << ")" << endl; 31 | } else 32 | refcount=new int(1); 33 | } 34 | 35 | void dynamicLoadedLibrary_t::close() 36 | { 37 | if (handle != nullptr) 38 | { 39 | FreeLibrary(handle); 40 | handle = nullptr; 41 | delete refcount; 42 | } 43 | } 44 | 45 | void * dynamicLoadedLibrary_t::getSymbol(const char *name) 46 | { 47 | if (handle != nullptr) 48 | { 49 | void *func = (void*)GetProcAddress(handle, name); //added explicit cast to enable mingw32 compilation (DarkTide) 50 | if (func == nullptr) 51 | cerr << "GetProcAddress error: " << GetLastError() << endl; 52 | return func; 53 | } 54 | else 55 | { 56 | return nullptr; 57 | } 58 | } 59 | 60 | #else 61 | 62 | void dynamicLoadedLibrary_t::open(const std::string &lib) 63 | { 64 | handle = dlopen(lib.c_str(),RTLD_NOW); 65 | if (handle == nullptr) 66 | cerr << "dlerror: " << dlerror() << endl; 67 | else 68 | refcount=new int(1); 69 | } 70 | 71 | void dynamicLoadedLibrary_t::close() 72 | { 73 | if (handle != nullptr) 74 | { 75 | dlclose(handle); 76 | handle = nullptr; 77 | delete refcount; 78 | } 79 | } 80 | 81 | void * dynamicLoadedLibrary_t::getSymbol(const char *name) 82 | { 83 | if (handle != nullptr) 84 | { 85 | void *func = dlsym(handle, name); 86 | if (func == nullptr) 87 | cerr<<"dlerror: "< 2 | #include 3 | 4 | __BEGIN_YAFRAY 5 | 6 | hashGrid_t::hashGrid_t(double _cellSize, unsigned int _gridSize, yafaray::bound_t _bBox) 7 | :cellSize(_cellSize), gridSize(_gridSize), bBox(_bBox) 8 | { 9 | invcellSize = 1. / cellSize; 10 | } 11 | 12 | void hashGrid_t::setParm(double _cellSize, unsigned int _gridSize, bound_t _bBox) 13 | { 14 | cellSize = _cellSize; 15 | invcellSize = 1. / cellSize; 16 | gridSize = _gridSize; 17 | bBox = _bBox; 18 | } 19 | 20 | void hashGrid_t::clear() 21 | { 22 | photons.clear(); 23 | } 24 | 25 | void hashGrid_t::pushPhoton(photon_t &p) 26 | { 27 | photons.push_back(p); 28 | } 29 | 30 | 31 | void hashGrid_t::updateGrid() 32 | { 33 | 34 | if (!hashGrid) 35 | { 36 | hashGrid = new std::list*[gridSize]; 37 | 38 | for (unsigned int i = 0; i < gridSize; ++i) 39 | hashGrid[i] = nullptr; 40 | } 41 | else 42 | { 43 | for (unsigned int i = 0; i < gridSize; ++i) 44 | { 45 | if( hashGrid[i]) 46 | { 47 | //delete hashGrid[i]; 48 | hashGrid[i]->clear(); // fix me! too many time consumed here 49 | //hashGrid[i] = nullptr; 50 | } 51 | } 52 | } 53 | 54 | //travel the vector to build the Grid 55 | for(auto itr = photons.begin(); itr != photons.end(); ++itr) 56 | { 57 | point3d_t hashindex = ( (*itr).pos - bBox.a) * invcellSize; 58 | 59 | int ix = abs(int(hashindex.x)); 60 | int iy = abs(int(hashindex.y)); 61 | int iz = abs(int(hashindex.z)); 62 | 63 | unsigned int index = Hash(ix,iy,iz); 64 | 65 | if(hashGrid[index] == nullptr) 66 | hashGrid[index] = new std::list(); 67 | 68 | hashGrid[index]->push_front(&(*itr)); 69 | } 70 | unsigned int notused = 0; 71 | for (unsigned int i = 0; i < gridSize; ++i) 72 | { 73 | if(!hashGrid[i] || hashGrid[i]->size() == 0) notused++; 74 | } 75 | Y_VERBOSE<<"HashGrid: there are " << notused << " enties not used!"<begin(); itr != hashGrid[hv]->end(); ++itr) 95 | { 96 | if( ( (*itr)->pos- P).lengthSqr() < sqRadius) 97 | { 98 | found[count++] = foundPhoton_t((*itr),sqRadius); 99 | } 100 | } 101 | } 102 | } 103 | } 104 | return count; 105 | } 106 | 107 | __END_YAFRAY -------------------------------------------------------------------------------- /src/yafraycore/imagesplitter.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | __BEGIN_YAFRAY 7 | 8 | // currently only supports creation of scanrow-ordered tiles 9 | // shuffling would of course be easy, but i don't find that too usefull really, 10 | // it does maximum damage to the coherency gain and visual feedback is medicore too 11 | 12 | imageSpliter_t::imageSpliter_t(int w, int h, int x0,int y0, int bsize, tilesOrderType torder, int nthreads): blocksize(bsize), tilesorder(torder) 13 | { 14 | int nx, ny; 15 | nx = (w+blocksize-1)/blocksize; 16 | ny = (h+blocksize-1)/blocksize; 17 | 18 | std::vector regions_raw; 19 | 20 | for(int j=0; j regions_subdivided; 43 | 44 | for(size_t rn=0; rnregions_raw.size()-nthreads) blocksize2 = std::max(4, blocksize / 4); 54 | else if(rn<=regions_raw.size()-nthreads) blocksize2 = std::max(4, blocksize / 2); 55 | int nx2, ny2; 56 | nx2 = (regions_raw[rn].w+blocksize2-1)/blocksize2; 57 | ny2 = (regions_raw[rn].h+blocksize2-1)/blocksize2; 58 | 59 | for(int j=0; j=(int)regions.size()) return false; 94 | region_t &r = regions[n]; 95 | area.X = r.x; 96 | area.Y = r.y; 97 | area.W = r.w; 98 | area.H = r.h; 99 | return true; 100 | } 101 | 102 | __END_YAFRAY 103 | -------------------------------------------------------------------------------- /src/yafraycore/material.cc: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * material.cc: default implementations for materials 3 | * This is part of the yafray package 4 | * Copyright (C) 2006 Mathias Wein 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | __BEGIN_YAFRAY 28 | 29 | 30 | float material_t::highestMaterialIndex = 1.f; //Initially this class shared variable will be 1.f 31 | unsigned int material_t::materialIndexAuto = 0; //Initially this class shared variable will be 0 32 | float material_t::mHighestSamplingFactor = 1.f; //Initially this class shared variable will be 1.f 33 | 34 | 35 | bool material_t::scatterPhoton(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wi, vector3d_t &wo, pSample_t &s) const 36 | { 37 | float W = 0.f; 38 | color_t scol = sample(state, sp, wi, wo, s, W); 39 | if(s.pdf > 1.0e-6f) 40 | { 41 | color_t cnew = s.lcol * s.alpha * scol * W; 42 | float new_max = cnew.maximum(); 43 | float old_max = s.lcol.maximum(); 44 | float prob = std::min(1.f, new_max/old_max); 45 | if(s.s3 <= prob && prob > 1e-4f) 46 | { 47 | s.color = cnew / prob; 48 | return true; 49 | } 50 | } 51 | return false; 52 | } 53 | 54 | color_t material_t::getReflectivity(const renderState_t &state, const surfacePoint_t &sp, BSDF_t flags)const 55 | { 56 | if(! (flags & (BSDF_TRANSMIT | BSDF_REFLECT) & bsdfFlags) ) return color_t(0.f); 57 | float s1, s2, s3, s4, W = 0.f; 58 | color_t total(0.f), col; 59 | vector3d_t wi, wo; 60 | for(int i=0; i<16; ++i) 61 | { 62 | s1 = 0.03125 + 0.0625 * (float)i; // (1.f/32.f) + (1.f/16.f)*(float)i; 63 | s2 = RI_vdC(i); 64 | s3 = scrHalton(2, i); 65 | s4 = scrHalton(3, i); 66 | wo = SampleCosHemisphere(sp.N, sp.NU, sp.NV, s1, s2); 67 | sample_t s(s3, s4, flags); 68 | col = sample(state, sp, wo, wi, s, W); 69 | total += col * W; 70 | } 71 | return total * 0.0625; //total / 16.f 72 | } 73 | 74 | 75 | void material_t::applyBump(surfacePoint_t &sp, float dfdNU, float dfdNV) const 76 | { 77 | sp.NU += dfdNU * sp.N; 78 | sp.NV += dfdNV * sp.N; 79 | sp.N = (sp.NU ^ sp.NV).normalize(); 80 | sp.NU.normalize(); 81 | sp.NV = (sp.N ^ sp.NU).normalize(); 82 | } 83 | 84 | __END_YAFRAY 85 | -------------------------------------------------------------------------------- /src/yafraycore/memoryIO.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | __BEGIN_YAFRAY 8 | 9 | 10 | memoryIO_t::memoryIO_t ( int resx, int resy, float* iMem ) 11 | { 12 | sizex = resx; 13 | sizey = resy; 14 | imageMem = iMem; // iMem must be a valid pointer to memory of the size: sizex * sizey * 4 * sizeof(float) 15 | } 16 | 17 | // Depth channel support? 18 | 19 | //FIXME: the putpixel functions in MemoryIO are not actually using the Render Passes, always using the Combined pass. Probably no need for this to do anything for now, but in the future it might need to be extended to include all passes 20 | bool memoryIO_t::putPixel(int numView, int x, int y, const renderPasses_t *renderPasses, int idx, const colorA_t &color, bool alpha) 21 | { 22 | imageMem[(x + sizex * y) * 4 + 0] = color.R; 23 | imageMem[(x + sizex * y) * 4 + 0] = color.G; 24 | imageMem[(x + sizex * y) * 4 + 0] = color.B; 25 | if(!alpha) imageMem[(x + sizex * y) * 4 + 3] = 1.f; 26 | 27 | return true; 28 | } 29 | 30 | //FIXME: the putpixel functions in MemoryIO are not actually using the Render Passes, always using the Combined pass. Probably no need for this to do anything for now, but in the future it might need to be extended to include all passes 31 | bool memoryIO_t::putPixel(int numView, int x, int y, const renderPasses_t *renderPasses, const std::vector &colExtPasses, bool alpha) 32 | { 33 | imageMem[(x + sizex * y) * 4 + 0] = colExtPasses.at(0).R; 34 | imageMem[(x + sizex * y) * 4 + 0] = colExtPasses.at(0).G; 35 | imageMem[(x + sizex * y) * 4 + 0] = colExtPasses.at(0).B; 36 | if(!alpha) imageMem[(x + sizex * y) * 4 + 3] = 1.f; 37 | 38 | return true; 39 | } 40 | 41 | void memoryIO_t::flush(int numView, const renderPasses_t *renderPasses) { } 42 | 43 | memoryIO_t::~memoryIO_t() { } 44 | 45 | 46 | __END_YAFRAY 47 | 48 | -------------------------------------------------------------------------------- /src/yafraycore/object3d.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | __BEGIN_YAFRAY 6 | 7 | float object3d_t::highestObjectIndex = 1.f; //Initially this class shared variable will be 1.f 8 | unsigned int object3d_t::objectIndexAuto = 0; //Initially this class shared variable will be 0 9 | 10 | 11 | triangleObject_t::triangleObject_t(int ntris, bool hasUV, bool hasOrco): 12 | has_orco(hasOrco), has_uv(hasUV), is_smooth(false), normals_exported(false) 13 | { 14 | triangles.reserve(ntris); 15 | if(hasUV) 16 | { 17 | uv_offsets.reserve(ntris); 18 | } 19 | 20 | if(hasOrco) 21 | { 22 | points.reserve(2 * 3 * ntris); 23 | } 24 | else 25 | { 26 | points.reserve(3 * ntris); 27 | } 28 | } 29 | 30 | int triangleObject_t::getPrimitives(const triangle_t **prims) 31 | { 32 | for(unsigned int i=0; i < triangles.size(); ++i) 33 | { 34 | prims[i] = &(triangles[i]); 35 | } 36 | return triangles.size(); 37 | } 38 | 39 | triangle_t* triangleObject_t::addTriangle(const triangle_t &t) 40 | { 41 | triangles.push_back(t); 42 | triangles.back().selfIndex = triangles.size() - 1; 43 | return &(triangles.back()); 44 | } 45 | 46 | void triangleObject_t::finish() 47 | { 48 | for(auto i=triangles.begin(); i!= triangles.end(); ++i) 49 | { 50 | i->recNormal(); 51 | } 52 | } 53 | 54 | // triangleObjectInstance_t Methods 55 | 56 | triangleObjectInstance_t::triangleObjectInstance_t(triangleObject_t *base, matrix4x4_t obj2World) 57 | { 58 | objToWorld = obj2World; 59 | mBase = base; 60 | has_orco = mBase->has_orco; 61 | has_uv = mBase->has_uv; 62 | is_smooth = mBase->is_smooth; 63 | normals_exported = mBase->normals_exported; 64 | visible = true; 65 | is_base_mesh = false; 66 | 67 | triangles.reserve(mBase->triangles.size()); 68 | 69 | for(size_t i = 0; i < mBase->triangles.size(); i++) 70 | { 71 | triangles.push_back(triangleInstance_t(&mBase->triangles[i], this)); 72 | } 73 | } 74 | 75 | int triangleObjectInstance_t::getPrimitives(const triangle_t **prims) 76 | { 77 | for(size_t i = 0; i < triangles.size(); i++) 78 | { 79 | prims[i] = &triangles[i]; 80 | } 81 | return triangles.size(); 82 | } 83 | 84 | void triangleObjectInstance_t::finish() 85 | { 86 | // Empty 87 | } 88 | 89 | /*=================== 90 | meshObject_t methods 91 | =====================================*/ 92 | 93 | meshObject_t::meshObject_t(int ntris, bool hasUV, bool hasOrco): 94 | has_orco(hasOrco), has_uv(hasUV), has_vcol(false), is_smooth(false), light(nullptr) 95 | { 96 | //triangles.reserve(ntris); 97 | if(hasUV) 98 | { 99 | uv_offsets.reserve(ntris); 100 | } 101 | } 102 | 103 | int meshObject_t::getPrimitives(const primitive_t **prims) const 104 | { 105 | int n=0; 106 | for(unsigned int i=0; i < triangles.size(); ++i, ++n) 107 | { 108 | prims[n] = &(triangles[i]); 109 | } 110 | for(unsigned int i=0; i < s_triangles.size(); ++i, ++n) 111 | { 112 | prims[n] = &(s_triangles[i]); 113 | } 114 | return n; 115 | } 116 | 117 | primitive_t* meshObject_t::addTriangle(const vTriangle_t &t) 118 | { 119 | triangles.push_back(t); 120 | return &(triangles.back()); 121 | } 122 | 123 | primitive_t* meshObject_t::addBsTriangle(const bsTriangle_t &t) 124 | { 125 | s_triangles.push_back(t); 126 | return &(triangles.back()); 127 | } 128 | 129 | void meshObject_t::finish() 130 | { 131 | for(auto i=triangles.begin(); i!= triangles.end(); ++i) 132 | { 133 | i->recNormal(); 134 | } 135 | } 136 | 137 | __END_YAFRAY 138 | -------------------------------------------------------------------------------- /src/yafraycore/std_primitives.cc: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * std_primitives.cc: standard geometric primitives 3 | * This is part of the yafray package 4 | * Copyright (C) 2006 Mathias Wein 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | __BEGIN_YAFRAY 27 | 28 | bound_t sphere_t::getBound() const 29 | { 30 | vector3d_t r(radius * 1.0001); 31 | return bound_t(center - r, center + r); 32 | } 33 | 34 | bool sphere_t::intersect(const ray_t &ray, float *t, intersectData_t &data) const 35 | { 36 | vector3d_t vf = ray.from - center; 37 | float ea = ray.dir*ray.dir; 38 | float eb = 2.0*(vf*ray.dir); 39 | float ec = vf*vf - radius*radius; 40 | float osc = eb*eb-4.0*ea*ec; 41 | if(osc<0) return false; 42 | osc=fSqrt(osc); 43 | float sol1=(-eb-osc)/(2.0*ea); 44 | float sol2=(-eb+osc)/(2.0*ea); 45 | float sol=sol1; 46 | if(sol < ray.tmin) 47 | { 48 | sol = sol2; 49 | if(sol < ray.tmin) return false; 50 | } 51 | //if(sol > ray.tmax) return false; //tmax = -1 is not substituted yet... 52 | *t = sol; 53 | return true; 54 | } 55 | 56 | void sphere_t::getSurface(surfacePoint_t &sp, const point3d_t &hit, intersectData_t &data) const 57 | { 58 | vector3d_t normal = hit - center; 59 | sp.orcoP = normal; 60 | normal.normalize(); 61 | sp.material = material; 62 | sp.N = normal; 63 | sp.Ng = normal; 64 | //sp.origin = (void*)this; 65 | sp.hasOrco = true; 66 | sp.P = hit; 67 | createCS(sp.N, sp.NU, sp.NV); 68 | sp.U = atan2(normal.y, normal.x)*M_1_PI + 1; 69 | sp.V = 1.f - fAcos(normal.z)*M_1_PI; 70 | sp.light = nullptr; 71 | } 72 | 73 | object3d_t* sphere_factory(paraMap_t ¶ms, renderEnvironment_t &env) 74 | { 75 | point3d_t center(0.f, 0.f, 0.f); 76 | double radius(1.f); 77 | const material_t *mat; 78 | const std::string *matname = nullptr; 79 | params.getParam("center", center); 80 | params.getParam("radius", radius); 81 | params.getParam("material", matname); 82 | if(!matname) return nullptr; 83 | mat = env.getMaterial(*matname); 84 | if(!mat) return nullptr; 85 | sphere_t *sphere = new sphere_t(center, radius, mat); 86 | return new primObject_t(sphere); 87 | } 88 | 89 | __END_YAFRAY 90 | -------------------------------------------------------------------------------- /src/yafraycore/sysinfo.cc: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * sysinfo.cc: runtime system information 3 | * This is part of the yafray package 4 | * Copyright (C) 2006 Mathias Wein 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | //Threads detection code moved here from scene.cc 22 | 23 | #include 24 | #include 25 | 26 | #ifdef __APPLE__ 27 | #include 28 | #elif _WIN32 29 | #include 30 | #endif 31 | #if HAVE_UNISTD_H 32 | #include 33 | #endif 34 | 35 | __BEGIN_YAFRAY 36 | 37 | int sysInfo_t::getNumSystemThreads() const 38 | { 39 | int nthreads = 1; 40 | 41 | #ifdef WIN32 42 | SYSTEM_INFO info; 43 | GetSystemInfo(&info); 44 | nthreads = (int) info.dwNumberOfProcessors; 45 | #else 46 | # ifdef __APPLE__ 47 | int mib[2]; 48 | size_t len; 49 | 50 | mib[0] = CTL_HW; 51 | mib[1] = HW_NCPU; 52 | len = sizeof(int); 53 | sysctl(mib, 2, &nthreads, &len, nullptr, 0); 54 | # elif defined(__sgi) 55 | nthreads = sysconf(_SC_NPROC_ONLN); 56 | # else 57 | nthreads = (int)sysconf(_SC_NPROCESSORS_ONLN); 58 | # endif 59 | #endif 60 | 61 | return nthreads; 62 | } 63 | 64 | __END_YAFRAY 65 | -------------------------------------------------------------------------------- /src/yafraycore/timer.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifdef _WIN32 4 | #include 5 | #else 6 | #include 7 | #endif 8 | 9 | __BEGIN_YAFRAY 10 | 11 | timer_t gTimer; 12 | 13 | bool timer_t::addEvent(const std::string &name) 14 | { 15 | if(includes(name)) return false; 16 | else events[name] = tdata_t(); 17 | return true; 18 | } 19 | 20 | bool timer_t::start(const std::string &name) 21 | { 22 | auto i=events.find(name); 23 | if(i==events.end()) return false; 24 | #ifdef WIN32 25 | i->second.start = clock(); 26 | #else 27 | struct timezone tz; 28 | gettimeofday(&i->second.tvs, &tz); 29 | #endif 30 | i->second.started = true; 31 | return true; 32 | } 33 | 34 | bool timer_t::stop(const std::string &name) 35 | { 36 | auto i=events.find(name); 37 | if(i==events.end()) return false; 38 | if(!(i->second.started))return false; 39 | #ifdef WIN32 40 | i->second.finish = clock(); 41 | #else 42 | struct timezone tz; 43 | gettimeofday(&i->second.tvf, &tz); 44 | #endif 45 | i->second.stopped = true; 46 | return true; 47 | } 48 | 49 | bool timer_t::reset(const std::string &name) 50 | { 51 | auto i=events.find(name); 52 | if (i==events.end()) return false; 53 | i->second.started = false; 54 | i->second.stopped = false; 55 | return true; 56 | } 57 | 58 | double timer_t::getTime(const std::string &name) 59 | { 60 | auto i=events.find(name); 61 | if (i==events.end()) return -1; 62 | #ifdef WIN32 63 | else return ((double) (i->second.finish - i->second.start) ) / CLOCKS_PER_SEC; 64 | #else 65 | else 66 | { 67 | const tdata_t &td = i->second; 68 | return (td.tvf.tv_sec - td.tvs.tv_sec) + double(td.tvf.tv_usec - td.tvs.tv_usec)/1.0e6; 69 | } 70 | #endif 71 | } 72 | 73 | double timer_t::getTimeNotStopping(const std::string &name) 74 | { 75 | auto i=events.find(name); 76 | if (i==events.end()) return -1; 77 | #ifdef WIN32 78 | else return ((double) (clock() - i->second.start) ) / CLOCKS_PER_SEC; 79 | #else 80 | else 81 | { 82 | timeval now; 83 | struct timezone tz; 84 | gettimeofday(&now, &tz); 85 | const tdata_t &td = i->second; 86 | return (now.tv_sec - td.tvs.tv_sec) + double(now.tv_usec - td.tvs.tv_usec)/1.0e6; 87 | } 88 | #endif 89 | } 90 | 91 | 92 | bool timer_t::includes(const std::string &label)const 93 | { 94 | auto i=events.find(label); 95 | return (i==events.end()) ? false : true; 96 | } 97 | 98 | void timer_t::splitTime(double t, double *secs, int *mins, int *hours, int *days) 99 | { 100 | int times = (int)t; 101 | int s = times; 102 | int d = times / 86400; 103 | if(days) 104 | { 105 | *days = d; 106 | times -= d*86400; 107 | } 108 | int h = times / 3600; 109 | if(hours) 110 | { 111 | *hours = h; 112 | times -= h*3600; 113 | } 114 | int m = times / 60; 115 | if(mins) 116 | { 117 | *mins = m; 118 | times -= m*60; 119 | } 120 | *secs = t - double(s - times); 121 | } 122 | 123 | __END_YAFRAY 124 | -------------------------------------------------------------------------------- /tests/test01/test01 - expected render result.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YafaRay/Core/e780bdc6ad36d89c356d256ab56c99d0b7e30b85/tests/test01/test01 - expected render result.png -------------------------------------------------------------------------------- /tests/test01/test01_tex.exr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YafaRay/Core/e780bdc6ad36d89c356d256ab56c99d0b7e30b85/tests/test01/test01_tex.exr -------------------------------------------------------------------------------- /tests/test01/test01_tex.hdr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YafaRay/Core/e780bdc6ad36d89c356d256ab56c99d0b7e30b85/tests/test01/test01_tex.hdr -------------------------------------------------------------------------------- /tests/test01/test01_tex.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YafaRay/Core/e780bdc6ad36d89c356d256ab56c99d0b7e30b85/tests/test01/test01_tex.jpg -------------------------------------------------------------------------------- /tests/test01/test01_tex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YafaRay/Core/e780bdc6ad36d89c356d256ab56c99d0b7e30b85/tests/test01/test01_tex.png -------------------------------------------------------------------------------- /tests/test01/test01_tex.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YafaRay/Core/e780bdc6ad36d89c356d256ab56c99d0b7e30b85/tests/test01/test01_tex.tga -------------------------------------------------------------------------------- /tests/test01/test01_tex.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YafaRay/Core/e780bdc6ad36d89c356d256ab56c99d0b7e30b85/tests/test01/test01_tex.tif --------------------------------------------------------------------------------