POV-Ray : Newsgroups : povray.general : checkered passed : Re: checkered passed Server Time
8 Aug 2024 16:23:13 EDT (-0400)
  Re: checkered passed  
From: Chris Colefax
Date: 15 Nov 2000 01:42:38
Message: <3a12305e@news.povray.org>
Rick Mabry <rma### [at] softdiskcom> wrote:
> The checker pattern gives:
>
> ABABABAB
> BABABABA
> ABABABAB
> BABABABA
>
> But what is the best way to obtain
>
> ABCABCABCABC
> BCABCABCABCA
> CABCABCABCAB
> ABCABCABCABC
> BCABCABCABCA
>
> and other  general checker patterns? Must these be done "by hand" using
> loops?

POV-Ray includes the hexagon pattern, which tiles three colours, pigments,
textures, etc. using (duh!) hexagons.  If you want other tiled patterns you
should be able to use repeat warps (best for flat colours) and/or nested
patterns, e.g. a macro to create the tiling pattern you've shown above:

   #macro checker_pigment (Pigment1, Pigment2, Pigment3)
      gradient y pigment_map {
         [1/3 gradient x pigment_map {
            [1/3 Pigment1] [1/3 Pigment2] [2/3 Pigment2] [2/3 Pigment3]}
            ]
         [1/3 gradient x pigment_map {
            [1/3 Pigment3] [1/3 Pigment1] [2/3 Pigment1] [2/3 Pigment2]}
            ]
         [2/3 gradient x pigment_map {
            [1/3 Pigment3] [1/3 Pigment1] [2/3 Pigment1] [2/3 Pigment2]}
            ]
         [2/3 gradient x pigment_map {
            [1/3 Pigment2] [1/3 Pigment3] [2/3 Pigment3] [2/3 Pigment1]}
            ]
         }
         scale 3
   #end

   plane {z, 20
      pigment {checker_pigment (rgb x, rgb y, rgb z) translate -100}
      finish {ambient 1 diffuse 0}
      }

This macro can be easily modified for tiling complete textures, and extended
into the third dimension (z) if needed.  The only thing to note is that the
gradient pattern is symmetrical around the origin, so the tiling breaks
along the x and y axes.  This is easily avoided by translating the pattern
origin out of view.


Post a reply to this message

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