Palette animation

Sage
Posts: 1,403
Joined: 2005.07
Post: #1
I've got graphics files that I can load but when I draw them its a mess because its two images in one files, palette animation is used to fade from one to the other (this is all done with QuickDraw but for reasons I wont mention I dont want to use QuickDraw).
Whats the quickest way to redraw an image or pixels, with an animated palette.

I dont mind relying on the extension GL_ARB_imaging, if that would be useful but I can find little information on it just now.

It would be best to be able to use texturing to achive this, but if regenerating texture's in runtime with different palettes I'd like to know about any possible alternatives, at a last resort I will just have to pre-render amounts of textures.

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #2
So wait, are you trying to fade from one picture from another? If that's the case, you can just have 2 textured quads (if you don't need mipmapping, you could even use GL_TEXTURE_RECTANGLE_ARB. You can then draw the one you're fading in on top, and step from alpha = 0 to alpha = 1, then stop drawing the previous one. (you'll want the texture to be set to GL_MODULATE for this) If this isn't what you want, can you be a little more specific?

Edit: corrected the flag for a rectangular texture
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #3
Good plan, I can do that if the palette animation is too slow,

Whats actually inside this image file I have is two images in the same place really, viewed with one palette I see the macplay logo and with another the id logo, a fade between them is done by tweening from on palette to the other.

What I'd like to do is draw textured quads with a indexed color data but put that through some palette to achieve the same effect, of course if this is slow I will be able to pre-render different palettized versions of the textures and use alpha like that,

thanks for the idea.

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Oldtimer
Posts: 834
Joined: 2002.09
Post: #4
Palette animation through OpenGL is not supported under Mac OS X. Which is a good thing. Wink
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #5
Not if you have palettized graphics files that you want to render quickly Annoyed

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #6
I think its probably impossible actually, when you do glTexImage2D there's no indexed color mode so I think I'll have to just convert everything to RGB.

edit: please, someone correct me if im wrong.

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #7
There is no internal indexed format, but you can specify your client format as GL_COLOR_INDEX and have OpenGL do the palette mapping for you during texture upload. Read the glPixelMap and glPixelTransfer man pages.

Since this is CPU-side processing during texture upload, it might be too slow to animate textures. So if all you want to do is cross-fade two textures, you are probably better off uploading two textures and using alpha modulation, as mentioned above. But, you can still have GL do the mapping for you while uploading those two textures.
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #8
Oh well, at least this way I do not have to manually lookup my table and convert each pixel of my texture's.
Thanks!

edit: Got it working, thanks very much!

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #9
If you can use fragment shaders, you can use a 1D NEAREST-filtered texture as the palette, and a 2D, NEAREST-filtered, 1-channel texture as the indexed image, and use the fragment shader to perform the mapping. Then palette animation is a matter of swapping or updating the palette texture.

Doesn't sound like you need this here, but if you're porting something that has lots of palette animation, it might be useful.
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #10
yes, I would have liked to but sadly I can't do shaders my graphics cards not good enough.

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #11
Not to mention the fact that the requirements (for the video card) would be horrendously high considering it's a port from a game 14 or so years ago...
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  glsl matrix palette OptimisticMonkey 4 5,551 May 17, 2011 10:23 PM
Last Post: OneSadCookie