POV-Ray : Newsgroups : povray.newusers : tartan pattern : Re: tartan pattern Server Time
13 May 2024 17:10:03 EDT (-0400)
  Re: tartan pattern  
From: John Greenwood
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

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