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

Author Topic: BlendMode and RenderTexture not updating  (Read 6879 times)

0 Members and 1 Guest are viewing this topic.

MrMuffins

  • Newbie
  • *
  • Posts: 30
    • View Profile
BlendMode and RenderTexture not updating
« on: March 17, 2016, 09:49:44 am »
Hello, trying to get additive blendmode to work with a lighting system.

Which works of course. Problem for me however, lights will always be "on top" of the screen at all times.

So if I use two framebuffers by adding all lights, then blocking lights to the first, then drawing it to the second buffer, I can achieve my affect.

Which works, except I get this glitch/artifact?


My best explanation, its like the scene isn't clearing when I call .clear(); Even though I clearly am.
If none of the lights move, it works.

Min. working code example:
(click to show/hide)


If I add a rectangleshape with black, and draw it after .clear, it works. But it defeats the whole purpose of clear and also breaks my light blocking sprites.

Anyone know why this is happening? Spent too much time on something so trivial. Don't really want to settle for static lights either.
Thanks.
« Last Edit: March 17, 2016, 09:57:36 am by MrMuffins »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
AW: BlendMode and RenderTexture not updating
« Reply #1 on: March 17, 2016, 11:43:28 am »
What exactly do you mean with glitch? The trapeze? The cut-off edges?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: BlendMode and RenderTexture not updating
« Reply #2 on: March 17, 2016, 01:53:19 pm »
For a minimal and complete example, it would help to provide the texture that is used.

Also:
Assigning two signed ints to a Vector2u is not nice (sf::Vector2u mouse; mouse = { event.mouseMove.x, event.mouseMove.y };).
sf::BlendMode::BlendAdd and sf::BlendMode::BlendMultiply don't exist.
Consider posting code you've actually tried  ;)
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: BlendMode and RenderTexture not updating
« Reply #3 on: March 17, 2016, 02:37:57 pm »
Assigning two signed ints to a Vector2u is not nice (sf::Vector2u mouse; mouse = { event.mouseMove.x, event.mouseMove.y };
Indeed, and not only because of the conversion, but because it's semantically wrong. sf::Window::mapPixelToCoords() should be used.

sf::BlendMode::BlendAdd and sf::BlendMode::BlendMultiply don't exist.
They do. C++11 permits to fully qualify enumerators even in C++98 enums.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

MrMuffins

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: AW: BlendMode and RenderTexture not updating
« Reply #4 on: March 17, 2016, 06:23:16 pm »
What exactly do you mean with glitch? The trapeze? The cut-off edges?

Similar to this http://i.imgur.com/kDMrTbIg.png

As soon as I start moving the lights, all the old places it were remain, creating the effect in my first picture. Like the screen isn't clearing.

For a minimal and complete example, it would help to provide the texture that is used.


I'm sorry, here http://i.imgur.com/kypRCP6.png

Also:
Assigning two signed ints to a Vector2u is not nice (sf::Vector2u mouse; mouse = { event.mouseMove.x, event.mouseMove.y };).
sf::BlendMode::BlendAdd and sf::BlendMode::BlendMultiply don't exist.
Consider posting code you've actually tried  ;)

As example code I didn't really bother with it too much. As for code I tried...I did. Its a complete min. example of it working.

See

Better example of it in action:
« Last Edit: March 17, 2016, 06:28:12 pm by MrMuffins »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: BlendMode and RenderTexture not updating
« Reply #5 on: March 17, 2016, 07:17:48 pm »
Ah you mean when you move the texture around.

What version of SFML are you using?
What's your GPU? (Is your driver up to date?)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

MrMuffins

  • Newbie
  • *
  • Posts: 30
    • View Profile
[Solved] BlendMode and RenderTexture not updating
« Reply #6 on: March 17, 2016, 08:35:14 pm »
Ah you mean when you move the texture around.

What version of SFML are you using?
What's your GPU? (Is your driver up to date?)

SFML 2.1, ASUS Radeon HD 7750, Drivers are up to date

...Well I'll be. Quite embarrassing, I tend to hold off updating. Just updated to SFML 2.3.2 and the problem is gone and the blending/lights work perfectly.

Thanks for helping me out.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: BlendMode and RenderTexture not updating
« Reply #7 on: March 17, 2016, 11:26:05 pm »
Yeah, there has been some bugfixes and improvements around the render texture since 2.1. :)

Glad it's working now.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: BlendMode and RenderTexture not updating
« Reply #8 on: March 18, 2016, 01:45:14 am »
Assigning two signed ints to a Vector2u is not nice (sf::Vector2u mouse; mouse = { event.mouseMove.x, event.mouseMove.y };
Indeed, and not only because of the conversion, but because it's semantically wrong. sf::Window::mapPixelToCoords() should be used.
Exactly.

sf::BlendMode::BlendAdd and sf::BlendMode::BlendMultiply don't exist.
They do. C++11 permits to fully qualify enumerators even in C++98 enums.
BlendAdd, BlendMultiply etc. are not enums. They're constant BlendMode objects.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: BlendMode and RenderTexture not updating
« Reply #9 on: March 18, 2016, 11:56:45 am »
In SFML 2.1 they were enums. But you're right, fully-qualified enumerators is one of the subtle situations that's not backwards-compatible. There's also a few others related to this change, but most people shouldn't be affected.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

 

anything