POV-Ray : Newsgroups : povray.newusers : tartan pattern : Re: tartan pattern Server Time
14 May 2024 19:37:12 EDT (-0400)
  Re: tartan pattern  
From: John Greenwood
Date: 9 Mar 2014 05:45:01
Message: <web.531c36c037ca8724a7cafab50@news.povray.org>
Thomas de Groot <tho### [at] degrootorg> wrote:
> 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

Thanks for the reply, which answers my initial question.

I think however that my difficulties lie in the way a texture is introduced
in the form of a macro. I will try and narrow down the problem and present it as
a new question.

John


Post a reply to this message

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