Merge branch 'master' into blender2.8
authorDalai Felinto <dfelinto@gmail.com>
Mon, 3 Jul 2017 13:07:14 +0000 (15:07 +0200)
committerDalai Felinto <dfelinto@gmail.com>
Mon, 3 Jul 2017 13:18:46 +0000 (15:18 +0200)
12 files changed:
intern/cycles/device/opencl/opencl_base.cpp
intern/cycles/kernel/closure/bsdf.h
intern/cycles/kernel/closure/bsdf_principled_diffuse.h
intern/cycles/kernel/svm/svm_closure.h
intern/cycles/util/util_math_float3.h
intern/elbeem/intern/isosurface.cpp
source/blender/blenkernel/intern/rigidbody.c
source/blender/blenkernel/intern/sequencer.c
source/blender/editors/interface/interface_regions.c
source/blender/editors/util/undo.c
source/blender/gpu/shaders/gpu_shader_material.glsl
source/blender/makesrna/intern/rna_sequencer.c

index e4ab979dcbf9bfce79a4bbbbdb7b28916cf7b59b..223a590119714b7325ca571bb953327066fde7d1 100644 (file)
@@ -1226,7 +1226,7 @@ void OpenCLDeviceBase::store_cached_kernel(
 }
 
 string OpenCLDeviceBase::build_options_for_base_program(
-        const DeviceRequestedFeatures& /*requested_features*/)
+        const DeviceRequestedFeatures& requested_features)
 {
        /* TODO(sergey): By default we compile all features, meaning
         * mega kernel is not getting feature-based optimizations.
@@ -1234,6 +1234,14 @@ string OpenCLDeviceBase::build_options_for_base_program(
         * Ideally we need always compile kernel with as less features
         * enabled as possible to keep performance at it's max.
         */
+
+       /* For now disable baking when not in use as this has major
+        * impact on kernel build times.
+        */
+       if(!requested_features.use_baking) {
+               return "-D__NO_BAKING__";
+       }
+
        return "";
 }
 
index a04c157dc40dcb205cefd9fc0f8021ed215974c7..86a00d2124db29a39cec42185fbcd2bf52521bec 100644 (file)
@@ -423,6 +423,11 @@ ccl_device bool bsdf_merge(ShaderClosure *a, ShaderClosure *b)
                case CLOSURE_BSDF_HAIR_REFLECTION_ID:
                case CLOSURE_BSDF_HAIR_TRANSMISSION_ID:
                        return bsdf_hair_merge(a, b);
+#ifdef __PRINCIPLED__
+               case CLOSURE_BSDF_PRINCIPLED_DIFFUSE_ID:
+               case CLOSURE_BSDF_BSSRDF_PRINCIPLED_ID:
+                       return bsdf_principled_diffuse_merge(a, b);
+#endif
 #ifdef __VOLUME__
                case CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID:
                        return volume_henyey_greenstein_merge(a, b);
index 215c32e1ffb0780592c6345be154cf08202432c7..f8ca64293b0653c92c830f119743a401aa7d9d8b 100644 (file)
@@ -58,6 +58,14 @@ ccl_device int bsdf_principled_diffuse_setup(PrincipledDiffuseBsdf *bsdf)
        return SD_BSDF|SD_BSDF_HAS_EVAL;
 }
 
+ccl_device bool bsdf_principled_diffuse_merge(const ShaderClosure *a, const ShaderClosure *b)
+{
+       const PrincipledDiffuseBsdf *bsdf_a = (const PrincipledDiffuseBsdf*)a;
+       const PrincipledDiffuseBsdf *bsdf_b = (const PrincipledDiffuseBsdf*)b;
+
+       return (isequal_float3(bsdf_a->N, bsdf_b->N) && bsdf_a->roughness == bsdf_b->roughness);
+}
+
 ccl_device float3 bsdf_principled_diffuse_eval_reflect(const ShaderClosure *sc, const float3 I,
        const float3 omega_in, float *pdf)
 {
index b3d24f88420b8501264bfed7543fe5a91395fc1d..9578fcf26873c95c16fe3d0c47a1dc540aa339a7 100644 (file)
@@ -158,7 +158,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
                        }
 
                        /* diffuse */
-                       if(fabsf(average(base_color)) > CLOSURE_WEIGHT_CUTOFF) {
+                       if(fabsf(average(mixed_ss_base_color)) > CLOSURE_WEIGHT_CUTOFF) {
                                if(subsurface < CLOSURE_WEIGHT_CUTOFF && diffuse_weight > CLOSURE_WEIGHT_CUTOFF) {
                                        float3 diff_weight = weight * base_color * diffuse_weight;
 
index 5327d9f7cc6c801ca67dad3f64a79e74182a4a90..bb04c4aa2d929724c2e9fa78772bdd80d14fd45c 100644 (file)
@@ -374,9 +374,9 @@ ccl_device_inline bool isfinite3_safe(float3 v)
 
 ccl_device_inline float3 ensure_finite3(float3 v)
 {
-       if(!isfinite_safe(v.x)) v.x = 0.0;
-       if(!isfinite_safe(v.y)) v.y = 0.0;
-       if(!isfinite_safe(v.z)) v.z = 0.0;
+       if(!isfinite_safe(v.x)) v.x = 0.0f;
+       if(!isfinite_safe(v.y)) v.y = 0.0f;
+       if(!isfinite_safe(v.z)) v.z = 0.0f;
        return v;
 }
 
index b29c9e2035891a6abe33523f89da03cb2c92ee5b..de7bfe8e687c65cd523a6901339422105f33ba1f 100644 (file)
@@ -15,6 +15,7 @@
 #include "particletracer.h"
 #include <algorithm>
 #include <stdio.h>
+#include <cmath>
 
 #ifdef sun
 #include "ieeefp.h"
@@ -25,6 +26,8 @@
 #define round(x) (x)
 #endif
 
+using std::isfinite;
+
 /******************************************************************************
  * Constructor
  *****************************************************************************/
index 6056515af9ac88402c8be6a6cb53e8d192d08f30..11c1a9b6bb18cf878f499f6110119af4cdded5ac 100644 (file)
@@ -1562,12 +1562,8 @@ void BKE_rigidbody_do_simulation(Scene *scene, float ctime)
        BKE_ptcache_id_time(&pid, scene, ctime, &startframe, &endframe, NULL);
        cache = rbw->pointcache;
 
-       if (ctime <= startframe) {
-               rbw->ltime = startframe;
-               return;
-       }
        /* make sure we don't go out of cache frame range */
-       else if (ctime > endframe) {
+       if (ctime > endframe) {
                ctime = endframe;
        }
 
@@ -1583,7 +1579,6 @@ void BKE_rigidbody_do_simulation(Scene *scene, float ctime)
 
        if (BKE_ptcache_read(&pid, ctime, can_simulate)) {
                BKE_ptcache_validate(cache, (int)ctime);
-               rbw->ltime = ctime;
                return;
        }
 
index e316b7f26e9926871779b1c2286c8fa0e916d433..bebd3d64b4478e4e7a282aa3a03e0efc7bc9bc8b 100644 (file)
@@ -2084,7 +2084,7 @@ void BKE_sequencer_proxy_set(struct Sequence *seq, bool value)
                }
        }
        else {
-               seq->flag ^= SEQ_USE_PROXY;
+               seq->flag &= ~SEQ_USE_PROXY;
        }       
 }
 
index fd6d056f7d4074891754a24e5a2ecd8dd48a86ff..738ebfcc5c2cf71b7c4e54f11d9253d9b6aaf142 100644 (file)
@@ -2107,9 +2107,11 @@ static void ui_update_color_picker_buts_rgb(uiBlock *block, ColorPicker *cpicker
                        continue;
 
                if (bt->rnaprop) {
-                       
                        ui_but_v3_set(bt, rgb);
                        
+                       /* original button that created the color picker already does undo
+                        * push, so disable it on RNA buttons in the color picker block */
+                       UI_but_flag_disable(bt, UI_BUT_UNDO);
                }
                else if (STREQ(bt->str, "Hex: ")) {
                        float rgb_gamma[3];
index f5830e451e3abccf1f7e2b63f1f86f99319e167f..ff328a28ee9b7538c045024dc4f4fe65723a3fc7 100644 (file)
@@ -335,6 +335,12 @@ static int ed_undo_redo_exec(bContext *C, wmOperator *UNUSED(op))
        return ret ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
 }
 
+static int ed_undo_redo_poll(bContext *C)
+{
+       wmOperator *last_op = WM_operator_last_redo(C);
+       return last_op && ED_operator_screenactive(C) && 
+               WM_operator_check_ui_enabled(C, last_op->type->name);
+}
 
 /* ********************** */
 
@@ -386,7 +392,7 @@ void ED_OT_undo_redo(wmOperatorType *ot)
        
        /* api callbacks */
        ot->exec = ed_undo_redo_exec;
-       ot->poll = ED_operator_screenactive;
+       ot->poll = ed_undo_redo_poll;
 }
 
 /* ui callbacks should call this rather than calling WM_operator_repeat() themselves */
index 0c36d6ca618aaaf7d13c5037a340a4ad135ef105..1f9ab45e556e952abf45538d2292275bc1c145d4 100644 (file)
@@ -2690,7 +2690,7 @@ void node_bsdf_principled(vec4 base_color, float subsurface, vec3 subsurface_rad
 
        /* ambient light */
        // TODO: set ambient light to an appropriate value
-       vec3 L = vec3(mix(0.1, 0.03, metallic)) * base_color.rgb;
+       vec3 L = mix(0.1, 0.03, metallic) * mix(base_color.rgb, subsurface_color.rgb, subsurface * (1.0 - metallic));
 
        float eta = (2.0 / (1.0 - sqrt(0.08 * specular))) - 1.0;
 
@@ -2704,10 +2704,11 @@ void node_bsdf_principled(vec4 base_color, float subsurface, vec3 subsurface_rad
        /* directional lights */
        for (int i = 0; i < NUM_LIGHTS; i++) {
                vec3 light_position_world = glLightSource[i].position.xyz;
-               vec3 light_position = normalize(NormalMatrix * light_position_world);
+               vec3 light_position = normalize(light_position_world);
 
                vec3 H = normalize(light_position + V);
 
+               vec3 light_diffuse = glLightSource[i].diffuse.rgb;
                vec3 light_specular = glLightSource[i].specular.rgb;
 
                float NdotL = dot(N, light_position);
@@ -2748,8 +2749,9 @@ void node_bsdf_principled(vec4 base_color, float subsurface, vec3 subsurface_rad
                        // sheen
                        vec3 Fsheen = schlick_fresnel(LdotH) * sheen * Csheen;
 
-                       diffuse_and_specular_bsdf = (M_1_PI * mix(Fd, ss, subsurface) * base_color.rgb + Fsheen)
-                                                   * (1.0 - metallic) + Gs * Fs * Ds;
+                       vec3 diffuse_bsdf = (mix(Fd * base_color.rgb, ss * subsurface_color.rgb, subsurface) + Fsheen) * light_diffuse;
+                       vec3 specular_bsdf = Gs * Fs * Ds * light_specular;
+                       diffuse_and_specular_bsdf = diffuse_bsdf * (1.0 - metallic) + specular_bsdf;
                }
                diffuse_and_specular_bsdf *= max(NdotL, 0.0);
 
@@ -2766,11 +2768,11 @@ void node_bsdf_principled(vec4 base_color, float subsurface, vec3 subsurface_rad
                        float Fr = fresnel_dielectric_cos(LdotH, 1.5); //mix(0.04, 1.0, FH);
                        float Gr = smithG_GGX(CNdotL, 0.25) * smithG_GGX(CNdotV, 0.25);
 
-                       clearcoat_bsdf = clearcoat * Gr * Fr * Dr * vec3(0.25);
+                       clearcoat_bsdf = clearcoat * Gr * Fr * Dr * vec3(0.25) * light_specular;
                }
                clearcoat_bsdf *= max(CNdotL, 0.0);
 
-               L += light_specular * (diffuse_and_specular_bsdf + clearcoat_bsdf);
+               L += diffuse_and_specular_bsdf + clearcoat_bsdf;
        }
 
        result = vec4(L, 1.0);
index 6f8aa32da86f5a739bc34cf5dc0aa64c363ad7fc..f628c5f14d9016360c7fa1d7c682c5eb619693c8 100644 (file)
@@ -341,7 +341,7 @@ static void rna_Sequence_use_translation_set(PointerRNA *ptr, int value)
                }
        }
        else {
-               seq->flag ^= SEQ_USE_TRANSFORM;
+               seq->flag &= ~SEQ_USE_TRANSFORM;
        }
 }
 
@@ -355,7 +355,7 @@ static void rna_Sequence_use_crop_set(PointerRNA *ptr, int value)
                }
        }
        else {
-               seq->flag ^= SEQ_USE_CROP;
+               seq->flag &= ~SEQ_USE_CROP;
        }
 }