diff options
author | Lukas Stockner <lukas.stockner@freenet.de> | 2019-05-02 16:45:31 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-05-03 16:42:49 +0300 |
commit | 68b15fc3ad4f74be192150d3a2fb35e7ef2d4edd (patch) | |
tree | 26c2aa7b37c3520417acf13b4a80c3023346b1c2 /intern/cycles/kernel | |
parent | dba4684f82a179a5c8abdae5940bc7c35e65a1a7 (diff) |
Cycles: support loading images from arbitrary OpenColorIO color space
These are the internal changes to Cycles, for Blender integration there are no
functional changes in this commit.
Images are converted to scene linear color space on file load, and on reading
from the OpenImageIO texture cache. 8-bit images are compressed with the sRGB
transfer function to avoid precision loss while keeping memory usages low. This
also means that for common cases of 8-bit sRGB images no conversion happens at
all on image loading.
Initial patch by Lukas, completed by Brecht.
Differential Revision: https://developer.blender.org/D3491
Diffstat (limited to 'intern/cycles/kernel')
-rw-r--r-- | intern/cycles/kernel/osl/osl_globals.h | 13 | ||||
-rw-r--r-- | intern/cycles/kernel/osl/osl_services.cpp | 10 | ||||
-rw-r--r-- | intern/cycles/kernel/svm/svm_types.h | 5 |
3 files changed, 14 insertions, 14 deletions
diff --git a/intern/cycles/kernel/osl/osl_globals.h b/intern/cycles/kernel/osl/osl_globals.h index 414aaf891db..51bc5cf81a9 100644 --- a/intern/cycles/kernel/osl/osl_globals.h +++ b/intern/cycles/kernel/osl/osl_globals.h @@ -37,6 +37,7 @@ using std::isfinite; CCL_NAMESPACE_BEGIN class OSLRenderServices; +class ColorSpaceProcessor; /* OSL Texture Handle * @@ -53,21 +54,15 @@ class OSLRenderServices; struct OSLTextureHandle : public OIIO::RefCnt { enum Type { OIIO, SVM, IES, BEVEL, AO }; - OSLTextureHandle() : type(OIIO), svm_slot(-1), oiio_handle(NULL) - { - } - - OSLTextureHandle(Type type) : type(type), svm_slot(-1), oiio_handle(NULL) - { - } - - OSLTextureHandle(Type type, int svm_slot) : type(type), svm_slot(svm_slot), oiio_handle(NULL) + OSLTextureHandle(Type type = OIIO, int svm_slot = -1) + : type(type), svm_slot(svm_slot), oiio_handle(NULL), processor(NULL) { } Type type; int svm_slot; OSL::TextureSystem::TextureHandle *oiio_handle; + ColorSpaceProcessor *processor; }; typedef OIIO::intrusive_ptr<OSLTextureHandle> OSLTextureHandleRef; diff --git a/intern/cycles/kernel/osl/osl_services.cpp b/intern/cycles/kernel/osl/osl_services.cpp index 7de596a2c30..0257f569f4a 100644 --- a/intern/cycles/kernel/osl/osl_services.cpp +++ b/intern/cycles/kernel/osl/osl_services.cpp @@ -25,6 +25,7 @@ #include <string.h> +#include "render/colorspace.h" #include "render/mesh.h" #include "render/object.h" #include "render/scene.h" @@ -1116,6 +1117,9 @@ bool OSLRenderServices::texture(ustring filename, * other nasty stuff happening. */ ts->geterror(); } + else if (handle && handle->processor) { + ColorSpaceManager::to_scene_linear(handle->processor, result, nchannels); + } break; } } @@ -1213,6 +1217,9 @@ bool OSLRenderServices::texture3d(ustring filename, * other nasty stuff happening. */ ts->geterror(); } + else if (handle && handle->processor) { + ColorSpaceManager::to_scene_linear(handle->processor, result, nchannels); + } break; } case OSLTextureHandle::IES: @@ -1287,6 +1294,9 @@ bool OSLRenderServices::environment(ustring filename, result[3] = 1.0f; } } + else if (handle && handle->processor) { + ColorSpaceManager::to_scene_linear(handle->processor, result, nchannels); + } return status; } diff --git a/intern/cycles/kernel/svm/svm_types.h b/intern/cycles/kernel/svm/svm_types.h index d31e4f93696..2e4d0c81b95 100644 --- a/intern/cycles/kernel/svm/svm_types.h +++ b/intern/cycles/kernel/svm/svm_types.h @@ -373,11 +373,6 @@ typedef enum NodeNormalMapSpace { NODE_NORMAL_MAP_BLENDER_WORLD, } NodeNormalMapSpace; -typedef enum NodeImageColorSpace { - NODE_COLOR_SPACE_NONE = 0, - NODE_COLOR_SPACE_COLOR = 1, -} NodeImageColorSpace; - typedef enum NodeImageProjection { NODE_IMAGE_PROJ_FLAT = 0, NODE_IMAGE_PROJ_BOX = 1, |