From 1e8e30c72d782b478467a1ec5cf9e13d710c49ac Mon Sep 17 00:00:00 2001 From: est77 Date: Wed, 15 Apr 2020 20:44:23 +0200 Subject: [PATCH] Remove Disney Material --- CMakeLists.txt | 25 - THIRDPARTIES.txt | 25 - cmake/config/linux-gcc-clang.txt | 8 - cmake/config/mac-clang.txt | 8 - cmake/config/win-vs.txt | 22 - cmake/modules/FindSeExpr.cmake | 64 -- cmake/modules/FindSeExprEditor.cmake | 64 -- sandbox/seexpr/clouds/blue_clouds.se | 8 - sandbox/seexpr/geometric/checkers.se | 7 - sandbox/seexpr/geometric/dots.se | 8 - sandbox/seexpr/gradients/horizontal.se | 1 - sandbox/seexpr/gradients/vertical.se | 1 - sandbox/seexpr/noise/fbm.se | 5 - sandbox/seexpr/noise/noise.se | 5 - sandbox/seexpr/noise/turbulence.se | 8 - sandbox/share/cmake/Modules/FindSeExpr.cmake | 64 -- .../cmake/Modules/FindSeExprEditor.cmake | 64 -- .../help/about/aboutwindow.cpp | 8 - .../application/commandlinehandlerbase.cpp | 9 - src/appleseed.studio/CMakeLists.txt | 19 - .../help/about/aboutwindow.cpp | 8 - .../mainwindow/project/assemblyitem.cpp | 1 - .../project/disneymaterialcustomui.cpp | 253 ------ .../project/disneymaterialcustomui.h | 95 -- .../project/disneymateriallayerui.cpp | 566 ------------ .../project/disneymateriallayerui.h | 130 --- .../project/expressioneditorwindow.cpp | 354 -------- .../project/expressioneditorwindow.h | 105 --- .../project/expressioneditorwindow.ui | 52 -- .../project/materialcollectionitem.cpp | 121 +-- .../project/materialcollectionitem.h | 4 - .../mainwindow/project/materialitem.cpp | 29 +- .../mainwindow/project/objectinstanceitem.cpp | 100 -- .../mainwindow/project/objectinstanceitem.h | 2 - src/appleseed/CMakeLists.txt | 28 - .../foundation/core/buildoptions.h.in | 1 - .../foundation/core/thirdparties.cpp | 2 - .../foundation/meta/tests/test_seexpr.cpp | 118 --- src/appleseed/foundation/utility/seexpr.cpp | 91 -- src/appleseed/foundation/utility/seexpr.h | 70 -- src/appleseed/renderer/api/material.h | 3 - .../modeling/bsdf/disneylayeredbrdf.cpp | 212 ----- .../modeling/bsdf/disneylayeredbrdf.h | 119 --- .../modeling/material/disneymaterial.cpp | 852 ------------------ .../modeling/material/disneymaterial.h | 196 ---- .../material/materialfactoryregistrar.cpp | 6 - .../modeling/project/projectfileupdater.cpp | 20 - src/appleseed/renderer/utility/seexpr.h | 266 ------ 48 files changed, 3 insertions(+), 4224 deletions(-) delete mode 100644 cmake/modules/FindSeExpr.cmake delete mode 100644 cmake/modules/FindSeExprEditor.cmake delete mode 100644 sandbox/seexpr/clouds/blue_clouds.se delete mode 100644 sandbox/seexpr/geometric/checkers.se delete mode 100644 sandbox/seexpr/geometric/dots.se delete mode 100644 sandbox/seexpr/gradients/horizontal.se delete mode 100644 sandbox/seexpr/gradients/vertical.se delete mode 100644 sandbox/seexpr/noise/fbm.se delete mode 100644 sandbox/seexpr/noise/noise.se delete mode 100644 sandbox/seexpr/noise/turbulence.se delete mode 100644 sandbox/share/cmake/Modules/FindSeExpr.cmake delete mode 100644 sandbox/share/cmake/Modules/FindSeExprEditor.cmake delete mode 100644 src/appleseed.studio/mainwindow/project/disneymaterialcustomui.cpp delete mode 100644 src/appleseed.studio/mainwindow/project/disneymaterialcustomui.h delete mode 100644 src/appleseed.studio/mainwindow/project/disneymateriallayerui.cpp delete mode 100644 src/appleseed.studio/mainwindow/project/disneymateriallayerui.h delete mode 100644 src/appleseed.studio/mainwindow/project/expressioneditorwindow.cpp delete mode 100644 src/appleseed.studio/mainwindow/project/expressioneditorwindow.h delete mode 100644 src/appleseed.studio/mainwindow/project/expressioneditorwindow.ui delete mode 100644 src/appleseed/foundation/meta/tests/test_seexpr.cpp delete mode 100644 src/appleseed/foundation/utility/seexpr.cpp delete mode 100644 src/appleseed/foundation/utility/seexpr.h delete mode 100644 src/appleseed/renderer/modeling/bsdf/disneylayeredbrdf.cpp delete mode 100644 src/appleseed/renderer/modeling/bsdf/disneylayeredbrdf.h delete mode 100644 src/appleseed/renderer/modeling/material/disneymaterial.cpp delete mode 100644 src/appleseed/renderer/modeling/material/disneymaterial.h delete mode 100644 src/appleseed/renderer/utility/seexpr.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a01f82433..50edf8d8d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -131,7 +131,6 @@ option (WITH_BENCH "Build appleseed.bench" option (WITH_TOOLS "Build appleseed tools" ON) option (WITH_PYTHON2_BINDINGS "Build Python bindings for Python 2" ON) option (WITH_PYTHON3_BINDINGS "Build Python bindings for Python 3" OFF) -option (WITH_DISNEY_MATERIAL "Build Disney material" OFF) option (WITH_EMBREE "Include support for Embree intersection backend" OFF) option (WITH_GPU "Build GPU support" OFF) option (WITH_SPECTRAL_SUPPORT "Include support for spectral colors" ON) @@ -147,7 +146,6 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Windows") option (USE_FIND_PACKAGE_FOR_OCIO "Use find_package() for OpenColorIO library" OFF) option (USE_FIND_PACKAGE_FOR_OIIO "Use find_package() for OpenImageIO library" OFF) option (USE_FIND_PACKAGE_FOR_OSL "Use find_package() for OpenShadingLanguage library" OFF) - option (USE_FIND_PACKAGE_FOR_SEEXPR "Use find_package() for SeExpr library" OFF) option (USE_FIND_PACKAGE_FOR_XERCES "Use find_package() for Xerces library" OFF) option (USE_FIND_PACKAGE_FOR_ZLIB "Use find_package() for zlib library" OFF) else () @@ -158,7 +156,6 @@ else () set (USE_FIND_PACKAGE_FOR_OIIO ON) set (USE_FIND_PACKAGE_FOR_OSL ON) set (USE_FIND_PACKAGE_FOR_PNG ON) - set (USE_FIND_PACKAGE_FOR_SEEXPR ON) set (USE_FIND_PACKAGE_FOR_XERCES ON) set (USE_FIND_PACKAGE_FOR_ZLIB ON) endif () @@ -323,17 +320,6 @@ if (USE_FIND_PACKAGE_FOR_PNG) find_package (PNG REQUIRED) endif () -if (WITH_DISNEY_MATERIAL) - set (APPLESEED_WITH_DISNEY_MATERIAL ON) - add_definitions (-DAPPLESEED_WITH_DISNEY_MATERIAL) - if (USE_FIND_PACKAGE_FOR_SEEXPR) - find_package (SeExpr REQUIRED) - if (WITH_STUDIO) - find_package (SeExprEditor REQUIRED) - endif () - endif () -endif () - if (USE_FIND_PACKAGE_FOR_XERCES) add_definitions (-DAPPLESEED_WITH_EXTERNAL_XERCES) find_package (Xerces REQUIRED) @@ -404,17 +390,6 @@ else () include_directories (${APPLESEED_DEPS_STAGE_DIR}/osl-debug/include) endif () -if (WITH_DISNEY_MATERIAL) - if (USE_FIND_PACKAGE_FOR_SEEXPR) - include_directories (${SEEXPR_INCLUDE_DIRS}) - if (WITH_STUDIO) - include_directories (${SEEXPREDITOR_INCLUDE_DIRS}) - endif () - else () - include_directories (${APPLESEED_DEPS_STAGE_DIR}/SeExpr-debug/include) - endif () -endif () - if (USE_FIND_PACKAGE_FOR_XERCES) include_directories (${XERCES_INCLUDE_DIRS}) else () diff --git a/THIRDPARTIES.txt b/THIRDPARTIES.txt index a6d4ba8709..6dd6e2ccb6 100644 --- a/THIRDPARTIES.txt +++ b/THIRDPARTIES.txt @@ -1663,31 +1663,6 @@ License: ------------------------------------------------------------------------------ -SeExpr -https://www.disneyanimation.com/technology/seexpr.html - -License: - - - Copyright Disney Enterprises, Inc. All rights reserved. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License - and the following modification to it: Section 6 Trademarks. - deleted and replaced with: - - 6. Trademarks. This License does not grant permission to use the - trade names, trademarks, service marks, or product names of the - Licensor and its affiliates, except as required for reproducing - the content of the NOTICE file. - - You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - - ------------------------------------------------------------------------------- - - Xerces-C++ https://xerces.apache.org/xerces-c/ diff --git a/cmake/config/linux-gcc-clang.txt b/cmake/config/linux-gcc-clang.txt index d0c61f0b88..bdb316eaec 100644 --- a/cmake/config/linux-gcc-clang.txt +++ b/cmake/config/linux-gcc-clang.txt @@ -201,14 +201,6 @@ macro (link_against_osl target) target_link_libraries (${target} ${OSL_EXEC_LIBRARY} ${OSL_COMP_LIBRARY} ${OSL_QUERY_LIBRARY}) endmacro () -macro (link_against_seexpr target) - target_link_libraries (${target} ${SEEXPR_LIBRARIES}) -endmacro () - -macro (link_against_seexpreditor target) - target_link_libraries (${target} ${SEEXPREDITOR_LIBRARIES}) -endmacro () - macro (link_against_xercesc target) target_link_libraries (${target} ${XERCES_LIBRARIES}) endmacro () diff --git a/cmake/config/mac-clang.txt b/cmake/config/mac-clang.txt index f22729af90..8f6393e5f0 100644 --- a/cmake/config/mac-clang.txt +++ b/cmake/config/mac-clang.txt @@ -148,14 +148,6 @@ macro (link_against_osl target) target_link_libraries (${target} ${OSL_EXEC_LIBRARY} ${OSL_COMP_LIBRARY} ${OSL_QUERY_LIBRARY}) endmacro () -macro (link_against_seexpr target) - target_link_libraries (${target} ${SEEXPR_LIBRARIES}) -endmacro () - -macro (link_against_seexpreditor target) - target_link_libraries (${target} ${SEEXPREDITOR_LIBRARIES}) -endmacro () - macro (link_against_xercesc target) target_link_libraries (${target} ${XERCES_LIBRARIES}) endmacro () diff --git a/cmake/config/win-vs.txt b/cmake/config/win-vs.txt index 615a220289..c7bb608512 100644 --- a/cmake/config/win-vs.txt +++ b/cmake/config/win-vs.txt @@ -351,28 +351,6 @@ macro (link_against_osl target) endif () endmacro () -macro (link_against_seexpr target) - if (USE_FIND_PACKAGE_FOR_SEEXPR) - target_link_libraries (${target} ${SEEXPR_LIBRARIES}) - else () - target_link_libraries (${target} - debug ${APPLESEED_DEPS_STAGE_DIR}/seexpr-debug/lib/SeExpr.lib - optimized ${APPLESEED_DEPS_STAGE_DIR}/seexpr-release/lib/SeExpr.lib - ) - endif () -endmacro () - -macro (link_against_seexpreditor target) - if (USE_FIND_PACKAGE_FOR_SEEXPR) - target_link_libraries (${target} ${SEEXPREDITOR_LIBRARIES}) - else () - target_link_libraries (${target} - debug ${APPLESEED_DEPS_STAGE_DIR}/seexpr-debug/lib/SeExprEditor.lib - optimized ${APPLESEED_DEPS_STAGE_DIR}/seexpr-release/lib/SeExprEditor.lib - ) - endif () -endmacro () - macro (link_against_xercesc target) if (USE_FIND_PACKAGE_FOR_XERCES) target_link_libraries (${target} ${XERCES_LIBRARIES}) diff --git a/cmake/modules/FindSeExpr.cmake b/cmake/modules/FindSeExpr.cmake deleted file mode 100644 index c19886c587..0000000000 --- a/cmake/modules/FindSeExpr.cmake +++ /dev/null @@ -1,64 +0,0 @@ - -# -# This source file is part of appleseed. -# Visit https://appleseedhq.net/ for additional information and resources. -# -# This software is released under the MIT license. -# -# Copyright (c) 2013-2018 Esteban Tovagliari, The appleseedhq Organization -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - - -# -# Find SeExpr headers and libraries. -# -# This module defines the following variables: -# -# SEEXPR_FOUND True if SeExpr was found -# SEEXPR_INCLUDE_DIRS Where to find SeExpr header files -# SEEXPR_LIBRARIES List of SeExpr libraries to link against -# - -include (FindPackageHandleStandardArgs) - -find_path (SEEXPR_INCLUDE_DIR NAMES SeExpression.h) - -find_library (SEEXPR_LIBRARY NAMES SeExpr) - -# Handle the QUIETLY and REQUIRED arguments and set SEEXPR_FOUND. -find_package_handle_standard_args (SEEXPR DEFAULT_MSG - SEEXPR_INCLUDE_DIR - SEEXPR_LIBRARY -) - -# Set the output variables. -if (SEEXPR_FOUND) - set (SEEXPR_INCLUDE_DIRS ${SEEXPR_INCLUDE_DIR}) - set (SEEXPR_LIBRARIES ${SEEXPR_LIBRARY}) -else () - set (SEEXPR_INCLUDE_DIRS) - set (SEEXPR_LIBRARIES) -endif () - -mark_as_advanced ( - SEEXPR_INCLUDE_DIR - SEEXPR_LIBRARY -) diff --git a/cmake/modules/FindSeExprEditor.cmake b/cmake/modules/FindSeExprEditor.cmake deleted file mode 100644 index 361f8f95ec..0000000000 --- a/cmake/modules/FindSeExprEditor.cmake +++ /dev/null @@ -1,64 +0,0 @@ - -# -# This source file is part of appleseed. -# Visit https://appleseedhq.net/ for additional information and resources. -# -# This software is released under the MIT license. -# -# Copyright (c) 2014-2018 Marius Avram, The appleseedhq Organization -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - - -# -# Find SeExprEditor headers and libraries. -# -# This module defines the following variables: -# -# SEEXPREDITOR_FOUND True if SeExprEditor was found -# SEEXPREDITOR_INCLUDE_DIRS Where to find SeExprEditor header files -# SEEXPREDITOR_LIBRARIES List of SeExprEditor libraries to link against -# - -include (FindPackageHandleStandardArgs) - -find_path (SEEXPREDITOR_INCLUDE_DIR NAMES SeExprEditor/SeExprEditor.h) - -find_library (SEEXPREDITOR_LIBRARY NAMES SeExprEditor) - -# Handle the QUIETLY and REQUIRED arguments and set SEEXPREDITOR_FOUND. -find_package_handle_standard_args (SEEXPREDITOR DEFAULT_MSG - SEEXPREDITOR_INCLUDE_DIR - SEEXPREDITOR_LIBRARY -) - -# Set the output variables. -if (SEEXPREDITOR_FOUND) - set (SEEXPREDITOR_INCLUDE_DIRS ${SEEXPR_INCLUDE_DIR}) - set (SEEXPREDITOR_LIBRARIES ${SEEXPREDITOR_LIBRARY}) -else () - set (SEEXPREDITOR_INCLUDE_DIRS) - set (SEEXPREDITOR_LIBRARIES) -endif () - -mark_as_advanced ( - SEEXPREDITOR_INCLUDE_DIR - SEEXPREDITOR_LIBRARY -) diff --git a/sandbox/seexpr/clouds/blue_clouds.se b/sandbox/seexpr/clouds/blue_clouds.se deleted file mode 100644 index 852306c67d..0000000000 --- a/sandbox/seexpr/clouds/blue_clouds.se +++ /dev/null @@ -1,8 +0,0 @@ -$freq = 7; # 0.0 100.0 -$contrast = 0.65; # 0.0 1.0 - -$p = [$u, $v, 0.0] * $freq; - -$x = fbm( $p + fbm( $p + fbm($p))); -$cc = ccurve(sin($x),0,[0.0823529,0.203922,0.223529],4,1,[0.737255,0.545098,1],4,0.680052,[0.101961,0.141176,0.262745],4,0.317536,[0.768627,0.921569,0.933333],4); -contrast($cc, $contrast) diff --git a/sandbox/seexpr/geometric/checkers.se b/sandbox/seexpr/geometric/checkers.se deleted file mode 100644 index 9fc8a420e6..0000000000 --- a/sandbox/seexpr/geometric/checkers.se +++ /dev/null @@ -1,7 +0,0 @@ -$col1 = [0,0,0]; -$col2 = [1,1,1]; -$freq = 4; # 0.000, 100.000 - -$p = [$u, $v, 0] * $freq; - -(floor($p[0]) + floor($p[1])) % 2 == 0 ? $col1 : $col2 diff --git a/sandbox/seexpr/geometric/dots.se b/sandbox/seexpr/geometric/dots.se deleted file mode 100644 index d879d6751d..0000000000 --- a/sandbox/seexpr/geometric/dots.se +++ /dev/null @@ -1,8 +0,0 @@ -$freq = 4; # 0.000, 100.000 -$radius = 0.5; # 0.000, 1.000 -$softness = 0.005; # 0.0, 1.0 - -$center = [0.5,0.5,0]; -$p = [fmod($u * $freq, 1), fmod($v * $freq, 1), 0.0]; -$r = length( $p - $center); -invert(smoothstep($r, $radius - ($softness * $freq), $radius + ($softness * $freq))) diff --git a/sandbox/seexpr/gradients/horizontal.se b/sandbox/seexpr/gradients/horizontal.se deleted file mode 100644 index 5b5e03f248..0000000000 --- a/sandbox/seexpr/gradients/horizontal.se +++ /dev/null @@ -1 +0,0 @@ -$u diff --git a/sandbox/seexpr/gradients/vertical.se b/sandbox/seexpr/gradients/vertical.se deleted file mode 100644 index b8f362422c..0000000000 --- a/sandbox/seexpr/gradients/vertical.se +++ /dev/null @@ -1 +0,0 @@ -$v diff --git a/sandbox/seexpr/noise/fbm.se b/sandbox/seexpr/noise/fbm.se deleted file mode 100644 index db40384f7e..0000000000 --- a/sandbox/seexpr/noise/fbm.se +++ /dev/null @@ -1,5 +0,0 @@ -$freq = 1; # 0.010, 100.000 -$slice = 0.5; # 0.000, 1.000 -$contrast = 0.5; # 0.000, 1.000 - -contrast(fbm([$freq * $u, $freq * $v, $slice]), $contrast) diff --git a/sandbox/seexpr/noise/noise.se b/sandbox/seexpr/noise/noise.se deleted file mode 100644 index 9da3896317..0000000000 --- a/sandbox/seexpr/noise/noise.se +++ /dev/null @@ -1,5 +0,0 @@ -$freq = 5; # 0.010, 100.000 -$slice = 0.5; # 0.000, 1.000 -$contrast = 0.5; # 0.000, 1.000 - -contrast(noise([$freq * $u, $freq * $v, $slice]), $contrast) diff --git a/sandbox/seexpr/noise/turbulence.se b/sandbox/seexpr/noise/turbulence.se deleted file mode 100644 index a914068526..0000000000 --- a/sandbox/seexpr/noise/turbulence.se +++ /dev/null @@ -1,8 +0,0 @@ -$freq = 10; # 0.010, 100.000 -$slice = 0.5; # 0.000, 1.000 -$octaves = 6; # 1 8 -$lacunarity = 2; # 1.0 4.0 -$gain = 0.5; # 0.0 1.0 -$contrast = 0.5; # 0.000, 1.000 - -contrast(turbulence([$freq * $u, $freq * $v, $slice], $octaves, $lacunarity, $gain), $contrast) diff --git a/sandbox/share/cmake/Modules/FindSeExpr.cmake b/sandbox/share/cmake/Modules/FindSeExpr.cmake deleted file mode 100644 index c19886c587..0000000000 --- a/sandbox/share/cmake/Modules/FindSeExpr.cmake +++ /dev/null @@ -1,64 +0,0 @@ - -# -# This source file is part of appleseed. -# Visit https://appleseedhq.net/ for additional information and resources. -# -# This software is released under the MIT license. -# -# Copyright (c) 2013-2018 Esteban Tovagliari, The appleseedhq Organization -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - - -# -# Find SeExpr headers and libraries. -# -# This module defines the following variables: -# -# SEEXPR_FOUND True if SeExpr was found -# SEEXPR_INCLUDE_DIRS Where to find SeExpr header files -# SEEXPR_LIBRARIES List of SeExpr libraries to link against -# - -include (FindPackageHandleStandardArgs) - -find_path (SEEXPR_INCLUDE_DIR NAMES SeExpression.h) - -find_library (SEEXPR_LIBRARY NAMES SeExpr) - -# Handle the QUIETLY and REQUIRED arguments and set SEEXPR_FOUND. -find_package_handle_standard_args (SEEXPR DEFAULT_MSG - SEEXPR_INCLUDE_DIR - SEEXPR_LIBRARY -) - -# Set the output variables. -if (SEEXPR_FOUND) - set (SEEXPR_INCLUDE_DIRS ${SEEXPR_INCLUDE_DIR}) - set (SEEXPR_LIBRARIES ${SEEXPR_LIBRARY}) -else () - set (SEEXPR_INCLUDE_DIRS) - set (SEEXPR_LIBRARIES) -endif () - -mark_as_advanced ( - SEEXPR_INCLUDE_DIR - SEEXPR_LIBRARY -) diff --git a/sandbox/share/cmake/Modules/FindSeExprEditor.cmake b/sandbox/share/cmake/Modules/FindSeExprEditor.cmake deleted file mode 100644 index 361f8f95ec..0000000000 --- a/sandbox/share/cmake/Modules/FindSeExprEditor.cmake +++ /dev/null @@ -1,64 +0,0 @@ - -# -# This source file is part of appleseed. -# Visit https://appleseedhq.net/ for additional information and resources. -# -# This software is released under the MIT license. -# -# Copyright (c) 2014-2018 Marius Avram, The appleseedhq Organization -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - - -# -# Find SeExprEditor headers and libraries. -# -# This module defines the following variables: -# -# SEEXPREDITOR_FOUND True if SeExprEditor was found -# SEEXPREDITOR_INCLUDE_DIRS Where to find SeExprEditor header files -# SEEXPREDITOR_LIBRARIES List of SeExprEditor libraries to link against -# - -include (FindPackageHandleStandardArgs) - -find_path (SEEXPREDITOR_INCLUDE_DIR NAMES SeExprEditor/SeExprEditor.h) - -find_library (SEEXPREDITOR_LIBRARY NAMES SeExprEditor) - -# Handle the QUIETLY and REQUIRED arguments and set SEEXPREDITOR_FOUND. -find_package_handle_standard_args (SEEXPREDITOR DEFAULT_MSG - SEEXPREDITOR_INCLUDE_DIR - SEEXPREDITOR_LIBRARY -) - -# Set the output variables. -if (SEEXPREDITOR_FOUND) - set (SEEXPREDITOR_INCLUDE_DIRS ${SEEXPR_INCLUDE_DIR}) - set (SEEXPREDITOR_LIBRARIES ${SEEXPREDITOR_LIBRARY}) -else () - set (SEEXPREDITOR_INCLUDE_DIRS) - set (SEEXPREDITOR_LIBRARIES) -endif () - -mark_as_advanced ( - SEEXPREDITOR_INCLUDE_DIR - SEEXPREDITOR_LIBRARY -) diff --git a/src/appleseed.bench/help/about/aboutwindow.cpp b/src/appleseed.bench/help/about/aboutwindow.cpp index 6e7db371fd..977afb001f 100644 --- a/src/appleseed.bench/help/about/aboutwindow.cpp +++ b/src/appleseed.bench/help/about/aboutwindow.cpp @@ -113,13 +113,6 @@ namespace void AboutWindow::set_library_features() { - const bool WithDisneyMaterial = -#ifdef APPLESEED_WITH_DISNEY_MATERIAL - true; -#else - false; -#endif - const bool WithEmbree = #ifdef APPLESEED_WITH_EMBREE true; @@ -144,7 +137,6 @@ void AboutWindow::set_library_features() QString details; details += "This build of appleseed has the following features:\n\n"; details += QString(" Instruction sets: %1\n").arg(Appleseed::get_lib_cpu_features()); - details += QString(" Disney material with SeExpr support: %1\n").arg(to_enabled_disabled(WithDisneyMaterial)); details += QString(" Embree: %1\n").arg(to_enabled_disabled(WithEmbree)); details += QString(" Spectral support: %1\n").arg(to_enabled_disabled(WithSpectralSupport)); details += QString(" GPU support: %1\n").arg(to_enabled_disabled(WithGPUSupport)); diff --git a/src/appleseed.common/application/commandlinehandlerbase.cpp b/src/appleseed.common/application/commandlinehandlerbase.cpp index 71e441f9ea..336b62a11e 100644 --- a/src/appleseed.common/application/commandlinehandlerbase.cpp +++ b/src/appleseed.common/application/commandlinehandlerbase.cpp @@ -109,13 +109,6 @@ struct CommandLineHandlerBase::Impl Compiler::get_compiler_name(), Compiler::get_compiler_version()); - const bool WithDisneyMaterial = -#ifdef APPLESEED_WITH_DISNEY_MATERIAL - true; -#else - false; -#endif - const bool WithEmbree = #ifdef APPLESEED_WITH_EMBREE true; @@ -141,12 +134,10 @@ struct CommandLineHandlerBase::Impl logger, "library features:\n" " Instruction sets %s\n" - " Disney material with SeExpr %s\n" " Embree %s\n" " Spectral support %s\n" " GPU support %s", Appleseed::get_lib_cpu_features(), - to_enabled_disabled(WithDisneyMaterial), to_enabled_disabled(WithEmbree), to_enabled_disabled(WithSpectralSupport), to_enabled_disabled(WithGPUSupport)); diff --git a/src/appleseed.studio/CMakeLists.txt b/src/appleseed.studio/CMakeLists.txt index 17a3304199..3d2953c29e 100644 --- a/src/appleseed.studio/CMakeLists.txt +++ b/src/appleseed.studio/CMakeLists.txt @@ -208,17 +208,6 @@ set (mainwindow_project_sources mainwindow/project/tools.cpp mainwindow/project/tools.h ) -if (WITH_DISNEY_MATERIAL) - list (APPEND mainwindow_project_sources - mainwindow/project/expressioneditorwindow.cpp - mainwindow/project/expressioneditorwindow.h - mainwindow/project/expressioneditorwindow.ui - mainwindow/project/disneymaterialcustomui.cpp - mainwindow/project/disneymaterialcustomui.h - mainwindow/project/disneymateriallayerui.cpp - mainwindow/project/disneymateriallayerui.h - ) -endif () list (APPEND appleseed.studio_sources ${mainwindow_project_sources} ) @@ -506,10 +495,6 @@ target_link_libraries (appleseed.studio ${PYTHON_LIBRARIES} ) -if (WITH_DISNEY_MATERIAL) - link_against_seexpreditor (appleseed.studio) -endif () - #-------------------------------------------------------------------------------------------------- # Post-build commands. @@ -550,10 +535,6 @@ install (DIRECTORY ../../sandbox/ocio DESTINATION . ) -install (DIRECTORY ../../sandbox/seexpr - DESTINATION . -) - install (DIRECTORY ../../sandbox/studio DESTINATION . ) diff --git a/src/appleseed.studio/help/about/aboutwindow.cpp b/src/appleseed.studio/help/about/aboutwindow.cpp index 21d3b26d5d..5b0962a289 100644 --- a/src/appleseed.studio/help/about/aboutwindow.cpp +++ b/src/appleseed.studio/help/about/aboutwindow.cpp @@ -112,13 +112,6 @@ namespace void AboutWindow::set_library_features() { - const bool WithDisneyMaterial = -#ifdef APPLESEED_WITH_DISNEY_MATERIAL - true; -#else - false; -#endif - const bool WithEmbree = #ifdef APPLESEED_WITH_EMBREE true; @@ -143,7 +136,6 @@ void AboutWindow::set_library_features() QString details; details += "This build of appleseed has the following features:\n\n"; details += QString(" Instruction sets: %1\n").arg(Appleseed::get_lib_cpu_features()); - details += QString(" Disney material with SeExpr support: %1\n").arg(to_enabled_disabled(WithDisneyMaterial)); details += QString(" Embree: %1\n").arg(to_enabled_disabled(WithEmbree)); details += QString(" Spectral support: %1\n").arg(to_enabled_disabled(WithSpectralSupport)); details += QString(" GPU support: %1\n").arg(to_enabled_disabled(WithGPUSupport)); diff --git a/src/appleseed.studio/mainwindow/project/assemblyitem.cpp b/src/appleseed.studio/mainwindow/project/assemblyitem.cpp index cf3af97fa7..3741420500 100644 --- a/src/appleseed.studio/mainwindow/project/assemblyitem.cpp +++ b/src/appleseed.studio/mainwindow/project/assemblyitem.cpp @@ -185,7 +185,6 @@ QMenu* AssemblyItem::get_single_item_context_menu() const menu->addAction("Create Volume...", m_volume_collection_item, SLOT(slot_create())); QMenu* submenu = menu->addMenu("Create Material..."); - submenu->addAction("Create Disney Material...", m_material_collection_item, SLOT(slot_create_disney())); submenu->addAction("Create Generic Material...", m_material_collection_item, SLOT(slot_create_generic())); menu->addAction("Create Surface Shader...", m_surface_shader_collection_item, SLOT(slot_create())); diff --git a/src/appleseed.studio/mainwindow/project/disneymaterialcustomui.cpp b/src/appleseed.studio/mainwindow/project/disneymaterialcustomui.cpp deleted file mode 100644 index f4977bb75f..0000000000 --- a/src/appleseed.studio/mainwindow/project/disneymaterialcustomui.cpp +++ /dev/null @@ -1,253 +0,0 @@ - -// -// This source file is part of appleseed. -// Visit https://appleseedhq.net/ for additional information and resources. -// -// This software is released under the MIT license. -// -// Copyright (c) 2014-2018 Marius Avram, The appleseedhq Organization -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// - -// Interface header. -#include "disneymaterialcustomui.h" - -// appleseed.studio headers. -#include "mainwindow/project/disneymateriallayerui.h" - -// appleseed.renderer headers. -#include "renderer/api/material.h" - -// appleseed.foundation headers. -#include "foundation/containers/dictionary.h" -#include "foundation/utility/api/specializedapiarrays.h" - -// Qt headers. -#include -#include - -// Standard headers. -#include -#include - -using namespace foundation; -using namespace renderer; - -namespace appleseed { -namespace studio { - -// -// DisneyMaterialCustomUI class implementation. -// - -namespace -{ - int get_layer_number(const Dictionary& values) - { - return - values.strings().exist("layer_number") - ? values.get("layer_number") - : 0; - } - - struct LayerDefinitionOrderPredicate - { - bool operator()(const Dictionary& lhs, const Dictionary& rhs) const - { - return get_layer_number(lhs) < get_layer_number(rhs); - } - }; - - std::vector collect_layer_definitions(const Dictionary& values) - { - std::vector layer_definitions; - - for (const_each i = values.dictionaries(); i; ++i) - layer_definitions.push_back(i->value()); - - std::sort( - layer_definitions.begin(), - layer_definitions.end(), - LayerDefinitionOrderPredicate()); - - return layer_definitions; - } -} - -DisneyMaterialCustomUI::DisneyMaterialCustomUI( - const Project& project, - ParamArray& settings) - : m_project(project) - , m_settings(settings) - , m_parent(nullptr) - , m_layout(nullptr) -{ -} - -void DisneyMaterialCustomUI::create_widgets( - QVBoxLayout* layout, - const Dictionary& values) -{ - m_parent = layout->parentWidget(); - m_layout = layout; - - // Add New Layer button. - m_add_layer_button = new QPushButton("Add New Layer"); - m_layout->addWidget(m_add_layer_button); - connect(m_add_layer_button, SIGNAL(clicked()), this, SLOT(slot_add_layer())); - - // Stretcher at the bottom. - m_layout->addStretch(1); - - const std::vector layer_definitions = collect_layer_definitions(values); - - if (layer_definitions.empty()) - { - // Insert the initial layer. - append_new_layer(make_new_layer_values()); - } - else - { - for (const_each> i = layer_definitions; i; ++i) - append_new_layer(*i); - } -} - -Dictionary DisneyMaterialCustomUI::get_values() const -{ - Dictionary values; - - for (size_t i = 0; i < m_layers.size(); ++i) - { - Dictionary layer_values = m_layers[i]->get_values(); - - values.insert( - layer_values.get("layer_name").c_str(), - layer_values.insert("layer_number", i)); - } - - return values; -} - -void DisneyMaterialCustomUI::slot_add_layer() -{ - append_new_layer(make_new_layer_values()); - - emit signal_apply(); -} - -void DisneyMaterialCustomUI::slot_move_layer_up(QWidget* layer_widget) -{ - const size_t layer_index = find_layer_index_by_widget(layer_widget); - - if (layer_index > 0) - { - std::swap(m_layers[layer_index], m_layers[layer_index - 1]); - - const int layer_widget_index = m_layout->indexOf(layer_widget); - m_layout->takeAt(layer_widget_index); - m_layout->insertWidget(layer_widget_index - 1, layer_widget); - } - - emit signal_apply(); -} - -void DisneyMaterialCustomUI::slot_move_layer_down(QWidget* layer_widget) -{ - const size_t layer_index = find_layer_index_by_widget(layer_widget); - - if (layer_index < m_layers.size() - 1) - { - std::swap(m_layers[layer_index], m_layers[layer_index + 1]); - - const int layer_widget_index = m_layout->indexOf(layer_widget); - m_layout->takeAt(layer_widget_index); - m_layout->insertWidget(layer_widget_index + 1, layer_widget); - } - - emit signal_apply(); -} - -void DisneyMaterialCustomUI::slot_delete_layer(QWidget* layer_widget) -{ - const size_t layer_index = find_layer_index_by_widget(layer_widget); - - m_layers.erase(m_layers.begin() + layer_index); - - m_layout->removeWidget(layer_widget); - layer_widget->deleteLater(); - - emit signal_apply(); -} - -size_t DisneyMaterialCustomUI::find_layer_index_by_widget(const QWidget* layer_widget) const -{ - for (size_t i = 0; i < m_layers.size(); ++i) - { - if (m_layers[i] == layer_widget) - return i; - } - - assert(!"Could not find layer widget."); - return ~size_t(0); -} - -std::vector DisneyMaterialCustomUI::collect_layer_names() const -{ - std::vector names; - - for (size_t i = 0; i < m_layers.size(); ++i) - names.push_back(m_layers[i]->get_values().get("layer_name")); - - return names; -} - -Dictionary DisneyMaterialCustomUI::make_new_layer_values() -{ - return - DisneyMaterialLayer::get_default_values() - .insert("layer_name", make_unique_name("layer", collect_layer_names())); -} - -void DisneyMaterialCustomUI::append_new_layer(const Dictionary& values) -{ - DisneyMaterialLayerUI* layer_widget = - new DisneyMaterialLayerUI(m_parent, m_project, m_settings, values); - - connect( - layer_widget, SIGNAL(signal_move_layer_up(QWidget*)), - this, SLOT(slot_move_layer_up(QWidget*))); - connect( - layer_widget, SIGNAL(signal_move_layer_down(QWidget*)), - this, SLOT(slot_move_layer_down(QWidget*))); - connect( - layer_widget, SIGNAL(signal_delete_layer(QWidget*)), - this, SLOT(slot_delete_layer(QWidget*))); - connect( - layer_widget, SIGNAL(signal_apply()), - this, SIGNAL(signal_apply())); - - m_layers.push_back(layer_widget); - - m_layout->insertWidget(m_layout->count() - 2, layer_widget); -} - -} // namespace studio -} // namespace appleseed diff --git a/src/appleseed.studio/mainwindow/project/disneymaterialcustomui.h b/src/appleseed.studio/mainwindow/project/disneymaterialcustomui.h deleted file mode 100644 index 72d7044291..0000000000 --- a/src/appleseed.studio/mainwindow/project/disneymaterialcustomui.h +++ /dev/null @@ -1,95 +0,0 @@ - -// -// This source file is part of appleseed. -// Visit https://appleseedhq.net/ for additional information and resources. -// -// This software is released under the MIT license. -// -// Copyright (c) 2014-2018 Marius Avram, The appleseedhq Organization -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// - -#pragma once - -// appleseed.studio headers. -#include "mainwindow/project/customentityui.h" - -// appleseed.foundation headers. -#include "foundation/platform/compiler.h" - -// Standard headers. -#include -#include -#include - -// Qt headers. -#include - -// Forward declarations. -namespace appleseed { namespace studio { class DisneyMaterialLayerUI; } } -namespace foundation { class Dictionary; } -namespace renderer { class ParamArray; } -namespace renderer { class Project; } -class QPushButton; -class QVBoxLayout; -class QWidget; - -namespace appleseed { -namespace studio { - -class DisneyMaterialCustomUI - : public CustomEntityUI -{ - Q_OBJECT - - public: - DisneyMaterialCustomUI( - const renderer::Project& project, - renderer::ParamArray& settings); - - void create_widgets( - QVBoxLayout* layout, - const foundation::Dictionary& values) override; - - foundation::Dictionary get_values() const override; - - private slots: - void slot_add_layer(); - void slot_move_layer_up(QWidget* layer_widget); - void slot_move_layer_down(QWidget* layer_widget); - void slot_delete_layer(QWidget* layer_widget); - - private: - const renderer::Project& m_project; - renderer::ParamArray& m_settings; - QWidget* m_parent; - QVBoxLayout* m_layout; - - std::vector m_layers; - QPushButton* m_add_layer_button; - - size_t find_layer_index_by_widget(const QWidget* layer_widget) const; - std::vector collect_layer_names() const; - foundation::Dictionary make_new_layer_values(); - void append_new_layer(const foundation::Dictionary& layer_values); -}; - -} // namespace studio -} // namespace appleseed diff --git a/src/appleseed.studio/mainwindow/project/disneymateriallayerui.cpp b/src/appleseed.studio/mainwindow/project/disneymateriallayerui.cpp deleted file mode 100644 index 823c9c69b1..0000000000 --- a/src/appleseed.studio/mainwindow/project/disneymateriallayerui.cpp +++ /dev/null @@ -1,566 +0,0 @@ - -// -// This source file is part of appleseed. -// Visit https://appleseedhq.net/ for additional information and resources. -// -// This software is released under the MIT license. -// -// Copyright (c) 2014-2018 Marius Avram, The appleseedhq Organization -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// - -// Interface header. -#include "disneymateriallayerui.h" - -// appleseed.studio headers. -#include "mainwindow/project/expressioneditorwindow.h" -#include "mainwindow/project/tools.h" -#include "utility/settingskeys.h" - -// appleseed.qtcommon headers. -#include "utility/interop.h" -#include "utility/miscellaneous.h" -#include "widgets/doubleslider.h" -#include "widgets/mousewheelfocuseventfilter.h" - -// appleseed.renderer headers. -#include "renderer/api/material.h" -#include "renderer/api/project.h" - -// appleseed.foundation headers. -#include "foundation/containers/dictionary.h" -#include "foundation/utility/searchpaths.h" - -// Qt headers. -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// Boost headers. -#include "boost/filesystem/operations.hpp" -#include "boost/filesystem/path.hpp" - -// Standard headers. -#include -#include -#include - -using namespace appleseed::qtcommon; -using namespace boost; -using namespace foundation; -using namespace renderer; - -namespace appleseed { -namespace studio { - -DisneyMaterialLayerUI::DisneyMaterialLayerUI( - QWidget* parent, - const Project& project, - ParamArray& settings, - const Dictionary& values) - : QFrame(parent) - , m_project(project) - , m_settings(settings) - , m_input_metadata(DisneyMaterialLayer::get_input_metadata()) - , m_fold_icon(":/widgets/layer_fold.png") - , m_unfold_icon(":/widgets/layer_unfold.png") - , m_is_folded(values.strings().exist("layer_folded") && values.get("layer_folded")) -{ - setProperty("hasFrame", true); - - create_layer_ui(); - create_input_widgets(values); - - if (m_is_folded) - fold(); -} - -void DisneyMaterialLayerUI::create_layer_ui() -{ - // Top-level layout of the layer - QVBoxLayout* layout = new QVBoxLayout(this); - - // Container widget for the layer buttons. - QWidget* button_box = new QWidget(this); - QHBoxLayout* button_box_layout = new QHBoxLayout(button_box); - button_box_layout->setSpacing(0); - button_box_layout->setMargin(0); - layout->addWidget(button_box); - - // Fold button. - m_fold_unfold_button = new QToolButton(button_box); - m_fold_unfold_button->setObjectName("widget"); - m_fold_unfold_button->setIcon(m_fold_icon); - button_box_layout->addWidget(m_fold_unfold_button); - connect(m_fold_unfold_button, SIGNAL(clicked()), this, SLOT(slot_fold_unfold_layer())); - - // Layer header (only visible when the layer is folded). - m_header_widget = new QWidget(button_box); - m_header_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - m_header_layout = new QFormLayout(m_header_widget); - m_header_layout->setSpacing(7); - button_box_layout->addWidget(m_header_widget); - - // Move Up button. - QToolButton* up_button = new QToolButton(button_box); - up_button->setObjectName("widget"); - up_button->setIcon(QIcon(":widgets/layer_move_up.png")); - button_box_layout->addWidget(up_button); - connect(up_button, SIGNAL(clicked()), this, SLOT(slot_move_layer_up())); - - // Move Down button. - QToolButton* down_button = new QToolButton(button_box); - down_button->setObjectName("widget"); - down_button->setIcon(QIcon(":widgets/layer_move_down.png")); - button_box_layout->addWidget(down_button); - connect(down_button, SIGNAL(clicked()), this, SLOT(slot_move_layer_down())); - - // Remove button. - QToolButton* remove_button = new QToolButton(button_box); - remove_button->setObjectName("widget"); - remove_button->setIcon(QIcon(":/widgets/layer_remove.png")); - button_box_layout->addWidget(remove_button); - connect(remove_button, SIGNAL(clicked()), this, SLOT(slot_delete_layer())); - - // Container widget for the layer contents. - m_content_widget = new QWidget(this); - m_content_layout = new QFormLayout(m_content_widget); - m_content_layout->setLabelAlignment(Qt::AlignRight); - m_content_layout->setSpacing(10); - m_content_layout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow); - layout->addWidget(m_content_widget); -} - -void DisneyMaterialLayerUI::create_input_widgets(const Dictionary& values) -{ - for (size_t i = 0, e = m_input_metadata.size(); i < e; ++i) - { - Dictionary im = m_input_metadata[i]; - const std::string input_name = im.get("name"); - const std::string input_type = im.get("type"); - - im.insert("value", - values.strings().exist(input_name.c_str()) ? values.get(input_name.c_str()) : - im.strings().exist("default") ? im.get("default") : - ""); - - std::unique_ptr widget_proxy = - input_type == "colormap" ? - im.dictionaries().exist("entity_types") && - im.dictionaries().get("entity_types").strings().exist("color") - ? create_color_input_widgets(im) - : create_colormap_input_widgets(im) : - input_type == "text" ? create_text_input_widgets(im) : - std::unique_ptr(nullptr); - - assert(widget_proxy.get()); - connect(widget_proxy.get(), SIGNAL(signal_changed()), SIGNAL(signal_apply())); - - m_widget_proxies.insert(input_name, std::move(widget_proxy)); - } -} - -Dictionary DisneyMaterialLayerUI::get_values() const -{ - return - m_widget_proxies - .get_values() - .insert("layer_folded", m_is_folded); -} - -void DisneyMaterialLayerUI::mouseDoubleClickEvent(QMouseEvent* event) -{ - slot_fold_unfold_layer(); -} - -void DisneyMaterialLayerUI::slot_fold_unfold_layer() -{ - m_is_folded = !m_is_folded; - m_is_folded ? fold() : unfold(); -} - -void DisneyMaterialLayerUI::slot_move_layer_up() -{ - emit signal_move_layer_up(this); -} - -void DisneyMaterialLayerUI::slot_move_layer_down() -{ - emit signal_move_layer_down(this); -} - -void DisneyMaterialLayerUI::slot_delete_layer() -{ - emit signal_delete_layer(this); -} - -void DisneyMaterialLayerUI::slot_open_color_picker(const QString& widget_name) -{ - IInputWidgetProxy* widget_proxy = m_widget_proxies.get(widget_name.toStdString()); - - const std::string color_expression = widget_proxy->get(); - const QColor initial_color = ColorExpressionProxy::expression_to_qcolor(widget_proxy->get()); - - QColorDialog* dialog = new QColorDialog(initial_color, m_content_widget); - dialog->setWindowTitle("Pick Color"); - dialog->setOptions(QColorDialog::DontUseNativeDialog); - - ForwardColorChangedSignal* forward_signal = - new ForwardColorChangedSignal(dialog, widget_name, initial_color); - connect( - dialog, SIGNAL(currentColorChanged(const QColor&)), - forward_signal, SLOT(slot_color_changed(const QColor&))); - connect( - forward_signal, SIGNAL(signal_color_changed(const QString&, const QColor&)), - SLOT(slot_color_changed(const QString&, const QColor&))); - connect( - dialog, SIGNAL(rejected()), - forward_signal, SLOT(slot_color_reset())); - connect( - forward_signal, SIGNAL(signal_color_reset(const QString&, const QColor&)), - SLOT(slot_color_changed(const QString&, const QColor&))); - - dialog->exec(); -} - -void DisneyMaterialLayerUI::slot_color_changed(const QString& widget_name, const QColor& color) -{ - IInputWidgetProxy* widget_proxy = m_widget_proxies.get(widget_name.toStdString()); - widget_proxy->set(ColorExpressionProxy::qcolor_to_expression(color)); - widget_proxy->emit_signal_changed(); -} - -namespace -{ - bool find_path_in_dir( - const QString& filename, - const QDir& dir, - QString& result) - { - result = dir.relativeFilePath(filename); - - // Ignore paths that go up the directory hierarchy. - if (result.startsWith("..")) - return false; - - const QFileInfo relative_file_info(result); - if (relative_file_info.isRelative()) - return true; - - return false; - } - - QString find_path_in_search_paths(const SearchPaths& s, const QString& filename) - { - const QFileInfo file_info(filename); - assert(file_info.isAbsolute()); - - for (size_t i = 0; i < s.get_explicit_path_count(); ++i) - { - // Iterate in reverse order, to match search paths priorities. - QString search_path(QString::fromStdString( - s.get_explicit_path(s.get_explicit_path_count() - 1 - i))); - const QFileInfo search_path_info(search_path); - - if (search_path_info.isRelative()) - { - assert(s.has_root_path()); - - search_path = - QDir::cleanPath( - QString(s.get_root_path().c_str()) + - QDir::separator() + - search_path); - } - - const QDir search_dir(search_path); - QString relative_path; - - if (find_path_in_dir(filename, search_dir, relative_path)) - return relative_path; - } - - if (s.has_root_path()) - { - const QDir root_dir(s.get_root_path().c_str()); - assert(root_dir.isAbsolute()); - - QString relative_path; - - if (find_path_in_dir(filename, root_dir, relative_path)) - return relative_path; - } - - return filename; - } - - std::string texture_to_expression(const SearchPaths& search_paths, const QString& path) - { - const QString relative_path = find_path_in_search_paths(search_paths, path); - const QString texture_expression = QString("texture(\"%1\", $u, $v)").arg(relative_path); - return texture_expression.toStdString(); - } -} - -void DisneyMaterialLayerUI::slot_open_file_picker(const QString& widget_name) -{ - QString filepath = - get_open_filename( - m_content_widget, - "Pick Texture File...", - get_oiio_image_files_filter(), - m_settings, - SETTINGS_FILE_DIALOG_OIIO_TEXTURES); - - if (!filepath.isEmpty()) - { - IInputWidgetProxy* widget_proxy = m_widget_proxies.get(widget_name.toStdString()); - widget_proxy->set( - texture_to_expression( - m_project.search_paths(), - filepath)); - widget_proxy->emit_signal_changed(); - } -} - -void DisneyMaterialLayerUI::slot_open_expression_editor(const QString& widget_name) -{ - IInputWidgetProxy* widget_proxy = m_widget_proxies.get(widget_name.toStdString()); - - ExpressionEditorWindow* expression_editor_window = - new ExpressionEditorWindow( - m_project, - m_settings, - widget_name, - widget_proxy->get(), - m_content_widget); - - connect( - expression_editor_window, - SIGNAL(signal_expression_applied(const QString&, const QString&)), - SLOT(slot_expression_changed(const QString&, const QString&))); - - expression_editor_window->show(); - expression_editor_window->activateWindow(); -} - -void DisneyMaterialLayerUI::slot_expression_changed( - const QString& widget_name, - const QString& expression) -{ - IInputWidgetProxy* widget_proxy = m_widget_proxies.get(widget_name.toStdString()); - widget_proxy->set(expression.toStdString()); - widget_proxy->emit_signal_changed(); -} - -namespace -{ - QLabel* create_label(const Dictionary& metadata) - { - QLabel* label = new QLabel(metadata.get("label") + ":"); - - if (metadata.get("use") == "required") - { - QFont font; - font.setBold(true); - label->setFont(font); - } - - return label; - } - - bool should_be_focused(const Dictionary& metadata) - { - return - metadata.strings().exist("focus") && - metadata.strings().get("focus"); - } -} - -std::unique_ptr DisneyMaterialLayerUI::create_text_input_widgets(const Dictionary& metadata) -{ - QLineEdit* line_edit = new QLineEdit(m_content_widget); - - if (should_be_focused(metadata)) - { - line_edit->selectAll(); - line_edit->setFocus(); - } - - m_content_layout->addRow(create_label(metadata), line_edit); - - std::unique_ptr widget_proxy(new LineEditProxy(line_edit)); - widget_proxy->set(metadata.strings().get("value")); - - return widget_proxy; -} - -std::unique_ptr DisneyMaterialLayerUI::create_color_input_widgets(const Dictionary& metadata) -{ - QLineEdit* line_edit = new QLineEdit(m_content_widget); - - QToolButton* picker_button = new QToolButton(m_content_widget); - picker_button->setObjectName("color_picker"); - const std::string name = metadata.get("name"); - connect(picker_button, &QToolButton::clicked, [=]() { emit slot_open_color_picker(QString::fromStdString(name)); }); - - if (should_be_focused(metadata)) - { - line_edit->selectAll(); - line_edit->setFocus(); - } - - QHBoxLayout* layout = new QHBoxLayout(); - layout->setSpacing(6); - layout->addWidget(line_edit); - layout->addWidget(picker_button); - layout->addWidget(create_texture_button(name)); - layout->addWidget(create_expression_button(name)); - m_content_layout->addRow(create_label(metadata), layout); - - std::unique_ptr widget_proxy(new ColorExpressionProxy(line_edit, picker_button)); - widget_proxy->set(metadata.strings().get("value")); - - return widget_proxy; -} - -std::unique_ptr DisneyMaterialLayerUI::create_colormap_input_widgets(const Dictionary& metadata) -{ - QLineEdit* line_edit = new QLineEdit(m_content_widget); - line_edit->setMaximumWidth(120); - - DoubleSlider* slider = new DoubleSlider(Qt::Horizontal, m_content_widget); - slider->setRange(0.0, 1.0); - slider->setPageStep(0.1); - new MouseWheelFocusEventFilter(slider); - new LineEditDoubleSliderAdaptor(line_edit, slider); - connect(slider, SIGNAL(valueChanged(int)), SIGNAL(signal_apply())); - - if (should_be_focused(metadata)) - { - line_edit->selectAll(); - line_edit->setFocus(); - } - - const std::string name = metadata.get("name"); - - QHBoxLayout* layout = new QHBoxLayout(); - layout->setSpacing(6); - layout->addWidget(line_edit); - layout->addWidget(slider); - layout->addWidget(create_texture_button(name)); - layout->addWidget(create_expression_button(name)); - m_content_layout->addRow(create_label(metadata), layout); - - std::unique_ptr widget_proxy(new LineEditProxy(line_edit)); - widget_proxy->set(metadata.strings().get("value")); - - return widget_proxy; -} - -QWidget* DisneyMaterialLayerUI::create_texture_button(const std::string& name) -{ - QToolButton* texture_button = new QToolButton(m_content_widget); - texture_button->setIcon(load_icons("disney_texture")); - texture_button->setAutoRaise(true); // enable hover state - texture_button->setToolTip("Bind Texture..."); - - connect(texture_button, &QToolButton::clicked, [=]() { emit slot_open_file_picker(QString::fromStdString(name)); }); - - return texture_button; -} - -QWidget* DisneyMaterialLayerUI::create_expression_button(const std::string& name) -{ - QToolButton* expression_button = new QToolButton(m_content_widget); - expression_button->setIcon(load_icons("disney_expression")); - expression_button->setAutoRaise(true); // enable hover state - expression_button->setToolTip("Bind Expression..."); - - connect(expression_button, &QToolButton::clicked, [=]() { emit slot_open_expression_editor(QString::fromStdString(name)); }); - - return expression_button; -} - -namespace -{ - QString get_layer_name_label(const DictionaryArray& input_metadata) - { - for (size_t i = 0; i < input_metadata.size(); ++i) - { - if (input_metadata[i].get("name") == "layer_name") - return input_metadata[i].get("label") + ":"; - } - - assert(!"Could not find layer name input metadata."); - return QString(); - } -} - -void DisneyMaterialLayerUI::fold() -{ - // Hide the layer's content. - m_content_widget->setVisible(false); - - // Use dynamic_cast<> solely to allow checking that we indeed have a LineEditProxy. - LineEditProxy* layer_name_proxy = - dynamic_cast(m_widget_proxies.get("layer_name")); - assert(layer_name_proxy); - - // Show the layer's name in the header. - QLineEdit* name_line_edit = new QLineEdit(m_header_widget); - name_line_edit->setText( - QString::fromStdString(layer_name_proxy->get())); - connect( - name_line_edit, SIGNAL(textChanged(const QString&)), - layer_name_proxy, SLOT(slot_set(const QString))); - m_header_layout->addRow( - get_layer_name_label(m_input_metadata), - name_line_edit); - - // Update the icon of the fold/unfold button. - m_fold_unfold_button->setIcon(m_unfold_icon); -} - -void DisneyMaterialLayerUI::unfold() -{ - // Show the layer's content. - m_content_widget->setVisible(true); - - // Hide the layer's name in the header. - clear_layout(m_header_widget->layout()); - - // Update the icon of the fold/unfold button. - m_fold_unfold_button->setIcon(m_fold_icon); -} - -} // namespace studio -} // namespace appleseed diff --git a/src/appleseed.studio/mainwindow/project/disneymateriallayerui.h b/src/appleseed.studio/mainwindow/project/disneymateriallayerui.h deleted file mode 100644 index bb7b3fc33c..0000000000 --- a/src/appleseed.studio/mainwindow/project/disneymateriallayerui.h +++ /dev/null @@ -1,130 +0,0 @@ - -// -// This source file is part of appleseed. -// Visit https://appleseedhq.net/ for additional information and resources. -// -// This software is released under the MIT license. -// -// Copyright (c) 2014-2018 Marius Avram, The appleseedhq Organization -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// - -#pragma once - -// appleseed.studio headers. -#include "utility/inputwidgetproxies.h" - -// appleseed.foundation headers. -#include "foundation/platform/compiler.h" -#include "foundation/utility/api/specializedapiarrays.h" - -// Qt headers. -#include -#include -#include - -// Standard headers. -#include -#include - -// Forward declarations. -namespace foundation { class Dictionary; } -namespace renderer { class ParamArray; } -namespace renderer { class Project; } -class QColor; -class QFormLayout; -class QMouseEvent; -class QString; -class QToolButton; -class QWidget; - -namespace appleseed { -namespace studio { - -class DisneyMaterialLayerUI - : public QFrame -{ - Q_OBJECT - - public: - DisneyMaterialLayerUI( - QWidget* parent, - const renderer::Project& project, - renderer::ParamArray& settings, - const foundation::Dictionary& values); - - foundation::Dictionary get_values() const; - - void mouseDoubleClickEvent(QMouseEvent* event) override; - - signals: - void signal_move_layer_up(QWidget* layer_widget); - void signal_move_layer_down(QWidget* layer_widget); - void signal_delete_layer(QWidget* layer_widget); - void signal_apply(); - - private slots: - void slot_fold_unfold_layer(); - void slot_move_layer_up(); - void slot_move_layer_down(); - void slot_delete_layer(); - - void slot_open_color_picker(const QString& widget_name); - void slot_color_changed(const QString& widget_name, const QColor& color); - - void slot_open_file_picker(const QString& widget_name); - - void slot_open_expression_editor(const QString& widget_name); - void slot_expression_changed(const QString& widget_name, const QString& expression); - - private: - const renderer::Project& m_project; - renderer::ParamArray& m_settings; - const foundation::DictionaryArray m_input_metadata; - - const QIcon m_fold_icon; - const QIcon m_unfold_icon; - - QToolButton* m_fold_unfold_button; - QWidget* m_header_widget; - QFormLayout* m_header_layout; - QWidget* m_content_widget; - QFormLayout* m_content_layout; - - InputWidgetProxyCollection m_widget_proxies; - - bool m_is_folded; - - void create_layer_ui(); - void create_input_widgets(const foundation::Dictionary& values); - - std::unique_ptr create_text_input_widgets(const foundation::Dictionary& metadata); - std::unique_ptr create_color_input_widgets(const foundation::Dictionary& metadata); - std::unique_ptr create_colormap_input_widgets(const foundation::Dictionary& metadata); - - QWidget* create_texture_button(const std::string& name); - QWidget* create_expression_button(const std::string& name); - - void fold(); - void unfold(); -}; - -} // namespace studio -} // namespace appleseed diff --git a/src/appleseed.studio/mainwindow/project/expressioneditorwindow.cpp b/src/appleseed.studio/mainwindow/project/expressioneditorwindow.cpp deleted file mode 100644 index 01fcdda5a4..0000000000 --- a/src/appleseed.studio/mainwindow/project/expressioneditorwindow.cpp +++ /dev/null @@ -1,354 +0,0 @@ - -// -// This source file is part of appleseed. -// Visit https://appleseedhq.net/ for additional information and resources. -// -// This software is released under the MIT license. -// -// Copyright (c) 2014-2018 Marius Avram, The appleseedhq Organization -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// - -// Interface header. -#include "expressioneditorwindow.h" - -// UI definition headers. -#include "ui_expressioneditorwindow.h" - -// appleseed.studio headers. -#include "mainwindow/project/tools.h" -#include "utility/settingskeys.h" - -// appleseed.qtcommon headers. -#include "utility/miscellaneous.h" - -// appleseed.common headers. -#include "application/application.h" - -// appleseed.renderer headers. -#include "renderer/api/log.h" -#include "renderer/api/material.h" -#include "renderer/api/project.h" -#include "renderer/api/utility.h" - -// SeExpr headers. -#pragma warning (push) -#pragma warning (disable : 4267) // conversion from 'size_t' to 'int', possible loss of data -#include "SeExpression.h" -#include "SeExprEditor/SeExprEditor.h" -#include "SeExprEditor/SeExprEdBrowser.h" -#include "SeExprEditor/SeExprEdControlCollection.h" -#pragma warning (pop) - -// Qt headers. -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// Boost headers. -#include "boost/filesystem/operations.hpp" -#include "boost/filesystem/path.hpp" - -// Standard headers. -#include -#include -#include - -using namespace appleseed::common; -using namespace appleseed::qtcommon; -using namespace foundation; -using namespace renderer; -namespace bf = boost::filesystem; - -namespace appleseed { -namespace studio { - -ExpressionEditorWindow::ExpressionEditorWindow( - const Project& project, - ParamArray& settings, - const QString& widget_name, - const std::string& expression, - QWidget* parent) - : WindowBase(parent, "expression_editor_window") - , m_ui(new Ui::ExpressionEditorWindow()) - , m_project(project) - , m_settings(settings) - , m_widget_name(widget_name) - , m_show_examples(false) -{ - m_ui->setupUi(this); - - setAttribute(Qt::WA_DeleteOnClose); - setWindowFlags(Qt::Tool); - - QHBoxLayout* root_layout = new QHBoxLayout(m_ui->scrollarea); - - QVBoxLayout* left_layout = new QVBoxLayout(); - QVBoxLayout* right_layout = new QVBoxLayout(); - root_layout->addLayout(left_layout); - root_layout->addLayout(right_layout); - - // Expression controls. - SeExprEdControlCollection* controls = new SeExprEdControlCollection(); - QScrollArea* controls_scrollarea = new QScrollArea(this); - controls_scrollarea->setObjectName("expression_controls"); - controls_scrollarea->setMinimumHeight(200); - controls_scrollarea->setWidgetResizable(true); - controls_scrollarea->setWidget(controls); - left_layout->addWidget(controls_scrollarea); - - // Clear button. - QShortcut* clear_shortcut = new QShortcut(QKeySequence("Ctrl+N"), this); - connect(clear_shortcut, SIGNAL(activated()), SLOT(slot_clear_expression())); - QPushButton* clear_button = new QPushButton("Clear"); - clear_button->setToolTip(clear_shortcut->key().toString(QKeySequence::NativeText)); - connect(clear_button, SIGNAL(clicked()), SLOT(slot_clear_expression())); - - // Save button. - QShortcut* save_shortcut = new QShortcut(QKeySequence("Ctrl+S"), this); - connect(save_shortcut, SIGNAL(activated()), SLOT(slot_save_script())); - QPushButton* save_button = new QPushButton("Save"); - save_button->setToolTip(save_shortcut->key().toString(QKeySequence::NativeText)); - connect(save_button, SIGNAL(clicked()), SLOT(slot_save_script())); - - // Load button. - QShortcut* load_shortcut = new QShortcut(QKeySequence("Ctrl+O"), this); - connect(load_shortcut, SIGNAL(activated()), SLOT(slot_load_script())); - QPushButton* load_button = new QPushButton("Load"); - load_button->setToolTip(load_shortcut->key().toString(QKeySequence::NativeText)); - connect(load_button, SIGNAL(clicked()), SLOT(slot_load_script())); - - // Help button. - QPushButton* help_button = new QPushButton("Help"); - connect(help_button, SIGNAL(clicked()), SLOT(slot_show_help())); - - // Examples button. - QPushButton* examples_button = new QPushButton("Examples"); - connect(examples_button, SIGNAL(clicked()), SLOT(slot_show_examples())); - - QHBoxLayout* file_buttonbox = new QHBoxLayout(); - file_buttonbox->addWidget(clear_button); - file_buttonbox->addWidget(load_button); - file_buttonbox->addWidget(save_button); - file_buttonbox->addWidget(help_button); - file_buttonbox->addWidget(examples_button); - left_layout->addLayout(file_buttonbox); - - m_editor = new SeExprEditor(this, controls); - QTextEdit* text_edit = m_editor->findChild(""); - text_edit->setObjectName("expression_editor"); - m_editor->setExpr(expression, true); - left_layout->addWidget(m_editor); - - m_error = new QLabel("Expression has errors. Check log for details."); - m_error->setObjectName("error"); - m_error->hide(); - left_layout->addWidget(m_error); - - // Expression browser. - m_browser = new SeExprEdBrowser(nullptr, m_editor); - const bf::path root_path(Application::get_root_path()); - const std::string scripts_path = (root_path / "seexpr").string(); - m_browser->addPath("Examples", scripts_path); - m_browser->update(); - m_browser->hide(); - right_layout->addWidget(m_browser); - - m_ui->buttonbox_layout->addStretch(1); - m_ui->buttonbox_layout->setStretch(0, 1); - m_ui->buttonbox_layout->setStretch(1, 0); - - connect(m_ui->buttonbox, SIGNAL(accepted()), SLOT(slot_accept())); - connect(m_ui->buttonbox, SIGNAL(rejected()), SLOT(slot_cancel())); - - connect( - m_ui->buttonbox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), - SLOT(slot_apply())); - - connect( - create_window_local_shortcut(this, Qt::Key_Escape), SIGNAL(activated()), - SLOT(close())); - - WindowBase::load_settings(); -} - -ExpressionEditorWindow::~ExpressionEditorWindow() -{ - delete m_ui; -} - -void ExpressionEditorWindow::apply_expression() -{ - const std::string expression = m_editor->getExpr(); - const SeExpression expr(expression); - - if (expr.isValid()) - { - m_error->hide(); - RENDERER_LOG_INFO("expression successfully applied."); - emit signal_expression_applied(m_widget_name, QString::fromStdString(expression)); - } - else - { - m_error->show(); - RENDERER_LOG_ERROR("expression error: %s", expr.parseError().c_str()); - } -} - -void ExpressionEditorWindow::slot_accept() -{ - apply_expression(); - close(); -} - -void ExpressionEditorWindow::slot_apply() -{ - apply_expression(); -} - -void ExpressionEditorWindow::slot_cancel() -{ - close(); -} - -void ExpressionEditorWindow::slot_clear_expression() -{ - m_editor->setExpr(std::string()); -} - -void ExpressionEditorWindow::slot_save_script() -{ - if (m_script_filepath.empty()) - { - QString filepath = - get_save_filename( - this, - "Save As...", - "Expression Scripts (*.se)", - m_settings, - SETTINGS_FILE_DIALOG_PROJECTS); - - if (!filepath.isEmpty()) - { - if (QFileInfo(filepath).suffix().isEmpty()) - filepath += ".se"; - - m_script_filepath = filepath.toStdString(); - } - } - - if (!m_script_filepath.empty()) - { - std::ofstream script_file(m_script_filepath.c_str()); - - if (!script_file.is_open()) - { - show_error_message_box( - "Saving Error", - "Failed to save the expression script file " + m_script_filepath + "."); - return; - } - - script_file << m_editor->getExpr(); - script_file.close(); - } -} - -void ExpressionEditorWindow::slot_load_script() -{ - QString filepath = - get_open_filename( - this, - "Open...", - "Expression Scripts (*.se);;All Files (*.*)", - m_settings, - SETTINGS_FILE_DIALOG_PROJECTS); - - if (!filepath.isEmpty()) - { - // Open script file. - std::ifstream script_file(filepath.toStdString().c_str()); - if (!script_file.is_open()) - { - show_error_message_box( - "Loading Error", - "Failed to load the expression script file " + filepath.toStdString() + "."); - return; - } - - // Read script file into memory. - std::stringstream script_buffer; - script_buffer << script_file.rdbuf(); - script_file.close(); - - // Set script as expression. - m_editor->setExpr(script_buffer.str()); - apply_expression(); - } -} - -void ExpressionEditorWindow::slot_show_examples() -{ - m_show_examples = !m_show_examples; - - if (m_show_examples) - { - if (width() < 800) - resize(800, height()); - m_ui->buttonbox_layout->setStretch(0, 1); - m_ui->buttonbox_layout->setStretch(1, 1); - m_browser->show(); - } - else - { - if (width() > 400) - resize(std::max(400, width() - 400), height()); - m_ui->buttonbox_layout->setStretch(1, 0); - m_browser->hide(); - } -} - -void ExpressionEditorWindow::slot_show_help() -{ - bf::path docs_path = Application::get_root_path(); - docs_path /= "docs/seexpr/userdoc.html"; - - const QString docs_file = QString::fromStdString(docs_path.string()); - QDesktopServices::openUrl(QUrl::fromLocalFile(docs_file)); -} - -void ExpressionEditorWindow::closeEvent(QCloseEvent* e) -{ - emit signal_editor_closed(); - e->accept(); -} - -} // namespace studio -} // namespace appleseed - -#include "mainwindow/project/moc_cpp_expressioneditorwindow.cxx" diff --git a/src/appleseed.studio/mainwindow/project/expressioneditorwindow.h b/src/appleseed.studio/mainwindow/project/expressioneditorwindow.h deleted file mode 100644 index 827b3828d9..0000000000 --- a/src/appleseed.studio/mainwindow/project/expressioneditorwindow.h +++ /dev/null @@ -1,105 +0,0 @@ - -// -// This source file is part of appleseed. -// Visit https://appleseedhq.net/ for additional information and resources. -// -// This software is released under the MIT license. -// -// Copyright (c) 2014-2018 Marius Avram, The appleseedhq Organization -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// - -#pragma once - -// appleseed.studio headers. -#include "utility/windowbase.h" - -// Qt headers. -#include -#include - -// Standard headers. -#include - -// Forward declarations. -namespace renderer { class ParamArray; } -namespace renderer { class Project; } -namespace Ui { class ExpressionEditorWindow; } -class QLabel; -class QWidget; -class SeExprEdBrowser; -class SeExprEditor; - -namespace appleseed { -namespace studio { - -class ExpressionEditorWindow - : public WindowBase -{ - Q_OBJECT - - public: - // Constructor. - ExpressionEditorWindow( - const renderer::Project& project, - renderer::ParamArray& settings, - const QString& widget_name, - const std::string& expression, - QWidget* parent = nullptr); - - // Destructor. - ~ExpressionEditorWindow() override; - - void apply_expression(); - - public slots: - void slot_accept(); - void slot_apply(); - void slot_cancel(); - - void slot_clear_expression(); - void slot_save_script(); - void slot_load_script(); - void slot_show_examples(); - void slot_show_help(); - - signals: - void signal_expression_applied(const QString& widget_name, const QString& expression); - void signal_editor_closed(); - - protected: - void closeEvent(QCloseEvent* e) override; - - private: - // Not wrapped in std::unique_ptr<> to avoid pulling in the UI definition code. - Ui::ExpressionEditorWindow* m_ui; - - const renderer::Project& m_project; - renderer::ParamArray& m_settings; - const QString m_widget_name; - SeExprEditor* m_editor; - SeExprEdBrowser* m_browser; - QLabel* m_error; - std::string m_script_filepath; - bool m_show_examples; -}; - -} // namespace studio -} // namespace appleseed diff --git a/src/appleseed.studio/mainwindow/project/expressioneditorwindow.ui b/src/appleseed.studio/mainwindow/project/expressioneditorwindow.ui deleted file mode 100644 index 238162e9b4..0000000000 --- a/src/appleseed.studio/mainwindow/project/expressioneditorwindow.ui +++ /dev/null @@ -1,52 +0,0 @@ - - - ExpressionEditorWindow - - - Qt::ApplicationModal - - - - 0 - 0 - 400 - 600 - - - - Expression Editor - - - - - - true - - - - - 0 - 0 - 380 - 545 - - - - - - - - - - - QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - - diff --git a/src/appleseed.studio/mainwindow/project/materialcollectionitem.cpp b/src/appleseed.studio/mainwindow/project/materialcollectionitem.cpp index 9579887465..bf1ac15257 100644 --- a/src/appleseed.studio/mainwindow/project/materialcollectionitem.cpp +++ b/src/appleseed.studio/mainwindow/project/materialcollectionitem.cpp @@ -31,9 +31,6 @@ // appleseed.studio headers. #include "mainwindow/project/assemblyitem.h" -#ifdef APPLESEED_WITH_DISNEY_MATERIAL -#include "mainwindow/project/disneymaterialcustomui.h" -#endif #include "mainwindow/project/entityeditor.h" #include "mainwindow/project/entityeditorcontext.h" #include "mainwindow/project/entityeditorwindow.h" @@ -96,41 +93,13 @@ MaterialCollectionItem::MaterialCollectionItem( add_items(materials); } -#ifdef APPLESEED_WITH_DISNEY_MATERIAL - -const Material& MaterialCollectionItem::create_default_disney_material(const std::string& material_name) -{ - auto_release_ptr material = - DisneyMaterialFactory().create(material_name.c_str(), ParamArray()); - - static_cast(material.get())->add_new_default_layer(); - - Material* material_ptr = material.get(); - add_item(material_ptr); - - EntityTraits::insert_entity(material, m_parent); - m_editor_context.m_project_builder.slot_notify_project_modification(); - - return *material_ptr; -} - -#endif // APPLESEED_WITH_DISNEY_MATERIAL - QMenu* MaterialCollectionItem::get_single_item_context_menu() const { QMenu* menu = ItemBase::get_single_item_context_menu(); menu->clear(); - menu->addSeparator(); menu->addAction("Create Generic Material...", this, SLOT(slot_create_generic())); menu->addAction("Create OSL Material...", this, SLOT(slot_create_osl())); - -#ifdef APPLESEED_WITH_DISNEY_MATERIAL - menu->addSeparator(); - menu->addAction("Create Disney Material...", this, SLOT(slot_create_disney())); - menu->addAction("Import Disney Material...", this, SLOT(slot_import_disney())); -#endif - return menu; } @@ -151,82 +120,6 @@ void MaterialCollectionItem::slot_create_generic() do_create_material("generic_material"); } -void MaterialCollectionItem::slot_create_disney() -{ -#ifdef APPLESEED_WITH_DISNEY_MATERIAL - do_create_material("disney_material"); -#endif -} - -void MaterialCollectionItem::slot_import_disney() -{ -#ifdef APPLESEED_WITH_DISNEY_MATERIAL - QString filepath = - get_open_filename( - nullptr, - "Import...", - "Disney Material (*.dmt);;All Files (*.*)", - m_editor_context.m_settings, - SETTINGS_FILE_DIALOG_PROJECTS); - - if (!filepath.isEmpty()) - { - const bf::path root_path(Application::get_root_path()); - const bf::path schema_file_path = root_path / "schemas" / "settings.xsd"; - - SettingsFileReader reader(global_logger()); - ParamArray parameters; - const bool success = - reader.read( - filepath.toStdString().c_str(), - schema_file_path.string().c_str(), - parameters); - - if (!success) - { - show_error_message_box( - "Importing Error", - "Failed to import the Disney Material file " + filepath.toStdString()); - return; - } - - std::string name = parameters.get("__name"); - const std::string model = parameters.get("__model"); - parameters.strings().remove("__name"); - parameters.strings().remove("__model"); - - if (model != "disney_material") - { - show_error_message_box( - "Importing Error", - "Material model " + model + " is not supported."); - return; - } - - // If there is already a material with the same name, rename the imported material. - for (const_each i = m_parent.materials(); i; ++i) - { - if (strcmp(i->get_name(), name.c_str()) == 0) - { - name = make_unique_name(name, m_parent.materials()); - break; - } - } - - auto_release_ptr material = - DisneyMaterialFactory().create(name.c_str(), parameters); - Material* material_ptr = material.get(); - - add_item(material_ptr); - - EntityTraits::insert_entity(material, m_parent); - m_editor_context.m_project_builder.slot_notify_project_modification(); - - m_editor_context.m_project_explorer.select_entity(material_ptr->get_uid()); - } -#endif -} - void MaterialCollectionItem::slot_create_osl() { do_create_material("osl_material"); @@ -256,18 +149,6 @@ void MaterialCollectionItem::do_create_material(const char* model) std::unique_ptr entity_browser( new EntityBrowser(Base::m_parent)); - std::unique_ptr custom_entity_ui; - -#ifdef APPLESEED_WITH_DISNEY_MATERIAL - if (strcmp(model, "disney_material") == 0) - { - custom_entity_ui.reset( - new DisneyMaterialCustomUI( - m_editor_context.m_project, - m_editor_context.m_settings)); - } -#endif - open_entity_editor( QTreeWidgetItem::treeWidget(), window_title, @@ -275,7 +156,7 @@ void MaterialCollectionItem::do_create_material(const char* model) m_editor_context.m_settings, std::move(form_factory), std::move(entity_browser), - std::move(custom_entity_ui), + std::unique_ptr(), Dictionary(), this, SLOT(slot_create_applied(foundation::Dictionary)), diff --git a/src/appleseed.studio/mainwindow/project/materialcollectionitem.h b/src/appleseed.studio/mainwindow/project/materialcollectionitem.h index 565a10c80b..9621ea8022 100644 --- a/src/appleseed.studio/mainwindow/project/materialcollectionitem.h +++ b/src/appleseed.studio/mainwindow/project/materialcollectionitem.h @@ -54,8 +54,6 @@ class MaterialCollectionItem renderer::Assembly& parent, AssemblyItem* parent_item); - const renderer::Material& create_default_disney_material(const std::string& material_name); - protected: typedef CollectionItem Base; @@ -63,8 +61,6 @@ class MaterialCollectionItem private slots: void slot_create_generic(); - void slot_create_disney(); - void slot_import_disney(); void slot_create_osl(); private: diff --git a/src/appleseed.studio/mainwindow/project/materialitem.cpp b/src/appleseed.studio/mainwindow/project/materialitem.cpp index 245a1c8a33..0283c5f45b 100644 --- a/src/appleseed.studio/mainwindow/project/materialitem.cpp +++ b/src/appleseed.studio/mainwindow/project/materialitem.cpp @@ -30,9 +30,6 @@ #include "materialitem.h" // appleseed.studio headers. -#ifdef APPLESEED_WITH_DISNEY_MATERIAL -#include "mainwindow/project/disneymaterialcustomui.h" -#endif #include "mainwindow/project/entityeditorcontext.h" #include "mainwindow/project/tools.h" #include "utility/settingskeys.h" @@ -83,15 +80,6 @@ MaterialItem::MaterialItem( QMenu* MaterialItem::get_single_item_context_menu() const { QMenu* menu = ItemBase::get_single_item_context_menu(); - -#ifdef APPLESEED_WITH_DISNEY_MATERIAL - if (strcmp(m_entity->get_model(), "disney_material") == 0) - { - menu->addSeparator(); - menu->addAction("Export...", this, SLOT(slot_export())); - } -#endif - return menu; } @@ -106,19 +94,6 @@ void MaterialItem::slot_edit(AttributeEditor* attribute_editor) std::unique_ptr entity_browser( new EntityBrowser(m_parent)); - std::unique_ptr custom_entity_ui; - -#ifdef APPLESEED_WITH_DISNEY_MATERIAL - if (strcmp(m_entity->get_model(), "disney_material") == 0) - { - custom_entity_ui = - std::unique_ptr( - new DisneyMaterialCustomUI( - m_editor_context.m_project, - m_editor_context.m_settings)); - } -#endif - const Dictionary values = get_values(); if (attribute_editor) @@ -126,7 +101,7 @@ void MaterialItem::slot_edit(AttributeEditor* attribute_editor) attribute_editor->edit( std::move(form_factory), std::move(entity_browser), - std::move(custom_entity_ui), + std::unique_ptr(), values, this, SLOT(slot_edit_accepted(foundation::Dictionary))); @@ -144,7 +119,7 @@ void MaterialItem::slot_edit(AttributeEditor* attribute_editor) m_editor_context.m_settings, std::move(form_factory), std::move(entity_browser), - std::move(custom_entity_ui), + std::unique_ptr(), values, this, SLOT(slot_edit_accepted(foundation::Dictionary)), diff --git a/src/appleseed.studio/mainwindow/project/objectinstanceitem.cpp b/src/appleseed.studio/mainwindow/project/objectinstanceitem.cpp index 7051ab6dc2..4ac289d6b7 100644 --- a/src/appleseed.studio/mainwindow/project/objectinstanceitem.cpp +++ b/src/appleseed.studio/mainwindow/project/objectinstanceitem.cpp @@ -123,10 +123,6 @@ QMenu* ObjectInstanceItem::get_single_item_context_menu() const menu->addSeparator(); -#ifdef APPLESEED_WITH_DISNEY_MATERIAL - menu->addAction("Assign New Disney Material", this, SLOT(slot_assign_new_disney_material())); -#endif - menu->addAction("Assign Materials...", this, SLOT(slot_open_material_assignment_editor())); add_material_assignment_menu_actions(menu); @@ -161,107 +157,11 @@ QMenu* ObjectInstanceItem::get_multiple_items_context_menu(const QListaddSeparator(); -#ifdef APPLESEED_WITH_DISNEY_MATERIAL - menu->addAction("Assign New Disney Material", this, SLOT(slot_assign_new_disney_material())) - ->setData(QVariant::fromValue(items)); -#endif - add_material_assignment_menu_actions(menu, items); return menu; } -#ifdef APPLESEED_WITH_DISNEY_MATERIAL - -// Friend of ObjectInstanceItem class, thus cannot be placed in anonymous namespace. -class AssignNewDisneyMaterialAction - : public RenderingManager::IScheduledAction -{ - public: - AssignNewDisneyMaterialAction( - EntityEditorContext& editor_context, - const QList& items) - : m_editor_context(editor_context) - , m_items(items) - { - } - - void operator()(Project& project) override - { - for (int i = 0; i < m_items.size(); ++i) - { - // Create a new Disney material and assign it to the object instance. - const Material& material = create_and_assign_new_material(m_items[i]); - - // Select the last added material. - if (i == m_items.size() - 1) - m_editor_context.m_project_explorer.select_entity(material.get_uid()); - } - } - - const Material& create_and_assign_new_material(ObjectInstanceItem* object_instance_item) - { - const ObjectInstance& object_instance = *object_instance_item->m_entity; - const Assembly& assembly = object_instance_item->m_parent; - - // Name the material after the name of the object instance. - const std::string material_name = - make_unique_name( - std::string(object_instance.get_name()) + "_material", - assembly.materials()); - - // Create the material and insert it into the assembly. - const AssemblyItem* assembly_item = m_editor_context.m_item_registry.get_item(assembly); - const Material& material = - assembly_item->get_material_collection_item().create_default_disney_material(material_name); - - // Assign the material to the object instance. - // We need the object bound to the instance in order to retrieve the material slots. - const Object* object = object_instance.find_object(); - if (object) - { - const size_t slot_count = object->get_material_slot_count(); - - if (slot_count > 0) - { - for (size_t i = 0; i < slot_count; ++i) - { - object_instance_item->do_assign_material( - object->get_material_slot(i), - ObjectInstance::BothSides, - material_name.c_str()); - } - } - else - { - object_instance_item->do_assign_material( - ObjectInstanceItem::DefaultSlotName, - ObjectInstance::BothSides, - material_name.c_str()); - } - } - - return material; - } - - private: - EntityEditorContext& m_editor_context; - const QList m_items; -}; - -#endif // APPLESEED_WITH_DISNEY_MATERIAL - -void ObjectInstanceItem::slot_assign_new_disney_material() -{ -#ifdef APPLESEED_WITH_DISNEY_MATERIAL - m_editor_context.m_rendering_manager.schedule_or_execute( - std::unique_ptr( - new AssignNewDisneyMaterialAction( - m_editor_context, - get_action_items()))); -#endif -} - void ObjectInstanceItem::slot_open_material_assignment_editor() { MaterialAssignmentEditorWindow* editor_window = diff --git a/src/appleseed.studio/mainwindow/project/objectinstanceitem.h b/src/appleseed.studio/mainwindow/project/objectinstanceitem.h index 38b4befce7..fc9c597f2d 100644 --- a/src/appleseed.studio/mainwindow/project/objectinstanceitem.h +++ b/src/appleseed.studio/mainwindow/project/objectinstanceitem.h @@ -91,7 +91,6 @@ class ObjectInstanceItem void update_style(); private slots: - void slot_assign_new_disney_material(); void slot_open_material_assignment_editor(); void slot_assign_material(); void slot_assign_material_accepted(QString page_name, QString entity_name, QVariant data); @@ -99,7 +98,6 @@ class ObjectInstanceItem private: friend class EntityDeletionAction; - friend class AssignNewDisneyMaterialAction; typedef SingleModelEntityItem Base; diff --git a/src/appleseed/CMakeLists.txt b/src/appleseed/CMakeLists.txt index 217a96d673..57df7ea090 100644 --- a/src/appleseed/CMakeLists.txt +++ b/src/appleseed/CMakeLists.txt @@ -657,11 +657,6 @@ set (foundation_meta_tests_sources foundation/meta/tests/test_z85.cpp foundation/meta/tests/test_zip.cpp ) -if (WITH_DISNEY_MATERIAL) - list (APPEND foundation_meta_tests_sources - foundation/meta/tests/test_seexpr.cpp - ) -endif () list (APPEND appleseed_sources ${foundation_meta_tests_sources} ) @@ -996,12 +991,6 @@ set (foundation_utility_sources foundation/utility/zip.cpp foundation/utility/zip.h ) -if (WITH_DISNEY_MATERIAL) - list (APPEND foundation_utility_sources - foundation/utility/seexpr.cpp - foundation/utility/seexpr.h - ) -endif () list (APPEND appleseed_sources ${foundation_utility_sources} ) @@ -1660,12 +1649,6 @@ set (renderer_modeling_bsdf_sources renderer/modeling/bsdf/specularbtdf.h renderer/modeling/bsdf/specularhelper.h ) -if (WITH_DISNEY_MATERIAL) - list (APPEND renderer_modeling_bsdf_sources - renderer/modeling/bsdf/disneylayeredbrdf.cpp - renderer/modeling/bsdf/disneylayeredbrdf.h - ) -endif () list (APPEND appleseed_sources ${renderer_modeling_bsdf_sources} ) @@ -1954,12 +1937,6 @@ set (renderer_modeling_material_sources renderer/modeling/material/oslmaterial.cpp renderer/modeling/material/oslmaterial.h ) -if (WITH_DISNEY_MATERIAL) - list (APPEND renderer_modeling_material_sources - renderer/modeling/material/disneymaterial.cpp - renderer/modeling/material/disneymaterial.h - ) -endif () list (APPEND appleseed_sources ${renderer_modeling_material_sources} ) @@ -2197,7 +2174,6 @@ set (renderer_utility_sources renderer/utility/projectpoints.cpp renderer/utility/projectpoints.h renderer/utility/rgbspectrum.h - renderer/utility/seexpr.h renderer/utility/settingsparsing.cpp renderer/utility/settingsparsing.h renderer/utility/shadowterminator.h @@ -2361,10 +2337,6 @@ if (WITH_EMBREE) link_against_embree (appleseed) endif () -if (WITH_DISNEY_MATERIAL) - link_against_seexpr (appleseed) -endif () - if (WITH_GPU) target_link_libraries (appleseed ${OPTIX_LIBRARIES} diff --git a/src/appleseed/foundation/core/buildoptions.h.in b/src/appleseed/foundation/core/buildoptions.h.in index 3880f0b392..e89c2b1a13 100644 --- a/src/appleseed/foundation/core/buildoptions.h.in +++ b/src/appleseed/foundation/core/buildoptions.h.in @@ -42,6 +42,5 @@ // Optional components. -#cmakedefine APPLESEED_WITH_DISNEY_MATERIAL #cmakedefine APPLESEED_WITH_EMBREE #cmakedefine APPLESEED_WITH_GPU diff --git a/src/appleseed/foundation/core/thirdparties.cpp b/src/appleseed/foundation/core/thirdparties.cpp index a4759822cc..7196557bc3 100644 --- a/src/appleseed/foundation/core/thirdparties.cpp +++ b/src/appleseed/foundation/core/thirdparties.cpp @@ -94,7 +94,6 @@ LibraryVersionArray ThirdParties::get_versions() static const char* BCDVersion = "v1.1"; static const char* LibJpegTurboVersion = "1.3.1"; static const char* LibTIFFVersion = "4.0.3"; - static const char* SeExprVersion = "appleseedhq/SeExpr, qt5-appleseed branch, commit 8a3d1cd"; LibraryVersionArray versions; @@ -129,7 +128,6 @@ LibraryVersionArray ThirdParties::get_versions() versions.push_back(APIStringPair("OpenEXR", OPENEXR_VERSION_STRING)); versions.push_back(APIStringPair("OpenImageIO", OIIO_VERSION_STRING)); versions.push_back(APIStringPair("OpenShadingLanguage", OSL_LIBRARY_VERSION_STRING)); - versions.push_back(APIStringPair("SeExpr", SeExprVersion)); versions.push_back(APIStringPair("Xerces-C++", XERCES_FULLVERSIONDOT)); versions.push_back(APIStringPair("zlib", ZLIB_VERSION)); diff --git a/src/appleseed/foundation/meta/tests/test_seexpr.cpp b/src/appleseed/foundation/meta/tests/test_seexpr.cpp deleted file mode 100644 index 20a2ef56f3..0000000000 --- a/src/appleseed/foundation/meta/tests/test_seexpr.cpp +++ /dev/null @@ -1,118 +0,0 @@ - -// -// This source file is part of appleseed. -// Visit https://appleseedhq.net/ for additional information and resources. -// -// This software is released under the MIT license. -// -// Copyright (c) 2016-2018 Francois Beaune, The appleseedhq Organization -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// - -// appleseed.foundation headers. -#include "foundation/utility/seexpr.h" -#include "foundation/utility/test.h" - -// Standard headers. -#include - -using namespace foundation; - -TEST_SUITE(Foundation_Utility_SeExpr_SeExprFilePathExtractor) -{ - TEST_CASE(ExtractPaths_GivenEmptyExpression_ReturnsZeroPath) - { - SeExprFilePathExtractor extractor; - SeExprFilePathExtractor::PathCollection paths; - - extractor.extract_paths("", paths); - - EXPECT_EQ(0, paths.size()); - } - - TEST_CASE(ExtractPaths_GivenSimpleTextureExpression_ReturnsOnePath) - { - SeExprFilePathExtractor extractor; - SeExprFilePathExtractor::PathCollection paths; - - extractor.extract_paths("texture(\"/path/to/file.exr\", $u, $v)", paths); - - ASSERT_EQ(1, paths.size()); - EXPECT_EQ("/path/to/file.exr", paths[0]); - } - - TEST_CASE(ExtractPaths_GivenSimpleTextureExpressionWithExtraWhitespaces_ReturnsOnePath) - { - SeExprFilePathExtractor extractor; - SeExprFilePathExtractor::PathCollection paths; - - extractor.extract_paths("texture( \"/path/to/file.exr\", $u, $v )", paths); - - ASSERT_EQ(1, paths.size()); - EXPECT_EQ("/path/to/file.exr", paths[0]); - } - - TEST_CASE(ExtractPaths_GivenTextureExpressionEmbeddedInExpression_ReturnsOnePath) - { - SeExprFilePathExtractor extractor; - SeExprFilePathExtractor::PathCollection paths; - - extractor.extract_paths("2*(1-texture( \"/path/to/file.exr\", $u, $v ))", paths); - - ASSERT_EQ(1, paths.size()); - EXPECT_EQ("/path/to/file.exr", paths[0]); - } - - TEST_CASE(ExtractPaths_GivenTwoTextureExpressions_ReturnsTwoPaths) - { - SeExprFilePathExtractor extractor; - SeExprFilePathExtractor::PathCollection paths; - - extractor.extract_paths("texture(\"/path/to/file1.exr\", $u, $v) * texture(\"/path/to/file2.exr\", $u, $v)", paths); - - ASSERT_EQ(2, paths.size()); - EXPECT_EQ("/path/to/file1.exr", paths[0]); - EXPECT_EQ("/path/to/file2.exr", paths[1]); - } - - TEST_CASE(ReplacePaths_GivenSimpleTextureExpression_ReplacesPath) - { - SeExprFilePathExtractor extractor; - SeExprFilePathExtractor::MappingCollection mappings; - mappings["/path/to/file.exr"] = "/bruce/lee.exr"; - - const std::string result = - extractor.replace_paths("texture(\"/path/to/file.exr\", $u, $v)", mappings); - - ASSERT_EQ("texture(\"/bruce/lee.exr\", $u, $v)", result); - } - - TEST_CASE(ReplacePaths_GivenTwoTextureExpressionWithSamePaths_ReplacesBothPaths) - { - SeExprFilePathExtractor extractor; - SeExprFilePathExtractor::MappingCollection mappings; - mappings["/path/to/file.exr"] = "/bruce/lee.exr"; - - const std::string result = - extractor.replace_paths("texture(\"/path/to/file.exr\", $u, $v) * texture(\"/path/to/file.exr\", $u, $v)", mappings); - - ASSERT_EQ("texture(\"/bruce/lee.exr\", $u, $v) * texture(\"/bruce/lee.exr\", $u, $v)", result); - } -} diff --git a/src/appleseed/foundation/utility/seexpr.cpp b/src/appleseed/foundation/utility/seexpr.cpp deleted file mode 100644 index 58d49116ca..0000000000 --- a/src/appleseed/foundation/utility/seexpr.cpp +++ /dev/null @@ -1,91 +0,0 @@ - -// -// This source file is part of appleseed. -// Visit https://appleseedhq.net/ for additional information and resources. -// -// This software is released under the MIT license. -// -// Copyright (c) 2016-2018 Francois Beaune, The appleseedhq Organization -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// - -// Interface header. -#include "seexpr.h" - -using namespace boost; - -namespace foundation -{ - -// -// SeExprFilePathExtractor class implementation. -// - -SeExprFilePathExtractor::SeExprFilePathExtractor() - : m_regex("(?\\btexture\\(\\s*\")(?[^\"]+)(?\")") -{ -} - -void SeExprFilePathExtractor::extract_paths( - const std::string& expression, - PathCollection& paths) const -{ - std::string::const_iterator start = expression.begin(); - std::string::const_iterator end = expression.end(); - smatch matches; - - while (regex_search(start, end, matches, m_regex)) - { - sub_match submatch = matches["path"]; - paths.push_back(submatch.str()); - start = submatch.second; - } -} - -namespace -{ - struct Formatter - { - const SeExprFilePathExtractor::MappingCollection& m_mappings; - - explicit Formatter(const SeExprFilePathExtractor::MappingCollection& mappings) - : m_mappings(mappings) - { - } - - std::string operator()(const smatch& matches) const - { - std::string result = matches["prefix"].str(); - result += m_mappings.find(matches["path"].str())->second; - result += matches["suffix"].str(); - return result; - } - }; -} - -std::string SeExprFilePathExtractor::replace_paths( - const std::string& expression, - const MappingCollection& mappings) const -{ - const Formatter formatter(mappings); - return regex_replace(expression, m_regex, formatter); -} - -} // namespace foundation diff --git a/src/appleseed/foundation/utility/seexpr.h b/src/appleseed/foundation/utility/seexpr.h deleted file mode 100644 index 92c3c49469..0000000000 --- a/src/appleseed/foundation/utility/seexpr.h +++ /dev/null @@ -1,70 +0,0 @@ - -// -// This source file is part of appleseed. -// Visit https://appleseedhq.net/ for additional information and resources. -// -// This software is released under the MIT license. -// -// Copyright (c) 2016-2018 Francois Beaune, The appleseedhq Organization -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// - -#pragma once - -// appleseed.foundation headers. -#include "foundation/core/concepts/noncopyable.h" - -// Boost headers. -#include "boost/regex.hpp" - -// Standard headers. -#include -#include -#include - -namespace foundation -{ - -// -// Extracts all file paths from a valid SeExpr expression. -// - -class SeExprFilePathExtractor - : public NonCopyable -{ - public: - typedef std::vector PathCollection; - typedef std::map MappingCollection; - - SeExprFilePathExtractor(); - - void extract_paths( - const std::string& expression, - PathCollection& paths) const; - - std::string replace_paths( - const std::string& expression, - const MappingCollection& mappings) const; - - private: - const boost::regex m_regex; -}; - -} // namespace foundation diff --git a/src/appleseed/renderer/api/material.h b/src/appleseed/renderer/api/material.h index c8198b6dd3..4c0faced17 100644 --- a/src/appleseed/renderer/api/material.h +++ b/src/appleseed/renderer/api/material.h @@ -30,9 +30,6 @@ #pragma once // API headers. -#ifdef APPLESEED_WITH_DISNEY_MATERIAL -#include "renderer/modeling/material/disneymaterial.h" -#endif #include "renderer/modeling/material/genericmaterial.h" #include "renderer/modeling/material/imaterialfactory.h" #include "renderer/modeling/material/material.h" diff --git a/src/appleseed/renderer/modeling/bsdf/disneylayeredbrdf.cpp b/src/appleseed/renderer/modeling/bsdf/disneylayeredbrdf.cpp deleted file mode 100644 index cd7a669081..0000000000 --- a/src/appleseed/renderer/modeling/bsdf/disneylayeredbrdf.cpp +++ /dev/null @@ -1,212 +0,0 @@ - -// -// This source file is part of appleseed. -// Visit https://appleseedhq.net/ for additional information and resources. -// -// This software is released under the MIT license. -// -// Copyright (c) 2014-2018 Esteban Tovagliari, The appleseedhq Organization -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// - -// Interface header. -#include "disneylayeredbrdf.h" - -// appleseed.renderer headers. -#include "renderer/kernel/lighting/scatteringmode.h" -#include "renderer/kernel/shading/directshadingcomponents.h" -#include "renderer/kernel/shading/shadingcontext.h" -#include "renderer/modeling/bsdf/disneybrdf.h" -#include "renderer/modeling/color/colorspace.h" -#include "renderer/modeling/material/disneymaterial.h" -#include "renderer/utility/paramarray.h" - -// appleseed.foundation headers. -#include "foundation/image/color.h" -#include "foundation/image/colorspace.h" -#include "foundation/memory/arena.h" - -// Standard headers. -#include -#include - -using namespace foundation; - -namespace renderer -{ - -// -// DisneyLayeredBRDF class implementation. -// - -namespace -{ - const char* Model = "disney_layered_brdf"; -} - -DisneyLayeredBRDF::DisneyLayeredBRDF(const DisneyMaterial* parent) - : BSDF( - "disney_layered_brdf", - Reflective, - ScatteringMode::Diffuse | ScatteringMode::Glossy, - ParamArray()) - , m_parent(parent) - , m_brdf(DisneyBRDFFactory().create("disney_brdf", ParamArray())) -{ - assert(parent); -} - -void DisneyLayeredBRDF::release() -{ - delete this; -} - -const char* DisneyLayeredBRDF::get_model() const -{ - return Model; -} - -bool DisneyLayeredBRDF::on_frame_begin( - const Project& project, - const BaseGroup* parent, - OnFrameBeginRecorder& recorder, - IAbortSwitch* abort_switch) -{ - if (!BSDF::on_frame_begin(project, parent, recorder, abort_switch)) - return false; - - if (!m_brdf->on_frame_begin(project, parent, recorder, abort_switch)) - return false; - - return true; -} - -size_t DisneyLayeredBRDF::compute_input_data_size() const -{ - return sizeof(DisneyBRDFInputValues); -} - -void* DisneyLayeredBRDF::evaluate_inputs( - const ShadingContext& shading_context, - const ShadingPoint& shading_point) const -{ - DisneyBRDFInputValues* values = shading_context.get_arena().allocate(); - memset(values, 0, sizeof(DisneyBRDFInputValues)); - - Color3f base_color(0.0f); - - for (size_t i = 0, e = m_parent->get_layer_count(); i < e; ++i) - { - const DisneyMaterialLayer& layer = - m_parent->get_layer(i, shading_context.get_thread_index()); - - layer.evaluate_expressions( - shading_point, - shading_context.get_oiio_texture_system(), - base_color, - *values); - } - - // Colors in SeExpr are always in the sRGB color space. - // todo: convert colors earlier so that all math is done in linear space. - values->m_base_color.set( - fast_srgb_to_linear_rgb(base_color), - g_std_lighting_conditions, - Spectrum::Reflectance); - - m_brdf->prepare_inputs( - shading_context.get_arena(), - shading_point, - values); - - return values; -} - -void DisneyLayeredBRDF::sample( - SamplingContext& sampling_context, - const void* data, - const bool adjoint, - const bool cosine_mult, - const LocalGeometry& local_geometry, - const Dual3f& outgoing, - const int modes, - BSDFSample& sample) const -{ - if (m_parent->get_layer_count() == 0) - return; - - m_brdf->sample( - sampling_context, - data, - adjoint, - cosine_mult, - local_geometry, - outgoing, - modes, - sample); -} - -float DisneyLayeredBRDF::evaluate( - const void* data, - const bool adjoint, - const bool cosine_mult, - const LocalGeometry& local_geometry, - const Vector3f& outgoing, - const Vector3f& incoming, - const int modes, - DirectShadingComponents& value) const -{ - if (m_parent->get_layer_count() == 0) - return 0.0f; - - return - m_brdf->evaluate( - data, - adjoint, - cosine_mult, - local_geometry, - outgoing, - incoming, - modes, - value); -} - -float DisneyLayeredBRDF::evaluate_pdf( - const void* data, - const bool adjoint, - const LocalGeometry& local_geometry, - const Vector3f& outgoing, - const Vector3f& incoming, - const int modes) const -{ - if (m_parent->get_layer_count() == 0) - return 0.0f; - - return - m_brdf->evaluate_pdf( - data, - adjoint, - local_geometry, - outgoing, - incoming, - modes); -} - -} // namespace renderer diff --git a/src/appleseed/renderer/modeling/bsdf/disneylayeredbrdf.h b/src/appleseed/renderer/modeling/bsdf/disneylayeredbrdf.h deleted file mode 100644 index fcb77ac32a..0000000000 --- a/src/appleseed/renderer/modeling/bsdf/disneylayeredbrdf.h +++ /dev/null @@ -1,119 +0,0 @@ - -// -// This source file is part of appleseed. -// Visit https://appleseedhq.net/ for additional information and resources. -// -// This software is released under the MIT license. -// -// Copyright (c) 2014-2018 Esteban Tovagliari, The appleseedhq Organization -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// - -#pragma once - -// appleseed.renderer headers. -#include "renderer/global/globaltypes.h" -#include "renderer/modeling/bsdf/bsdf.h" - -// appleseed.foundation headers. -#include "foundation/math/dual.h" -#include "foundation/math/vector.h" -#include "foundation/memory/autoreleaseptr.h" - -// Standard headers. -#include - -// Forward declarations. -namespace foundation { class DictionaryArray; } -namespace foundation { class IAbortSwitch; } -namespace renderer { class BaseGroup; } -namespace renderer { class BSDFSample; } -namespace renderer { class DisneyMaterial; } -namespace renderer { class OnFrameBeginRecorder; } -namespace renderer { class ParamArray; } -namespace renderer { class Project; } -namespace renderer { class ShadingContext; } -namespace renderer { class ShadingPoint; } - -namespace renderer -{ - -// -// Disney layered BRDF class. -// - -class DisneyLayeredBRDF - : public BSDF -{ - public: - void release() override; - - const char* get_model() const override; - - bool on_frame_begin( - const Project& project, - const BaseGroup* parent, - OnFrameBeginRecorder& recorder, - foundation::IAbortSwitch* abort_switch = nullptr) override; - - size_t compute_input_data_size() const override; - - void* evaluate_inputs( - const ShadingContext& shading_context, - const ShadingPoint& shading_point) const override; - - void sample( - SamplingContext& sampling_context, - const void* data, - const bool adjoint, - const bool cosine_mult, - const LocalGeometry& local_geometry, - const foundation::Dual3f& outgoing, - const int modes, - BSDFSample& sample) const override; - - float evaluate( - const void* data, - const bool adjoint, - const bool cosine_mult, - const LocalGeometry& local_geometry, - const foundation::Vector3f& outgoing, - const foundation::Vector3f& incoming, - const int modes, - DirectShadingComponents& value) const override; - - float evaluate_pdf( - const void* data, - const bool adjoint, - const LocalGeometry& local_geometry, - const foundation::Vector3f& outgoing, - const foundation::Vector3f& incoming, - const int modes) const override; - - private: - friend class DisneyMaterial; - - const DisneyMaterial* m_parent; - foundation::auto_release_ptr m_brdf; - - explicit DisneyLayeredBRDF(const DisneyMaterial* parent); -}; - -} // namespace renderer diff --git a/src/appleseed/renderer/modeling/material/disneymaterial.cpp b/src/appleseed/renderer/modeling/material/disneymaterial.cpp deleted file mode 100644 index db5e75006e..0000000000 --- a/src/appleseed/renderer/modeling/material/disneymaterial.cpp +++ /dev/null @@ -1,852 +0,0 @@ - -// -// This source file is part of appleseed. -// Visit https://appleseedhq.net/ for additional information and resources. -// -// This software is released under the MIT license. -// -// Copyright (c) 2014-2018 Esteban Tovagliari, The appleseedhq Organization -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// - -// Interface header. -#include "disneymaterial.h" - -// appleseed.renderer headers. -#include "renderer/kernel/shading/shadingpoint.h" -#include "renderer/kernel/texturing/oiiotexturesystem.h" -#include "renderer/modeling/bsdf/disneybrdf.h" -#include "renderer/modeling/bsdf/disneylayeredbrdf.h" -#include "renderer/modeling/scene/containers.h" -#include "renderer/utility/seexpr.h" - -// appleseed.foundation headers. -#include "foundation/containers/dictionary.h" -#include "foundation/image/colorspace.h" -#include "foundation/math/scalar.h" -#include "foundation/utility/api/specializedapiarrays.h" -#include "foundation/utility/foreach.h" -#include "foundation/utility/seexpr.h" -#include "foundation/utility/tls.h" - -// Standard headers. -#include -#include -#include -#include -#include -#include - -using namespace foundation; - -namespace renderer -{ - -namespace -{ - // - // The DisneyLayerParam class wraps an SeAppleseedExpr object to add basic optimizations - // for straightforward expressions such as a single scalar or a simple texture lookup. - // - - class DisneyLayerParam - { - public: - DisneyLayerParam( - const char* name, - const Dictionary& params, - const bool is_vector) - : m_param_name(name) - , m_expr(params.get(name)) - , m_is_vector(is_vector) - , m_is_constant(false) - , m_texture_is_srgb(true) - { - } - - DisneyLayerParam(const DisneyLayerParam& other) - : m_param_name(other.m_param_name) - , m_expr(other.m_expr) - , m_is_vector(other.m_is_vector) - , m_is_constant(other.m_is_constant) - , m_constant_value(other.m_constant_value) - , m_texture_filename(other.m_texture_filename) - , m_texture_options(other.m_texture_options) - , m_texture_is_srgb(other.m_texture_is_srgb) - { - } - - std::string& expression() - { - return m_expr; - } - - const std::string& expression() const - { - return m_expr; - } - - bool prepare() - { - m_expression.setWantVec(m_is_vector); - m_expression.set_expr(m_expr); - - if (!m_expression.isValid()) - { - RENDERER_LOG_ERROR("expression error for \"%s\" parameter: %s", - m_param_name, m_expression.parseError().c_str()); - return false; - } - - // Case of a simple constant. - m_is_constant = m_expression.isConstant(); - if (m_is_constant) - { - const SeVec3d result = m_expression.evaluate(); - m_constant_value = Color3d(result[0], result[1], result[2]); - return true; - } - - // Case of a simple texture lookup of the form texture("path/to/texture", $u, $v). - { - const std::string expression = trim_both(m_expression.getExpr(), " \r\n"); - std::vector tokens; - tokenize(expression, "()", tokens); - - if (tokens.size() != 2) - return true; - - if (trim_both(tokens[0]) != "texture") - return true; - - const std::string inner_content = tokens[1]; - tokens.clear(); - tokenize(inner_content, ",", tokens); - - if (tokens.size() != 3) - return true; - - if (trim_both(tokens[1]) != "$u") - return true; - - if (trim_both(tokens[2]) != "$v") - return true; - - m_texture_filename = OIIO::ustring(trim_both(tokens[0], " \"")); - m_texture_is_srgb = texture_is_srgb(m_texture_filename); - m_texture_options.rwrap = OIIO::TextureOpt::WrapPeriodic; - m_texture_options.swrap = OIIO::TextureOpt::WrapPeriodic; - m_texture_options.twrap = OIIO::TextureOpt::WrapPeriodic; - } - - return true; - } - - Color3f evaluate( - const ShadingPoint& shading_point, - OIIOTextureSystem& texture_system) const - { - if (m_is_constant) - return m_constant_value; - - if (!m_texture_filename.empty()) - { - const Vector2f& uv = shading_point.get_uv(0); - - Color3f color; - if (!texture_system.texture( - m_texture_filename, - m_texture_options, - uv[0], - uv[1], - 0.0f, - 0.0f, - 0.0f, - 0.0f, - 3, - &color[0])) - { - // Failed to find or open the texture. - const std::string message = texture_system.geterror(); - if (!message.empty()) - { - const std::string modified_message = prefix_all_lines(trim_both(message), "oiio: "); - RENDERER_LOG_ERROR("%s", modified_message.c_str()); - } - return Color3f(1.0f, 0.0f, 1.0f); - } - - // Colors in SeExpr are always in the sRGB color space. - if (!m_texture_is_srgb) - color = fast_linear_rgb_to_srgb(color); - - return color; - } - - return - m_expression.update_and_evaluate( - shading_point, - texture_system); - } - - private: - const char* m_param_name; - std::string m_expr; - bool m_is_vector; - bool m_is_constant; - Color3d m_constant_value; - OIIO::ustring m_texture_filename; - mutable OIIO::TextureOpt m_texture_options; - bool m_texture_is_srgb; - mutable SeAppleseedExpr m_expression; - }; -} - - -// -// DisneyMaterialLayer class implementation. -// - -namespace -{ - const UniqueID g_disney_material_layer_class_uid = new_guid(); -} - -struct DisneyMaterialLayer::Impl -{ - Impl( - const char* name, - const Dictionary& params) - : m_name(name) - , m_layer_number(params.get("layer_number")) - , m_mask("mask", params, false) - , m_base_color("base_color", params, true) - , m_subsurface("subsurface", params, false) - , m_metallic("metallic", params, false) - , m_specular("specular", params, false) - , m_specular_tint("specular_tint", params, false) - , m_anisotropic("anisotropic", params, false) - , m_roughness("roughness", params, false) - , m_sheen("sheen", params, false) - , m_sheen_tint("sheen_tint", params, false) - , m_clearcoat("clearcoat", params, false) - , m_clearcoat_gloss("clearcoat_gloss", params, false) - { - } - - const std::string m_name; - const int m_layer_number; - DisneyLayerParam m_mask; - DisneyLayerParam m_base_color; - DisneyLayerParam m_subsurface; - DisneyLayerParam m_metallic; - DisneyLayerParam m_specular; - DisneyLayerParam m_specular_tint; - DisneyLayerParam m_anisotropic; - DisneyLayerParam m_roughness; - DisneyLayerParam m_sheen; - DisneyLayerParam m_sheen_tint; - DisneyLayerParam m_clearcoat; - DisneyLayerParam m_clearcoat_gloss; -}; - -DisneyMaterialLayer::DisneyMaterialLayer( - const char* name, - const Dictionary& params) - : Entity(g_disney_material_layer_class_uid, params) - , impl(new Impl(name, params)) -{ -} - -DisneyMaterialLayer::DisneyMaterialLayer(const DisneyMaterialLayer& other) - : Entity(other.m_class_uid, other.m_params) - , impl(new Impl(*other.impl)) -{ -} - -DisneyMaterialLayer::~DisneyMaterialLayer() -{ - delete impl; -} - -void DisneyMaterialLayer::release() -{ - delete this; -} - -DisneyMaterialLayer& DisneyMaterialLayer::operator=(const DisneyMaterialLayer& other) -{ - DisneyMaterialLayer tmp(other); - std::swap(impl, tmp.impl); - return *this; -} - -bool DisneyMaterialLayer::operator<(const DisneyMaterialLayer& other) const -{ - return impl->m_layer_number < other.impl->m_layer_number; -} - -int DisneyMaterialLayer::get_layer_number() const -{ - return impl->m_layer_number; -} - -bool DisneyMaterialLayer::prepare_expressions() const -{ - return - impl->m_mask.prepare() && - impl->m_base_color.prepare() && - impl->m_subsurface.prepare() && - impl->m_metallic.prepare() && - impl->m_specular.prepare() && - impl->m_specular_tint.prepare() && - impl->m_anisotropic.prepare() && - impl->m_roughness.prepare() && - impl->m_sheen.prepare() && - impl->m_sheen_tint.prepare() && - impl->m_clearcoat.prepare() && - impl->m_clearcoat_gloss.prepare(); -} - -void DisneyMaterialLayer::evaluate_expressions( - const ShadingPoint& shading_point, - OIIOTextureSystem& texture_system, - Color3f& base_color, - DisneyBRDFInputValues& values) const -{ - const float mask = saturate(impl->m_mask.evaluate(shading_point, texture_system)[0]); - - if (mask == 0.0f) - return; - - base_color = - lerp( - base_color, - impl->m_base_color.evaluate(shading_point, texture_system), - mask); - - values.m_subsurface = - lerp( - values.m_subsurface, - saturate(impl->m_subsurface.evaluate(shading_point, texture_system)[0]), - mask); - - values.m_metallic = - lerp( - values.m_metallic, - saturate(impl->m_metallic.evaluate(shading_point, texture_system)[0]), - mask); - - values.m_specular = - lerp( - values.m_specular, - std::max(impl->m_specular.evaluate(shading_point, texture_system)[0], 0.0f), - mask); - - values.m_specular_tint = - lerp( - values.m_specular_tint, - saturate(impl->m_specular_tint.evaluate(shading_point, texture_system)[0]), - mask); - - values.m_anisotropic = - lerp( - values.m_anisotropic, - clamp(impl->m_anisotropic.evaluate(shading_point, texture_system)[0], -1.0f, 1.0f), - mask); - - values.m_roughness = - lerp( - values.m_roughness, - clamp(impl->m_roughness.evaluate(shading_point, texture_system)[0], 0.001f, 1.0f), - mask); - - values.m_sheen = - lerp( - values.m_sheen, - impl->m_sheen.evaluate(shading_point, texture_system)[0], - mask); - - values.m_sheen_tint = - lerp( - values.m_sheen_tint, - saturate(impl->m_sheen_tint.evaluate(shading_point, texture_system)[0]), - mask); - - values.m_clearcoat = - lerp( - values.m_clearcoat, - impl->m_clearcoat.evaluate(shading_point, texture_system)[0], - mask); - - values.m_clearcoat_gloss = - lerp( - values.m_clearcoat_gloss, - saturate(impl->m_clearcoat_gloss.evaluate(shading_point, texture_system)[0]), - mask); -} - -DictionaryArray DisneyMaterialLayer::get_input_metadata() -{ - DictionaryArray metadata; - - metadata.push_back( - Dictionary() - .insert("name", "layer_name") - .insert("label", "Layer Name") - .insert("type", "text") - .insert("use", "required")); - - metadata.push_back( - Dictionary() - .insert("name", "mask") - .insert("label", "Mask") - .insert("type", "colormap") - .insert("use", "optional") - .insert("default", "1.0")); - - metadata.push_back( - Dictionary() - .insert("name", "base_color") - .insert("label", "Base Color") - .insert("type", "colormap") - .insert("entity_types", - Dictionary() - .insert("color", "Colors") - .insert("texture_instance", "Texture Instances")) - .insert("use", "required") - .insert("default", "[0.9, 0.9, 0.9]")); - - metadata.push_back( - Dictionary() - .insert("name", "subsurface") - .insert("label", "Subsurface") - .insert("type", "colormap") - .insert("entity_types", - Dictionary().insert("texture_instance", "Texture Instances")) - .insert("use", "optional") - .insert("default", "0.0")); - - metadata.push_back( - Dictionary() - .insert("name", "metallic") - .insert("label", "Metallic") - .insert("type", "colormap") - .insert("entity_types", - Dictionary().insert("texture_instance", "Texture Instances")) - .insert("use", "optional") - .insert("default", "0.0")); - - metadata.push_back( - Dictionary() - .insert("name", "specular") - .insert("label", "Specular") - .insert("type", "colormap") - .insert("entity_types", - Dictionary().insert("texture_instance", "Texture Instances")) - .insert("use", "optional") - .insert("default", "0.0")); - - metadata.push_back( - Dictionary() - .insert("name", "specular_tint") - .insert("label", "Specular Tint") - .insert("type", "colormap") - .insert("entity_types", - Dictionary().insert("texture_instance", "Texture Instances")) - .insert("use", "optional") - .insert("default", "0.0")); - - metadata.push_back( - Dictionary() - .insert("name", "anisotropic") - .insert("label", "Anisotropic") - .insert("type", "colormap") - .insert("entity_types", - Dictionary().insert("texture_instance", "Texture Instances")) - .insert("use", "optional") - .insert("default", "0.0")); - - metadata.push_back( - Dictionary() - .insert("name", "roughness") - .insert("label", "Roughness") - .insert("type", "colormap") - .insert("entity_types", - Dictionary().insert("texture_instance", "Texture Instances")) - .insert("use", "optional") - .insert("default", "0.1")); - - metadata.push_back( - Dictionary() - .insert("name", "sheen") - .insert("label", "Sheen") - .insert("type", "colormap") - .insert("entity_types", - Dictionary().insert("texture_instance", "Texture Instances")) - .insert("use", "optional") - .insert("default", "0.0")); - - metadata.push_back( - Dictionary() - .insert("name", "sheen_tint") - .insert("label", "Sheen Tint") - .insert("type", "colormap") - .insert("entity_types", - Dictionary().insert("texture_instance", "Texture Instances")) - .insert("use", "optional") - .insert("default", "0.0")); - - metadata.push_back( - Dictionary() - .insert("name", "clearcoat") - .insert("label", "Clearcoat") - .insert("type", "colormap") - .insert("entity_types", - Dictionary().insert("texture_instance", "Texture Instances")) - .insert("use", "optional") - .insert("default", "0.0")); - - metadata.push_back( - Dictionary() - .insert("name", "clearcoat_gloss") - .insert("label", "Clearcoat Gloss") - .insert("type", "colormap") - .insert("entity_types", - Dictionary().insert("texture_instance", "Texture Instances")) - .insert("use", "optional") - .insert("default", "1.0")); - - return metadata; -} - -// todo: this is actually completely generic, could be moved somewhere more central. -Dictionary DisneyMaterialLayer::get_default_values() -{ - Dictionary values; - - const DictionaryArray input_metadata = get_input_metadata(); - - for (size_t i = 0; i < input_metadata.size(); ++i) - { - const Dictionary& im = input_metadata[i]; - const std::string input_name = im.get("name"); - - if (im.strings().exist("default")) - { - const std::string input_value = im.get("default"); - values.insert(input_name.c_str(), input_value); - } - } - - return values; -} - - -// -// DisneyMaterial class implementation. -// - -namespace -{ - const char* Model = "disney_material"; -} - -struct DisneyMaterial::Impl -{ - typedef std::vector DisneyMaterialLayerContainer; - - static const size_t MaxThreadCount = 256; - - DisneyMaterialLayerContainer m_layers; - std::unique_ptr m_brdf; - mutable TLS m_per_thread_layers; - - explicit Impl(const DisneyMaterial* parent) - : m_brdf(new DisneyLayeredBRDF(parent)) - , m_per_thread_layers(MaxThreadCount) - { - for (size_t i = 0; i < MaxThreadCount; ++i) - m_per_thread_layers[i] = nullptr; - } - - ~Impl() - { - for (size_t i = 0; i < MaxThreadCount; ++i) - assert(m_per_thread_layers[i] == 0); - } - - void clear_per_thread_layers() - { - for (size_t i = 0; i < MaxThreadCount; ++i) - { - if (m_per_thread_layers[i]) - { - delete m_per_thread_layers[i]; - m_per_thread_layers[i] = nullptr; - } - } - - } -}; - -DisneyMaterial::DisneyMaterial( - const char* name, - const ParamArray& params) - : Material(name, params) - , impl(new Impl(this)) -{ - m_inputs.declare("edf", InputFormatEntity, ""); - m_inputs.declare("alpha_map", InputFormatFloat, ""); - m_inputs.declare("displacement_map", InputFormatSpectralReflectance, ""); -} - -DisneyMaterial::~DisneyMaterial() -{ - delete impl; -} - -void DisneyMaterial::release() -{ - delete this; -} - -const char* DisneyMaterial::get_model() const -{ - return Model; -} - -void DisneyMaterial::collect_asset_paths(StringArray& paths) const -{ - SeExprFilePathExtractor extractor; - SeExprFilePathExtractor::PathCollection paths_; - - for (const_each layer_it = m_params.dictionaries(); layer_it; ++layer_it) - { - const StringDictionary& layer_params = layer_it->value().strings(); - for (const_each param_it = layer_params; param_it; ++param_it) - extractor.extract_paths(param_it->value(), paths_); - } - - for (const_each i = paths_; i; ++i) - paths.push_back(i->c_str()); -} - -void DisneyMaterial::update_asset_paths(const StringDictionary& mappings) -{ - SeExprFilePathExtractor extractor; - SeExprFilePathExtractor::MappingCollection mappings_; - - for (const_each i = mappings; i; ++i) - mappings_.insert(std::make_pair(i->key(), i->value())); - - for (each layer_it = m_params.dictionaries(); layer_it; ++layer_it) - { - StringDictionary& layer_params = layer_it->value().strings(); - for (const_each param_it = layer_params; param_it; ++param_it) - { - layer_params.set( - param_it->key(), - extractor.replace_paths(param_it->value(), mappings_)); - } - } -} - -bool DisneyMaterial::on_frame_begin( - const Project& project, - const BaseGroup* parent, - OnFrameBeginRecorder& recorder, - IAbortSwitch* abort_switch) -{ - if (!Material::on_frame_begin(project, parent, recorder, abort_switch)) - return false; - - if (!impl->m_brdf->on_frame_begin(project, parent, recorder, abort_switch)) - return false; - - const OnFrameBeginMessageContext context("material", this); - - m_render_data.m_bsdf = impl->m_brdf.get(); - m_render_data.m_edf = get_uncached_edf(); - m_render_data.m_basis_modifier = create_basis_modifier(context); - - if (m_render_data.m_edf && m_render_data.m_alpha_map) - { - RENDERER_LOG_WARNING( - "%smaterial is emitting light but may be partially or entirely transparent; " - "this may lead to unexpected or unphysical results.", - context.get()); - } - - return prepare_layers(context); -} - -void DisneyMaterial::on_frame_end( - const Project& project, - const BaseGroup* parent) -{ - impl->clear_per_thread_layers(); - impl->m_layers.clear(); - - Material::on_frame_end(project, parent); -} - -void DisneyMaterial::add_layer(Dictionary layer_values) -{ - // Assign a name to the layer if there isn't one already. - if (!layer_values.strings().exist("layer_name")) - { - const std::string layer_name = make_unique_name("layer", impl->m_layers); - layer_values.insert("layer_name", layer_name); - } - - // Assign a number to the layer if there isn't one already. - if (!layer_values.strings().exist("layer_number")) - { - int layer_number = 0; - for (const_each i = impl->m_layers; i; ++i) - layer_number = std::max(layer_number, i->get_layer_number()); - layer_values.insert("layer_number", layer_number); - } - - // Insert the layer into the material. - const std::string& layer_name = layer_values.get("layer_name"); - m_params.insert(layer_name.c_str(), layer_values); -} - -void DisneyMaterial::add_new_default_layer() -{ - add_layer(DisneyMaterialLayer::get_default_values()); -} - -size_t DisneyMaterial::get_layer_count() const -{ - return impl->m_layers.size(); -} - -const DisneyMaterialLayer& DisneyMaterial::get_layer( - const size_t index, - const size_t thread_index) const -{ - assert(index < get_layer_count()); - - if (thread_index == ~size_t(0)) - return impl->m_layers[index]; - - assert(thread_index < Impl::MaxThreadCount); - - std::vector* layers = - impl->m_per_thread_layers[thread_index]; - - if (layers == nullptr) - { - layers = new std::vector(impl->m_layers); - - for (const_each> it = *layers; it; ++it) - { - APPLESEED_UNUSED const bool ok = it->prepare_expressions(); - assert(ok); - } - - impl->m_per_thread_layers[thread_index] = layers; - } - - return (*layers)[index]; -} - -bool DisneyMaterial::prepare_layers(const MessageContext& context) -{ - assert(impl->m_layers.empty()); - - try - { - for (const_each it = m_params.dictionaries(); it; ++it) - { - DisneyMaterialLayer layer(it->key(), it->value()); - - if (!layer.prepare_expressions()) - return false; - - impl->m_layers.push_back(layer); - } - } - catch (const std::exception& e) // namespace qualification required - { - RENDERER_LOG_ERROR("%s%s.", context.get(), e.what()); - return false; - } - - sort(impl->m_layers.begin(), impl->m_layers.end()); - - return true; -} - - -// -// DisneyMaterialFactory class implementation. -// - -void DisneyMaterialFactory::release() -{ - delete this; -} - -const char* DisneyMaterialFactory::get_model() const -{ - return Model; -} - -Dictionary DisneyMaterialFactory::get_model_metadata() const -{ - return - Dictionary() - .insert("name", Model) - .insert("label", "Disney Material") - .insert("default_model", "true"); -} - -DictionaryArray DisneyMaterialFactory::get_input_metadata() const -{ - DictionaryArray metadata; - - add_surface_shader_metadata(metadata); - - metadata.push_back( - Dictionary() - .insert("name", "edf") - .insert("label", "EDF") - .insert("type", "entity") - .insert("entity_types", Dictionary().insert("edf", "EDF")) - .insert("use", "optional")); - - add_alpha_map_metadata(metadata); - add_displacement_metadata(metadata); - - return metadata; -} - -auto_release_ptr DisneyMaterialFactory::create( - const char* name, - const ParamArray& params) const -{ - return auto_release_ptr(new DisneyMaterial(name, params)); -} - -} // namespace renderer diff --git a/src/appleseed/renderer/modeling/material/disneymaterial.h b/src/appleseed/renderer/modeling/material/disneymaterial.h deleted file mode 100644 index 4bd73596de..0000000000 --- a/src/appleseed/renderer/modeling/material/disneymaterial.h +++ /dev/null @@ -1,196 +0,0 @@ - -// -// This source file is part of appleseed. -// Visit https://appleseedhq.net/ for additional information and resources. -// -// This software is released under the MIT license. -// -// Copyright (c) 2014-2018 Esteban Tovagliari, The appleseedhq Organization -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// - -#pragma once - -// appleseed.renderer headers. -#include "renderer/modeling/bsdf/disneybrdf.h" -#include "renderer/modeling/material/imaterialfactory.h" -#include "renderer/modeling/material/material.h" - -// appleseed.foundation headers. -#include "foundation/core/concepts/noncopyable.h" -#include "foundation/memory/autoreleaseptr.h" -#include "foundation/platform/compiler.h" - -// appleseed.main headers. -#include "main/dllsymbol.h" - -// Forward declarations. -namespace foundation { class Dictionary; } -namespace foundation { class DictionaryArray; } -namespace foundation { class StringArray; } -namespace foundation { class StringDictionary; } -namespace renderer { class BaseGroup; } -namespace renderer { class MessageContext; } -namespace renderer { class OIIOTextureSystem; } -namespace renderer { class OnFrameBeginRecorder; } -namespace renderer { class ParamArray; } -namespace renderer { class ShadingContext; } - -namespace renderer -{ - -// -// A layer in the Disney material. -// - -class APPLESEED_DLLSYMBOL DisneyMaterialLayer - : public Entity -{ - public: - // Constructor. - DisneyMaterialLayer(const DisneyMaterialLayer& other); - - // Destructor. - ~DisneyMaterialLayer() override; - - // Delete this instance. - void release() override; - - DisneyMaterialLayer& operator=(const DisneyMaterialLayer& other); - - bool operator<(const DisneyMaterialLayer& other) const; - - int get_layer_number() const; - - bool prepare_expressions() const; - - void evaluate_expressions( - const ShadingPoint& shading_point, - OIIOTextureSystem& texture_system, - foundation::Color3f& base_color, - DisneyBRDFInputValues& values) const; - - static foundation::DictionaryArray get_input_metadata(); - static foundation::Dictionary get_default_values(); - - private: - friend class DisneyMaterial; - - struct Impl; - Impl* impl; - - // Constructor. - DisneyMaterialLayer( - const char* name, - const foundation::Dictionary& params); -}; - - -// -// Disney material. -// - -class APPLESEED_DLLSYMBOL DisneyMaterial - : public Material -{ - public: - // Delete this instance. - void release() override; - - // Return a string identifying the model of this material. - const char* get_model() const override; - - // Expose asset file paths referenced by this entity to the outside. - void collect_asset_paths(foundation::StringArray& paths) const override; - void update_asset_paths(const foundation::StringDictionary& mappings) override; - - bool on_frame_begin( - const Project& project, - const BaseGroup* parent, - OnFrameBeginRecorder& recorder, - foundation::IAbortSwitch* abort_switch = nullptr) override; - - void on_frame_end( - const Project& project, - const BaseGroup* parent) override; - - // Add a new layer with given values to the material. - // A name and a number will be automatically assigned - // to the layer if it lacks them. - void add_layer( - foundation::Dictionary layer_values); - - // Add a new layer using default values to the material. - void add_new_default_layer(); - - // Retrieve the number of layers in the material. - size_t get_layer_count() const; - - // Retrieve a given layer of the material. - const DisneyMaterialLayer& get_layer( - const size_t index, - const size_t thread_index = ~size_t(0)) const; - - private: - friend class DisneyMaterialFactory; - - struct Impl; - Impl* impl; - - // Constructor. - DisneyMaterial( - const char* name, - const ParamArray& params); - - // Destructor. - ~DisneyMaterial() override; - - // Prepare all layers for rendering. Returns true on success. - bool prepare_layers(const MessageContext& context); -}; - - -// -// Disney material factory. -// - -class APPLESEED_DLLSYMBOL DisneyMaterialFactory - : public IMaterialFactory -{ - public: - // Delete this instance. - void release() override; - - // Return a string identifying this material model. - const char* get_model() const override; - - // Return metadata for this material model. - foundation::Dictionary get_model_metadata() const override; - - // Return metadata for the inputs of this material model. - foundation::DictionaryArray get_input_metadata() const override; - - // Create a new material instance. - foundation::auto_release_ptr create( - const char* name, - const ParamArray& params) const override; -}; - -} // namespace renderer diff --git a/src/appleseed/renderer/modeling/material/materialfactoryregistrar.cpp b/src/appleseed/renderer/modeling/material/materialfactoryregistrar.cpp index d37512c4a5..6c5a53340a 100644 --- a/src/appleseed/renderer/modeling/material/materialfactoryregistrar.cpp +++ b/src/appleseed/renderer/modeling/material/materialfactoryregistrar.cpp @@ -32,9 +32,6 @@ // appleseed.renderer headers. #include "renderer/modeling/entity/entityfactoryregistrar.h" -#ifdef APPLESEED_WITH_DISNEY_MATERIAL -#include "renderer/modeling/material/disneymaterial.h" -#endif #include "renderer/modeling/material/genericmaterial.h" #include "renderer/modeling/material/materialtraits.h" #include "renderer/modeling/material/oslmaterial.h" @@ -62,9 +59,6 @@ MaterialFactoryRegistrar::MaterialFactoryRegistrar(const SearchPaths& search_pat : impl(new Impl()) { // Register built-in factories. -#ifdef APPLESEED_WITH_DISNEY_MATERIAL - impl->register_factory(auto_release_ptr(new DisneyMaterialFactory())); -#endif impl->register_factory(auto_release_ptr(new GenericMaterialFactory())); impl->register_factory(auto_release_ptr(new OSLMaterialFactory())); } diff --git a/src/appleseed/renderer/modeling/project/projectfileupdater.cpp b/src/appleseed/renderer/modeling/project/projectfileupdater.cpp index f086f510a8..8ca48400fb 100644 --- a/src/appleseed/renderer/modeling/project/projectfileupdater.cpp +++ b/src/appleseed/renderer/modeling/project/projectfileupdater.cpp @@ -1322,9 +1322,6 @@ namespace { for (BSDF& bsdf : assembly.bsdfs()) update_bsdf_inputs(bsdf); - - for (Material& material : assembly.materials()) - update_material_inputs(material); } static void update_bsdf_inputs(BSDF& bsdf) @@ -1340,23 +1337,6 @@ namespace params.insert("sheen_tint", 0.5f); } } - - static void update_material_inputs(Material& material) - { - // Don't rely on DisneyMaterialFactory().get_model() because appleseed needs - // to be able to update projects even when built without Disney material support - // (i.e. the APPLESEED_WITH_DISNEY_MATERIAL preprocessor symbol is undefined). - if (strcmp(material.get_model(), "disney_material") == 0) - { - ParamArray& params = material.get_parameters(); - for (DictionaryDictionary::iterator& i : params.dictionaries()) - { - Dictionary& layer_params = i.value(); - if (!layer_params.strings().exist("roughness")) - layer_params.insert("roughness", 0.5f); - } - } - } }; diff --git a/src/appleseed/renderer/utility/seexpr.h b/src/appleseed/renderer/utility/seexpr.h deleted file mode 100644 index ea0128dc88..0000000000 --- a/src/appleseed/renderer/utility/seexpr.h +++ /dev/null @@ -1,266 +0,0 @@ - -// -// This source file is part of appleseed. -// Visit https://appleseedhq.net/ for additional information and resources. -// -// This software is released under the MIT license. -// -// Copyright (c) 2016-2018 Francois Beaune, The appleseedhq Organization -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// - -#pragma once - -// appleseed.renderer headers. -#include "renderer/global/globallogger.h" -#include "renderer/kernel/shading/shadingpoint.h" -#include "renderer/kernel/texturing/oiiotexturesystem.h" - -// appleseed.foundation headers. -#include "foundation/image/color.h" -#include "foundation/image/colorspace.h" -#include "foundation/math/vector.h" -#include "foundation/platform/compiler.h" -#include "foundation/string/string.h" -#include "foundation/utility/foreach.h" - -// SeExpr headers. -#pragma warning (push) -#pragma warning (disable : 4267) // conversion from 'size_t' to 'int', possible loss of data -#include "SeExpression.h" -#include "SeExprFunc.h" -#include "SeExprNode.h" -#pragma warning (pop) - -// Boost headers. -#include "boost/ptr_container/ptr_vector.hpp" - -// Standard headers. -#include -#include - -namespace renderer -{ - -inline bool texture_is_srgb(const OIIO::ustring& filename) -{ - return filename.rfind(".exr") != filename.length() - 4; -} - - -// -// TextureSeExprFunc class. -// - -class TextureSeExprFunc - : public SeExprFuncX -{ - public: - TextureSeExprFunc() - : SeExprFuncX(true) // true = thread-safe - , m_texture_system(nullptr) - , m_texture_is_srgb(true) - { - m_texture_options.swrap = OIIO::TextureOpt::WrapPeriodic; - m_texture_options.twrap = OIIO::TextureOpt::WrapPeriodic; - } - - void set_texture_system(OIIOTextureSystem* texture_system) - { - m_texture_system = texture_system; - } - - bool prep( - SeExprFuncNode* node, - bool /*wantVec*/) override - { - if (node->nargs() != 3) - { - node->addError("3 arguments expected."); - return false; - } - - if (!node->isStrArg(0)) - { - node->addError("First argument must be a texture file path."); - return false; - } - - if (node->getStrArg(0).empty()) - { - node->addError("Path to texture file is empty."); - return false; - } - - if (!node->child(1)->prep(0) || !node->child(2)->prep(0)) - return false; - - m_texture_filename = OIIO::ustring(node->getStrArg(0), 0); - m_texture_is_srgb = texture_is_srgb(m_texture_filename); - - return true; - } - - void eval( - const SeExprFuncNode* node, - SeVec3d& result) const override - { - SeVec3d u, v; - node->child(1)->eval(u); - node->child(2)->eval(v); - - foundation::Color3f color; - if (!m_texture_system->texture( - m_texture_filename, - m_texture_options, - static_cast(u[0]), - static_cast(v[0]), - 0.0f, - 0.0f, - 0.0f, - 0.0f, - 3, - &color[0])) - { - // Failed to find or open the texture. - const std::string message = m_texture_system->geterror(); - if (!message.empty()) - { - const std::string modified_message = - foundation::prefix_all_lines(foundation::trim_both(message), "oiio: "); - RENDERER_LOG_ERROR("%s", modified_message.c_str()); - } - result = SeVec3d(1.0, 0.0, 1.0); - return; - } - - // Colors in SeExpr are always in the sRGB color space. - if (!m_texture_is_srgb) - color = foundation::linear_rgb_to_srgb(color); - - result = SeVec3d(color[0], color[1], color[2]); - } - - private: - OIIOTextureSystem* m_texture_system; - OIIO::ustring m_texture_filename; - mutable OIIO::TextureOpt m_texture_options; - bool m_texture_is_srgb; -}; - - -// -// SeAppleseedExpr class. -// - -class SeAppleseedExpr - : public SeExpression -{ - public: - SeAppleseedExpr() - { - } - - SeAppleseedExpr(const std::string& expr) - : SeExpression(expr) - { - reset_vars(); - } - - void set_expr(const std::string& expr) - { - SeExpression::setExpr(expr); - reset_vars(); - } - - // Called during preparation. - SeExprVarRef* resolveVar(const std::string& name) const override - { - assert(name.length() >= 1); - - if (name[0] == 'u') - return &m_u_var; - else if (name[0] == 'v') - return &m_v_var; - else return SeExpression::resolveVar(name); - } - - // Called during preparation. - SeExprFunc* resolveFunc(const std::string& name) const override - { - if (name == "texture") - { - TextureSeExprFunc* texture_function_x = new TextureSeExprFunc(); - SeExprFunc* texture_function = new SeExprFunc(*texture_function_x, 3, 3); - m_functions_x.push_back(texture_function_x); - m_functions.push_back(texture_function); - return texture_function; - } - - return SeExpression::resolveFunc(name); - } - - foundation::Color3d update_and_evaluate( - const ShadingPoint& shading_point, - OIIOTextureSystem& texture_system) - { - for (foundation::each> i = m_functions_x; i; ++i) - i->set_texture_system(&texture_system); - - const foundation::Vector2f& uv = shading_point.get_uv(0); - m_u_var.m_val = uv[0]; - m_v_var.m_val = uv[1]; - - const SeVec3d result = evaluate(); - return foundation::Color3d(result[0], result[1], result[2]); - } - - private: - void reset_vars() const - { - m_u_var.m_val = 0.0; - m_v_var.m_val = 0.0; - } - - struct Var - : public SeExprScalarVarRef - { - double m_val; - - Var() {} - - explicit Var(const double val) - : m_val(val) - { - } - - void eval(const SeExprVarNode* /*node*/, SeVec3d& result) override - { - result[0] = m_val; - } - }; - - mutable Var m_u_var; - mutable Var m_v_var; - mutable boost::ptr_vector m_functions_x; - mutable boost::ptr_vector m_functions; -}; - -} // namespace renderer