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.
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.
Hopefully this answer is clearer regarding our intentions and issue.
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.