The Daily Click ::. Forums ::. Digital Works ::. Tilemap Pixel Shader (aka "texture atlas")
 

Post Reply  Post Oekaki 
 

Posted By Message

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
5th May, 2013 at 05/05/2013 19:19:22 -

For anyone unfamiliar with the concept, here's a little background info:
http://blog.tojicode.com/2012/07/sprite-tile-maps-on-gpu.html

So basically, you have an object the same size as your frame, with two textures:
* a map image representing your game level, with 1 pixel per tile.
* a tileset image with the individual tiles, in a 16x16 tile grid.

The color of each pixel in the map image determines which tile from the tileset to draw at that position.

Anyway, here's my version: http://sdrv.ms/13aDqGN

The tileset image must be 16x16 tiles in size. Tiles are indexed from 0-255 (ordered left-to-right and top-to-bottom), using the red component from the map image only (unlike the example above which uses red and green).

btw: I realize there are many other ways to do the same thing, besides a pixel shader, but it just seemed like an interesting experiment. I really ought to add scrolling...


Edited by Sketchy

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
8th May, 2013 at 08/05/2013 17:24:48 -

I made another new pixel shader - this one is for auto-tiling.
You give your object 2 textures - one acts as a map (1 pixel per tile), and the other holds the tile graphics. All the maths for selecting which tile to draw, according to the tiles around it, is done by the shader (proper area tiling requires two objects; linear tiling or walls etc only needs one).

To try and illustrate the idea:
Image

Download: http://sdrv.ms/10qCr5T

 
n/a

nim



Registered
  17/05/2002
Points
  7233
9th May, 2013 at 09/05/2013 02:23:29 -

I'm always amazed that you make these awesome code examples and just give them away. Have you considered setting up a small website with all of your examples so far? I know they're all on skydrive but I mean something more like nivram's site.

 
//

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
9th May, 2013 at 09/05/2013 10:54:31 -

It's not exactly organized or up to date, but I have this: http://www.sketchy.co.nf

 
n/a

Del Duio

Born in a Bowling Alley

Registered
  29/07/2005
Points
  1078

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!Evil klikerHasslevania 2!The OutlawSanta Boot
11th May, 2013 at 11/05/2013 14:23:55 -


Originally Posted by nim
I'm always amazed that you make these awesome code examples and just give them away. Have you considered setting up a small website with all of your examples so far? I know they're all on skydrive but I mean something more like nivram's site.



No kidding!

Sketchy, do you have some sort of job doing this stuff or is it a hobby? You and Pixelthief come up with some ulta-amazing stuff and it never ceases to amaze.

 
--

"Del Duio has received 0 trophies. Click here to see them all."

"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"

DXF Games, coming next: Hasslevania 2- This Space for Rent!

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
12th May, 2013 at 12/05/2013 01:28:23 -

Thanks very much - and no, I don't do any of this for a job (I'm actually an outdoor activities guide - sea kayaking, rock climbing, coasteering, etc). It would be nice to eventually release a commercial game though, if I can ever be bothered to finish one...

To be honest, none of it's really that innovative - I mostly just find interesting ideas on other programming sites, and then try to replicate them in MMF2, so someone else has already done the hard work.
I think I enjoy just tinkering and solving problems more than I enjoy actually making games (mainly because graphics are so much hassle), and since I never finish games myself, I may as well share what I do make.

 
n/a

Del Duio

Born in a Bowling Alley

Registered
  29/07/2005
Points
  1078

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!Evil klikerHasslevania 2!The OutlawSanta Boot
12th May, 2013 at 12/05/2013 15:55:32 -

You've always been very helpful to everybody either here or on Clickteam's site.
I for one don't think you'll have any trouble getting help for any commercial game you decide to eventually make!




 
--

"Del Duio has received 0 trophies. Click here to see them all."

"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"

DXF Games, coming next: Hasslevania 2- This Space for Rent!
   

Post Reply



 



Advertisement

Worth A Click