[Bf-blender-cvs] [31608aab544] temp-lineart-contained: LineArt: Adjustable overscan.
YimingWu
noreply at git.blender.org
Mon Jun 7 15:04:14 CEST 2021
Commit: 31608aab544a2811427d3389eef0efedba5ddf73
Author: YimingWu
Date: Mon Jun 7 21:03:58 2021 +0800
Branches: temp-lineart-contained
https://developer.blender.org/rB31608aab544a2811427d3389eef0efedba5ddf73
LineArt: Adjustable overscan.
===================================================================
M source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
M source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
M source/blender/makesdna/DNA_gpencil_modifier_defaults.h
M source/blender/makesdna/DNA_gpencil_modifier_types.h
M source/blender/makesrna/intern/rna_gpencil_modifier.c
===================================================================
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
index 7142c0ceb4d..7b36fcd18c0 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
@@ -370,6 +370,8 @@ static void options_panel_draw(const bContext *UNUSED(C), Panel *panel)
uiLayoutSetPropSep(subrow, true);
uiItemR(subrow, ptr, "source_camera", 0, "", ICON_OBJECT_DATA);
+ uiItemR(layout, ptr, "overscan", 0, NULL, ICON_NONE);
+
uiItemR(layout, ptr, "use_remove_doubles", 0, NULL, ICON_NONE);
uiItemR(layout, ptr, "use_edge_overlap", 0, IFACE_("Overlapping Edges As Contour"), ICON_NONE);
uiItemR(layout, ptr, "use_object_instances", 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 7dae1ac4b6f..56e22a1b308 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
+++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
@@ -230,6 +230,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 08a28bf5dff..efd080b3f08 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
@@ -2042,7 +2042,7 @@ static void lineart_main_load_geometries(
if (fit == CAMERA_SENSOR_FIT_HOR && asp < 1) {
sensor /= asp;
}
- double fov = focallength_to_fov(cam->lens, sensor);
+ 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) {
@@ -3014,6 +3014,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->chaining_image_threshold = lmd->chaining_image_threshold;
rb->angle_splitting_threshold = lmd->angle_splitting_threshold;
diff --git a/source/blender/makesdna/DNA_gpencil_modifier_defaults.h b/source/blender/makesdna/DNA_gpencil_modifier_defaults.h
index 5b8f1b6fa5e..52a5df3b49a 100644
--- a/source/blender/makesdna/DNA_gpencil_modifier_defaults.h
+++ b/source/blender/makesdna/DNA_gpencil_modifier_defaults.h
@@ -299,6 +299,7 @@
.chaining_image_threshold = 0.001f, \
.stroke_offset = 0.05,\
.chain_smooth_tolerance = 0.0f,\
+ .overscan = 0.1f,\
}
#define _DNA_DEFAULT_LengthGpencilModifierData \
diff --git a/source/blender/makesdna/DNA_gpencil_modifier_types.h b/source/blender/makesdna/DNA_gpencil_modifier_types.h
index a5f683be6ad..87e4e07b1d9 100644
--- a/source/blender/makesdna/DNA_gpencil_modifier_types.h
+++ b/source/blender/makesdna/DNA_gpencil_modifier_types.h
@@ -919,6 +919,12 @@ typedef struct LineartGpencilModifierData {
char source_vertex_group[64];
char vgname[64];
+ /* Camera focal length is divided by (1 + overscan), before caluclation, which give a wider FOV,
+ * this doesn't change coordinates range internally (-1, 1), but makes the caluclated frame
+ * bigger than actual output. This is for the easier shifting calculation. A value of 0.5 means
+ * the "internal" focal length become 2/3 of the actual camera. */
+ float overscan;
+
float opacity;
short thickness;
@@ -926,7 +932,7 @@ typedef struct LineartGpencilModifierData {
unsigned char transparency_mask;
unsigned char intersection_mask;
- char _pad[7];
+ char _pad[3];
/** `0..1` range for cosine angle */
float crease_threshold;
diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c
index d3320b4eb59..f2f1469c511 100644
--- a/source/blender/makesrna/intern/rna_gpencil_modifier.c
+++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c
@@ -2972,6 +2972,15 @@ static void rna_def_modifier_gpencillineart(BlenderRNA *brna)
"Use cached line art result instead of run line art once again.");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+ prop = RNA_def_property(srna, "overscan", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_ui_text(
+ prop,
+ "Overscan",
+ "A margin to prevent strokes from ending abruptly at the edge of the image");
+ RNA_def_property_ui_range(prop, 0.0f, 0.5f, 0.01f, 3);
+ RNA_def_property_range(prop, 0.0f, 0.5f);
+ RNA_def_property_update(prop, NC_SCENE, "rna_GpencilModifier_update");
+
prop = RNA_def_property(srna, "thickness", PROP_INT, PROP_NONE);
RNA_def_property_ui_text(prop, "Thickness", "The thickness for the generated strokes");
RNA_def_property_ui_range(prop, 1, 100, 1, 1);
More information about the Bf-blender-cvs
mailing list