From 8b5626584119e2e854586b5080dba90c2f7ca96b Mon Sep 17 00:00:00 2001 From: Brad Weinberger <1484541+BradleyMarie@users.noreply.github.com> Date: Thu, 14 Aug 2025 12:01:03 -0700 Subject: [PATCH] Fix index clamping bug in MarbleTexture. This also fixes MarbleTexture so that they render properly again since t also ends up being miscomputed as a consequence of the incorrect clamping. Issue #252 --- src/textures/marble.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/textures/marble.h b/src/textures/marble.h index 94919c6d71..1d932c1c11 100644 --- a/src/textures/marble.h +++ b/src/textures/marble.h @@ -71,8 +71,8 @@ class MarbleTexture : public Texture { {.58f, .58f, .6f}, {.2f, .2f, .33f}, {.58f, .58f, .6f}, }; #define NC sizeof(c) / sizeof(c[0]) -#define NSEG (NC - 3) - int first = std::min(1, int(std::floor(t * NSEG))); +#define NSEG int(NC - 3) + int first = std::min(NSEG - 1, int(std::floor(t * NSEG))); t = (t * NSEG - first); Spectrum c0 = Spectrum::FromRGB(c[first]); Spectrum c1 = Spectrum::FromRGB(c[first + 1]);