Merge branch 'master' into blender2.8

This commit is contained in:
2018-09-11 11:01:39 +10:00
14 changed files with 122 additions and 116 deletions

View File

@@ -258,39 +258,34 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
float3 spec_weight = weight * specular_weight;
MicrofacetBsdf *bsdf = (MicrofacetBsdf*)bsdf_alloc(sd, sizeof(MicrofacetBsdf), spec_weight);
if(!bsdf) {
break;
}
MicrofacetExtra *extra = (MicrofacetExtra*)closure_alloc_extra(sd, sizeof(MicrofacetExtra));
if(!extra) {
break;
if (bsdf && extra) {
bsdf->N = N;
bsdf->ior = (2.0f / (1.0f - safe_sqrtf(0.08f * specular))) - 1.0f;
bsdf->T = T;
bsdf->extra = extra;
float aspect = safe_sqrtf(1.0f - anisotropic * 0.9f);
float r2 = roughness * roughness;
bsdf->alpha_x = r2 / aspect;
bsdf->alpha_y = r2 * aspect;
float m_cdlum = 0.3f * base_color.x + 0.6f * base_color.y + 0.1f * base_color.z; // luminance approx.
float3 m_ctint = m_cdlum > 0.0f ? base_color / m_cdlum : make_float3(0.0f, 0.0f, 0.0f); // normalize lum. to isolate hue+sat
float3 tmp_col = make_float3(1.0f, 1.0f, 1.0f) * (1.0f - specular_tint) + m_ctint * specular_tint;
bsdf->extra->cspec0 = (specular * 0.08f * tmp_col) * (1.0f - metallic) + base_color * metallic;
bsdf->extra->color = base_color;
bsdf->extra->clearcoat = 0.0f;
/* setup bsdf */
if(distribution == CLOSURE_BSDF_MICROFACET_GGX_GLASS_ID || roughness <= 0.075f) /* use single-scatter GGX */
sd->flag |= bsdf_microfacet_ggx_aniso_fresnel_setup(bsdf, sd);
else /* use multi-scatter GGX */
sd->flag |= bsdf_microfacet_multi_ggx_aniso_fresnel_setup(bsdf, sd);
}
bsdf->N = N;
bsdf->ior = (2.0f / (1.0f - safe_sqrtf(0.08f * specular))) - 1.0f;
bsdf->T = T;
bsdf->extra = extra;
float aspect = safe_sqrtf(1.0f - anisotropic * 0.9f);
float r2 = roughness * roughness;
bsdf->alpha_x = r2 / aspect;
bsdf->alpha_y = r2 * aspect;
float m_cdlum = 0.3f * base_color.x + 0.6f * base_color.y + 0.1f * base_color.z; // luminance approx.
float3 m_ctint = m_cdlum > 0.0f ? base_color / m_cdlum : make_float3(0.0f, 0.0f, 0.0f); // normalize lum. to isolate hue+sat
float3 tmp_col = make_float3(1.0f, 1.0f, 1.0f) * (1.0f - specular_tint) + m_ctint * specular_tint;
bsdf->extra->cspec0 = (specular * 0.08f * tmp_col) * (1.0f - metallic) + base_color * metallic;
bsdf->extra->color = base_color;
bsdf->extra->clearcoat = 0.0f;
/* setup bsdf */
if(distribution == CLOSURE_BSDF_MICROFACET_GGX_GLASS_ID || roughness <= 0.075f) /* use single-scatter GGX */
sd->flag |= bsdf_microfacet_ggx_aniso_fresnel_setup(bsdf, sd);
else /* use multi-scatter GGX */
sd->flag |= bsdf_microfacet_multi_ggx_aniso_fresnel_setup(bsdf, sd);
}
#ifdef __CAUSTICS_TRICKS__
}
@@ -313,29 +308,24 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
#endif
{
MicrofacetBsdf *bsdf = (MicrofacetBsdf*)bsdf_alloc(sd, sizeof(MicrofacetBsdf), glass_weight*fresnel);
if(!bsdf) {
break;
}
MicrofacetExtra *extra = (MicrofacetExtra*)closure_alloc_extra(sd, sizeof(MicrofacetExtra));
if(!extra) {
break;
if (bsdf && extra) {
bsdf->N = N;
bsdf->T = make_float3(0.0f, 0.0f, 0.0f);
bsdf->extra = extra;
bsdf->alpha_x = refl_roughness * refl_roughness;
bsdf->alpha_y = refl_roughness * refl_roughness;
bsdf->ior = ior;
bsdf->extra->color = base_color;
bsdf->extra->cspec0 = cspec0;
bsdf->extra->clearcoat = 0.0f;
/* setup bsdf */
sd->flag |= bsdf_microfacet_ggx_fresnel_setup(bsdf, sd);
}
bsdf->N = N;
bsdf->T = make_float3(0.0f, 0.0f, 0.0f);
bsdf->extra = extra;
bsdf->alpha_x = refl_roughness * refl_roughness;
bsdf->alpha_y = refl_roughness * refl_roughness;
bsdf->ior = ior;
bsdf->extra->color = base_color;
bsdf->extra->cspec0 = cspec0;
bsdf->extra->clearcoat = 0.0f;
/* setup bsdf */
sd->flag |= bsdf_microfacet_ggx_fresnel_setup(bsdf, sd);
}
/* refraction */
@@ -344,52 +334,45 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
#endif
{
MicrofacetBsdf *bsdf = (MicrofacetBsdf*)bsdf_alloc(sd, sizeof(MicrofacetBsdf), base_color*glass_weight*(1.0f - fresnel));
if(!bsdf) {
break;
if(bsdf) {
bsdf->N = N;
bsdf->T = make_float3(0.0f, 0.0f, 0.0f);
bsdf->extra = NULL;
if(distribution == CLOSURE_BSDF_MICROFACET_GGX_GLASS_ID)
transmission_roughness = 1.0f - (1.0f - refl_roughness) * (1.0f - transmission_roughness);
else
transmission_roughness = refl_roughness;
bsdf->alpha_x = transmission_roughness * transmission_roughness;
bsdf->alpha_y = transmission_roughness * transmission_roughness;
bsdf->ior = ior;
/* setup bsdf */
sd->flag |= bsdf_microfacet_ggx_refraction_setup(bsdf);
}
bsdf->N = N;
bsdf->T = make_float3(0.0f, 0.0f, 0.0f);
bsdf->extra = NULL;
if(distribution == CLOSURE_BSDF_MICROFACET_GGX_GLASS_ID)
transmission_roughness = 1.0f - (1.0f - refl_roughness) * (1.0f - transmission_roughness);
else
transmission_roughness = refl_roughness;
bsdf->alpha_x = transmission_roughness * transmission_roughness;
bsdf->alpha_y = transmission_roughness * transmission_roughness;
bsdf->ior = ior;
/* setup bsdf */
sd->flag |= bsdf_microfacet_ggx_refraction_setup(bsdf);
}
}
else { /* use multi-scatter GGX */
MicrofacetBsdf *bsdf = (MicrofacetBsdf*)bsdf_alloc(sd, sizeof(MicrofacetBsdf), glass_weight);
if(!bsdf) {
break;
}
MicrofacetExtra *extra = (MicrofacetExtra*)closure_alloc_extra(sd, sizeof(MicrofacetExtra));
if(!extra) {
break;
if(bsdf && extra) {
bsdf->N = N;
bsdf->extra = extra;
bsdf->T = make_float3(0.0f, 0.0f, 0.0f);
bsdf->alpha_x = roughness * roughness;
bsdf->alpha_y = roughness * roughness;
bsdf->ior = ior;
bsdf->extra->color = base_color;
bsdf->extra->cspec0 = cspec0;
bsdf->extra->clearcoat = 0.0f;
/* setup bsdf */
sd->flag |= bsdf_microfacet_multi_ggx_glass_fresnel_setup(bsdf, sd);
}
bsdf->N = N;
bsdf->extra = extra;
bsdf->T = make_float3(0.0f, 0.0f, 0.0f);
bsdf->alpha_x = roughness * roughness;
bsdf->alpha_y = roughness * roughness;
bsdf->ior = ior;
bsdf->extra->color = base_color;
bsdf->extra->cspec0 = cspec0;
bsdf->extra->clearcoat = 0.0f;
/* setup bsdf */
sd->flag |= bsdf_microfacet_multi_ggx_glass_fresnel_setup(bsdf, sd);
}
}
#ifdef __CAUSTICS_TRICKS__
@@ -402,29 +385,24 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
#endif
if(clearcoat > CLOSURE_WEIGHT_CUTOFF) {
MicrofacetBsdf *bsdf = (MicrofacetBsdf*)bsdf_alloc(sd, sizeof(MicrofacetBsdf), weight);
if(!bsdf) {
break;
}
MicrofacetExtra *extra = (MicrofacetExtra*)closure_alloc_extra(sd, sizeof(MicrofacetExtra));
if(!extra) {
break;
if(bsdf && extra) {
bsdf->N = clearcoat_normal;
bsdf->T = make_float3(0.0f, 0.0f, 0.0f);
bsdf->ior = 1.5f;
bsdf->extra = extra;
bsdf->alpha_x = clearcoat_roughness * clearcoat_roughness;
bsdf->alpha_y = clearcoat_roughness * clearcoat_roughness;
bsdf->extra->color = make_float3(0.0f, 0.0f, 0.0f);
bsdf->extra->cspec0 = make_float3(0.04f, 0.04f, 0.04f);
bsdf->extra->clearcoat = clearcoat;
/* setup bsdf */
sd->flag |= bsdf_microfacet_ggx_clearcoat_setup(bsdf, sd);
}
bsdf->N = clearcoat_normal;
bsdf->T = make_float3(0.0f, 0.0f, 0.0f);
bsdf->ior = 1.5f;
bsdf->extra = extra;
bsdf->alpha_x = clearcoat_roughness * clearcoat_roughness;
bsdf->alpha_y = clearcoat_roughness * clearcoat_roughness;
bsdf->extra->color = make_float3(0.0f, 0.0f, 0.0f);
bsdf->extra->cspec0 = make_float3(0.04f, 0.04f, 0.04f);
bsdf->extra->clearcoat = clearcoat;
/* setup bsdf */
sd->flag |= bsdf_microfacet_ggx_clearcoat_setup(bsdf, sd);
}
#ifdef __CAUSTICS_TRICKS__
}

View File

@@ -506,6 +506,11 @@ void UI_blocklist_update_window_matrix(const struct bContext *C, const struct Li
void UI_blocklist_draw(const struct bContext *C, const struct ListBase *lb);
void UI_block_update_from_old(const struct bContext *C, struct uiBlock *block);
enum {
UI_BLOCK_THEME_STYLE_REGULAR = 0,
UI_BLOCK_THEME_STYLE_POPUP = 1,
};
void UI_block_theme_style_set(uiBlock *block, char theme_style);
void UI_block_emboss_set(uiBlock *block, char dt);
void UI_block_free(const struct bContext *C, uiBlock *block);

View File

@@ -2943,6 +2943,11 @@ void UI_block_emboss_set(uiBlock *block, char dt)
block->dt = dt;
}
void UI_block_theme_style_set(uiBlock *block, char theme_style)
{
block->theme_style = theme_style;
}
/**
* \param but: Button to update.
* \param validate: When set, this function may change the button value.

View File

@@ -409,6 +409,7 @@ struct uiBlock {
short content_hints; /* eBlockContentHints */
char direction;
char theme_style; /* UI_BLOCK_THEME_STYLE_* */
char dt; /* drawtype: UI_EMBOSS, UI_EMBOSS_NONE ... etc, copied to buttons */
bool auto_open;
char _pad[5];

View File

@@ -629,6 +629,7 @@ uiBlock *ui_block_func_COLOR(bContext *C, uiPopupBlockHandle *handle, void *arg_
ui_block_colorpicker(block, handle->retvec, &but->rnapoin, but->rnaprop, show_picker);
block->flag = UI_BLOCK_LOOP | UI_BLOCK_KEEP_OPEN | UI_BLOCK_OUT_1 | UI_BLOCK_MOVEMOUSE_QUIT;
UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP);
UI_block_bounds_set_normal(block, 0.5 * UI_UNIT_X);
block->block_event_func = ui_colorpicker_small_wheel_cb;

View File

@@ -87,6 +87,7 @@ static uiBlock *ui_block_func_PIE(bContext *UNUSED(C), uiPopupBlockHandle *handl
UI_block_layout_resolve(block, &width, &height);
UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_NUMSELECT);
UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP);
block->minbounds = minwidth;
block->bounds = 1;

View File

@@ -241,6 +241,7 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi
uiBut *but_activate = NULL;
UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_NUMSELECT);
UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP);
UI_block_direction_set(block, direction);
/* offset the mouse position, possibly based on earlier selection */

View File

@@ -197,6 +197,7 @@ static uiBlock *ui_block_func_POPOVER(bContext *C, uiPopupBlockHandle *handle, v
/* Not attached to a button. */
int offset[2] = {0, 0};
UI_block_flag_enable(block, UI_BLOCK_LOOP);
UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP);
UI_block_direction_set(block, block->direction);
block->minbounds = UI_MENU_WIDTH_MIN;
bool use_place_under_active = !handle->refresh;

View File

@@ -514,6 +514,7 @@ uiBlock *ui_popup_block_refresh(
}
block->flag |= UI_BLOCK_LOOP;
UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP);
/* defer this until blocks are translated (below) */
block->oldblock = NULL;

View File

@@ -186,6 +186,7 @@ static uiBlock *template_common_search_menu(
block = UI_block_begin(C, region, "_popup", UI_EMBOSS);
UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_SEARCH_MENU);
UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP);
/* preview thumbnails */
if (preview_rows > 0 && preview_cols > 0) {
@@ -2510,6 +2511,7 @@ static uiBlock *ui_icon_view_menu_cb(bContext *C, ARegion *ar, void *arg_litem)
block = UI_block_begin(C, ar, "_popup", UI_EMBOSS_PULLDOWN);
UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_NO_FLIP);
UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP);
RNA_property_enum_items(C, &args.ptr, args.prop, &item, NULL, &free);

View File

@@ -4088,7 +4088,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
wt->wcol_theme = &tui->wcol_box;
wt->state = widget_state;
}
else if (but->block->flag & UI_BLOCK_LOOP) {
else if (but->block->theme_style == UI_BLOCK_THEME_STYLE_POPUP) {
wt->wcol_theme = &tui->wcol_menu_back;
wt->state = widget_state;
}
@@ -4134,8 +4134,9 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
case UI_BTYPE_SEARCH_MENU:
wt = widget_type(UI_WTYPE_NAME);
if (but->block->flag & UI_BLOCK_LOOP)
if (but->block->theme_style == UI_BLOCK_THEME_STYLE_POPUP) {
wt->wcol_theme = &btheme->tui.wcol_menu_back;
}
break;
case UI_BTYPE_TAB:
@@ -4158,9 +4159,9 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
wt = widget_type(UI_WTYPE_TOGGLE);
/* option buttons have strings outside, on menus use different colors */
if (but->block->flag & UI_BLOCK_LOOP)
if (but->block->theme_style == UI_BLOCK_THEME_STYLE_POPUP) {
wt->state = widget_state_option_menu;
}
break;
case UI_BTYPE_MENU:

View File

@@ -1020,6 +1020,7 @@ static uiBlock *node_find_menu(bContext *C, ARegion *ar, void *arg_op)
block = UI_block_begin(C, ar, "_popup", UI_EMBOSS);
UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_MOVEMOUSE_QUIT | UI_BLOCK_SEARCH_MENU);
UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP);
but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 10, 9 * UI_UNIT_X, UI_UNIT_Y, 0, 0, "");
UI_but_func_search_set(but, NULL, node_find_cb, op->type, node_find_call_cb, NULL);

View File

@@ -785,6 +785,7 @@ static uiBlock *wm_enum_search_menu(bContext *C, ARegion *ar, void *arg)
block = UI_block_begin(C, ar, "_popup", UI_EMBOSS);
UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_MOVEMOUSE_QUIT | UI_BLOCK_SEARCH_MENU);
UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP);
search[0] = '\0';
BLI_assert(search_menu->use_previews || (search_menu->prv_cols == 0 && search_menu->prv_rows == 0));
@@ -1027,6 +1028,8 @@ static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op)
block = UI_block_begin(C, ar, __func__, UI_EMBOSS);
UI_block_flag_disable(block, UI_BLOCK_LOOP);
UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_REGULAR);
/* UI_BLOCK_NUMSELECT for layer buttons */
UI_block_flag_enable(block, UI_BLOCK_NUMSELECT | UI_BLOCK_KEEP_OPEN | UI_BLOCK_MOVEMOUSE_QUIT);
@@ -1115,6 +1118,7 @@ static uiBlock *wm_block_dialog_create(bContext *C, ARegion *ar, void *userData)
block = UI_block_begin(C, ar, __func__, UI_EMBOSS);
UI_block_flag_disable(block, UI_BLOCK_LOOP);
UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_REGULAR);
/* intentionally don't use 'UI_BLOCK_MOVEMOUSE_QUIT', some dialogues have many items
* where quitting by accident is very annoying */
@@ -1159,6 +1163,7 @@ static uiBlock *wm_operator_ui_create(bContext *C, ARegion *ar, void *userData)
block = UI_block_begin(C, ar, __func__, UI_EMBOSS);
UI_block_flag_disable(block, UI_BLOCK_LOOP);
UI_block_flag_enable(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_MOVEMOUSE_QUIT);
UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_REGULAR);
layout = UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, data->width, data->height, 0, style);
@@ -1486,6 +1491,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
* with the OS when the splash shows, window clipping in this case gives
* ugly results and clipping the splash isn't useful anyway, just disable it [#32938] */
UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_KEEP_OPEN | UI_BLOCK_NO_WIN_CLIP);
UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP);
/* XXX splash scales with pixelsize, should become widget-units */
but = uiDefBut(block, UI_BTYPE_IMAGE, 0, "", 0, 0.5f * U.widget_unit, U.pixelsize * 501, U.pixelsize * 282, ibuf, 0.0, 0.0, 0, 0, ""); /* button owns the imbuf now */
@@ -1647,6 +1653,7 @@ static uiBlock *wm_block_search_menu(bContext *C, ARegion *ar, void *userdata)
block = UI_block_begin(C, ar, "_popup", UI_EMBOSS);
UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_MOVEMOUSE_QUIT | UI_BLOCK_SEARCH_MENU);
UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP);
but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 10, init_data->size[0], UI_UNIT_Y, 0, 0, "");
UI_but_func_operator_search(but);

View File

@@ -377,6 +377,7 @@ static uiBlock *block_create_confirm_quit(struct bContext *C, struct ARegion *ar
uiBlock *block = UI_block_begin(C, ar, "confirm_quit_popup", UI_EMBOSS);
UI_block_flag_enable(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_LOOP | UI_BLOCK_NO_WIN_CLIP | UI_BLOCK_NUMSELECT);
UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP);
UI_block_emboss_set(block, UI_EMBOSS);
uiLayout *layout = UI_block_layout(