Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2019-03-19 20:54:17 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2019-03-19 20:54:17 +0300
commitfa59c6a3e7d72d57faadcf0795848b4c3b8381d9 (patch)
treeea668f42028f8cdf5a5968feeed27e8bd99b30fd /intern/cycles/blender
parente7f535cd4cf919b7e479d20b8a1b6714f166151d (diff)
parent83de13f75aafca7d4e1d58ddd36cca19121aa84f (diff)
Merge branch 'blender2.7'
Diffstat (limited to 'intern/cycles/blender')
-rw-r--r--intern/cycles/blender/addon/operators.py41
-rw-r--r--intern/cycles/blender/blender_python.cpp45
-rw-r--r--intern/cycles/blender/blender_session.cpp19
-rw-r--r--intern/cycles/blender/blender_util.h1
4 files changed, 85 insertions, 21 deletions
diff --git a/intern/cycles/blender/addon/operators.py b/intern/cycles/blender/addon/operators.py
index 63c9868ca6a..b53679bd328 100644
--- a/intern/cycles/blender/addon/operators.py
+++ b/intern/cycles/blender/addon/operators.py
@@ -124,9 +124,48 @@ class CYCLES_OT_denoise_animation(Operator):
return {'FINISHED'}
+class CYCLES_OT_merge_images(Operator):
+ "Combine OpenEXR multilayer images rendered with different sample" \
+ "ranges into one image with reduced noise."
+ bl_idname = "cycles.merge_images"
+ bl_label = "Merge Images"
+
+ input_filepath1: StringProperty(
+ name='Input Filepath',
+ description='File path for image to merge',
+ default='',
+ subtype='FILE_PATH')
+
+ input_filepath2: StringProperty(
+ name='Input Filepath',
+ description='File path for image to merge',
+ default='',
+ subtype='FILE_PATH')
+
+ output_filepath: StringProperty(
+ name='Output Filepath',
+ description='File path for merged image',
+ default='',
+ subtype='FILE_PATH')
+
+ def execute(self, context):
+ in_filepaths = [self.input_filepath1, self.input_filepath2]
+ out_filepath = self.output_filepath
+
+ import _cycles
+ try:
+ _cycles.merge(input=in_filepaths, output=out_filepath)
+ except Exception as e:
+ self.report({'ERROR'}, str(e))
+ return {'FINISHED'}
+
+ return {'FINISHED'}
+
+
classes = (
CYCLES_OT_use_shading_nodes,
- CYCLES_OT_denoise_animation
+ CYCLES_OT_denoise_animation,
+ CYCLES_OT_merge_images
)
def register():
diff --git a/intern/cycles/blender/blender_python.cpp b/intern/cycles/blender/blender_python.cpp
index 4a1eeeb65c1..ccd783073a3 100644
--- a/intern/cycles/blender/blender_python.cpp
+++ b/intern/cycles/blender/blender_python.cpp
@@ -23,6 +23,7 @@
#include "blender/blender_session.h"
#include "render/denoising.h"
+#include "render/merge.h"
#include "util/util_debug.h"
#include "util/util_foreach.h"
@@ -642,9 +643,8 @@ static PyObject *opencl_compile_func(PyObject * /*self*/, PyObject *args)
}
#endif
-static bool denoise_parse_filepaths(PyObject *pyfilepaths, vector<string>& filepaths)
+static bool image_parse_filepaths(PyObject *pyfilepaths, vector<string>& filepaths)
{
-
if(PyUnicode_Check(pyfilepaths)) {
const char *filepath = PyUnicode_AsUTF8(pyfilepaths);
filepaths.push_back(filepath);
@@ -713,12 +713,12 @@ static PyObject *denoise_func(PyObject * /*self*/, PyObject *args, PyObject *key
/* Parse file paths list. */
vector<string> input, output;
- if(!denoise_parse_filepaths(pyinput, input)) {
+ if(!image_parse_filepaths(pyinput, input)) {
return NULL;
}
if(pyoutput) {
- if(!denoise_parse_filepaths(pyoutput, output)) {
+ if(!image_parse_filepaths(pyoutput, output)) {
return NULL;
}
}
@@ -757,6 +757,42 @@ static PyObject *denoise_func(PyObject * /*self*/, PyObject *args, PyObject *key
Py_RETURN_NONE;
}
+static PyObject *merge_func(PyObject * /*self*/, PyObject *args, PyObject *keywords)
+{
+ static const char *keyword_list[] = {"input", "output", NULL};
+ PyObject *pyinput, *pyoutput = NULL;
+
+ if (!PyArg_ParseTupleAndKeywords(args, keywords, "OO", (char**)keyword_list, &pyinput, &pyoutput)) {
+ return NULL;
+ }
+
+ /* Parse input list. */
+ vector<string> input;
+ if(!image_parse_filepaths(pyinput, input)) {
+ return NULL;
+ }
+
+ /* Parse output string. */
+ if(!PyUnicode_Check(pyoutput)) {
+ PyErr_SetString(PyExc_ValueError, "Output must be a string.");
+ return NULL;
+ }
+ string output = PyUnicode_AsUTF8(pyoutput);
+
+ /* Merge. */
+ ImageMerger merger;
+ merger.input = input;
+ merger.output = output;
+
+ if(!merger.run()) {
+ PyErr_SetString(PyExc_ValueError, merger.error.c_str());
+ return NULL;
+ }
+
+ Py_RETURN_NONE;
+}
+
+
static PyObject *debug_flags_update_func(PyObject * /*self*/, PyObject *args)
{
PyObject *pyscene;
@@ -920,6 +956,7 @@ static PyMethodDef methods[] = {
/* Standalone denoising */
{"denoise", (PyCFunction)denoise_func, METH_VARARGS|METH_KEYWORDS, ""},
+ {"merge", (PyCFunction)merge_func, METH_VARARGS|METH_KEYWORDS, ""},
/* Debugging routines */
{"debug_flags_update", debug_flags_update_func, METH_VARARGS, ""},
diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp
index a06135b5362..cf856c3b3d4 100644
--- a/intern/cycles/blender/blender_session.cpp
+++ b/intern/cycles/blender/blender_session.cpp
@@ -393,15 +393,6 @@ static void add_cryptomatte_layer(BL::RenderResult& b_rr, string name, string ma
render_add_metadata(b_rr, prefix+"manifest", manifest);
}
-/* TODO(sergey): Ideally this will be an utility function in util string.h, but
- * currently is relying on Blender side function, so can not do that. */
-static string make_human_readable_time(double time)
-{
- char time_str[128];
- BLI_timecode_string_from_time_simple(time_str, sizeof(time_str), time);
- return time_str;
-}
-
void BlenderSession::stamp_view_layer_metadata(Scene *scene, const string& view_layer_name)
{
BL::RenderResult b_rr = b_engine.get_result();
@@ -440,11 +431,11 @@ void BlenderSession::stamp_view_layer_metadata(Scene *scene, const string& view_
double total_time, render_time;
session->progress.get_time(total_time, render_time);
b_rr.stamp_data_add_field((prefix + "total_time").c_str(),
- make_human_readable_time(total_time).c_str());
+ time_human_readable_from_seconds(total_time).c_str());
b_rr.stamp_data_add_field((prefix + "render_time").c_str(),
- make_human_readable_time(render_time).c_str());
+ time_human_readable_from_seconds(render_time).c_str());
b_rr.stamp_data_add_field((prefix + "synchronization_time").c_str(),
- make_human_readable_time(total_time - render_time).c_str());
+ time_human_readable_from_seconds(total_time - render_time).c_str());
}
void BlenderSession::render(BL::Depsgraph& b_depsgraph_)
@@ -1014,7 +1005,6 @@ void BlenderSession::update_status_progress()
string scene_status = "";
float progress;
double total_time, remaining_time = 0, render_time;
- char time_str[128];
float mem_used = (float)session->stats.mem_used / 1024.0f / 1024.0f;
float mem_peak = (float)session->stats.mem_peak / 1024.0f / 1024.0f;
@@ -1034,8 +1024,7 @@ void BlenderSession::update_status_progress()
scene_status += ", " + b_rview_name;
if(remaining_time > 0) {
- BLI_timecode_string_from_time_simple(time_str, sizeof(time_str), remaining_time);
- timestatus += "Remaining:" + string(time_str) + " | ";
+ timestatus += "Remaining:" + time_human_readable_from_seconds(remaining_time) + " | ";
}
timestatus += string_printf("Mem:%.2fM, Peak:%.2fM", (double)mem_used, (double)mem_peak);
diff --git a/intern/cycles/blender/blender_util.h b/intern/cycles/blender/blender_util.h
index b9a1de08705..ec836bd5ec1 100644
--- a/intern/cycles/blender/blender_util.h
+++ b/intern/cycles/blender/blender_util.h
@@ -32,7 +32,6 @@
* todo: clean this up ... */
extern "C" {
-size_t BLI_timecode_string_from_time_simple(char *str, size_t maxlen, double time_seconds);
void BKE_image_user_frame_calc(void *iuser, int cfra);
void BKE_image_user_file_path(void *iuser, void *ima, char *path);
unsigned char *BKE_image_get_pixels_for_frame(void *image, int frame);