POV-Ray : Newsgroups : povray.general : Tilable textures Server Time
2 Nov 2024 13:20:29 EDT (-0400)
  Tilable textures (Message 1 to 4 of 4)  
From: SharkD
Subject: Tilable textures
Date: 15 Aug 2009 02:53:00
Message: <4a865b4c$1@news.povray.org>
I may have asked this before, but what are some good ways to create 2D 
textures that tile? A tiling desktop background is a common (maybe not 
so much these days...) example.

Secondly (and this is the more advanced part), how might I turn tiling 
on and off for a particular direction? What I really want to do is 
create square terrain tiles (for a game) that have 16 possible "states" 
based on whether or not a tile has a neighbor.

For example, a tile with four neighbors would join nicely on all four 
sides. A tile with only three neighbors would be "closed" on one side.

Here's are the 16 possible "states":

   o        o        x        x
o o o    x o o    o o o    x o o
   o        o        o        o


   o        o        x        x
o o x    x o x    o o x    x o x
   o        o        o        x


   o        o        x        x
o o o    x o o    o o o    x o o
   x        x        x        x


   o        o        x        x
o o x    x o x    o o x    x o x
   x        x        x        x

The "o" in the middle of each diagram is the tile in the center. The 
rest are its neighbors.

-Mike


Post a reply to this message

From: stbenge
Subject: Re: Tilable textures
Date: 15 Aug 2009 04:17:48
Message: <4a866f2c@news.povray.org>
SharkD wrote:
> I may have asked this before, but what are some good ways to create 2D 
> textures that tile? 

In 2D space you can use diamond tiling:

#declare repeatable_pattern=
pigment{
  cylindrical rotate x*90 scale 1.00
  pigment_map{
   [0 rgb 0]
   [1 crackle scale .5]
  }
}

plane{z,0
  pigment{
   average
   pigment_map{
    [1 repeatable_pattern translate -x]
    [1 repeatable_pattern translate x]
    [1 repeatable_pattern translate -y]
    [1 repeatable_pattern translate y]
   }
   translate(x+y)
   warp{repeat x*2}
   warp{repeat y*2}
  }
}

or square tiling:

#declare repeatable_pattern=
pigment{
  cylindrical rotate x*90 scale 1.50
  pigment_map{
   [0 rgb 0]
   [1 crackle scale .5]
  }
}

plane{z,0
  pigment{
   average
   pigment_map{
    [1 repeatable_pattern translate<-1,-1,0>]
    [1 repeatable_pattern translate<1,-1,0>]
    [1 repeatable_pattern translate<-1,1,0>]
    [1 repeatable_pattern translate<1,1,0>]
   }
   translate(x+y)
   warp{repeat x*2}
   warp{repeat y*2}
  }
}

where "repeatable_pattern" is a pigment you wish to use in excess.

> Secondly (and this is the more advanced part), how might I turn tiling 
> on and off for a particular direction? 

I think perhaps you'll be keeping track of where the break in repetition 
occurs, so for a tile which repeats using diamond tiling, with a break 
in repetition to the right:

  pigment{
   average
   pigment_map{
    [1 repeatable_pattern translate -x]
    [1 non_repeatable_pattern translate x]
    [1 repeatable_pattern translate -y]
    [1 repeatable_pattern translate y]
   }
   translate(x+y)
   warp{repeat x*2}
   warp{repeat y*2}
  }

might suffice.

I hope this helps somewhat.

Sam


Post a reply to this message

From: stbenge
Subject: Re: Tilable textures
Date: 15 Aug 2009 04:27:24
Message: <4a86716c@news.povray.org>
stbenge wrote:
> #declare repeatable_pattern=
> pigment{
>  cylindrical rotate x*90 scale 1.00
>  pigment_map{
>   [0 rgb 0]
     [1 crackle color_map{[0 rgb 0][1 rgb 4]}]
>  }
> }

Oh yeah, this^ will fix any dimness experienced while averaging four 
copies of the pigment. Can't stretch it too thin without proper 
compensation ;)


Post a reply to this message

From: Warp
Subject: Re: Tilable textures
Date: 15 Aug 2009 04:36:54
Message: <4a8673a6@news.povray.org>
SharkD <mik### [at] gmailcom> wrote:
> I may have asked this before, but what are some good ways to create 2D 
> textures that tile?

//==================================================================
#declare PatternFunc =
  function { pattern { wood turbulence .5 scale .5 } };

#declare PatternFuncTiledX =
  function
  { pattern
    { function
      { (1-x)*PatternFunc(x, y, z) +
        x*PatternFunc(x-1, y, z)
      }
      warp { repeat x }
    }
  };

#declare PatternFuncTiledY =
  function
  { pattern
    { function
      { (1-y)*PatternFunc(x, y, z) +
        y*PatternFunc(x, y-1, z)
      }
      warp { repeat y }
    }
  };

#declare PatternFuncTiledXY =
  function
  { pattern
    { function
      { (1-y)*PatternFuncTiledX(x, y, z) +
        y*PatternFuncTiledX(x, y-1, z)
      }
      warp { repeat y }
    }
  };

camera { location -z*3 look_at 0 }
plane
{ -z, 0
  pigment
  { function { PatternFuncTiledXY(x, y, z) }
    color_map { [0 rgb 0] [1 rgb 1] }
  }
  finish { ambient 1 }
}
//==================================================================

-- 
                                                          - Warp


Post a reply to this message

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