POV-Ray : Newsgroups : povray.newusers : random rotated pattern : Re: random rotated pattern Server Time
29 Jul 2024 08:22:43 EDT (-0400)
  Re: random rotated pattern  
From: Mike Williams
Date: 1 Apr 2006 15:14:11
Message: <z7MfROAhxsLEFwXz@econym.demon.co.uk>
Wasn't it eilart who wrote:
>
>The function F returns a pattern? 

Any function can be used as a pattern. A pattern is just something that
returns a numerical value between 0.0 and 1.0 for any point in space. A
function is something that returns a numerical value for any point in
space. When you use a function as a pattern, it just ignores the integer
part of the numerical value.

>The x inside the F function is the
>parameter passed to the function or simple warp offset indication?

x, y and z between them indicate a point in space. When a ray hits a
surface, POV passes the x,y,z coordinates of that point to the function
or pattern to get the value for that point. It then does things like
looking up that numerical value in a colour_map to determine the colour
at that point in space.

>I thing that F returns a numeric value instead, because of how is used in
>the H function. But what is this value? A random value generated by the
>cells pattern?

The cells pattern returns the same random value for all points in the
same "cell". The pattern of cells is then offset and scaled to produce
something that matches the brick pattern. The brick layer is only there
to provide the mortar.

>So this script is cell pattern dependant?

Yes

>Can I use to rotate an arbitrary pattern? This is what i don't understand.

G is the arbitrary pattern function. I chose a simple gradient, because
it's easy to see when a gradient is rotated. 

I could have used, say, a granite pattern for G, like this:

#version 3.6;
global_settings {assumed_gamma 1.0}
camera {location  <5,0,-10> look_at <0,0,0> angle 50}
light_source {<-30, 100, -30> color rgb 1}

#declare F = function {pattern {cells
  warp {repeat y offset 1000.5*x}
  scale <1,0.5,1>
}}
  
#declare G = function {pattern {granite scale 5}}

#declare H = function {G(x*sin(F(x,y,z)*2*pi)+y*cos(F(x,y,z)*2*pi),
y*sin(F(x,y,z)*2*pi)-x*cos(F(x,y,z)*2*pi),0)}

plane {z,0
  texture {
    pigment { function {  H(x,y,0)  }
      colour_map {[0.25 rgb <1.0,0.7,0.4>][0.75 rgb <0.8,0.3,0>]}
    }
  }
  texture {
    pigment {brick rgb 1 rgbt 1
      brick_size <1,0.5,0.5>
      mortar 0.02
    }
  }
}  
  


But then it wouldn't be obvious that the granite pattern was actually
being rotated. The randomness of the granite pattern means that you get
an almost identical effect if the pattern is randomly translated (which
is somewhat easier):

#version 3.6;
global_settings {assumed_gamma 1.0}
camera {location  <5,0,-10> look_at <0,0,0> angle 50}
light_source {<-30, 100, -30> color rgb 1}

#declare F = function {pattern {cells
  warp {repeat y offset 1000.5*x}
  scale <1,0.5,1>
}}
  
#declare G = function {pattern {granite scale 5}}

#declare H = function {G(x+F(x,y,z)*100,y,z)}


plane {z,0
  texture {
    pigment { function {  H(x,y,0)  }
      colour_map {[0.25 rgb <1.0,0.7,0.4>][0.75 rgb <0.8,0.3,0>]}
    }
  }
  texture {
    pigment {brick rgb 1 rgbt 1
      brick_size <1,0.5,0.5>
      mortar 0.02
    }
  }
}  
  

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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