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

Author Topic: Support for blend color  (Read 9088 times)

0 Members and 1 Guest are viewing this topic.

mphe

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Support for blend color
« on: October 12, 2018, 01:40:46 am »
I was wondering why there's no support for blend colors. There are implementations for all regular blend modes but not for blending with a constant color.

The only way to achieve such a result seems to be by using vertex colors.
But why iterate over the mesh everytime the color changes to update the vertex colors, when there's already a corresponding OpenGL blend mode available?

For certain color effects, like color flashing, you would need to update the vertex colors every frame. Depending on mesh size and the amount of objects that are affected, this seems like quite a bit of unnecessary overhead.

Is there a reason why this isn't supported yet? Are there any plans to support it in the future?

AlexAUT

  • Sr. Member
  • ****
  • Posts: 396
    • View Profile
Re: Support for blend color
« Reply #1 on: October 12, 2018, 10:39:53 am »
Out of curiosity, which blend mode does reproduce that behaviour? List

I would do it with a very simple shader, just add one uniform (vec3 or vec4) to the vertex shader and add it to the color of the vertex. I can post a working example if you are not familiar with shaders.


AlexAUT

FRex

  • Hero Member
  • *****
  • Posts: 1839
  • Not doing gamedev/using SFML lately
    • View Profile
    • Email
Re: Support for blend color
« Reply #2 on: October 12, 2018, 11:02:25 am »
Quote
Out of curiosity, which blend mode does reproduce that behaviour? List
GL_CONSTANT_COLOR?
I'm not using SFML nor doing any gamedev lately.

AlexAUT

  • Sr. Member
  • ****
  • Posts: 396
    • View Profile
Re: Support for blend color
« Reply #3 on: October 12, 2018, 11:38:31 am »
I thought he is trying to add a constant amount to each channel.  ::)

FRex

  • Hero Member
  • *****
  • Posts: 1839
  • Not doing gamedev/using SFML lately
    • View Profile
    • Email
Re: Support for blend color
« Reply #4 on: October 12, 2018, 11:48:37 am »
Adding isn't what Vertex color does (which he says does the same thing as this blending he wants).
I'm not using SFML nor doing any gamedev lately.

mphe

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: Support for blend color
« Reply #5 on: October 12, 2018, 01:54:53 pm »
Out of curiosity, which blend mode does reproduce that behaviour? List

As FRex said, GL_CONSTANT_COLOR.
There's also a glBlendColor function for setting the corresponding color.

It would be possible with shaders, but that seems a bit overkill for such a simple task.

Hapax

  • Hero Member
  • *****
  • Posts: 3050
  • My number of posts is shown in hexadecimal.
    • View Profile
Re: Support for blend color
« Reply #6 on: October 15, 2018, 09:58:55 pm »
Is it this sort of thing that you were wanting?
https://github.com/Hapaxia/Lens/blob/master/Lens/blendColor.frag
Selba Ward - SFML drawables
Kairos - Timing Library
Rectangular Boundary Collision - Rectangular SAT Collision

@Hapaxiation - Hapaxia on Twitter

mphe

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: Support for blend color
« Reply #7 on: October 17, 2018, 03:19:15 pm »
No, as far as I know the blend color is multiplied with the pixel color.
And I know this is possible to do with shaders, but that wasn't the question.

The question / feature request was to add support for blend colors in SFML blend modes, as it is already supported in OpenGL by glBlendColor and the GL_CONSTANT_COLOR related modes.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10157
    • View Profile
    • development blog
    • Email
Re: Support for blend color
« Reply #8 on: October 17, 2018, 08:48:37 pm »
What would you propose as an API design?
Official FAQ: https://www.sfml-dev.org/faq.php
Nightly Builds: https://www.nightlybuilds.ch/
——————————————————————
Dev Blog: https://dev.my-gate.net/
Thor: http://www.bromeon.ch/libraries/thor/

FRex

  • Hero Member
  • *****
  • Posts: 1839
  • Not doing gamedev/using SFML lately
    • View Profile
    • Email
Re: Support for blend color
« Reply #9 on: October 17, 2018, 09:22:25 pm »
Add more enum values to Factor and a Color field to BlendMode and apply it in applyBlendMode if factor is one for GL_CONSTANT_COLOR?
I'm not using SFML nor doing any gamedev lately.

mphe

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: Support for blend color
« Reply #10 on: October 18, 2018, 03:10:06 am »
Agree with FRex.
Seems like the most straight forward design for this.

FRex

  • Hero Member
  • *****
  • Posts: 1839
  • Not doing gamedev/using SFML lately
    • View Profile
    • Email
Re: Support for blend color
« Reply #11 on: October 20, 2018, 02:14:31 am »
Should I open an issue for this?
I'm not using SFML nor doing any gamedev lately.

mphe

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: Support for blend color
« Reply #12 on: October 25, 2018, 09:47:16 pm »
Not sure if that question goes to exploiter or me, but in case of the latter: yes, please

FRex

  • Hero Member
  • *****
  • Posts: 1839
  • Not doing gamedev/using SFML lately
    • View Profile
    • Email
Re: Support for blend color
« Reply #13 on: October 25, 2018, 11:01:47 pm »
I was asking like Exploiter or Laurent. :P
I'm not using SFML nor doing any gamedev lately.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10157
    • View Profile
    • development blog
    • Email
Re: Support for blend color
« Reply #14 on: October 26, 2018, 12:22:17 am »
Yes, please. :)
Official FAQ: https://www.sfml-dev.org/faq.php
Nightly Builds: https://www.nightlybuilds.ch/
——————————————————————
Dev Blog: https://dev.my-gate.net/
Thor: http://www.bromeon.ch/libraries/thor/

 

anything