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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - DaiMysha

Pages: [1]
1
Feature requests / Re: Add sf::BlendMode::ReverseSubtract
« on: August 13, 2015, 08:17:44 pm »
Apologies for the unclear answer. Let me try to explain.

What we are trying to achieve is a light that, instead of adding its component to the world, substracts them.
Say you have a purple light (red and blue), if you were to put a blue negative light on it, you would end up seeing a red light. It's what happens with the dark cone in the screenshot, since it's a pure white light, it removes every color in its path resulting in the shadow cone seen.
The underlying calcul here is (255,0,255) - (0,0,255) = (255,0,0)

My Light Manager works in (currently) 3 steps.

First step is the user drawing his world on the screen. Then the light manager draws its lights on its own texture (let's call it the light layer texture) and draws that texture on top of the users' world with a multiply.

To (hopefully) optimize the rendering, every light registered to the light manager also has its own texture in which it pre renders itself and passes onto the light manager to be draw on the light layer texture.

The light manager then adds all the lights textures into his own texture to create the light later which is then drawn on top of the user's world.
The idea of a negative light would be that instead of adding it to the light layer, it is substracted from it.

That's why it's not possible for me to invert the two texture concerned, the light manager's light layer and the lights's pre rendered texture. Inverting them would mean that i draw the light layer on top of a light's inner texture, and that cannot work.

Quote from: Hapax
What blue rectangle?
It doesn't see well because the window is dark, but at the origin of the dark cone, in the screenshot, there is a blue square representing the player's position.

Quote from: Hapax
What is the destination and what is the source?
In this case, the result is what you see on the screen (the black cone, after multiplying it to the user's world),
the destination is the light manager's light layer texture and the source is the light's pre-rendered texture

If we suppose layers are added from left to right, what i'm trying to achieve here is :
[users's world] * [light manager base color + lights - negative lights]

The issue here being the - negative lights part. We could have it by using a shader or pure OpenGL code but we simply don't understand why this option hasn't been made available right from the start.

Quote from: Hapax
Not sure why min and max are required.
I don't know why they would be, but i don't see a reason not to include them. They've been made available by OpenGL so why not ? And if one day someone actually finds a use to them, he'll be happy that they are available and don't find themseves in my position.

Hopefully this answer is clearer regarding our intentions and issue.

2
Feature requests / Re: Add sf::BlendMode::ReverseSubtract
« on: August 13, 2015, 03:39:28 pm »
I'm the one who initiated the light system project.

We did some testing with a local fork of SFML and implemented the modification (which consists of 13 changed lines)

Tried it using that custom version and the result is as expected, see screenshot below.
The light emitted from the blue rectangle is white negative and cancels the lights emitted everywhere else.

If you know a way to do this without using the gl reverse subtract function reaching the result given in the screenshot i am curious because we didn't find anything that worked.

What is the expected result?
According to this documentation, the reverse subtraction is the source being subtracted from the destination rather than the destination being subtract from the source.
Can you not form this in an sf::BlendMode?

We cannot. I am rendering the lights individually on a global RenderTexture that I then draw on the window. It's not possible to invert the two textures.

The expected result is this one:

result = destination - source

That is exactly what GL_FUNC_REVERSE_SUBTRACT does

Pages: [1]
anything