Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Seamless Texture, does any one knows how to code it?

Author
Message
haliop
User Banned
Posted: 11th May 2010 13:24
whats behind that algorithem?
i guess its probably something like a sphere view or something but i honestly have no idea, i do not want to use extrior programs but to code it , does anyone have a clue?
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 11th May 2010 13:44
Quote: "whats behind that algorithem?"


Which algorithm? There are many different ways of making seamless textures, but they fall into roughly two groups: (a) modify an existing image so that the edges tile seamlessly, and (b) make a seamless texture from scratch by wrapping around the vertical and horizontal coordinates.

If you mean (a) then you could try this:

seamless texturing utility
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 11th May 2010 14:14
If you mean, you want to actually generate the texture, then as GG says, it's really a matter of wrapping the coordinates when sampling the image. A function that creates a grass texture for instance might start with pure black, then add green noise randomly over the image, then smooth it out - very basic. The problem would arise when the smoothing function gets to the edges, as it should blend the wrapped coordinates to make it seamless. So if you sampled a 3x3 area of the image, I would have that done with a function that checks the image dimensions, and adjusts the passed coordinates to suit.

Ideally you would have a function to return the pixel colour at a given location based on X and Y coordinates that you would specify. If a coordinate is below 0 then add the image width or height, and if a coordinate exceeds the image width or height, decrease it. This way your sampling would account for wrapping textures, and it would generate perfectly seamless textures for you.

So it might just be a case of making a special wrapping POINT function, depends on what sort of textures you want to make. Along with general noise being used for grass - you might use it for stone, then add in some crack lines (moving a point randomly 'dragging' a crack), wrap this in the same way, and you'll keep the texture seamless.

Personally, I would make some functions that can be run in sequence to create different textures - like a function to take 2 colours and fill an image with noise based on these colours - and a function to smooth out, add cracks etc. You can even add details from other images, like a little flower - then paste it 9 times, 1 centre paste, then the image width and height added and subtracted so that if the sprite overlaps an edge, it will be seamless because the same sprite is pasted at the opposite edge.

There's lots of techniques out there that are worth looking into, perlin noise etc, I would try and get the basic grass in there then investigate some procedural texture generation techniques.


Health, Ammo, and bacon and eggs!
haliop
User Banned
Posted: 11th May 2010 18:06
i am generating textures from brushes and stamps.
if i have a green 1024x1024 clean bitmap, i do a random Paste Image on it so i have a lot of foliage like brushes, once i have the image it looks really good , but i want to make it seamless , i have already saw the noise idea , but that gives me a low detail altough looking pretty good.

how can i make it to any image what so ever , ofcourse with a sense of logic in it?
haliop
User Banned
Posted: 11th May 2010 18:08
btw im using DarkGDK and not DBP so i cant really use the Utility.
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 11th May 2010 19:38
Well if your texture is 1024x1024, you could just repeat the pasting of the brushes. I would paste the brush at X,Y, then paste it at X-1024,y and X+1024,y and x,Y-1024 and x,Y+1024.

That way, your brush will be pasted seamlessly, because if your brush overlaps, it gets pasted on the opposite side too, making it seamless.


Health, Ammo, and bacon and eggs!
The Slayer
Forum Vice President
15
Years of Service
User Offline
Joined: 9th Nov 2009
Playing: (Hide and) Seek and Destroy on my guitar!
Posted: 11th May 2010 22:22
Well, I didn't try this out yet, but it could work:

There's the command 'SET MATRIX TEXTURE Matrix Number, Texture Mode, Mip Mode', where a value of 1 for the 'Texture Mode' mirrors the texture to create a seamless texture pattern, and a value of two will set clamping which retains the colour of the last pixel at the textures edge and paint with that throughout the out of range area. So, you could texture a flat matrix with some (non seamless) texture, use a value of 1 for 'Texture mode', and then grab that image with the camera?
Of course, the camera would have to be positioned perfectly above the matrix, but it should be possible, I guess?

Cheers

Slayer rules!!! Yeaaah, man!
Mobiius
Valued Member
22
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 11th May 2010 22:24
Ew, matrices.

My signature is NOT a moderator plaything! Stop changing it!
haliop
User Banned
Posted: 11th May 2010 22:35
yeh man the matrice idea does sounds good and its no problem to catch with the camera man! wow dude , that is an awesome solution ty.

Van b , but it will have the seams showing, if what your saying will work then no need at all for the seamless idea in te firstplace
am i wrong?
and if i overlap one by the other it still dosenot make it seamless
or i just didnt understand what you were trying to say, sorry.
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 11th May 2010 23:26
I shall make an example...


Health, Ammo, and bacon and eggs!
haliop
User Banned
Posted: 11th May 2010 23:34
wow , tnx Van.
The Slayer
Forum Vice President
15
Years of Service
User Offline
Joined: 9th Nov 2009
Playing: (Hide and) Seek and Destroy on my guitar!
Posted: 11th May 2010 23:40
Quote: "Ew, matrices."

They're still usefull in some cases.

Quote: "yeh man the matrice idea does sounds good and its no problem to catch with the camera man! wow dude , that is an awesome solution ty."

You're welcome! I'm not sure if that command exists in DarkGDK, though?

Cheers

Slayer rules!!! Yeaaah, man!
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 11th May 2010 23:47
Try this, just made a little function to do a repeat paste. Media and stuff is all included.


Health, Ammo, and bacon and eggs!

Attachments

Login to view attachments
haliop
User Banned
Posted: 12th May 2010 00:44
dude... Van B
you are F aweosme man.
i am speechless.

ty very much.
take a look of what im doing with it , and hopefully you will find some intrest in it in the future as it will make alot of our (game programmers) lifes extremly simplier.

http://forum.thegamecreators.com/?m=forum_view&t=169730&b=22

everyone in DarkGDK subforum tnx you all for your help.
haliop
User Banned
Posted: 12th May 2010 00:46
altough Van B , i will not use Paste Image , but Paste Sprite then i can random rotate and size the given Image , giving it a much more random nature look.

Login to post a reply

Server time is: 2025-06-01 09:25:42
Your offset time is: 2025-06-01 09:25:42