diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h index 03ba7cf0e4a..8c75a57ff66 100644 --- a/source/blender/blenkernel/BKE_blender_version.h +++ b/source/blender/blenkernel/BKE_blender_version.h @@ -29,7 +29,7 @@ extern "C" { /* Blender file format version. */ #define BLENDER_FILE_VERSION BLENDER_VERSION -#define BLENDER_FILE_SUBVERSION 0 +#define BLENDER_FILE_SUBVERSION 1 /* Minimum Blender version that supports reading file written with the current * version. Older Blender versions will test this and cancel loading the file, showing a warning to diff --git a/source/blender/blenkernel/intern/grease_pencil_convert_legacy.cc b/source/blender/blenkernel/intern/grease_pencil_convert_legacy.cc index 5c196b7065b..681a6ac1f94 100644 --- a/source/blender/blenkernel/intern/grease_pencil_convert_legacy.cc +++ b/source/blender/blenkernel/intern/grease_pencil_convert_legacy.cc @@ -129,8 +129,14 @@ void legacy_gpencil_frame_to_grease_pencil_drawing(const bGPDframe &gpf, /* Do first point. */ const bGPDspoint &first_pt = stroke_points.first(); stroke_positions.first() = float3(first_pt.x, first_pt.y, first_pt.z); - /* Store the actual radius of the stroke (without layer adjustment). */ - stroke_radii.first() = gps->thickness * first_pt.pressure; + /* Previously, Grease Pencil used a radius convention where 1 "px" = 0.001 units. This "px" was + * the brush size which would be stored in the stroke thickness and then scaled by the point + * pressure factor. Finally, the render engine would divide this thickness value by 2000 (we're + * going from a thickness to a radius, hence the factor of two) to convert back into blender + * units. + * Store the radius now directly in blender units. This makes it consistent with how hair + * curves handle the radius. */ + stroke_radii.first() = gps->thickness * first_pt.pressure / 2000.0f; stroke_opacities.first() = first_pt.strength; stroke_deltatimes.first() = 0; stroke_rotations.first() = first_pt.uv_rot; @@ -143,8 +149,7 @@ void legacy_gpencil_frame_to_grease_pencil_drawing(const bGPDframe &gpf, const bGPDspoint &pt_prev = stroke_points[point_i - 1]; const bGPDspoint &pt = stroke_points[point_i]; stroke_positions[point_i] = float3(pt.x, pt.y, pt.z); - /* Store the actual radius of the stroke (without layer adjustment). */ - stroke_radii[point_i] = gps->thickness * pt.pressure; + stroke_radii[point_i] = gps->thickness * pt.pressure / 2000.0f; stroke_opacities[point_i] = pt.strength; stroke_deltatimes[point_i] = pt.time - pt_prev.time; stroke_rotations[point_i] = pt.uv_rot; diff --git a/source/blender/blenloader/intern/versioning_400.cc b/source/blender/blenloader/intern/versioning_400.cc index 7662f2ab4bf..e0b0037078b 100644 --- a/source/blender/blenloader/intern/versioning_400.cc +++ b/source/blender/blenloader/intern/versioning_400.cc @@ -1059,6 +1059,30 @@ static void enable_geometry_nodes_is_modifier(Main &bmain) } } +static void versioning_grease_pencil_stroke_radii_scaling(GreasePencil *grease_pencil) +{ + using namespace blender; + /* Previously, Grease Pencil used a radius convention where 1 "px" = 0.001 units. This "px" was + * the brush size which would be stored in the stroke thickness and then scaled by the point + * pressure factor. Finally, the render engine would divide this thickness value by 2000 (we're + * going from a thickness to a radius, hence the factor of two) to convert back into blender + * units. + * Store the radius now directly in blender units. This makes it consistent with how hair curves + * handle the radius. */ + for (GreasePencilDrawingBase *base : grease_pencil->drawings()) { + if (base->type != GP_DRAWING) { + continue; + } + bke::greasepencil::Drawing &drawing = reinterpret_cast(base)->wrap(); + MutableSpan radii = drawing.radii_for_write(); + threading::parallel_for(radii.index_range(), 8192, [&](const IndexRange range) { + for (const int i : range) { + radii[i] /= 2000.0f; + } + }); + } +} + void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain) { if (!MAIN_VERSION_FILE_ATLEAST(bmain, 400, 1)) { @@ -1686,6 +1710,12 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain) } } + if (!MAIN_VERSION_FILE_ATLEAST(bmain, 401, 1)) { + LISTBASE_FOREACH (GreasePencil *, grease_pencil, &bmain->grease_pencils) { + versioning_grease_pencil_stroke_radii_scaling(grease_pencil); + } + } + /** * Versioning code until next subversion bump goes here. * diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index 6ea1a0aadc3..1a75b4d16ae 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -685,6 +685,7 @@ set(GLSL_SRC intern/draw_shader_shared.h engines/gpencil/shaders/gpencil_frag.glsl + engines/gpencil/shaders/grease_pencil_frag.glsl engines/gpencil/shaders/gpencil_vert.glsl engines/gpencil/shaders/grease_pencil_vert.glsl engines/gpencil/shaders/gpencil_antialiasing_frag.glsl diff --git a/source/blender/draw/engines/gpencil/shaders/grease_pencil_frag.glsl b/source/blender/draw/engines/gpencil/shaders/grease_pencil_frag.glsl new file mode 100644 index 00000000000..da955bc342a --- /dev/null +++ b/source/blender/draw/engines/gpencil/shaders/grease_pencil_frag.glsl @@ -0,0 +1,142 @@ +/* SPDX-FileCopyrightText: 2020-2023 Blender Authors + * + * SPDX-License-Identifier: GPL-2.0-or-later */ + +#pragma BLENDER_REQUIRE(common_grease_pencil_lib.glsl) +#pragma BLENDER_REQUIRE(common_colormanagement_lib.glsl) + +float length_squared(vec2 v) +{ + return dot(v, v); +} +float length_squared(vec3 v) +{ + return dot(v, v); +} + +vec3 gpencil_lighting(void) +{ + vec3 light_accum = vec3(0.0); + for (int i = 0; i < GPENCIL_LIGHT_BUFFER_LEN; i++) { + if (gp_lights[i]._color.x == -1.0) { + break; + } + vec3 L = gp_lights[i]._position - gp_interp.pos; + float vis = 1.0; + gpLightType type = floatBitsToUint(gp_lights[i]._type); + /* Spot Attenuation. */ + if (type == GP_LIGHT_TYPE_SPOT) { + mat3 rot_scale = mat3(gp_lights[i]._right, gp_lights[i]._up, gp_lights[i]._forward); + vec3 local_L = rot_scale * L; + local_L /= abs(local_L.z); + float ellipse = inversesqrt(length_squared(local_L)); + vis *= smoothstep(0.0, 1.0, (ellipse - gp_lights[i]._spot_size) / gp_lights[i]._spot_blend); + /* Also mask +Z cone. */ + vis *= step(0.0, local_L.z); + } + /* Inverse square decay. Skip for suns. */ + float L_len_sqr = length_squared(L); + if (type < GP_LIGHT_TYPE_SUN) { + vis /= L_len_sqr; + } + else { + L = gp_lights[i]._forward; + L_len_sqr = 1.0; + } + /* Lambertian falloff */ + if (type != GP_LIGHT_TYPE_AMBIENT) { + L /= sqrt(L_len_sqr); + vis *= clamp(dot(gpNormal, L), 0.0, 1.0); + } + light_accum += vis * gp_lights[i]._color; + } + /* Clamp to avoid NaNs. */ + return clamp(light_accum, 0.0, 1e10); +} + +void main() +{ + vec4 col; + if (flag_test(gp_interp_flat.mat_flag, GP_STROKE_TEXTURE_USE)) { + bool premul = flag_test(gp_interp_flat.mat_flag, GP_STROKE_TEXTURE_PREMUL); + col = texture_read_as_linearrgb(gpStrokeTexture, premul, gp_interp.uv); + } + else if (flag_test(gp_interp_flat.mat_flag, GP_FILL_TEXTURE_USE)) { + bool use_clip = flag_test(gp_interp_flat.mat_flag, GP_FILL_TEXTURE_CLIP); + vec2 uvs = (use_clip) ? clamp(gp_interp.uv, 0.0, 1.0) : gp_interp.uv; + bool premul = flag_test(gp_interp_flat.mat_flag, GP_FILL_TEXTURE_PREMUL); + col = texture_read_as_linearrgb(gpFillTexture, premul, uvs); + } + else if (flag_test(gp_interp_flat.mat_flag, GP_FILL_GRADIENT_USE)) { + bool radial = flag_test(gp_interp_flat.mat_flag, GP_FILL_GRADIENT_RADIAL); + float fac = clamp(radial ? length(gp_interp.uv * 2.0 - 1.0) : gp_interp.uv.x, 0.0, 1.0); + uint matid = gp_interp_flat.mat_flag >> GPENCIl_MATID_SHIFT; + col = mix(gp_materials[matid].fill_color, gp_materials[matid].fill_mix_color, fac); + } + else /* SOLID */ { + col = vec4(1.0); + } + col.rgb *= col.a; + + /* Composite all other colors on top of texture color. + * Everything is pre-multiply by `col.a` to have the stencil effect. */ + fragColor = col * gp_interp.color_mul + col.a * gp_interp.color_add; + + fragColor.rgb *= gpencil_lighting(); + + fragColor *= gpencil_stroke_round_cap_mask(gp_interp_flat.sspos.xy, + gp_interp_flat.sspos.zw, + gp_interp_flat.aspect, + gp_interp_noperspective.thickness.x, + gp_interp_noperspective.hardness); + + /* To avoid aliasing artifacts, we reduce the opacity of small strokes. */ + fragColor *= smoothstep(0.0, 1.0, gp_interp_noperspective.thickness.y); + + /* Holdout materials. */ + if (flag_test(gp_interp_flat.mat_flag, GP_STROKE_HOLDOUT | GP_FILL_HOLDOUT)) { + revealColor = fragColor.aaaa; + } + else { + /* NOT holdout materials. + * For compatibility with colored alpha buffer. + * Note that we are limited to mono-chromatic alpha blending here + * because of the blend equation and the limit of 1 color target + * when using custom color blending. */ + revealColor = vec4(0.0, 0.0, 0.0, fragColor.a); + + if (fragColor.a < 0.001) { + discard; + return; + } + } + + vec2 fb_size = max(vec2(textureSize(gpSceneDepthTexture, 0).xy), + vec2(textureSize(gpMaskTexture, 0).xy)); + vec2 uvs = gl_FragCoord.xy / fb_size; + /* Manual depth test */ + float scene_depth = texture(gpSceneDepthTexture, uvs).r; + if (gl_FragCoord.z > scene_depth) { + discard; + return; + } + + /* FIXME(fclem): Grrr. This is bad for performance but it's the easiest way to not get + * depth written where the mask obliterate the layer. */ + float mask = texture(gpMaskTexture, uvs).r; + if (mask < 0.001) { + discard; + return; + } + + /* We override the fragment depth using the fragment shader to ensure a constant value. + * This has a cost as the depth test cannot happen early. + * We could do this in the vertex shader but then perspective interpolation of uvs and + * fragment clipping gets really complicated. */ + if (gp_interp_flat.depth >= 0.0) { + gl_FragDepth = gp_interp_flat.depth; + } + else { + gl_FragDepth = gl_FragCoord.z; + } +} diff --git a/source/blender/draw/engines/gpencil/shaders/infos/gpencil_info.hh b/source/blender/draw/engines/gpencil/shaders/infos/gpencil_info.hh index 1cd9bf4ae8e..2dd15c30fb0 100644 --- a/source/blender/draw/engines/gpencil/shaders/infos/gpencil_info.hh +++ b/source/blender/draw/engines/gpencil/shaders/infos/gpencil_info.hh @@ -85,7 +85,7 @@ GPU_SHADER_CREATE_INFO(gpencil_geometry_next) .vertex_out(gpencil_geometry_flat_iface) .vertex_out(gpencil_geometry_noperspective_iface) .vertex_source("grease_pencil_vert.glsl") - .fragment_source("gpencil_frag.glsl") + .fragment_source("grease_pencil_frag.glsl") .additional_info("draw_gpencil_new") .depth_write(DepthWrite::ANY); diff --git a/source/blender/draw/intern/shaders/common_grease_pencil_lib.glsl b/source/blender/draw/intern/shaders/common_grease_pencil_lib.glsl index ab7cf94bffa..937cbb706c1 100644 --- a/source/blender/draw/intern/shaders/common_grease_pencil_lib.glsl +++ b/source/blender/draw/intern/shaders/common_grease_pencil_lib.glsl @@ -66,18 +66,8 @@ vec2 gpencil_project_to_screenspace(vec4 v, vec4 viewport_size) float gpencil_stroke_thickness_modulate(float thickness, vec4 ndc_pos, vec4 viewport_size) { - /* Modify stroke thickness by object and layer factors. */ - thickness = max(1.0, thickness * gpThicknessScale + gpThicknessOffset); - - if (gpThicknessIsScreenSpace) { - /* Multiply offset by view Z so that offset is constant in screen-space. - * (e.i: does not change with the distance to camera) */ - thickness *= ndc_pos.w; - } - else { - /* World space point size. */ - thickness *= gpThicknessWorldScale * ProjectionMatrix[1][1] * viewport_size.y; - } + /* World space point size. */ + thickness *= gpThicknessScale * ProjectionMatrix[1][1] * viewport_size.y; return thickness; } @@ -85,7 +75,7 @@ float gpencil_clamp_small_stroke_thickness(float thickness, vec4 ndc_pos) { /* To avoid aliasing artifacts, we clamp the line thickness and * reduce its opacity in the fragment shader. */ - float min_thickness = ndc_pos.w * 1.3; + float min_thickness = ndc_pos.w * 0.00065; thickness = max(min_thickness, thickness); return thickness; diff --git a/source/blender/draw/intern/shaders/draw_view_info.hh b/source/blender/draw/intern/shaders/draw_view_info.hh index 10842f06e66..526ad91c2a8 100644 --- a/source/blender/draw/intern/shaders/draw_view_info.hh +++ b/source/blender/draw/intern/shaders/draw_view_info.hh @@ -172,10 +172,7 @@ GPU_SHADER_CREATE_INFO(draw_gpencil_new) .sampler(1, ImageType::FLOAT_BUFFER, "gp_col_tx") /* Per Object */ .define("gpThicknessScale", "1.0") /* TODO(fclem): Replace with object info. */ - .define("gpThicknessWorldScale", "1.0 / 2000.0") /* TODO(fclem): Same as above. */ - .define("gpThicknessIsScreenSpace", "(gpThicknessWorldScale < 0.0)") /* Per Layer */ - .define("gpThicknessOffset", "0.0") /* TODO(fclem): Remove. */ .additional_info("draw_modelmat_new", "draw_resource_id_varying", "draw_view", diff --git a/source/blender/editors/grease_pencil/intern/grease_pencil_add.cc b/source/blender/editors/grease_pencil/intern/grease_pencil_add.cc index 109046ad3d3..6b57c720fe2 100644 --- a/source/blender/editors/grease_pencil/intern/grease_pencil_add.cc +++ b/source/blender/editors/grease_pencil/intern/grease_pencil_add.cc @@ -7,6 +7,7 @@ */ #include +#include #include "BKE_curves.hh" #include "BKE_grease_pencil.hh" @@ -189,21 +190,24 @@ static std::array stroke_positions({ }); static constexpr std::array stroke_radii({ - 0.038f, 0.069f, 0.089f, 0.112f, 0.134f, 0.155f, 0.175f, 0.194f, 0.211f, 0.227f, 0.242f, 0.256f, - 0.268f, 0.28f, 0.29f, 0.299f, 0.307f, 0.315f, 0.322f, 0.329f, 0.335f, 0.341f, 0.346f, 0.351f, - 0.355f, 0.36f, 0.364f, 0.368f, 0.371f, 0.373f, 0.376f, 0.377f, 0.378f, 0.379f, 0.379f, 0.379f, - 0.38f, 0.38f, 0.381f, 0.382f, 0.384f, 0.386f, 0.388f, 0.39f, 0.393f, 0.396f, 0.399f, 0.403f, - 0.407f, 0.411f, 0.415f, 0.42f, 0.425f, 0.431f, 0.437f, 0.443f, 0.45f, 0.457f, 0.464f, 0.471f, - 0.479f, 0.487f, 0.495f, 0.503f, 0.512f, 0.52f, 0.528f, 0.537f, 0.545f, 0.553f, 0.562f, 0.57f, - 0.579f, 0.588f, 0.597f, 0.606f, 0.615f, 0.625f, 0.635f, 0.644f, 0.654f, 0.664f, 0.675f, 0.685f, - 0.696f, 0.707f, 0.718f, 0.729f, 0.74f, 0.751f, 0.761f, 0.772f, 0.782f, 0.793f, 0.804f, 0.815f, - 0.828f, 0.843f, 0.86f, 0.879f, 0.897f, 0.915f, 0.932f, 0.947f, 0.962f, 0.974f, 0.985f, 0.995f, - 1.004f, 1.011f, 1.018f, 1.024f, 1.029f, 1.033f, 1.036f, 1.037f, 1.037f, 1.035f, 1.032f, 1.029f, - 1.026f, 1.023f, 1.021f, 1.019f, 1.017f, 1.016f, 1.016f, 1.016f, 1.016f, 1.017f, 1.017f, 1.018f, - 1.017f, 1.017f, 1.016f, 1.015f, 1.013f, 1.009f, 1.005f, 0.998f, 0.99f, 0.98f, 0.968f, 0.955f, - 0.939f, 0.923f, 0.908f, 0.895f, 0.882f, 0.87f, 0.858f, 0.844f, 0.828f, 0.81f, 0.79f, 0.769f, - 0.747f, 0.724f, 0.7f, 0.676f, 0.651f, 0.625f, 0.599f, 0.573f, 0.546f, 0.516f, 0.483f, 0.446f, - 0.407f, 0.365f, 0.322f, 0.28f, 0.236f, 0.202f, 0.155f, + 0.00143, 0.00259, 0.00334, 0.00420, 0.00503, 0.00581, 0.00656, 0.00728, 0.00791, 0.00851, + 0.00907, 0.00960, 0.01005, 0.01050, 0.01087, 0.01121, 0.01151, 0.01181, 0.01208, 0.01234, + 0.01256, 0.01279, 0.01297, 0.01316, 0.01331, 0.01350, 0.01365, 0.01380, 0.01391, 0.01399, + 0.01410, 0.01414, 0.01418, 0.01421, 0.01421, 0.01421, 0.01425, 0.01425, 0.01429, 0.01433, + 0.01440, 0.01448, 0.01455, 0.01462, 0.01474, 0.01485, 0.01496, 0.01511, 0.01526, 0.01541, + 0.01556, 0.01575, 0.01594, 0.01616, 0.01639, 0.01661, 0.01688, 0.01714, 0.01740, 0.01766, + 0.01796, 0.01826, 0.01856, 0.01886, 0.01920, 0.01950, 0.01980, 0.02014, 0.02044, 0.02074, + 0.02107, 0.02138, 0.02171, 0.02205, 0.02239, 0.02273, 0.02306, 0.02344, 0.02381, 0.02415, + 0.02452, 0.02490, 0.02531, 0.02569, 0.02610, 0.02651, 0.02693, 0.02734, 0.02775, 0.02816, + 0.02854, 0.02895, 0.02933, 0.02974, 0.03015, 0.03056, 0.03105, 0.03161, 0.03225, 0.03296, + 0.03364, 0.03431, 0.03495, 0.03551, 0.03608, 0.03652, 0.03694, 0.03731, 0.03765, 0.03791, + 0.03818, 0.03840, 0.03859, 0.03874, 0.03885, 0.03889, 0.03889, 0.03881, 0.03870, 0.03859, + 0.03848, 0.03836, 0.03829, 0.03821, 0.03814, 0.03810, 0.03810, 0.03810, 0.03810, 0.03814, + 0.03814, 0.03818, 0.03814, 0.03814, 0.03810, 0.03806, 0.03799, 0.03784, 0.03769, 0.03743, + 0.03713, 0.03675, 0.03630, 0.03581, 0.03521, 0.03461, 0.03405, 0.03356, 0.03308, 0.03263, + 0.03218, 0.03165, 0.03105, 0.03038, 0.02963, 0.02884, 0.02801, 0.02715, 0.02625, 0.02535, + 0.02441, 0.02344, 0.02246, 0.02149, 0.02048, 0.01935, 0.01811, 0.01673, 0.01526, 0.01369, + 0.01208, 0.01050, 0.00885, 0.00758, 0.00581, }); static constexpr std::array stroke_opacities({ @@ -636,65 +640,76 @@ static constexpr std::array monkey_fill_opacities({ }); static constexpr std::array monkey_fill_radii({ - 0.2670, 0.3100, 0.3800, 0.4330, 0.4710, 0.4960, 0.5110, 0.5210, 0.5270, 0.5310, 0.5340, 0.5350, - 0.5360, 0.5360, 0.5360, 0.5350, 0.5340, 0.5340, 0.5330, 0.5330, 0.5320, 0.5310, 0.5310, 0.5320, - 0.5350, 0.5400, 0.5420, 0.5430, 0.5430, 0.5460, 0.5490, 0.5490, 0.5490, 0.5490, 0.5510, 0.5530, - 0.5540, 0.5540, 0.5550, 0.5560, 0.5570, 0.5570, 0.5570, 0.5570, 0.5580, 0.5580, 0.5570, 0.5560, - 0.5540, 0.5520, 0.5510, 0.5500, 0.5490, 0.5490, 0.5490, 0.5500, 0.5520, 0.5560, 0.5630, 0.5720, - 0.5820, 0.5910, 0.5970, 0.6020, 0.6050, 0.6070, 0.6090, 0.6120, 0.6160, 0.6190, 0.6230, 0.6260, - 0.6300, 0.6370, 0.6460, 0.6540, 0.6590, 0.6640, 0.6670, 0.6710, 0.6740, 0.6770, 0.6780, 0.6800, - 0.6800, 0.6810, 0.6820, 0.6830, 0.6850, 0.6870, 0.6900, 0.6930, 0.6970, 0.7000, 0.7040, 0.7070, - 0.7090, 0.7110, 0.7120, 0.7140, 0.7150, 0.7150, 0.7160, 0.7170, 0.7180, 0.7180, 0.7180, 0.7190, - 0.7190, 0.7190, 0.7190, 0.7190, 0.7180, 0.7170, 0.7170, 0.7180, 0.7170, 0.7150, 0.7130, 0.7180, - 0.7320, 0.7530, 0.7740, 0.7910, 0.8020, 0.8090, 0.8120, 0.8140, 0.8140, 0.8120, 0.8100, 0.8060, - 0.8000, 0.7940, 0.7880, 0.7830, 0.7810, 0.7790, 0.7780, 0.7770, 0.7770, 0.7760, 0.7750, 0.7740, - 0.7740, 0.7730, 0.7720, 0.7710, 0.7700, 0.7680, 0.7670, 0.7660, 0.7650, 0.7640, 0.7610, 0.7560, - 0.7510, 0.7450, 0.7390, 0.7330, 0.7280, 0.7230, 0.7180, 0.7130, 0.7090, 0.7040, 0.7000, 0.6950, - 0.6910, 0.6860, 0.6810, 0.6760, 0.6710, 0.6660, 0.6630, 0.6610, 0.6600, 0.6590, 0.6580, 0.6580, - 0.6580, 0.6570, 0.6560, 0.6530, 0.6460, 0.6370, 0.6280, 0.6200, 0.6140, 0.6100, 0.6080, 0.6070, - 0.6060, 0.6050, 0.6030, 0.5980, 0.5910, 0.5830, 0.5740, 0.5640, 0.5550, 0.5470, 0.5410, 0.5360, - 0.5320, 0.5290, 0.5250, 0.5210, 0.5160, 0.5100, 0.5050, 0.4990, 0.4950, 0.4930, 0.4910, 0.4910, - 0.4910, 0.4920, 0.4920, 0.4920, 0.4930, 0.4930, 0.4930, 0.4920, 0.4910, 0.4910, 0.4900, 0.4900, - 0.4890, 0.4890, 0.4890, 0.4890, 0.4890, 0.4900, 0.4900, 0.4910, 0.4920, 0.4940, 0.4970, 0.5010, - 0.5050, 0.5100, 0.5150, 0.5200, 0.5250, 0.5300, 0.5350, 0.5390, 0.5420, 0.5460, 0.5480, 0.5500, - 0.5510, 0.5520, 0.5530, 0.5540, 0.5540, 0.5550, 0.5560, 0.5560, 0.5570, 0.5580, 0.5580, 0.5580, - 0.5590, 0.5590, 0.5590, 0.5580, 0.5580, 0.5550, 0.1000, 0.2199, 0.4615, 0.6019, 0.6981, 0.7689, - 0.8236, 0.8660, 0.9003, 0.9272, 0.9485, 0.9653, 0.9781, 0.9876, 0.9942, 0.9983, 0.9997, 0.9990, - 0.9963, 0.9912, 0.9834, 0.9724, 0.9576, 0.9385, 0.9143, 0.8841, 0.8461, 0.7979, 0.7359, 0.6541, - 0.5396, 0.3600, 0.1000, 0.1000, 0.2199, 0.6019, 0.7689, 0.8660, 0.9272, 0.9653, 0.9876, 0.9983, - 0.9990, 0.9912, 0.9724, 0.9385, 0.8841, 0.7979, 0.6541, 0.3600, 0.1000, 0.1000, 0.2199, 0.3600, - 0.4615, 0.5396, 0.6019, 0.6541, 0.6981, 0.7359, 0.7689, 0.7979, 0.8236, 0.8461, 0.8660, 0.8841, - 0.9003, 0.9143, 0.9272, 0.9385, 0.9485, 0.9576, 0.9653, 0.9724, 0.9781, 0.9834, 0.9876, 0.9912, - 0.9942, 0.9963, 0.9983, 0.9990, 0.9997, 0.9997, 0.9990, 0.9983, 0.9963, 0.9942, 0.9912, 0.9876, - 0.9834, 0.9781, 0.9724, 0.9653, 0.9576, 0.9485, 0.9385, 0.9272, 0.9143, 0.9003, 0.8841, 0.8660, - 0.8461, 0.8236, 0.7979, 0.7689, 0.7359, 0.6981, 0.6541, 0.6019, 0.5396, 0.4615, 0.3600, 0.2199, - 0.1000, 0.1000, 0.2199, 0.4615, 0.6019, 0.6981, 0.7689, 0.8236, 0.8660, 0.9003, 0.9272, 0.9485, - 0.9653, 0.9781, 0.9876, 0.9942, 0.9983, 0.9997, 0.9990, 0.9963, 0.9912, 0.9834, 0.9724, 0.9576, - 0.9385, 0.9143, 0.8841, 0.8461, 0.7979, 0.7359, 0.6541, 0.5396, 0.3600, 0.1000, 0.1000, 0.2199, - 0.3600, 0.4615, 0.5396, 0.6019, 0.6541, 0.6981, 0.7359, 0.7689, 0.7979, 0.8236, 0.8461, 0.8660, - 0.8841, 0.9003, 0.9143, 0.9272, 0.9385, 0.9485, 0.9576, 0.9653, 0.9724, 0.9781, 0.9834, 0.9876, - 0.9912, 0.9942, 0.9963, 0.9983, 0.9990, 0.9997, 0.9997, 0.9990, 0.9983, 0.9963, 0.9942, 0.9912, - 0.9876, 0.9834, 0.9781, 0.9724, 0.9653, 0.9576, 0.9485, 0.9385, 0.9272, 0.9143, 0.9003, 0.8841, - 0.8660, 0.8461, 0.8236, 0.7979, 0.7689, 0.7359, 0.6981, 0.6541, 0.6019, 0.5396, 0.4615, 0.3600, - 0.2199, 0.1000, 0.1000, 0.2199, 0.4615, 0.6019, 0.6981, 0.7689, 0.8236, 0.8660, 0.9003, 0.9272, - 0.9485, 0.9653, 0.9781, 0.9876, 0.9942, 0.9983, 0.9997, 0.9990, 0.9963, 0.9912, 0.9834, 0.9724, - 0.9576, 0.9385, 0.9143, 0.8841, 0.8461, 0.7979, 0.7359, 0.6541, 0.5396, 0.3600, 0.1000, 0.1000, - 0.2199, 0.6019, 0.7689, 0.8660, 0.9272, 0.9653, 0.9876, 0.9983, 0.9990, 0.9912, 0.9724, 0.9385, - 0.8841, 0.7979, 0.6541, 0.3600, 0.1000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, - 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, - 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, - 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, - 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 0.1000, 0.2199, 0.4615, 0.6019, 0.6981, 0.7689, - 0.8236, 0.8660, 0.9003, 0.9272, 0.9485, 0.9653, 0.9781, 0.9876, 0.9942, 0.9983, 0.9997, 0.9990, - 0.9963, 0.9912, 0.9834, 0.9724, 0.9576, 0.9385, 0.9143, 0.8841, 0.8461, 0.7979, 0.7359, 0.6541, - 0.5396, 0.3600, 0.1000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, - 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, - 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, - 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, - 1.0000, 1.0000, 1.0000, 1.0000, 0.1000, 0.2199, 0.6019, 0.7689, 0.8660, 0.9272, 0.9653, 0.9876, - 0.9983, 0.9990, 0.9912, 0.9724, 0.9385, 0.8841, 0.7979, 0.6541, 0.3600, 0.1000, 0.1000, 0.2199, - 0.6019, 0.7689, 0.8660, 0.9272, 0.9653, 0.9876, 0.9983, 0.9990, 0.9912, 0.9724, 0.9385, 0.8841, - 0.7979, 0.6541, 0.3600, 0.1000, + 0.01001, 0.01163, 0.01425, 0.01624, 0.01766, 0.01860, 0.01916, 0.01954, 0.01976, 0.01991, + 0.02002, 0.02006, 0.02010, 0.02010, 0.02010, 0.02006, 0.02002, 0.02002, 0.01999, 0.01999, + 0.01995, 0.01991, 0.01991, 0.01995, 0.02006, 0.02025, 0.02033, 0.02036, 0.02036, 0.02048, + 0.02059, 0.02059, 0.02059, 0.02059, 0.02066, 0.02074, 0.02078, 0.02078, 0.02081, 0.02085, + 0.02089, 0.02089, 0.02089, 0.02089, 0.02093, 0.02093, 0.02089, 0.02085, 0.02078, 0.02070, + 0.02066, 0.02063, 0.02059, 0.02059, 0.02059, 0.02063, 0.02070, 0.02085, 0.02111, 0.02145, + 0.02183, 0.02216, 0.02239, 0.02258, 0.02269, 0.02276, 0.02284, 0.02295, 0.02310, 0.02321, + 0.02336, 0.02348, 0.02363, 0.02389, 0.02423, 0.02452, 0.02471, 0.02490, 0.02501, 0.02516, + 0.02528, 0.02539, 0.02543, 0.02550, 0.02550, 0.02554, 0.02558, 0.02561, 0.02569, 0.02576, + 0.02588, 0.02599, 0.02614, 0.02625, 0.02640, 0.02651, 0.02659, 0.02666, 0.02670, 0.02678, + 0.02681, 0.02681, 0.02685, 0.02689, 0.02693, 0.02693, 0.02693, 0.02696, 0.02696, 0.02696, + 0.02696, 0.02696, 0.02693, 0.02689, 0.02689, 0.02693, 0.02689, 0.02681, 0.02674, 0.02693, + 0.02745, 0.02824, 0.02903, 0.02966, 0.03008, 0.03034, 0.03045, 0.03053, 0.03053, 0.03045, + 0.03038, 0.03023, 0.03000, 0.02978, 0.02955, 0.02936, 0.02929, 0.02921, 0.02918, 0.02914, + 0.02914, 0.02910, 0.02906, 0.02903, 0.02903, 0.02899, 0.02895, 0.02891, 0.02888, 0.02880, + 0.02876, 0.02873, 0.02869, 0.02865, 0.02854, 0.02835, 0.02816, 0.02794, 0.02771, 0.02749, + 0.02730, 0.02711, 0.02693, 0.02674, 0.02659, 0.02640, 0.02625, 0.02606, 0.02591, 0.02573, + 0.02554, 0.02535, 0.02516, 0.02498, 0.02486, 0.02479, 0.02475, 0.02471, 0.02468, 0.02468, + 0.02468, 0.02464, 0.02460, 0.02449, 0.02423, 0.02389, 0.02355, 0.02325, 0.02303, 0.02288, + 0.02280, 0.02276, 0.02273, 0.02269, 0.02261, 0.02242, 0.02216, 0.02186, 0.02153, 0.02115, + 0.02081, 0.02051, 0.02029, 0.02010, 0.01995, 0.01984, 0.01969, 0.01954, 0.01935, 0.01912, + 0.01894, 0.01871, 0.01856, 0.01849, 0.01841, 0.01841, 0.01841, 0.01845, 0.01845, 0.01845, + 0.01849, 0.01849, 0.01849, 0.01845, 0.01841, 0.01841, 0.01838, 0.01838, 0.01834, 0.01834, + 0.01834, 0.01834, 0.01834, 0.01838, 0.01838, 0.01841, 0.01845, 0.01853, 0.01864, 0.01879, + 0.01894, 0.01912, 0.01931, 0.01950, 0.01969, 0.01987, 0.02006, 0.02021, 0.02033, 0.02048, + 0.02055, 0.02063, 0.02066, 0.02070, 0.02074, 0.02078, 0.02078, 0.02081, 0.02085, 0.02085, + 0.02089, 0.02093, 0.02093, 0.02093, 0.02096, 0.02096, 0.02096, 0.02093, 0.02093, 0.02081, + 0.00300, 0.00660, 0.01384, 0.01806, 0.02094, 0.02307, 0.02471, 0.02598, 0.02701, 0.02782, + 0.02845, 0.02896, 0.02934, 0.02963, 0.02983, 0.02995, 0.02999, 0.02997, 0.02989, 0.02974, + 0.02950, 0.02917, 0.02873, 0.02815, 0.02743, 0.02652, 0.02538, 0.02394, 0.02208, 0.01962, + 0.01619, 0.01080, 0.00300, 0.00300, 0.00660, 0.01806, 0.02307, 0.02598, 0.02782, 0.02896, + 0.02963, 0.02995, 0.02997, 0.02974, 0.02917, 0.02815, 0.02652, 0.02394, 0.01962, 0.01080, + 0.00300, 0.00300, 0.00660, 0.01080, 0.01384, 0.01619, 0.01806, 0.01962, 0.02094, 0.02208, + 0.02307, 0.02394, 0.02471, 0.02538, 0.02598, 0.02652, 0.02701, 0.02743, 0.02782, 0.02815, + 0.02845, 0.02873, 0.02896, 0.02917, 0.02934, 0.02950, 0.02963, 0.02974, 0.02983, 0.02989, + 0.02995, 0.02997, 0.02999, 0.02999, 0.02997, 0.02995, 0.02989, 0.02983, 0.02974, 0.02963, + 0.02950, 0.02934, 0.02917, 0.02896, 0.02873, 0.02845, 0.02815, 0.02782, 0.02743, 0.02701, + 0.02652, 0.02598, 0.02538, 0.02471, 0.02394, 0.02307, 0.02208, 0.02094, 0.01962, 0.01806, + 0.01619, 0.01384, 0.01080, 0.00660, 0.00300, 0.00300, 0.00660, 0.01384, 0.01806, 0.02094, + 0.02307, 0.02471, 0.02598, 0.02701, 0.02782, 0.02845, 0.02896, 0.02934, 0.02963, 0.02983, + 0.02995, 0.02999, 0.02997, 0.02989, 0.02974, 0.02950, 0.02917, 0.02873, 0.02815, 0.02743, + 0.02652, 0.02538, 0.02394, 0.02208, 0.01962, 0.01619, 0.01080, 0.00300, 0.00300, 0.00660, + 0.01080, 0.01384, 0.01619, 0.01806, 0.01962, 0.02094, 0.02208, 0.02307, 0.02394, 0.02471, + 0.02538, 0.02598, 0.02652, 0.02701, 0.02743, 0.02782, 0.02815, 0.02845, 0.02873, 0.02896, + 0.02917, 0.02934, 0.02950, 0.02963, 0.02974, 0.02983, 0.02989, 0.02995, 0.02997, 0.02999, + 0.02999, 0.02997, 0.02995, 0.02989, 0.02983, 0.02974, 0.02963, 0.02950, 0.02934, 0.02917, + 0.02896, 0.02873, 0.02845, 0.02815, 0.02782, 0.02743, 0.02701, 0.02652, 0.02598, 0.02538, + 0.02471, 0.02394, 0.02307, 0.02208, 0.02094, 0.01962, 0.01806, 0.01619, 0.01384, 0.01080, + 0.00660, 0.00300, 0.00300, 0.00660, 0.01384, 0.01806, 0.02094, 0.02307, 0.02471, 0.02598, + 0.02701, 0.02782, 0.02845, 0.02896, 0.02934, 0.02963, 0.02983, 0.02995, 0.02999, 0.02997, + 0.02989, 0.02974, 0.02950, 0.02917, 0.02873, 0.02815, 0.02743, 0.02652, 0.02538, 0.02394, + 0.02208, 0.01962, 0.01619, 0.01080, 0.00300, 0.00200, 0.00440, 0.01204, 0.01538, 0.01732, + 0.01854, 0.01931, 0.01975, 0.01997, 0.01998, 0.01982, 0.01945, 0.01877, 0.01768, 0.01596, + 0.01308, 0.00720, 0.00200, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, + 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, + 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, + 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, + 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, + 0.03000, 0.03000, 0.00300, 0.00660, 0.01384, 0.01806, 0.02094, 0.02307, 0.02471, 0.02598, + 0.02701, 0.02782, 0.02845, 0.02896, 0.02934, 0.02963, 0.02983, 0.02995, 0.02999, 0.02997, + 0.02989, 0.02974, 0.02950, 0.02917, 0.02873, 0.02815, 0.02743, 0.02652, 0.02538, 0.02394, + 0.02208, 0.01962, 0.01619, 0.01080, 0.00300, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, + 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, + 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, + 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, + 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, + 0.03000, 0.03000, 0.03000, 0.03000, 0.00200, 0.00440, 0.01204, 0.01538, 0.01732, 0.01854, + 0.01931, 0.01975, 0.01997, 0.01998, 0.01982, 0.01945, 0.01877, 0.01768, 0.01596, 0.01308, + 0.00720, 0.00200, 0.00200, 0.00440, 0.01204, 0.01538, 0.01732, 0.01854, 0.01931, 0.01975, + 0.01997, 0.01998, 0.01982, 0.01945, 0.01877, 0.01768, 0.01596, 0.01308, 0.00720, 0.00200, }); static constexpr std::array monkey_fill_offsets({ @@ -1022,49 +1037,58 @@ static constexpr std::array monkey_line_opacities({ }); static constexpr std::array monkey_line_radii({ - 0.1000, 0.2199, 0.4615, 0.6019, 0.6981, 0.7689, 0.8236, 0.8660, 0.9003, 0.9272, 0.9485, 0.9653, - 0.9781, 0.9876, 0.9942, 0.9983, 0.9997, 0.9990, 0.9963, 0.9912, 0.9834, 0.9724, 0.9576, 0.9385, - 0.9143, 0.8841, 0.8461, 0.7979, 0.7359, 0.6541, 0.5396, 0.3600, 0.1000, 0.1000, 0.2199, 0.4615, - 0.6019, 0.6981, 0.7689, 0.8236, 0.8660, 0.9003, 0.9272, 0.9485, 0.9653, 0.9781, 0.9876, 0.9942, - 0.9983, 0.9997, 0.9990, 0.9963, 0.9912, 0.9834, 0.9724, 0.9576, 0.9385, 0.9143, 0.8841, 0.8461, - 0.7979, 0.7359, 0.6541, 0.5396, 0.3600, 0.1000, 0.1000, 0.1288, 0.2962, 0.4147, 0.5028, 0.5723, - 0.6291, 0.6768, 0.7177, 0.7530, 0.7838, 0.8109, 0.8349, 0.8564, 0.8756, 0.8922, 0.9074, 0.9211, - 0.9329, 0.9440, 0.9531, 0.9617, 0.9688, 0.9755, 0.9808, 0.9858, 0.9894, 0.9930, 0.9952, 0.9973, - 0.9987, 0.9993, 1.0000, 0.9993, 0.9987, 0.9973, 0.9952, 0.9930, 0.9894, 0.9858, 0.9808, 0.9755, - 0.9688, 0.9617, 0.9531, 0.9440, 0.9329, 0.9211, 0.9074, 0.8922, 0.8756, 0.8564, 0.8349, 0.8109, - 0.7838, 0.7530, 0.7177, 0.6768, 0.6291, 0.5723, 0.5028, 0.4147, 0.2962, 0.1288, 0.1000, 0.1000, - 0.1288, 0.4147, 0.5723, 0.6768, 0.7530, 0.8109, 0.8564, 0.8922, 0.9211, 0.9440, 0.9617, 0.9755, - 0.9858, 0.9930, 0.9973, 0.9993, 0.9993, 0.9973, 0.9930, 0.9858, 0.9755, 0.9617, 0.9440, 0.9211, - 0.8922, 0.8564, 0.8109, 0.7530, 0.6768, 0.5723, 0.4147, 0.1288, 0.1000, 0.1000, 0.2199, 0.4615, - 0.6019, 0.6981, 0.7689, 0.8236, 0.8660, 0.9003, 0.9272, 0.9485, 0.9653, 0.9781, 0.9876, 0.9942, - 0.9983, 0.9997, 0.9990, 0.9963, 0.9912, 0.9834, 0.9724, 0.9576, 0.9385, 0.9143, 0.8841, 0.8461, - 0.7979, 0.7359, 0.6541, 0.5396, 0.3600, 0.1000, 0.1000, 0.2199, 0.4615, 0.6019, 0.6981, 0.7689, - 0.8236, 0.8660, 0.9003, 0.9272, 0.9485, 0.9653, 0.9781, 0.9876, 0.9942, 0.9983, 0.9997, 0.9990, - 0.9963, 0.9912, 0.9834, 0.9724, 0.9576, 0.9385, 0.9143, 0.8841, 0.8461, 0.7979, 0.7359, 0.6541, - 0.5396, 0.3600, 0.1000, 0.1000, 0.1288, 0.4147, 0.5723, 0.6768, 0.7530, 0.8109, 0.8564, 0.8922, - 0.9211, 0.9440, 0.9617, 0.9755, 0.9858, 0.9930, 0.9973, 0.9993, 0.9993, 0.9973, 0.9930, 0.9858, - 0.9755, 0.9617, 0.9440, 0.9211, 0.8922, 0.8564, 0.8109, 0.7530, 0.6768, 0.5723, 0.4147, 0.1288, - 0.1000, 0.1000, 0.2199, 0.4615, 0.6019, 0.6981, 0.7689, 0.8236, 0.8660, 0.9003, 0.9272, 0.9485, - 0.9653, 0.9781, 0.9876, 0.9942, 0.9983, 0.9997, 0.9990, 0.9963, 0.9912, 0.9834, 0.9724, 0.9576, - 0.9385, 0.9143, 0.8841, 0.8461, 0.7979, 0.7359, 0.6541, 0.5396, 0.3600, 0.1000, 0.1000, 0.2199, - 0.3600, 0.4615, 0.5396, 0.6019, 0.6541, 0.6981, 0.7359, 0.7689, 0.7979, 0.8236, 0.8461, 0.8660, - 0.8841, 0.9003, 0.9143, 0.9272, 0.9385, 0.9485, 0.9576, 0.9653, 0.9724, 0.9781, 0.9834, 0.9876, - 0.9912, 0.9942, 0.9963, 0.9983, 0.9990, 0.9997, 0.9997, 0.9990, 0.9983, 0.9963, 0.9942, 0.9912, - 0.9876, 0.9834, 0.9781, 0.9724, 0.9653, 0.9576, 0.9485, 0.9385, 0.9272, 0.9143, 0.9003, 0.8841, - 0.8660, 0.8461, 0.8236, 0.7979, 0.7689, 0.7359, 0.6981, 0.6541, 0.6019, 0.5396, 0.4615, 0.3600, - 0.2199, 0.1000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, - 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, - 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, - 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, - 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 0.1000, 0.2199, 0.4615, 0.6019, 0.6981, 0.7689, - 0.8236, 0.8660, 0.9003, 0.9272, 0.9485, 0.9653, 0.9781, 0.9876, 0.9942, 0.9983, 0.9997, 0.9990, - 0.9963, 0.9912, 0.9834, 0.9724, 0.9576, 0.9385, 0.9143, 0.8841, 0.8461, 0.7979, 0.7359, 0.6541, - 0.5396, 0.3600, 0.1000, 0.1000, 0.2199, 0.6019, 0.7689, 0.8660, 0.9272, 0.9653, 0.9876, 0.9983, - 0.9990, 0.9912, 0.9724, 0.9385, 0.8841, 0.7979, 0.6541, 0.3600, 0.1000, 0.1000, 0.2199, 0.6019, - 0.7689, 0.8660, 0.9272, 0.9653, 0.9876, 0.9983, 0.9990, 0.9912, 0.9724, 0.9385, 0.8841, 0.7979, - 0.6541, 0.3600, 0.1000, 0.1000, 0.2199, 0.4615, 0.6019, 0.6981, 0.7689, 0.8236, 0.8660, 0.9003, - 0.9272, 0.9485, 0.9653, 0.9781, 0.9876, 0.9942, 0.9983, 0.9997, 0.9990, 0.9963, 0.9912, 0.9834, - 0.9724, 0.9576, 0.9385, 0.9143, 0.8841, 0.8461, 0.7979, 0.7359, 0.6541, 0.5396, 0.3600, 0.1000, + 0.00300, 0.00660, 0.01384, 0.01806, 0.02094, 0.02307, 0.02471, 0.02598, 0.02701, 0.02782, + 0.02845, 0.02896, 0.02934, 0.02963, 0.02983, 0.02995, 0.02999, 0.02997, 0.02989, 0.02974, + 0.02950, 0.02917, 0.02873, 0.02815, 0.02743, 0.02652, 0.02538, 0.02394, 0.02208, 0.01962, + 0.01619, 0.01080, 0.00300, 0.00300, 0.00660, 0.01384, 0.01806, 0.02094, 0.02307, 0.02471, + 0.02598, 0.02701, 0.02782, 0.02845, 0.02896, 0.02934, 0.02963, 0.02983, 0.02995, 0.02999, + 0.02997, 0.02989, 0.02974, 0.02950, 0.02917, 0.02873, 0.02815, 0.02743, 0.02652, 0.02538, + 0.02394, 0.02208, 0.01962, 0.01619, 0.01080, 0.00300, 0.00300, 0.00386, 0.00889, 0.01244, + 0.01508, 0.01717, 0.01887, 0.02030, 0.02153, 0.02259, 0.02351, 0.02433, 0.02505, 0.02569, + 0.02627, 0.02677, 0.02722, 0.02763, 0.02799, 0.02832, 0.02859, 0.02885, 0.02906, 0.02926, + 0.02942, 0.02957, 0.02968, 0.02979, 0.02986, 0.02992, 0.02996, 0.02998, 0.03000, 0.02998, + 0.02996, 0.02992, 0.02986, 0.02979, 0.02968, 0.02957, 0.02942, 0.02926, 0.02906, 0.02885, + 0.02859, 0.02832, 0.02799, 0.02763, 0.02722, 0.02677, 0.02627, 0.02569, 0.02505, 0.02433, + 0.02351, 0.02259, 0.02153, 0.02030, 0.01887, 0.01717, 0.01508, 0.01244, 0.00889, 0.00386, + 0.00300, 0.00300, 0.00386, 0.01244, 0.01717, 0.02030, 0.02259, 0.02433, 0.02569, 0.02677, + 0.02763, 0.02832, 0.02885, 0.02926, 0.02957, 0.02979, 0.02992, 0.02998, 0.02998, 0.02992, + 0.02979, 0.02957, 0.02926, 0.02885, 0.02832, 0.02763, 0.02677, 0.02569, 0.02433, 0.02259, + 0.02030, 0.01717, 0.01244, 0.00386, 0.00300, 0.00300, 0.00660, 0.01384, 0.01806, 0.02094, + 0.02307, 0.02471, 0.02598, 0.02701, 0.02782, 0.02845, 0.02896, 0.02934, 0.02963, 0.02983, + 0.02995, 0.02999, 0.02997, 0.02989, 0.02974, 0.02950, 0.02917, 0.02873, 0.02815, 0.02743, + 0.02652, 0.02538, 0.02394, 0.02208, 0.01962, 0.01619, 0.01080, 0.00300, 0.00200, 0.00440, + 0.00923, 0.01204, 0.01396, 0.01538, 0.01647, 0.01732, 0.01801, 0.01854, 0.01897, 0.01931, + 0.01956, 0.01975, 0.01988, 0.01997, 0.01999, 0.01998, 0.01993, 0.01982, 0.01967, 0.01945, + 0.01915, 0.01877, 0.01829, 0.01768, 0.01692, 0.01596, 0.01472, 0.01308, 0.01079, 0.00720, + 0.00200, 0.00200, 0.00258, 0.00829, 0.01145, 0.01354, 0.01506, 0.01622, 0.01713, 0.01784, + 0.01842, 0.01888, 0.01923, 0.01951, 0.01972, 0.01986, 0.01995, 0.01999, 0.01999, 0.01995, + 0.01986, 0.01972, 0.01951, 0.01923, 0.01888, 0.01842, 0.01784, 0.01713, 0.01622, 0.01506, + 0.01354, 0.01145, 0.00829, 0.00258, 0.00200, 0.00300, 0.00660, 0.01384, 0.01806, 0.02094, + 0.02307, 0.02471, 0.02598, 0.02701, 0.02782, 0.02845, 0.02896, 0.02934, 0.02963, 0.02983, + 0.02995, 0.02999, 0.02997, 0.02989, 0.02974, 0.02950, 0.02917, 0.02873, 0.02815, 0.02743, + 0.02652, 0.02538, 0.02394, 0.02208, 0.01962, 0.01619, 0.01080, 0.00300, 0.00300, 0.00660, + 0.01080, 0.01384, 0.01619, 0.01806, 0.01962, 0.02094, 0.02208, 0.02307, 0.02394, 0.02471, + 0.02538, 0.02598, 0.02652, 0.02701, 0.02743, 0.02782, 0.02815, 0.02845, 0.02873, 0.02896, + 0.02917, 0.02934, 0.02950, 0.02963, 0.02974, 0.02983, 0.02989, 0.02995, 0.02997, 0.02999, + 0.02999, 0.02997, 0.02995, 0.02989, 0.02983, 0.02974, 0.02963, 0.02950, 0.02934, 0.02917, + 0.02896, 0.02873, 0.02845, 0.02815, 0.02782, 0.02743, 0.02701, 0.02652, 0.02598, 0.02538, + 0.02471, 0.02394, 0.02307, 0.02208, 0.02094, 0.01962, 0.01806, 0.01619, 0.01384, 0.01080, + 0.00660, 0.00300, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, + 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, + 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, + 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, + 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, 0.03000, + 0.03000, 0.03000, 0.03000, 0.03000, 0.00300, 0.00660, 0.01384, 0.01806, 0.02094, 0.02307, + 0.02471, 0.02598, 0.02701, 0.02782, 0.02845, 0.02896, 0.02934, 0.02963, 0.02983, 0.02995, + 0.02999, 0.02997, 0.02989, 0.02974, 0.02950, 0.02917, 0.02873, 0.02815, 0.02743, 0.02652, + 0.02538, 0.02394, 0.02208, 0.01962, 0.01619, 0.01080, 0.00300, 0.00200, 0.00440, 0.01204, + 0.01538, 0.01732, 0.01854, 0.01931, 0.01975, 0.01997, 0.01998, 0.01982, 0.01945, 0.01877, + 0.01768, 0.01596, 0.01308, 0.00720, 0.00200, 0.00200, 0.00440, 0.01204, 0.01538, 0.01732, + 0.01854, 0.01931, 0.01975, 0.01997, 0.01998, 0.01982, 0.01945, 0.01877, 0.01768, 0.01596, + 0.01308, 0.00720, 0.00200, 0.00300, 0.00660, 0.01384, 0.01806, 0.02094, 0.02307, 0.02471, + 0.02598, 0.02701, 0.02782, 0.02845, 0.02896, 0.02934, 0.02963, 0.02983, 0.02995, 0.02999, + 0.02997, 0.02989, 0.02974, 0.02950, 0.02917, 0.02873, 0.02815, 0.02743, 0.02652, 0.02538, + 0.02394, 0.02208, 0.01962, 0.01619, 0.01080, 0.00300, }); static constexpr std::array monkey_line_offsets({ @@ -1086,40 +1110,6 @@ static constexpr std::array monkey_line_offsets({ 516, }); -static const std::array monkey_line_radii_factors({ - 60, - 60, - 60, - 60, - 60, - 40, - 40, - 60, - 60, - 60, - 60, - 60, - 40, - 40, - 60, -}); - -static const std::array monkey_fill_radii_factors({ - 75, - 60, - 60, - 60, - 60, - 60, - 60, - 40, - 60, - 60, - 60, - 40, - 40, -}); - static int add_material_from_template(Main &bmain, Object &ob, const ColorTemplate &pct) { int index; @@ -1143,7 +1133,6 @@ static bke::CurvesGeometry create_drawing_data(const Span positions, const Span opacities, const Span offsets, const Span materials, - const Span radii_factor, const float4x4 &matrix) { using namespace blender::bke; @@ -1156,6 +1145,8 @@ static bke::CurvesGeometry create_drawing_data(const Span positions, MutableSpan point_positions = curves.positions_for_write(); point_positions.copy_from(positions); + curves.transform(matrix); + SpanAttributeWriter point_radii = attributes.lookup_or_add_for_write_only_span( "radius", ATTR_DOMAIN_POINT); point_radii.span.copy_from(radii); @@ -1172,15 +1163,6 @@ static bke::CurvesGeometry create_drawing_data(const Span positions, "material_index", ATTR_DOMAIN_CURVE); stroke_materials.span.copy_from(materials); - const OffsetIndices points_by_curve = curves.points_by_curve(); - for (const int curve_i : curves.curves_range()) { - const IndexRange points = points_by_curve[curve_i]; - for (const int point_i : points) { - point_positions[point_i] = math::transform_point(matrix, point_positions[point_i]); - point_radii.span[point_i] *= radii_factor[curve_i]; - } - } - point_radii.finish(); point_opacities.finish(); @@ -1227,7 +1209,7 @@ void create_stroke(Main &bmain, Object &object, float4x4 matrix, const int frame Drawing &drawing_lines = reinterpret_cast(grease_pencil.drawing(0))->wrap(); drawing_lines.strokes_for_write() = create_drawing_data( - stroke_positions, stroke_radii, stroke_opacities, {0, 175}, {material_index}, {75}, matrix); + stroke_positions, stroke_radii, stroke_opacities, {0, 175}, {material_index}, matrix); drawing_lines.tag_topology_changed(); } @@ -1293,7 +1275,6 @@ void create_suzanne(Main &bmain, Object &object, float4x4 matrix, const int fram monkey_line_opacities, monkey_line_offsets, monkey_line_materials, - monkey_line_radii_factors, matrix); drawing_lines.tag_topology_changed(); @@ -1304,7 +1285,6 @@ void create_suzanne(Main &bmain, Object &object, float4x4 matrix, const int fram monkey_fill_opacities, monkey_fill_offsets, monkey_fill_materials, - monkey_fill_radii_factors, matrix); drawing_fills.tag_topology_changed(); } diff --git a/source/blender/editors/sculpt_paint/grease_pencil_paint.cc b/source/blender/editors/sculpt_paint/grease_pencil_paint.cc index 23ad8d6fcdc..78f2219f5a3 100644 --- a/source/blender/editors/sculpt_paint/grease_pencil_paint.cc +++ b/source/blender/editors/sculpt_paint/grease_pencil_paint.cc @@ -29,6 +29,17 @@ namespace blender::ed::sculpt_paint::greasepencil { static constexpr float POINT_OVERRIDE_THRESHOLD_PX = 3.0f; static constexpr float POINT_RESAMPLE_MIN_DISTANCE_PX = 10.0f; +static float calc_brush_radius(ViewContext *vc, + const Brush *brush, + const Scene *scene, + const float3 location) +{ + if (!BKE_brush_use_locked_size(scene, brush)) { + return paint_calc_object_space_radius(vc, location, BKE_brush_size_get(scene, brush)); + } + return BKE_brush_unprojected_radius_get(scene, brush); +} + template static inline void linear_interpolation(const T &a, const T &b, MutableSpan dst) { @@ -110,12 +121,11 @@ class PaintOperation : public GreasePencilStrokeOperation { * because it avoids passing a very large number of parameters between functions. */ struct PaintOperationExecutor { + Scene *scene_; ARegion *region_; GreasePencil *grease_pencil_; Brush *brush_; - int brush_size_; - float brush_alpha_; BrushGpencilSettings *settings_; float4 vertex_color_; @@ -126,18 +136,16 @@ struct PaintOperationExecutor { PaintOperationExecutor(const bContext &C) { - Scene *scene = CTX_data_scene(&C); + scene_ = CTX_data_scene(&C); region_ = CTX_wm_region(&C); Object *object = CTX_data_active_object(&C); grease_pencil_ = static_cast(object->data); - Paint *paint = &scene->toolsettings->gp_paint->paint; + Paint *paint = &scene_->toolsettings->gp_paint->paint; brush_ = BKE_paint_brush(paint); settings_ = brush_->gpencil_settings; - brush_size_ = BKE_brush_size_get(scene, brush_); - brush_alpha_ = BKE_brush_alpha_get(scene, brush_); - const bool use_vertex_color = (scene->toolsettings->gp_paint->mode == + const bool use_vertex_color = (scene_->toolsettings->gp_paint->mode == GPPAINT_FLAG_USE_VERTEXCOLOR); const bool use_vertex_color_stroke = use_vertex_color && ELEM(settings_->vertex_mode, GPPAINT_MODE_STROKE, @@ -154,7 +162,7 @@ struct PaintOperationExecutor { /* The object should have an active layer. */ BLI_assert(grease_pencil_->has_active_layer()); bke::greasepencil::Layer &active_layer = *grease_pencil_->get_active_layer_for_write(); - const int drawing_index = active_layer.drawing_index_at(scene->r.cfra); + const int drawing_index = active_layer.drawing_index_at(scene_->r.cfra); /* Drawing should exist. */ BLI_assert(drawing_index >= 0); @@ -174,9 +182,12 @@ struct PaintOperationExecutor { return math::transform_point(transforms_.world_space_to_layer_space, proj_point); } - float radius_from_input_sample(const InputSample &sample) + float radius_from_input_sample(const bContext &C, const InputSample &sample) { - float radius = brush_size_ / 2.0f; + ViewContext vc; + ED_view3d_viewcontext_init(const_cast(&C), &vc, CTX_data_depsgraph_pointer(&C)); + float radius = calc_brush_radius( + &vc, brush_, scene_, screen_space_to_drawing_plane(sample.mouse_position)); if (BKE_brush_use_size_pressure(brush_)) { radius *= BKE_curvemapping_evaluateF(settings_->curve_sensitivity, 0, sample.pressure); } @@ -185,7 +196,7 @@ struct PaintOperationExecutor { float opacity_from_input_sample(const InputSample &sample) { - float opacity = brush_alpha_; + float opacity = BKE_brush_alpha_get(scene_, brush_); if (BKE_brush_use_alpha_pressure(brush_)) { opacity *= BKE_curvemapping_evaluateF(settings_->curve_strength, 0, sample.pressure); } @@ -193,11 +204,12 @@ struct PaintOperationExecutor { } void process_start_sample(PaintOperation &self, + const bContext &C, const InputSample &start_sample, const int material_index) { const float2 start_coords = start_sample.mouse_position; - const float start_radius = this->radius_from_input_sample(start_sample); + const float start_radius = this->radius_from_input_sample(C, start_sample); const float start_opacity = this->opacity_from_input_sample(start_sample); const ColorGeometry4f start_vertex_color = ColorGeometry4f(vertex_color_); @@ -332,11 +344,12 @@ struct PaintOperationExecutor { } void process_extension_sample(PaintOperation &self, + const bContext &C, const InputSample &extension_sample, const int curve_index) { const float2 coords = extension_sample.mouse_position; - const float radius = this->radius_from_input_sample(extension_sample); + const float radius = this->radius_from_input_sample(C, extension_sample); const float opacity = this->opacity_from_input_sample(extension_sample); const ColorGeometry4f vertex_color = ColorGeometry4f(vertex_color_); @@ -403,11 +416,11 @@ struct PaintOperationExecutor { self, points, points.index_range().drop_front(self.active_smooth_index_)); } - void execute(PaintOperation &self, const InputSample &extension_sample) + void execute(PaintOperation &self, const bContext &C, const InputSample &extension_sample) { /* New curve was created in `process_start_sample`.*/ const int curve_index = drawing_->strokes().curves_range().last(); - this->process_extension_sample(self, extension_sample, curve_index); + this->process_extension_sample(self, C, extension_sample, curve_index); drawing_->tag_topology_changed(); } }; @@ -436,7 +449,7 @@ void PaintOperation::on_stroke_begin(const bContext &C, const InputSample &start const int material_index = BKE_grease_pencil_object_material_index_get(object, material); PaintOperationExecutor executor{C}; - executor.process_start_sample(*this, start_sample, material_index); + executor.process_start_sample(*this, C, start_sample, material_index); DEG_id_tag_update(&grease_pencil->id, ID_RECALC_GEOMETRY); WM_event_add_notifier(&C, NC_GEOM | ND_DATA, grease_pencil); @@ -448,7 +461,7 @@ void PaintOperation::on_stroke_extended(const bContext &C, const InputSample &ex GreasePencil *grease_pencil = static_cast(object->data); PaintOperationExecutor executor{C}; - executor.execute(*this, extension_sample); + executor.execute(*this, C, extension_sample); DEG_id_tag_update(&grease_pencil->id, ID_RECALC_GEOMETRY); WM_event_add_notifier(&C, NC_GEOM | ND_DATA, grease_pencil); diff --git a/source/blender/editors/sculpt_paint/paint_cursor.cc b/source/blender/editors/sculpt_paint/paint_cursor.cc index 7d4c4730a0e..0a469e71e83 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.cc +++ b/source/blender/editors/sculpt_paint/paint_cursor.cc @@ -1539,6 +1539,9 @@ static void grease_pencil_brush_cursor_draw(PaintCursorContext *pcontext) return; } + /* Note: For now, there is only as screen space sized cursor. */ + radius = BKE_brush_size_get(pcontext->scene, brush); + /* Get current drawing material. */ Material *ma = BKE_grease_pencil_object_material_from_brush_get(object, brush); if (ma) { @@ -1560,9 +1563,6 @@ static void grease_pencil_brush_cursor_draw(PaintCursorContext *pcontext) GPPAINT_MODE_STROKE, GPPAINT_MODE_BOTH); - radius = ed::greasepencil::brush_radius_world_space( - *pcontext->C, pcontext->x, pcontext->y); - copy_v3_v3(color, use_vertex_color_stroke ? brush->rgb : gp_style->stroke_rgba); } }