From 38490c7ce82e5f9e86d79fe49329e175b71c7f38 Mon Sep 17 00:00:00 2001 From: Liam Collod Date: Tue, 14 Nov 2023 13:09:10 +0100 Subject: [PATCH] feat(primaries_inset): plot: improve code style only output change is overlapping of points which is different --- src/primaries_inset/src/PrimariesPlot.blink | 54 ++++++++++----------- 1 file changed, 25 insertions(+), 29 deletions(-) diff --git a/src/primaries_inset/src/PrimariesPlot.blink b/src/primaries_inset/src/PrimariesPlot.blink index 1ac28ff..46af1f4 100644 --- a/src/primaries_inset/src/PrimariesPlot.blink +++ b/src/primaries_inset/src/PrimariesPlot.blink @@ -1,4 +1,4 @@ -// version 7 +// version 8 kernel InsetPrimariesPlot : ImageComputationKernel { Image src; @@ -423,6 +423,7 @@ kernel InsetPrimariesPlot : ImageComputationKernel float invert = u_invert == 1 ? -1: 1; float2 dst_whitepoint = u_src_whitepoint + u_whitepoint_pre_offset * invert; + float2 dst_post_whitepoint = dst_whitepoint + u_whitepoint_post_offset * invert; // 1. calculate inset gamut float3x3 inset_colorspace; @@ -450,58 +451,52 @@ kernel InsetPrimariesPlot : ImageComputationKernel primary_b_inset, u_rotate_b * (pi/180) * invert, dst_whitepoint ); + // 2. start drawing in pixel space + float point_r_weight = 0.0; float point_g_weight = 0.0; float point_b_weight = 0.0; float point_w_weight = 0.0; - float2 point_center(0,0); - // 2. start drawing in pixel space + // smaller point for src primaries + float point_scale = u_point_scale * u_outline_scale * 0.5; + // bigger point for dst primaries + float point_scale_torus = u_point_scale * u_outline_scale; // 2.1 draw src primaries point_center = convert_CIExy_to_workspace(u_src_primary_r); point_center = float2(pos.x, pos.y) - point_center; - point_r_weight = draw_point(point_center, u_point_scale * u_outline_scale * 0.5); + point_r_weight = draw_point(point_center, point_scale); point_center = convert_CIExy_to_workspace(u_src_primary_g); point_center = float2(pos.x, pos.y) - point_center; - point_g_weight = draw_point(point_center, u_point_scale * u_outline_scale * 0.5); + point_g_weight = draw_point(point_center, point_scale); point_center = convert_CIExy_to_workspace(u_src_primary_b); point_center = float2(pos.x, pos.y) - point_center; - point_b_weight = draw_point(point_center, u_point_scale * u_outline_scale * 0.5); + point_b_weight = draw_point(point_center, point_scale); point_center = convert_CIExy_to_workspace(u_src_whitepoint); point_center = float2(pos.x, pos.y) - point_center; - point_w_weight = draw_point(point_center, u_point_scale * u_outline_scale * 0.5); + point_w_weight = draw_point(point_center, point_scale); // 2.2 draw inset primaries point_center = convert_CIExy_to_workspace(primary_r_inset); point_center = float2(pos.x, pos.y) - point_center; - point_r_weight += draw_torus( - point_center, u_point_scale, u_point_scale * u_outline_scale - ); + point_r_weight += draw_torus(point_center, u_point_scale, point_scale_torus); point_center = convert_CIExy_to_workspace(primary_g_inset); point_center = float2(pos.x, pos.y) - point_center; - point_g_weight += draw_torus( - point_center, u_point_scale, u_point_scale * u_outline_scale - ); + point_g_weight += draw_torus(point_center, u_point_scale, point_scale_torus); point_center = convert_CIExy_to_workspace(primary_b_inset); point_center = float2(pos.x, pos.y) - point_center; - point_b_weight += draw_torus( - point_center, u_point_scale, u_point_scale * u_outline_scale - ); + point_b_weight += draw_torus(point_center, u_point_scale, point_scale_torus); - point_center = convert_CIExy_to_workspace( - dst_whitepoint + u_whitepoint_post_offset * invert - ); + point_center = convert_CIExy_to_workspace(dst_post_whitepoint); point_center = float2(pos.x, pos.y) - point_center; - point_w_weight += draw_torus( - point_center, u_point_scale, u_point_scale * u_outline_scale - ); + point_w_weight += draw_torus(point_center, u_point_scale, point_scale_torus); point_r_weight = max(point_r_weight, point_w_weight); point_g_weight = max(point_g_weight, point_w_weight); @@ -512,23 +507,24 @@ kernel InsetPrimariesPlot : ImageComputationKernel float4 border_color(0.0, 0.0, 0.0, 0.0); if (u_show_space_borders){ float border_alpha = draw_borders(float2(pos.x, pos.y)); + // avoid border visually overlapping with points border_alpha = point_alpha > 0.0? 0.0: border_alpha; - border_color = float4(border_alpha, border_alpha, border_alpha, border_alpha); - border_color = border_color * 0.1; + border_color = float4(0.1, 0.1, 0.1, 1.0) * border_alpha; } float4 spectral_locus_color(0.0, 0.0, 0.0, 0.0); if (u_show_spectral_locus){ float spectral_locus_alpha = draw_spectral_locus(float2(pos.x, pos.y)); - spectral_locus_color = float4( - spectral_locus_alpha, spectral_locus_alpha, spectral_locus_alpha, spectral_locus_alpha - ); - spectral_locus_color = spectral_locus_color * 0.2; + // avoid locus visually overlapping with points + spectral_locus_alpha = point_alpha > 0.0? 0.0: spectral_locus_alpha; + spectral_locus_color = float4(0.2, 0.2, 0.2, 1.0) * spectral_locus_alpha; } - float4 daylight_locus_color = float4(0.0, 0.0, 0.0, 0.0); + float4 daylight_locus_color(0.0, 0.0, 0.0, 0.0); if (u_show_daylight_locus){ float daylight_locus_alpha = draw_daylight_locus(float2(pos.x, pos.y)); + // avoid locus visually overlapping with points + daylight_locus_alpha = point_alpha > 0.0? 0.0: daylight_locus_alpha; daylight_locus_color = float4(0.5, 0.3, 0.2, 1.0) * daylight_locus_alpha; } dst() = (