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

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

0 Members and 1 Guest are viewing this topic.


  • Hero Member
  • *****
  • Posts: 3339
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Let There Be Light 2
« Reply #165 on: July 29, 2019, 02:37:28 am »
Is there a way to only draw the lights for each lightSystem and not the dark parts?  :o
You could try drawing the second one using an additive blend mode.
See BlendMode documentation.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
 *Hapaxia Links*


  • Newbie
  • *
  • Posts: 42
    • View Profile
    • Flow Soccer development
Re: Let There Be Light 2
« Reply #166 on: July 29, 2019, 05:32:40 pm »
Thanks for the answer, but that didn't work, it still draws the dark parts twice and the lights very strong, that's not the result I want.
Maybe I need to create other sprites (penumbraTexture.png, etc.) with the dark parts as transparent for the second lightsystem. I don't know how to do that but I'll mess around with GIMP and see what's the result.

If lolz or someone has another easy answer for using 2 light systems it would be great.


  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Let There Be Light 2
« Reply #167 on: March 12, 2020, 02:51:20 pm »
Hello, I've been using SFML for quite a while, but stumbled upon this gem of a library a few days ago.

I have successfully integrated Alia5's version of LTBL2 and I am VERY pleased with it but there's 1 thing missing for me to achive what I want:
I'd love to have a directional light source to interact with normal/specular maps - a way to lit the surface of every object drawn to normal map buffer from given angle, a kind of global light source.
I suspect it can be done after every other light source is drawn with slight modification of existing shaders, but currently it's beyond me. If I'll manage to do it I'll post it here, but feel free to be first if it's no biggie to you  :-*

Many thanks to everyone involved in this project and SFML itself.
« Last Edit: March 12, 2020, 05:07:30 pm by grzyboleusz »


  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Let There Be Light 2
« Reply #168 on: March 17, 2020, 11:31:27 am »
As I said, there it is:

Shader to add global directional lighting, every pixel is lit from given direction vector without cosidering the distance (slightly modified version of the one included in the library, I only use it to draw light with additive blending):

(click to show/hide)

Also, I needed a shader to correct rotated normal maps of the sprites so there it is:
(click to show/hide)

As you can see, it uses vertex color channels to represent rotation and flipping, so you dont have to set any uniforms while drawing - useful for collective VertexArrays
Red color - if lower than 1.0 (or 255 in sf::Color) flips the normal map horizontally
Green  color - if lower than 1.0 (or 255 in sf::Color) flips the normal map vertically
Blue color - is angle in radians divided by Tau (2 * Pi)
Simply use it to draw normal maps
« Last Edit: March 17, 2020, 11:44:58 am by grzyboleusz »


  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Let There Be Light 2
« Reply #169 on: May 27, 2020, 03:09:11 pm »

I have problem thats my light point emmision is only a half of circle and i dont know how to fix it :/
I use fallowing code with Alia5 LTBL2:

Code: [Select]
#include "ltbl/lighting/LightSystem.hpp"
#include <SFML/Graphics.hpp>
#include <iostream>

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, 1000.f, 1000.f }, window.getSize());

    sf::Texture pointLightTexture;

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

    while (window.isOpen()) {
        sf::Event event;
        while (window.pollEvent(event)) {
            if (event.type == sf::Event::Closed) {
        sf::Vector2f pos(sf::Mouse::getPosition(window));

    return 0;
any tips?

edit: dummy me
 ltbl::LightSystem lightSystem{normal_texture_,specular_texture_,FALSE};
« Last Edit: May 28, 2020, 09:11:38 am by Yuri »