Jump to content
  • Advertisement
Sign in to follow this  
guillotine

D3D9 - Palette shader behaviour with ID3DXSprite

This topic is 2139 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

Hello,

 

I'm very much a newbie with HLSL, but I was able to understand enough to put together a simple shader that would change the colors of indexed, gray-scaled sprites in my 2D engine.

 

Here's the  shader:





Texture ColorTexture;

sampler ColorTextureSampler = sampler_state { texture = <ColorTexture> ; magfilter = NONE; minfilter = NONE; mipfilter = NONE; AddressU = wrap; AddressV = wrap; };

Texture PaletteTexture;

sampler PaletteTextureSampler = sampler_state { texture = <PaletteTexture> ; magfilter = NONE; minfilter = NONE; mipfilter = NONE; AddressU = wrap; AddressV = wrap; };

float4 Palette(float2 pos : TEXCOORD0) : COLOR0
{
	float4 color = tex2D(ColorTextureSampler, pos);
	return tex1D(PaletteTextureSampler, color.r);
}

technique Technique1
{
    pass
    {
        PixelShader = compile ps_2_0 Palette();
    }
}

The only issue is that no matter what I set to ColorTexture, the shader seems to ignore it and use the texture being drawn instead.

I use the Draw method of ID3DXSprite. It's not even a "real" problem I guess since I would want to pass the current texture anyway for this, but I'm curious if there is a way around it without abandoning ID3DXSprite which really does everything I need.

 

Share this post


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

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!