Skip to content

Commit

Permalink
feat(primaries_inset): plot: improve code style
Browse files Browse the repository at this point in the history
only output change is overlapping of points which is different
  • Loading branch information
MrLixm committed Nov 14, 2023
1 parent 196c1b1 commit 38490c7
Showing 1 changed file with 25 additions and 29 deletions.
54 changes: 25 additions & 29 deletions src/primaries_inset/src/PrimariesPlot.blink
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// version 7
// version 8
kernel InsetPrimariesPlot : ImageComputationKernel<ePixelWise>
{
Image<eRead, eAccessPoint, eEdgeClamped> src;
Expand Down Expand Up @@ -423,6 +423,7 @@ kernel InsetPrimariesPlot : ImageComputationKernel<ePixelWise>

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;
Expand Down Expand Up @@ -450,58 +451,52 @@ kernel InsetPrimariesPlot : ImageComputationKernel<ePixelWise>
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);
Expand All @@ -512,23 +507,24 @@ kernel InsetPrimariesPlot : ImageComputationKernel<ePixelWise>
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() = (
Expand Down

0 comments on commit 38490c7

Please sign in to comment.