Remapping of colors?

Post: #1
Hi folks. I'm trying to do a remapping of colors. I had created a routine which would read the backbuffer into main memory, remap using a custom CPU routine, and then DrawPixels back. But obviously it's slow and I want to get it fully into GPU hardware acceleration.

I then tried the following code, as an alternative, which works on my ibook with software OGL but not on the imac with hardware OGL. It tries to use glCopyPixels with a color remapping table. (it's actually slower than my custom routine because my custom routine only remaps about 20 of the colors - les mem access). There is a problem in that when I enable the color mapping with GL_COLOR, the glCopyPixels refuses to copy any pixels. If I disable the GL_COLOR it will copy the rect but obviously without any remapping. Any ideas there?

Also, is there a way I can remap a whole range of numerous colors to other colors using OpenGL? (currently v1.2 and no OGLSL). ???? I really need to get the whole thing into hardware if I can. I'm trying to use all kinds of combinations of blending and stencilling but not much luck without saving off a buffer and uploading it in some way.

Thanks for your ideas on this.

'Define remapping for use with glCopyPixels
Local redmap:Short[256]
Local greenmap:Short[256]
Local bluemap:Short[256]
For Local index:Int=0 To 255
    redmap[index]=Short(Rand(0,255) Shl 8)
    greenmap[index]=Short(Rand(0,255) Shl 8)
    bluemap[index]=Short(Rand(0,255) Shl 8)

...some other code is in here

Quote this message in a reply
Posts: 5,143
Joined: 2002.04
Post: #2
What hardware are you using? If you've got a GeForce3, GeForce4Ti, Radeon 8500 or better, you can do it in hardware, with more or less pain depending on precisely which card you have and precisely what you need to do. For cards before then, doing the processing on the CPU is probably as good as it gets.
Quote this message in a reply
Post: #3
Umm ... its an NVidia GeForce 4MX

What I need to do is render a bunch of images to the backbuffer, which will involve some alpha blending and so on, and then perform a color remapping of various colors or components to others. If I could remap a range of 20 colors to another 20 colors, and then maybe two more sets like that, it would suffice.
Quote this message in a reply
Posts: 1,234
Joined: 2002.10
Post: #4
The GL 1.1 functionality your GF4MX supports can't do what you want with hardware acceleration, sorry.

Doing your initial drawing via render-to-texture, and using EXT_paletted_texture would probably work, and be hardware accelerated. Unfortunately, EXT_paletted_texture is deprecated as of 10.3.4 and isn't exported any more. And it was never supported on any ATI hardware.

Of course a fragment program could do this in hardware, but not on a GF4MX.
Quote this message in a reply
Post: #5
I need to not use any extensions, must be plain old OpenGL 1.2
Quote this message in a reply
Posts: 5,143
Joined: 2002.04
Post: #6
that's a very strange requirement...

But it puts you completely out of luck. Not a chance. NWIH. Not nohow, not never.
Quote this message in a reply
Post: #7
Oh. Well I found a way, thanks anyway.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Lighting and changing texture colors in OpenGL agreendev 2 10,963 Aug 13, 2010 03:47 PM
Last Post: agreendev
  Reading texture colors values Leroy 6 6,923 Jul 24, 2007 10:06 PM
Last Post: Leroy
  Where'd My Colors Go? Nick 13 8,658 Mar 25, 2005 06:34 PM
Last Post: tigakub
  About transparent colors un textures valle 2 4,087 Oct 26, 2004 09:52 AM
Last Post: valle