POV-Ray : Newsgroups : povray.programming : Cells Pattern Server Time
8 Jul 2024 20:08:04 EDT (-0400)
  Cells Pattern (Message 1 to 3 of 3)  
From: Slime
Subject: Cells Pattern
Date: 10 Nov 2002 02:30:27
Message: <3dce0b13$1@news.povray.org>
The function that calculates the cells pattern is as follows:

static DBL cells_pattern (VECTOR EPoint)
{
  int    temp;
  DBL    tf;

  temp = POV_GET_OLD_RAND(); /* save current seed */


  /* select a random value based on the cube from which this came. */

  /* floor the values, instead of just truncating - this eliminates
duplicated cells
  around the axes */

  POV_SRAND(Hash3d((int)floor(EPoint[X]+Small_Tolerance),
                   (int)floor(EPoint[Y]+Small_Tolerance),
                   (int)floor(EPoint[Z]+Small_Tolerance)));

  tf = FRAND();

  POV_SRAND(temp);  /* restore */

  return min(tf, 1.0);
}

Why is Small_Tolerance being added to EPoint? That just offsets the pattern
by a little bit. What's the point?

 - Slime
[ http://www.slimeland.com/ ]


Post a reply to this message

From: John VanSickle
Subject: Re: Cells Pattern
Date: 10 Nov 2002 06:59:37
Message: <3DCE4A2D.AC259872@hotmail.com>
Slime wrote:
> 
> The function that calculates the cells pattern is as follows:
> 
> static DBL cells_pattern (VECTOR EPoint)
> {
>   int    temp;
>   DBL    tf;
> 
>   temp = POV_GET_OLD_RAND(); /* save current seed */
> 
>   /* select a random value based on the cube from which this came. */
> 
>   /* floor the values, instead of just truncating - this eliminates
> duplicated cells
>   around the axes */
> 
>   POV_SRAND(Hash3d((int)floor(EPoint[X]+Small_Tolerance),
>                    (int)floor(EPoint[Y]+Small_Tolerance),
>                    (int)floor(EPoint[Z]+Small_Tolerance)));
> 
>   tf = FRAND();
> 
>   POV_SRAND(temp);  /* restore */
> 
>   return min(tf, 1.0);
> }
> 
> Why is Small_Tolerance being added to EPoint? That just offsets the
> pattern by a little bit. What's the point?

Probably so that when the cell border is coincident with the surface
being textured there will be no speckling.  This would be the case if
it was applied to a plane facing along a coordiante axis at an
integral distance from the origin.

Regards,
John


Post a reply to this message

From: Slime
Subject: Re: Cells Pattern
Date: 10 Nov 2002 12:14:06
Message: <3dce93de$1@news.povray.org>
> Probably so that when the cell border is coincident with the surface
> being textured there will be no speckling.  This would be the case if
> it was applied to a plane facing along a coordiante axis at an
> integral distance from the origin.

Oooh. Good point.

The annoying thing is, when applied to a box from <0,0,0> to <1,1,1>, the
very edges of the box are in different cells than the rest of the faces that
they belong to.

 - Slime
[ http://www.slimeland.com/ ]


Post a reply to this message

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