POV-Ray : Newsgroups : povray.newusers : random rotated pattern Server Time
25 Nov 2024 07:38:03 EST (-0500)
  random rotated pattern (Message 1 to 9 of 9)  
From: eilart
Subject: random rotated pattern
Date: 1 Apr 2006 05:50:01
Message: <web.442e5a3e4051beb335dfc7790@news.povray.org>
Hi, i'm wondering if ther's a way to render a brick pattern in which every
brick have a random rotated pattern.

Thanks

matteo


Post a reply to this message

From: Mike Williams
Subject: Re: random rotated pattern
Date: 1 Apr 2006 07:54:25
Message: <fQKk7HA7fnLEFwg4@econym.demon.co.uk>
Wasn't it eilart who wrote:
>Hi, i'm wondering if ther's a way to render a brick pattern in which every
>brick have a random rotated pattern.

I don't think you can rotate a pattern randomly for different parts of a
texture. The problem is that rotations are handled at parse time rather
than at render time, so you can't use things like functions on them.

Here's a simple brick wall with random colours on the bricks. [To see
how it works, change the "offset" to "0.5*x". The "1000.5*x" causes the
bricks of the same colour to be shifted sideways by 1000 extra steps, so
you don't see the pattern repeat.]

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

plane {z,0
  // random colours
  texture {
    pigment {cells
      warp {repeat y offset 1000.5*x}
      colour_map {[0 rgb <1,0.7,0.4>][1 rgb <0.8,0.3,0>]}
      scale <1,0.5,1>
    }
  }
  // mortar applied as a texture layer
  texture {
    pigment {brick rgb 1 rgbt 1
      brick_size <1,0.5,0.5>
      mortar 0.02
    }
  }
}  


It's possible to pull out the pattern as a function

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

and then use that to control a pigment or a texture_map

pigment {function{F(x,y,z)}

but you can't use it to control a rotation_map because there's no such
thing.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Mike Williams
Subject: Re: random rotated pattern
Date: 1 Apr 2006 08:01:03
Message: <nAJqPLA2knLEFwG4@econym.demon.co.uk>
Wasn't it eilart who wrote:
>Hi, i'm wondering if ther's a way to render a brick pattern in which
>every brick have a random rotated pattern.

It turns out I was wrong. It is possible to write a texture rotation
function pattern. Here's one that rotates a one-dimensional gradient
function.

G: is the gradient function
F: is the function that chooses a random value for each cell
H: applies F as a rotation to G.x

If you want to rotate a two dimensional texture, then you have to change
H to apply rotations to G.x and G.y


#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 {x*6}

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

plane {z,0
  texture {
    pigment { function {  H(x,y,0)  }
      colour_map {[0.5 rgb 0.5][0.5 rgb 0.6]}
    }
  }
  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

From: Bob H
Subject: Re: random rotated pattern
Date: 1 Apr 2006 09:07:22
Message: <442e891a$1@news.povray.org>
Hey now, that isn't any April Fool's trick there. Looks very useful.


Post a reply to this message

From: eilart
Subject: Re: random rotated pattern
Date: 1 Apr 2006 09:35:00
Message: <web.442e8f19e10db4eb35dfc7790@news.povray.org>
"Bob H" <omniverse@charter%net> wrote:
Hei, many thanks, i'll try it.


Post a reply to this message

From: eilart
Subject: Re: random rotated pattern
Date: 1 Apr 2006 10:00:00
Message: <web.442e94b1e10db4eb35dfc7790@news.povray.org>
"eilart" <mat### [at] maltesenarrazioniit> wrote:
> "Bob H" <omniverse@charter%net> wrote:
> Hei, many thanks, i'll try it.

But a simple macro wouldn't work?
A macro with a texture argument that returns a random rotated texture?
Or the macro will be parsed only once?

I see that your way works, but it's not so understandable for me, so it's a
little uneasy to translate it in my scene.


Post a reply to this message

From: Mike Williams
Subject: Re: random rotated pattern
Date: 1 Apr 2006 10:12:28
Message: <gewLYBAThpLEFwG8@econym.demon.co.uk>
Wasn't it eilart who wrote:
>"eilart" <mat### [at] maltesenarrazioniit> wrote:
>> "Bob H" <omniverse@charter%net> wrote:
>> Hei, many thanks, i'll try it.
>
>But a simple macro wouldn't work?
>A macro with a texture argument that returns a random rotated texture?
>Or the macro will be parsed only once?

You could easily write a macro that will generate a wall brick by brick
with a a separate texture on each brick, rotated randomly, but you asked
for a random rotated pattern, so I wrote a pattern that randomly
rotates.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: eilart
Subject: Re: random rotated pattern
Date: 1 Apr 2006 10:45:01
Message: <web.442e9eebe10db4eb35dfc7790@news.povray.org>
>
> You could easily write a macro that will generate a wall brick by brick
> with a a separate texture on each brick, rotated randomly, but you asked
> for a random rotated pattern, so I wrote a pattern that randomly
> rotates.
>
> --
> Mike Williams
> Gentleman of Leisure

I'm sorry. Your pattern works perfectly ant it's the thing that I wanted.
I don't want to generate the wall brick by brick, i want a pattern that can
be used like a pattern.
The problem is that i'm a little dumb and i haven't yet understood
completely your script.

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

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?
So this script is cell pattern dependant?
Can I use to rotate an arbitrary pattern? This is what i don't understand.

Thanksalot anyway!


Post a reply to this message

From: Mike Williams
Subject: Re: random rotated pattern
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.