From 595cfd2a81efef18ec368504611257a36e3de3fd Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 14 Aug 2017 16:38:50 +0200 Subject: Fix T52331: Motion blur shutter length not keyable The only reason shutter time was marked as non-animatable is because Blender Internal render does not support such animation. But this is something what users are keeping asking for and now Blender Internal is on it's way out. Enabled animation of this property, but noted in tooltip that Blender Internal does not support animation of this property. --- source/blender/makesrna/intern/rna_scene.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 2b468aa6910..2722f8759b8 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -6250,8 +6250,8 @@ static void rna_def_scene_render_data(BlenderRNA *brna) prop = RNA_def_property(srna, "motion_blur_shutter", PROP_FLOAT, PROP_UNSIGNED); RNA_def_property_float_sdna(prop, NULL, "blurfac"); RNA_def_property_ui_range(prop, 0.01f, 2.0f, 1, 2); - RNA_def_property_ui_text(prop, "Shutter", "Time taken in frames between shutter open and close"); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Shutter", "Time taken in frames between shutter open and close " + "(NOTE: Blender Internal does not support animated shutter)"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); prop = RNA_def_property(srna, "motion_blur_shutter_curve", PROP_POINTER, PROP_NONE); -- cgit v1.2.3 From 66c1b23aa10ded34869c2efabbe815ea254d4b09 Mon Sep 17 00:00:00 2001 From: Lukas Stockner Date: Tue, 15 Aug 2017 00:11:52 +0200 Subject: Cycles/BI: Add a pixel size option for speeding up viewport rendering This patch adds "Pixel Size" to the performance options, which allows to render in a smaller resolution, which is especially useful for displays with high DPI. Reviewers: Severin, dingto, sergey, brecht Reviewed By: brecht Subscribers: Severin, venomgfx, eyecandy, brecht Differential Revision: https://developer.blender.org/D1619 --- source/blender/blenkernel/BKE_scene.h | 2 ++ source/blender/blenkernel/intern/scene.c | 8 ++++++++ source/blender/editors/render/render_internal.c | 9 +++++---- source/blender/makesdna/DNA_scene_types.h | 3 +-- source/blender/makesrna/intern/rna_render.c | 14 ++++++++++++++ source/blender/makesrna/intern/rna_scene.c | 22 ++++++++++++++++++++++ 6 files changed, 52 insertions(+), 6 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h index f1680b6ccbf..b7ecb85819e 100644 --- a/source/blender/blenkernel/BKE_scene.h +++ b/source/blender/blenkernel/BKE_scene.h @@ -152,6 +152,8 @@ bool BKE_scene_check_rigidbody_active(const struct Scene *scene); int BKE_scene_num_threads(const struct Scene *scene); int BKE_render_num_threads(const struct RenderData *r); +int BKE_render_preview_pixel_size(const struct RenderData *r); + double BKE_scene_unit_scale(const struct UnitSettings *unit, const int unit_type, double value); /* multiview */ diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index b7fc6e70e65..b8ad54dc533 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -2411,6 +2411,14 @@ int BKE_scene_num_threads(const Scene *scene) return BKE_render_num_threads(&scene->r); } +int BKE_render_preview_pixel_size(const RenderData *r) +{ + if (r->preview_pixel_size == 0) { + return (U.pixelsize > 1.5f)? 2 : 1; + } + return r->preview_pixel_size; +} + /* Apply the needed correction factor to value, based on unit_type (only length-related are affected currently) * and unit->scale_length. */ diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index 9d98a3676ac..da14e72f887 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -1171,7 +1171,7 @@ static void render_update_resolution(Render *re, const RenderPreview *rp, } if (rp->has_freestyle) { - if (rp->resolution_divider == 1) { + if (rp->resolution_divider == BKE_render_preview_pixel_size(&rp->scene->r)) { RE_ChangeModeFlag(re, R_EDGE_FRS, false); } else { @@ -1312,11 +1312,12 @@ static void render_view3d_startjob(void *customdata, short *stop, short *do_upda RE_updateRenderInstances(re, ob_inst_update_flag); for (;;) { + int pixel_size = BKE_render_preview_pixel_size(&rp->scene->r); if (first_time == false) { if (restore) RE_DataBase_IncrementalView(re, rp->viewmat, 1); - rp->resolution_divider /= 2; + rp->resolution_divider = MAX2(rp->resolution_divider/2, pixel_size); *do_update = 1; render_update_resolution(re, rp, use_border, &cliprct); @@ -1333,7 +1334,7 @@ static void render_view3d_startjob(void *customdata, short *stop, short *do_upda first_time = false; - if (*stop || rp->resolution_divider == 1) { + if (*stop || rp->resolution_divider == pixel_size) { break; } } @@ -1435,7 +1436,7 @@ static void render_view3d_do(RenderEngine *engine, const bContext *C) Scene *scene = CTX_data_scene(C); ARegion *ar = CTX_wm_region(C); int width = ar->winx, height = ar->winy; - int divider = 1; + int divider = BKE_render_preview_pixel_size(&scene->r); int resolution_threshold = scene->r.preview_start_resolution * scene->r.preview_start_resolution; diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 2bca5565553..de516dc0f1f 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -790,14 +790,13 @@ typedef struct RenderData { struct BakeData bake; int preview_start_resolution; + short preview_pixel_size; /* Type of the debug pass to use. * Only used when built with debug passes support. */ short debug_pass_type; - short pad; - /* MultiView */ ListBase views; /* SceneRenderView */ short actview; diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c index c30765d8857..a66c160ed1a 100644 --- a/source/blender/makesrna/intern/rna_render.c +++ b/source/blender/makesrna/intern/rna_render.c @@ -33,6 +33,8 @@ #include "BLI_utildefines.h" #include "BLI_path_util.h" +#include "BKE_scene.h" + #include "RNA_define.h" #include "RNA_enum_types.h" @@ -123,6 +125,11 @@ static int engine_support_display_space_shader(RenderEngine *UNUSED(engine), Sce return IMB_colormanagement_support_glsl_draw(&scene->view_settings); } +static int engine_get_preview_pixel_size(RenderEngine *UNUSED(engine), Scene *scene) +{ + return BKE_render_preview_pixel_size(&scene->r); +} + static void engine_bind_display_space_shader(RenderEngine *UNUSED(engine), Scene *scene) { IMB_colormanagement_setup_glsl_draw(&scene->view_settings, @@ -647,6 +654,13 @@ static void rna_def_render_engine(BlenderRNA *brna) parm = RNA_def_boolean(func, "supported", 0, "Supported", ""); RNA_def_function_return(func, parm); + func = RNA_def_function(srna, "get_preview_pixel_size", "engine_get_preview_pixel_size"); + RNA_def_function_ui_description(func, "Get the pixel size that should be used for preview rendering"); + parm = RNA_def_pointer(func, "scene", "Scene", "", ""); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + parm = RNA_def_int(func, "pixel_size", 0, 1, 8, "Pixel Size", "", 1, 8); + RNA_def_function_return(func, parm); + RNA_define_verify_sdna(0); prop = RNA_def_property(srna, "is_animation", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 2722f8759b8..71350edeb94 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -1846,6 +1846,13 @@ static void rna_Scene_simplify_update(Main *bmain, Scene *UNUSED(scene), Pointer rna_Scene_use_simplify_update(bmain, sce, ptr); } +static void rna_SceneRenderData_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +{ + Scene *sce = ptr->id.data; + + DAG_id_tag_update(&sce->id, 0); +} + static void rna_Scene_use_persistent_data_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { Scene *sce = ptr->id.data; @@ -5895,6 +5902,15 @@ static void rna_def_scene_render_data(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; + static EnumPropertyItem pixel_size_items[] = { + {0, "AUTO", 0, "Automatic", "Automatic pixel size, depends on the UI scale"}, + {1, "1", 0, "1x", "Render at full resolution"}, + {2, "2", 0, "2x", "Render at 50% resolution"}, + {4, "4", 0, "4x", "Render at 25% resolution"}, + {8, "8", 0, "8x", "Render at 12.5% resolution"}, + {0, NULL, 0, NULL, NULL} + }; + static EnumPropertyItem octree_resolution_items[] = { {64, "64", 0, "64", ""}, {128, "128", 0, "128", ""}, @@ -6018,6 +6034,12 @@ static void rna_def_scene_render_data(BlenderRNA *brna) "progressively increasing it to the full viewport size"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); + prop = RNA_def_property(srna, "preview_pixel_size", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "preview_pixel_size"); + RNA_def_property_enum_items(prop, pixel_size_items); + RNA_def_property_ui_text(prop, "Pixel Size", "Pixel size for viewport rendering"); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderData_update"); + prop = RNA_def_property(srna, "pixel_aspect_x", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "xasp"); RNA_def_property_flag(prop, PROP_PROPORTIONAL); -- cgit v1.2.3 From ac88a3942e49f73f6ccf050f7275b9fb34888743 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 15 Aug 2017 12:34:40 +0200 Subject: Alembic import: fix crash when face color index is out of bounds. This can happen with Alembic files exported from Maya. I'm unsure as to the root cause, but at least this fixes the crash itself. Thanks to @looch for reporting this with a test file. The test file has to remain confidential, though, so it's on my workstation only. --- source/blender/alembic/intern/abc_customdata.cc | 33 ++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/blender/alembic/intern/abc_customdata.cc b/source/blender/alembic/intern/abc_customdata.cc index 1d2bc689027..3380aaf222e 100644 --- a/source/blender/alembic/intern/abc_customdata.cc +++ b/source/blender/alembic/intern/abc_customdata.cc @@ -252,6 +252,26 @@ static void read_uvs(const CDStreamConfig &config, void *data, } } +static size_t mcols_out_of_bounds_check( + const size_t color_index, + const size_t array_size, + const PropertyHeader &prop_header, + bool &r_bounds_warning_given) +{ + if (color_index < array_size) { + return color_index; + } + + if (!r_bounds_warning_given) { + std::cerr << "Alembic import: color index out of bounds " + "reading face colors for property " + << prop_header.getName() << std::endl; + r_bounds_warning_given = true; + } + + return 0; +} + static void read_custom_data_mcols(const ICompoundProperty &arbGeomParams, const PropertyHeader &prop_header, const CDStreamConfig &config, @@ -303,6 +323,8 @@ static void read_custom_data_mcols(const ICompoundProperty &arbGeomParams, size_t face_index = 0; size_t color_index; + bool bounds_warning_given = false; + for (int i = 0; i < config.totpoly; ++i) { MPoly *poly = &mpolys[i]; MCol *cface = &cfaces[poly->loopstart + poly->totloop]; @@ -311,9 +333,13 @@ static void read_custom_data_mcols(const ICompoundProperty &arbGeomParams, for (int j = 0; j < poly->totloop; ++j, ++face_index) { --cface; --mloop; - color_index = is_facevarying ? face_index : mloop->v; if (use_c3f_ptr) { + color_index = mcols_out_of_bounds_check( + is_facevarying ? face_index : mloop->v, + c3f_ptr->size(), + prop_header, bounds_warning_given); + const Imath::C3f &color = (*c3f_ptr)[color_index]; cface->a = FTOCHAR(color[0]); cface->r = FTOCHAR(color[1]); @@ -321,6 +347,11 @@ static void read_custom_data_mcols(const ICompoundProperty &arbGeomParams, cface->b = 255; } else { + color_index = mcols_out_of_bounds_check( + is_facevarying ? face_index : mloop->v, + c4f_ptr->size(), + prop_header, bounds_warning_given); + const Imath::C4f &color = (*c4f_ptr)[color_index]; cface->a = FTOCHAR(color[0]); cface->r = FTOCHAR(color[1]); -- cgit v1.2.3 From f20d7bed1426ca3d1268182835f04e7ab8212cac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 15 Aug 2017 12:43:17 +0200 Subject: Alembic import: report object name in face color index out of bounds error --- source/blender/alembic/intern/abc_customdata.cc | 23 ++++++++++++++++------- source/blender/alembic/intern/abc_customdata.h | 3 ++- source/blender/alembic/intern/abc_mesh.cc | 18 ++++++++++++------ 3 files changed, 30 insertions(+), 14 deletions(-) (limited to 'source') diff --git a/source/blender/alembic/intern/abc_customdata.cc b/source/blender/alembic/intern/abc_customdata.cc index 3380aaf222e..d6e7a80d174 100644 --- a/source/blender/alembic/intern/abc_customdata.cc +++ b/source/blender/alembic/intern/abc_customdata.cc @@ -255,6 +255,7 @@ static void read_uvs(const CDStreamConfig &config, void *data, static size_t mcols_out_of_bounds_check( const size_t color_index, const size_t array_size, + const std::string & iobject_full_name, const PropertyHeader &prop_header, bool &r_bounds_warning_given) { @@ -263,8 +264,10 @@ static size_t mcols_out_of_bounds_check( } if (!r_bounds_warning_given) { - std::cerr << "Alembic import: color index out of bounds " - "reading face colors for property " + std::cerr << "Alembic: color index out of bounds " + "reading face colors for object " + << iobject_full_name + << ", property " << prop_header.getName() << std::endl; r_bounds_warning_given = true; } @@ -272,7 +275,8 @@ static size_t mcols_out_of_bounds_check( return 0; } -static void read_custom_data_mcols(const ICompoundProperty &arbGeomParams, +static void read_custom_data_mcols(const std::string & iobject_full_name, + const ICompoundProperty &arbGeomParams, const PropertyHeader &prop_header, const CDStreamConfig &config, const Alembic::Abc::ISampleSelector &iss) @@ -338,7 +342,8 @@ static void read_custom_data_mcols(const ICompoundProperty &arbGeomParams, color_index = mcols_out_of_bounds_check( is_facevarying ? face_index : mloop->v, c3f_ptr->size(), - prop_header, bounds_warning_given); + iobject_full_name, prop_header, + bounds_warning_given); const Imath::C3f &color = (*c3f_ptr)[color_index]; cface->a = FTOCHAR(color[0]); @@ -350,7 +355,8 @@ static void read_custom_data_mcols(const ICompoundProperty &arbGeomParams, color_index = mcols_out_of_bounds_check( is_facevarying ? face_index : mloop->v, c4f_ptr->size(), - prop_header, bounds_warning_given); + iobject_full_name, prop_header, + bounds_warning_given); const Imath::C4f &color = (*c4f_ptr)[color_index]; cface->a = FTOCHAR(color[0]); @@ -387,7 +393,10 @@ static void read_custom_data_uvs(const ICompoundProperty &prop, read_uvs(config, cd_data, sample.getVals(), sample.getIndices()); } -void read_custom_data(const ICompoundProperty &prop, const CDStreamConfig &config, const Alembic::Abc::ISampleSelector &iss) +void read_custom_data(const std::string & iobject_full_name, + const ICompoundProperty &prop, + const CDStreamConfig &config, + const Alembic::Abc::ISampleSelector &iss) { if (!prop.valid()) { return; @@ -417,7 +426,7 @@ void read_custom_data(const ICompoundProperty &prop, const CDStreamConfig &confi continue; } - read_custom_data_mcols(prop, prop_header, config, iss); + read_custom_data_mcols(iobject_full_name, prop, prop_header, config, iss); continue; } } diff --git a/source/blender/alembic/intern/abc_customdata.h b/source/blender/alembic/intern/abc_customdata.h index 9e671fde386..b3072a2c9f7 100644 --- a/source/blender/alembic/intern/abc_customdata.h +++ b/source/blender/alembic/intern/abc_customdata.h @@ -96,7 +96,8 @@ void write_custom_data(const OCompoundProperty &prop, CustomData *data, int data_type); -void read_custom_data(const ICompoundProperty &prop, +void read_custom_data(const std::string & iobject_full_name, + const ICompoundProperty &prop, const CDStreamConfig &config, const Alembic::Abc::ISampleSelector &iss); diff --git a/source/blender/alembic/intern/abc_mesh.cc b/source/blender/alembic/intern/abc_mesh.cc index 456d16b3e0d..6545ced8e4a 100644 --- a/source/blender/alembic/intern/abc_mesh.cc +++ b/source/blender/alembic/intern/abc_mesh.cc @@ -943,7 +943,8 @@ static void get_weight_and_index(CDStreamConfig &config, config.ceil_index = i1; } -static void read_mesh_sample(ImportSettings *settings, +static void read_mesh_sample(const std::string & iobject_full_name, + ImportSettings *settings, const IPolyMeshSchema &schema, const ISampleSelector &selector, CDStreamConfig &config, @@ -981,7 +982,8 @@ static void read_mesh_sample(ImportSettings *settings, } if ((settings->read_flag & (MOD_MESHSEQ_READ_UV | MOD_MESHSEQ_READ_COLOR)) != 0) { - read_custom_data(schema.getArbGeomParams(), config, selector); + read_custom_data(iobject_full_name, + schema.getArbGeomParams(), config, selector); } } @@ -1110,7 +1112,8 @@ DerivedMesh *AbcMeshReader::read_derivedmesh(DerivedMesh *dm, config.time = sample_sel.getRequestedTime(); bool do_normals = false; - read_mesh_sample(&settings, m_schema, sample_sel, config, do_normals); + read_mesh_sample(m_iobject.getFullName(), + &settings, m_schema, sample_sel, config, do_normals); if (new_dm) { /* Check if we had ME_SMOOTH flag set to restore it. */ @@ -1217,7 +1220,8 @@ ABC_INLINE MEdge *find_edge(MEdge *edges, int totedge, int v1, int v2) return NULL; } -static void read_subd_sample(ImportSettings *settings, +static void read_subd_sample(const std::string & iobject_full_name, + ImportSettings *settings, const ISubDSchema &schema, const ISampleSelector &selector, CDStreamConfig &config) @@ -1252,7 +1256,8 @@ static void read_subd_sample(ImportSettings *settings, } if ((settings->read_flag & (MOD_MESHSEQ_READ_UV | MOD_MESHSEQ_READ_COLOR)) != 0) { - read_custom_data(schema.getArbGeomParams(), config, selector); + read_custom_data(iobject_full_name, + schema.getArbGeomParams(), config, selector); } } @@ -1382,7 +1387,8 @@ DerivedMesh *AbcSubDReader::read_derivedmesh(DerivedMesh *dm, /* Only read point data when streaming meshes, unless we need to create new ones. */ CDStreamConfig config = get_config(new_dm ? new_dm : dm); config.time = sample_sel.getRequestedTime(); - read_subd_sample(&settings, m_schema, sample_sel, config); + read_subd_sample(m_iobject.getFullName(), + &settings, m_schema, sample_sel, config); if (new_dm) { /* Check if we had ME_SMOOTH flag set to restore it. */ -- cgit v1.2.3