Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (487)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (553)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Tileset Generating Algorithm  (Read 2170 times)
0 Members and 1 Guest are viewing this topic.
Offline mudman

Junior Member




Here we go again...


« Posted 2006-03-20 11:46:05 »

I was wondering if anyone knew a good algorithm to generate power-of-two textures from a set of smaller tiles/sprites?
Problem: A number of tiles/sprites of different dimensions should be placed in one or more images of power-of-two dimensions, wasting as little space as possible.
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #1 - Posted 2006-03-20 11:54:33 »

If you can do the work offline, then nVidia's tools might be worth a look: http://developer.nvidia.com/object/texture_atlas_tools.html

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline mudman

Junior Member




Here we go again...


« Reply #2 - Posted 2006-03-20 12:40:14 »

Yes, the generation of tilesets should be done by the level-editor. I'll take a look at your link, thanks.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline darkprophet

Senior Member




Go Go Gadget Arms


« Reply #3 - Posted 2006-03-20 14:18:29 »

If you are doing this process offline, no problem. But if you are doing this at runtime (I think thats the best solution IMO), then your going to have to deal with texture coordinate shifting. Basically, find what objects are using this texture, hold them in a list somewhere, shift the texture, then bring the texture coordinates of those objects to the range at which your image is now in.

I might have a go at it myself Smiley

DP

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
Offline mudman

Junior Member




Here we go again...


« Reply #4 - Posted 2006-03-20 14:50:02 »

I'm not quite sure I understand what you're talking about?
As I see it all I need to know when rendering a sprite is the texture that contains it, it's coordinates inside the texture and its dimensions. (+ of course "hotspot" x and y)?
Maybe we're talking about the same thing?
Offline darkprophet

Senior Member




Go Go Gadget Arms


« Reply #5 - Posted 2006-03-20 15:41:00 »

I thought you are using OpenGL because you were referring to POT textures, my bad.

DP

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
Offline mudman

Junior Member




Here we go again...


« Reply #6 - Posted 2006-03-20 15:49:04 »

I might be using OpenGL in the future, atm I'm just using Java2d and drawImage() Smiley
But still it would be preferrable to pack small tiles/sprites into power-of-two sized images since Java2d hardware acceleration probably just pads non power-of-two images - probably wasting huge amounts of VRAM.
It seems like a bin-packing problem which is proven to be NP-complete so I don't expect an optimal solution to this Smiley
Offline Aramaz

Junior Member




Java Games Rock!


« Reply #7 - Posted 2006-03-20 16:28:06 »

Yes it is NP-complete. You can probably come up with some reasonably good heuristic solution by experimenting a little with cut out paper rectangles Smiley

Play XSW: www.xsw.se
Offline Kova

Senior Member





« Reply #8 - Posted 2006-03-21 01:45:22 »

Sorry for offtopic. I'm new to java 2d and don't quite get what are you talking about so please let me see if I understood... if you use images with size that has form of x^2 where x is natural number, drawing is better? Can someone please explain in more detail or give a link. We're talking about size as in width and height or byte usage for storing?
 Huh
Thank you.
Offline mudman

Junior Member




Here we go again...


« Reply #9 - Posted 2006-03-21 08:12:23 »

Java2D hardware-accelerates BufferedImages that are compatible with the screen.
It caches the image in a texture in video RAM - and on many graphics cards textures need to have dimensions that are whole powers of two, (2^x, not x^2). So I can only assume that images that don't have power of two dimensions are padded when cached in VRAM. This could waste quite a bit of VRAM...
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CopyableCougar4 (23 views)
2014-08-22 19:31:30

atombrot (34 views)
2014-08-19 09:29:53

Tekkerue (30 views)
2014-08-16 06:45:27

Tekkerue (28 views)
2014-08-16 06:22:17

Tekkerue (18 views)
2014-08-16 06:20:21

Tekkerue (27 views)
2014-08-16 06:12:11

Rayexar (65 views)
2014-08-11 02:49:23

BurntPizza (41 views)
2014-08-09 21:09:32

BurntPizza (31 views)
2014-08-08 02:01:56

Norakomi (42 views)
2014-08-06 19:49:38
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!