Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Is it possible to make full white sprite?  (Read 2801 times)

0 Members and 1 Guest are viewing this topic.

underww

  • Newbie
  • *
  • Posts: 34
    • View Profile
Is it possible to make full white sprite?
« on: January 29, 2018, 03:31:53 pm »
I'm trying to make the sprites white shortly when characters take damage.
Some solutions I found are making white images by hand then swap the sprites or using shaders.

I don't like both solutions for a couple of reasons.
(There're a lot of images and I change the images often. and also I don't want to use shader for now.)

I was trying to make the white sprite using sf::BlendMode, but I could make only white sprite with black background.
(It seems because of the transparent area of the images.)

So I want to know if it is possible to make full white sprite without making white image or shader.
Thanks in advance. :)

Paul

  • Jr. Member
  • **
  • Posts: 78
    • View Profile
Re: Is it possible to make full white sprite?
« Reply #1 on: January 29, 2018, 05:53:35 pm »
In OpenGL it's possible even without shaders:

// Set color, your case
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB );
glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB,  GL_REPLACE );
glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB,  GL_PRIMARY_COLOR_ARB );
 

// Mix colors
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
 

But I'm not sure if it's in any SFML functions.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Is it possible to make full white sprite?
« Reply #2 on: January 29, 2018, 06:54:37 pm »
No, this is not exposed in SFML. Maybe you can call these functions directly and get what you want when drawing with SFML, but I wouldn't do that. It's a pretty old and limited way to do it, if it was me I'd definitely go with a fragment shader.
Laurent Gomila - SFML developer

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Is it possible to make full white sprite?
« Reply #3 on: January 29, 2018, 11:12:03 pm »
I created some simple, quite generic, shaders a while back called (Lens) and one of them could do this for you, if you do choose the shader route.

Try this one:
https://github.com/Hapaxia/Lens/blob/master/Lens/blendColor.frag

In this shader, it just replaces all colours in the texture with the colour given to the drawable (sprite etc.); the transparency remains the same. It does this instead of 'multiplying' the colour with texture as is the default state (without shaders). The 'amount' uniform simply sets how much of this effect should apply. Anything from zero (original texture) and one (only the specified colour). So, for this effect, simply set the uniform 'amount' to 1.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

underww

  • Newbie
  • *
  • Posts: 34
    • View Profile
Re: Is it possible to make full white sprite?
« Reply #4 on: January 30, 2018, 02:55:06 pm »
Thanks for the answers. I'll try some.