OpenGL / Paletted textures

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
Post Reply
BlackAura
DC Developer
DC Developer
Posts: 9951
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Sun Dec 30, 2001 9:02 am
Has thanked: 0
Been thanked: 1 time

OpenGL / Paletted textures

Post by BlackAura »

I'm doing some more work on DCBasic, and I've been adding support for 8-bit and 4-bit paletted textures. The Dreamcast itself can handle these just fine - it has a colour table with enough entries for 1024 colours (4 separate palettes for 8-bit textures, or 64 palettes for 4-bit textures), and I can get / set these colour palettes quite easily.

Hopefully, it should be obvious why I want to implement this. Using paletted textures would allow people to do all kinds of effects that are difficult to do otherwise (like colour cycling), 8-bit and 4-bit textures use less RAM and disc space, it lets you re-use the same artwork with a different colour palette, and so on. So it's a good thing to have for 2D games.

The problem is PC-side support. I'm using the GL_EXT_paletted_texture extension for paletted texture support. However, it's not supported on any ATI cards, or newer (or ancient) nVidia cards. So, although it should work fine on my system (GeForce FX 5200), it wouldn't work if you had an ATI card, or a GeForce 6xxx. The problem isn't just that the drivers don't support it - the required hardware support isn't there either, so using Direct3D (eww...) wouldn't help either.

So, what's a guy to do? The rest of the system will run just fine without paletted textures, but at the moment you'll just get a little white rectangle instead of a paletted texture if the extension isn't supported. If people actually use paletted textures in a game (quite likely - we have more than a few pixel artist laying around), the game will simply be a white screen, and therefore unplayable.

I've not done much investigation into fragment programs (or pixel shaders in DirectX-speak) and similar, but would it be possible to use them to simulate paletted texture support? I really don't know what they can do, or how powerful they are, so if anyone has any experience in that area, it'd be appreciated.

Other than that, is there any other kind of fallback I can use in case the paletted texture extension isn't there? Recolouring the textures in software is probably out of the question - you could have the same texture used 64 times in a single frame, each time with a different colour palette. I can't really think of any way of doing it that's even remotely efficient. Still, I might have to use it as a last resort fallback.
Alexvrb
DCEmu Ultra Poster
DCEmu Ultra Poster
Posts: 1754
Joined: Wed Jul 17, 2002 11:25 am
Has thanked: 0
Been thanked: 0

Post by Alexvrb »

What about having it color the texture with every palette and storing them all in video memory, how much memory would that consume? I'm sure there's a better way, of course, just curious.
If you have twenty monkeys,
banging randomly on typewriters,
they will in twenty minutes produce the complete source code to World of Warcraft.
BlackAura
DC Developer
DC Developer
Posts: 9951
Joined: Sun Dec 30, 2001 9:02 am
Has thanked: 0
Been thanked: 1 time

Post by BlackAura »

The problem there is that you can change the colour palettes at any time, which means I'll need to constantly re-upload the textures if the colour palettes keep changing.

Ah, the hell with it. That'll have to do at the moment. It's not as if PCs are anywhere near as limited as a Dreamcast is anyway.
User avatar
Stef.D
DCEmu Respected
DCEmu Respected
Posts: 114
Joined: Wed Oct 15, 2003 1:46 am
Has thanked: 0
Been thanked: 0
Contact:

Post by Stef.D »

Hmmm, i would be *very* suprised that ATI card nor newer NVidia cards doesn't support paletted textures.
They were always be used and they still are.
I guess there are others extensions to use them with OpenGL.
I'll look somewhere if i can find something about that.

Edit :

Name Strings

GL_EXT_paletted_texture

...

Support

Intel 810/815.

Mesa.

Microsoft software OpenGL implementation.

Selected NVIDIA GPUs: NV1x (GeForce 256, GeForce2, GeForce4 MX,
GeForce4 Go, Quadro, Quadro2), NV2x (GeForce3, GeForce4 Ti,
Quadro DCC, Quadro4 XGL), and NV3x (GeForce FX 5xxxx, Quadro FX
1000/2000/3000).
NV3 (Riva 128) and NV4 (TNT, TNT2) GPUs and NV4x
GPUs do NOT support this functionality (no hardware support).
Future NVIDIA GPU designs will no longer support paletted textures.
:o


You're right :oops: then if newer card doesn't support anymore paletted texture, you won't be able to do easily the palette rotation effects... and i guess many old games doesn't work anymore because of that.[/code]
Ex-Cyber
DCEmu User with No Life
DCEmu User with No Life
Posts: 3641
Joined: Sat Feb 16, 2002 1:55 pm
Has thanked: 0
Been thanked: 0

Post by Ex-Cyber »

I don't have any NV4x hardware, so I can't test this (and sources are sketchy), but rumor seems to have it that if you can somehow convince the drivers that you've paid the Quadro tax, GL_EXT_paletted_texture will magically appear again (judging from the OpenGL forums, it is very important to a lot of high-end science stuff). However, this may be outdated information that only applies to old NV3x driver revisions, as I don't really know the timeline (I'm generally happy with a 3-year-old card, and if I upgrade it'll be to get passive cooling with a shrunken variant of the same core).
"You know, I have a great, wonderful, really original method of teaching antitrust law, and it kept 80 percent of the students awake. They learned things. It was fabulous." -- Justice Stephen Breyer
Alexvrb
DCEmu Ultra Poster
DCEmu Ultra Poster
Posts: 1754
Joined: Wed Jul 17, 2002 11:25 am
Has thanked: 0
Been thanked: 0

Post by Alexvrb »

BlackAura wrote:The problem there is that you can change the colour palettes at any time, which means I'll need to constantly re-upload the textures if the colour palettes keep changing.

Ah, the hell with it. That'll have to do at the moment. It's not as if PCs are anywhere near as limited as a Dreamcast is anyway.
You could make a couple of render paths if it floats your boat. I've got a good old Geforce 3... uploading lots of data should be fine for AGP and up, but those stuck with PCI solutions would need hardware support for paletted textures, or else I'd figure performance would suck.

OT:
Ex-Cyber wrote:(I'm generally happy with a 3-year-old card, and if I upgrade it'll be to get passive cooling with a shrunken variant of the same core).
What about a passively cooled full sized original? With faster memory, too. Something like this. I personally prefer to always have some form of active cooling, even if its very quiet/minimal. The way I see it, if I have something like an arctic cooling solution where it vents outside the case, that is x amount of heat the rest of the fans do not need to be capable of dealing with, so they can run near silent as well. Of course then there's always water cooling, which is becoming increasingly attractive. At least I know I can get a great deal on a heater core. I wonder if a general-purpose electric fuel pump would work well? Oh my, I've gone even more off topic than estimated...
If you have twenty monkeys,
banging randomly on typewriters,
they will in twenty minutes produce the complete source code to World of Warcraft.
Post Reply