Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411573 Posts in 69386 Topics- by 58444 Members - Latest Member: darkcitien

May 04, 2024, 12:57:14 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)The 5-Tile Solution to making a Dynamic Tileset
Pages: [1] 2
Print
Author Topic: The 5-Tile Solution to making a Dynamic Tileset  (Read 5043 times)
droqen
Level 10
*****


View Profile WWW
« on: March 12, 2010, 12:05:56 PM »

 
That's right! I used only five 16x16 tiles, and made a system that would allow them to cover any tile layout -- interior corners and all! I'll admit the method is slightly limiting, but in most cases you can use this method (with a bit of programming) to tile your stuff flawlessly.

At worst, you'd need to create 8 tiles, when in most cases you need 16 different tiles made even without accounting for interior corners.

The solution is a matter of cutting each of your supertiles into four SMALLER tiles. That's why I said I was kind of cheating -- you need to make sure that each of the 8x8 tiles can mesh perfectly with the others. (Of course, you can go 32x32 tiles with 16x16 quarter-tiles, or 70x70 with 35x35 subtiles too. But the tiles must fit on a grid; they can't match up in weird ways or the whole thing goes down in flames!)

Each corner only needs to check for 3 adjacent spaces (instead of the usual 4-8), thus reducing the amount of artwork that needs to be done manually.

Should I include some example code or something? There is a better explanation HERE [my blog <3], as well as below.

Instead of checking a tile for four, or even eight different neighbours (resulting in 16 to holy shit different tiles per tileset), you can simply check each corner for three different tiles, as shown here:


It's a bit more work to implement, and you may end up rendering more sprites (despite rendering the same number of pixels), but in the end you'll be able to add a whole connecting set of tiles with a relatively very small amount of work.

Congratulations!


Anyway, I hope that was helpful for anyone who needs to make a million different connecting tilesets :x Maybe I just saved you a half-hour of work, or something.
« Last Edit: March 12, 2010, 07:49:02 PM by Droqen » Logged

Zaratustra
Level 7
**



View Profile WWW
« Reply #1 on: March 12, 2010, 12:09:55 PM »

So, basically, you divided each tile in 4 smaller tiles.
Logged

droqen
Level 10
*****


View Profile WWW
« Reply #2 on: March 12, 2010, 12:16:12 PM »

Yep. And it makes things way easier on me :3 so I figured I'd give a good presentation or something, so that other people can do this instead of making 2^8 tiles 47 or so different tiles for interior corners, the bastards they are
Logged

Mikademus
Level 10
*****


The Magical Owl


View Profile
« Reply #3 on: March 12, 2010, 01:48:47 PM »

Revolutionary stuff. Grin But a nice presentation, and big creds for your good intentions!
Logged

\\\"There\\\'s a tendency among the press to attribute the creation of a game to a single person,\\\" says Warren Spector, creator of Thief and Deus Ex. --IGN<br />My compilation of game engines for indies
Cthulhu32
Level 6
*


Brawp


View Profile WWW
« Reply #4 on: March 12, 2010, 06:31:23 PM »

I'm planning to do something very similar to this on the Spuck online version (Phubans & my Gamma entry), but the one complication is there are actually more complicated corners because of the way we draw our map.



You can see how the corners have shadows, because at the time I did not want to dynamically generate those, I had to have separate tiles for the corners and shadows like that. But I'm debating scrapping that and dynamically searching for shadows, because doing it the way you've mentioned is 100000x easier Smiley

Great tech/tut btw, hopefully some people use this for their own games. What I like is the ability to make a map editor where you literally have a paint brush, and you just brushy brushy and then add detail later.
Logged

Skofo
Level 10
*****



View Profile
« Reply #5 on: March 12, 2010, 08:01:44 PM »

Amazing! I bet Crysis uses this same technique.  Wink
Logged

If you wish to make a video game from scratch, you must first invent the universe.
Akhel
Level 10
*****



View Profile
« Reply #6 on: March 12, 2010, 08:34:43 PM »

Stop bitching, I thought it was interesting.
Logged
BorisTheBrave
Level 10
*****


View Profile WWW
« Reply #7 on: March 13, 2010, 02:06:54 AM »

You can see how the corners have shadows, because at the time I did not want to dynamically generate those, I had to have separate tiles for the corners and shadows like that. But I'm debating scrapping that and dynamically searching for shadows, because doing it the way you've mentioned is 100000x easier Smiley
No no, you just have two layers of tiles one for shadow and one without. As all your regular tiles are just squares, you only need one shadow tile - a square extrudeded diagonally into a 6 sided shape. Lay those down overlapping each other, and you will get your shadow patter (only actually correct in places like the top right, where your tile approach failed.
Logged
Mipe
Level 10
*****


Migrating to imagination.


View Profile
« Reply #8 on: March 13, 2010, 02:34:19 AM »

Amazing! I bet Crysis uses this same technique.  Wink

Hey, you can always click Home button or use one of those bread crumb links if you don't like what you're reading.

----
On topic:

You could take it further; if your renderer supports rotation, you could use even less sprites.
One filled tile, one corner tile, one edge tile. Rotate the latter two as needed!
Logged
Christian Knudsen
Level 10
*****



View Profile WWW
« Reply #9 on: March 13, 2010, 02:38:10 AM »

It seems the floor wouldn't match up in most cases of rotation. You could always have the floor as a separate layer, though, but that's maybe taking it a bit too far and having a way too complicated solution for a simple problem. Wink
Logged

Laserbrain Studios
Currently working on Hidden Asset (TIGSource DevLog)
Mipe
Level 10
*****


Migrating to imagination.


View Profile
« Reply #10 on: March 13, 2010, 02:53:52 AM »

Well, yeah, that entirely depends on how you design your tiles. Smiley
Logged
Rob Lach
Level 10
*****



View Profile WWW
« Reply #11 on: March 13, 2010, 04:03:27 AM »

You could make this into a 1 tile set if you just make your texture lookups more clever.
Logged

gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #12 on: March 14, 2010, 02:53:03 AM »

Amazing! I bet Crysis uses this same technique.  Wink

Funny things is that they did! Except in 3D to polygonize their voxel data (and to reduce 256 case to 16) : P
Logged

Core Xii
Level 10
*****


the resident dissident


View Profile WWW
« Reply #13 on: March 14, 2010, 03:30:31 AM »

Well, that's not really five 16x16 tiles, it's just twenty 8x8 tiles simply arranged in a visually consistent formation. Nothing dynamic about it.
Logged
droqen
Level 10
*****


View Profile WWW
« Reply #14 on: March 14, 2010, 08:41:39 AM »

Mipey, I considered rotation, but figured this would be... enough :x
Rotation might be even more limiting, too (textures need to be allow for rotation-matching and stuff)

This is a great mix of responses xD

Core, it's as much 5 tiles in its creation as it is 20 smaller tiles if not more so -- and the former is quicker and easier to say. :D
Plus, the 'dynamic' bit is supposedly the fact that the tiles automatically set themselves up instead of you having to do them by hand. Maybe 'automatic tiling' would be a better phrase, or something.

Anyway, glad I could be of assistance to some :3
Logged

JMickle
Level 10
*****



View Profile
« Reply #15 on: March 14, 2010, 08:55:58 AM »

these guys are being picky. this method is clever.
Logged

gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #16 on: March 14, 2010, 10:03:16 AM »

That's an interesting thing to consider.
It's the same technique used by rpgmk's autotile.
Logged

raigan
Level 5
*****


View Profile
« Reply #17 on: March 14, 2010, 03:03:35 PM »

This is a great and useful solution, and thanks for sharing!

However: it's a bit confusing/misleading to describe this as "5 tiles" since really there are 20 unique tiles. Looking at your 5 tiles I couldn't understand how things would possibly work, but after reading it became clear that the 5 tiles are a meaningless grouping, since really it's all about the 20 8x8 tiles -- they are the functional unit underlying your method and it's easy to understand what you're doing once you've made this realization.

Rather than using 5 16x16 tiles, you could just as easily e.g stuff the 8x8 tiles into a single 8x160 or 16x80 or 32x40 block and call it "one tile". In light of this arbitrariness the only sensible descripion is to use the smallest possible unit, 8x8, since you can't reduce it any further than that.

Anyway, great job, sorry for being so picky Smiley
Logged
SHilbert
Level 0
**



View Profile WWW
« Reply #18 on: March 14, 2010, 03:43:02 PM »

This is cool stuff, IMHO. It may be 20 smaller tiles, but it's only as much work as drawing 5 full-size tiles, so I think this has utility. Now if only everything wasn't already more or less hardcoded to 16x16 tiles in my code...
Logged

nikki
Level 10
*****


View Profile
« Reply #19 on: March 15, 2010, 06:03:59 AM »

Its a good technique

I don't understand where the 20 tiles come from, I only see these:
  • inward corner  4x
  • outward corner 4x
  • horizontal 2x
  • vertical 2x

total: 12

The thing that worries me though:
Isn't drawing 4x the amount of tiles alot heavier (those dreadfully slow draw commands)  then just checking more neighbours (simple lookups) ?
Logged
Pages: [1] 2
Print
Jump to:  

Theme orange-lt created by panic