Implement Start Resolution for preview render in BI
authorSergey Sharybin <sergey.vfx@gmail.com>
Wed, 9 Jul 2014 13:02:07 +0000 (19:02 +0600)
committerSergey Sharybin <sergey.vfx@gmail.com>
Wed, 9 Jul 2014 13:55:40 +0000 (19:55 +0600)
So now viewport render resolution division works exactly the same as in Cycles.

release/scripts/startup/bl_ui/properties_render.py
source/blender/blenloader/intern/versioning_270.c
source/blender/editors/render/render_internal.c
source/blender/makesdna/DNA_scene_types.h
source/blender/makesrna/intern/rna_scene.c

index 42cb6086c35da5bd1c26b13cf8c23ce05b653a3f..9ffd244d78fdbc496e4fc460bf7b041e46e5ac3a 100644 (file)
@@ -273,6 +273,9 @@ class RENDER_PT_performance(RenderButtonsPanel, Panel):
         col.prop(rd, "tile_x", text="X")
         col.prop(rd, "tile_y", text="Y")
 
+        col.separator()
+        col.prop(rd, 'preview_start_resolution')
+
         col = split.column()
         col.label(text="Memory:")
         sub = col.column()
index 50e7c83447bcb7ed198844fa0040244a7a4d7ccf..103f9b76ba7cb19de9d4f5f3335242d5d7a87bde 100644 (file)
@@ -309,4 +309,11 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
                        }
                }
        }
+
+       if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "int", "preview_start_resolution")) {
+               Scene *scene;
+               for (scene = main->scene.first; scene; scene = scene->id.next) {
+                       scene->r.preview_start_resolution = 64;
+               }
+       }
 }
index bf7b4cf785b375c3fbda5b863c980f656f4c8a52..fd67115808fd3786f6667d5af3613205afbac206 100644 (file)
@@ -1014,8 +1014,6 @@ void RENDER_OT_render(wmOperatorType *ot)
 #define PR_UPDATE_MATERIAL                     4
 #define PR_UPDATE_DATABASE                     8
 
-#define START_RESOLUTION_DIVIDER       8
-
 typedef struct RenderPreview {
        /* from wmJob */
        void *owner;
@@ -1032,6 +1030,7 @@ typedef struct RenderPreview {
        
        float viewmat[4][4];
 
+       int start_resolution_divider;
        int resolution_divider;
 } RenderPreview;
 
@@ -1193,7 +1192,7 @@ static void render_view3d_startjob(void *customdata, short *stop, short *do_upda
        rstats = RE_GetStats(re);
 
        if (update_flag & PR_UPDATE_VIEW) {
-               rp->resolution_divider = START_RESOLUTION_DIVIDER;
+               rp->resolution_divider = rp->start_resolution_divider;
        }
 
        use_border = render_view3d_disprect(rp->scene, rp->ar, rp->v3d,
@@ -1388,7 +1387,12 @@ static void render_view3d_do(RenderEngine *engine, const bContext *C)
        wmJob *wm_job;
        RenderPreview *rp;
        Scene *scene = CTX_data_scene(C);
-       
+       ARegion *ar = CTX_wm_region(C);
+       int width = ar->winx, height = ar->winy;
+       int divider = 1;
+       int resolution_threshold = scene->r.preview_start_resolution *
+                                  scene->r.preview_start_resolution;
+
        if (CTX_wm_window(C) == NULL)
                return;
        if (!render_view3d_flag_changed(engine, C))
@@ -1399,6 +1403,12 @@ static void render_view3d_do(RenderEngine *engine, const bContext *C)
        rp = MEM_callocN(sizeof(RenderPreview), "render preview");
        rp->job = wm_job;
 
+       while (width * height > resolution_threshold) {
+               width = max_ii(1, width / 2);
+               height = max_ii(1, height / 2);
+               divider *= 2;
+       }
+
        /* customdata for preview thread */
        rp->scene = scene;
        rp->engine = engine;
@@ -1407,7 +1417,8 @@ static void render_view3d_do(RenderEngine *engine, const bContext *C)
        rp->v3d = rp->sa->spacedata.first;
        rp->rv3d = CTX_wm_region_view3d(C);
        rp->bmain = CTX_data_main(C);
-       rp->resolution_divider = START_RESOLUTION_DIVIDER;
+       rp->resolution_divider = divider;
+       rp->start_resolution_divider = divider;
        copy_m4_m4(rp->viewmat, rp->rv3d->viewmat);
        
        /* clear info text */
index 6b1cad120a76022293ddf016c9b110780e70d0b8..6cf2b3383082fc210671f9a0c53a19fa7158a7d1 100644 (file)
@@ -604,6 +604,9 @@ typedef struct RenderData {
 
        /* Cycles baking */
        struct BakeData bake;
+
+       int preview_start_resolution;
+       int pad;
 } RenderData;
 
 /* *************************************************************** */
index bce7d0062f2b8e4456ceb503181953c79ca4c91b..13349446168138a9bf1aa8987198b890421d2ab0 100644 (file)
@@ -4436,7 +4436,15 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
        RNA_def_property_range(prop, 8, 65536);
        RNA_def_property_ui_text(prop, "Tile Y", "Vertical tile size to use while rendering");
        RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-       
+
+       prop = RNA_def_property(srna, "preview_start_resolution", PROP_INT, PROP_NONE);
+       RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+       RNA_def_property_range(prop, 8, 16384);
+       RNA_def_property_int_default(prop, 64);
+       RNA_def_property_ui_text(prop, "Start Resolution", "Resolution to start rendering preview at, "
+                                                          "progressively increasing it to the full viewport size");
+       RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
+
        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);