Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYimingWu <xp8110@outlook.com>2021-07-28 14:55:29 +0300
committerYimingWu <xp8110@outlook.com>2021-07-28 14:55:29 +0300
commit8e9d06f5a0425255ce526e9c1aa7f852165749f0 (patch)
tree63810f0ac5e66ef5a1cb1be53035a6333a982b89 /source/blender/gpencil_modifiers
parent544ddcdaac20bab7707a49edbd31b8ae38446603 (diff)
LineArt: Camera Overscan
Expand camera effective region to a portion beyond image frame so strokes won't end right at the border. Reviewed By: Antonio Vazquez (antoniov) Differential Revision: https://developer.blender.org/D12049
Diffstat (limited to 'source/blender/gpencil_modifiers')
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c2
-rw-r--r--source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h2
-rw-r--r--source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c29
3 files changed, 24 insertions, 9 deletions
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
index 8228915c6a8..ac458041ca3 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
@@ -380,6 +380,8 @@ static void options_panel_draw(const bContext *UNUSED(C), Panel *panel)
return;
}
+ uiItemR(layout, ptr, "overscan", 0, NULL, ICON_NONE);
+
uiLayout *col = uiLayoutColumn(layout, true);
uiItemR(col, ptr, "use_remove_doubles", 0, NULL, ICON_NONE);
diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
index 3730dba8e70..8eed2e705e8 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
+++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
@@ -228,6 +228,8 @@ typedef struct LineartRenderBuffer {
double view_projection[4][4];
double view[4][4];
+ float overscan;
+
struct LineartBoundingArea *initial_bounding_areas;
unsigned int bounding_area_count;
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
index a97d79a886e..3a6d6a8f32f 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
@@ -2013,7 +2013,10 @@ static void lineart_geometry_load_assign_thread(LineartObjectLoadTaskInfo *olti_
use_olti->pending = obi;
}
-static bool lineart_geometry_check_visible(double (*model_view_proj)[4], Object *use_ob)
+static bool lineart_geometry_check_visible(double (*model_view_proj)[4],
+ double shift_x,
+ double shift_y,
+ Object *use_ob)
{
BoundBox *bb = BKE_object_boundbox_get(use_ob);
if (!bb) {
@@ -2027,6 +2030,8 @@ static bool lineart_geometry_check_visible(double (*model_view_proj)[4], Object
copy_v3db_v3fl(co[i], bb->vec[i]);
copy_v3_v3_db(tmp, co[i]);
mul_v4_m4v3_db(co[i], model_view_proj, tmp);
+ co[i][0] -= shift_x * 2 * co[i][3];
+ co[i][1] -= shift_y * 2 * co[i][3];
}
bool cond[6] = {true, true, true, true, true, true};
@@ -2062,11 +2067,6 @@ static void lineart_main_load_geometries(
int fit = BKE_camera_sensor_fit(cam->sensor_fit, rb->w, rb->h);
double asp = ((double)rb->w / (double)rb->h);
- double t_start;
-
- if (G.debug_value == 4000) {
- t_start = PIL_check_seconds_timer();
- }
int bound_box_discard_count = 0;
if (cam->type == CAM_PERSP) {
@@ -2076,14 +2076,20 @@ static void lineart_main_load_geometries(
if (fit == CAMERA_SENSOR_FIT_HOR && asp < 1) {
sensor /= asp;
}
- double fov = focallength_to_fov(cam->lens, sensor);
+ const double fov = focallength_to_fov(cam->lens / (1 + rb->overscan), sensor);
lineart_matrix_perspective_44d(proj, fov, asp, cam->clip_start, cam->clip_end);
}
else if (cam->type == CAM_ORTHO) {
- double w = cam->ortho_scale / 2;
+ const double w = cam->ortho_scale / 2;
lineart_matrix_ortho_44d(proj, -w, w, -w / asp, w / asp, cam->clip_start, cam->clip_end);
}
+ double t_start;
+
+ if (G.debug_value == 4000) {
+ t_start = PIL_check_seconds_timer();
+ }
+
invert_m4_m4(inv, rb->cam_obmat);
mul_m4db_m4db_m4fl_uniq(result, proj, inv);
copy_m4_m4_db(proj, result);
@@ -2130,7 +2136,7 @@ static void lineart_main_load_geometries(
continue;
}
- if (!lineart_geometry_check_visible(obi->model_view_proj, use_ob)) {
+ if (!lineart_geometry_check_visible(obi->model_view_proj, rb->shift_x, rb->shift_y, use_ob)) {
if (G.debug_value == 4000) {
bound_box_discard_count++;
}
@@ -3023,6 +3029,11 @@ static LineartRenderBuffer *lineart_create_render_buffer(Scene *scene,
rb->shift_x = fit == CAMERA_SENSOR_FIT_HOR ? c->shiftx : c->shiftx / asp;
rb->shift_y = fit == CAMERA_SENSOR_FIT_VERT ? c->shifty : c->shifty * asp;
+ rb->overscan = lmd->overscan;
+
+ rb->shift_x /= (1 + rb->overscan);
+ rb->shift_y /= (1 + rb->overscan);
+
rb->crease_threshold = cos(M_PI - lmd->crease_threshold);
rb->angle_splitting_threshold = lmd->angle_splitting_threshold;
rb->chaining_image_threshold = lmd->chaining_image_threshold;