Merge branch 'master' into blender2.8
authorCampbell Barton <ideasman42@gmail.com>
Tue, 18 Jul 2017 08:10:19 +0000 (18:10 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 18 Jul 2017 08:10:19 +0000 (18:10 +1000)
intern/cycles/kernel/kernel_accumulate.h
intern/cycles/kernel/kernel_path.h
intern/cycles/kernel/kernel_path_branched.h
intern/cycles/kernel/kernel_types.h
intern/cycles/kernel/split/kernel_holdout_emission_blurring_pathtermination_ao.h
source/blender/editors/animation/anim_markers.c
source/blender/editors/space_view3d/view3d_walk.c
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/intern/wm_event_system.c

index 175bd6b9737daf999c6519b622781fe615a97639..9ed16aceb55d563e9b4c4841d3da1a89e2711cb8 100644 (file)
@@ -220,7 +220,9 @@ ccl_device_inline void path_radiance_init(PathRadiance *L, int use_light_pass)
 #ifdef __SHADOW_TRICKS__
        L->path_total = make_float3(0.0f, 0.0f, 0.0f);
        L->path_total_shaded = make_float3(0.0f, 0.0f, 0.0f);
-       L->shadow_color = make_float3(0.0f, 0.0f, 0.0f);
+       L->shadow_background_color = make_float3(0.0f, 0.0f, 0.0f);
+       L->shadow_radiance_sum = make_float3(0.0f, 0.0f, 0.0f);
+       L->shadow_throughput = 0.0f;
 #endif
 
 #ifdef __DENOISING_FEATURES__
@@ -680,11 +682,12 @@ ccl_device_inline float3 path_radiance_sum_shadowcatcher(KernelGlobals *kg,
        const float shadow = path_radiance_sum_shadow(L);
        float3 L_sum;
        if(kernel_data.background.transparent) {
-               *alpha = 1.0f-shadow;
-               L_sum = make_float3(0.0f, 0.0f, 0.0f);
+               *alpha = 1.0f - L->shadow_throughput * shadow;
+               L_sum = L->shadow_radiance_sum;
        }
        else {
-               L_sum = L->shadow_color * shadow;
+               L_sum = L->shadow_background_color * L->shadow_throughput * shadow +
+                       L->shadow_radiance_sum;
        }
        return L_sum;
 }
index fc093ad83194543e8916391f6bda3dde05324a1a..c340b3bc96859096b6cc1844436c8884185418bb 100644 (file)
@@ -643,11 +643,16 @@ ccl_device_inline float kernel_path_integrate(KernelGlobals *kg,
 #ifdef __SHADOW_TRICKS__
                if((sd.object_flag & SD_OBJECT_SHADOW_CATCHER)) {
                        if(state.flag & PATH_RAY_CAMERA) {
-                               state.flag |= (PATH_RAY_SHADOW_CATCHER | PATH_RAY_SHADOW_CATCHER_ONLY | PATH_RAY_STORE_SHADOW_INFO);
+                               state.flag |= (PATH_RAY_SHADOW_CATCHER |
+                                              PATH_RAY_SHADOW_CATCHER_ONLY |
+                                              PATH_RAY_STORE_SHADOW_INFO);
                                state.catcher_object = sd.object;
                                if(!kernel_data.background.transparent) {
-                                       L->shadow_color = indirect_background(kg, &emission_sd, &state, &ray);
+                                       L->shadow_background_color =
+                                               indirect_background(kg, &emission_sd, &state, &ray);
                                }
+                               L->shadow_radiance_sum = path_radiance_clamp_and_sum(kg, L);
+                               L->shadow_throughput = average(throughput);
                        }
                }
                else {
index 10816d3e5d1f28a4432dec52571e90df0b28417c..77d4f1df4472eb984d9c588076d9339374f62498 100644 (file)
@@ -499,13 +499,16 @@ ccl_device float kernel_branched_path_integrate(KernelGlobals *kg,
 
 #ifdef __SHADOW_TRICKS__
                if((sd.object_flag & SD_OBJECT_SHADOW_CATCHER)) {
-                       if(state.flag & PATH_RAY_CAMERA) {
-                               state.flag |= (PATH_RAY_SHADOW_CATCHER | PATH_RAY_SHADOW_CATCHER_ONLY | PATH_RAY_STORE_SHADOW_INFO);
-                               state.catcher_object = sd.object;
-                               if(!kernel_data.background.transparent) {
-                                       L->shadow_color = indirect_background(kg, &emission_sd, &state, &ray);
-                               }
+                       state.flag |= (PATH_RAY_SHADOW_CATCHER |
+                                      PATH_RAY_SHADOW_CATCHER_ONLY |
+                                      PATH_RAY_STORE_SHADOW_INFO);
+                       state.catcher_object = sd.object;
+                       if(!kernel_data.background.transparent) {
+                               L->shadow_background_color =
+                                       indirect_background(kg, &emission_sd, &state, &ray);
                        }
+                       L->shadow_radiance_sum = path_radiance_clamp_and_sum(kg, L);
+                       L->shadow_throughput = average(throughput);
                }
                else {
                        state.flag &= ~PATH_RAY_SHADOW_CATCHER_ONLY;
index 34affab1b9d03e559b2950b5c7417a10fe8431ba..37af98b32c7a19a8c4bb0c89b4e1d92881250ab6 100644 (file)
@@ -515,7 +515,13 @@ typedef ccl_addr_space struct PathRadiance {
        float3 path_total_shaded;
 
        /* Color of the background on which shadow is alpha-overed. */
-       float3 shadow_color;
+       float3 shadow_background_color;
+
+       /* Path radiance sum and throughput at the moment when ray hits shadow
+        * catcher object.
+        */
+       float3 shadow_radiance_sum;
+       float shadow_throughput;
 #endif
 
 #ifdef __DENOISING_FEATURES__
index 670a557f084d33fd7a89ef90c89ea7fa6ea705b1..fec671be0167df81d0186484e25aa5f6fea08142 100644 (file)
@@ -125,13 +125,21 @@ ccl_device void kernel_holdout_emission_blurring_pathtermination_ao(
 #ifdef __SHADOW_TRICKS__
                if((sd->object_flag & SD_OBJECT_SHADOW_CATCHER)) {
                        if(state->flag & PATH_RAY_CAMERA) {
-                               state->flag |= (PATH_RAY_SHADOW_CATCHER | PATH_RAY_SHADOW_CATCHER_ONLY | PATH_RAY_STORE_SHADOW_INFO);
+                               PathRadiance *L = &kernel_split_state.path_radiance[ray_index];
+                               state->flag |= (PATH_RAY_SHADOW_CATCHER |
+                                               PATH_RAY_SHADOW_CATCHER_ONLY |
+                                               PATH_RAY_STORE_SHADOW_INFO);
                                state->catcher_object = sd->object;
                                if(!kernel_data.background.transparent) {
-                                       PathRadiance *L = &kernel_split_state.path_radiance[ray_index];
                                        ccl_global Ray *ray = &kernel_split_state.ray[ray_index];
-                                       L->shadow_color = indirect_background(kg, &kernel_split_state.sd_DL_shadow[ray_index], state, ray);
+                                       L->shadow_background_color = indirect_background(
+                                               kg,
+                                               &kernel_split_state.sd_DL_shadow[ray_index],
+                                               state,
+                                               ray);
                                }
+                               L->shadow_radiance_sum = path_radiance_clamp_and_sum(kg, L);
+                               L->shadow_throughput = average(throughput);
                        }
                }
                else {
index e563d3f8cf0be14de14b3135a7e83096b56998dd..dfe7edde3371c40ecd7a62800fe22416d31e7d80 100644 (file)
@@ -913,7 +913,7 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, const wmEvent *even
                        case PADENTER:
                        case LEFTMOUSE:
                        case MIDDLEMOUSE:
-                               if (WM_modal_tweak_exit(event, mm->event_type)) {
+                               if (WM_event_is_modal_tweak_exit(event, mm->event_type)) {
                                        ed_marker_move_exit(C, op);
                                        WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL);
                                        WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL);
index 71a4980d4a6f6f1e36d720670febc5694f71e78c..812e7eba758596c1b774230461cbe21c4faee256 100644 (file)
@@ -687,16 +687,6 @@ static int walkEnd(bContext *C, WalkInfo *walk)
        return OPERATOR_CANCELLED;
 }
 
-static bool wm_event_is_last_mousemove(const wmEvent *event)
-{
-       while ((event = event->next)) {
-               if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) {
-                       return false;
-               }
-       }
-       return true;
-}
-
 static void walkEvent(bContext *C, wmOperator *op, WalkInfo *walk, const wmEvent *event)
 {
        if (event->type == TIMER && event->customdata == walk->timer) {
@@ -749,7 +739,7 @@ static void walkEvent(bContext *C, wmOperator *op, WalkInfo *walk, const wmEvent
                        }
                        else
 #endif
-                       if (wm_event_is_last_mousemove(event)) {
+                       if (WM_event_is_last_mousemove(event)) {
                                wmWindow *win = CTX_wm_window(C);
 
 #ifdef __APPLE__
index a8c67a296afbf0ee870a59af63da80e633e2a7ce..6dee20eb261710a74744bc03e87dbb5761543a03 100644 (file)
@@ -212,8 +212,9 @@ struct wmEventHandler *WM_event_add_dropbox_handler(ListBase *handlers, ListBase
 
                        /* mouse */
 void           WM_event_add_mousemove(struct bContext *C);
-bool        WM_modal_tweak_exit(const struct wmEvent *event, int tweak_event);
+bool           WM_event_is_modal_tweak_exit(const struct wmEvent *event, int tweak_event);
 bool           WM_event_is_absolute(const struct wmEvent *event);
+bool           WM_event_is_last_mousemove(const struct wmEvent *event);
 
 #ifdef WITH_INPUT_NDOF
                        /* 3D mouse */
index 6a1be83291886230caf70c342f61a9519b836289..dad6a6ec317f2229a931014353386b76e643ec30 100644 (file)
@@ -644,6 +644,16 @@ bool WM_event_is_absolute(const wmEvent *event)
        return (event->tablet_data != NULL);
 }
 
+bool WM_event_is_last_mousemove(const wmEvent *event)
+{
+       while ((event = event->next)) {
+               if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) {
+                       return false;
+               }
+       }
+       return true;
+}
+
 #ifdef WITH_INPUT_NDOF
 void WM_ndof_deadzone_set(float deadzone)
 {
@@ -2986,7 +2996,7 @@ void WM_event_add_mousemove(bContext *C)
 
 
 /* for modal callbacks, check configuration for how to interpret exit with tweaks  */
-bool WM_modal_tweak_exit(const wmEvent *event, int tweak_event)
+bool WM_event_is_modal_tweak_exit(const wmEvent *event, int tweak_event)
 {
        /* if the release-confirm userpref setting is enabled, 
         * tweak events can be canceled when mouse is released