Log in

View Full Version : Another Q for a 2d engine: Vector Gfx


Karukef
07-20-2004, 10:04 AM
Vector graphics is really neat because it allows arbitrary scaling. On the other hand, in the wake of endless flash movies, the style often associated with vector graphics is becoming (and has been) very dull.

I know it is possible to convert a regular handrawn bitmap into vector format and retain as much detail as wanted. In my very little experience from using flash I remember the authoring program had such a conversion built in, but I no longer remember the quality and filesize. I do however remember that a sophisticated fractal based rescaling program could convert a bitmap into a higher quality scalable bitmap (I kid you not, _higher_ quality with amazing scalability), but that technology has to my best knowledge been bought up and used for god-knows-what. (I have seen it as a photoshop plugin though)

What I am getting at, does anyone know of good scaling possibilities for bitmaps? (Blurred scaling not acceptable) Vector conversion, fractal calculations - whatever. It would be interesting to create a 2d engine that does resolution independency regardless of the bitmaps used for graphics wouldn't it?

Karukef
07-20-2004, 10:08 AM
By the way, here is the site for the company that has the Fractal Image technology right now - http://www.altamira-group.com/

It is now called "Genuine Fractals" and if anyone want to try it out the trial photoshop plugin is called "Genuine Fractals PrintPro 3.5 Trial"

gfm
07-20-2004, 11:06 AM
My 2D engine uses vector graphics. Basically, all the graphics for the whole game are stored in SWF (Flash) format. Instead of using Flash Player, I've built my own engine which takes the SWF files and converts them to bitmap sprites for runtime. The pros are small file sizes (good for download size) and the screen resolution can be dynamically resized and I can rerasterize the vector graphics to match the new resolution -- so they are resolution independent.

Link to Info (http://www.mischief.com/zblocks)

I'm using a highly modified version of gameswf to render the SWFs to 2D bitmaps. Another option would be just use gameswf as-is to get 3D accelerated vector graphics rendering, but for me, supporting old 2D hardware was important.

Also, to answer one of your direct questions... There are many ways to turn a bitmap into a vector graphic, including a bitmap tracer built into Flash that is very good at what it does (there are other options too like Adobe Streamline, but I haven't had much experience with them). Keep in mind though, that these tools usually don't employ any sort of sophisticated algorithms to try to replace large areas of color with gradients or anything, so you end up with a LOT of single-color filled shapes in the vector version which means the file size will be very large (possibly larger than the bitmap) and it doesn't look all that great scaled up. These bitmap tracers can be useful as a first step, to get something into a vector format for further editing, but you can't just have them convert bitmap->vector and expect the results to be immediately useful, you'll need to tweak the results (sometimes quite a lot) to really take advantage of the vectors.

Karukef
07-20-2004, 12:16 PM
These bitmap tracers can be useful as a first step, to get something into a vector format for further editing, but you can't just have them convert bitmap->vector and expect the results to be immediately useful, you'll need to tweak the results (sometimes quite a lot) to really take advantage of the vectors.

This is really good information. I will only implement a resolution-independent 2d engine if it can automagically support any 2d bitmap produced by an artist. I absolutely know it can be done, as the amazing Genuine Fractals plugin for photoshop demonstrate, but I guess the real issue is that unless some available code for such technology exists I will have to hire a very skilled programmer to create it from scratch.

Well, if anyone do know about such technology that is also available (paying "indie size" money for it is perfectly acceptable) then please speak up :)

gfm
07-20-2004, 12:22 PM
The fractal approach seems like the right solution to your specific problem.

Be careful of patents though, I believe most of the fractal image systems are covered by patents that might cause you to have to pay patent fees even if you find freely available source/build your own/hire someone to do it for you.

Karukef
07-20-2004, 12:31 PM
That's exactly what I mean with an "available" version. Those technologies are really patanted silly.

I am however considering if it is possible to create a non-realtime more sophisticated version of the scale2x and similar algorithms. But then there is the problem of handling a resolution that is, lets say, 25% or 28% bigger than the original resolution.

Well, I have to admit that I am very comfortable with simply letting my engine run at only one resolution. Pixel art is, after all, pixel art and may be too fragile to stand computational resizing.

The only way to get really good resolution-independent graphics is to use a fairly high resolution for the screen and have the graphics drawn at an even higher resolution, and even then there would be issues with sharp features disappearing.

erikh2000
07-20-2004, 04:32 PM
This is really good information. I will only implement a resolution-independent 2d engine if it can automagically support any 2d bitmap produced by an artist. I absolutely know it can be done, as the amazing Genuine Fractals plugin for photoshop demonstrate, but I guess the real issue is that unless some available code for such technology exists I will have to hire a very skilled programmer to create it from scratch.
This part confuses me. Why are you worrying about writing this functionality into your game? Possibly, I misunderstand your situation, but it seems you could use existing tools such as the fractal plugin or Flash to get your artist's bitmaps into a vector format. Your game engine would just concern itself with displaying vector graphics, like what GFM and other people have done. And that part by itself is hard enough to code!

-Erik

Karukef
07-21-2004, 10:40 AM
Well, you are misunderstanding a slight bit. The reason I dont simply incorporate this into the engine is because good looking pixel graphics becomes less good looking when scaled. Good looking vector graphics scales perfectly well, but creating vector graphics is hard work. If an automatic conversion to vector graphics would retain all the fidelity of the original image it would be an excellent solution but right now no such tool does a good enough job to my knowledge.

Anyway, I only asked because it's nice to have these "possibly interesting alternatives" out of the way :)

Lerc
07-21-2004, 04:11 PM
That's exactly what I mean with an "available" version. Those technologies are really patanted silly.

I am however considering if it is possible to create a non-realtime more sophisticated version of the scale2x and similar algorithms. But then there is the problem of handling a resolution that is, lets say, 25% or 28% bigger than the original resolution.

I have had a play around with various scaling algorithms, and I came up with a good hybrid scaling algorithm that was roughly Scale2x mixed with bilinear interpolation. I also extended the Scale2x edge check to spot 2:1 gradients.

Here's an image showing the results an old 320x200 game that I worked on a number of years back.
http://www.screamingduck.com/Cruft/DrakeScale.png
The version of the scaler in that image is a little rough around the edges (literally) because it is a realtime implementation.

Scale2x checks for equivalence between nearby pixels. It works well on old games becaue they are usually paletted. An image in 24 bit may have no equal pixels beside each other because the values differ by a tiny amount. This would cripple Scale2x.

The solution would be to use Fuzzly logic. I put together a trial program using A Fuzzy Scale2x, the results For the most part were OK, but for Photos I found Bicubic to do a better job. The Fuzzy solution was good for sprites when you can count the transparency colour as a special case where the differance between the pixel and the transparency is absolute. I also put in a special case that quantised any colour blends that included the transparency colour to either be totally transparent or ignore that component. I actually suspect A bicubic filter that did this for sprites would be particularly usefull as well.

I produced this image showing my results from using Fuzzy Scale2x.
http://www.screamingduck.com/Cruft/wossname.png
The fuzzy logic code can't be used for a realtime solution, takes about a minute per image.


I think I have a pretty good handle on what parts the different algorithms do well. The best solution would be one that does the entire image with all algoritms and tags each pixel with a confidance value on how good it did. You then take the most confidant pixels from each result to produce an overall better image.

Wouldn't be a speedy scaler though.

To answer your other question. The best way to acheive results such as 30% larger when applying a pixel doubler algorithm is to Double then scale down again. You get quite good results. The most amazing thing that I have found is that A lot of images from games look better when Scale2x is applied then a pixel average Scale back down to the original size. The images take on an anti-aliased look. It does depend on the pixel artist however. The very best pixel artists squeeze so much out of individual pixels that mucking with it just a little bit can throw the entire look at.

Karukef
07-22-2004, 11:04 AM
I think I have a pretty good handle on what parts the different algorithms do well. The best solution would be one that does the entire image with all algoritms and tags each pixel with a confidance value on how good it did. You then take the most confidant pixels from each result to produce an overall better image.

Wouldn't be a speedy scaler though.

To answer your other question. The best way to acheive results such as 30% larger when applying a pixel doubler algorithm is to Double then scale down again. You get quite good results. The most amazing thing that I have found is that A lot of images from games look better when Scale2x is applied then a pixel average Scale back down to the original size. The images take on an anti-aliased look. It does depend on the pixel artist however. The very best pixel artists squeeze so much out of individual pixels that mucking with it just a little bit can throw the entire look at.

Excellent information. It's nice to see someone with even more interest in those nifty algorithms than me. I made a fuzzy Scale2x myself once but the doubling/reducing technique was quite nifty. If I am going to implement resolution independency (beyond pure scale2x) in the engine, this information will be what pushed me above the top ;)