Sign in to follow this  
PumpkinPieman

Textures and multiple colour palettes

Recommended Posts

I've been thinking about textures that have multiple colour palettes, I haven't quite got to them but now that they are on the tip of my tongue I might as well ask. With D3DCreateTextureFromFileEx you can specify a colour palette, now that's great and all but down the road I plan on making a small war RTS. What does this mean to me? Does this mean I'm going to have to load up several of the same texture with different colours palettes, or is there some other way I can avoid this? (First thing that comes to mind is pixel shaders but I haven't gotten there yet ...) Thanks.

Share this post


Link to post
Share on other sites
Those arguments allow to store a loaded palette from a P8 image. You must give it null or a pointer to 256 COLORENTRYs (or some name like that...). D3DX will fill in the palette data from the file.

You can then use SetPaletteEntries to set this up as a palette on your device. D3D allows upto something like 16000 palettes to be programmed at once. If your device support it the flags field will actually be alpha. (TEXTURECAPS_ALPHAPALETTE).

You can then use SetCurrentTexturePalette to activate one of your 16000 palettes.

Things to note about palettes:

The palette you specify applies to ALL texture stages, meaning you cannot use multitexturing with two textures with different palettes. (trivia: This does not apply to certain non-PC, but Windows and DirectX based systems).

A GeForce3 in a DX8 app does have P8 support (but not L8 or A8L8).

A GeForce3 in a DX9 app does NOT have P8 support (but has L8 and A8L8).

Other cards my similarly phase out P8.

On GeForce3Ti200s and regular GeForce3s (possibly all cards. Not sure if it was an nVidia or DirectX bug) I noticed that modifying the palette quickly caused a reboot. Inserting Sleep() calls to allow D3D to finish drawing before changing palettes fixed the issue. This meant palettes were nearly useless.

In the end I determined palettes in D3D, if supported, can be used as either an A8 or L8 texture. You set the palette once at device creation / reset and never again. This avoids the reboots. Other fixed palette uses can be used.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this