Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualSteve_Segreto

Posted 26 November 2012 - 02:22 AM

Replacing my default sprites with a greyscale one is kinda tedious, and I am hoping there's a better way.


I wonder if tinting the player would be good enough instead of a full palette swap ... don't use your existing palette swapping pixel shader, instead treat the image of your character as a greyscale by sampling the original texture and ignoring 2 out of the 3 color channels, then multiply the greyscale by a passed in tintcolor to make the player a different color.

float4 originalColor = tex2d( TexSampler, tex0.xy );
float4 greyColor = float4( originalColor.r, originalColor.r, originalColor.r, originalColor.a );
float4 newColor = greyColor * tintColor;

where you pass tintColor in as a uniform extern.

You might have to experiment with which channel you want to use as the grey scale (r,g or b).

#1Steve_Segreto

Posted 26 November 2012 - 02:21 AM

Replacing my default sprites with a greyscale one is kinda tedious, and I am hoping there's a better way.


I wonder if tinting the player's would be good enough instead of a full palette swap ... don't use your existing palette swapping pixel shader, instead treat the image of your character as a greyscale by sampling the original texture and ignoring 2 out of the 3 color channels, then multiply the greyscale by a passed in tintcolor to make the player a different color.

float4 originalColor = tex2d( TexSampler, tex0.xy );
float4 greyColor = float4( originalColor.r, originalColor.r, originalColor.r, originalColor.a );
float4 newColor = greyColor * tintColor;

where you pass tintColor in as a uniform extern.

You might have to experiment with which channel you want to use as the grey scale (r,g or b).

PARTNERS