From 76c48cfffbac6cb40103c99eb76c0847b0d1a16a Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Sun, 3 Sep 2023 17:09:05 -0700 Subject: modules/flow: don't reap elements on screen-space exit This is too aggressive and produces some undesirable visible artifacts on the periphery, especially for slow-moving small-size fields. In such scenarios the elements near the edges would be excessively pruned when the direction wandered off-screen, then leaving an overly sparse region when the direction inevitably wandered back. This is still an issue but it's far less prominent when only clipping to the flow field boundaries... since the FOV doesn't quite encompass the edges of the flow field. Now the elements can survive wandering a bit off-screen, and re-enter. --- src/modules/flow/flow.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/modules') diff --git a/src/modules/flow/flow.c b/src/modules/flow/flow.c index 973fad0..8b1386d 100644 --- a/src/modules/flow/flow.c +++ b/src/modules/flow/flow.c @@ -164,8 +164,9 @@ static void flow_render_fragment(til_module_context_t *context, til_stream_t *st x = (pos.x * 2.f - 1.f) / (pos.z + ZCONST) * fragment->width + (fragment->width >> 1); y = (pos.y * 2.f - 1.f) / (pos.z + ZCONST) * fragment->height + (fragment->height >> 1) ; - if (!til_fb_fragment_put_pixel_checked(fragment, TIL_FB_DRAW_FLAG_TEXTURABLE, x, y, color_to_uint32_rgb(d.color)) || - pos.x < 0.f || pos.x > 1.f || + (void) til_fb_fragment_put_pixel_checked(fragment, TIL_FB_DRAW_FLAG_TEXTURABLE, x, y, color_to_uint32_rgb(d.color)); + + if (pos.x < 0.f || pos.x > 1.f || pos.y < 0.f || pos.y > 1.f || pos.z < 0.f || pos.z > 1.f) *e = rand_element(&ctxt->til_module_context.seed); -- cgit v1.2.1