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

Author Topic: Let There Be Light 2  (Read 149395 times)

0 Members and 1 Guest are viewing this topic.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11039
    • View Profile
    • development blog
    • Email
Re: Let There Be Light 2
« Reply #150 on: January 28, 2017, 05:55:27 pm »
Looks nice! Do you have your changes to LTBL2 online somewhere?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Ungod

  • Newbie
  • *
  • Posts: 44
    • View Profile
Re: Let There Be Light 2
« Reply #151 on: January 28, 2017, 06:43:57 pm »
Uploaded it here: https://github.com/Ung0d/light_ungod/tree/master

However, its fully integrated in my engine (uses my quad-tree, depends on my signal system to emit signals when a light of an entity is changed, depends on my logger ect...) so this is not intended to compile in any way. I dont want to make my whole engine open source, hope you understand :)

I merged the things together I liked most of the different reimplementations of LTBL2 posted in this thread and added the stuff I usually have in systems in my engine (component-support, signals ect). I biggest changes I made are:

1) I introduced LightAffectors. Thats basically a std::function-wrapper that refers to a specific PointLight. The affector code is called every frame. Maybe its note noticeable in the gif, but you can realize light-flickering and other neat stuff this way. See LightSystem::update and LightAffector class

2) In (I think) all other versions of ltbl, a Light and a LightCollider were rendered (and all heavy calculations were computed) even if their bounding boxes did not collide and thus the light was not affected by the collider at all. I changed that behavior. Now the LightSystem checks for collision of the bounding boxes (which is cheap in compare) and light-colliders that do not collide with a light are ignored. See LightSystem::renderLight

Alia5

  • Newbie
  • *
  • Posts: 34
    • View Profile
Re: Let There Be Light 2
« Reply #152 on: March 16, 2017, 12:30:07 am »
I currently work on a "small" game framework using SFML and LTBL2.

Starting out with the version of  Cmdu76, I modified it a bit further.
In addition to normal maps, I implemented specular maps, the ability for occluders to cast shadows on other occluders and also added a little pseudo-bloom shader.
The pseudo bloom isn't embedded in LTBL2 (yet?) but sits in a wrapper class of mine.


Click the gif for a higher quality window

Cmdu76

  • Full Member
  • ***
  • Posts: 194
    • View Profile
Re: Let There Be Light 2
« Reply #153 on: March 16, 2017, 10:48:18 am »
Nice ! I'm glad it helped you !

Do the modifications you made are open source somewhere ?

Alia5

  • Newbie
  • *
  • Posts: 34
    • View Profile
Re: Let There Be Light 2
« Reply #154 on: March 16, 2017, 12:06:40 pm »
Sure! There you go. :)

It's not a separate LTBL2 repo, though, as I have it merged into my framework.

Edit:
It's worth noting that I didn't implement normal/specular maps for directional lights yet.
Also, I changed LTBLs sprites to require a separate call for drawing the regular texture, normals and specular, which kinda defeats the point a bit, but makes it overall more flexible.
« Last Edit: March 16, 2017, 12:29:46 pm by Alia5 »

DJuego

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
Re: Let There Be Light 2
« Reply #155 on: April 08, 2018, 10:04:28 pm »
Any update about this? It is a pity that there is no a lighting extension for SFML alive and happy. :-|

DJuego

JSpirit

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Let There Be Light 2
« Reply #156 on: April 24, 2018, 05:53:51 pm »
Hey, it is possible to disable the shadow "system", and keep the image light effect and mostly the occluders effect ?

Alia5

  • Newbie
  • *
  • Posts: 34
    • View Profile
Re: Let There Be Light 2
« Reply #157 on: April 24, 2018, 06:23:13 pm »
I guess you wouldn't need such a complex library for that.
Just draw your "lights" to some renderTexture, draw black shapes for your occluders, and finally blend that render texture additively ;)

Grundkurs

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Re: Let There Be Light 2
« Reply #158 on: November 03, 2018, 08:14:35 pm »
to sum it up:
let there be light (https://github.com/eXpl0it3r/LTBL)
let there be light 2 (https://github.com/222464/LTBL2)
let there be light 2 by Cmdu76 (https://github.com/Cmdu76/LTBL2)
let there be light 2 by Alia5 (https://github.com/Alia5/FSE/tree/master/LTBL2)

I did notice that Alia5 did further improve Cmdu76's version of LTBL2, for example ltbl::LightSystem::create now deletes existing objects (marked as TODO in Cmdu76 version), BaseLight in Utils.hpp got a virtual Destructor which is important to prevent object slicing when inherited objects are deleted and so forth...
It seems advisable to use Alia5's version of LTBL2.

DJuego

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
Re: Let There Be Light 2
« Reply #159 on: November 03, 2018, 09:15:07 pm »
Thank you for the LTBL2 compilation, Grundkurs

Well. I wish so much that this project had a more updated and powerful successor ...

DJuego

Alias

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Let There Be Light 2
« Reply #160 on: November 05, 2018, 02:11:57 am »
Hey while using Cmdu76's version of the library I am getting a segfault in the LightSystem::Update(sf::Vector2u const& size) function at mEmissionTempTexture.create(size.x, size.y); while running the example project (https://github.com/Cmdu76/LTBL2/blob/master/examples/main.cpp).

Here is the backtrace:

#0  0x00007ffff7b94ed4 in sf::RenderTarget::initialize (this=0x7fffffffd628) at /SFML/Graphics/RenderTarget.cpp:545
#1  0x00007ffff7b933d4 in sf::RenderTexture::create (this=0x7fffffffd628, width=800, height=600, settings=...) at SFML/Graphics/RenderTexture.cpp:92
#2  0x00007ffff7b93264 in sf::RenderTexture::create (this=0x7fffffffd628, width=800, height=600, depthBuffer=false) at SFML/Graphics/RenderTexture.cpp:54
#3  0x000000000041ac01 in ltbl::LightSystem::update (this=0x7fffffffd070, size=...) at LTBL/LightSystem.cpp:330
#4  0x0000000000418ff3 in ltbl::LightSystem::create (this=0x7fffffffd070, rootRegion=..., imageSize=...) at LTBL/LightSystem.cpp:44
#5  0x0000000000406e87 in main () at main.cpp:43

And here's some screenshots of the output:



Anybody see what I'm doing wrong?

Grundkurs

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Re: Let There Be Light 2
« Reply #161 on: November 05, 2018, 10:29:42 pm »
@Alia5: i tried your LTBL2 implementation, however a minimal example already produced a strange result.
I cannot set the Origin of a LightPointEmission-Object to the center without the Light-Point getting "spliced".
I did use the common "pointLightTexture.png", which is round.

#include "LTBL2/LightSystem.hpp"
#include <SFML/Graphics/RenderTexture.hpp>
#include <SFML/Graphics/RenderWindow.hpp>
int main() {
    sf::RenderTexture normal_texture_;
    sf::RenderTexture specular_texture_;
    sf::RenderWindow window{sf::VideoMode{800,600}, "LightShow"};
    ltbl::LightSystem lightSystem{normal_texture_,specular_texture_,true};
    lightSystem.create({ -1000.f, -1000.f, 2000.f, 2000.f }, window.getSize());

    sf::Texture pointLightTexture;
    pointLightTexture.loadFromFile("../examples/pointLightTexture.png");
    pointLightTexture.setSmooth(true);

    auto* light = lightSystem.createLightPointEmission();
    light->setTexture(pointLightTexture);
    light->setOrigin(pointLightTexture.getSize().x / 2.f, pointLightTexture.getSize().y / 2.f);
    light->setScale(10.f,10.f);

    while (window.isOpen()) {
        sf::Event event;
        while (window.pollEvent(event)) {
            if (event.type == sf::Event::Closed) {
                window.close();
            }
        }
        sf::Vector2f pos(sf::Mouse::getPosition(window));
        light->setPosition(pos);

        window.clear(sf::Color::White);
        lightSystem.render(window);
        window.display();
    }
    return 0;
}
 

This produces this Lightpoint:


The white dot marks the position of the mouse (the mouse cursor does not get captured when taking screenshots).

Alia5

  • Newbie
  • *
  • Posts: 34
    • View Profile
Re: Let There Be Light 2
« Reply #162 on: November 06, 2018, 11:54:26 am »
@Grundkurs
I haven't worked on anything the last half a year or something, but I don't think my mods to LTBL2 work really well for a standalone implementation outside of FSE. (Hence it's not a fork but directly baked into the repo)

For reference you can look at:
https://github.com/Alia5/FSE/blob/master/FSE/Lights/FSELightWorld.cpp

Edit: I might decouple them somewhat one day, but when and if that day ever comes remains to be seen
« Last Edit: November 06, 2018, 11:57:53 am by Alia5 »

Glucio

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
Re: Let There Be Light 2
« Reply #163 on: February 12, 2019, 08:18:37 pm »
I've been trying to fiddle with this for a bit.
So after a long and hair pulling process, I managed to generate a .lib (I think)

Now that my project builds yet again, I'm trying to add some lights but since there is no documentation, I'm having a rough time.

Would anyone be able to shine some light for me? (Sorry for the bad pun)  :-X

Any help would be appreciated!

Edit: spelling
« Last Edit: February 12, 2019, 08:32:31 pm by Glucio »

Guido_Ion

  • Newbie
  • *
  • Posts: 42
    • View Profile
    • Flow Soccer development
Re: Let There Be Light 2
« Reply #164 on: July 25, 2019, 09:29:25 pm »
Hi, I hope this is not dead  ??? I'm still using LTBL2 , it's great!

For performance issues I wanted to use 2 diferent ltbl::LightSystem(), one for static lights (render once, draw every frame) and another one for dynamic lights (render and draw every frame).

The issue I'm having is that when drawing both lightSystems everything is really dark, I guess the not lighted parts are being drawn twice, thus turning everything dark.

Is there a way to only draw the lights for each lightSystem and not the dark parts?  :o

Or maybe there is another way instead of using 2 light systems, I need to render only the lights that change and not the static ones, BUT I need to draw every light, every frame.