POV-Ray : Newsgroups : povray.general : row of bricks Server Time
31 Oct 2024 06:14:39 EDT (-0400)
  row of bricks (Message 1 to 6 of 6)  
From: David Kraics
Subject: row of bricks
Date: 17 Nov 2023 03:30:00
Message: <web.65572457c829a4a56633439fa57e0@news.povray.org>
I am wanting to create a line of 13 bricks, with obvious separation between
them. However, I want make it with a single box. What would be the best code or
texture to do this? At first I thought of an image_map but that is just for 2 of
the six sides of a box.


Post a reply to this message

From: Bald Eagle
Subject: Re: row of bricks
Date: 17 Nov 2023 06:20:00
Message: <web.65574bd1b54d8b5a1f9dae3025979125@news.povray.org>
"David Kraics" <bar### [at] aolcom> wrote:
> I am wanting to create a line of 13 bricks, with obvious separation between
> them. However, I want make it with a single box. What would be the best code or
> texture to do this? At first I thought of an image_map but that is just for 2 of
> the six sides of a box.

I suppose you could do a texture pattern that evaluates mod (x,1) and then
select () for any value that is less than the unit brick length, everything else
being 0.
Then use that with a texture map which is part brick, and part clear.

Use scale <> to get your 13 bricks if necessary.

- BW


Post a reply to this message

From: Bald Eagle
Subject: Re: row of bricks
Date: 17 Nov 2023 06:45:00
Message: <web.65575193b54d8b5a1f9dae3025979125@news.povray.org>
#version 3.8;
global_settings {assumed_gamma 1}

camera {
 location <13/2, 0.5, -13>
 right     x*image_width/image_height
 up y
 look_at <13/2, 0, 0>

}


light_source {<1, 10, -20> rgb 1}

sky_sphere {pigment {rgb 1}}


#declare BrickWidth = 0.9;
#declare f_Bricks = function {mod (x, 1)}
#declare Bricks = function {select (f_Bricks (x, y, z)-BrickWidth, 0, 1)}

#declare Brick = texture {pigment {rgb x}}
#declare Clear = texture {pigment {rgbt 1}}
#declare TextureMap = texture_map {[0.0 Brick] [1.0 Clear]}
#declare BrickTexture = texture {function {Bricks (x, y, z)} texture_map
{TextureMap}}

box {<0, 0, 0> <13, 0.5, 1> texture {BrickTexture}}


Post a reply to this message

From: ingo
Subject: Re: row of bricks
Date: 17 Nov 2023 07:30:00
Message: <web.65575c7eb54d8b5a17bac71e8ffb8ce3@news.povray.org>
"David Kraics" <bar### [at] aolcom> wrote:
> I am wanting to create a line of 13 bricks, with obvious separation between
> them. However, I want make it with a single box. What would be the best code or
> texture to do this? At first I thought of an image_map but that is just for 2 of
> the six sides of a box.

for some inspiration, have a look at WallStucco.pov in advanced scenefiles in
the distribution. It uses a height_field for the brick wall.

ingo


Post a reply to this message

From: David Kraics
Subject: Re: row of bricks
Date: 17 Nov 2023 16:05:00
Message: <web.6557d571b54d8b5a6633439fa57e0@news.povray.org>
Bald Eagle, thank you for your coding. I couldn't wrap my mind around how or why
it works, but I could plug in my colors and use it.


Post a reply to this message

From: Bald Eagle
Subject: Re: row of bricks
Date: 17 Nov 2023 18:05:00
Message: <web.6557f0dcb54d8b5a1f9dae3025979125@news.povray.org>
"David Kraics" <bar### [at] aolcom> wrote:
> Bald Eagle, thank you for your coding. I couldn't wrap my mind around how or why
> it works, but I could plug in my colors and use it.


Excellent.  Hopefullly it's for something fun, and you post your finished render
so we can see what it was all about   :)

You wanted a repeating pattern.  That screams "mod" to computer graphics people.
So wtf is mod?  It's basically just the fractional component of a number.
0.0 = 0.0
0.1 = 0.1
0.2 = 0.2
0.3 = 0.3
0.4 = 0.4
0.5 = 0.5
0.6 = 0.6
0.7 = 0.7
0.8 = 0.8
0.9 = 0.9
1.0 = 0.0
1.1 = 0.1
.... etc forever and ever

but you don't want a ramp or fade in your pattern, you want a sudden jump.
That's a discontinuous function, and screams "select".

f_Bricks = function {mod (x, 1)}
Bricks = function {select (f_Bricks (x, y, z)-BrickWidth, 0, 1)}

So you have f_Bricks taking all of your 3D space data, only using the x
component, and basically making every part of that number line just repeat in a
sawtooth wave.  Select looks at the first argument - mod x minus the brick width
parameter, and sees if it's <0 or >=0.  Every x value up until 0.9 will be
negative, and so select spits out 0.  Then in that small space between 09 and 1,
mod x minus the brick width is positive, so select spits out 1.

You feed that controlling function into your texture to determine how that
texture map is applied, and all the x's below 0.9 are red, and from 0.9-1 it's
clear.

Wash, rinse, repeat.


// =====================================================================

#version 3.8;
global_settings {assumed_gamma 1}

camera {
 location <13/2, 0.5, -13>
 right     x*image_width/image_height
 up y
 look_at <13/2, 0, 0>

}


light_source {<1, 10, -20> rgb 1}

sky_sphere {pigment {rgb 1}}


#declare E = 0.01;
#declare Line = 0.01;
#declare BrickWidth = 0.9;
#declare f_Bricks = function {mod (x, 1)}
#declare Bricks = function {select (f_Bricks (x, y, z)-BrickWidth, 0, 1)}

#declare Brick = texture {pigment {rgb x}}
#declare Clear = texture {pigment {rgbt 1}}
#declare TextureMap = texture_map {[0.0 Brick] [1.0 Clear]}
#declare BrickTexture = texture {function {Bricks (x, y, z)} texture_map
{TextureMap}}

box {<0, 0, 0> <13-E, 0.5, 1> texture {BrickTexture}}


box {<0, 1, 0>, <13, 2, 1> texture {BrickTexture rotate z*90}}

#for (L, 0, 12)
 union {
  cylinder {<0, 0, 0>, <0, 2, 0> Line}
  cylinder {<BrickWidth, 0, 0>, <BrickWidth, 2, 0> Line}
  pigment {rgb x+y}
  translate x*L
 }
#end

#declare Step = 0.01;
union {
 #for (Val, 0, 13, Step)
  #declare Y = f_Bricks (Val, 0, 0);
  #declare Current = <Val, Y, 0>;
  sphere {Current, Line}
  #if (Val > 0)
   #cylinder {Last, Current Line}
  #end
  #declare Last = Current;
 #end
 pigment {rgb y}
 translate y
}


Post a reply to this message


Attachments:
Download 'brickpattern.png' (39 KB)

Preview of image 'brickpattern.png'
brickpattern.png


 

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