Merge branch 'master' into blender2.8
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Thu, 6 Sep 2018 18:11:18 +0000 (20:11 +0200)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Thu, 6 Sep 2018 18:11:18 +0000 (20:11 +0200)
intern/cycles/kernel/kernel_montecarlo.h
intern/cycles/render/camera.cpp
source/blender/compositor/operations/COM_CompositorOperation.cpp
source/blender/editors/space_image/image_ops.c

index 09a3fe8f23dfdc84c2d76757cbe69d14d30b5836..9b96bb80c32e27a824148c629a454bc986f53fc8 100644 (file)
@@ -202,12 +202,12 @@ ccl_device float3 ensure_valid_reflection(float3 Ng, float3 I, float3 N)
        float Ix2 = sqr(dot(I, X)), Iz2 = sqr(Iz);
        float Ix2Iz2 = Ix2 + Iz2;
 
-       float a = sqrtf(Ix2*(Ix2Iz2 - sqr(0.05f)));
+       float a = safe_sqrtf(Ix2*(Ix2Iz2 - sqr(0.05f)));
        float b = Iz*0.05f + Ix2Iz2;
        float c = (a + b > 0.0f)? (a + b) : (-a + b);
 
-       float Nz = sqrtf(0.5f * c * (1.0f / Ix2Iz2));
-       float Nx = sqrtf(1.0f - sqr(Nz));
+       float Nz = safe_sqrtf(0.5f * c * (1.0f / Ix2Iz2));
+       float Nx = safe_sqrtf(1.0f - sqr(Nz));
 
        /* Transform back into global coordinates. */
        return Nx*X + Nz*Ng;
index cc3dd1c923b4ad9f19af1ae0d72a3394712203d7..ec3c56e820add5ccae4c968e9b2cec4b96ac586d 100644 (file)
@@ -716,7 +716,7 @@ float Camera::world_to_raster_size(float3 P)
                float3 D = transform_point(&worldtocamera, P);
                float dist = len(D);
 
-               Ray ray;
+               Ray ray = {0};
 
                /* Distortion can become so great that the results become meaningless, there
                 * may be a better way to do this, but calculating differentials from the
index 16e33c908d671625241674cd6286548eb561573f..24846f738dd046c268f70618fa51408f21f393c2 100644 (file)
@@ -94,6 +94,7 @@ void CompositorOperation::deinitExecution()
                                MEM_freeN(rv->rectz);
                        }
                        rv->rectz = this->m_depthBuffer;
+                       rr->have_combined = true;
                }
                else {
                        if (this->m_outputBuffer) {
index be91f7abf99bc0ded10883529557b3f3eb2da3b4..c42f17f2700d03fc18cd4e391d8aa390050a5179 100644 (file)
@@ -1859,6 +1859,8 @@ static bool save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
                rr = BKE_image_acquire_renderresult(scene, ima);
                bool is_mono = rr ? BLI_listbase_count_at_most(&rr->views, 2) < 2 : BLI_listbase_count_at_most(&ima->views, 2) < 2;
                bool is_exr_rr = rr && ELEM(imf->imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER) && RE_HasFloatPixels(rr);
+               bool is_multilayer = is_exr_rr && (imf->imtype == R_IMF_IMTYPE_MULTILAYER);
+               int layer = (is_multilayer) ? -1 : sima->iuser.layer;
 
                /* error handling */
                if (!rr) {
@@ -1890,14 +1892,14 @@ static bool save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
                /* fancy multiview OpenEXR */
                if (imf->views_format == R_IMF_VIEWS_MULTIVIEW && is_exr_rr) {
                        /* save render result */
-                       ok = RE_WriteRenderResult(op->reports, rr, simopts->filepath, imf, NULL, sima->iuser.layer);
+                       ok = RE_WriteRenderResult(op->reports, rr, simopts->filepath, imf, NULL, layer);
                        save_image_post(bmain, op, ibuf, ima, ok, true, relbase, relative, do_newpath, simopts->filepath);
                        ED_space_image_release_buffer(sima, ibuf, lock);
                }
                /* regular mono pipeline */
                else if (is_mono) {
                        if (is_exr_rr) {
-                               ok = RE_WriteRenderResult(op->reports, rr, simopts->filepath, imf, NULL, -1);
+                               ok = RE_WriteRenderResult(op->reports, rr, simopts->filepath, imf, NULL, layer);
                        }
                        else {
                                colormanaged_ibuf = IMB_colormanagement_imbuf_for_write(ibuf, save_as_render, true, &imf->view_settings, &imf->display_settings, imf);
@@ -1925,7 +1927,7 @@ static bool save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
 
                                if (is_exr_rr) {
                                        BKE_scene_multiview_view_filepath_get(&scene->r, simopts->filepath, view, filepath);
-                                       ok_view = RE_WriteRenderResult(op->reports, rr, filepath, imf, view, -1);
+                                       ok_view = RE_WriteRenderResult(op->reports, rr, filepath, imf, view, layer);
                                        save_image_post(bmain, op, ibuf, ima, ok_view, true, relbase, relative, do_newpath, filepath);
                                }
                                else {
@@ -1960,7 +1962,7 @@ static bool save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
                /* stereo (multiview) images */
                else if (simopts->im_format.views_format == R_IMF_VIEWS_STEREO_3D) {
                        if (imf->imtype == R_IMF_IMTYPE_MULTILAYER) {
-                               ok = RE_WriteRenderResult(op->reports, rr, simopts->filepath, imf, NULL, -1);
+                               ok = RE_WriteRenderResult(op->reports, rr, simopts->filepath, imf, NULL, layer);
                                save_image_post(bmain, op, ibuf, ima, ok, true, relbase, relative, do_newpath, simopts->filepath);
                                ED_space_image_release_buffer(sima, ibuf, lock);
                        }