Jump to content
  • Advertisement
Sign in to follow this  
SoulBuster

Can PixelShader benefit to Palette-based games?

This topic is 4954 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

There is a 2D fighting game called Guilty Gear XX Reload for PC which is a direct port of its PS2 console version. This game uses lots of palette animation, and very eye candy. In its config menu there is an option for "Palette Effect" which can be Standart or Simple. But when Pixel Shader option for GFX Drawing Process enabled, Palette Effect options gets grayed/disabled. That made me think like that : If you don't use pixel shader it will use Palettizated Textures, and methods like SetPaletteEntries() and SetCurrentTexturePalette() of IDirect3DDevice object, otherwise it will implement palette feature through pixel shader. Is something like this possible? or is my theory wrong? Or can it be related to PS2 hardware? Using ps might have made gfx methods' porting easier... Since I'm no PS GURU, I ask you GURUs ;)

Share this post


Link to post
Share on other sites
Advertisement
You can implement palette lookups on pixel shaders, by putting the color map into a texture and using a palette index to look up colors from it. The inconvenience is that pixel shaders "like" to work with discrete floating-point values instead of precisely-indexed arrays (of which group the palette is a member of) and therefore - due filtering - can provide in-between results from the lookups (which is bad here, but good for "conventional" use of textures).

By disabling texture filtering, though, nearest-neighbour lookup is a viable emulation for truly integer-based array indexing.

The unfortunate part of this solution is that on some graphics cards, the user can force texture filtering on an off from the driver settings; thus, you cannot assume that the palette lookups function as you intended, just wish for the best.

Finally, your post would belong to "Graphics programming and theory" board [wink]

Share this post


Link to post
Share on other sites
I think a simple fix for filtering would be to make the texture have each color say 5 pixels in a line, then try to sample the middle one and filtering shouldn't interfere too much (at least with the current methods of filtering)

Share this post


Link to post
Share on other sites
Quote:
Original post by Extrarius
I think a simple fix for filtering would be to make the texture have each color say 5 pixels in a line, then try to sample the middle one and filtering shouldn't interfere too much (at least with the current methods of filtering)


Nice hack, didn't think of that [smile] Then again, I seldom need to sample textures by integers in my projects.

Anyway, 4 or 8 would probably be better values to multiply with here than 5 - gfx cards still perform more efficiently with powers of 2 rather than arbitrary values, regarding texture dimensions.

Share this post


Link to post
Share on other sites
Quote:
Original post by Nik02
Quote:
Original post by Extrarius
I think a simple fix for filtering would be to make the texture have each color say 5 pixels in a line, then try to sample the middle one and filtering shouldn't interfere too much (at least with the current methods of filtering)


Nice hack, didn't think of that [smile] Then again, I seldom need to sample textures by integers in my projects.

Anyway, 4 or 8 would probably be better values to multiply with here than 5 - gfx cards still perform more efficiently with powers of 2 rather than arbitrary values, regarding texture dimensions.

Now that's just a padding issue. Odd numbers are better suited because fínding the middle of 4 or 8 pixels isn't quite possible using ints [wink].

Share this post


Link to post
Share on other sites
It's not necessary to find the actual centers. The purpose is to "isolate" the color with the adjacent pixels of same color, effectively bypassing the effects of filtering even if the actual texel filter is active.

In the end, you're right, though - the powers of two is a padding issue [wink]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!