Merge branch 'master' into blender2.8
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Thu, 23 Nov 2017 18:16:11 +0000 (19:16 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Thu, 23 Nov 2017 18:16:11 +0000 (19:16 +0100)
intern/cycles/kernel/svm/svm_gradient.h
intern/cycles/render/buffers.cpp
release/scripts/startup/bl_ui/properties_render.py
release/scripts/startup/bl_ui/space_view3d.py
source/blender/gpu/shaders/gpu_shader_material.glsl
source/blender/makesrna/intern/rna_scene.c
source/blender/nodes/shader/node_shader_tree.c
source/blender/render/intern/source/render_result.c

index 53d7b4f812cb0c281441387856de895636c5b056..74e36e70427dae889c25c18543d5450aabce009c 100644 (file)
@@ -46,7 +46,10 @@ ccl_device float svm_gradient(float3 p, NodeGradientType type)
                return atan2f(y, x) / M_2PI_F + 0.5f;
        }
        else {
-               float r = fmaxf(1.0f - sqrtf(x*x + y*y + z*z), 0.0f);
+               /* Bias a little bit for the case where p is a unit length vector,
+                * to get exactly zero instead of a small random value depending
+                * on float precision. */
+               float r = fmaxf(0.999999f - sqrtf(x*x + y*y + z*z), 0.0f);
 
                if(type == NODE_BLEND_QUADRATIC_SPHERE)
                        return r*r;
index 7d4c3325a1526922671ed52eda0b4106dc447ef5..c6502df725243fe6c915c0854249e3b63f82e1ba 100644 (file)
@@ -236,10 +236,17 @@ bool RenderBuffers::get_pass_rect(PassType type, float exposure, int sample, int
 
                int size = params.width*params.height;
 
-               if(components == 1) {
+               if(components == 1 && type == PASS_RENDER_TIME) {
+                       /* Render time is not stored by kernel, but measured per tile. */
+                       float val = (float) (1000.0 * render_time/(params.width * params.height * sample));
+                       for(int i = 0; i < size; i++, pixels++) {
+                               pixels[0] = val;
+                       }
+               }
+               else if(components == 1) {
                        assert(pass.components == components);
 
-                       /* scalar */
+                       /* Scalar */
                        if(type == PASS_DEPTH) {
                                for(int i = 0; i < size; i++, in += pass_stride, pixels++) {
                                        float f = *in;
@@ -264,12 +271,6 @@ bool RenderBuffers::get_pass_rect(PassType type, float exposure, int sample, int
                                }
                        }
 #endif
-                       else if(type == PASS_RENDER_TIME) {
-                               float val = (float) (1000.0 * render_time/(params.width * params.height * sample));
-                               for(int i = 0; i < size; i++, pixels++) {
-                                       pixels[0] = val;
-                               }
-                       }
                        else {
                                for(int i = 0; i < size; i++, in += pass_stride, pixels++) {
                                        float f = *in;
index 51ebc79294f58797d0bd54ac210d29fc7bb34bfc..e62f0a6e100d0062846f547b3611fdabfcf73e95 100644 (file)
@@ -480,19 +480,19 @@ class RENDER_PT_encoding(RenderButtonsPanel, Panel):
         pbox.prop(ffmpeg, "max_b_frames", text="")
         pbox.enabled = ffmpeg.use_max_b_frames
 
-        split = layout.split()
-        split.enabled = ffmpeg.constant_rate_factor == 'NONE'
-        col = split.column()
-        col.label(text="Rate:")
-        col.prop(ffmpeg, "video_bitrate")
-        col.prop(ffmpeg, "minrate", text="Minimum")
-        col.prop(ffmpeg, "maxrate", text="Maximum")
-        col.prop(ffmpeg, "buffersize", text="Buffer")
+        if ffmpeg.constant_rate_factor == 'NONE':
+            split = layout.split()
+            col = split.column()
+            col.label(text="Rate:")
+            col.prop(ffmpeg, "video_bitrate")
+            col.prop(ffmpeg, "minrate", text="Minimum")
+            col.prop(ffmpeg, "maxrate", text="Maximum")
+            col.prop(ffmpeg, "buffersize", text="Buffer")
 
-        col = split.column()
-        col.label(text="Mux:")
-        col.prop(ffmpeg, "muxrate", text="Rate")
-        col.prop(ffmpeg, "packetsize", text="Packet Size")
+            col = split.column()
+            col.label(text="Mux:")
+            col.prop(ffmpeg, "muxrate", text="Rate")
+            col.prop(ffmpeg, "packetsize", text="Packet Size")
 
         layout.separator()
 
@@ -500,10 +500,10 @@ class RENDER_PT_encoding(RenderButtonsPanel, Panel):
         if ffmpeg.format != 'MP3':
             layout.prop(ffmpeg, "audio_codec", text="Audio Codec")
 
-        row = layout.row()
-        row.enabled = ffmpeg.audio_codec != 'NONE'
-        row.prop(ffmpeg, "audio_bitrate")
-        row.prop(ffmpeg, "audio_volume", slider=True)
+        if ffmpeg.audio_codec != 'NONE':
+            row = layout.row()
+            row.prop(ffmpeg, "audio_bitrate")
+            row.prop(ffmpeg, "audio_volume", slider=True)
 
 
 class RENDER_PT_bake(RenderButtonsPanel, Panel):
index d449dd20c3e4217a3af23b00160aee0528549e1f..cd062a676478f352c0eaa4ee0f6a77ec9b080f06 100644 (file)
@@ -1554,18 +1554,21 @@ class VIEW3D_MT_object_specials(Menu):
             use_shading_nodes = context.view_render.use_shading_nodes
 
             if use_shading_nodes:
-                try:
-                    value = lamp.node_tree.nodes["Emission"].inputs["Strength"].default_value
-                except AttributeError:
-                    value = None
-
-                if value is not None:
+                emission_node = None
+                if lamp.node_tree:
+                    for node in lamp.node_tree.nodes:
+                        if getattr(node, "type", None) == 'EMISSION':
+                            emission_node = node
+                            break
+
+                if emission_node is not None:
                     props = layout.operator("wm.context_modal_mouse", text="Strength")
                     props.data_path_iter = "selected_editable_objects"
-                    props.data_path_item = "data.node_tree.nodes[\"Emission\"].inputs[\"Strength\"].default_value"
+                    props.data_path_item = "data.node_tree" \
+                                           ".nodes[\"" + emission_node.name + "\"]" \
+                                           ".inputs[\"Strength\"].default_value"
                     props.header_text = "Lamp Strength: %.3f"
                     props.input_scale = 0.1
-                del value
 
                 if lamp.type == 'AREA':
                     props = layout.operator("wm.context_modal_mouse", text="Size X")
index 4aaaab2c5ad6a123333765d2ac61f6701ea4702f..5d0ca35cc1f4f54c813d98e09fc5447191fc8bdf 100644 (file)
@@ -3348,7 +3348,10 @@ float calc_gradient(vec3 p, int gradient_type)
                return atan(y, x) / (M_PI * 2) + 0.5;
        }
        else {
-               float r = max(1.0 - sqrt(x * x + y * y + z * z), 0.0);
+               /* Bias a little bit for the case where p is a unit length vector,
+                * to get exactly zero instead of a small random value depending
+                * on float precision. */
+               float r = max(0.999999 - sqrt(x * x + y * y + z * z), 0.0);
                if (gradient_type == 5) {  /* quadratic sphere */
                        return r * r;
                }
index d2a7bd65d4af62dfc777813e432bbb565219dad4..cc139ec1b895bf238dc67cd6afeb1d435d07788a 100644 (file)
@@ -5245,7 +5245,7 @@ static void rna_def_scene_ffmpeg_settings(BlenderRNA *brna)
        };
 
        static const EnumPropertyItem ffmpeg_crf_items[] = {
-               {FFM_CRF_NONE, "NONE", 0, "None; use constant bit-rate",
+               {FFM_CRF_NONE, "NONE", 0, "None; use custom bitrate",
                 "Use constant bit rate, rather than constant output quality"},
                {FFM_CRF_LOSSLESS, "LOSSLESS", 0, "Lossless", ""},
                {FFM_CRF_PERC_LOSSLESS, "PERC_LOSSLESS", 0, "Perceptually lossless", ""},
index dc48aa324b250ece6cc26177de7f96988a012c5a..bd22a2be647b06b5bf5ce1f26ce2630bf6c34de9 100644 (file)
@@ -348,7 +348,9 @@ static void ntree_shader_link_builtin_group_normal(
                 * some internal re-linking in order to avoid cycles.
                 */
                bNode *group_output_node = ntreeFindType(group_ntree, NODE_GROUP_OUTPUT);
-               BLI_assert(group_output_node != NULL);
+               if (group_output_node == NULL) {
+                       return;
+               }
                bNodeSocket *group_output_node_displacement_socket =
                        nodeFindSocket(group_output_node,
                                       SOCK_IN,
index 53169c256a944b9a21c305dad40a4016ae0369ad..0e7f35fbca35757f292b2bb19536b4b77c450080 100644 (file)
@@ -921,6 +921,17 @@ bool RE_WriteRenderResult(ReportList *reports, RenderResult *rr, const char *fil
                                }
                        }
 
+                       /* We only store RGBA passes as half float, for
+                        * others precision loss can be problematic. */
+                       bool pass_half_float = half_float &&
+                                              (STREQ(rp->chan_id, "RGB") ||
+                                               STREQ(rp->chan_id, "RGBA") ||
+                                               STREQ(rp->chan_id, "R") ||
+                                               STREQ(rp->chan_id, "G") ||
+                                               STREQ(rp->chan_id, "B") ||
+                                               STREQ(rp->chan_id, "A"));
+
+
                        for (int a = 0; a < rp->channels; a++) {
                                /* Save Combined as RGBA if single layer save. */
                                char passname[EXR_PASS_MAXNAME];
@@ -936,10 +947,9 @@ bool RE_WriteRenderResult(ReportList *reports, RenderResult *rr, const char *fil
                                        layname[0] = '\0';
                                }
 
-                               /* Add channel. */
                                IMB_exr_add_channel(exrhandle, layname, passname, viewname,
                                                    rp->channels, rp->channels * rr->rectx, rp->rect + a,
-                                                   STREQ(rp->name, RE_PASSNAME_Z) ? false : half_float);
+                                                   pass_half_float);
                        }
                }
        }