POV-Ray : Newsgroups : povray.newusers : tartan pattern Server Time
28 Apr 2024 19:04:43 EDT (-0400)
  tartan pattern (Message 1 to 7 of 7)  
From: John Greenwood
Subject: tartan pattern
Date: 7 Mar 2014 06:40:01
Message: <web.5319ae9c1ab50c86a7cafab50@news.povray.org>
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>}


Post a reply to this message

From: James Holsenback
Subject: Re: tartan pattern
Date: 7 Mar 2014 08:19:07
Message: <5319c74b@news.povray.org>
On 03/07/2014 06:35 AM, 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?

http://wiki.povray.org/content/Documentation:Tutorial_Section_3.4#Working_With_Layered_Textures


Post a reply to this message

From: John Greenwood
Subject: Re: tartan pattern
Date: 8 Mar 2014 07:50:01
Message: <web.531b118f37ca8724a7cafab50@news.povray.org>
James Holsenback <nom### [at] nonecom> wrote:
> On 03/07/2014 06:35 AM, 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?
>
>
http://wiki.povray.org/content/Documentation:Tutorial_Section_3.4#Working_With_Layered_Textures

Um.. I did read that, but I am floundering. I want to define a number of objects
with a variety of textures with a concise single line. Below are four attempts.
The first shows the sort of effect but does not use the macro parameters. No 2
uses one of the parameters and gives the wrong result. No 3 does not work and I
can't see why. No 4 is a mess; it gives the same result as No 2 but why does it
work when No 3 doesn't?

Can macros be nested in this way?


#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> }


// 1 this gives desired effect
#macro Stripes(Direction,Colour,Width,Pitch)
  texture {
    pigment  {
        gradient x
    frequency 100/Pitch
        color_map {
      [0.00 color Colour]
      [Width color Colour]
      [Width color Clear]
      [1 color Clear]

                  }
      rotate Direction*z
             }
      normal { bumps 1 scale .001 }
      finish { specular .5 roughness .1}
          }
#end

#macro Shape(Base_Colour,Added_Texture)  // but neither of these parameters are
being used
#union   {
  sphere {<0,0,0>, .1}
  sphere {<.03,.03,0>, .1}
  pigment {rgb <1,1,1>}  // this sets the background colour
  Stripes(45,<1,0,0,0>,.5,2)
         }
#end

#declare Sample = Shape(<1,0,0>,Stripes(90,<0,0,1>,.3,.01));    //I want to
define objects with a variety of textures with a concise single line like this

object {Sample translate <.13,-.13,0>}
object {Sample translate <0,0,10>}
object {Sample translate <-.25,.25,30>}
object {Sample translate <-.80,.80,70>}


/*
// 2 This does not do the stripes
#macro Stripes(Direction,Colour,Width,Pitch)
  texture {
    pigment  {
        gradient x
    frequency 100/Pitch
        color_map {
      [0.00 color Colour]
      [Width color Colour]
      [Width color Clear]
      [1 color Clear]

                  }
      rotate Direction*z
             }
      normal { bumps 1 scale .001 }
      finish { specular .5 roughness .1}
          }
#end

#macro Shape(Base_Colour,Added_Texture)
#union   {
  sphere {<0,0,0>, .1}
  sphere {<.03,.03,0>, .1}
  pigment {rgb Base_Colour}  // Use of the macro parameter stops next bit
working
//  texture { pigment {rgb Base_Colour}} makes no difference
  Stripes(45,<1,0,0,0>,.5,2)
         }
#end

#declare Sample = Shape(<1,0,0>,Stripes(90,<0,0,1>,.3,.01));

object {Sample translate <.13,-.13,0>}
object {Sample translate <0,0,10>}
object {Sample translate <-.25,.25,30>}
object {Sample translate <-.80,.80,70>}
*/


/*
// 3 This does not work
#macro Stripes(Direction,Colour,Width,Pitch)
  texture {
    pigment  {
        gradient x
    frequency 100/Pitch
        color_map {
      [0.00 color Colour]
      [Width color Colour]
      [Width color Clear]
      [1 color Clear]

                  }
      rotate Direction*z
             }
      normal { bumps 1 scale .001 }
      finish { specular .5 roughness .1}
          }
#end

#macro Shape(Base_Colour,Added_Texture)
#union   {
  sphere {<0,0,0>, .1}
  sphere {<.03,.03,0>, .1}
  pigment {rgb <1,1,1>}  // this sets the background colour
  Added_Texture
         }
#end

#declare Sample = Shape(<1,0,0>,Stripes(90,<0,0,1>,.3,.01));

object {Sample translate <.13,-.13,0>}
object {Sample translate <0,0,10>}
object {Sample translate <-.25,.25,30>}
object {Sample translate <-.80,.80,70>}
*/

/*
// 4 This "works" but stripes are wrong
#macro Stripes(Direction,Colour,Width,Pitch)
    pigment  {
        gradient x
    frequency 100/Pitch
        color_map {
      [0.00 color Colour]
      [Width color Colour]
      [Width color Clear]
      [1 color Clear]
                  }

    rotate Direction*z   }
#end

#macro Shape(Base_Colour,Added_Texture)
  #union {
    sphere {<0,0,0>, .1}
    sphere {<.03,.03,0>, .1}
    pigment {rgb Base_Colour}
    texture {Added_Texture }
       }


#end

#declare Sample = Shape(<1,0,0>,Stripes(90,<0,0,1>,.3,.01));    // this is what
I want: a single line


object {Sample translate <.13,-.13,0>}
object {Sample translate <0,0,10>}
object {Sample translate <-.25,.25,30>}
object {Sample translate <-.80,.80,70>}
*/


Post a reply to this message

From: Thomas de Groot
Subject: Re: tartan pattern
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

From: John Greenwood
Subject: Re: tartan pattern
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

From: Thomas de Groot
Subject: Re: tartan pattern
Date: 10 Mar 2014 05:13:36
Message: <531d8240$1@news.povray.org>
Following your post, I remembered a tartan pattern made with Moray in 
2002. I don't remember who the author was though. I reworked it for 
POV-Ray (left-handed system) and version 3.7. Here is the code. Enjoy 
and explore further developments ;-)

//Start Code
#declare Col1 = <1.0, 0.0, 0.0>;
#declare Col2 = <1.0, 0.0, 0.0>;

#declare Pig1 =
pigment {
   gradient x
   color_map {
     [0.190 srgb <0.0, 0.0, 0.0>]
     [0.190 srgb Col1]
     [0.233 srgb Col1]
     [0.233 srgb <0.0, 0.0, 0.0>]
     [0.304 srgb <0.0, 0.0, 0.0>]
     [0.304 srgb <1.0, 1.0, 1.0>]
     [0.325 srgb <1.0, 1.0, 1.0>]
     [0.325 srgb <0.0, 0.0, 0.0>]
     [0.396 srgb <0.0, 0.0, 0.0>]
     [0.396 srgb Col1]
     [0.441 srgb Col1]
     [0.441 srgb <0.0, 0.0, 0.0>]
     [0.625 srgb <0.0, 0.0, 0.0>]
     [0.625 srgb Col1]
   }
}

#declare Pig2 =
pigment {
   gradient x
   color_map {
     [0.190 srgb <0.0, 0.0, 0.0>]
     [0.190 srgb Col2]
     [0.233 srgb Col2]
     [0.233 srgb <0.0, 0.0, 0.0>]
     [0.304 srgb <0.0, 0.0, 0.0>]
     [0.304 srgb <1.0, 1.0, 1.0>]
     [0.325 srgb <1.0, 1.0, 1.0>]
     [0.325 srgb <0.0, 0.0, 0.0>]
     [0.396 srgb <0.0, 0.0, 0.0>]
     [0.396 srgb Col2]
     [0.441 srgb Col2]
     [0.441 srgb <0.0, 0.0, 0.0>]
     [0.625 srgb <0.0, 0.0, 0.0>]
     [0.625 srgb Col2]
   }
}

#declare Mat_McGregor =
material {
   texture {
     pigment_pattern {
       gradient <1.0, 1.0, 0.0>
       color_map {
         [0.0 srgb <0.0, 0.0, 0.0>]
         [0.5 srgb <0.0, 0.0, 0.0>]
         [0.9 srgb <1.0, 1.0, 1.0>]
         [1.0 srgb <1.0, 1.0, 1.0>]
       }
       scale  0.03
       rotate 45.0*y
     }
     texture_map {
       [0.0 pigment {Pig1}]
       [1.0 pigment {Pig2} rotate -90.0*y]
     }
   }
}

//End Code

Thomas


Post a reply to this message

From: John Greenwood
Subject: Re: tartan pattern
Date: 10 Mar 2014 06:55:00
Message: <web.531d99d737ca8724a7cafab50@news.povray.org>
Thomas de Groot <tho### [at] degrootorg> wrote:
> Following your post, I remembered a tartan pattern made with Moray in
> 2002. I don't remember who the author was though. I reworked it for
> POV-Ray (left-handed system) and version 3.7. Here is the code. Enjoy
> and explore further developments ;-)
>
> //Start Code
......
> //End Code
>
> Thomas

Thomas: Thanks for sending that. Impressive but far too detailed for my
purposes.

I have tracked down the source of my problems. I was using:

    pigment  {
      gradient y
      frequency 100/Pitch      <---This is the offending line
      color_map {
        [0.00 color rgbt ColourY]
        [Width color rgbt ColourY]
        [Width color Clear]
        [1 color Clear]
                  }
             }
When I changed this to:
       frequency Pitch
Everything started working as it should

Thanks for all the help

John


Post a reply to this message

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