SFML community forums

Help => Graphics => Topic started by: Clairvoire on November 12, 2010, 02:45:44 am

Title: Changing Sprite Hue, Saturation, Brightness
Post by: Clairvoire on November 12, 2010, 02:45:44 am
I'd want to make it so I can edit these values with my sprites.  sf::SetColor and sf::SetBlendMode seem to affect the sprites at a point where this sort of thing would be possible, but I cannot pinpoint where they take place in the source code.

Basically, I just want to know how I can take source_pixel.red, and apply a formula I made to it, before it's wrote to screen_pixel.red

Or maybe that ability already exists.  Would be awesome if it did!  It's the only thing I've missed from SDL, the ability to take control at the pixel level.
Title: Changing Sprite Hue, Saturation, Brightness
Post by: thePyro_13 on November 12, 2010, 04:42:59 am
You could grab the pixels from an image, edit them and then reload them. Seems kind of roundabout. And isn't ideal for sprites which use the same image.

It sounds like a job for shaders.
Title: Changing Sprite Hue, Saturation, Brightness
Post by: Clairvoire on November 12, 2010, 07:56:38 am
Yeah, was hoping to keep images only loaded up once.  But Shaders... I have heard them here and there when I skimmed the documentation, but never sunk my teeth into them really.  I thought they only worked on the screen itself.  I may be wrong, I'll have to investigate!
Title: Changing Sprite Hue, Saturation, Brightness
Post by: Laurent on November 12, 2010, 08:05:32 am
Quote
I thought they only worked on the screen itself. I may be wrong, I'll have to investigate!

True in SFML 1, wrong in SFML 2 ;)