POV-Ray : Newsgroups : povray.newusers : tartan pattern : Re: tartan pattern Server Time
13 May 2024 23:55:49 EDT (-0400)
  Re: tartan pattern  
From: Thomas de Groot
Date: 8 Mar 2014 10:25:06
Message: <531b3652$1@news.povray.org>
On 7-3-2014 12:35, John Greenwood wrote:
> The macro below is intended to generate a tartan-type pattern. to start with I
> am trying to superimpose two sets of transparent stripes at right angles.
>
> The second set of stripes is superimposed on the background colour as expected
> but the first pigment, defining the first set of stripes, seems to have been
> overwritten by the second pigment. How do I get them to both superimpose?
>
>
> #version 3.7 ;
> background {color rgb 1/2}
>    #include "colors.inc"
>
> global_settings {
>      assumed_gamma 1
>   max_trace_level 100 }
>
> camera{location <0,0,-10> angle 5 look_at <0,0,0> }
> light_source{<0,200,-200> colour White parallel point_at <0,0,0> }
>
> #macro Tartan(Direction,ColourX,ColourY,Width,Pitch)
>    texture {
>      pigment  {           // first set of stripes
>          gradient x
>      frequency 100/Pitch
>          color_map {
>        [0.00 color rgbt ColourX]
>        [Width color rgbt ColourX]
>        [Width color Clear]
>        [1 color Clear]
>                    }
>               }
>      pigment  {          // second set of stripes
>          gradient y
>      frequency 100/Pitch
>          color_map {
>        [0.00 color rgbt ColourY]
>        [Width color rgbt ColourY]
>        [Width color Clear]
>        [1 color Clear]
>                    }
>               }
>        normal { bumps 1 scale .001 }
>        finish { specular .5 roughness .1}
>        rotate Direction*z
>            }
> #end
>
> #declare Sample  =
> #union   {
>    sphere {<0,0,0>, .1}
>    sphere {<.03,.03,0>, .1}
>    pigment {rgb <1,1,1>}  // this sets the background colour
>    Tartan(45,<1,0,0,0>,<0,1,0,.5>,.5,2)
>           }
>
> object {Sample translate <.13,-.13,0>}
> object {Sample translate <0,0,10>}
> object {Sample translate <-.25,.25,30>}
> object {Sample translate <-.80,.80,70>}

Layered textures are not layered pigments ;-)

If you change your code as follows, the pattern becomes apparent:

#macro Tartan(Direction,ColourX,ColourY,Width,Pitch)
   texture {
     pigment  {           // first set of stripes
       gradient x
       frequency 100/Pitch
       color_map {
         [0.00 color rgbt ColourX]
         [Width color rgbt ColourX]
         [Width color Clear]
         [1 color Clear]
       }
     }
   }
   texture {
     pigment  {          // second set of stripes
       gradient y
       frequency 100/Pitch
       color_map {
         [0.00 color rgbt ColourY]
         [Width color rgbt ColourY]
         [Width color Clear]
         [1 color Clear]
       }
     }
     normal { bumps 1 scale .001 }
     finish { specular .5 roughness .1}
     rotate Direction*z
   }
#end

Thomas


Post a reply to this message

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