Compare commits

..

1 Commits

736 changed files with 11374 additions and 13585 deletions

View File

@@ -612,6 +612,12 @@ if(WIN32)
option(WITH_WINDOWS_FIND_MODULES "Use find_package to locate libraries" OFF)
mark_as_advanced(WITH_WINDOWS_FIND_MODULES)
option(WINDOWS_USE_VISUAL_STUDIO_PROJECT_FOLDERS "Organize the visual studio projects according to source folder structure." ON)
mark_as_advanced(WINDOWS_USE_VISUAL_STUDIO_PROJECT_FOLDERS)
option(WINDOWS_USE_VISUAL_STUDIO_SOURCE_FOLDERS "Organize the source files in filters matching the source folders." ON)
mark_as_advanced(WINDOWS_USE_VISUAL_STUDIO_SOURCE_FOLDERS)
option(WINDOWS_PYTHON_DEBUG "Include the files needed for debugging python scripts with visual studio 2017+." OFF)
mark_as_advanced(WINDOWS_PYTHON_DEBUG)
@@ -629,18 +635,6 @@ if(WIN32)
endif()
if(WIN32 OR XCODE)
option(IDE_GROUP_SOURCES_IN_FOLDERS "Organize the source files in filters matching the source folders." ON)
mark_as_advanced(IDE_GROUP_SOURCES_IN_FOLDERS)
option(IDE_GROUP_PROJECTS_IN_FOLDERS "Organize the projects according to source folder structure." ON)
mark_as_advanced(IDE_GROUP_PROJECTS_IN_FOLDERS)
if (IDE_GROUP_PROJECTS_IN_FOLDERS)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
endif()
endif()
if(UNIX)
# See WITH_WINDOWS_SCCACHE for Windows.
option(WITH_COMPILER_CCACHE "Use ccache to improve rebuild times (Works with Ninja, Makefiles and Xcode)" OFF)
@@ -1598,10 +1592,6 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNUSED_PARAMETER -Wunused-parameter)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_ALL -Wall)
# Designated initializer is a C++20 feature & breaks MSVC build. Dropping MSVC 2019 or
# updating to C++20 allows removing this.
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_CXX20_DESIGNATOR -Wc++20-designator)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_AUTOLOGICAL_COMPARE -Wno-tautological-compare)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts)

View File

@@ -84,7 +84,7 @@ include(cmake/openimageio.cmake)
include(cmake/tiff.cmake)
if(WIN32)
include(cmake/flexbison.cmake)
elseif(UNIX AND NOT APPLE)
else()
include(cmake/flex.cmake)
endif()
include(cmake/osl.cmake)

View File

@@ -29,13 +29,13 @@ elseif(APPLE)
if("${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "arm64")
set(ISPC_EXTRA_ARGS_APPLE
-DBISON_EXECUTABLE=/opt/homebrew/opt/bison/bin/bison
-DFLEX_EXECUTABLE=/opt/homebrew/opt/flex/bin/flex
-DFLEX_EXECUTABLE=${LIBDIR}/flex/bin/flex
-DARM_ENABLED=On
)
else()
set(ISPC_EXTRA_ARGS_APPLE
-DBISON_EXECUTABLE=/usr/local/opt/bison/bin/bison
-DFLEX_EXECUTABLE=/usr/local/opt/flex/bin/flex
-DFLEX_EXECUTABLE=${LIBDIR}/flex/bin/flex
-DARM_ENABLED=Off
)
endif()
@@ -84,7 +84,7 @@ if(WIN32)
external_ispc
external_flexbison
)
elseif(UNIX AND NOT APPLE)
else()
add_dependencies(
external_ispc
external_flex

View File

@@ -16,18 +16,12 @@
#
# ***** END GPL LICENSE BLOCK *****
if(APPLE)
set(OPENMP_PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/openmp/src/external_openmp < ${PATCH_DIR}/openmp.diff)
else()
set(OPENMP_PATCH_COMMAND)
endif()
ExternalProject_Add(external_openmp
URL file://${PACKAGE_DIR}/${OPENMP_FILE}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH ${OPENMP_HASH_TYPE}=${OPENMP_HASH}
PREFIX ${BUILD_DIR}/openmp
PATCH_COMMAND ${OPENMP_PATCH_COMMAND}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openmp ${DEFAULT_CMAKE_FLAGS}
INSTALL_COMMAND cd ${BUILD_DIR}/openmp/src/external_openmp-build && install_name_tool -id @rpath/libomp.dylib runtime/src/libomp.dylib && make install
INSTALL_DIR ${LIBDIR}/openmp

View File

@@ -96,7 +96,7 @@ if(WIN32)
external_osl
external_flexbison
)
elseif(UNIX AND NOT APPLE)
else()
add_dependencies(
external_osl
external_flex

View File

@@ -23,7 +23,7 @@ set(PNG_EXTRA_ARGS
)
if(BLENDER_PLATFORM_ARM)
set(PNG_EXTRA_ARGS ${PNG_EXTRA_ARGS} -DPNG_HARDWARE_OPTIMIZATIONS=ON -DPNG_ARM_NEON=on -DCMAKE_SYSTEM_PROCESSOR="aarch64")
set(PNG_EXTRA_ARGS ${PNG_EXTRA_ARGS} -DPNG_HARDWARE_OPTIMIZATIONS=ON -DPNG_ARM_NEON=ON -DCMAKE_SYSTEM_PROCESSOR="aarch64")
endif()
ExternalProject_Add(external_png

View File

@@ -158,18 +158,10 @@ set(LLVM_HASH 5a4fab4d7fc84aefffb118ac2c8a4fc0)
set(LLVM_HASH_TYPE MD5)
set(LLVM_FILE llvm-project-${LLVM_VERSION}.src.tar.xz)
if(APPLE)
# Cloth physics test is crashing due to this bug:
# https://bugs.llvm.org/show_bug.cgi?id=50579
set(OPENMP_VERSION 9.0.1)
set(OPENMP_HASH 6eade16057edbdecb3c4eef9daa2bfcf)
else()
set(OPENMP_VERSION ${LLVM_VERSION})
set(OPENMP_HASH ac48ce3e4582ccb82f81ab59eb3fc9dc)
endif()
set(OPENMP_URI https://github.com/llvm/llvm-project/releases/download/llvmorg-${OPENMP_VERSION}/openmp-${OPENMP_VERSION}.src.tar.xz)
set(OPENMP_URI https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VERSION}/openmp-${LLVM_VERSION}.src.tar.xz)
set(OPENMP_HASH ac48ce3e4582ccb82f81ab59eb3fc9dc)
set(OPENMP_HASH_TYPE MD5)
set(OPENMP_FILE openmp-${OPENMP_VERSION}.src.tar.xz)
set(OPENMP_FILE openmp-${LLVM_VERSION}.src.tar.xz)
set(OPENIMAGEIO_VERSION 2.2.15.1)
set(OPENIMAGEIO_URI https://github.com/OpenImageIO/oiio/archive/Release-${OPENIMAGEIO_VERSION}.tar.gz)

View File

@@ -1019,7 +1019,7 @@ PRINT ""
PYTHON_SOURCE=( "https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tgz" )
_boost_version_nodots=`echo "$BOOST_VERSION" | sed -r 's/\./_/g'`
BOOST_SOURCE=( "https://boostorg.jfrog.io/artifactory/main/release/$BOOST_VERSION/source/boost_$_boost_version_nodots.tar.bz2" )
BOOST_SOURCE=( "https://dl.bintray.com/boostorg/release/$BOOST_VERSION/source/boost_$_boost_version_nodots.tar.bz2" )
BOOST_BUILD_MODULES="--with-system --with-filesystem --with-thread --with-regex --with-locale --with-date_time --with-wave --with-iostreams --with-python --with-program_options --with-serialization --with-atomic"
TBB_SOURCE=( "https://github.com/oneapi-src/oneTBB/archive/$TBB_VERSION$TBB_VERSION_UPDATE.tar.gz" )

View File

@@ -1,23 +0,0 @@
diff --git a/runtime/src/z_Linux_asm.S b/runtime/src/z_Linux_asm.S
index 0d8885e..42aa5ad 100644
--- a/runtime/src/z_Linux_asm.S
+++ b/runtime/src/z_Linux_asm.S
@@ -1540,10 +1540,12 @@ __kmp_unnamed_critical_addr:
.comm .gomp_critical_user_,32,8
.data
.align 8
- .global __kmp_unnamed_critical_addr
-__kmp_unnamed_critical_addr:
+ .global ___kmp_unnamed_critical_addr
+___kmp_unnamed_critical_addr:
.8byte .gomp_critical_user_
- .size __kmp_unnamed_critical_addr,8
+# if !(KMP_OS_DARWIN)
+ .size ___kmp_unnamed_critical_addr,8
+# endif
#endif /* KMP_ARCH_PPC64 || KMP_ARCH_AARCH64 */
#if KMP_OS_LINUX

View File

@@ -1,66 +0,0 @@
# - Find Zstd library
# Find the native Zstd includes and library
# This module defines
# ZSTD_INCLUDE_DIRS, where to find zstd.h, Set when
# ZSTD_INCLUDE_DIR is found.
# ZSTD_LIBRARIES, libraries to link against to use Zstd.
# ZSTD_ROOT_DIR, The base directory to search for Zstd.
# This can also be an environment variable.
# ZSTD_FOUND, If false, do not try to use Zstd.
#
# also defined, but not for general use are
# ZSTD_LIBRARY, where to find the Zstd library.
#=============================================================================
# Copyright 2019 Blender Foundation.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# If ZSTD_ROOT_DIR was defined in the environment, use it.
IF(NOT ZSTD_ROOT_DIR AND NOT $ENV{ZSTD_ROOT_DIR} STREQUAL "")
SET(ZSTD_ROOT_DIR $ENV{ZSTD_ROOT_DIR})
ENDIF()
SET(_zstd_SEARCH_DIRS
${ZSTD_ROOT_DIR}
)
FIND_PATH(ZSTD_INCLUDE_DIR
NAMES
zstd.h
HINTS
${_zstd_SEARCH_DIRS}
PATH_SUFFIXES
include
)
FIND_LIBRARY(ZSTD_LIBRARY
NAMES
zstd
HINTS
${_zstd_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
# handle the QUIETLY and REQUIRED arguments and set ZSTD_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Zstd DEFAULT_MSG
ZSTD_LIBRARY ZSTD_INCLUDE_DIR)
IF(ZSTD_FOUND)
SET(ZSTD_LIBRARIES ${ZSTD_LIBRARY})
SET(ZSTD_INCLUDE_DIRS ${ZSTD_INCLUDE_DIR})
ENDIF()
MARK_AS_ADVANCED(
ZSTD_INCLUDE_DIR
ZSTD_LIBRARY
)

View File

@@ -208,7 +208,7 @@ function(blender_source_group
)
# if enabled, use the sources directories as filters.
if(IDE_GROUP_SOURCES_IN_FOLDERS)
if(WINDOWS_USE_VISUAL_STUDIO_SOURCE_FOLDERS)
foreach(_SRC ${sources})
# remove ../'s
get_filename_component(_SRC_DIR ${_SRC} REALPATH)
@@ -240,8 +240,8 @@ function(blender_source_group
endforeach()
endif()
# if enabled, set the FOLDER property for the projects
if(IDE_GROUP_PROJECTS_IN_FOLDERS)
# if enabled, set the FOLDER property for visual studio projects
if(WINDOWS_USE_VISUAL_STUDIO_PROJECT_FOLDERS)
get_filename_component(FolderDir ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY)
string(REPLACE ${CMAKE_SOURCE_DIR} "" FolderDir ${FolderDir})
set_target_properties(${name} PROPERTIES FOLDER ${FolderDir})

View File

@@ -441,9 +441,6 @@ if(WITH_HARU)
endif()
endif()
set(ZSTD_ROOT_DIR ${LIBDIR}/zstd)
find_package(Zstd REQUIRED)
if(EXISTS ${LIBDIR})
without_system_libs_end()
endif()
@@ -503,10 +500,17 @@ endif()
# makesdna, tests, etc.), we add an rpath to the OpenMP library dir through
# CMAKE_BUILD_RPATH. This avoids having to make many copies of the dylib next to each binary.
#
# For the installed Python module and installed Blender executable, CMAKE_INSTALL_RPATH
# is modified to find the dylib in an adjacent folder. Install step puts the libraries there.
# For the installed Blender executable, CMAKE_INSTALL_RPATH will be used
# to locate the dylibs at @executable_path, next to the Blender executable.
#
# For the installed Python module, CMAKE_INSTALL_RPATH is modified to find the
# dylib in an adjacent folder.
set(CMAKE_SKIP_BUILD_RPATH FALSE)
list(APPEND CMAKE_BUILD_RPATH "${OpenMP_LIBRARY_DIR}")
set(CMAKE_SKIP_INSTALL_RPATH FALSE)
list(APPEND CMAKE_INSTALL_RPATH "@loader_path/../Resources/${BLENDER_VERSION}/lib")
list(APPEND CMAKE_INSTALL_RPATH "@executable_path")
if(WITH_PYTHON_MODULE)
list(APPEND CMAKE_INSTALL_RPATH "@loader_path/../Resources/${BLENDER_VERSION}/lib")
endif()

View File

@@ -99,7 +99,6 @@ endif()
find_package_wrapper(JPEG REQUIRED)
find_package_wrapper(PNG REQUIRED)
find_package_wrapper(ZLIB REQUIRED)
find_package_wrapper(Zstd REQUIRED)
find_package_wrapper(Freetype REQUIRED)
if(WITH_PYTHON)

View File

@@ -57,6 +57,8 @@ if(CMAKE_C_COMPILER_ID MATCHES "Clang")
endif()
endif()
set_property(GLOBAL PROPERTY USE_FOLDERS ${WINDOWS_USE_VISUAL_STUDIO_PROJECT_FOLDERS})
if(NOT WITH_PYTHON_MODULE)
set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT blender)
endif()
@@ -873,6 +875,3 @@ if(WITH_HARU)
set(WITH_HARU OFF)
endif()
endif()
set(ZSTD_INCLUDE_DIRS ${LIBDIR}/zstd/include)
set(ZSTD_LIBRARIES ${LIBDIR}/zstd/lib/zstd_static.lib)

View File

@@ -1,4 +1,4 @@
set SOURCEDIR=%BLENDER_DIR%/doc/python_api/sphinx-in
set SOURCEDIR=%BLENDER_DIR%/doc/python_api/sphinx-in
set BUILDDIR=%BLENDER_DIR%/doc/python_api/sphinx-out
if "%BF_LANG%" == "" set BF_LANG=en
set SPHINXOPTS=-j auto -D language=%BF_LANG%
@@ -29,6 +29,6 @@ exit /b 1
--background -noaudio --factory-startup ^
--python %BLENDER_DIR%/doc/python_api/sphinx_doc_gen.py
"%SPHINX_BIN%" -b html %SPHINXOPTS% %O% %SOURCEDIR% %BUILDDIR%
%SPHINX_BIN% -b html %SPHINXOPTS% %O% %SOURCEDIR% %BUILDDIR%
:EOF

View File

@@ -9,8 +9,14 @@ if EXIST "%SPHINX_BIN%" (
goto detect_sphinx_done
)
REM Finally see if it is perhaps installed at the default location
set SPHINX_BIN=%ProgramFiles%\Inkscape\bin\inkscape.exe
if EXIST "%SPHINX_BIN%" (
goto detect_sphinx_done
)
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINX_BIN environment variable to point
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.

View File

@@ -33,7 +33,7 @@ echo - 2019b ^(build with visual studio 2019 Build Tools^)
echo.
echo Documentation Targets ^(Not associated with building^)
echo - doc_py ^(Generate sphinx python api docs^)
echo -doc_py ^(Generate sphinx python api docs^)
echo.
echo Experimental options

View File

@@ -123,7 +123,7 @@ def Align(handle):
class BlendFile:
'''
Reads a blendfile and store the header, all the fileblocks, and catalogue
structs found in the DNA fileblock
structs foound in the DNA fileblock
- BlendFile.Header (BlendFileHeader instance)
- BlendFile.Blocks (list of BlendFileBlock instances)

View File

@@ -1,13 +1,13 @@
sphinx==4.1.1
sphinx==3.5.4
# Sphinx dependencies that are important
Jinja2==3.0.1
Pygments==2.10.0
docutils==0.17.1
Jinja2==2.11.3
Pygments==2.9.0
docutils==0.16
snowballstemmer==2.1.0
babel==2.9.1
requests==2.26.0
requests==2.25.1
# Only needed to match the theme used for the official documentation.
# Without this theme, the default theme will be used.
sphinx_rtd_theme==1.0.0rc1
sphinx_rtd_theme==0.5.2

View File

@@ -254,8 +254,6 @@ else:
"gpu.shader",
"gpu.state",
"gpu.texture",
"gpu.platform",
"gpu.capabilities",
"gpu_extras",
"idprop.types",
"mathutils",
@@ -1049,7 +1047,7 @@ context_type_map = {
"annotation_data": ("GreasePencil", False),
"annotation_data_owner": ("ID", False),
"armature": ("Armature", False),
"asset_library_ref": ("AssetLibraryReference", False),
"asset_library": ("AssetLibraryReference", False),
"bone": ("Bone", False),
"brush": ("Brush", False),
"camera": ("Camera", False),
@@ -2002,8 +2000,6 @@ def write_rst_importable_modules(basepath):
"gpu.shader": "GPU Shader Utilities",
"gpu.state": "GPU State Utilities",
"gpu.texture": "GPU Texture Utilities",
"gpu.platform": "GPU Platform Utilities",
"gpu.capabilities": "GPU Capabilities Utilities",
"bmesh": "BMesh Module",
"bmesh.ops": "BMesh Operators",
"bmesh.types": "BMesh Types",

View File

@@ -86,7 +86,6 @@ AUD_API AUD_SoundInfo AUD_getInfo(AUD_Sound* sound)
info.specs.channels = AUD_CHANNELS_INVALID;
info.specs.rate = AUD_RATE_INVALID;
info.length = 0.0f;
info.start_offset = 0.0f;
try
{
@@ -96,7 +95,6 @@ AUD_API AUD_SoundInfo AUD_getInfo(AUD_Sound* sound)
{
info.specs = convSpecToC(reader->getSpecs());
info.length = reader->getLength() / (float) info.specs.rate;
info.start_offset = reader->getStartOffset();
}
}
catch(Exception&)
@@ -247,7 +245,7 @@ AUD_API int AUD_readSound(AUD_Sound* sound, float* buffer, int length, int sampl
buffer[i * 3] = min;
buffer[i * 3 + 1] = max;
buffer[i * 3 + 2] = sqrt(power / len); // RMS
buffer[i * 3 + 2] = sqrt(power) / len;
if(overallmax < max)
overallmax = max;

View File

@@ -176,5 +176,4 @@ typedef struct
{
AUD_Specs specs;
float length;
double start_offset;
} AUD_SoundInfo;

View File

@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
import sys
import os

View File

@@ -70,12 +70,6 @@ public:
*/
virtual int getPosition() const=0;
/**
* Returns the start offset the sound should have to line up with related sources.
* \return The required start offset in seconds.
*/
virtual double getStartOffset() const { return 0.0;}
/**
* Returns the specification of the reader.
* \return The Specs structure.

View File

@@ -67,4 +67,4 @@ public:
virtual void read(int& length, bool& eos, sample_t* buffer);
};
AUD_NAMESPACE_END
AUD_NAMESPACE_END

View File

@@ -68,7 +68,7 @@ int FFMPEGReader::decode(AVPacket& packet, Buffer& buffer)
for(int i = 0; i < m_frame->nb_samples; i++)
{
std::memcpy(((data_t*)buffer.getBuffer()) + buf_pos + ((m_codecCtx->channels * i) + channel) * single_size,
m_frame->data[channel] + i * single_size, single_size);
m_frame->data[channel] + i * single_size, single_size);
}
}
}
@@ -109,7 +109,7 @@ int FFMPEGReader::decode(AVPacket& packet, Buffer& buffer)
for(int i = 0; i < m_frame->nb_samples; i++)
{
std::memcpy(((data_t*)buffer.getBuffer()) + buf_pos + ((m_codecCtx->channels * i) + channel) * single_size,
m_frame->data[channel] + i * single_size, single_size);
m_frame->data[channel] + i * single_size, single_size);
}
}
}
@@ -126,10 +126,7 @@ int FFMPEGReader::decode(AVPacket& packet, Buffer& buffer)
void FFMPEGReader::init()
{
m_position = 0;
m_start_offset = 0.0f;
m_pkgbuf_left = 0;
m_st_time = 0;
m_duration = 0;
if(avformat_find_stream_info(m_formatCtx, nullptr) < 0)
AUD_THROW(FileException, "File couldn't be read, ffmpeg couldn't find the stream info.");
@@ -137,41 +134,15 @@ void FFMPEGReader::init()
// find audio stream and codec
m_stream = -1;
double dur_sec = 0;
for(unsigned int i = 0; i < m_formatCtx->nb_streams; i++)
{
#ifdef FFMPEG_OLD_CODE
if(m_formatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO)
if((m_formatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO)
#else
if(m_formatCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
if((m_formatCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
#endif
&& (m_stream < 0))
{
AVStream *audio_stream = m_formatCtx->streams[i];
double audio_timebase = av_q2d(audio_stream->time_base);
if (audio_stream->start_time != AV_NOPTS_VALUE)
{
m_st_time = audio_stream->start_time;
}
int64_t ctx_start_time = 0;
if (m_formatCtx->start_time != AV_NOPTS_VALUE) {
ctx_start_time = m_formatCtx->start_time;
}
m_start_offset = m_st_time * audio_timebase - (double)ctx_start_time / AV_TIME_BASE;
if(audio_stream->duration != AV_NOPTS_VALUE)
{
dur_sec = audio_stream->duration * audio_timebase;
}
else
{
/* If the audio starts after the stream start time, subract this from the total duration. */
dur_sec = (double)m_formatCtx->duration / AV_TIME_BASE - m_start_offset;
}
m_stream=i;
break;
}
@@ -242,7 +213,6 @@ void FFMPEGReader::init()
}
m_specs.rate = (SampleRate) m_codecCtx->sample_rate;
m_duration = lround(dur_sec * m_codecCtx->sample_rate);
}
FFMPEGReader::FFMPEGReader(std::string filename) :
@@ -368,17 +338,21 @@ void FFMPEGReader::seek(int position)
{
if(position >= 0)
{
double pts_time_base =
av_q2d(m_formatCtx->streams[m_stream]->time_base);
uint64_t st_time = m_formatCtx->start_time;
uint64_t seek_pos = ((uint64_t)position) * ((uint64_t)AV_TIME_BASE) / ((uint64_t)m_specs.rate);
uint64_t seek_pts = (((uint64_t)position) / ((uint64_t)m_specs.rate)) / pts_time_base;
if(m_st_time != AV_NOPTS_VALUE) {
seek_pts += m_st_time;
if(st_time != AV_NOPTS_VALUE) {
seek_pos += st_time;
}
double pts_time_base =
av_q2d(m_formatCtx->streams[m_stream]->time_base);
uint64_t pts_st_time =
((st_time != AV_NOPTS_VALUE) ? st_time : 0)
/ pts_time_base / (uint64_t) AV_TIME_BASE;
// a value < 0 tells us that seeking failed
if(av_seek_frame(m_formatCtx, m_stream, seek_pts,
if(av_seek_frame(m_formatCtx, -1, seek_pos,
AVSEEK_FLAG_BACKWARD | AVSEEK_FLAG_ANY) >= 0)
{
avcodec_flush_buffers(m_codecCtx);
@@ -400,7 +374,7 @@ void FFMPEGReader::seek(int position)
if(packet.pts != AV_NOPTS_VALUE)
{
// calculate real position, and read to frame!
m_position = (packet.pts - m_st_time) * pts_time_base * m_specs.rate;
m_position = (packet.pts - pts_st_time) * pts_time_base * m_specs.rate;
if(m_position < position)
{
@@ -431,7 +405,8 @@ void FFMPEGReader::seek(int position)
int FFMPEGReader::getLength() const
{
// return approximated remaning size
return m_duration - m_position;
return (int)((m_formatCtx->duration * m_codecCtx->sample_rate)
/ AV_TIME_BASE)-m_position;
}
int FFMPEGReader::getPosition() const
@@ -439,11 +414,6 @@ int FFMPEGReader::getPosition() const
return m_position;
}
double FFMPEGReader::getStartOffset() const
{
return m_start_offset;
}
Specs FFMPEGReader::getSpecs() const
{
return m_specs.specs;
@@ -480,13 +450,11 @@ void FFMPEGReader::read(int& length, bool& eos, sample_t* buffer)
// decode the package
pkgbuf_pos = decode(packet, m_pkgbuf);
if (packet.pts >= m_st_time) {
// copy to output buffer
data_size = std::min(pkgbuf_pos, left * sample_size);
m_convert((data_t*) buf, (data_t*) m_pkgbuf.getBuffer(), data_size / AUD_FORMAT_SIZE(m_specs.format));
buf += data_size / AUD_FORMAT_SIZE(m_specs.format);
left -= data_size / sample_size;
}
// copy to output buffer
data_size = std::min(pkgbuf_pos, left * sample_size);
m_convert((data_t*) buf, (data_t*) m_pkgbuf.getBuffer(), data_size / AUD_FORMAT_SIZE(m_specs.format));
buf += data_size / AUD_FORMAT_SIZE(m_specs.format);
left -= data_size / sample_size;
}
av_packet_unref(&packet);
}

View File

@@ -54,22 +54,6 @@ private:
*/
int m_position;
/**
* The start offset in seconds relative to the media container start time.
* IE how much the sound should be delayed to be kept in sync with the rest of the containter streams.
*/
double m_start_offset;
/**
* The start time pts of the stream. All packets before this timestamp shouldn't be played back (only decoded).
*/
int64_t m_st_time;
/**
* The duration of the audio stream in samples.
*/
int64_t m_duration;
/**
* The specification of the audio data.
*/
@@ -198,7 +182,6 @@ public:
virtual void seek(int position);
virtual int getLength() const;
virtual int getPosition() const;
virtual double getStartOffset() const;
virtual Specs getSpecs() const;
virtual void read(int& length, bool& eos, sample_t* buffer);
};

View File

@@ -32,24 +32,17 @@ void PulseAudioDevice::PulseAudio_state_callback(pa_context *context, void *data
device->m_state = AUD_pa_context_get_state(context);
}
void PulseAudioDevice::PulseAudio_request(pa_stream *stream, size_t total_bytes, void *data)
void PulseAudioDevice::PulseAudio_request(pa_stream *stream, size_t num_bytes, void *data)
{
PulseAudioDevice* device = (PulseAudioDevice*)data;
void* buffer;
while(total_bytes > 0)
{
size_t num_bytes = total_bytes;
AUD_pa_stream_begin_write(stream, &buffer, &num_bytes);
AUD_pa_stream_begin_write(stream, &buffer, &num_bytes);
device->mix((data_t*)buffer, num_bytes / AUD_DEVICE_SAMPLE_SIZE(device->m_specs));
device->mix((data_t*)buffer, num_bytes / AUD_DEVICE_SAMPLE_SIZE(device->m_specs));
AUD_pa_stream_write(stream, buffer, num_bytes, nullptr, 0, PA_SEEK_RELATIVE);
total_bytes -= num_bytes;
}
AUD_pa_stream_write(stream, buffer, num_bytes, nullptr, 0, PA_SEEK_RELATIVE);
}
void PulseAudioDevice::PulseAudio_underflow(pa_stream *stream, void *data)
@@ -103,6 +96,7 @@ void PulseAudioDevice::runMixingThread()
PulseAudioDevice::PulseAudioDevice(std::string name, DeviceSpecs specs, int buffersize) :
m_state(PA_CONTEXT_UNCONNECTED),
m_buffersize(buffersize),
m_underflows(0)
{
m_mainloop = AUD_pa_mainloop_new();
@@ -193,9 +187,6 @@ PulseAudioDevice::PulseAudioDevice(std::string name, DeviceSpecs specs, int buff
AUD_pa_stream_set_write_callback(m_stream, PulseAudio_request, this);
AUD_pa_stream_set_underflow_callback(m_stream, PulseAudio_underflow, this);
buffersize *= AUD_DEVICE_SAMPLE_SIZE(m_specs);
m_buffersize = buffersize;
pa_buffer_attr buffer_attr;
buffer_attr.fragsize = -1U;

View File

@@ -59,7 +59,7 @@ private:
* \param num_bytes The length in bytes to be supplied.
* \param data The PulseAudio device.
*/
AUD_LOCAL static void PulseAudio_request(pa_stream* stream, size_t total_bytes, void* data);
AUD_LOCAL static void PulseAudio_request(pa_stream* stream, size_t num_bytes, void* data);
/**
* Reports an underflow from the PulseAudio server.

View File

@@ -57,4 +57,4 @@ void VolumeReader::read(int& length, bool& eos, sample_t* buffer)
buffer[i] = buffer[i] * m_volumeStorage->getVolume();
}
AUD_NAMESPACE_END
AUD_NAMESPACE_END

View File

@@ -1,7 +0,0 @@
Project: NanoSVG
URL: https://github.com/memononen/nanosvg
License: zlib
Upstream version:
Local modifications: Added some functionality to manage grease pencil layers
Added a fix to SVG import arc and float errors (https://developer.blender.org/rB11dc674c78b49fc4e0b7c134c375b6c8b8eacbcc)

View File

@@ -1,86 +0,0 @@
diff --git a/c:/tmp/nanosvg_original.h b/c:/tmp/nanosvg_modif.h
index 24a01a86d3d..eca0d07e79d 100644
--- a/c:/tmp/nanosvg_original.h
+++ b/c:/tmp/nanosvg_modif.h
@@ -24,7 +24,8 @@
*
* Bounding box calculation based on http://blog.hackers-cafe.net/2009/06/how-to-calculate-bezier-curves-bounding.html
*
- */
+ * This is a modified version for Blender used by importers.
+ **/
#ifndef NANOSVG_H
#define NANOSVG_H
@@ -148,6 +149,8 @@ extern "C" {
typedef struct NSVGshape
{
char id[64]; // Optional 'id' attr of the shape or its group
+ /* Blender: Parent ID used for layer creation. */
+ char id_parent[64];
NSVGpaint fill; // Fill paint
NSVGpaint stroke; // Stroke paint
float opacity; // Opacity of the shape.
@@ -370,6 +373,7 @@ int nsvg__parseXML(char* input,
/* Simple SVG parser. */
#define NSVG_MAX_ATTR 128
+#define NSVG_MAX_BREADCRUMB 5
enum NSVGgradientUnits
{
@@ -471,6 +475,10 @@ typedef struct NSVGparser
float dpi;
char pathFlag;
char defsFlag;
+ /** Blender breadcrumb for layers. */
+ char breadcrumb[NSVG_MAX_BREADCRUMB][64];
+ /** Blender number of elements in breadcrumb. */
+ int breadcrumb_len;
} NSVGparser;
static void nsvg__xformIdentity(float* t)
@@ -980,6 +988,14 @@ static void nsvg__addShape(NSVGparser* p)
memset(shape, 0, sizeof(NSVGshape));
memcpy(shape->id, attr->id, sizeof shape->id);
+ /* Copy parent id from breadcrumb. */
+ if (p->breadcrumb_len > 0) {
+ memcpy(shape->id_parent, p->breadcrumb[0], sizeof shape->id_parent);
+ }
+ else {
+ memcpy(shape->id_parent, attr->id, sizeof shape->id_parent);
+ }
+
scale = nsvg__getAverageScale(attr->xform);
shape->strokeWidth = attr->strokeWidth * scale;
shape->strokeDashOffset = attr->strokeDashOffset * scale;
@@ -2814,6 +2830,14 @@ static void nsvg__startElement(void* ud, const char* el, const char** attr)
if (strcmp(el, "g") == 0) {
nsvg__pushAttr(p);
nsvg__parseAttribs(p, attr);
+
+ /* Save the breadcrumb of groups. */
+ if (p->breadcrumb_len < NSVG_MAX_BREADCRUMB) {
+ NSVGattrib *attr_id = nsvg__getAttr(p);
+ memcpy(
+ p->breadcrumb[p->breadcrumb_len], attr_id->id, sizeof(p->breadcrumb[p->breadcrumb_len]));
+ p->breadcrumb_len++;
+ }
}
else if (strcmp(el, "path") == 0) {
if (p->pathFlag) // Do not allow nested paths.
@@ -2874,7 +2898,12 @@ static void nsvg__endElement(void* ud, const char* el)
NSVGparser* p = (NSVGparser*)ud;
if (strcmp(el, "g") == 0) {
- nsvg__popAttr(p);
+ /* Remove the breadcrumb level. */
+ if (p->breadcrumb_len > 0) {
+ p->breadcrumb[p->breadcrumb_len - 1][0] = '\0';
+ p->breadcrumb_len--;
+ }
+ nsvg__popAttr(p);
}
else if (strcmp(el, "path") == 0) {
p->pathFlag = 0;

View File

@@ -115,16 +115,6 @@ if(WITH_OPENVDB)
)
endif()
if(WITH_ALEMBIC)
add_definitions(-DWITH_ALEMBIC)
list(APPEND INC_SYS
${ALEMBIC_INCLUDE_DIRS}
)
list(APPEND LIB
${ALEMBIC_LIBRARIES}
)
endif()
if(WITH_OPENIMAGEDENOISE)
add_definitions(-DWITH_OPENIMAGEDENOISE)
list(APPEND INC_SYS

View File

@@ -61,7 +61,6 @@ class CyclesRender(bpy.types.RenderEngine):
bl_use_save_buffers = True
bl_use_spherical_stereo = True
bl_use_custom_freestyle = True
bl_use_alembic_procedural = True
def __init__(self):
self.session = None

View File

@@ -227,11 +227,6 @@ def update_render_passes(self, context):
view_layer.update_render_passes()
def update_render_engine(self, context):
scene = context.scene
scene.update_render_engine()
class CyclesRenderSettings(bpy.types.PropertyGroup):
device: EnumProperty(
@@ -245,7 +240,6 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
description="Feature set to use for rendering",
items=enum_feature_set,
default='SUPPORTED',
update=update_render_engine,
)
shading_system: BoolProperty(
name="Open Shading Language",
@@ -408,7 +402,7 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
adaptive_threshold: FloatProperty(
name="Adaptive Sampling Threshold",
description="Noise level step to stop sampling at, lower values reduce noise at the cost of render time. Zero for automatic setting based on number of AA samples",
description="Noise level step to stop sampling at, lower values reduce noise the cost of render time. Zero for automatic setting based on number of AA samples",
min=0.0, max=1.0,
default=0.0,
precision=4,
@@ -808,82 +802,6 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
items=enum_texture_limit
)
use_texture_cache: BoolProperty(
name="Use Texture Cache",
default=False,
description="Enables out-of-core texturing to conserve RAM"
)
texture_cache_size: IntProperty(
name="Texture Cache Size (MB)",
default=1024,
description="The size of the OpenImageIO texture cache in MB",
min=0
)
texture_auto_convert: BoolProperty(
name="Auto Convert Textures",
default=True,
description="Automatically convert textures to .tx files for optimal texture cache performance"
)
texture_accept_unmipped: BoolProperty(
name="Accept Unmipped",
default=True,
description="Texture cached rendering without mip mapping is very expensive. Uncheck to prevent Cycles from using textures that are not mip mapped"
)
texture_accept_untiled: BoolProperty(
name="Accept Untiled",
default=True,
description="Texture cached rendering without tiled textures is very expensive. Uncheck to prevent Cycles from using textures that are not tiled"
)
texture_auto_tile: BoolProperty(
name="Auto Tile",
default=True,
description="On the fly creation of tiled versions of textures that are not tiled. This can increase render time but helps reduce memory usage"
)
texture_auto_mip: BoolProperty(
name="Auto Mip",
default=True,
description="On the fly creation of mip maps of textures that are not mip mapped. This can increase render time but helps reduce memory usage"
)
texture_tile_size: IntProperty(
name="Tile Size",
default=64,
description="The size of tiles that Cycles uses for auto tiling"
)
texture_blur_diffuse: FloatProperty(
name="Diffuse Blur",
default=0.0156,
description="The amount of texture blur applied to diffuse bounces",
min = 0.0, max = 1.0
)
texture_blur_glossy: FloatProperty(
name="Glossy Blur",
default=0.0,
description="The amount of texture blur applied to glossy bounces",
min = 0.0, max = 1.0
)
use_custom_cache_path: BoolProperty(
name="Use Custom Cache Path",
default=False,
description="Use a custom path for the texture cache, as oppoosed to placing cache files next to the original file"
)
custom_cache_path: StringProperty(
name="Custom Cache Path",
default="",
subtype="DIR_PATH",
description="Custom path for the texture cache"
)
use_fast_gi: BoolProperty(
name="Fast GI Approximation",
description="Approximate diffuse indirect light with background tinted ambient occlusion. This provides fast alternative to full global illumination, for interactive viewport rendering or final renders with reduced quality",

View File

@@ -781,40 +781,6 @@ class CYCLES_RENDER_PT_performance_final_render(CyclesButtonsPanel, Panel):
col.prop(rd, "use_save_buffers")
col.prop(rd, "use_persistent_data", text="Persistent Data")
class CYCLES_RENDER_PT_texture_cache(CyclesButtonsPanel, Panel):
bl_label = "Texture Cache"
bl_options = {'DEFAULT_CLOSED'}
def draw_header(self, context):
cscene = context.scene.cycles
self.layout.prop(cscene, "use_texture_cache", text="")
def draw(self, context):
layout = self.layout
scene = context.scene
cscene = scene.cycles
rd = scene.render
layout.active = cscene.use_texture_cache
split = layout.split()
col = split.column()
col.prop(cscene, "texture_auto_convert")
col.prop(cscene, "texture_accept_unmipped")
col.prop(cscene, "texture_accept_untiled")
col.prop(cscene, "texture_auto_mip")
col.prop(cscene, "texture_auto_tile")
col = split.column()
col.prop(cscene, "texture_cache_size")
col.prop(cscene, "texture_tile_size")
col.prop(cscene, "texture_blur_diffuse")
col.prop(cscene, "texture_blur_glossy")
row = layout.row()
row.prop(cscene, "use_custom_cache_path")
row = layout.row()
row.active = cscene.use_custom_cache_path
row.prop(cscene, "custom_cache_path")
class CYCLES_RENDER_PT_performance_viewport(CyclesButtonsPanel, Panel):
bl_label = "Viewport"
@@ -2341,7 +2307,6 @@ classes = (
CYCLES_RENDER_PT_performance_acceleration_structure,
CYCLES_RENDER_PT_performance_final_render,
CYCLES_RENDER_PT_performance_viewport,
CYCLES_RENDER_PT_texture_cache,
CYCLES_RENDER_PT_passes,
CYCLES_RENDER_PT_passes_data,
CYCLES_RENDER_PT_passes_light,

View File

@@ -1038,6 +1038,23 @@ static void create_subd_mesh(Scene *scene,
/* Sync */
static BL::MeshSequenceCacheModifier object_mesh_cache_find(BL::Object &b_ob)
{
if (b_ob.modifiers.length() > 0) {
BL::Modifier b_mod = b_ob.modifiers[b_ob.modifiers.length() - 1];
if (b_mod.type() == BL::Modifier::type_MESH_SEQUENCE_CACHE) {
BL::MeshSequenceCacheModifier mesh_cache = BL::MeshSequenceCacheModifier(b_mod);
if (MeshSequenceCacheModifier_has_velocity_get(&mesh_cache.ptr)) {
return mesh_cache;
}
}
}
return BL::MeshSequenceCacheModifier(PointerRNA_NULL);
}
/* Check whether some of "built-in" motion-related attributes are needed to be exported (includes
* things like velocity from cache modifier, fluid simulation).
*
@@ -1078,7 +1095,7 @@ static void sync_mesh_cached_velocities(BL::Object &b_ob, Scene *scene, Mesh *me
return;
}
BL::MeshSequenceCacheModifier b_mesh_cache = object_mesh_cache_find(b_ob, true, nullptr);
BL::MeshSequenceCacheModifier b_mesh_cache = object_mesh_cache_find(b_ob);
if (!b_mesh_cache) {
return;
@@ -1241,7 +1258,7 @@ void BlenderSync::sync_mesh_motion(BL::Depsgraph b_depsgraph,
}
/* Cached motion blur already exported. */
BL::MeshSequenceCacheModifier mesh_cache = object_mesh_cache_find(b_ob, true, nullptr);
BL::MeshSequenceCacheModifier mesh_cache = object_mesh_cache_find(b_ob);
if (mesh_cache) {
return;
}

View File

@@ -14,7 +14,6 @@
* limitations under the License.
*/
#include "render/alembic.h"
#include "render/camera.h"
#include "render/graph.h"
#include "render/integrator.h"
@@ -485,71 +484,6 @@ bool BlenderSync::sync_object_attributes(BL::DepsgraphObjectInstance &b_instance
/* Object Loop */
void BlenderSync::sync_procedural(BL::Object &b_ob,
BL::MeshSequenceCacheModifier &b_mesh_cache,
bool has_subdivision_modifier)
{
#ifdef WITH_ALEMBIC
BL::CacheFile cache_file = b_mesh_cache.cache_file();
void *cache_file_key = cache_file.ptr.data;
AlembicProcedural *procedural = static_cast<AlembicProcedural *>(
procedural_map.find(cache_file_key));
if (procedural == nullptr) {
procedural = scene->create_node<AlembicProcedural>();
procedural_map.add(cache_file_key, procedural);
}
else {
procedural_map.used(procedural);
}
float current_frame = b_scene.frame_current();
if (cache_file.override_frame()) {
current_frame = cache_file.frame();
}
if (!cache_file.override_frame()) {
procedural->set_start_frame(b_scene.frame_start());
procedural->set_end_frame(b_scene.frame_end());
}
procedural->set_frame(current_frame);
procedural->set_frame_rate(b_scene.render().fps() / b_scene.render().fps_base());
procedural->set_frame_offset(cache_file.frame_offset());
string absolute_path = blender_absolute_path(b_data, b_ob, b_mesh_cache.cache_file().filepath());
procedural->set_filepath(ustring(absolute_path));
procedural->set_scale(cache_file.scale());
procedural->set_use_prefetch(cache_file.use_prefetch());
procedural->set_prefetch_cache_size(cache_file.prefetch_cache_size());
/* create or update existing AlembicObjects */
ustring object_path = ustring(b_mesh_cache.object_path());
AlembicObject *abc_object = procedural->get_or_create_object(object_path);
array<Node *> used_shaders = find_used_shaders(b_ob);
abc_object->set_used_shaders(used_shaders);
PointerRNA cobj = RNA_pointer_get(&b_ob.ptr, "cycles");
const float subd_dicing_rate = max(0.1f, RNA_float_get(&cobj, "dicing_rate") * dicing_rate);
abc_object->set_subd_dicing_rate(subd_dicing_rate);
abc_object->set_subd_max_level(max_subdivisions);
abc_object->set_ignore_subdivision(!has_subdivision_modifier);
if (abc_object->is_modified() || procedural->is_modified()) {
procedural->tag_update(scene);
}
#else
(void)b_ob;
(void)b_mesh_cache;
#endif
}
void BlenderSync::sync_objects(BL::Depsgraph &b_depsgraph,
BL::SpaceView3D &b_v3d,
float motion_time)
@@ -565,7 +499,6 @@ void BlenderSync::sync_objects(BL::Depsgraph &b_depsgraph,
light_map.pre_sync();
geometry_map.pre_sync();
object_map.pre_sync();
procedural_map.pre_sync();
particle_system_map.pre_sync();
motion_times.clear();
}
@@ -606,39 +539,15 @@ void BlenderSync::sync_objects(BL::Depsgraph &b_depsgraph,
/* Object itself. */
if (b_instance.show_self()) {
#ifdef WITH_ALEMBIC
bool use_procedural = false;
bool has_subdivision_modifier = false;
BL::MeshSequenceCacheModifier b_mesh_cache(PointerRNA_NULL);
/* Experimental as Blender does not have good support for procedurals at the moment, also
* only available in preview renders since currently do not have a good cache policy, the
* data being loaded at once for all the frames. */
if (experimental && b_v3d) {
b_mesh_cache = object_mesh_cache_find(b_ob, false, &has_subdivision_modifier);
use_procedural = b_mesh_cache && b_mesh_cache.cache_file().use_render_procedural();
}
if (use_procedural) {
/* Skip in the motion case, as generating motion blur data will be handled in the
* procedural. */
if (!motion) {
sync_procedural(b_ob, b_mesh_cache, has_subdivision_modifier);
}
}
else
#endif
{
sync_object(b_depsgraph,
b_view_layer,
b_instance,
motion_time,
false,
show_lights,
culling,
&use_portal,
sync_hair ? NULL : &geom_task_pool);
}
sync_object(b_depsgraph,
b_view_layer,
b_instance,
motion_time,
false,
show_lights,
culling,
&use_portal,
sync_hair ? NULL : &geom_task_pool);
}
/* Particle hair as separate object. */
@@ -671,7 +580,6 @@ void BlenderSync::sync_objects(BL::Depsgraph &b_depsgraph,
object_map.post_sync();
geometry_map.post_sync();
particle_system_map.post_sync();
procedural_map.post_sync();
}
if (motion)

View File

@@ -71,7 +71,7 @@ bool BlenderSync::sync_dupli_particle(BL::Object &b_ob,
Particle pa;
pa.index = persistent_id[0];
pa.age = b_scene.frame_current_final() - b_pa.birth_time();
pa.age = b_scene.frame_current() - b_pa.birth_time();
pa.lifetime = b_pa.lifetime();
pa.location = get_float3(b_pa.location());
pa.rotation = get_float4(b_pa.rotation());

View File

@@ -24,7 +24,6 @@
#include "blender/blender_util.h"
#include "render/denoising.h"
#include "render/image_oiio.h"
#include "render/merge.h"
#include "util/util_debug.h"
@@ -488,24 +487,6 @@ static PyObject *osl_update_node_func(PyObject * /*self*/, PyObject *args)
if (param->varlenarray || param->isstruct || param->type.arraylen > 1)
continue;
/* Read metadata. */
bool is_bool_param = false;
ustring param_label = param->name;
for (const OSL::OSLQuery::Parameter &metadata : param->metadata) {
if (metadata.type == TypeDesc::STRING) {
if (metadata.name == "widget") {
/* Boolean socket. */
if (metadata.sdefault[0] == "boolean" || metadata.sdefault[0] == "checkBox") {
is_bool_param = true;
}
}
else if (metadata.name == "label") {
/* Socket label. */
param_label = metadata.sdefault[0];
}
}
}
/* determine socket type */
string socket_type;
BL::NodeSocket::type_enum data_type = BL::NodeSocket::type_VALUE;
@@ -513,7 +494,6 @@ static PyObject *osl_update_node_func(PyObject * /*self*/, PyObject *args)
float default_float = 0.0f;
int default_int = 0;
string default_string = "";
bool default_boolean = false;
if (param->isclosure) {
socket_type = "NodeSocketShader";
@@ -543,19 +523,10 @@ static PyObject *osl_update_node_func(PyObject * /*self*/, PyObject *args)
}
else if (param->type.aggregate == TypeDesc::SCALAR) {
if (param->type.basetype == TypeDesc::INT) {
if (is_bool_param) {
socket_type = "NodeSocketBool";
data_type = BL::NodeSocket::type_BOOLEAN;
if (param->validdefault) {
default_boolean = (bool)param->idefault[0];
}
}
else {
socket_type = "NodeSocketInt";
data_type = BL::NodeSocket::type_INT;
if (param->validdefault)
default_int = param->idefault[0];
}
socket_type = "NodeSocketInt";
data_type = BL::NodeSocket::type_INT;
if (param->validdefault)
default_int = param->idefault[0];
}
else if (param->type.basetype == TypeDesc::FLOAT) {
socket_type = "NodeSocketFloat";
@@ -575,57 +546,33 @@ static PyObject *osl_update_node_func(PyObject * /*self*/, PyObject *args)
else
continue;
/* Update existing socket. */
bool found_existing = false;
/* find socket socket */
BL::NodeSocket b_sock(PointerRNA_NULL);
if (param->isoutput) {
for (BL::NodeSocket &b_sock : b_node.outputs) {
if (b_sock.identifier() == param->name) {
if (b_sock.bl_idname() != socket_type) {
/* Remove if type no longer matches. */
b_node.outputs.remove(b_data, b_sock);
}
else {
/* Reuse and update label. */
if (b_sock.name() != param_label) {
b_sock.name(param_label.string());
}
used_sockets.insert(b_sock.ptr.data);
found_existing = true;
}
break;
}
b_sock = b_node.outputs[param->name.string()];
/* remove if type no longer matches */
if (b_sock && b_sock.bl_idname() != socket_type) {
b_node.outputs.remove(b_data, b_sock);
b_sock = BL::NodeSocket(PointerRNA_NULL);
}
}
else {
for (BL::NodeSocket &b_sock : b_node.inputs) {
if (b_sock.identifier() == param->name) {
if (b_sock.bl_idname() != socket_type) {
/* Remove if type no longer matches. */
b_node.inputs.remove(b_data, b_sock);
}
else {
/* Reuse and update label. */
if (b_sock.name() != param_label) {
b_sock.name(param_label.string());
}
used_sockets.insert(b_sock.ptr.data);
found_existing = true;
}
break;
}
b_sock = b_node.inputs[param->name.string()];
/* remove if type no longer matches */
if (b_sock && b_sock.bl_idname() != socket_type) {
b_node.inputs.remove(b_data, b_sock);
b_sock = BL::NodeSocket(PointerRNA_NULL);
}
}
if (!found_existing) {
/* Create new socket. */
BL::NodeSocket b_sock = (param->isoutput) ? b_node.outputs.create(b_data,
socket_type.c_str(),
param_label.c_str(),
param->name.c_str()) :
b_node.inputs.create(b_data,
socket_type.c_str(),
param_label.c_str(),
param->name.c_str());
if (!b_sock) {
/* create new socket */
if (param->isoutput)
b_sock = b_node.outputs.create(
b_data, socket_type.c_str(), param->name.c_str(), param->name.c_str());
else
b_sock = b_node.inputs.create(
b_data, socket_type.c_str(), param->name.c_str(), param->name.c_str());
/* set default value */
if (data_type == BL::NodeSocket::type_VALUE) {
@@ -643,12 +590,9 @@ static PyObject *osl_update_node_func(PyObject * /*self*/, PyObject *args)
else if (data_type == BL::NodeSocket::type_STRING) {
set_string(b_sock.ptr, "default_value", default_string);
}
else if (data_type == BL::NodeSocket::type_BOOLEAN) {
set_boolean(b_sock.ptr, "default_value", default_boolean);
}
used_sockets.insert(b_sock.ptr.data);
}
used_sockets.insert(b_sock.ptr.data);
}
/* remove unused parameters */
@@ -692,22 +636,6 @@ static PyObject *osl_compile_func(PyObject * /*self*/, PyObject *args)
}
#endif
static PyObject *oiio_make_tx(PyObject * /*self*/, PyObject *args)
{
const char *inputfile = NULL, *outputfile = NULL, *colorspace = NULL;
int extension = EXTENSION_CLIP;
if (!PyArg_ParseTuple(args, "sssi", &inputfile, &outputfile, &colorspace, &extension))
return NULL;
/* return */
if (!OIIOImageLoader::make_tx(
inputfile, outputfile, ustring(colorspace), (ExtensionType)extension))
Py_RETURN_FALSE;
Py_RETURN_TRUE;
}
static PyObject *system_info_func(PyObject * /*self*/, PyObject * /*value*/)
{
string system_info = Device::device_capabilities();
@@ -1097,7 +1025,6 @@ static PyMethodDef methods[] = {
{"osl_update_node", osl_update_node_func, METH_VARARGS, ""},
{"osl_compile", osl_compile_func, METH_VARARGS, ""},
#endif
{"oiio_make_tx", oiio_make_tx, METH_VARARGS, ""},
{"available_devices", available_devices_func, METH_VARARGS, ""},
{"system_info", system_info_func, METH_NOARGS, ""},
#ifdef WITH_OPENCL

View File

@@ -149,7 +149,7 @@ BlenderAttributeType blender_attribute_name_split_type(ustring name, string *r_r
static BL::NodeSocket get_node_output(BL::Node &b_node, const string &name)
{
for (BL::NodeSocket &b_out : b_node.outputs) {
if (b_out.identifier() == name) {
if (b_out.name() == name) {
return b_out;
}
}
@@ -215,12 +215,7 @@ static void set_default_value(ShaderInput *input,
break;
}
case SocketType::INT: {
if (b_sock.type() == BL::NodeSocket::type_BOOLEAN) {
node->set(socket, get_boolean(b_sock.ptr, "default_value"));
}
else {
node->set(socket, get_int(b_sock.ptr, "default_value"));
}
node->set(socket, get_int(b_sock.ptr, "default_value"));
break;
}
case SocketType::COLOR: {
@@ -1007,59 +1002,71 @@ static bool node_use_modified_socket_name(ShaderNode *node)
return true;
}
static ShaderInput *node_find_input_by_name(ShaderNode *node, BL::NodeSocket &b_socket)
static ShaderInput *node_find_input_by_name(ShaderNode *node,
BL::Node &b_node,
BL::NodeSocket &b_socket)
{
string name = b_socket.identifier();
ShaderInput *input = node->input(name.c_str());
string name = b_socket.name();
if (!input && node_use_modified_socket_name(node)) {
/* Different internal name for shader. */
if (string_startswith(name, "Shader")) {
string_replace(name, "Shader", "Closure");
if (node_use_modified_socket_name(node)) {
bool found = false;
int counter = 0, total = 0;
for (BL::NodeSocket &b_input : b_node.inputs) {
if (b_input.name() == name) {
if (!found) {
counter++;
}
total++;
}
if (b_input.ptr.data == b_socket.ptr.data)
found = true;
}
input = node->input(name.c_str());
if (!input) {
/* Different internal numbering of two sockets with same name.
* Note that the Blender convention for unique socket names changed
* from . to _ at some point, so we check both to handle old files. */
if (string_endswith(name, "_001")) {
string_replace(name, "_001", "2");
}
else if (string_endswith(name, ".001")) {
string_replace(name, ".001", "2");
}
else if (string_endswith(name, "_002")) {
string_replace(name, "_002", "3");
}
else if (string_endswith(name, ".002")) {
string_replace(name, ".002", "3");
}
else {
name += "1";
}
/* rename if needed */
if (name == "Shader")
name = "Closure";
input = node->input(name.c_str());
}
if (total > 1)
name = string_printf("%s%d", name.c_str(), counter);
}
return input;
return node->input(name.c_str());
}
static ShaderOutput *node_find_output_by_name(ShaderNode *node, BL::NodeSocket &b_socket)
static ShaderOutput *node_find_output_by_name(ShaderNode *node,
BL::Node &b_node,
BL::NodeSocket &b_socket)
{
string name = b_socket.identifier();
ShaderOutput *output = node->output(name.c_str());
string name = b_socket.name();
if (!output && node_use_modified_socket_name(node)) {
/* Different internal name for shader. */
if (name == "Shader") {
name = "Closure";
output = node->output(name.c_str());
if (node_use_modified_socket_name(node)) {
bool found = false;
int counter = 0, total = 0;
for (BL::NodeSocket &b_output : b_node.outputs) {
if (b_output.name() == name) {
if (!found) {
counter++;
}
total++;
}
if (b_output.ptr.data == b_socket.ptr.data) {
found = true;
}
}
/* rename if needed */
if (name == "Shader")
name = "Closure";
if (total > 1)
name = string_printf("%s%d", name.c_str(), counter);
}
return output;
return node->output(name.c_str());
}
static void add_nodes(Scene *scene,
@@ -1202,7 +1209,7 @@ static void add_nodes(Scene *scene,
if (node) {
/* map node sockets for linking */
for (BL::NodeSocket &b_input : b_node.inputs) {
ShaderInput *input = node_find_input_by_name(node, b_input);
ShaderInput *input = node_find_input_by_name(node, b_node, b_input);
if (!input) {
/* XXX should not happen, report error? */
continue;
@@ -1212,7 +1219,7 @@ static void add_nodes(Scene *scene,
set_default_value(input, b_input, b_data, b_ntree);
}
for (BL::NodeSocket &b_output : b_node.outputs) {
ShaderOutput *output = node_find_output_by_name(node, b_output);
ShaderOutput *output = node_find_output_by_name(node, b_node, b_output);
if (!output) {
/* XXX should not happen, report error? */
continue;

View File

@@ -59,7 +59,6 @@ BlenderSync::BlenderSync(BL::RenderEngine &b_engine,
b_scene(b_scene),
shader_map(scene),
object_map(scene),
procedural_map(scene),
geometry_map(scene),
light_map(scene),
particle_system_map(scene),
@@ -802,27 +801,6 @@ SceneParams BlenderSync::get_scene_params(BL::Scene &b_scene, bool background)
params.bvh_layout = DebugFlags().cpu.bvh_layout;
params.texture.use_cache = RNA_boolean_get(&cscene, "use_texture_cache");
params.texture.cache_size = RNA_int_get(&cscene, "texture_cache_size");
params.texture.auto_convert = RNA_boolean_get(&cscene, "texture_auto_convert");
params.texture.accept_unmipped = RNA_boolean_get(&cscene, "texture_accept_unmipped");
params.texture.accept_untiled = RNA_boolean_get(&cscene, "texture_accept_untiled");
params.texture.tile_size = RNA_int_get(&cscene, "texture_tile_size");
params.texture.auto_mip = RNA_boolean_get(&cscene, "texture_auto_mip");
params.texture.auto_tile = RNA_boolean_get(&cscene, "texture_auto_tile");
params.texture.diffuse_blur = RNA_float_get(&cscene, "texture_blur_diffuse");
params.texture.glossy_blur = RNA_float_get(&cscene, "texture_blur_glossy");
params.texture.use_custom_cache_path = RNA_boolean_get(&cscene, "use_custom_cache_path");
if (params.texture.use_custom_cache_path) {
char *path = RNA_string_get_alloc(&cscene, "custom_cache_path", NULL, 0);
if (path) {
params.texture.custom_cache_path = path;
MEM_freeN(path);
}
}
else {
params.texture.custom_cache_path.clear();
}
params.background = background;
return params;

View File

@@ -151,10 +151,6 @@ class BlenderSync {
TaskPool *geom_task_pool);
void sync_object_motion_init(BL::Object &b_parent, BL::Object &b_ob, Object *object);
void sync_procedural(BL::Object &b_ob,
BL::MeshSequenceCacheModifier &b_mesh_cache,
bool has_subdivision);
bool sync_object_attributes(BL::DepsgraphObjectInstance &b_instance, Object *object);
/* Volume */
@@ -225,7 +221,6 @@ class BlenderSync {
id_map<void *, Shader> shader_map;
id_map<ObjectKey, Object> object_map;
id_map<void *, Procedural> procedural_map;
id_map<GeometryKey, Geometry> geometry_map;
id_map<ObjectKey, Light> light_map;
id_map<ParticleSystemKey, ParticleSystem> particle_system_map;

View File

@@ -145,7 +145,7 @@ static inline void curvemapping_minmax(/*const*/ BL::CurveMapping &cumap,
float *min_x,
float *max_x)
{
// const int num_curves = cumap.curves.length(); /* Gives linking error so far. */
/* const int num_curves = cumap.curves.length(); */ /* Gives linking error so far. */
const int num_curves = rgb_curve ? 4 : 3;
*min_x = FLT_MAX;
*max_x = -FLT_MAX;
@@ -246,11 +246,7 @@ static inline string image_user_file_path(BL::ImageUser &iuser,
string filepath_str = string(filepath);
if (load_tiled && ima.source() == BL::Image::source_TILED) {
string udim;
if (ima.tiles.length() > 0) {
udim = to_string(ima.tiles[0].number());
}
string_replace(filepath_str, udim, "<UDIM>");
string_replace(filepath_str, "1001", "<UDIM>");
}
return filepath_str;
}
@@ -572,45 +568,6 @@ static inline BL::FluidDomainSettings object_fluid_gas_domain_find(BL::Object &b
return BL::FluidDomainSettings(PointerRNA_NULL);
}
static inline BL::MeshSequenceCacheModifier object_mesh_cache_find(BL::Object &b_ob,
bool check_velocity,
bool *has_subdivision_modifier)
{
for (int i = b_ob.modifiers.length() - 1; i >= 0; --i) {
BL::Modifier b_mod = b_ob.modifiers[i];
if (b_mod.type() == BL::Modifier::type_MESH_SEQUENCE_CACHE) {
BL::MeshSequenceCacheModifier mesh_cache = BL::MeshSequenceCacheModifier(b_mod);
if (check_velocity) {
if (!MeshSequenceCacheModifier_has_velocity_get(&mesh_cache.ptr)) {
return BL::MeshSequenceCacheModifier(PointerRNA_NULL);
}
}
return mesh_cache;
}
/* Skip possible particles system modifiers as they do not modify the geometry. */
if (b_mod.type() == BL::Modifier::type_PARTICLE_SYSTEM) {
continue;
}
/* Only skip the subsurf modifier if we are not checking for the mesh sequence cache modifier
* for motion blur. */
if (b_mod.type() == BL::Modifier::type_SUBSURF && !check_velocity) {
if (has_subdivision_modifier) {
*has_subdivision_modifier = true;
}
continue;
}
break;
}
return BL::MeshSequenceCacheModifier(PointerRNA_NULL);
}
static inline Mesh::SubdivisionType object_subdivision_type(BL::Object &b_ob,
bool preview,
bool experimental)

View File

@@ -13,7 +13,7 @@
# limitations under the License.
function(cycles_set_solution_folder target)
if(IDE_GROUP_PROJECTS_IN_FOLDERS)
if(WINDOWS_USE_VISUAL_STUDIO_FOLDERS)
get_filename_component(folderdir ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY)
string(REPLACE ${CMAKE_SOURCE_DIR} "" folderdir ${folderdir})
set_target_properties(${target} PROPERTIES FOLDER ${folderdir})

View File

@@ -376,12 +376,6 @@ class Device {
return NULL;
}
/* open image io, only for CPU device */
virtual void *oiio_memory()
{
return NULL;
}
/* load/compile kernels, must be called before adding tasks */
virtual bool load_kernels(const DeviceRequestedFeatures & /*requested_features*/)
{

View File

@@ -39,7 +39,6 @@
#include "kernel/kernel_types.h"
#include "kernel/split/kernel_split_data.h"
#include "kernel/kernel_globals.h"
#include "kernel/kernel_oiio_globals.h"
#include "kernel/kernel_adaptive_sampling.h"
#include "kernel/filter/filter.h"
@@ -185,9 +184,6 @@ class CPUDevice : public Device {
#ifdef WITH_OSL
OSLGlobals osl_globals;
#endif
OIIOGlobals oiio_globals;
#ifdef WITH_OPENIMAGEDENOISE
oidn::DeviceRef oidn_device;
oidn::FilterRef oidn_filter;
@@ -316,9 +312,6 @@ class CPUDevice : public Device {
#ifdef WITH_OSL
kernel_globals.osl = &osl_globals;
#endif
oiio_globals.tex_sys = NULL;
kernel_globals.oiio = &oiio_globals;
#ifdef WITH_EMBREE
embree_device = rtcNewDevice("verbose=0");
#endif
@@ -364,12 +357,6 @@ class CPUDevice : public Device {
#endif
task_pool.cancel();
texture_info.free();
if (oiio_globals.tex_sys) {
VLOG(1) << oiio_globals.tex_sys->getstats();
oiio_globals.tex_sys->reset_stats();
TextureSystem::destroy(oiio_globals.tex_sys);
}
kernel_globals.oiio = NULL;
}
virtual bool show_samples() const override
@@ -561,11 +548,6 @@ class CPUDevice : public Device {
#endif
}
void *oiio_memory() override
{
return &oiio_globals;
}
void build_bvh(BVH *bvh, Progress &progress, bool refit) override
{
#ifdef WITH_EMBREE
@@ -1504,10 +1486,6 @@ class CPUDevice : public Device {
#ifdef WITH_OSL
OSLShader::thread_init(&kg, &kernel_globals, &osl_globals);
#endif
if (kg.oiio && kg.oiio->tex_sys) {
kg.oiio_tdata = kg.oiio->tex_sys->get_perthread_info();
}
return kg;
}

View File

@@ -231,12 +231,6 @@ device_texture::device_texture(Device *device,
data_type = TYPE_UINT16;
data_elements = 1;
break;
case IMAGE_DATA_TYPE_OIIO:
/* Assumes 64 bit pointers to be stored as uint. */
static_assert(sizeof(void*) == sizeof(uint64_t));
data_type = TYPE_UINT64;
data_elements = 1;
break;
case IMAGE_DATA_NUM_TYPES:
assert(0);
return;

View File

@@ -79,10 +79,7 @@ struct SocketType {
LINK_NORMAL = (1 << 8),
LINK_POSITION = (1 << 9),
LINK_TANGENT = (1 << 10),
LINK_TEXTURE_DX = (1 << 11),
LINK_TEXTURE_DY = (1 << 12),
DEFAULT_LINK_MASK = (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7) | (1 << 8) | (1 << 9) |
(1 << 10) | (1 << 11) | (1 << 12)
DEFAULT_LINK_MASK = (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7) | (1 << 8) | (1 << 9) | (1 << 10)
};
ustring name;

View File

@@ -211,8 +211,7 @@ ccl_device_inline int bsdf_sample(KernelGlobals *kg,
omega_in,
&domega_in->dx,
&domega_in->dy,
pdf,
sd);
pdf);
break;
case CLOSURE_BSDF_REFRACTION_ID:
label = bsdf_refraction_sample(sc,
@@ -226,8 +225,7 @@ ccl_device_inline int bsdf_sample(KernelGlobals *kg,
omega_in,
&domega_in->dx,
&domega_in->dy,
pdf,
sd);
pdf);
break;
case CLOSURE_BSDF_TRANSPARENT_ID:
label = bsdf_transparent_sample(sc,
@@ -259,8 +257,7 @@ ccl_device_inline int bsdf_sample(KernelGlobals *kg,
omega_in,
&domega_in->dx,
&domega_in->dy,
pdf,
sd);
pdf);
break;
case CLOSURE_BSDF_MICROFACET_MULTI_GGX_ID:
case CLOSURE_BSDF_MICROFACET_MULTI_GGX_FRESNEL_ID:
@@ -294,8 +291,7 @@ ccl_device_inline int bsdf_sample(KernelGlobals *kg,
&domega_in->dx,
&domega_in->dy,
pdf,
&sd->lcg_state,
sd);
&sd->lcg_state);
break;
case CLOSURE_BSDF_MICROFACET_BECKMANN_ID:
case CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID:
@@ -311,8 +307,7 @@ ccl_device_inline int bsdf_sample(KernelGlobals *kg,
omega_in,
&domega_in->dx,
&domega_in->dy,
pdf,
sd);
pdf);
break;
case CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ID:
label = bsdf_ashikhmin_shirley_sample(sc,

View File

@@ -161,10 +161,8 @@ ccl_device int bsdf_ashikhmin_velvet_sample(const ShaderClosure *sc,
#ifdef __RAY_DIFFERENTIALS__
// TODO: find a better approximation for the retroreflective bounce
*domega_in_dx = (2.0f * dot(N, dIdx)) * N - dIdx;
*domega_in_dy = (2.0f * dot(N, dIdy)) * N - dIdy;
*domega_in_dx *= 125.0f;
*domega_in_dy *= 125.0f;
*domega_in_dx = (2 * dot(N, dIdx)) * N - dIdx;
*domega_in_dy = (2 * dot(N, dIdy)) * N - dIdy;
#endif
}
else

View File

@@ -101,10 +101,8 @@ ccl_device int bsdf_diffuse_sample(const ShaderClosure *sc,
*eval = make_float3(*pdf, *pdf, *pdf);
#ifdef __RAY_DIFFERENTIALS__
// TODO: find a better approximation for the diffuse bounce
*domega_in_dx = (2.0f * dot(N, dIdx)) * N - dIdx;
*domega_in_dy = (2.0f * dot(N, dIdy)) * N - dIdy;
*domega_in_dx *= 125.0f;
*domega_in_dy *= 125.0f;
*domega_in_dx = (2 * dot(N, dIdx)) * N - dIdx;
*domega_in_dy = (2 * dot(N, dIdy)) * N - dIdy;
#endif
}
else
@@ -165,10 +163,8 @@ ccl_device int bsdf_translucent_sample(const ShaderClosure *sc,
*eval = make_float3(*pdf, *pdf, *pdf);
#ifdef __RAY_DIFFERENTIALS__
// TODO: find a better approximation for the diffuse bounce
*domega_in_dx = -((2.0f * dot(N, dIdx)) * N - dIdx);
*domega_in_dy = -((2.0f * dot(N, dIdy)) * N - dIdy);
*domega_in_dx *= 125.0f;
*domega_in_dy *= 125.0f;
*domega_in_dx = -((2 * dot(N, dIdx)) * N - dIdx);
*domega_in_dy = -((2 * dot(N, dIdy)) * N - dIdy);
#endif
}
else {

View File

@@ -112,10 +112,8 @@ ccl_device int bsdf_diffuse_ramp_sample(const ShaderClosure *sc,
if (dot(Ng, *omega_in) > 0.0f) {
*eval = bsdf_diffuse_ramp_get_color(bsdf->colors, *pdf * M_PI_F) * M_1_PI_F;
# ifdef __RAY_DIFFERENTIALS__
*domega_in_dx = (2.0f * dot(N, dIdx)) * N - dIdx;
*domega_in_dy = (2.0f * dot(N, dIdy)) * N - dIdy;
*domega_in_dx *= 125.0f;
*domega_in_dy *= 125.0f;
*domega_in_dx = (2 * dot(N, dIdx)) * N - dIdx;
*domega_in_dy = (2 * dot(N, dIdy)) * N - dIdy;
# endif
}
else

View File

@@ -228,10 +228,8 @@ ccl_device int bsdf_hair_reflection_sample(const ShaderClosure *sc,
// differentials - TODO: find a better approximation for the reflective bounce
#ifdef __RAY_DIFFERENTIALS__
*domega_in_dx = 2.0f * dot(locy, dIdx) * locy - dIdx;
*domega_in_dy = 2.0f * dot(locy, dIdy) * locy - dIdy;
*domega_in_dx *= 10.0f;
*domega_in_dy *= 10.0f;
*domega_in_dx = 2 * dot(locy, dIdx) * locy - dIdx;
*domega_in_dy = 2 * dot(locy, dIdy) * locy - dIdy;
#endif
*pdf = fabsf(phi_pdf * theta_pdf);

View File

@@ -570,8 +570,7 @@ ccl_device int bsdf_microfacet_ggx_sample(KernelGlobals *kg,
float3 *omega_in,
float3 *domega_in_dx,
float3 *domega_in_dy,
float *pdf,
const ShaderData *sd)
float *pdf)
{
const MicrofacetBsdf *bsdf = (const MicrofacetBsdf *)sc;
float alpha_x = bsdf->alpha_x;
@@ -700,20 +699,8 @@ ccl_device int bsdf_microfacet_ggx_sample(KernelGlobals *kg,
}
#ifdef __RAY_DIFFERENTIALS__
# ifdef __DNDU__
float3 dwodx = -dIdx;
float3 dwody = -dIdy;
float dDNdx = dot(dwodx, N) + dot(I, sd->dNdx);
float dDNdy = dot(dwody, N) + dot(I, sd->dNdy);
*domega_in_dx = dwodx + 2.0f * (dot(I, N) * sd->dNdx + dDNdx * N);
*domega_in_dy = dwody + 2.0f * (dot(I, N) * sd->dNdy + dDNdy * N);
# else
*domega_in_dx = (2.0f * dot(m, dIdx)) * m - dIdx;
*domega_in_dy = (2.0f * dot(m, dIdy)) * m - dIdy;
# endif
const float softness = min(alpha_x, alpha_y) * 10.0f;
*domega_in_dx *= (1.0f + softness);
*domega_in_dy *= (1.0f + softness);
*domega_in_dx = (2 * dot(m, dIdx)) * m - dIdx;
*domega_in_dy = (2 * dot(m, dIdy)) * m - dIdy;
#endif
}
}
@@ -736,10 +723,6 @@ ccl_device int bsdf_microfacet_ggx_sample(KernelGlobals *kg,
&R,
&T,
#ifdef __RAY_DIFFERENTIALS__
# ifdef __DNDU__
sd->dNdx,
sd->dNdy,
# endif
dIdx,
dIdy,
&dRdx,
@@ -755,9 +738,6 @@ ccl_device int bsdf_microfacet_ggx_sample(KernelGlobals *kg,
#ifdef __RAY_DIFFERENTIALS__
*domega_in_dx = dTdx;
*domega_in_dy = dTdy;
const float softness = min(alpha_x, alpha_y) * 10.0f;
*domega_in_dx *= (1.0f + softness);
*domega_in_dy *= (1.0f + softness);
#endif
if (alpha_x * alpha_y <= 1e-7f || fabsf(m_eta - 1.0f) < 1e-4f) {
@@ -1018,8 +998,7 @@ ccl_device int bsdf_microfacet_beckmann_sample(KernelGlobals *kg,
float3 *omega_in,
float3 *domega_in_dx,
float3 *domega_in_dy,
float *pdf,
const ShaderData *sd)
float *pdf)
{
const MicrofacetBsdf *bsdf = (const MicrofacetBsdf *)sc;
float alpha_x = bsdf->alpha_x;
@@ -1111,20 +1090,8 @@ ccl_device int bsdf_microfacet_beckmann_sample(KernelGlobals *kg,
}
#ifdef __RAY_DIFFERENTIALS__
# ifdef __DNDU__
float3 dwodx = -dIdx;
float3 dwody = -dIdy;
float dDNdx = dot(dwodx, N) + dot(I, sd->dNdx);
float dDNdy = dot(dwody, N) + dot(I, sd->dNdy);
*domega_in_dx = dwodx + 2.f * (dot(I, N) * sd->dNdx + dDNdx * N);
*domega_in_dy = dwody + 2.f * (dot(I, N) * sd->dNdy + dDNdy * N);
# else
*domega_in_dx = (2.0f * dot(m, dIdx)) * m - dIdx;
*domega_in_dy = (2.0f * dot(m, dIdy)) * m - dIdy;
# endif
const float softness = min(alpha_x, alpha_y) * 10.0f;
*domega_in_dx *= (1.0f + softness);
*domega_in_dy *= (1.0f + softness);
*domega_in_dx = (2 * dot(m, dIdx)) * m - dIdx;
*domega_in_dy = (2 * dot(m, dIdy)) * m - dIdy;
#endif
}
}
@@ -1147,10 +1114,6 @@ ccl_device int bsdf_microfacet_beckmann_sample(KernelGlobals *kg,
&R,
&T,
#ifdef __RAY_DIFFERENTIALS__
# ifdef __DNDU__
sd->dNdx,
sd->dNdy,
# endif
dIdx,
dIdy,
&dRdx,
@@ -1166,9 +1129,6 @@ ccl_device int bsdf_microfacet_beckmann_sample(KernelGlobals *kg,
#ifdef __RAY_DIFFERENTIALS__
*domega_in_dx = dTdx;
*domega_in_dy = dTdy;
const float softness = min(alpha_x, alpha_y) * 10.0f;
*domega_in_dx *= (1.0f + softness);
*domega_in_dy *= (1.0f + softness);
#endif
if (alpha_x * alpha_y <= 1e-7f || fabsf(m_eta - 1.0f) < 1e-4f) {

View File

@@ -526,11 +526,8 @@ ccl_device int bsdf_microfacet_multi_ggx_sample(KernelGlobals *kg,
*omega_in = X * localO.x + Y * localO.y + Z * localO.z;
#ifdef __RAY_DIFFERENTIALS__
*domega_in_dx = (2.0f * dot(Z, dIdx)) * Z - dIdx;
*domega_in_dy = (2.0f * dot(Z, dIdy)) * Z - dIdy;
const float softness = min(bsdf->alpha_x, bsdf->alpha_y) * 10.0f;
*domega_in_dx *= (1.0f + softness);
*domega_in_dy *= (1.0f + softness);
*domega_in_dx = (2 * dot(Z, dIdx)) * Z - dIdx;
*domega_in_dy = (2 * dot(Z, dIdy)) * Z - dIdy;
#endif
return LABEL_REFLECT | LABEL_GLOSSY;
}
@@ -644,8 +641,7 @@ ccl_device int bsdf_microfacet_multi_ggx_glass_sample(KernelGlobals *kg,
float3 *domega_in_dx,
float3 *domega_in_dy,
float *pdf,
ccl_addr_space uint *lcg_state,
const ShaderData *sd)
ccl_addr_space uint *lcg_state)
{
const MicrofacetBsdf *bsdf = (const MicrofacetBsdf *)sc;
@@ -664,10 +660,6 @@ ccl_device int bsdf_microfacet_multi_ggx_glass_sample(KernelGlobals *kg,
&R,
&T,
#ifdef __RAY_DIFFERENTIALS__
# ifdef __DNDU__
sd->dNdx,
sd->dNdy,
# endif
dIdx,
dIdy,
&dRdx,
@@ -721,9 +713,6 @@ ccl_device int bsdf_microfacet_multi_ggx_glass_sample(KernelGlobals *kg,
#ifdef __RAY_DIFFERENTIALS__
*domega_in_dx = (2 * dot(Z, dIdx)) * Z - dIdx;
*domega_in_dy = (2 * dot(Z, dIdy)) * Z - dIdy;
const float softness = min(bsdf->alpha_x, bsdf->alpha_y) * 10.0f;
*domega_in_dx *= (1.0f + softness);
*domega_in_dy *= (1.0f + softness);
#endif
return LABEL_REFLECT | LABEL_GLOSSY;
}
@@ -735,9 +724,6 @@ ccl_device int bsdf_microfacet_multi_ggx_glass_sample(KernelGlobals *kg,
((bsdf->ior - bsdf->ior * bsdf->ior * cosI / dnp) * dot(dIdx, Z)) * Z;
*domega_in_dy = -(bsdf->ior * dIdy) +
((bsdf->ior - bsdf->ior * bsdf->ior * cosI / dnp) * dot(dIdy, Z)) * Z;
const float softness = min(bsdf->alpha_x, bsdf->alpha_y) * 10.0f;
*domega_in_dx *= (1.0f + softness);
*domega_in_dy *= (1.0f + softness);
#endif
return LABEL_TRANSMIT | LABEL_GLOSSY;

View File

@@ -116,8 +116,6 @@ ccl_device int bsdf_oren_nayar_sample(const ShaderClosure *sc,
// TODO: find a better approximation for the bounce
*domega_in_dx = (2.0f * dot(bsdf->N, dIdx)) * bsdf->N - dIdx;
*domega_in_dy = (2.0f * dot(bsdf->N, dIdy)) * bsdf->N - dIdy;
*domega_in_dx *= 125.0f;
*domega_in_dy *= 125.0f;
#endif
}
else {

View File

@@ -123,10 +123,8 @@ ccl_device int bsdf_phong_ramp_sample(const ShaderClosure *sc,
float3 R = (2 * cosNO) * bsdf->N - I;
# ifdef __RAY_DIFFERENTIALS__
*domega_in_dx = (2.0f * dot(bsdf->N, dIdx)) * bsdf->N - dIdx;
*domega_in_dy = (2.0f * dot(bsdf->N, dIdy)) * bsdf->N - dIdy;
*domega_in_dx *= 10.0f;
*domega_in_dy *= 10.0f;
*domega_in_dx = (2 * dot(bsdf->N, dIdx)) * bsdf->N - dIdx;
*domega_in_dy = (2 * dot(bsdf->N, dIdy)) * bsdf->N - dIdy;
# endif
float3 T, B;

View File

@@ -125,10 +125,8 @@ ccl_device int bsdf_principled_diffuse_sample(const ShaderClosure *sc,
#ifdef __RAY_DIFFERENTIALS__
// TODO: find a better approximation for the diffuse bounce
*domega_in_dx = (2.0f * dot(N, dIdx)) * N - dIdx;
*domega_in_dy = (2.0f * dot(N, dIdy)) * N - dIdy;
*domega_in_dx *= 125.0f;
*domega_in_dy *= 125.0f;
*domega_in_dx = -((2 * dot(N, dIdx)) * N - dIdx);
*domega_in_dy = -((2 * dot(N, dIdy)) * N - dIdy);
#endif
}
else {

View File

@@ -126,10 +126,8 @@ ccl_device int bsdf_principled_sheen_sample(const ShaderClosure *sc,
#ifdef __RAY_DIFFERENTIALS__
// TODO: find a better approximation for the diffuse bounce
*domega_in_dx = (2.0f * dot(N, dIdx)) * N - dIdx;
*domega_in_dy = (2.0f * dot(N, dIdy)) * N - dIdy;
*domega_in_dx *= 125.0f;
*domega_in_dy *= 125.0f;
*domega_in_dx = -((2 * dot(N, dIdx)) * N - dIdx);
*domega_in_dy = -((2 * dot(N, dIdy)) * N - dIdy);
#endif
}
else {

View File

@@ -70,8 +70,7 @@ ccl_device int bsdf_reflection_sample(const ShaderClosure *sc,
float3 *omega_in,
float3 *domega_in_dx,
float3 *domega_in_dy,
float *pdf,
const ShaderData *sd)
float *pdf)
{
const MicrofacetBsdf *bsdf = (const MicrofacetBsdf *)sc;
float3 N = bsdf->N;
@@ -82,18 +81,8 @@ ccl_device int bsdf_reflection_sample(const ShaderClosure *sc,
*omega_in = (2 * cosNO) * N - I;
if (dot(Ng, *omega_in) > 0) {
#ifdef __RAY_DIFFERENTIALS__
# ifdef __DNDU__
/* as described in pbrt */
float3 dwodx = -dIdx;
float3 dwody = -dIdy;
float dDNdx = dot(dwodx, N) + dot(I, sd->dNdx);
float dDNdy = dot(dwody, N) + dot(I, sd->dNdy);
*domega_in_dx = dwodx + 2.f * (dot(I, N) * sd->dNdx + dDNdx * N);
*domega_in_dy = dwody + 2.f * (dot(I, N) * sd->dNdy + dDNdy * N);
# else
*domega_in_dx = 2.0f * dot(N, dIdx) * N - dIdx;
*domega_in_dy = 2.0f * dot(N, dIdy) * N - dIdy;
# endif
*domega_in_dx = 2 * dot(N, dIdx) * N - dIdx;
*domega_in_dy = 2 * dot(N, dIdy) * N - dIdy;
#endif
/* Some high number for MIS. */
*pdf = 1e6f;

View File

@@ -70,8 +70,7 @@ ccl_device int bsdf_refraction_sample(const ShaderClosure *sc,
float3 *omega_in,
float3 *domega_in_dx,
float3 *domega_in_dy,
float *pdf,
ShaderData *sd)
float *pdf)
{
const MicrofacetBsdf *bsdf = (const MicrofacetBsdf *)sc;
float m_eta = bsdf->ior;
@@ -89,10 +88,6 @@ ccl_device int bsdf_refraction_sample(const ShaderClosure *sc,
&R,
&T,
#ifdef __RAY_DIFFERENTIALS__
# ifdef __DNDU__
sd->dNdx,
sd->dNdy,
# endif
dIdx,
dIdy,
&dRdx,

View File

@@ -142,8 +142,6 @@ ccl_device int bsdf_diffuse_toon_sample(const ShaderClosure *sc,
// TODO: find a better approximation for the bounce
*domega_in_dx = (2.0f * dot(bsdf->N, dIdx)) * bsdf->N - dIdx;
*domega_in_dy = (2.0f * dot(bsdf->N, dIdy)) * bsdf->N - dIdy;
*domega_in_dx *= 125.0f;
*domega_in_dy *= 125.0f;
#endif
}
else
@@ -235,10 +233,8 @@ ccl_device int bsdf_glossy_toon_sample(const ShaderClosure *sc,
*eval = *pdf * bsdf_toon_get_intensity(max_angle, smooth, angle);
#ifdef __RAY_DIFFERENTIALS__
*domega_in_dx = (2.0f * dot(bsdf->N, dIdx)) * bsdf->N - dIdx;
*domega_in_dy = (2.0f * dot(bsdf->N, dIdy)) * bsdf->N - dIdy;
*domega_in_dx *= 10.0f;
*domega_in_dy *= 10.0f;
*domega_in_dx = (2 * dot(bsdf->N, dIdx)) * bsdf->N - dIdx;
*domega_in_dy = (2 * dot(bsdf->N, dIdy)) * bsdf->N - dIdy;
#endif
}
else

View File

@@ -41,10 +41,6 @@ ccl_device float fresnel_dielectric(float eta,
float3 *R,
float3 *T,
#ifdef __RAY_DIFFERENTIALS__
# ifdef __DNDU__
const float3 dNdx,
const float3 dNdy,
# endif
const float3 dIdx,
const float3 dIdy,
float3 *dRdx,
@@ -73,14 +69,14 @@ ccl_device float fresnel_dielectric(float eta,
}
// compute reflection
*R = (2.0f * cos) * Nn - I;
*R = (2 * cos) * Nn - I;
#ifdef __RAY_DIFFERENTIALS__
*dRdx = (2.0f * dot(Nn, dIdx)) * Nn - dIdx;
*dRdy = (2.0f * dot(Nn, dIdy)) * Nn - dIdy;
*dRdx = (2 * dot(Nn, dIdx)) * Nn - dIdx;
*dRdy = (2 * dot(Nn, dIdy)) * Nn - dIdy;
#endif
float arg = 1 - (neta * neta * (1 - (cos * cos)));
if (arg < 0.0f) {
if (arg < 0) {
*T = make_float3(0.0f, 0.0f, 0.0f);
#ifdef __RAY_DIFFERENTIALS__
*dTdx = make_float3(0.0f, 0.0f, 0.0f);
@@ -93,16 +89,8 @@ ccl_device float fresnel_dielectric(float eta,
float nK = (neta * cos) - dnp;
*T = -(neta * I) + (nK * Nn);
#ifdef __RAY_DIFFERENTIALS__
# ifndef __DNDU__
# define dNdx make_float3(0.0f, 0.0f, 0.0f)
# define dNdy make_float3(0.0f, 0.0f, 0.0f)
# endif
float dDNdx = dot(dIdx, Nn) - dot(I, dNdx);
float dDNdy = dot(dIdy, Nn) - dot(I, dNdy);
float dmudx = (neta - neta * neta * cos / dnp) * dDNdx;
float dmudy = (neta - neta * neta * cos / dnp) * dDNdy;
*dTdx = -(neta * dIdx) + (nK * dNdx + dmudx * Nn);
*dTdy = -(neta * dIdy) + (nK * dNdy + dmudy * Nn);
*dTdx = -(neta * dIdx) + ((neta - neta * neta * cos / dnp) * dot(dIdx, Nn)) * Nn;
*dTdy = -(neta * dIdy) + ((neta - neta * neta * cos / dnp) * dot(dIdy, Nn)) * Nn;
#endif
// compute Fresnel terms
float cosTheta1 = cos; // N.R

View File

@@ -90,15 +90,8 @@ ccl_device float3 volume_henyey_greenstein_eval_phase(const ShaderClosure *sc,
return make_float3(*pdf, *pdf, *pdf);
}
ccl_device float3 henyey_greenstrein_sample(float3 D,
float g,
float randu,
float randv,
float *pdf,
float3 dIdx,
float3 dIdy,
float3 *domega_in_dx,
float3 *domega_in_dy)
ccl_device float3
henyey_greenstrein_sample(float3 D, float g, float randu, float randv, float *pdf)
{
/* match pdf for small g */
float cos_theta;
@@ -120,33 +113,12 @@ ccl_device float3 henyey_greenstrein_sample(float3 D,
float sin_theta = safe_sqrtf(1.0f - cos_theta * cos_theta);
float phi = M_2PI_F * randv;
float cos_phi = cosf(phi);
float sin_phi = sinf(phi);
float3 dir = make_float3(sin_theta * cos_phi, sin_theta * sin_phi, cos_theta);
float3 dir = make_float3(sin_theta * cosf(phi), sin_theta * sinf(phi), cos_theta);
float3 T, B;
make_orthonormals(D, &T, &B);
dir = dir.x * T + dir.y * B + dir.z * D;
#ifdef __RAY_DIFFERENTIALS__
if (domega_in_dx && domega_in_dy) {
if (pdf && *pdf < 1.0f) {
float spread = 0.125f / sqrtf(*pdf);
make_orthonormals(dir, &T, &B);
*domega_in_dx = spread * T;
*domega_in_dy = spread * B;
}
else {
make_orthonormals(D - dIdx, &T, &B);
*domega_in_dx = sin_theta * cos_phi * T + sin_theta * sin_phi * B + cos_theta * (D - dIdx) -
dir;
make_orthonormals(D - dIdy, &T, &B);
*domega_in_dy = sin_theta * cos_phi * T + sin_theta * sin_phi * B + cos_theta * (D - dIdy) -
dir;
}
}
#endif
return dir;
}
@@ -166,10 +138,15 @@ ccl_device int volume_henyey_greenstein_sample(const ShaderClosure *sc,
float g = volume->g;
/* note that I points towards the viewer and so is used negated */
*omega_in = henyey_greenstrein_sample(
-I, g, randu, randv, pdf, dIdx, dIdy, domega_in_dx, domega_in_dy);
*omega_in = henyey_greenstrein_sample(-I, g, randu, randv, pdf);
*eval = make_float3(*pdf, *pdf, *pdf); /* perfect importance sampling */
#ifdef __RAY_DIFFERENTIALS__
/* todo: implement ray differential estimation */
*domega_in_dx = make_float3(0.0f, 0.0f, 0.0f);
*domega_in_dy = make_float3(0.0f, 0.0f, 0.0f);
#endif
return LABEL_VOLUME_SCATTER;
}

View File

@@ -778,10 +778,6 @@ ccl_device_inline void curve_shader_setup(KernelGlobals *kg,
sd->dPdu = dPdu;
sd->dPdv = cross(dPdu, sd->Ng);
# endif
# ifdef __DNDU__
sd->dNdx = make_float3(0.0f, 0.0f, 0.0f);
sd->dNdy = make_float3(0.0f, 0.0f, 0.0f);
# endif
if (isect->object != OBJECT_NONE) {
# ifdef __OBJECT_MOTION__

View File

@@ -85,7 +85,6 @@ ccl_device_noinline void motion_triangle_shader_setup(
sd->dPdu = (verts[0] - verts[2]);
sd->dPdv = (verts[1] - verts[2]);
#endif
/* Compute smooth normal. */
if (sd->shader & SHADER_SMOOTH_NORMAL) {
/* Find attribute. */

View File

@@ -107,20 +107,6 @@ triangle_smooth_normal(KernelGlobals *kg, float3 Ng, int prim, float u, float v)
return is_zero(N) ? Ng : N;
}
ccl_device_inline float3
triangle_smooth_normal_unnormalized(KernelGlobals *kg, float3 Ng, int prim, float u, float v)
{
/* load triangle vertices */
const uint4 tri_vindex = kernel_tex_fetch(__tri_vindex, prim);
float3 n0 = float4_to_float3(kernel_tex_fetch(__tri_vnormal, tri_vindex.x));
float3 n1 = float4_to_float3(kernel_tex_fetch(__tri_vnormal, tri_vindex.y));
float3 n2 = float4_to_float3(kernel_tex_fetch(__tri_vnormal, tri_vindex.z));
float3 N = (1.0f - u - v) * n2 + u * n0 + v * n1;
return is_zero(N) ? Ng : N;
}
/* Ray differentials on triangle */
ccl_device_inline void triangle_dPdudv(KernelGlobals *kg,
@@ -139,22 +125,6 @@ ccl_device_inline void triangle_dPdudv(KernelGlobals *kg,
*dPdv = (p1 - p2);
}
ccl_device_inline void triangle_dNdudv(KernelGlobals *kg,
int prim,
ccl_addr_space float3 *dNdu,
ccl_addr_space float3 *dNdv)
{
/* load triangle vertices */
const uint4 tri_vindex = kernel_tex_fetch(__tri_vindex, prim);
float3 n0 = float4_to_float3(kernel_tex_fetch(__tri_vnormal, tri_vindex.x));
float3 n1 = float4_to_float3(kernel_tex_fetch(__tri_vnormal, tri_vindex.y));
float3 n2 = float4_to_float3(kernel_tex_fetch(__tri_vnormal, tri_vindex.z));
/* compute derivatives of N w.r.t. uv */
*dNdu = (n0 - n2);
*dNdv = (n1 - n2);
}
/* Reading attributes on various triangle elements */
ccl_device float triangle_attribute_float(

View File

@@ -283,7 +283,6 @@ ccl_device void kernel_bake_evaluate(
P,
Ng,
Ng,
NULL,
shader,
object,
prim,

View File

@@ -36,23 +36,6 @@ ccl_device void differential_transfer(ccl_addr_space differential3 *dP_,
dP_->dy = tmpy - dot(tmpy, Ng) * tmp;
}
ccl_device void differential_reflect(differential3 *dD_,
float3 D,
const ccl_addr_space differential3 *dD,
float3 N,
const differential3 *dN)
{
/* ray differential transfer through homogeneous medium, to
* compute dPdx/dy at a shading point from the incoming ray */
const float dotDN = dot(D, N);
const float3 tmpx = N * (dot(dD->dx, N) + dot(D, dN->dx));
const float3 tmpy = N * (dot(dD->dy, N) + dot(D, dN->dy));
dD_->dx = dD->dx - 2.0f * (dotDN * dN->dx + tmpx);
dD_->dy = dD->dy - 2.0f * (dotDN * dN->dy + tmpy);
}
ccl_device void differential_incoming(ccl_addr_space differential3 *dI, const differential3 dD)
{
/* compute dIdx/dy at a shading point, we just need to negate the

View File

@@ -57,7 +57,6 @@ ccl_device_noinline_cpu float3 direct_emissive_eval(KernelGlobals *kg,
ls->P,
ls->Ng,
I,
&dI,
ls->shader,
ls->object,
ls->prim,
@@ -112,21 +111,10 @@ ccl_device_noinline_cpu bool direct_emission(KernelGlobals *kg,
if (ls->pdf == 0.0f)
return false;
differential3 dD;
differential3 dN;
#ifdef __DNDU__
dN.dx = sd->dNdx;
dN.dy = sd->dNdy;
#else
dN = differential3_zero();
#endif
/* This is how differentials are calculated for a perfect specular reflection.
* This is not the exact value that we should be getting here,
* but it's still better than using zero differentials. */
differential_reflect(&dD, sd->I, &sd->dI, sd->N, &dN);
/* todo: implement */
differential3 dD = differential3_zero();
/* evaluate closure */
emission_sd->dP = sd->dP;
float3 light_eval = direct_emissive_eval(
kg, emission_sd, ls, state, -ls->D, dD, ls->t, sd->time);

View File

@@ -44,9 +44,6 @@ struct OSLGlobals;
struct OSLThreadData;
struct OSLShadingSystem;
# endif
# ifdef __OIIO__
struct OIIOGlobals;
# endif
typedef unordered_map<float, float> CoverageMap;
@@ -67,11 +64,6 @@ typedef struct KernelGlobals {
OSLThreadData *osl_tdata;
# endif
# ifdef __OIIO__
OIIOGlobals *oiio;
void *oiio_tdata;
# endif
/* **** Run-time data **** */
/* Heap-allocated storage for transparent shadows intersections. */

View File

@@ -333,33 +333,6 @@ ccl_device bool lamp_light_eval(
return true;
}
ccl_device void lamp_light_dPdudv(KernelGlobals *kg,
int lamp,
float u,
float v,
ccl_addr_space float3 *dPdu,
ccl_addr_space float3 *dPdv)
{
const ccl_global KernelLight *klight = &kernel_tex_fetch(__lights, lamp);
LightType type = (LightType)klight->type;
switch (type) {
case LIGHT_AREA: {
*dPdu = make_float3(klight->area.axisu[0], klight->area.axisu[1], klight->area.axisu[2]);
*dPdv = make_float3(klight->area.axisv[0], klight->area.axisv[1], klight->area.axisv[2]);
break;
}
case LIGHT_POINT:
case LIGHT_DISTANT:
case LIGHT_SPOT:
default:
// TODO (Stefan)
*dPdu = make_float3(0.0f, 0.0f, 0.0f);
*dPdv = make_float3(0.0f, 0.0f, 0.0f);
break;
}
}
/* Triangle Light */
/* returns true if the triangle is has motion blur or an instancing transform applied */

View File

@@ -1,41 +0,0 @@
/*
* Copyright 2011-2017 Blender Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __KERNEL_OIIO_GLOBALS_H__
#define __KERNEL_OIIO_GLOBALS_H__
#include "util/util_thread.h"
#include "util/util_vector.h"
#include <OpenImageIO/texture.h>
CCL_NAMESPACE_BEGIN
struct OIIOTexture {
OIIO::TextureSystem::TextureHandle *handle;
OIIO::TextureOpt::InterpMode interpolation;
OIIO::TextureOpt::Wrap extension;
bool is_linear;
};
struct OIIOGlobals {
OIIO::TextureSystem *tex_sys;
float diffuse_blur;
float glossy_blur;
};
CCL_NAMESPACE_END
#endif

View File

@@ -30,8 +30,8 @@
#include "kernel/kernel_write_passes.h"
#include "kernel/kernel_accumulate.h"
#include "kernel/kernel_light.h"
#include "kernel/kernel_shader.h"
#include "kernel/kernel_light.h"
#include "kernel/kernel_adaptive_sampling.h"
#include "kernel/kernel_passes.h"
@@ -354,14 +354,8 @@ ccl_device_noinline
light_ray.D = ao_D;
light_ray.t = kernel_data.background.ao_distance;
light_ray.time = sd->time;
#ifdef __RAY_DIFFERENTIALS__
light_ray.dP = sd->dP;
/* This is how pbrt v3 implements differentials for diffuse bounces */
float3 a, b;
make_orthonormals(ao_D, &a, &b);
light_ray.dD.dx = normalize(ao_D + 0.1f * a);
light_ray.dD.dy = normalize(ao_D + 0.1f * b);
#endif /* __RAY_DIFFERENTIALS__ */
light_ray.dD = differential3_zero();
if (!shadow_blocked(kg, sd, emission_sd, state, &light_ray, &ao_shadow)) {
path_radiance_accum_ao(kg, L, state, throughput, ao_alpha, ao_bsdf, ao_shadow);

View File

@@ -50,14 +50,8 @@ ccl_device_inline void kernel_branched_path_ao(KernelGlobals *kg,
light_ray.D = ao_D;
light_ray.t = kernel_data.background.ao_distance;
light_ray.time = sd->time;
# ifdef __RAY_DIFFERENTIALS__
light_ray.dP = sd->dP;
/* This is how pbrt v3 implements differentials for diffuse bounces */
float3 a, b;
make_orthonormals(ao_D, &a, &b);
light_ray.dD.dx = normalize(ao_D + 0.1f * a);
light_ray.dD.dy = normalize(ao_D + 0.1f * b);
# endif /* __RAY_DIFFERENTIALS__ */
light_ray.dD = differential3_zero();
if (!shadow_blocked(kg, sd, emission_sd, state, &light_ray, &ao_shadow)) {
path_radiance_accum_ao(

View File

@@ -146,34 +146,6 @@ ccl_device_noinline
differential_transfer(&sd->dP, ray->dP, ray->D, ray->dD, sd->Ng, isect->t);
differential_incoming(&sd->dI, ray->dD);
differential_dudv(&sd->du, &sd->dv, sd->dPdu, sd->dPdv, sd->dP, sd->Ng);
# ifdef __DNDU__
if (sd->shader & SHADER_SMOOTH_NORMAL && sd->type & PRIMITIVE_TRIANGLE) {
// TODO stefan curves
/* dNdu/dNdv */
float3 dNdu, dNdv;
triangle_dNdudv(kg, sd->prim, &dNdu, &dNdv);
sd->dNdx = dNdu * sd->du.dx + dNdv * sd->dv.dx;
sd->dNdy = dNdu * sd->du.dy + dNdv * sd->dv.dy;
/* backfacing test */
bool backfacing = (dot(sd->Ng, sd->I) < 0.0f);
if (backfacing) {
sd->dNdx = -sd->dNdx;
sd->dNdy = -sd->dNdy;
}
# ifdef __INSTANCING__
if (isect->object != OBJECT_NONE) {
/* instance transform */
object_dir_transform_auto(kg, sd, &sd->dNdx);
object_dir_transform_auto(kg, sd, &sd->dNdy);
}
# endif /* __INSTANCING__ */
}
else {
sd->dNdx = make_float3(0.0f, 0.0f, 0.0f);
sd->dNdy = make_float3(0.0f, 0.0f, 0.0f);
}
# endif /* __DNDU__ */
#endif
PROFILING_SHADER(sd->shader);
@@ -207,11 +179,6 @@ ccl_device_inline
sd->u = isect->u;
sd->v = isect->v;
# ifdef __DNDU__
sd->dNdx = make_float3(0.0f, 0.0f, 0.0f);
sd->dNdy = make_float3(0.0f, 0.0f, 0.0f);
# endif
/* fetch triangle data */
if (sd->type == PRIMITIVE_TRIANGLE) {
float3 Ng = triangle_normal(kg, sd);
@@ -228,15 +195,6 @@ ccl_device_inline
# ifdef __DPDU__
/* dPdu/dPdv */
triangle_dPdudv(kg, sd->prim, &sd->dPdu, &sd->dPdv);
# endif
# ifdef __DNDU__
/* dNdu/dNdv */
if (sd->shader & SHADER_SMOOTH_NORMAL && sd->type & PRIMITIVE_TRIANGLE) {
float3 dNdu, dNdv;
triangle_dNdudv(kg, sd->prim, &dNdu, &dNdv);
sd->dNdx = dNdu * sd->du.dx + dNdv * sd->dv.dx;
sd->dNdy = dNdu * sd->du.dy + dNdv * sd->dv.dy;
}
# endif
}
else {
@@ -253,10 +211,6 @@ ccl_device_inline
# ifdef __DPDU__
object_dir_transform_auto(kg, sd, &sd->dPdu);
object_dir_transform_auto(kg, sd, &sd->dPdv);
# endif
# ifdef __DNDU__
object_dir_transform(kg, sd, &sd->dNdx);
object_dir_transform(kg, sd, &sd->dNdy);
# endif
}
@@ -268,10 +222,6 @@ ccl_device_inline
# ifdef __DPDU__
sd->dPdu = -sd->dPdu;
sd->dPdv = -sd->dPdv;
# endif
# ifdef __DNDU__
sd->dNdx = -sd->dNdx;
sd->dNdy = -sd->dNdy;
# endif
}
@@ -296,7 +246,6 @@ ccl_device_inline void shader_setup_from_sample(KernelGlobals *kg,
const float3 P,
const float3 Ng,
const float3 I,
const differential3 *dI,
int shader,
int object,
int prim,
@@ -377,39 +326,12 @@ ccl_device_inline void shader_setup_from_sample(KernelGlobals *kg,
object_dir_transform_auto(kg, sd, &sd->dPdu);
object_dir_transform_auto(kg, sd, &sd->dPdv);
}
#endif
#ifdef __DNDU__
float3 dNdu, dNdv;
triangle_dNdudv(kg, sd->prim, &dNdu, &dNdv);
sd->dNdx = dNdu * sd->du.dx + dNdv * sd->dv.dx;
sd->dNdy = dNdu * sd->du.dy + dNdv * sd->dv.dy;
# ifdef __INSTANCING__
if (!(sd->object_flag & SD_OBJECT_TRANSFORM_APPLIED)) {
object_normal_transform_auto(kg, sd, &sd->dNdx);
object_normal_transform_auto(kg, sd, &sd->dNdy);
}
# endif
#endif
}
else if (sd->type & PRIMITIVE_LAMP) {
#ifdef __DPDU__
lamp_light_dPdudv(kg, lamp, sd->u, sd->v, &sd->dPdu, &sd->dPdv);
#endif
#ifdef __DNDU__
sd->dNdx = make_float3(0.0f, 0.0f, 0.0f);
sd->dNdy = make_float3(0.0f, 0.0f, 0.0f);
#endif
}
else {
#ifdef __DPDU__
sd->dPdu = zero_float3();
sd->dPdv = zero_float3();
#endif
#ifdef __DNDU__
sd->dNdx = make_float3(0.0f, 0.0f, 0.0f);
sd->dNdy = make_float3(0.0f, 0.0f, 0.0f);
#endif
}
@@ -424,27 +346,16 @@ ccl_device_inline void shader_setup_from_sample(KernelGlobals *kg,
#ifdef __DPDU__
sd->dPdu = -sd->dPdu;
sd->dPdv = -sd->dPdv;
#endif
#ifdef __DNDU__
sd->dNdx = -sd->dNdx;
sd->dNdx = -sd->dNdx;
#endif
}
}
#ifdef __RAY_DIFFERENTIALS__
if (dI) {
sd->dI = *dI;
differential_transfer(&sd->dP, sd->dP, I, *dI, Ng, t);
differential_dudv(&sd->du, &sd->dv, sd->dPdu, sd->dPdv, sd->dP, sd->Ng);
}
else {
sd->dP = differential3_zero();
sd->dI = differential3_zero();
sd->du = differential_zero();
sd->dv = differential_zero();
}
/* no ray differentials here yet */
sd->dP = differential3_zero();
sd->dI = differential3_zero();
sd->du = differential_zero();
sd->dv = differential_zero();
#endif
PROFILING_SHADER(sd->shader);
@@ -460,32 +371,25 @@ ccl_device void shader_setup_from_displace(
int shader;
triangle_point_normal(kg, object, prim, u, v, &P, &Ng, &shader);
triangle_dPdudv(kg, prim, &sd->dP.dx, &sd->dP.dy);
/* force smooth shading for displacement */
shader |= SHADER_SMOOTH_NORMAL;
#if 0
/* TODO Stefan - need differentials here that don't break the unfiltered case */
I = -Ng;
differential3 dI = differential3_zero();
shader_setup_from_sample(kg, sd,
P, Ng, I, &dI,
#else
shader_setup_from_sample(
kg,
sd,
P,
Ng,
I,
NULL,
#endif
shader, object, prim,
u, v, 0.0f, 0.5f,
!(kernel_tex_fetch(__object_flag, object) & SD_OBJECT_TRANSFORM_APPLIED),
LAMP_NONE);
shader,
object,
prim,
u,
v,
0.0f,
0.5f,
!(kernel_tex_fetch(__object_flag, object) & SD_OBJECT_TRANSFORM_APPLIED),
LAMP_NONE);
}
/* ShaderData setup from ray into background */
@@ -518,10 +422,6 @@ ccl_device_inline void shader_setup_from_background(KernelGlobals *kg,
sd->dPdu = zero_float3();
sd->dPdv = zero_float3();
#endif
#ifdef __DNDU__
sd->dNdx = make_float3(0.0f, 0.0f, 0.0f);
sd->dNdy = make_float3(0.0f, 0.0f, 0.0f);
#endif
#ifdef __RAY_DIFFERENTIALS__
/* differentials */
@@ -569,17 +469,11 @@ ccl_device_inline void shader_setup_from_volume(KernelGlobals *kg, ShaderData *s
sd->dPdu = zero_float3();
sd->dPdv = zero_float3();
# endif
# ifdef __DNDU__
/* dNdu/dNdv */
sd->dNdx = make_float3(0.0f, 0.0f, 0.0f);
sd->dNdy = make_float3(0.0f, 0.0f, 0.0f);
# endif
# ifdef __RAY_DIFFERENTIALS__
/* differentials */
sd->dP.dx = ray->dP.dx + ray->t * ray->dD.dx;
sd->dP.dy = ray->dP.dy + ray->t * ray->dD.dy;
differential_incoming(&sd->dI, ray->dD);
sd->dP = ray->dD;
differential_incoming(&sd->dI, sd->dP);
sd->du = differential_zero();
sd->dv = differential_zero();
# endif

View File

@@ -558,7 +558,6 @@ ccl_device_noinline
/* Sample scattering direction. */
float scatter_u, scatter_v;
path_state_rng_2D(kg, state, PRNG_BSDF_U, &scatter_u, &scatter_v);
float cos_theta;
if (guided) {
cos_theta = sample_phase_dwivedi(diffusion_length, phase_log, scatter_u);

View File

@@ -124,8 +124,6 @@ CCL_NAMESPACE_BEGIN
# endif
# define __VOLUME_DECOUPLED__
# define __VOLUME_RECORD_ALL__
# define __DNDU__
# define __OIIO__
#endif /* __KERNEL_CPU__ */
#ifdef __KERNEL_CUDA__
@@ -955,11 +953,6 @@ typedef ccl_addr_space struct ccl_align(16) ShaderData
float3 dPdu;
float3 dPdv;
#endif
#ifdef __DNDU__
/* differential of N w.r.t. x and y. */
float3 dNdx;
float3 dNdy;
#endif
#ifdef __OBJECT_MOTION__
/* object <-> world space transformations, cached to avoid

View File

@@ -34,8 +34,6 @@
# endif
#endif /* WITH_CYCLES_OPTIMIZED_KERNEL_AVX */
#define OIIO_NO_AVX 1
#include "kernel/filter/filter.h"
#define KERNEL_ARCH cpu_avx
#include "kernel/kernels/cpu/filter_cpu_impl.h"

View File

@@ -35,8 +35,6 @@
# endif
#endif /* WITH_CYCLES_OPTIMIZED_KERNEL_AVX2 */
#define OIIO_NO_AVX 1
#include "kernel/filter/filter.h"
#define KERNEL_ARCH cpu_avx2
#include "kernel/kernels/cpu/filter_cpu_impl.h"

View File

@@ -34,8 +34,6 @@
# endif
#endif /* WITH_CYCLES_OPTIMIZED_KERNEL_AVX */
#define OIIO_NO_AVX 1
#include "kernel/kernel.h"
#define KERNEL_ARCH cpu_avx
#include "kernel/kernels/cpu/kernel_cpu_impl.h"

View File

@@ -35,8 +35,6 @@
# endif
#endif /* WITH_CYCLES_OPTIMIZED_KERNEL_AVX2 */
#define OIIO_NO_AVX 1
#include "kernel/kernel.h"
#define KERNEL_ARCH cpu_avx2
#include "kernel/kernels/cpu/kernel_cpu_impl.h"

View File

@@ -23,14 +23,6 @@
# include <nanovdb/util/SampleFromVoxels.h>
#endif
#ifdef __OIIO__
# include "kernel/kernel_oiio_globals.h"
# define NEAREST_LOOKUP_PATHS \
(PATH_RAY_DIFFUSE | PATH_RAY_SHADOW | PATH_RAY_DIFFUSE_ANCESTOR | PATH_RAY_VOLUME_SCATTER | \
PATH_RAY_GLOSSY | PATH_RAY_EMISSION)
# define DIFFUSE_BLUR_PATHS (PATH_RAY_DIFFUSE | PATH_RAY_DIFFUSE_ANCESTOR)
#endif
CCL_NAMESPACE_BEGIN
/* Make template functions private so symbols don't conflict between kernels with different
@@ -592,126 +584,32 @@ template<typename T> struct NanoVDBInterpolator {
#undef SET_CUBIC_SPLINE_WEIGHTS
ccl_device float4 kernel_tex_image_interp(KernelGlobals *kg, int id, float x, float y, differential ds, differential dt, uint path_flag)
ccl_device float4 kernel_tex_image_interp(KernelGlobals *kg, int id, float x, float y)
{
const TextureInfo &info = kernel_tex_fetch(__texture_info, id);
float4 r = make_float4(TEX_IMAGE_MISSING_R, TEX_IMAGE_MISSING_G, TEX_IMAGE_MISSING_B, TEX_IMAGE_MISSING_A);
switch (info.data_type) {
case IMAGE_DATA_TYPE_HALF:
r = TextureInterpolator<half>::interp(info, x, y);
break;
return TextureInterpolator<half>::interp(info, x, y);
case IMAGE_DATA_TYPE_BYTE:
r = TextureInterpolator<uchar>::interp(info, x, y);
break;
return TextureInterpolator<uchar>::interp(info, x, y);
case IMAGE_DATA_TYPE_USHORT:
r = TextureInterpolator<uint16_t>::interp(info, x, y);
break;
return TextureInterpolator<uint16_t>::interp(info, x, y);
case IMAGE_DATA_TYPE_FLOAT:
r = TextureInterpolator<float>::interp(info, x, y);
break;
return TextureInterpolator<float>::interp(info, x, y);
case IMAGE_DATA_TYPE_HALF4:
r = TextureInterpolator<half4>::interp(info, x, y);
break;
return TextureInterpolator<half4>::interp(info, x, y);
case IMAGE_DATA_TYPE_BYTE4:
r = TextureInterpolator<uchar4>::interp(info, x, y);
break;
return TextureInterpolator<uchar4>::interp(info, x, y);
case IMAGE_DATA_TYPE_USHORT4:
r = TextureInterpolator<ushort4>::interp(info, x, y);
break;
return TextureInterpolator<ushort4>::interp(info, x, y);
case IMAGE_DATA_TYPE_FLOAT4:
r = TextureInterpolator<float4>::interp(info, x, y);
break;
case IMAGE_DATA_TYPE_OIIO:
{
#ifdef __OIIO__
/* Make sure we have all necessary data in place, if not, bail. */
kernel_assert(kg->oiio);
kernel_assert(kg->oiio->tex_sys);
kernel_assert(info.data);
if (!kg->oiio || !kg->oiio->tex_sys || !info.data) {
return r;
}
/* Options: Anisotropic is a quality/speed tradeoff.
* Interpolation and extensions are supported in OIIO under different constants.
* */
OIIO::TextureOpt options;
options.anisotropic = 8;
float missingcolor[4] = {
TEX_IMAGE_MISSING_R, TEX_IMAGE_MISSING_G, TEX_IMAGE_MISSING_B, TEX_IMAGE_MISSING_A};
options.missingcolor = missingcolor;
options.mipmode = OIIO::TextureOpt::MipModeAniso;
options.sblur = options.tblur = 0.0f;
switch (info.interpolation) {
case INTERPOLATION_SMART:
options.interpmode = OIIO::TextureOpt::InterpSmartBicubic;
break;
case INTERPOLATION_CUBIC:
options.interpmode = OIIO::TextureOpt::InterpBicubic;
break;
case INTERPOLATION_LINEAR:
options.interpmode = OIIO::TextureOpt::InterpBilinear;
break;
//case INTERPOLATION_NONE:
case INTERPOLATION_CLOSEST:
default:
options.interpmode = OIIO::TextureOpt::InterpClosest;
break;
}
switch (info.extension) {
case EXTENSION_CLIP:
options.swrap = options.twrap = OIIO::TextureOpt::WrapBlack;
break;
case EXTENSION_EXTEND:
options.swrap = options.twrap = OIIO::TextureOpt::WrapClamp;
break;
case EXTENSION_REPEAT:
default:
options.swrap = options.twrap = OIIO::TextureOpt::WrapPeriodic;
break;
}
/* Texture lookup simplifications on less important paths. */
if (path_flag & NEAREST_LOOKUP_PATHS && !(path_flag & PATH_RAY_SINGULAR)) {
options.interpmode = OIIO::TextureOpt::InterpClosest;
options.mipmode = OIIO::TextureOpt::MipModeOneLevel;
}
else {
options.mipmode = OIIO::TextureOpt::MipModeAniso;
}
if (path_flag & DIFFUSE_BLUR_PATHS) {
options.sblur = options.tblur = kg->oiio->diffuse_blur;
}
else if (path_flag & PATH_RAY_GLOSSY) {
options.sblur = options.tblur = kg->oiio->glossy_blur;
}
else {
options.sblur = options.tblur = 0.0f;
}
OIIO::TextureSystem::TextureHandle *handle = *((OIIO::TextureSystem::TextureHandle**)info.data);
kernel_assert(handle && kg->oiio->tex_sys->good(handle));
if(handle && !kg->oiio->tex_sys->good(handle)) {
return r;
}
kg->oiio->tex_sys->texture(handle,
(OIIO::TextureSystem::Perthread *)kg->oiio_tdata,
options,
x,
y,
ds.dx,
ds.dy,
dt.dx,
dt.dy,
4,
(float *)&r);
#endif
break;
}
return TextureInterpolator<float4>::interp(info, x, y);
default:
assert(0);
return make_float4(
TEX_IMAGE_MISSING_R, TEX_IMAGE_MISSING_G, TEX_IMAGE_MISSING_B, TEX_IMAGE_MISSING_A);
}
return info.compress_as_srgb ? color_srgb_to_linear_v4(r) : r;
}
ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals *kg,
@@ -748,8 +646,6 @@ ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals *kg,
case IMAGE_DATA_TYPE_NANOVDB_FLOAT3:
return NanoVDBInterpolator<nanovdb::Vec3f>::interp_3d(info, P.x, P.y, P.z, interp);
#endif
case IMAGE_DATA_TYPE_OIIO:
return make_float4(TEX_IMAGE_MISSING_R, TEX_IMAGE_MISSING_G, TEX_IMAGE_MISSING_B, TEX_IMAGE_MISSING_A);
default:
assert(0);
return make_float4(

View File

@@ -36,8 +36,6 @@
# endif
#endif /* WITH_CYCLES_OPTIMIZED_KERNEL_AVX */
#define OIIO_NO_AVX 1
#include "kernel/kernel.h"
#define KERNEL_ARCH cpu_avx
#include "kernel/kernels/cpu/kernel_cpu_impl.h"

View File

@@ -37,8 +37,6 @@
# endif
#endif /* WITH_CYCLES_OPTIMIZED_KERNEL_AVX2 */
#define OIIO_NO_AVX 1
#include "kernel/kernel.h"
#define KERNEL_ARCH cpu_avx2
#include "kernel/kernels/cpu/kernel_cpu_impl.h"

View File

@@ -178,7 +178,7 @@ ccl_device_inline T kernel_tex_image_interp_nanovdb(
}
#endif
ccl_device float4 kernel_tex_image_interp(KernelGlobals *kg, int id, float x, float y, differential, differential, uint)
ccl_device float4 kernel_tex_image_interp(KernelGlobals *kg, int id, float x, float y)
{
const TextureInfo &info = kernel_tex_fetch(__texture_info, id);

View File

@@ -123,10 +123,6 @@ ccl_device_inline float4 svm_image_texture_read(
return make_float4(r.x, r.y, r.z, r.w);
}
#endif
/* Unsupported. */
else if (texture_type == IMAGE_DATA_TYPE_OIIO) {
return make_float4(TEX_IMAGE_MISSING_R, TEX_IMAGE_MISSING_G, TEX_IMAGE_MISSING_B, TEX_IMAGE_MISSING_A);
}
/* Byte */
else {
uchar r = tex_fetch(uchar, info, data_offset);
@@ -203,7 +199,7 @@ ccl_device_inline float svm_image_texture_frac(float x, int *ix)
} \
(void)0
ccl_device float4 kernel_tex_image_interp(KernelGlobals *kg, int id, float x, float y, differential, differential, uint)
ccl_device float4 kernel_tex_image_interp(KernelGlobals *kg, int id, float x, float y)
{
const ccl_global TextureInfo *info = kernel_tex_info(kg, id);

View File

@@ -56,7 +56,6 @@
#include "kernel/kernel_projection.h"
#include "kernel/kernel_accumulate.h"
#include "kernel/kernel_light.h"
#include "kernel/kernel_shader.h"
// clang-format on
@@ -1249,12 +1248,7 @@ bool OSLRenderServices::texture(ustring filename,
}
case OSLTextureHandle::SVM: {
/* Packed texture. */
differential ds, dt;
ds.dx = dsdx;
ds.dy = dsdy;
dt.dx = dtdx;
dt.dy = dtdy;
float4 rgba = kernel_tex_image_interp(kernel_globals, handle->svm_slot, s, 1.0f - t, ds, dt, sg->raytype);
float4 rgba = kernel_tex_image_interp(kernel_globals, handle->svm_slot, s, 1.0f - t);
result[0] = rgba[0];
if (nchannels > 1)
@@ -1286,7 +1280,7 @@ bool OSLRenderServices::texture(ustring filename,
texture_thread_info,
options,
s,
1.0f - t,
t,
dsdx,
dtdx,
dsdy,
@@ -1300,7 +1294,7 @@ bool OSLRenderServices::texture(ustring filename,
status = ts->texture(filename,
options,
s,
1.0f - t,
t,
dsdx,
dtdx,
dsdy,

View File

@@ -47,6 +47,7 @@ shader node_environment_texture(
string filename = "",
string projection = "equirectangular",
string interpolation = "linear",
int compress_as_srgb = 0,
int ignore_alpha = 0,
int unassociate_alpha = 0,
int is_float = 1,
@@ -78,4 +79,7 @@ shader node_environment_texture(
if (!is_float)
Color = min(Color, 1.0);
}
if (compress_as_srgb)
Color = color_srgb_to_scene_linear(Color);
}

View File

@@ -59,6 +59,7 @@ color image_texture_lookup(string filename,
float u,
float v,
output float Alpha,
int compress_as_srgb,
int ignore_alpha,
int unassociate_alpha,
int is_float,
@@ -88,6 +89,10 @@ color image_texture_lookup(string filename,
rgb = min(rgb, 1.0);
}
if (compress_as_srgb) {
rgb = color_srgb_to_scene_linear(rgb);
}
return rgb;
}
@@ -99,6 +104,7 @@ shader node_image_texture(int use_mapping = 0,
string interpolation = "smartcubic",
string extension = "periodic",
float projection_blend = 0.0,
int compress_as_srgb = 0,
int ignore_alpha = 0,
int unassociate_alpha = 0,
int is_tiled = 0,
@@ -116,6 +122,7 @@ shader node_image_texture(int use_mapping = 0,
p[0],
p[1],
Alpha,
compress_as_srgb,
ignore_alpha,
unassociate_alpha,
is_float,
@@ -194,6 +201,7 @@ shader node_image_texture(int use_mapping = 0,
p[1],
p[2],
tmp_alpha,
compress_as_srgb,
ignore_alpha,
unassociate_alpha,
is_float,
@@ -207,6 +215,7 @@ shader node_image_texture(int use_mapping = 0,
p[0],
p[2],
tmp_alpha,
compress_as_srgb,
ignore_alpha,
unassociate_alpha,
is_float,
@@ -220,6 +229,7 @@ shader node_image_texture(int use_mapping = 0,
p[1],
p[0],
tmp_alpha,
compress_as_srgb,
ignore_alpha,
unassociate_alpha,
is_float,
@@ -235,6 +245,7 @@ shader node_image_texture(int use_mapping = 0,
projected[0],
projected[1],
Alpha,
compress_as_srgb,
ignore_alpha,
unassociate_alpha,
is_float,
@@ -248,6 +259,7 @@ shader node_image_texture(int use_mapping = 0,
projected[0],
projected[1],
Alpha,
compress_as_srgb,
ignore_alpha,
unassociate_alpha,
is_float,

View File

@@ -58,9 +58,7 @@ shader node_texture_coordinate(
getattribute("geom:uv", UV);
}
else {
if (!getattribute("geom:generated", Generated)) {
Generated = transform("object", P);
}
getattribute("geom:generated", Generated);
getattribute("geom:uv", UV);
}

View File

@@ -327,10 +327,10 @@ ccl_device_noinline void svm_eval_nodes(
break;
# endif /* NODES_FEATURE(NODE_FEATURE_BUMP) */
case NODE_TEX_IMAGE:
svm_node_tex_image(kg, sd, path_flag, stack, node, &offset);
svm_node_tex_image(kg, sd, stack, node, &offset);
break;
case NODE_TEX_IMAGE_BOX:
svm_node_tex_image_box(kg, sd, path_flag, stack, node);
svm_node_tex_image_box(kg, sd, stack, node);
break;
case NODE_TEX_NOISE:
svm_node_tex_noise(kg, sd, stack, node.y, node.z, node.w, &offset);
@@ -437,7 +437,7 @@ ccl_device_noinline void svm_eval_nodes(
svm_node_camera(kg, sd, stack, node.y, node.z, node.w);
break;
case NODE_TEX_ENVIRONMENT:
svm_node_tex_environment(kg, sd, path_flag, stack, node);
svm_node_tex_environment(kg, sd, stack, node);
break;
case NODE_TEX_SKY:
svm_node_tex_sky(kg, sd, stack, node, &offset);

View File

@@ -72,22 +72,6 @@ ccl_device void svm_node_attr(KernelGlobals *kg, ShaderData *sd, float *stack, u
}
#endif
if (node.y == ATTR_STD_GENERATED && desc.element == ATTR_ELEMENT_NONE) {
/* No generated attribute, fall back to object coordinates. */
float3 f = sd->P;
object_inverse_position_transform(kg, sd, &f);
if (type == NODE_ATTR_OUTPUT_FLOAT) {
stack_store_float(stack, out_offset, average(f));
}
else if (type == NODE_ATTR_OUTPUT_FLOAT3) {
stack_store_float3(stack, out_offset, f);
}
else {
stack_store_float(stack, out_offset, 1.0f);
}
return;
}
/* Surface. */
if (desc.type == NODE_ATTR_FLOAT) {
float f = primitive_surface_attribute_float(kg, sd, desc, NULL, NULL);
@@ -161,22 +145,6 @@ ccl_device void svm_node_attr_bump_dx(KernelGlobals *kg, ShaderData *sd, float *
}
#endif
if (node.y == ATTR_STD_GENERATED && desc.element == ATTR_ELEMENT_NONE) {
/* No generated attribute, fall back to object coordinates. */
float3 f = sd->P + sd->dP.dx;
object_inverse_position_transform(kg, sd, &f);
if (type == NODE_ATTR_OUTPUT_FLOAT) {
stack_store_float(stack, out_offset, average(f));
}
else if (type == NODE_ATTR_OUTPUT_FLOAT3) {
stack_store_float3(stack, out_offset, f);
}
else {
stack_store_float(stack, out_offset, 1.0f);
}
return;
}
/* Surface */
if (desc.type == NODE_ATTR_FLOAT) {
float dx;
@@ -254,22 +222,6 @@ ccl_device void svm_node_attr_bump_dy(KernelGlobals *kg, ShaderData *sd, float *
}
#endif
if (node.y == ATTR_STD_GENERATED && desc.element == ATTR_ELEMENT_NONE) {
/* No generated attribute, fall back to object coordinates. */
float3 f = sd->P + sd->dP.dy;
object_inverse_position_transform(kg, sd, &f);
if (type == NODE_ATTR_OUTPUT_FLOAT) {
stack_store_float(stack, out_offset, average(f));
}
else if (type == NODE_ATTR_OUTPUT_FLOAT3) {
stack_store_float3(stack, out_offset, f);
}
else {
stack_store_float(stack, out_offset, 1.0f);
}
return;
}
/* Surface */
if (desc.type == NODE_ATTR_FLOAT) {
float dy;

View File

@@ -16,21 +16,14 @@
CCL_NAMESPACE_BEGIN
ccl_device float4 svm_image_texture(KernelGlobals *kg,
int id,
float x,
float y,
differential ds,
differential dt,
uint flags,
int path_flag)
ccl_device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y, uint flags)
{
if (id == -1) {
return make_float4(
TEX_IMAGE_MISSING_R, TEX_IMAGE_MISSING_G, TEX_IMAGE_MISSING_B, TEX_IMAGE_MISSING_A);
}
float4 r = kernel_tex_image_interp(kg, id, x, y, ds, dt, path_flag);
float4 r = kernel_tex_image_interp(kg, id, x, y);
const float alpha = r.w;
if ((flags & NODE_IMAGE_ALPHA_UNASSOCIATE) && alpha != 1.0f && alpha != 0.0f) {
@@ -38,6 +31,10 @@ ccl_device float4 svm_image_texture(KernelGlobals *kg,
r.w = alpha;
}
if (flags & NODE_IMAGE_COMPRESS_AS_SRGB) {
r = color_srgb_to_linear_v4(r);
}
return r;
}
@@ -48,21 +45,19 @@ ccl_device_inline float3 texco_remap_square(float3 co)
}
ccl_device void svm_node_tex_image(
KernelGlobals *kg, ShaderData *sd, int path_flag, float *stack, uint4 node, int *offset)
KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
{
uint co_offset, out_offset, alpha_offset, flags;
uint projection, dx_offset, dy_offset, unused;
svm_unpack_node_uchar4(node.z, &co_offset, &out_offset, &alpha_offset, &flags);
svm_unpack_node_uchar4(node.w, &projection, &dx_offset, &dy_offset, &unused);
float3 co = stack_load_float3(stack, co_offset);
float2 tex_co;
if (projection == NODE_IMAGE_PROJ_SPHERE) {
if (node.w == NODE_IMAGE_PROJ_SPHERE) {
co = texco_remap_square(co);
tex_co = map_to_sphere(co);
}
else if (projection == NODE_IMAGE_PROJ_TUBE) {
else if (node.w == NODE_IMAGE_PROJ_TUBE) {
co = texco_remap_square(co);
tex_co = map_to_tube(co);
}
@@ -70,40 +65,6 @@ ccl_device void svm_node_tex_image(
tex_co = make_float2(co.x, co.y);
}
differential ds, dt;
#ifdef __KERNEL_CPU__
if (stack_valid(dx_offset) && stack_valid(dy_offset)) {
float3 dx = stack_load_float3(stack, dx_offset);
float3 dy = stack_load_float3(stack, dy_offset);
float2 tex_co_dx, tex_co_dy;
if (projection == NODE_IMAGE_PROJ_SPHERE) {
dx = texco_remap_square(dx);
tex_co_dx = map_to_sphere(dx);
dy = texco_remap_square(dy);
tex_co_dy = map_to_sphere(dy);
}
else if (projection == NODE_IMAGE_PROJ_TUBE) {
dx = texco_remap_square(dx);
tex_co_dx = map_to_tube(dx);
dy = texco_remap_square(dy);
tex_co_dy = map_to_tube(dy);
}
else {
tex_co_dx = make_float2(dx.x, dx.y);
tex_co_dy = make_float2(dy.x, dy.y);
}
ds.dx = tex_co_dx.x - tex_co.x;
ds.dy = tex_co_dy.x - tex_co.x;
dt.dx = tex_co_dx.y - tex_co.y;
dt.dy = tex_co_dy.y - tex_co.y;
}
else
#endif
{
ds = differential_zero();
dt = differential_zero();
}
/* TODO(lukas): Consider moving tile information out of the SVM node.
* TextureInfo seems a reasonable candidate. */
int id = -1;
@@ -147,7 +108,7 @@ ccl_device void svm_node_tex_image(
id = -num_nodes;
}
float4 f = svm_image_texture(kg, id, tex_co.x, tex_co.y, ds, dt, flags, path_flag);
float4 f = svm_image_texture(kg, id, tex_co.x, tex_co.y, flags);
if (stack_valid(out_offset))
stack_store_float3(stack, out_offset, make_float3(f.x, f.y, f.z));
@@ -155,8 +116,7 @@ ccl_device void svm_node_tex_image(
stack_store_float(stack, alpha_offset, f.w);
}
ccl_device void svm_node_tex_image_box(
KernelGlobals *kg, ShaderData *sd, int path_flag, float *stack, uint4 node)
ccl_device void svm_node_tex_image_box(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
{
/* get object space normal */
float3 N = sd->N;
@@ -184,9 +144,7 @@ ccl_device void svm_node_tex_image_box(
* 7 zones, with an if() test for each zone */
float3 weight = make_float3(0.0f, 0.0f, 0.0f);
uint blend_hi, blend_lo, dx_offset, dy_offset;
svm_unpack_node_uchar4(node.w, &blend_hi, &blend_lo, &dx_offset, &dy_offset);
float blend = ((blend_hi << 8) + blend_lo) / 65536.0f;
float blend = __int_as_float(node.w);
float limit = 0.5f * (1.0f + blend);
/* first test for corners with single texture */
@@ -237,49 +195,30 @@ ccl_device void svm_node_tex_image_box(
float4 f = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
float3 co_dx = make_float3(0.0f, 0.0f, 0.0f);
float3 co_dy = make_float3(0.0f, 0.0f, 0.0f);
differential ds, dt;
#ifdef __KERNEL_CPU__
if (stack_valid(dx_offset) && stack_valid(dy_offset)) {
co_dx = co - stack_load_float3(stack, dx_offset);
co_dy = co - stack_load_float3(stack, dy_offset);
}
#endif
/* Map so that no textures are flipped, rotation is somewhat arbitrary. */
if (weight.x > 0.0f) {
float2 uv = make_float2((signed_N.x < 0.0f) ? 1.0f - co.y : co.y, co.z);
ds.dx = co_dx.y;
ds.dy = co_dy.y;
dt.dx = co_dx.z;
dt.dy = co_dy.z;
f += weight.x * svm_image_texture(kg, id, uv.x, uv.y, ds, dt, flags, path_flag);
f += weight.x * svm_image_texture(kg, id, uv.x, uv.y, flags);
}
if (weight.y > 0.0f) {
float2 uv = make_float2((signed_N.y < 0.0f) ? 1.0f - co.x : co.x, co.z);
ds.dx = co_dx.x;
ds.dy = co_dy.x;
dt.dx = co_dx.z;
dt.dy = co_dy.z;
f += weight.y * svm_image_texture(kg, id, uv.x, uv.y, ds, dt, flags, path_flag);
float2 uv = make_float2((signed_N.y > 0.0f) ? 1.0f - co.x : co.x, co.z);
f += weight.y * svm_image_texture(kg, id, uv.x, uv.y, flags);
}
if (weight.z > 0.0f) {
float2 uv = make_float2((signed_N.z < 0.0f) ? 1.0f - co.y : co.y, co.x);
ds.dx = co_dx.y;
ds.dy = co_dy.y;
dt.dx = co_dx.x;
dt.dy = co_dy.x;
f += weight.z * svm_image_texture(kg, id, uv.x, uv.y, ds, dt, flags, path_flag);
float2 uv = make_float2((signed_N.z > 0.0f) ? 1.0f - co.y : co.y, co.x);
f += weight.z * svm_image_texture(kg, id, uv.x, uv.y, flags);
}
if (stack_valid(out_offset))
stack_store_float3(stack, out_offset, make_float3(f.x, f.y, f.z));
if (stack_valid(alpha_offset))
stack_store_float(stack, alpha_offset, f.w);
}
ccl_device void svm_node_tex_environment(
KernelGlobals *kg, ShaderData *sd, int path_flag, float *stack, uint4 node)
ccl_device void svm_node_tex_environment(KernelGlobals *kg,
ShaderData *sd,
float *stack,
uint4 node)
{
uint id = node.y;
uint co_offset, out_offset, alpha_offset, flags;
@@ -297,8 +236,7 @@ ccl_device void svm_node_tex_environment(
else
uv = direction_to_mirrorball(co);
float4 f = svm_image_texture(
kg, id, uv.x, uv.y, differential_zero(), differential_zero(), flags, path_flag);
float4 f = svm_image_texture(kg, id, uv.x, uv.y, flags);
if (stack_valid(out_offset))
stack_store_float3(stack, out_offset, make_float3(f.x, f.y, f.z));

View File

@@ -141,8 +141,6 @@ ccl_device float3 sky_radiance_nishita(KernelGlobals *kg,
float3 xyz;
/* convert dir to spherical coordinates */
float2 direction = direction_to_spherical(dir);
differential ds, dt;
ds.dx = ds.dy = dt.dx = dt.dy = 0.0f;
/* render above the horizon */
if (dir.z >= 0.0f) {
@@ -186,7 +184,7 @@ ccl_device float3 sky_radiance_nishita(KernelGlobals *kg,
if (x > 1.0f) {
x -= 1.0f;
}
xyz = float4_to_float3(kernel_tex_image_interp(kg, texture_id, x, y, ds, dt, 0));
xyz = float4_to_float3(kernel_tex_image_interp(kg, texture_id, x, y));
}
}
/* ground */
@@ -203,7 +201,7 @@ ccl_device float3 sky_radiance_nishita(KernelGlobals *kg,
if (x > 1.0f) {
x -= 1.0f;
}
xyz = float4_to_float3(kernel_tex_image_interp(kg, texture_id, x, -0.5f, ds, dt, 0)) * fade;
xyz = float4_to_float3(kernel_tex_image_interp(kg, texture_id, x, -0.5)) * fade;
}
}

View File

@@ -121,9 +121,6 @@ ccl_device void svm_node_tex_coord_bump_dx(
}
case NODE_TEXCO_NORMAL: {
data = sd->N;
# ifdef __DNDU__
data = sd->N + sd->dNdx;
# endif
object_inverse_normal_transform(kg, sd, &data);
break;
}
@@ -204,9 +201,6 @@ ccl_device void svm_node_tex_coord_bump_dy(
}
case NODE_TEXCO_NORMAL: {
data = sd->N;
# ifdef __DNDU__
data = sd->N + sd->dNdy;
# endif
object_inverse_normal_transform(kg, sd, &data);
break;
}
@@ -273,7 +267,7 @@ ccl_device void svm_node_normal_map(KernelGlobals *kg, ShaderData *sd, float *st
if (space == NODE_NORMAL_MAP_TANGENT) {
/* tangent space */
if (sd->object == OBJECT_NONE || (sd->type & PRIMITIVE_ALL_TRIANGLE) == 0) {
if (sd->object == OBJECT_NONE) {
/* Fallback to unperturbed normal. */
stack_store_float3(stack, normal_offset, sd->N);
return;
@@ -282,8 +276,10 @@ ccl_device void svm_node_normal_map(KernelGlobals *kg, ShaderData *sd, float *st
/* first try to get tangent attribute */
const AttributeDescriptor attr = find_attribute(kg, sd, node.z);
const AttributeDescriptor attr_sign = find_attribute(kg, sd, node.w);
const AttributeDescriptor attr_normal = find_attribute(kg, sd, ATTR_STD_VERTEX_NORMAL);
if (attr.offset == ATTR_STD_NOT_FOUND || attr_sign.offset == ATTR_STD_NOT_FOUND) {
if (attr.offset == ATTR_STD_NOT_FOUND || attr_sign.offset == ATTR_STD_NOT_FOUND ||
attr_normal.offset == ATTR_STD_NOT_FOUND) {
/* Fallback to unperturbed normal. */
stack_store_float3(stack, normal_offset, sd->N);
return;
@@ -295,7 +291,7 @@ ccl_device void svm_node_normal_map(KernelGlobals *kg, ShaderData *sd, float *st
float3 normal;
if (sd->shader & SHADER_SMOOTH_NORMAL) {
normal = triangle_smooth_normal_unnormalized(kg, sd->Ng, sd->prim, sd->u, sd->v);
normal = primitive_surface_attribute_float3(kg, sd, attr_normal, NULL, NULL);
}
else {
normal = sd->Ng;

View File

@@ -25,7 +25,6 @@
#include "render/shader.h"
#include "util/util_foreach.h"
#include "util/util_logging.h"
#include "util/util_progress.h"
#include "util/util_transform.h"
#include "util/util_vector.h"
@@ -212,35 +211,6 @@ void CachedData::set_time_sampling(TimeSampling time_sampling)
}
}
size_t CachedData::memory_used() const
{
size_t mem_used = 0;
mem_used += curve_first_key.memory_used();
mem_used += curve_keys.memory_used();
mem_used += curve_radius.memory_used();
mem_used += curve_shader.memory_used();
mem_used += num_ngons.memory_used();
mem_used += shader.memory_used();
mem_used += subd_creases_edge.memory_used();
mem_used += subd_creases_weight.memory_used();
mem_used += subd_face_corners.memory_used();
mem_used += subd_num_corners.memory_used();
mem_used += subd_ptex_offset.memory_used();
mem_used += subd_smooth.memory_used();
mem_used += subd_start_corner.memory_used();
mem_used += transforms.memory_used();
mem_used += triangles.memory_used();
mem_used += uv_loops.memory_used();
mem_used += vertices.memory_used();
for (const CachedAttribute &attr : attributes) {
mem_used += attr.data.memory_used();
}
return mem_used;
}
static M44d convert_yup_zup(const M44d &mtx, float scale_mult)
{
V3d scale, shear, rotation, translation;
@@ -415,8 +385,6 @@ NODE_DEFINE(AlembicObject)
SOCKET_STRING(path, "Alembic Path", ustring());
SOCKET_NODE_ARRAY(used_shaders, "Used Shaders", Shader::get_node_type());
SOCKET_BOOLEAN(ignore_subdivision, "Ignore Subdivision", true);
SOCKET_INT(subd_max_level, "Max Subdivision Level", 1);
SOCKET_FLOAT(subd_dicing_rate, "Subdivision Dicing Rate", 1.0f);
@@ -502,33 +470,6 @@ void AlembicObject::load_data_in_cache(CachedData &cached_data,
cached_data.clear();
if (this->get_ignore_subdivision()) {
PolyMeshSchemaData data;
data.topology_variance = schema.getTopologyVariance();
data.time_sampling = schema.getTimeSampling();
data.positions = schema.getPositionsProperty();
data.face_counts = schema.getFaceCountsProperty();
data.face_indices = schema.getFaceIndicesProperty();
data.num_samples = schema.getNumSamples();
data.velocities = schema.getVelocitiesProperty();
data.shader_face_sets = parse_face_sets_for_shader_assignment(schema, get_used_shaders());
read_geometry_data(proc, cached_data, data, progress);
if (progress.get_cancel()) {
return;
}
/* Use the schema as the base compound property to also be able to look for top level
* properties. */
read_attributes(
proc, cached_data, schema, schema.getUVsParam(), get_requested_attributes(), progress);
cached_data.invalidate_last_loaded_time(true);
data_loaded = true;
return;
}
SubDSchemaData data;
data.time_sampling = schema.getTimeSampling();
data.num_samples = schema.getNumSamples();
@@ -736,9 +677,6 @@ NODE_DEFINE(AlembicProcedural)
SOCKET_NODE_ARRAY(objects, "Objects", AlembicObject::get_node_type());
SOCKET_BOOLEAN(use_prefetch, "Use Prefetch", true);
SOCKET_INT(prefetch_cache_size, "Prefetch Cache Size", 4096);
return type;
}
@@ -843,43 +781,6 @@ void AlembicProcedural::generate(Scene *scene, Progress &progress)
const chrono_t frame_time = (chrono_t)((frame - frame_offset) / frame_rate);
/* Clear the subdivision caches as the data is stored differently. */
for (Node *node : objects) {
AlembicObject *object = static_cast<AlembicObject *>(node);
if (object->schema_type != AlembicObject::SUBD) {
continue;
}
if (object->ignore_subdivision_is_modified()) {
object->clear_cache();
}
}
if (use_prefetch_is_modified()) {
if (!use_prefetch) {
for (Node *node : objects) {
AlembicObject *object = static_cast<AlembicObject *>(node);
object->clear_cache();
}
}
}
if (prefetch_cache_size_is_modified()) {
/* Check whether the current memory usage fits in the new requested size,
* abort the render if it is any higher. */
size_t memory_used = 0ul;
for (Node *node : objects) {
AlembicObject *object = static_cast<AlembicObject *>(node);
memory_used += object->get_cached_data().memory_used();
}
if (memory_used > get_prefetch_cache_size_in_bytes()) {
progress.set_error("Error: Alembic Procedural memory limit reached");
return;
}
}
build_caches(progress);
foreach (Node *node, objects) {
@@ -1058,6 +959,14 @@ void AlembicProcedural::read_mesh(AlembicObject *abc_object, Abc::chrono_t frame
update_attributes(mesh->attributes, cached_data, frame_time);
/* we don't yet support arbitrary attributes, for now add vertex
* coordinates as generated coordinates if requested */
if (mesh->need_attribute(scene_, ATTR_STD_GENERATED)) {
Attribute *attr = mesh->attributes.add(ATTR_STD_GENERATED);
memcpy(
attr->data_float3(), mesh->get_verts().data(), sizeof(float3) * mesh->get_verts().size());
}
if (mesh->is_modified()) {
bool need_rebuild = mesh->triangles_is_modified();
mesh->tag_update(scene_, need_rebuild);
@@ -1066,13 +975,13 @@ void AlembicProcedural::read_mesh(AlembicObject *abc_object, Abc::chrono_t frame
void AlembicProcedural::read_subd(AlembicObject *abc_object, Abc::chrono_t frame_time)
{
if (abc_object->get_ignore_subdivision()) {
read_mesh(abc_object, frame_time);
return;
}
CachedData &cached_data = abc_object->get_cached_data();
if (abc_object->subd_max_level_is_modified() || abc_object->subd_dicing_rate_is_modified()) {
/* need to reset the current data is something changed */
cached_data.invalidate_last_loaded_time();
}
/* Update sockets. */
Object *object = abc_object->get_object();
@@ -1087,11 +996,6 @@ void AlembicProcedural::read_subd(AlembicObject *abc_object, Abc::chrono_t frame
return;
}
if (abc_object->subd_max_level_is_modified() || abc_object->subd_dicing_rate_is_modified()) {
/* need to reset the current data is something changed */
cached_data.invalidate_last_loaded_time();
}
Mesh *mesh = static_cast<Mesh *>(object->get_geometry());
/* Make sure shader ids are also updated. */
@@ -1149,6 +1053,14 @@ void AlembicProcedural::read_subd(AlembicObject *abc_object, Abc::chrono_t frame
update_attributes(mesh->subd_attributes, cached_data, frame_time);
/* we don't yet support arbitrary attributes, for now add vertex
* coordinates as generated coordinates if requested */
if (mesh->need_attribute(scene_, ATTR_STD_GENERATED)) {
Attribute *attr = mesh->attributes.add(ATTR_STD_GENERATED);
memcpy(
attr->data_float3(), mesh->get_verts().data(), sizeof(float3) * mesh->get_verts().size());
}
if (mesh->is_modified()) {
bool need_rebuild = (mesh->triangles_is_modified()) ||
(mesh->subd_num_corners_is_modified()) ||
@@ -1198,6 +1110,17 @@ void AlembicProcedural::read_curves(AlembicObject *abc_object, Abc::chrono_t fra
update_attributes(hair->attributes, cached_data, frame_time);
/* we don't yet support arbitrary attributes, for now add first keys as generated coordinates if
* requested */
if (hair->need_attribute(scene_, ATTR_STD_GENERATED)) {
Attribute *attr_generated = hair->attributes.add(ATTR_STD_GENERATED);
float3 *generated = attr_generated->data_float3();
for (size_t i = 0; i < hair->num_curves(); i++) {
generated[i] = hair->get_curve_keys()[hair->get_curve(i).first_key];
}
}
const bool rebuild = (hair->curve_keys_is_modified() || hair->curve_radius_is_modified());
hair->tag_update(scene_, rebuild);
}
@@ -1357,8 +1280,6 @@ void AlembicProcedural::walk_hierarchy(
void AlembicProcedural::build_caches(Progress &progress)
{
size_t memory_used = 0;
for (Node *node : objects) {
AlembicObject *object = static_cast<AlembicObject *>(node);
@@ -1412,18 +1333,7 @@ void AlembicProcedural::build_caches(Progress &progress)
if (scale_is_modified() || object->get_cached_data().transforms.size() == 0) {
object->setup_transform_cache(object->get_cached_data(), scale);
}
memory_used += object->get_cached_data().memory_used();
if (use_prefetch) {
if (memory_used > get_prefetch_cache_size_in_bytes()) {
progress.set_error("Error: Alembic Procedural memory limit reached");
return;
}
}
}
VLOG(1) << "AlembicProcedural memory usage : " << string_human_readable_size(memory_used);
}
CCL_NAMESPACE_END

View File

@@ -272,21 +272,6 @@ template<typename T> class DataStore {
node->set(*socket, value);
}
size_t memory_used() const
{
if constexpr (is_array<T>::value) {
size_t mem_used = 0;
for (const T &array : data) {
mem_used += array.size() * sizeof(array[0]);
}
return mem_used;
}
return data.size() * sizeof(T);
}
private:
const TimeIndexPair &get_index_for_time(double time) const
{
@@ -347,8 +332,6 @@ struct CachedData {
void invalidate_last_loaded_time(bool attributes_only = false);
void set_time_sampling(Alembic::AbcCoreAbstract::TimeSampling time_sampling);
size_t memory_used() const;
};
/* Representation of an Alembic object for the AlembicProcedural.
@@ -370,10 +353,6 @@ class AlembicObject : public Node {
/* Shaders used for rendering. */
NODE_SOCKET_API_ARRAY(array<Node *>, used_shaders)
/* Treat this subdivision object as a regular polygon mesh, so no subdivision will be performed.
*/
NODE_SOCKET_API(bool, ignore_subdivision)
/* Maximum number of subdivisions for ISubD objects. */
NODE_SOCKET_API(int, subd_max_level)
@@ -437,11 +416,6 @@ class AlembicObject : public Node {
return cached_data_.is_constant();
}
void clear_cache()
{
cached_data_.clear();
}
Object *object = nullptr;
bool data_loaded = false;
@@ -499,13 +473,6 @@ class AlembicProcedural : public Procedural {
* software. */
NODE_SOCKET_API(float, scale)
/* Cache controls */
NODE_SOCKET_API(bool, use_prefetch)
/* Memory limit for the cache, if the data does not fit within this limit, rendering is aborted.
*/
NODE_SOCKET_API(int, prefetch_cache_size)
AlembicProcedural();
~AlembicProcedural();
@@ -555,12 +522,6 @@ class AlembicProcedural : public Procedural {
void read_subd(AlembicObject *abc_object, Alembic::AbcGeom::Abc::chrono_t frame_time);
void build_caches(Progress &progress);
size_t get_prefetch_cache_size_in_bytes() const
{
/* prefetch_cache_size is in megabytes, so convert to bytes. */
return static_cast<size_t>(prefetch_cache_size) * 1024 * 1024;
}
};
CCL_NAMESPACE_END

View File

@@ -44,19 +44,9 @@ static set<chrono_t> get_relevant_sample_times(AlembicProcedural *proc,
return result;
}
double start_frame;
double end_frame;
if (proc->get_use_prefetch()) {
// load the data for the entire animation
start_frame = static_cast<double>(proc->get_start_frame());
end_frame = static_cast<double>(proc->get_end_frame());
}
else {
// load the data for the current frame
start_frame = static_cast<double>(proc->get_frame());
end_frame = start_frame;
}
// load the data for the entire animation
const double start_frame = static_cast<double>(proc->get_start_frame());
const double end_frame = static_cast<double>(proc->get_end_frame());
const double frame_rate = static_cast<double>(proc->get_frame_rate());
const double start_time = start_frame / frame_rate;

Some files were not shown because too many files have changed in this diff Show More