POV-Ray : Newsgroups : povray.general : Weirdnesses with function patterns : Weirdnesses with function patterns Server Time
29 Jul 2024 00:27:53 EDT (-0400)
  Weirdnesses with function patterns  
From: David Given
Date: 8 Dec 2013 13:17:47
Message: <52a4b7cb$1@news.povray.org>
Yes, me again, I'm afraid. I've found two issues where function patterns
are behaving really strangely.

Consider this texture:

texture {
	function { x }
	texture_map {
		[-0.5 pigment { Red } ]
		[0.5 pigment { Yellow } ]
	}
}

I'd expect this to be solid red in the -x direction, fading smoothly to
yellow as it passes x=0, and then solid yellow in the +x direction.

Instead what happens is the return value of the function is clipped into
the [0..1] range.

This could be intentional; however, if it is, then this behaviour isn't
documented, and the actual implementation that makes it happen seems a
little confused, which makes me suspect that's it's not intended.

The code comes in two parts: this in function_pattern:

	return ((value > 1.0) ? fmod(value, 1.0) : value);

...which wraps *positive* values, and this in Evaluate_TPat, which wraps
*negative* values.

	if(TPat->Frequency != 0.0)
		value = fmod(value * TPat->Frequency + TPat->Phase, 1.00001); // TODO
FIXME - magic number! Should be 1.0+SOME_EPSILON (or maybe actually 1.0?)

	/* allow negative Frequency */
	if(value < 0.0)
		value -= floor(value);

Because positive values are only wrapped in function_pattern, then this
means that positive values returned by non-function patterns aren't
wrapped at all! Also that TODO makes me sad.

So I think there's definitely something wrong here, but I'm not entirely
sure what. What's *supposed* to happen in this situation?

-- 
┌─── dg@cowlark.com ─────
http://www.cowlark.com ─────
│ "There does not now, nor will there ever, exist a programming
│ language in which it is the least bit hard to write bad programs." ---
│ Flon's Axiom


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.