PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Eye-candy

oh boy oh boy oh boy...this is so sweet I can't hold it away from you guys.

I managed to make the units, buildings and other sprites use an alpha channel. So? what does that mean? Well, it means no jaggies on the edges, because the pixels are semi-transparent (ie. buildings become more of a part of the landscape), building shadows are smooth and are colored by the landscape the fall on. But more importantly: It will mean some pretty cool explosions where you see things through the "fire" and stuff.

Still don't get what I'm saying...well it looks sortof like realtime anti-aliasing.

Think glowing engines, think smoke...the possibilities are quite big...the only thing that restricts us is imagination, timeframes and framerate.

// Fredrik

PS. For all you MOD-people out there. Most 3D software allows rendering of the alpha channel. So building your own units with alpha shouldn't be an issue. DS.
Last modification: Fredrik Malmer - 05/17/01 at 09:33:49
well done
Here is a image that makes it all a bit clearer. The screenshot part of it is a real ingame shot as it looks in the game.

Not even Carpediem has seen this...now you guys go ahead and feel exclusive!

Image

// Fredrik
so how do you do things like this? do you make a 3d model then take shots at various angles or just draw the thing like that?
Moose or Chuck · 17 May 2001, 14:06 UTC
There's only one angle, atleast at present, and it looks to me like it could have been done easily enough (meaning not taking a week or two) using Adobe Photoshop and some choice filters.
It is a 3D model, built in Blender. I rendered it and the alpha channel (which I modified slightly in Photoshop) and created an image, that the game uses.

Oh, this facility might be replaced in the final version of the game. Because I'm not very good at 3D modelling, compared to those who know what they're doing. We're working on getting a real 3D artist...

// Fredrik

Last modification: Fredrik Malmer - 05/17/01 at 12:11:52
Do you even need an alpha channel for this?  If you're using a color-key with your source image and copying pixels manually, you should know where the edges of the image are within the sprite's rect.  Just draw that edge pixel with 50% alpha blending with the destination pixel.  I'm thinking you could RLE the transparent pixels and speed things up a bit.

Granted you might want to use an alpha channel for some of the other effects you've mentioned, but I thought I just throw out this idea for discussion.
Moose or Chuck · 17 May 2001, 16:15 UTC
Alpha channels are fuzzy
Digby:

I could trace the edges of the bitmap, but then I couldn't have things like glowing engines or nice explosions. And most imprtantly. I could kiss goodbye to the nice building shadows.

I can't do RLE by the way because I need to go through the sprites pixel by pixel anyways because I have to check with the z-buffer to see if a pixel is behind a hill or not. Also hills casts shadows on units (yes they do!), so that has to be accounted for too.

But I do know a couple of things here and there that can be optimized so hopefully speed won't be an issue. And units will be quite small too.


Moose:

What do you mean fuzzy?

// Fredrik
Fredrik,

Right you are about glowing effects and translucency, you'll want an alpha channel for that sort of thing.  How many bits is your alpha channel?

I'm saying RLE the *transparent* pixels in your sprite.  Why would you need to perform a Z test on a transparent pixel?

BTW, could you post a larger image of the screenshot you've included in this thread on the web someplace?  It's not much bigger than a postage stamp and I'd really like to have a closer look at your work.  Thanks!
Moose or Chuck · 17 May 2001, 17:26 UTC
Nothing, I like alpha channels, that's all. Alpha channels are good, and fuzzy.
Holy cow... If (when) you get a working public demo and I show this to any Palm RTS fan, he (mostly likely he and not a she...) will probably steal my Pocket PC! This is sweet!

Digby, you should more personally team up with Fred and "Seize the Day"(ahem... Carpedium...)!
Good idea about the RLE coding on the transparent pixels. Thanks!

As for bigger screenshot...well I'm working on the website right now. We will probably have a few of them there.

// Fredrik
Fredrik,

Just a hint on RLE, try encoding runs vertically as well as horizontally.  For some images you'll get better compression that way.
Hey guys,
anyone out there who can explain me what the hell run length encoding gives in this case.
Not only that it's compression is comparable bad, it's also quite useless, at least nowadays nowhere used (well maybe i lay wrong , RLE TIFF's??).

However anyone who can bring light to my smokin' brain.?
We're talking about ingame RLE. To boost performance. The reason for this is that it is way faster to have the engine see "hmm...there is a transparent pixel in this sprite...how many follows it...aha...twenty...then let's skip 20 steps ahead and don't do any prosessing on those pixels."

Sortof...

// Fredrik
So personally I don't really care about compression of the sprites. They don't use much memory/storagespace. It's more of a performance issue.

// Fredrik
I tend to be a bit anal about skipping a few pixels because I'm currently working on the inner loop of a 3D rasterizer which I'm writing in ARM assembly.  I'm always looking to skip pixels whenever possbible for performance reasons.  If textures have been created with spans of like texels (a la RLE), then there are times that I don't have to do a texture fetch.  And if it's a transparent texel then I don't have to do a lot of stuff.

Anyway, none of this is working yet but the ideas keep spewing from my melon.

Fredrik, you using pre-multiplied alpha for those sprites?

Cheers,
Digby

SonicSilicon · 18 May 2001, 11:16 UTC
On the subject of optimizations...
Somewhere I heard of this wonderful idea of "pre-calculated transparency." Essentially the values that the sprite will contribute in an alpha blend is computed ahead of time and saved to a copy (or overwrite the original) that will be used in the actual composition.

Say that there is an explosion sprite. In that explosion sprite there could be full yellow pixel (r:255 - g:255 - b:0) with a bit of transparency (a:191 assuming 255 is opaque.) That pixel will not contribute the entire full bright yellow. Intead it will only contribute 191 of Red, 191 of Green, and no Blue. In pre-calculated transparency that value (r:191 - g:191 - b:0) would be stored in the sprite. When it comes time to mix the sprite with the image behind it, only what the background contributes will have to be calculated. Afterward the values from the pre-calculated transparent sprite are simply added to the result of the background's contribution.
Moose or Chuck · 18 May 2001, 11:23 UTC
wow its actually becoming like a developersforum and stuff, keep up the good work. :)
SonicSilicon,

Why you've just described premultiplied alpha! :)

In the typical alpha blending scenario, the equation for calculation the final pixel color is:

Sc = source color (sprite pixel)
A = alpha
Dc = destination color (screen pixel)

Dc = Sc*A + Dc*(1 - A)

Premultiplied alpha would be storing the result of the Sc*A calculation in the sprite pixel so you don't have to do the multiply.  The (1-A) can be precalculated, so it comes down to multiplying the screen pixel by a constant and adding the source color, then storing the result in the screen pixel.

There's lots of stuff out there on premultiplied alpha blending on the web.  I recommend the article that Alvy Ray Smith authored, "Image Compositing Fundamentals" :
ftp://ftp.alvyray.com/Acrobat/4_Comp.pdf

My alpha stuff is very optimized I would say...I use no floats and no divisions just bitshifts and multiplication.

The way you described with Sc*A + Dc*(1 - A) is basically the way I'm doing it, except for the optimizations used. (So I don't have to have a float alpha of 0.5 or so).

Anyways...I noticed when I do the same sprite without alpha I don't get any performance increase, so my alpha stuff is probably quite fast. There are other things in the game that could be optimized to gain speed.

one thing that I might do is to go through the sprite image at loadtime and separate the three color channels. That would probably give me some speed increase...probably not a lot, but some.

// Fredrik
Fredrik,

Absolutely you don't want to use floating point for these calculations for alpha blending.  I would say that you're better off using the CPU and doing calculations than creating lookup tables for alpha values. I wrote an alphablt routine years ago that used LUTs and it worked pretty well.  Doesn't carry over to this architecture though.

I think the memory bandwitdh is pretty low on these devices and you should do as much as you can to the pixel once you have it in registers.  This isn't always easy to do if you're coding in C/C++.  Still, anything you can do to minimize read/writes to RAM is going to be a win.  

If I have time this weekend, I might write some tests to see just how bad the memory bandwidth is on my iPaq.  I'll post results here (or more appropriately in the Developer Discussion area).

I said I was not using floating point. Think you misunderstood my post. ;)

My stuff is all integers. All the way through. And I'm using bitshifts whenever possible  (bitshifts are FAST!).

As for memory bandwidth tests I think there are some at pocketpcpassion. Either way. Anything that works good on the casio runs like a dream on the iPaq. And since Argentum is beeing written on a Casio EM-500 (me) and a overclocked Casio E-125 (carpediem) it will probably be oh-so-smooth on your iPAQ.

// Fredrik

Last modification: Fredrik Malmer - 05/18/01 at 13:33:47
yeah... and shit on the jornada. thats IF ou release it for sh3. nevermind.
It doesn't have to "run like shit" (*ahem*) on the jornada. The first versions of the game was in 14 fps or so and that was playable. We have to test it and see how it works.

// Fredrik
well excuse me, princess.

what is the font for the small text under the argentum logo anyways?
Diego Cueva · 18 May 2001, 17:54 UTC


what is the font for the small text under the argentum logo anyways?


I dont know, but the logo looks very nice... I like it.
Fredrik,

I was agreeing with your choice to use integer math and bit shifts instead of using floating point.  I probably should have worded that differently.  I guess you misunderstood my post? :)

Anyway, good luck with your project and if you can post some larger screenshots someplace let us know.

Cheers,
Dig



It's my favorite font, called Sevenet 7. We use it in the game too. It is a free font. I'll put it up on the website...you can download it here. The font size is 7, but in Photoshop 6, which I use you have to use 8. Turn of anti-aliasing, since it is a bitmap font.

// Fredrik
From what I remember of various benchmark results, the iPaq is extremely fast both reading and writing to RAM.

Dan East
Speaking of eye-candy...I added an other terrain screenshot to the website, showing of the "mars-style" map with some snow on it.

Oh, and I got the first part of the story down on paper today...it will probably be something you guys like.

// Fredrik