Sign in to follow this  
Followers 0
BoltBait

Seamless Texture Helper Plugin

21 posts in this topic

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:

    Coins1.jpg

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:

    Coins2.jpg

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):

Coins4.gif

    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:

    Coins3.jpg

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];
            }
        }
    }
} 

0

Share this post


Link to post
Share on other sites

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

0

Share this post


Link to post
Share on other sites
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.

0

Share this post


Link to post
Share on other sites

Not to worry, I managed to sort it

Thanks MadJik for the reply anyway :)

0

Share this post


Link to post
Share on other sites

: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))

randomtilesmaller846_thumb.jpg

I also got a better one but didn't find it on my hdd. I'll add it later... maybe :wink:

0

Share this post


Link to post
Share on other sites

http://paintdotnet.12.forumer.com/viewtopic.php?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:

0

Share this post


Link to post
Share on other sites

http://paintdotnet.12.forumer.com/viewtopic.php?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:

0

Share this post


Link to post
Share on other sites
When I run that I get the following error:

error.png

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

Done!

TY

0

Share this post


Link to post
Share on other sites
When I run that I get the following error:

error.png

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

Done!

TY

0

Share this post


Link to post
Share on other sites

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

0

Share this post


Link to post
Share on other sites

One question, Where in the menus is the option to use this?

I installed the plugin but can't find where it is accessed in order to use it.

Any help here would be most appreciated, thank you in advance.

0

Share this post


Link to post
Share on other sites

One question, Where in the menus is the option to use this?

I installed the plugin but can't find where it is accessed in order to use it.

Any help here would be most appreciated, thank you in advance.

You will find it in the Effects menu, just scroll down after clicking the Effects tab  :)

Edited by sashwilko
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0