change certain colors in a texture?
I have some .PNG files that I am assigning to 2DTexture objects. Certain areas of these .PNG will be a certain color, say orange.
Is it possible in XNA to say "change all pixels that are set to orange to red"
What I am trying to accomplish is to make ONE set of animated sprites ... but have 2 sides using the same set ... one side will have orange coloring ... the other will have red coloring ... without having to make two seperate sets.
You have a pixel shader test for a certain colour and replace it with another colour. Something like:
float4 colour = tex2D(texture, coord);
if (colour == ORANGE) colour = gSideColour;
Another way is to have another texture or channel (if your alpha isn't used) to mark where to multiply, add or lerp another colour. This allows for a better visual effect, with gradients, instead of just one colour. For example (assuming alpha).
colour.rgb = lerp(colour.rgb, gSideColour, colour.a);
float4 colour = tex2D(texture, coord);
if (colour == ORANGE) colour = gSideColour;
Another way is to have another texture or channel (if your alpha isn't used) to mark where to multiply, add or lerp another colour. This allows for a better visual effect, with gradients, instead of just one colour. For example (assuming alpha).
colour.rgb = lerp(colour.rgb, gSideColour, colour.a);
Quote:Original post by ET3D
You have a pixel shader test for a certain colour and replace it with another colour. Something like:
float4 colour = tex2D(texture, coord);
if (colour == ORANGE) colour = gSideColour;
Another way is to have another texture or channel (if your alpha isn't used) to mark where to multiply, add or lerp another colour. This allows for a better visual effect, with gradients, instead of just one colour. For example (assuming alpha).
colour.rgb = lerp(colour.rgb, gSideColour, colour.a);
I can't seem to find "float4" -- ???
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement