diff options
author | Lukas Stockner <lukas.stockner@freenet.de> | 2018-06-14 18:48:19 +0300 |
---|---|---|
committer | Lukas Stockner <lukas.stockner@freenet.de> | 2018-06-14 23:21:37 +0300 |
commit | 3ee606621cf53a2a4897e534e7e04d3632f419f8 (patch) | |
tree | e8ffff99f0ceeea46aa170298853d8034a1acf1d /intern/cycles/blender | |
parent | 064e701472ac430c8063ab5d577b5014eecf9ad5 (diff) |
Cycles: Query XYZ to/from Scene Linear conversion from OCIO instead of assuming sRGB
I've limited it to just the RGB<->XYZ stuff for now, correct image handling is the next step.
Reviewers: brecht, sergey
Differential Revision: https://developer.blender.org/D3478
Diffstat (limited to 'intern/cycles/blender')
-rw-r--r-- | intern/cycles/blender/blender_curves.cpp | 16 | ||||
-rw-r--r-- | intern/cycles/blender/blender_mesh.cpp | 12 | ||||
-rw-r--r-- | intern/cycles/blender/blender_session.cpp | 4 |
3 files changed, 20 insertions, 12 deletions
diff --git a/intern/cycles/blender/blender_curves.cpp b/intern/cycles/blender/blender_curves.cpp index 81d6a21cd13..5fd3455061d 100644 --- a/intern/cycles/blender/blender_curves.cpp +++ b/intern/cycles/blender/blender_curves.cpp @@ -784,17 +784,18 @@ static void ExportCurveTriangleVcol(ParticleCurveData *CData, for(int curvekey = CData->curve_firstkey[curve]; curvekey < CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 1; curvekey++) { for(int section = 0; section < resol; section++) { - cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear_v3(CData->curve_vcol[curve])); + /* Encode vertex color using the sRGB curve. */ + cdata[vertexindex] = color_float_to_byte(color_srgb_to_linear_v3(CData->curve_vcol[curve])); vertexindex++; - cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear_v3(CData->curve_vcol[curve])); + cdata[vertexindex] = color_float_to_byte(color_srgb_to_linear_v3(CData->curve_vcol[curve])); vertexindex++; - cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear_v3(CData->curve_vcol[curve])); + cdata[vertexindex] = color_float_to_byte(color_srgb_to_linear_v3(CData->curve_vcol[curve])); vertexindex++; - cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear_v3(CData->curve_vcol[curve])); + cdata[vertexindex] = color_float_to_byte(color_srgb_to_linear_v3(CData->curve_vcol[curve])); vertexindex++; - cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear_v3(CData->curve_vcol[curve])); + cdata[vertexindex] = color_float_to_byte(color_srgb_to_linear_v3(CData->curve_vcol[curve])); vertexindex++; - cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear_v3(CData->curve_vcol[curve])); + cdata[vertexindex] = color_float_to_byte(color_srgb_to_linear_v3(CData->curve_vcol[curve])); vertexindex++; } } @@ -1010,9 +1011,10 @@ void BlenderSync::sync_curves(Mesh *mesh, if(fdata) { size_t i = 0; + /* Encode vertex color using the sRGB curve. */ for(size_t curve = 0; curve < CData.curve_vcol.size(); curve++) if(!(CData.curve_keynum[curve] <= 1 || CData.curve_length[curve] == 0.0f)) - fdata[i++] = color_srgb_to_scene_linear_v3(CData.curve_vcol[curve]); + fdata[i++] = color_srgb_to_linear_v3(CData.curve_vcol[curve]); } } } diff --git a/intern/cycles/blender/blender_mesh.cpp b/intern/cycles/blender/blender_mesh.cpp index 76d17bc1ae6..8d2ade1e30b 100644 --- a/intern/cycles/blender/blender_mesh.cpp +++ b/intern/cycles/blender/blender_mesh.cpp @@ -401,7 +401,8 @@ static void attr_create_vertex_color(Scene *scene, int n = p->loop_total(); for(int i = 0; i < n; i++) { float3 color = get_float3(l->data[p->loop_start() + i].color()); - *(cdata++) = color_float_to_byte(color_srgb_to_scene_linear_v3(color)); + /* Encode vertex color using the sRGB curve. */ + *(cdata++) = color_float_to_byte(color_srgb_to_linear_v3(color)); } } } @@ -424,12 +425,13 @@ static void attr_create_vertex_color(Scene *scene, int tri_a[3], tri_b[3]; face_split_tri_indices(face_flags[i], tri_a, tri_b); + /* Encode vertex color using the sRGB curve. */ uchar4 colors[4]; - colors[0] = color_float_to_byte(color_srgb_to_scene_linear_v3(get_float3(c->color1()))); - colors[1] = color_float_to_byte(color_srgb_to_scene_linear_v3(get_float3(c->color2()))); - colors[2] = color_float_to_byte(color_srgb_to_scene_linear_v3(get_float3(c->color3()))); + colors[0] = color_float_to_byte(color_srgb_to_linear_v3(get_float3(c->color1()))); + colors[1] = color_float_to_byte(color_srgb_to_linear_v3(get_float3(c->color2()))); + colors[2] = color_float_to_byte(color_srgb_to_linear_v3(get_float3(c->color3()))); if(nverts[i] == 4) { - colors[3] = color_float_to_byte(color_srgb_to_scene_linear_v3(get_float3(c->color4()))); + colors[3] = color_float_to_byte(color_srgb_to_linear_v3(get_float3(c->color4()))); } cdata[0] = colors[tri_a[0]]; diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp index 00d23b9095e..4affd0479b0 100644 --- a/intern/cycles/blender/blender_session.cpp +++ b/intern/cycles/blender/blender_session.cpp @@ -139,6 +139,10 @@ void BlenderSession::create_session() scene->image_manager->builtin_image_pixels_cb = function_bind(&BlenderSession::builtin_image_pixels, this, _1, _2, _3, _4, _5); scene->image_manager->builtin_image_float_pixels_cb = function_bind(&BlenderSession::builtin_image_float_pixels, this, _1, _2, _3, _4, _5); +#ifdef WITH_OCIO + scene->film->set_color_config(OCIO_getCurrentConfig()); +#endif + session->scene = scene; /* create sync */ |