Commit: bfffcb518a5da85c3a322b7e10628f16db3f4001
Author: Lukas Stockner
Date:   Sat Aug 13 03:52:58 2016 +0200
Branches: soc-2016-cycles_denoising
https://developer.blender.org/rBbfffcb518a5da85c3a322b7e10628f16db3f4001

Cycles: Implement half float file output and fix flipped standalone-denoised 
images

Since the tonemapping task already supports both Byte and Half output,
the only needed change is to the DisplayBuffer itself.

===================================================================

M       intern/cycles/app/cycles_denoising.cpp
M       intern/cycles/app/cycles_standalone.cpp
M       intern/cycles/render/buffers.cpp
M       intern/cycles/render/buffers.h
M       intern/cycles/render/session.cpp
M       intern/cycles/render/session.h

===================================================================

diff --git a/intern/cycles/app/cycles_denoising.cpp 
b/intern/cycles/app/cycles_denoising.cpp
index de54b2c..5515fb1 100644
--- a/intern/cycles/app/cycles_denoising.cpp
+++ b/intern/cycles/app/cycles_denoising.cpp
@@ -203,6 +203,7 @@ bool cycles_denoising_session()
        options.session_params.progressive = false;
        options.session_params.background = true;
        options.session_params.tile_order = TILE_BOTTOM_TO_TOP;
+       options.session_params.flip_output = false;
 
        options.session = new Session(options.session_params);
        
options.session->progress.set_update_callback(function_bind(&session_print_status));
diff --git a/intern/cycles/app/cycles_standalone.cpp 
b/intern/cycles/app/cycles_standalone.cpp
index 899f6d6..c07f17f 100644
--- a/intern/cycles/app/cycles_standalone.cpp
+++ b/intern/cycles/app/cycles_standalone.cpp
@@ -369,6 +369,7 @@ static void options_parse(int argc, const char **argv)
                "--half-window %d", &options.session_params.half_window, "Size 
of the denoising window",
                "--samples %d", &options.session_params.samples, "Number of 
samples to render",
                "--output %s", &options.session_params.output_path, "File path 
to write output image",
+               "--output-half", &options.session_params.output_half_float, 
"Write output image in half float format",
                "--threads %d", &options.session_params.threads, "CPU Rendering 
Threads",
                "--width  %d", &options.width, "Window width in pixel",
                "--height %d", &options.height, "Window height in pixel",
diff --git a/intern/cycles/render/buffers.cpp b/intern/cycles/render/buffers.cpp
index f1e552d..e056934 100644
--- a/intern/cycles/render/buffers.cpp
+++ b/intern/cycles/render/buffers.cpp
@@ -518,6 +518,7 @@ DisplayBuffer::DisplayBuffer(Device *device_, bool linear)
        draw_height = 0;
        transparent = true; /* todo: determine from background */
        half_float = linear;
+       flip_image = true;
 }
 
 DisplayBuffer::~DisplayBuffer()
@@ -588,8 +589,7 @@ void DisplayBuffer::write(Device *device, const string& 
filename)
        if(w == 0 || h == 0)
                return;
        
-       if(half_float)
-               return;
+       TypeDesc output_format = half_float? TypeDesc::HALF : TypeDesc::UINT8;
 
        /* read buffer from device */
        device_memory& rgba = rgba_data();
@@ -597,16 +597,22 @@ void DisplayBuffer::write(Device *device, const string& 
filename)
 
        /* write image */
        ImageOutput *out = ImageOutput::create(filename);
-       ImageSpec spec(w, h, 4, TypeDesc::UINT8);
-       int scanlinesize = w*4*sizeof(uchar);
+       ImageSpec spec(w, h, 4, output_format);
+       int scanlinesize = w*spec.pixel_bytes();
 
        out->open(filename, spec);
 
+       uchar *pixels = (uchar*)rgba.data_pointer;
        /* conversion for different top/bottom convention */
-       out->write_image(TypeDesc::UINT8,
-               (uchar*)rgba.data_pointer + (h-1)*scanlinesize,
+       if(flip_image) {
+               pixels += (h-1)*scanlinesize;
+               scanlinesize = -scanlinesize;
+       }
+
+       out->write_image(output_format,
+               pixels,
                AutoStride,
-               -scanlinesize,
+               scanlinesize,
                AutoStride);
 
        out->close();
diff --git a/intern/cycles/render/buffers.h b/intern/cycles/render/buffers.h
index 4a9287f..716b1b7 100644
--- a/intern/cycles/render/buffers.h
+++ b/intern/cycles/render/buffers.h
@@ -147,6 +147,8 @@ public:
        /* byte buffer for converted result */
        device_vector<uchar4> rgba_byte;
        device_vector<half4> rgba_half;
+       /* flip the image while writing? */
+       bool flip_image;
 
        DisplayBuffer(Device *device, bool linear = false);
        ~DisplayBuffer();
diff --git a/intern/cycles/render/session.cpp b/intern/cycles/render/session.cpp
index 4488584..5a75f50 100644
--- a/intern/cycles/render/session.cpp
+++ b/intern/cycles/render/session.cpp
@@ -108,7 +108,8 @@ Session::~Session()
                /* tonemap and write out image if requested */
                delete display;
 
-               display = new DisplayBuffer(device, false);
+               display = new DisplayBuffer(device, params.output_half_float);
+               display->flip_image = params.flip_output;
                display->reset(device, buffers->params);
                tonemap(params.samples);
 
diff --git a/intern/cycles/render/session.h b/intern/cycles/render/session.h
index 8939b4e..1f709e5 100644
--- a/intern/cycles/render/session.h
+++ b/intern/cycles/render/session.h
@@ -45,7 +45,10 @@ public:
        DeviceInfo device;
        bool background;
        bool progressive_refine;
+
        string output_path;
+       bool flip_output;
+       bool output_half_float;
 
        bool progressive;
        bool experimental;
@@ -73,7 +76,10 @@ public:
        {
                background = false;
                progressive_refine = false;
+
                output_path = "";
+               flip_output = true;
+               output_half_float = false;
 
                progressive = false;
                experimental = false;
@@ -104,6 +110,8 @@ public:
                && background == params.background
                && progressive_refine == params.progressive_refine
                && output_path == params.output_path
+               && flip_output == params.flip_output
+               && output_half_float == params.output_half_float
                /* && samples == params.samples */
                && progressive == params.progressive
                && experimental == params.experimental

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to