Jump to content


Photo

Seamless Texture Helper Plugin


  • Please log in to reply
17 replies to this topic

#1 BoltBait

BoltBait
  • Administrators
  • 8,907 posts
  • LocationCalifornia, USA
  • Reputation:103

Posted 15 November 2006 - 01:10 AM

What is the hardest part of creating seamless textures? Yes, making sure they look natural when they repeat. The usual problem is that no matter how hard you try, the seam is usually clearly visible.

I thought that it may make it easier if you work on the edges first (in the middle of the canvas), then move them to the edges of the physical canvas.

I know this probably sounds strange, but just take a look at the instructions section below for a better explanation.

You can download the precompiled effect DLL here: SeamlessHelper.dll

Just drop this file in your /program files/Paint.NET/effects directory and you should be all set.


Instructions for Use

The best way to use this is to follow these steps:

1) Create a canvas that is an even width and even height. For example, 200 x 200. It is critical that you do not use odd dimensions--they can be different (like 200x100, etc.) just not odd.

2) Start creating your texture by focusing on the middle of the canvas. Do not place anything too close to the edges at this point.

I will be creating a repeating texture of American coins. Here you can see this step:

Posted Image
Notice that I am only concerned about covering the area marked in red. Do not include red lines, they are only here to illustrate the area that I'm trying to cover.

By the way, I found all the images of these coins by using Google Image Search. I made this composite image by using several layers and liberal use of the Feather plugin.

3) Flatten your image down to a single layer.

4) Run the Seamless Helper effect. Your image should now look like this:

Posted Image
Notice how the coins have been moved to the edges. Your texture now has seamless edges!

To illustrate this more simply, take a look at this image (before on left, after on right):

Posted Image

The effect DLL basically splits your image into 4 parts
and rearranges those parts as show above.
5) Now finish off the center of the image being careful to again stay away from the edges. I'll just add 3 quarters to the picture:

Posted Image
6) Save the file in your favorite format (GIF, JPG, or PNG).

That's it! You have created a seamless texture!

You can quickly test these by putting it on your desktop and chose the "tile" option.

Once you've made a seamless texture, the next thing you'll need is the photo flood fill plugin. 8)


Source Code

The codelab script is fairly straight forward:

void Render(Surface dst, Surface src, Rectangle rect)
{
    PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds);
    Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
    int CenterX = (int)(((selection.Right - selection.Left) / 2)+selection.Left);
    int CenterY = (int)(((selection.Bottom - selection.Top) / 2)+selection.Top);
    ColorBgra CurrentPixel;
    int srcX = 0, srcY = 0;
    for(int y = rect.Top; y < rect.Bottom; y++)
    {
        for (int x = rect.Left; x < rect.Right; x++)
        {
            if (selectionRegion.IsVisible(x, y))
            {
                srcX = x;
                srcY = y;
                if (x < CenterX)
                {
                    srcX += CenterX;
                }
                else
                {
                    srcX -= CenterX;
                }
                if (y < CenterY)
                {
                    srcY += CenterY;
                }
                else
                {
                    srcY -= CenterY;
                }
                dst[x,y] = src[srcX,srcY];
            }
        }
    }
} 

Click to play:
Posted ImagePosted ImagePosted ImagePosted ImagePosted Image
Download: BoltBait's Plugin Pack | CodeLab | More... and how about a Computer Dominos Game

#2 barkbark00

barkbark00
  • Members
  • 3,336 posts
  • Reputation:2

Posted 15 November 2006 - 01:20 AM

I could see this being very helpful
Posted Image
Take responsibility for your own intelligence. ;) -Rick Brewster

#3 TinSoldier

TinSoldier
  • Members
  • 175 posts
  • LocationAloha, OR USA
  • Reputation:0

Posted 15 November 2006 - 03:43 AM

I don't understand step 4 very well; you just added some more coins to your image on different layers? Is that correct?

#4 BoltBait

BoltBait
  • Administrators
  • 8,907 posts
  • LocationCalifornia, USA
  • Reputation:103

Posted 15 November 2006 - 04:21 AM

I don't understand step 4 very well; you just added some more coins to your image on different layers? Is that correct?

Yes, after step 3 there is a big white space in the center of my drawing... So I added 3 quarters to the picture to finish it off.
Click to play:
Posted ImagePosted ImagePosted ImagePosted ImagePosted Image
Download: BoltBait's Plugin Pack | CodeLab | More... and how about a Computer Dominos Game

#5 crazyasslatino

crazyasslatino
  • Newbies
  • 4 posts
  • Locationchicago, il
  • Reputation:0

Posted 20 November 2006 - 07:33 AM

thank god u made this! i always wanted something to make a tile background but never comes out right :D

#6 kirby145

kirby145
  • Members
  • 132 posts
  • Reputation:1

Posted 04 December 2006 - 09:45 PM

Wow how did you do that it's like magic
"By trying to reinvent the wheel every time we find very often with square wheels" ...X-blaster

#7 MadJik

MadJik
  • Members
  • 2,428 posts
  • LocationLille;France
  • Reputation:20

Posted 04 December 2006 - 10:27 PM

Madjik would have say : logic!

#8 shaun1ee

shaun1ee
  • Members
  • 12 posts
  • LocationSwindon, England
  • Reputation:0

Posted 05 April 2007 - 07:11 PM

Not to worry, I managed to sort it
Thanks MadJik for the reply anyway :)

#9 Enormator

Enormator
  • Members
  • 308 posts
  • Locationwhere my laptop is
  • Reputation:2

Posted 21 April 2007 - 08:55 PM

:D WOW I'm proud of me... and you
biiig thanx dude!
(Made this pic only with effects (like noise, median blur, emboss... and YOUR EFFECT))
Posted Image
I also got a better one but didn't find it on my hdd. I'll add it later... maybe :wink:

#10 MadJik

MadJik
  • Members
  • 2,428 posts
  • LocationLille;France
  • Reputation:20

Posted 06 June 2007 - 08:30 AM

http://paintdotnet.1...p?p=48707#48707
From a request/idea on another topic...

To make a texture at once, I make an average with Source+Destination.

Test the code with CodeLab:
void Render(Surface dst, Surface src, Rectangle rect) 
{ 
  PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds); 
  Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt(); 
  int CenterX = (int)(((selection.Right - selection.Left) / 2) + selection.Left); 
  int CenterY = (int)(((selection.Bottom - selection.Top) / 2) + selection.Top); 
  ColorBgra PixD,Pix1,Pix2; 
  int srcX = 0, srcY = 0;
  
  for(int y = rect.Top; y < rect.Bottom; y++) 
  { 
    for (int x = rect.Left; x < rect.Right; x++) 
    { 
      srcX = x; 
      srcY = y; 

      if (x < CenterX) srcX += CenterX; 
      else srcX -= CenterX; 

      if (y < CenterY) srcY += CenterY; 
      else srcY -= CenterY; 

      Pix1 = src[srcX,srcY]; 
      Pix2 = src[x,y];
      PixD = src[x,y];
      PixD.R = (byte)((float)(Pix1.R + Pix2.R + 0.5f)/2.0f);
      PixD.G = (byte)((float)(Pix1.G + Pix2.G + 0.5f)/2.0f);
      PixD.B = (byte)((float)(Pix1.B + Pix2.B + 0.5f)/2.0f);
      PixD.A = (byte)((float)(Pix1.A + Pix2.A + 0.5f)/2.0f);
      dst[x,y] = PixD;
    } 
  } 
}

Edit: correction of a bug :oops:

#11 barkbark00

barkbark00
  • Members
  • 3,336 posts
  • Reputation:2

Posted 06 June 2007 - 02:25 PM

When I run that I get the following error:

Posted Image
Posted Image
Take responsibility for your own intelligence. ;) -Rick Brewster

#12 MadJik

MadJik
  • Members
  • 2,428 posts
  • LocationLille;France
  • Reputation:20

Posted 06 June 2007 - 02:39 PM

When I run that I get the following error:

Posted Image


I've changed this line so often, but I forgot to update the post!
Done!
TY

#13 MadJik

MadJik
  • Members
  • 2,428 posts
  • LocationLille;France
  • Reputation:20

Posted 06 June 2007 - 08:30 AM

http://paintdotnet.1...p?p=48707#48707
From a request/idea on another topic...

To make a texture at once, I make an average with Source+Destination.

Test the code with CodeLab:
void Render(Surface dst, Surface src, Rectangle rect) 
{ 
  PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds); 
  Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt(); 
  int CenterX = (int)(((selection.Right - selection.Left) / 2) + selection.Left); 
  int CenterY = (int)(((selection.Bottom - selection.Top) / 2) + selection.Top); 
  ColorBgra PixD,Pix1,Pix2; 
  int srcX = 0, srcY = 0;
  
  for(int y = rect.Top; y < rect.Bottom; y++) 
  { 
    for (int x = rect.Left; x < rect.Right; x++) 
    { 
      srcX = x; 
      srcY = y; 

      if (x < CenterX) srcX += CenterX; 
      else srcX -= CenterX; 

      if (y < CenterY) srcY += CenterY; 
      else srcY -= CenterY; 

      Pix1 = src[srcX,srcY]; 
      Pix2 = src[x,y];
      PixD = src[x,y];
      PixD.R = (byte)((float)(Pix1.R + Pix2.R + 0.5f)/2.0f);
      PixD.G = (byte)((float)(Pix1.G + Pix2.G + 0.5f)/2.0f);
      PixD.B = (byte)((float)(Pix1.B + Pix2.B + 0.5f)/2.0f);
      PixD.A = (byte)((float)(Pix1.A + Pix2.A + 0.5f)/2.0f);
      dst[x,y] = PixD;
    } 
  } 
}

Edit: correction of a bug :oops:

#14 barkbark00

barkbark00
  • Members
  • 3,336 posts
  • Reputation:2

Posted 06 June 2007 - 02:25 PM

When I run that I get the following error:

Posted Image
Posted Image
Take responsibility for your own intelligence. ;) -Rick Brewster

#15 MadJik

MadJik
  • Members
  • 2,428 posts
  • LocationLille;France
  • Reputation:20

Posted 06 June 2007 - 02:39 PM

When I run that I get the following error:

Posted Image


I've changed this line so often, but I forgot to update the post!
Done!
TY

#16 MadJik

MadJik
  • Members
  • 2,428 posts
  • LocationLille;France
  • Reputation:20

Posted 20 June 2007 - 03:41 PM

Seamless texture Maker
http://paintdotnet.1...opic.php?t=5334

#17 R3VENGE

R3VENGE
  • Members
  • 1,162 posts
  • Reputation:0

Posted 01 January 2008 - 09:02 PM

this will help in my ut2k4 map textures. before i had pdn i just used paint and everything was out of place. now i can put it into line

Posted Image
psn id: R3V-fiR3


#18 jimjimmy1995

jimjimmy1995
  • Newbies
  • 6 posts
  • Reputation:0

Posted 21 January 2011 - 10:34 PM

I've been doing this manually grr this makes life easier.