SFML community forums

General => SFML projects => Topic started by: lolz123 on December 31, 2011, 04:17:53 am

Title: SFML Light System - Let There Be Light
Post by: lolz123 on December 31, 2011, 04:17:53 am
Let There Be Light is a 2D dynamic soft shadows system that uses SFML.

Here are some features:
- Physically accurate soft shadows
- Quad tree scene graph
- Light texture caching
- Emissive lights
- Light beams
- Directional lights
- Adjustable light color, attenuation, spread, source size, cone angle, bloom, and cone edge softness
- Ambient light setting
- Extendable light shape rendering
- Light bloom rendering

Feel free to use this system in a game. Please put me in the credits somewhere :).

Download (includes demo): https://sourceforge.net/projects/letthebelight/ (https://sourceforge.net/projects/letthebelight/)

The light system in action in the game "Gore Factor":

(http://i1218.photobucket.com/albums/dd401/222464/ltblexample.png)
Title: SFML Light System - Let There Be Light
Post by: Teemperor on December 31, 2011, 11:04:33 am
I get this on Ubuntu 11.10 with g++ 4.6.1 and enabled C++0x-standard? (without C++0x i get warnings from the headers to active C++0x and many errors)

http://pastebin.com/wrsgCHQj
Title: SFML Light System - Let There Be Light
Post by: lolz123 on December 31, 2011, 04:00:07 pm
Unfortunately, I am not very familiar with g++, so here is the limited help I can offer:
C++0x is required, but you seem to be missing a bunch of things in the older version of C++ too, such as auto_ptr. You also are not getting the math libaries (specifically the sqrt function), try including them the way you normally do in g++, and try switching sqrt to sqrtf. g++ seems to complain about the friend keyword a lot, which is strange. Try prefixing all the names of the classes following a friend declaration with "class". Also, your STL containers are complaining about the way I am accessing elements from the iterators, but this shouldn't be different between VS2010 and g++. Perhaps it is some compiler setting.
Title: SFML Light System - Let There Be Light
Post by: Haikarainen on December 31, 2011, 11:07:13 pm
Tested the binary, doesnt work on my system. Shadows is all buggy.

Gore factor works perfectly.

AMD HD6870 Black Edition
AMD Athlon II 645 Quadcore
8GB DDR3 XMS3 RAM
Windows 7 Ultimate x64

Video of the problem; http://www.youtube.com/watch?v=eb_kEywmVF0&feature=youtu.be
Title: SFML Light System - Let There Be Light
Post by: Nexus on January 01, 2012, 12:56:08 pm
Thanks a lot for sharing the code!

I hope you don't mind if I give you some tips, maybe the bugs are related:
Some points are tiny details, and I also see that you have just extracted the code from your project, but maybe some advice still helps you :)
Title: SFML Light System - Let There Be Light
Post by: bmn on January 01, 2012, 01:37:27 pm
I have the same problem as Haikarainen.

AMD HD6950, using latest drivers.

Another problem with ATI/AMD video cards?
Title: SFML Light System - Let There Be Light
Post by: lolz123 on January 01, 2012, 02:42:37 pm
Thanks for the tips! The code is pretty messy, since when I was writing it, I was just struggling to get something to work at all. The quad tree has pretty clean code IMO, but the light rendering certainly doesn't. I think it is time that I clean it up some more. It depends too much on my base windowing code, I will try to make it more modular. I like my own vector functions however :). I could make a bunch of functions that do things like dot and cross products on them, but they cannot be members then, so I wouldn't get intellisense in VS2010 and it would involve more typing. And I am very lazy. I never use any functions requiring SFML vectors anyways. Also, this allows my to use my quad tree in non-sfml projects.

The color classes work differently from the SFML ones. The SFML ones use integers, mine use floats, which I find easier to work with in many cases.

I think I know what causes the strange rendering. I can replicate it on my machine by not saving the OpenGL states right before drawing to a render texture. I do not understand why this is necessary though. Saving states is slow anyways, so I am trying to find a way around this. I will let you know when I have fixed it (or at least have a new version to test).
Title: SFML Light System - Let There Be Light
Post by: Chaia* on January 01, 2012, 03:17:44 pm
Hey, I got another problem on my system.

If the light is too close to the shape, the shadow won't be correct.
I took some screenshots for comparison.
The red point is the light center.

http://imageshack.us/photo/my-images/849/lettherebelight20120101.jpg/

My System: NV gtx 470, Phenom II 955, Win 7 64 bit
Title: SFML Light System - Let There Be Light
Post by: lolz123 on January 01, 2012, 03:22:38 pm
That happens when the light overlaps the hull. Don't forget, the lights are not points, but circles. I can make it detect this case and then simply not draw if you like.
Title: SFML Light System - Let There Be Light
Post by: lolz123 on January 01, 2012, 05:32:20 pm
I uploaded a new version. Does this one work for you guys?
Title: SFML Light System - Let There Be Light
Post by: Anata on January 01, 2012, 06:23:31 pm
http://youtu.be/Nf5sjxEnQU0

some problems when the light is near the polygon
Title: SFML Light System - Let There Be Light
Post by: Nexus on January 01, 2012, 06:24:44 pm
Quote from: "lolz123"
I could make a bunch of functions that do things like dot and cross products on them, but they cannot be members then, so I wouldn't get intellisense in VS2010 and it would involve more typing
You could move the classes to a namespace (actually you should). Or use intelligent tools like Visual Assist X ;)

The advantage of global functions is that you can call them symmetrically with respect to the arguments. Also binary operators like +, -, == etc. should always be global functions to allow implicit conversions of the first argument (and not only of the second).

Quote from: "lolz123"
Also, this allows my to use my quad tree in non-sfml projects.
Good point.

Quote from: "Anata"
http://youtu.be/Nf5sjxEnQU0
The video is private. And please use official Youtube links...
Title: SFML Light System - Let There Be Light
Post by: lolz123 on January 01, 2012, 07:40:57 pm
@ Anata: That isn't really a bug, it just doesn't render properly when a light is intersecting a hull. The lights are not points here, or else they would not cast a soft shadow. They have a radius, and when the light circle intersects a hull, the algorithm cannot find the right rays anymore, since the penumbra rays will intersect the hull shape. I now have an algorithm that detects if a light is intersecting a shape, and doesn't draw it when this happens, since it is hard to keep lights out of walls in some games (especially when they are attached to the player). It is ever so slightly slower now though :). I will let you know when the new version is complete.
Title: SFML Light System - Let There Be Light
Post by: lolz123 on January 02, 2012, 12:06:06 am
I uploaded a new version, in which I made the system far more modular. You should be able to slap it on to any existing SFML application without changing much. It also now allows you to set a flag to determine whether or not it will render shadows that are intersecting hulls. It defaults to not drawing them.

If any of you would like some documentation, let me know.
Title: SFML Light System - Let There Be Light
Post by: Haikarainen on January 02, 2012, 04:23:48 am
Quote from: "lolz123"
I uploaded a new version, in which I made the system far more modular. You should be able to slap it on to any existing SFML application without changing much. It also now allows you to set a flag to determine whether or not it will render shadows that are intersecting hulls. It defaults to not drawing them.

If any of you would like some documentation, let me know.


Demo works for me now!
Title: SFML Light System - Let There Be Light
Post by: bmn on January 06, 2012, 06:27:08 pm
Also works for me now.

I'm wondering how you fixed this because I have a project that does the same thing, but only on my dev computer.
Title: SFML Light System - Let There Be Light
Post by: lolz123 on January 07, 2012, 01:38:57 am
I just made sure to save all of the OpenGL states whenever I did something with the render texture.
Title: SFML Light System - Let There Be Light
Post by: ChonDee on January 24, 2012, 01:35:52 am
Wow, this is awesome, exactly what I need!
Keep up the good work!

Are you planning on making documentation for it?
Title: SFML Light System - Let There Be Light
Post by: lolz123 on January 24, 2012, 09:32:07 pm
I wasn't planning on it, but I certainly can! I will let you know when it is finished.
Title: SFML Light System - Let There Be Light
Post by: Ockonal on February 09, 2012, 01:40:33 am
Hello
lolz123
Great job! I've made it crossplatform. Everyone can download it from:
http://dl.dropbox.com/u/932520/Source.zip

There is data + a few changes in sources + Makefile. Worked fine for me in ArchLinux with the latest sfml build. I hope, the author not against this :)

btw, why do you write: `it->_Ptr->_Myval`, it's not crossplatform and very bad, why not to use `(*it)->...`?

And you've tried to access 'aabb' member from `QuadTreeOccupant` and it's protected? I replaced it with public to compile the code.

I like it, thanks!
Title: SFML Light System - Let There Be Light
Post by: StormWingDelta on February 09, 2012, 05:16:21 am
That could be why it didn't work on windows or does it not work out of the box when downloaded.  The examples didn't run on my end.
Title: SFML Light System - Let There Be Light
Post by: lolz123 on February 10, 2012, 12:38:44 am
Thanks Ockonal for cleaning up the code! I am putting together a manual for the light system, it should be done soon. I did change some things while doing so though, since some parts were not very user friendly (mainly having to do with updating AABB's), and there are still some glitches having to do with the OpenGL states getting messed up. I hope it is OK if I incorporate your improved code into the new version.
Title: SFML Light System - Let There Be Light
Post by: Ockonal on February 10, 2012, 01:08:38 am
lolz123, It's great ;) Waiting for it.

Btw, maybe it would be better to move directional light into separate structure? You are restict the number of triangles from light source when we set 'spreadAngle' but what if I want to move/rotate the source of directional light?
Title: SFML Light System - Let There Be Light
Post by: lolz123 on February 10, 2012, 01:59:14 am
Well, the only thing that changing the spread angle does is change the end angle for rendering the light. It runs the same code whether it is directional or not, so I think putting it in a separate structure is unnecessary. You can still rotate and move the the light, you just need to recalculate the AABB afterwards so that the quad tree remains updated. The AABB cannot just be moved, since the light is not round anymore when it is made directional. If a light is not directional, you can just move the AABB, and no recalculation is required. I am changing some things in the light class so it automatically updates the AABB by either moving or recalculating it when parameters affecting the shape or orientation/position of the light are changed. Right now, you have to do it manually, which can become very confusing :?

The light beam on the other hand needs a separate structure, since it renders the light in a completely different way (a quad). The light rendering is extensible for this reason, but it currently still only supports circular light sources. While not completely realistic, I do not think that anybody will notice that the light beam does not calculate shadow softness using the shape of the beam emitter but rather just a circle positioned along the center point of the beam emitter :wink:
Title: SFML Light System - Let There Be Light
Post by: Ockonal on February 10, 2012, 02:05:10 am
Great answer, thanks :) Maybe you can tell the near time of new release?

Now I'm rewriting the most part of you code with new structure and optimizaton, maybe, I can wait a few time for your updates and make my own after that.
Title: SFML Light System - Let There Be Light
Post by: lolz123 on February 10, 2012, 02:40:01 am
I will probably finish it in 2-3 days, unless the OpenGL states issue turns out to be a bigger problem than currently think it is.
Title: SFML Light System - Let There Be Light
Post by: Ockonal on February 10, 2012, 08:59:42 am
Okay, I'm waiting for you ;)
Title: SFML Light System - Let There Be Light
Post by: Ockonal on February 14, 2012, 02:39:15 pm
lolz123, sorry for disturbing, any news? :)
Title: SFML Light System - Let There Be Light
Post by: lolz123 on February 15, 2012, 03:06:23 am
Sorry about that, its taking a bit longer than expected. I am still having problems with the OpenGL states getting messed up  :(. It should be ready soon.
Title: SFML Light System - Let There Be Light
Post by: Ockonal on February 17, 2012, 11:46:29 am
lolz123, okay, no problems. Write here if you have any trobles. Maybe I and other peoples can help you.
Title: SFML Light System - Let There Be Light
Post by: Grimshaw on February 25, 2012, 02:51:16 am
I really enjoyed your code, I think I will just put this deep in the Parabola Engine!

Would you mind if I use your code, with possible modifications, even for redistributing later? You get credit for it anyway!


Question, I am using Visual Studio 2008 and while trying to compile your code, the compiler actually can't find unique_ptr. I guess I don't have the C++11 ready in my compiler? What do you advice?

Thanks in advance.
Title: SFML Light System - Let There Be Light
Post by: Ockonal on February 25, 2012, 12:49:03 pm
Quote from: "DevilWithin"

Question, I am using Visual Studio 2008 and while trying to compile your code, the compiler actually can't find unique_ptr. I guess I don't have the C++11 ready in my compiler? What do you advice?


Yes, c++1x support became after 2008 version of visual studio. Try to upgrade it.
Title: SFML Light System - Let There Be Light
Post by: Ockonal on February 28, 2012, 12:24:23 pm
lolz123, Any news? :) If something is wrong you could connect with me and I'll try to help you. Just don't want rewrite your code if there are some new changes ;)
Title: SFML Light System - Let There Be Light
Post by: Grimshaw on February 28, 2012, 01:17:38 pm
Thanks Ockogonal for the support as well!

I've updated all my stuff to VS2010 now, it seems to be fine :)

Now its time to implement everything into my own scene :)

One question, ConvexHulls are the only thing i should use to make the shadow casting shapes right?
Title: SFML Light System - Let There Be Light
Post by: Ockonal on February 28, 2012, 02:10:00 pm
DevilWithin, ;)
Yeah, ConvexHull is the only thing.

Btw, I'm using box2d in my engine and there is already defining the shape of the objects. It's normally that shadow could be dropped only by physic bodies. So I just convert physic shapes into ConvexHull at creating.
Title: SFML Light System - Let There Be Light
Post by: Grimshaw on February 29, 2012, 02:35:47 am
Your idea is indeed nice!

I was thinking of handling this by creating a utility class, a Shape extended.

That would be a collection of sf::Shapes, to allow concave shapes, or simply sets of them..

This would not be a bad idea because it could generate ConvexHulls, Box2D multi-fixtured bodies as well as rendering sf::Shapes..
Title: SFML Light System - Let There Be Light
Post by: Nexus on March 01, 2012, 06:30:55 pm
Quote from: "DevilWithin"
I was thinking of handling this by creating a utility class, a Shape extended.

That would be a collection of sf::Shapes, to allow concave shapes, or simply sets of them..
No need to reinvent the wheel, I've already written such a class (http://www.bromeon.ch/libraries/thor/v1.1/doc/classthor_1_1_concave_shape.html) ;)

By the way, my library also contains a triangulation algorithm, in case you want to split a polygon into triangles.
Title: SFML Light System - Let There Be Light
Post by: Grimshaw on March 01, 2012, 10:00:12 pm
Quote from: "Nexus"
Quote from: "DevilWithin"
I was thinking of handling this by creating a utility class, a Shape extended.

That would be a collection of sf::Shapes, to allow concave shapes, or simply sets of them..
No need to reinvent the wheel, I've already written such a class (http://www.bromeon.ch/libraries/thor/v1.1/doc/classthor_1_1_concave_shape.html) ;)

By the way, my library also contains a triangulation algorithm, in case you want to split a polygon into triangles.


Woo, I keep getting nice news ! Specially that triangulation thing, is just something on my todo list ! :)

Do you mind if i "copy" your design? I won't link to more libraries for simpleness sake (already linking to 6 or more). However i will gladly credit you as a contributor to the engine framework.
Title: SFML Light System - Let There Be Light
Post by: lolz123 on March 02, 2012, 02:37:14 am
Sorry that it has been taking so long for me to make the next version. It is practically finished now, I am just hunting for some minor bugs now. The next version (1.2) should be available for download by tomorrow. Here are some things that have changed:

- Fixed (hopefully) the strange artifacting occurring on some machines
- Cleaned up light and hull interfaces, they now do most AABB updates automatically
- Light rendering is a bit faster, since I found a way around saving the OpenGL states
- Fixed some AABB misalignment issues

Also, I wrote a manual for it. It includes a walkthrough for the demo program, and detailed descriptions of all of the core classes.
Title: SFML Light System - Let There Be Light
Post by: Grimshaw on March 02, 2012, 03:11:16 am
You already found a user to the next version! Thanks :)
Title: SFML Light System - Let There Be Light
Post by: ChonDee on March 02, 2012, 05:07:05 am
I'm looking forward to see it as well, keep up the good work!
Title: SFML Light System - Let There Be Light
Post by: Nexus on March 02, 2012, 06:42:12 pm
Quote from: "DevilWithin"
Do you mind if i "copy" your design? I won't link to more libraries for simpleness sake (already linking to 6 or more).
No, please just regard the license ;)
You can also copy the whole files required to triangulation and use them directly in your project. Then you can replace them easily in case I improve something, fix a bug or the like...

By the way, maybe you should wait until SFML 2 is out, because the naming convention in SFML (and probably also in Thor) might still change.

Quote from: "DevilWithin"
However i will gladly credit you as a contributor to the engine framework.
That would be nice, thanks :)
Title: SFML Light System - Let There Be Light
Post by: lolz123 on March 03, 2012, 01:21:56 am
Version 1.2 is now available for download!

Please let me know of any bugs you find!
Title: SFML Light System - Let There Be Light
Post by: Grimshaw on March 03, 2012, 03:26:37 am
zlib just the license I am planning to release under! :) Yes, i certainly will use your triangulation code :D Thanks!

My library is already using the nameConvention, i decided i don't like NameConvention anymore! When you guys change, I will lose some time adapting the code, its not a problem !

Now that the lib is better than ever and approaching an alpha release, I will really need criticism, testing , you know the drill..

@mr. author of the awesome lighting system

Thanks! Indeed, Thanks!

Though, there is one more thing I would like to ask to you or anyone that can answer. How do I manuals in the style of yours? I really liked the idea of making a PDF, exactly like yours, to describe my work. Thanks
Title: SFML Light System - Let There Be Light
Post by: lolz123 on March 03, 2012, 05:30:31 am
I used MS Word to write the manual. I simply saved it as a PDF. Nothing fancy  :)
Title: SFML Light System - Let There Be Light
Post by: Ockonal on March 03, 2012, 07:24:00 am
lolz123, great job! I gonna look at sources in a few hours and make some changes if they are needed. Gonna write here about any changes.

Thanks again.
Title: SFML Light System - Let There Be Light
Post by: Roose Bolton of the Dreadfort on March 06, 2012, 07:38:46 pm
Right I am getting to my wits end here..

Can anyone please explain how to link this into a project?

I want to play around with it so much it looks amazing!!

I have included SFML2.0 that works fine.. i downloaded GLEW of their website and linked it to my project correctly (or i think) and i get these errors when I try to compile ur main that you gave us with ur example code

Code: [Select]
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall ltbl::LightSystem::~LightSystem(void)" (??1LightSystem@ltbl@@QAE@XZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall ltbl::LightSystem::RenderLightTexture(float)" (?RenderLightTexture@LightSystem@ltbl@@QAEXM@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall ltbl::LightSystem::RenderLights(void)" (?RenderLights@LightSystem@ltbl@@QAEXXZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall ltbl::Light::SetCenter(class ltbl::Vec2f)" (?SetCenter@Light@ltbl@@QAEXVVec2f@2@@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall ltbl::LightSystem::AddConvexHull(class ltbl::ConvexHull *)" (?AddConvexHull@LightSystem@ltbl@@QAEXPAVConvexHull@2@@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall ltbl::ConvexHull::SetWorldCenter(class ltbl::Vec2f const &)" (?SetWorldCenter@ConvexHull@ltbl@@QAEXABVVec2f@2@@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall ltbl::ConvexHull::GenerateAABB(void)" (?GenerateAABB@ConvexHull@ltbl@@QAEXXZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall ltbl::ConvexHull::CalculateNormals(void)" (?CalculateNormals@ConvexHull@ltbl@@QAEXXZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: bool __thiscall ltbl::ConvexHull::LoadShape(char const *)" (?LoadShape@ConvexHull@ltbl@@QAE_NPBD@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall ltbl::ConvexHull::ConvexHull(void)" (??0ConvexHull@ltbl@@QAE@XZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall ltbl::LightSystem::AddLight(class ltbl::Light *)" (?AddLight@LightSystem@ltbl@@QAEXPAVLight@2@@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall ltbl::Light::Light(void)" (??0Light@ltbl@@QAE@XZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall ltbl::LightSystem::LightSystem(class ltbl::AABB const &,class sf::RenderWindow *)" (??0LightSystem@ltbl@@QAE@ABVAABB@1@PAVRenderWindow@sf@@@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall ltbl::AABB::AABB(class ltbl::Vec2f const &,class ltbl::Vec2f const &)" (??0AABB@ltbl@@QAE@ABVVec2f@1@0@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall ltbl::Vec2f::Vec2f(float,float)" (??0Vec2f@ltbl@@QAE@MM@Z) referenced in function _main


I am losing faith in life at the moment can anyone help me or send me over a example project with it all linked correctly?

sorry guys..

matthew.
Title: SFML Light System - Let There Be Light
Post by: lolz123 on March 06, 2012, 10:25:49 pm
Did you link to the .cpp's?
Title: SFML Light System - Let There Be Light
Post by: Roose Bolton of the Dreadfort on March 06, 2012, 11:01:26 pm
Yeah they are all linked. still getting unresolved external errors. ;/
Title: SFML Light System - Let There Be Light
Post by: Roose Bolton of the Dreadfort on March 06, 2012, 11:19:39 pm
Could you link me to the extact download link for glew?
Title: SFML Light System - Let There Be Light
Post by: lolz123 on March 07, 2012, 12:50:03 am
That shouldn't be the problem. I would either try adding the source directly to your project, or go into the files and change the "" in the #include statements to <>. I believe the problem may be that the #includes are not using the linker.
Title: SFML Light System - Let There Be Light
Post by: Roose Bolton of the Dreadfort on March 08, 2012, 07:27:47 pm
hmm I tried that to no success.

Basically I am >

Installing fresh SFML2.0 on my project, run test code all compiles and runs the window fine with blue colour.

Add your light addon to the project, attach it to my project and include it, I type  ltbl:: to make sure its linked as all the functions pop up.
 
Download Glew 1.7.0 (NewestVersion) and put it in C:\

go to my Project Properties > Include Directories and add
C:\glew\include

then in library directories add  
C:\glew\lib

then go to additional dependencies and add

glew32mx.lib
glew32.lib

Run the project, compiles all your code correctly then I get


Code: [Select]

1>Constructs.obj : error LNK2001: unresolved external symbol __imp__glEnd@0
1>Constructs.obj : error LNK2001: unresolved external symbol __imp__glBegin@4
1>Constructs.obj : error LNK2001: unresolved external symbol __imp__glVertex3f@12
1>Light.obj : error LNK2001: unresolved external symbol __imp__glClearDepth@8
1>Light.obj : error LNK2001: unresolved external symbol __imp__glDepthFunc@4
1>Light.obj : error LNK2001: unresolved external symbol __imp__glOrtho@48
1>Light.obj : error LNK2001: unresolved external symbol __imp__glColor4f@16
1>Light.obj : error LNK2001: unresolved external symbol __imp__glMatrixMode@4
1>Light.obj : error LNK2001: unresolved external symbol __imp__glViewport@16
1>Light.obj : error LNK2001: unresolved external symbol __imp__glEnable@4
1>Light.obj : error LNK2001: unresolved external symbol __imp__glLoadIdentity@0
1>LightSystem.obj : error LNK2001: unresolved external symbol __imp__glClear@4
1>LightSystem.obj : error LNK2001: unresolved external symbol __imp__glColor4b@16
1>LightSystem.obj : error LNK2001: unresolved external symbol __imp__glColorMask@16
1>LightSystem.obj : error LNK2001: unresolved external symbol __imp____glewBlendFuncSeparate
1>LightSystem.obj : error LNK2001: unresolved external symbol __imp__glDisable@4
1>LightSystem.obj : error LNK2001: unresolved external symbol __imp__glPopMatrix@0
1>LightSystem.obj : error LNK2001: unresolved external symbol __imp__glPushMatrix@0
1>LightSystem.obj : error LNK2001: unresolved external symbol __imp__glBlendFunc@8
1>LightSystem.obj : error LNK2001: unresolved external symbol __imp__glScalef@12
1>LightSystem.obj : error LNK2001: unresolved external symbol __imp__glTexCoord2i@8
1>LightSystem.obj : error LNK2001: unresolved external symbol __imp__glTranslatef@12
1>SFML_OpenGL.obj : error LNK2001: unresolved external symbol __imp__glewInit
1>D:\C++\SFML\SFML2.0Test\Release\SFML2.0Test.exe : fatal error LNK1120: 23 unresolved externals
Title: SFML Light System - Let There Be Light
Post by: Roose Bolton of the Dreadfort on March 08, 2012, 09:42:50 pm
EDIT: Do you need C++0x installed or something?
Title: SFML Light System - Let There Be Light
Post by: lolz123 on March 08, 2012, 10:20:17 pm
Yes, you need C++0x features. The chances are that your compiler has them. If you are using VS2010, you will have all of the necessary C++0x features.

It looks like you didn't link to OpenGL. Go to the linker input, and add:

OpenGL32.lib
Title: SFML Light System - Let There Be Light
Post by: Roose Bolton of the Dreadfort on March 09, 2012, 03:06:54 am
Yeah I am using VC2010..

oo adding Opengl linker brought the errors down too only 2!

anything else im missing?

sfml-graphics.lib
sfml-audio.lib
sfml-system.lib
sfml-window.lib
sfml-network.lib
glew32mx.lib
glew32.lib
OpenGL32.lib

Error -

Code: [Select]

1>------ Build started: Project: SFML2.0Test, Configuration: Release Win32 ------
1>Build started 09/03/2012 02:06:59.
1>InitializeBuildStatus:
1>  Touching "Release\SFML2.0Test.unsuccessfulbuild".
1>ClCompile:
1>  All outputs are up-to-date.
1>LightSystem.obj : error LNK2001: unresolved external symbol __imp____glewBlendFuncSeparate
1>SFML_OpenGL.obj : error LNK2001: unresolved external symbol __imp__glewInit
1>D:\C++\SFML\SFML2.0Test\Release\SFML2.0Test.exe : fatal error LNK1120: 2 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.40
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


Thanks a lot for the help
Title: SFML Light System - Let There Be Light
Post by: Roose Bolton of the Dreadfort on March 09, 2012, 03:24:54 am
Never mind, fixed it.

GLEW 1.7.0(Newest Release) does not work with Let There Be Light.

I used Glew 1.6.0 and works fine.
Title: SFML Light System - Let There Be Light
Post by: lolz123 on March 09, 2012, 03:41:24 am
I am glad that you solved it  :)
Title: SFML Light System - Let There Be Light
Post by: Roose Bolton of the Dreadfort on March 09, 2012, 06:48:22 am
I just noticed, if two lights cross each other or touch etc, hard edged cubes appear.. is this a bug? If not then is there a way to stop it happening? As the game I want to make will have lots of lights touching.

Cheers lolz
Title: SFML Light System - Let There Be Light
Post by: lolz123 on March 10, 2012, 12:55:10 am
Oh, woops, I forgot to make sure that the alpha buffer was cleared, which is apparently the cause of these strange artifacts :oops: . Try the latest version, should be fixed!
Title: SFML Light System - Let There Be Light
Post by: Roose Bolton of the Dreadfort on March 10, 2012, 04:52:29 am
overridden my old lighting and added the new version now getting this when I compile

Code: [Select]

1>LightSystem.obj : error LNK2019: unresolved external symbol "public: void __thiscall ltbl::EmissiveLight::Render(void)" (?Render@EmissiveLight@ltbl@@QAEXXZ) referenced in function "public: void __thiscall ltbl::LightSystem::RenderLights(void)" (?RenderLights@LightSystem@ltbl@@QAEXXZ)
1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall ltbl::EmissiveLight::SetCenter(class ltbl::Vec2f const &)" (?SetCenter@EmissiveLight@ltbl@@QAEXABVVec2f@2@@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall ltbl::EmissiveLight::SetRotation(float)" (?SetRotation@EmissiveLight@ltbl@@QAEXM@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall ltbl::EmissiveLight::SetTexture(class sf::Texture *)" (?SetTexture@EmissiveLight@ltbl@@QAEXPAVTexture@sf@@@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall ltbl::EmissiveLight::EmissiveLight(void)" (??0EmissiveLight@ltbl@@QAE@XZ) referenced in function _main
1>D:\C++\SFML\SFML2.0Test\Debug\SFML2.0Test.exe : fatal error LNK1120: 5 unresolved externals


Did you include some new stuff when you changed emissive lights?

PS: Just tried it again - older version works fine, this new version gets these errors..
Title: SFML Light System - Let There Be Light
Post by: lolz123 on March 10, 2012, 05:22:20 am
Yup, I re-wrote the emissive lights to some degree. You will probably have to change the #includes to use the linker again, since you are not adding them to your project.
Title: SFML Light System - Let There Be Light
Post by: Alejandro on March 10, 2012, 08:34:52 pm
Hello,

I'm having the same problem as 1337Matty, but even after I download GLEW 1.6.0 the errors are there. I have linked against glew32mxs, glew32s and libopengl32. Using MinGW 4.6.1 on Windows 7 64-bit.

Code: [Select]

obj\Release\LTBL\src\LightSystem.o:LightSystem.cpp|| undefined reference to `_imp____glewBlendFuncSeparate'|
obj\Release\LTBL\src\SFML_OpenGL.o:SFML_OpenGL.cpp|| undefined reference to `_imp__glewInit'|
||=== Build finished: 2 errors, 0 warnings ===|


If you have any suggestions as to how to fix the problem, I would be more than happy to try them :)
Title: SFML Light System - Let There Be Light
Post by: heishe on March 12, 2012, 12:05:50 am
A question: Can you explain in a couple of sentences what the principle behind the (hard-)shadow generation is (not interested in soft shadows since it seems like it's just a stretched texture that is attached to the edges of the shadow)?

I implemented a lighting system a while ago that was in essence based on the algorithm used here (although I completely rewrote and refactored the code since the original implementation was pretty slow and also quite ugly):

http://www.sfml-dev.org/wiki/fr/sources/lightmanager

I have used another algorithm before that but that turned out to be even slower, so I'm interested to see what your system is based on.
Title: SFML Light System - Let There Be Light
Post by: lolz123 on March 12, 2012, 12:47:55 am
The way Holy Spirit does it is slower for mainly 2 reasons:
1. It uses walls instead of hulls, which results in a lot of needless geometry
2. It doesn't use a spatial partitioning system
3. It doesn't cache lights, as far as I can tell

The hard edge shadow algorithm is based off of what is described in this article: http://www.gamedev.net/page/resources/_/technical/graphics-programming-and-theory/dynamic-2d-soft-shadows-r2032

The soft portion of the shadows was actually by far the hardest part! It is also the most processing intensive part. Let There Be Light calculates a penumbra that starts as a point and softens further away from the light, instead of just blurring the edges of the light.

---------------------------

On a different note, I am adding adjustable light attenuation and bloom to the next version of LTBL. It should be done soon, there are just a couple of bugs that need to be fixed. Here is a preview:

(http://i1218.photobucket.com/albums/dd401/222464/attenuationAndBloom.png)
Title: SFML Light System - Let There Be Light
Post by: Nexus on March 12, 2012, 12:00:28 pm
By the way, can you elaborate a bit on the differences between your light system and native OpenGL lights? I'm not too familiar with it, what features doesn't OpenGL provide?
Title: SFML Light System - Let There Be Light
Post by: Laurent on March 12, 2012, 12:08:48 pm
OpenGL lighting is very basic:
- it works per-vertex (while here we need per-pixel lighting)
- it doesn't provide additional effects, such as shadows (which require complex calculations with the scene's geometry), glow, etc.

OpenGL lighting is ok to have some fun, but it's definitely too basic to be used in a serious game.
Title: SFML Light System - Let There Be Light
Post by: lolz123 on March 20, 2012, 03:37:11 am
New version (1.3) is out, with the new attenuation shader and light bloom!
Title: SFML Light System - Let There Be Light
Post by: Ockonal on March 20, 2012, 01:45:00 pm
Good job!
Title: SFML Light System - Let There Be Light
Post by: Ockonal on March 20, 2012, 01:46:38 pm
Btw, are there any ideas you want implement into project too?
Title: SFML Light System - Let There Be Light
Post by: lolz123 on March 21, 2012, 04:11:43 am
Yes, the next thing I am going to try to implement is a per-sprite bloom effect.
Title: Re: SFML Light System - Let There Be Light
Post by: jmcmorris on March 25, 2012, 10:51:42 pm
This is some great stuff. I am planning to use it as a base for my lighting code in my game engine. I am currently working on understanding the system and how to do two things.

The first things is that right now the system will always stay at the starting screen position and not follow the view around. This means that when I move around my world, the lighting textures are only rendered at (0,0). I am initializing the LightSystem with an AABB region that is the entire size of my world and I'm updating the viewAABB center when the camera moves. Any ideas what I'm missing?

The other thing is that I have a world made up of tiles that can be added or removed arbitrarily. I was trying to come up with the best way to represent them in the light system as hulls. I have 3 different ideas.
I'm leaning towards the first one. I could only create hulls for the tiles that are nearby the player. Any suggestions? :)

Once again, this is great stuff. Thanks for releasing it!
Title: Re: SFML Light System - Let There Be Light
Post by: Grimshaw on March 26, 2012, 12:51:40 am
Hello,

I am myself having trouble with the views...

When I render the sample light system with the view as GetDefaultView(), it renders correctly, even if i move my view around, but it always renders starting from (0,0) , even if i defined the AABB region as something different..
Title: Re: SFML Light System - Let There Be Light
Post by: jmcmorris on March 26, 2012, 02:02:54 am
Looks like we are having the same issue. If I figure it out I'll be sure to post it here. Hope you do the same ;)

EDIT:

I got it figured out - at least one way. You want to translate everything along with your view.

Vec2f viewSize(viewAABB.GetDims());
Vec2f viewStart(viewAABB.GetCenter().x - (viewSize.x / 2), viewAABB.GetCenter().y - (viewSize.y / 2));
glTranslatef(viewStart.x, viewStart.y, 0.0f);
 

Put this code in LightSystem::RenderLightTexture() after the glLoadIdentity();

I haven't played around with any lights yet so I'll soon see if everything else still works...
Title: Re: SFML Light System - Let There Be Light
Post by: Grimshaw on March 26, 2012, 02:57:14 am
I've done that either, its not the solution, there are some weird things in here..
Title: Re: SFML Light System - Let There Be Light
Post by: jmcmorris on March 26, 2012, 02:59:13 am
I was just about to revoke my solution as I can see it is not right. I cant get lights to show up yet but I imagine they would follow the player...
Title: Re: SFML Light System - Let There Be Light
Post by: Grimshaw on March 26, 2012, 03:23:14 am
I can't believe this lighting solution was made without considering the situation where the render area is not the screen.. It simply does not work : (

Hey, lolz, can you fix this?

Since you rely on fixed dimensions for the quad tree, we should be able to place the quad tree anywhere like a drawable..

I would create a lighting system for example in (400,400) with size (1000,1000). I would put lights somewhere within (400-1400, 400-1400) so they are within the quad tree and render optimally.

Then, what should happen when I try to render is that the lighting texture is rendered exactly to fit the region I chose before.. This is not happening at all, Help? Thanks :)
Title: Re: SFML Light System - Let There Be Light
Post by: Roose Bolton of the Dreadfort on March 26, 2012, 05:12:59 am
Also having this problem, it was meant to be an addition made during this release with the 'SetView' function, however, it seems not to work. The only area that is lit is the area in the original view, if I scroll the view down, anything in the new area is not lit and ambient light does not effect it either.

TLDR; Lighting does not work on areas not in original viewport; SetView does not work.

If anyone can find a fix for this I will love them forever;

Thanks,

Matthew
Title: Re: SFML Light System - Let There Be Light
Post by: lolz123 on March 26, 2012, 11:18:11 pm
Oh, I see what you mean. Wow, I can't believe I missed that, sorry about that. A fix is under way!

@DevilWithin you can set the quad tree root region in the light system constructor. The AABB you pass it is the root region AABB.
Title: Re: SFML Light System - Let There Be Light
Post by: Grimshaw on March 27, 2012, 12:45:51 am
In the sample you pass the AABB as (0,0) (screenWidth, screenHeight)..

I have different quads around the world, with arbitrary size and position, i want each of them to display a tilemap and a lighting system on top with a light on its center for testing.

That doesn't work at all, tell me please how it would be done, both in AABB and view. Thanks :)
Title: Re: SFML Light System - Let There Be Light
Post by: lolz123 on March 27, 2012, 02:44:02 am
Alright, version 1.3.3 is up, I hope the views work properly now.
I also added some new features. The fins are now smoother, and there is a parameter in ConvexHull that allows you to specify if you want the light to render over the hull or not, so that objects under the convex hulls are visible. The demo has this setting enabled, so you can see it in action there.

@DevilWithin The darkness of the light system stretches indefinitely, in the new working version (not limited to the quad tree region). Changing the quad tree region only changes performance, nothing else. You mentioned multiple quads with light systems in each, are you trying to draw multiple, separate light systems at once? If so, I can add support for that, it is not a big change.

@jmcmorris Sorry, I missed you post! The game the light system originally came from, Gore Factor, also uses a tile map. Instead of generating hulls for every tile, I made it stretch the hull across multiple tiles, so there are less hulls in total (faster). The easy way of doing this is to make it attempt to stretch a hull horizontally or vertically as long as a there are consecutive tiles. If the map is modified, you would simply have to regenerate the hulls for the rows or columns (depending on your setup) of the map that contain modified tiles.
Title: Re: SFML Light System - Let There Be Light
Post by: jmcmorris on March 27, 2012, 02:49:43 am
Thanks for fixing this so quickly. I'll test this out later this evening. Also thanks for responding to my question. I was thinking of doing something like that. I had actually done a similar thing with box2d and it's chain shape for my tile map in the past.

Once I get something worth showing, I'll post what I am using your lighting system for. :)

Thanks again!
Title: Re: SFML Light System - Let There Be Light
Post by: Grimshaw on March 27, 2012, 03:13:44 am
You mentioned multiple quads with light systems in each, are you trying to draw multiple, separate light systems at once? If so, I can add support for that, it is not a big change.

That is exactly what i am doing :) If everything is properly encapsulated, that should work automatic, if it works for one case, it should work for all..

I want to have rectangles, with any proportions, which act as boundaries for the light system quad tree. Lights may go out of the rectangle, but will not lose the normal proportions, whatever the rectangle is.. This is because i have arbitrary sized streaming regions. They are pretty big, so i need to make a clear separation, and fast enabling/disabling of a region.

Plus, I don't get it about the views, what is written in the manual. The view should be synced in lighting and in world... This is exactly what i dont want, why would the light follow the view as some kind of ui? that doesn't make sense to me, if the world view moves, it simply sees another part of the lighting system, what if i have my regions with different systems, all in screen at once with a large zoom out?
Title: Re: SFML Light System - Let There Be Light
Post by: DJuego on March 28, 2012, 07:13:30 pm
It seems fantastic!   :o Thank you lolz123!

However I prefer to wait to build it with the new SFML naming convention. ??? I am anxious!  :P

DJuego
Title: Re: SFML Light System - Let There Be Light
Post by: jmcmorris on March 29, 2012, 11:47:27 am
It is going much better, but I have found two bugs regarding the convex hulls.

First is that the shadow fins will show up sometimes when they shouldn't. This can be seen with a rectangle convex hull. To reproduce this change the testShape.txt file to this...
Code: [Select]
-25 -50
-25 50
25 50
25 -50

And here is a screenshot of it - http://grab.by/czYM (that is suppose to be a box hull)

The other bug deals with the same setup. Regardless if you set ConvexHull::renderLightOverHull to true or false it still fills in the hull with the ambient light. It does work with the initial testShape.txt but not this modified one.

EDIT:

I have a question about hulls. How difficult would it be to make a hull transparency? An example would be if a hull is 50% transparency then it only blocks 50% of the light. Right now it is all or nothing.

I could see this adding a decent amount of complexity though. Since this would mean that a light source could be broken down not only by distance but also how many objects it has passed through.
Title: Re: SFML Light System - Let There Be Light
Post by: lolz123 on March 30, 2012, 10:19:40 pm
What you have encountered is not a bug, you just specified the vertices in the wrong order. They have to be specified in a counter-clockwise order, or else the normals (and therefore the shadow boundaries) will not generate properly.

I'll see what I can do to get some hull transparency rendering going  ;)

EDIT: Please note that LTBL coordinates do not have the Y axis flipped like in SFML
Title: Re: SFML Light System - Let There Be Light
Post by: jmcmorris on March 30, 2012, 10:31:16 pm
That's not counter-clockwise? It starts at the top left, goes to bottom left, then bottom right and then bottom top. What is counter-clockwise according to ltbl? I'll play with it once I get home.

I think hull transparency could be useful in several scenarios. The one I was planning on using it for is having the ambient light be nearly pitch black and then have the character cast a light shadow so that way it doesn't obscure the player's vision.

EDIT:

Ah, I see. so I actually want something like this... right?
Code: [Select]
-25 50
-25 -50
25 -50
25 50
Title: Re: SFML Light System - Let There Be Light
Post by: lolz123 on March 31, 2012, 12:45:20 am
Those coordinates will work fine. I am working on the hull transparency, shouldn't be a big modification. All it needs to do is render the shadows a bit lighter.
Title: Re: SFML Light System - Let There Be Light
Post by: Grimshaw on March 31, 2012, 01:35:14 am
EDIT: Please note that LTBL coordinates do not have the Y axis flipped like in SFML

Can you elaborate a little on that? Im a little confused here. So you say there is already a way to do what i need?
Title: Re: SFML Light System - Let There Be Light
Post by: jmcmorris on March 31, 2012, 02:11:48 am
@DevilWithin What he means by that is that the y coordinates starts at the bottom of the screen instead of the top. Which is why you need to do something along the lines of...
Code: [Select]
light.SetCenter(ltbl::Vec2(position.x, window.Height() - position.y))
I didn't realize that this is the case for the vectors as well - I should have though. :)

A side note, I'm actually thinking of modifying the ltbl code a little to make it so that it will automatically flip it for me because having to do that all of the time is not too friendly.
Title: Re: SFML Light System - Let There Be Light
Post by: Grimshaw on March 31, 2012, 02:34:54 am
That is something kinda important to have missed, I will try around with that, hoping it solves my issues :)
Title: Re: SFML Light System - Let There Be Light
Post by: jmcmorris on March 31, 2012, 02:57:54 am
Haha, yes it is quite important. Look at the ltbl example in main.cpp - it does this. :)
Title: Re: SFML Light System - Let There Be Light
Post by: Grimshaw on April 03, 2012, 02:10:40 pm
Hello,

When will the lighting system come out for the new name convention?
Also, is it actually ready to have multiple lighting systems in one app?

Thanks
Title: Re: SFML Light System - Let There Be Light
Post by: Ockonal on April 03, 2012, 04:17:44 pm
Could you, please, put this changes into source to receive multiplatform support:

Add #include <memory> into LightSystem.h (for the std::unique_ptr)
The other troubles are already solved (thanks).

The only problem is that I'm using latest git sources and the naming of functions changed (setView instead of SetView). Maybe you will work with the newest  code?
Title: Re: SFML Light System - Let There Be Light
Post by: Ockonal on April 03, 2012, 06:46:12 pm
Btw, due to changes in latest sfml commit (naming of fucntions) I have reviewed the code of Light System and changed all sfml's naming from upper case to lower case.

Here is upgraded source code: http://dl.dropbox.com/u/932520/lighting.zip

It full-compatible with linux and latest sfml-git.

Only sfml's function naming is changed. I hope I will help in any way the author of this lib ;)
Btw. Now, I think, you also should rename all of your functions.
Title: Re: SFML Light System - Let There Be Light
Post by: jmcmorris on April 03, 2012, 07:56:29 pm
lolz123, perhaps you want to consider putting this up on github? Then people could fork and make pull requests in other words, contribute. Just a suggestion! :)
Title: Re: SFML Light System - Let There Be Light
Post by: lolz123 on April 03, 2012, 11:29:26 pm
@jmcmorris: I will give that a try, it will take a bit of time for me to figure it out though, since I have never used it before.

I will switch to the new SFML naming convention in the next version of the light system, which should be finished pretty soon.
Title: Re: SFML Light System - Let There Be Light
Post by: jmcmorris on April 03, 2012, 11:46:59 pm
I would be up to helping you out with that if you'd like. Have you used Git before? If not how about SVN or some other version control?

I recently started using Git, but I have been using SVN for years now. It is reasonably similar and not too difficult. Github seems like the best place to get hosting - SFML uses it. :)
Title: Re: SFML Light System - Let There Be Light
Post by: Digital on April 08, 2012, 06:01:57 pm
I'm having trouble getting the emissive light to work (light point is fine). The whole screen turns white when it renders.
Title: Re: SFML Light System - Let There Be Light
Post by: lolz123 on April 09, 2012, 06:36:22 pm
The newest version of SFML defaults to not blending the render textures. You can either use an older SFML build, or wait for the next version of the light system to come out (soon!).
Title: Re: SFML Light System - Let There Be Light
Post by: Grimshaw on April 09, 2012, 08:28:13 pm
Hey lolz, i know i am an ungrateful bastard for always asking stuff when you already give so much, but i would like to ask if you can test the situation i stated some days ago.

It would be great if you could ship the next version with full support for having multiple completely independent lighting systems going on, you said it would be easy to do!

Thanks my friend :)
Title: Re: SFML Light System - Let There Be Light
Post by: lolz123 on April 10, 2012, 02:24:27 am
No problem, it will be in the next version  ;)
Title: Re: SFML Light System - Let There Be Light
Post by: Digital on April 10, 2012, 05:11:13 am
The newest version of SFML defaults to not blending the render textures. You can either use an older SFML build, or wait for the next version of the light system to come out (soon!).

Ah, thanks for the reply. I'll gladly wait it out and work on other aspects of my game in the meantime.
Title: Re: SFML Light System - Let There Be Light
Post by: StormWingDelta on April 11, 2012, 07:21:55 pm
Just wondering. Does this work for Code::Blocks?  Not sure if this was mentioned yet or not.
Also is there anything else to download that is needed for your lib to run?  Just wondering since a while back I downloaded this and not even the examples worked for some reason.
Title: Re: SFML Light System - Let There Be Light
Post by: Digital on April 12, 2012, 06:34:18 am
Just wondering. Does this work for Code::Blocks?  Not sure if this was mentioned yet or not.
Also is there anything else to download that is needed for your lib to run?  Just wondering since a while back I downloaded this and not even the examples worked for some reason.

I'm running it on Code::Blocks just fine with MinGW (gcc 4.6.1). You just have to link SFML and GLEW (included with SFML source). Didn't need anything extra.
Title: Re: SFML Light System - Let There Be Light
Post by: Grimshaw on April 13, 2012, 10:20:25 pm
Hey, any update on the progress? =))
Title: Re: SFML Light System - Let There Be Light
Post by: Roose Bolton of the Dreadfort on April 16, 2012, 07:21:48 pm
Hey Lolz..

I hope your still here.. I'm so depressed :(

Something I think you might have changed has broken something in the latest release.

Before, if I added a light, it would light up the texture behind it, which was cool because you could set the ambient light to (0,0,0) and it would be dark everywhere, then you could have a torch or lights light up certain areas, this does not work anymore.

the lights dont actually light up the texture behind them, it seems as if its on another layer

test it yourself,

add a big background image, set the ambient light to (0,0,0) then place a light in the centre, you wont see the light.

I hope you can fix this it's major to the little game I'm making and I was enjoying it so much :(

Cheers
Title: Re: SFML Light System - Let There Be Light
Post by: lolz123 on April 19, 2012, 04:54:07 pm
It doesn't work anymore because of some changes in SFML.
The new version will fix this, sorry that it is taking so long. It is nearly done though, it will probably be released this weekend.
Title: Re: SFML Light System - Let There Be Light
Post by: Roose Bolton of the Dreadfort on April 19, 2012, 07:04:02 pm
I haven't updated my SFML though?

either way, thanks a lot - cant wait :D
Title: Re: SFML Light System - Let There Be Light
Post by: HighQuality on April 24, 2012, 09:07:09 pm
Got a new ETA for the new version?
Can't wait to test it out btw, looks awesome :)

Will this system work for a huge world and will it be relatively fast? (for example 65536x65536 pixels)
Also, how would you go about programming something similar to a sun outdoors, so it casts shadows in the same angle on all objects for example.
Title: Re: SFML Light System - Let There Be Light
Post by: lolz123 on April 26, 2012, 12:10:46 am
Sorry that it is taking so long, the new version of SFML introduced a lot of new bugs  :P, and I also took part in Ludum Dare this past weekend. Most of the bugs come from the render textures (FBO's/pBuffers).

I may just do FBO's manually in OpenGL (thus really making it entirely SFML-independent), so future updates to SFML will not affect anything. Also, it would then be faster on my machine (and therefore probably others as well), since render textures take entire seconds to create on my machine for some reason, but normal FBO's are instantaneous.

Hopefully it will be finished by this weekend ::)

@ HighQuality:
The system can support massive worlds, since it has a spatial partitioning system. How fast it runs depends on the density of the lights, since more on screen at a time will be slower.

I thought about a separate sun feature before, I will work on it in the version following the next version.


Title: Re: SFML Light System - Let There Be Light
Post by: jmcmorris on April 26, 2012, 12:20:10 am
Looking forward to the next update!

I'm curious how you would go about creating this sun feature. I'm not sure how you could detect if the player is underground or not without having knowledge of the rest of the world.

I am working on a sandbox game, which I'm guessing is what HighQuality is doing. This is what I plan on doing... I have a wall tile layer and one for the ground as well. If the both are empty then I will fill that space in with light.
Title: Re: SFML Light System - Let There Be Light
Post by: HighQuality on April 26, 2012, 06:59:00 pm
@lolz123
That's great, participated in Ludum Dare as well, although I didn't finish the game on time due to it being too ambitious and I decided to quit a little after midnight around 3 hours before the competition ended (I'm from Sweden)

@jmcmorris
Actually I'm "porting" the engine a Game Maker project of mine to C++, it's an online rpg, won't call it an MMO yet since it's not massive by any means so far although it got the potential to be (I'm not exactly porting it, it's more of a remake)
The Game Maker version got about 15 months in the works and the C++ one like one.
Got more than 2 years experience of multiplayer programming in GameMaker through 39dll and got a basic understanding about how most stuff on the internet works.
If you wish you can check out our website at www.nevereal.net
Anyways, won't turn this topic into a discussion about our private projects more than I've already done since that's pretty offtopic and most likely breaks the forum rules.
Title: Re: SFML Light System - Let There Be Light
Post by: scorch on May 01, 2012, 03:17:18 pm
Will this support normal maps? It's the only thing I miss in this light system. :D
Title: Re: SFML Light System - Let There Be Light
Post by: lolz123 on May 02, 2012, 12:32:19 am
Sorry that it has been taking so long. Anyways, there is now a new version (1.5) that works with the latest SFML2! The code has been completely restructured, and a naming convention was adopted.

So, now all you have to do to use it in your project is link to the Source folder for a static link, and then link to OpenGL. Glew is no longer a dependency.

I added the hull transparency feature, but it is not quite working yet  :-[. It will render a bit strangely at the moment. It will be fully functioning in the next version.

I am now working on sunlight, normal maps, and the ability to run multiple separate light systems for the next version ;)
Title: Re: SFML Light System - Let There Be Light
Post by: DJuego on May 02, 2012, 01:02:42 pm
I am deeply interested in the evolution of this project. Thank you very much for your efforts, Lolz123!
It seems destined to be an amazing tool.

P.S.

From manual:  'A self-expanding quad tree is currently still in development, there are still a lot of bugs to iron out.'   :P This is incredible!!




DJuego
Title: Re: SFML Light System - Let There Be Light
Post by: scorch on May 02, 2012, 06:23:14 pm
If you can implement normal maps, perhaps I'll have a look on porting it to .NET (if you don't mind ;D) so that I can use it on a project of mine.  ;)
Title: Re: SFML Light System - Let There Be Light
Post by: N1ghtly on May 02, 2012, 09:53:45 pm
Along with the Thor library this is the most interesting library for SFML in my opinion :)
Title: Re: SFML Light System - Let There Be Light
Post by: nulloid on May 03, 2012, 03:43:16 am
Quote from: Lolz123
I added the hull transparency feature, but it is not quite working yet  :-[. It will render a bit strangely at the moment. It will be fully functioning in the next version.

Maybe my solution I've just implemented today will work for you. See examples here. (http://scotophobos.blogspot.com/2012/05/9-transparency.html) At the end of the post, there is a series of equations, telling you the color components of the shadow's color. (Note, that this is not a physically correct model, as far as I know.) The shapes are just alpha-blended on the shadowed texture. I think it is not the best solution, but that's not related to the problem.

Unfortunately, I can't just copy the code, since it is written in Haskell. (Only the rendering is done by SFML, the calculation of colors is in Haskell. But if you want to see, just ask :))

Also, if you have any other idea, please, share with me. Maybe that's better than this.

A question: will you implement mirrors? Because if so, I'll really consider using your engine instead of mine. (I have some ideas related to this, too, so maybe I can help.)
Title: Re: SFML Light System - Let There Be Light
Post by: lolz123 on May 04, 2012, 12:18:18 am
Thanks for the link! However, I am doing transparency without color at the moment. It just makes only some of the light shine through, but does not change the color of the light. I didn't even think of doing different colors yet, maybe I will try to add that later. If I do, I will probably have another look at your equations  ;). My idea at the moment would be to render the shadows with the transparent object's color with multiplicative blending to the lighting buffer, after having rendered the light to it.

I am not sure why you would want mirrors in a 2D game, since you will not see anything really interesting, unless you are shining a laser at it. Curved mirrors would be pretty difficult (if not composed out of a lot of small planar mirrors which would make it insanely processing intensive), but a planar mirror should be possible, if you render a second light representing the image of the light source in the mirror, and then invert the shadow masking for the mirror. That, or you could stencil out the part overlapping the mirror and then flip it. I'll give it a try once I complete the existing feature list  :)
Title: Re: SFML Light System - Let There Be Light
Post by: DJuego on May 04, 2012, 12:55:36 am
Damned nostalgia!

   Mirrors+Laser+2D = DEFLEKTOR (in my good old Commodore 64).

   http://www.youtube.com/watch?v=G4R1yai4nvA (http://www.youtube.com/watch?v=G4R1yai4nvA)

The physic for plane mirror in this case (beams of highly coherent light) is relatively easy. "the angle of incidence equals the angle of reflection" and so...

 ;D

P.S: I suggest a change log for Let There Be Light.

DJuego

Sorry for my English!

Title: Re: SFML Light System - Let There Be Light
Post by: lolz123 on May 04, 2012, 01:34:15 am
Lasers would be pretty simple, but would be completely separate from the rest of the light system. But, I can add it if you like. I was thinking more about mirrors for point light sources, those would  be a lot harder to do :)
Title: Re: SFML Light System - Let There Be Light
Post by: nulloid on May 04, 2012, 05:01:37 am
Quote from: lolz123
I am not sure why you would want mirrors in a 2D game...
I'm making a puzzle game based on lights. That is why I need a mirror, and colored lights and transparency and such. Without them, the puzzles would be slightly boring.

Quote from: lolz123
...but a planar mirror should be possible, if you render a second light representing the image of the light source in the mirror, and then invert the shadow masking for the mirror.
This is exactly what I have in mind. The interesting part kicks in when some mirrors are facing at each other, or are in an angle next to each other, so light bounces off them multiple times. Ahh.. thinking is sometimes just plain tiring. :D

Quote from: lolz123
Curved mirrors would be pretty difficult...
Whoa, man, these kind of ideas give me a heart attack :D Yes, they would be, at least with a vector-based engine. And I don't even dare to think about refractions... with curved surfaces...

Thanks for the answers, and keep up the good work :)
Title: Re: SFML Light System - Let There Be Light
Post by: DJuego on May 19, 2012, 01:02:01 pm
Just keeping the sentiment alive.  ;D

DJuego
Title: Re: SFML Light System - Let There Be Light
Post by: Roose Bolton of the Dreadfort on May 26, 2012, 04:11:35 pm
Argh!

Just finished my University work and was about to start again working on my hobby game and noticed the new SFML update that fixes a big error.

I downloaded it and noticed the all the directories and installation method has changed..

can anyone explain how to install this?

before it was just drag into your project which was easy...

I have tried to include LTBL/ but to no avail :(
Title: Re: SFML Light System - Let There Be Light
Post by: lolz123 on May 26, 2012, 08:26:08 pm
Just link to the "Source" folder, and include the headers like so: #include <LTBL/.../...>
Title: Re: SFML Light System - Let There Be Light
Post by: Roose Bolton of the Dreadfort on May 27, 2012, 05:02:47 am
Hey mate!

Yeah that worked -,- haha thanks..

I noticed you haven't included your source to the demo program anymore so its hard to run tests :( and the code in your PDF readme does not have the fixed naming conventions and is throwing errors at really strange stuff like

Code: [Select]

ltbl::Light* testLight = new ltbl::Light();


Saying 'object of abstract class not allowed'

also - did you fix the problem where a light wouldn't actually 'light' up the texture, but just put a fake overlay on top - so if the ambient light was (0,0,0) there would be no light anywhere even if there was a light where i was standing? as I wanted to do a game with 0 ambient light and where lights would actually 'light' up an area - this actually worked in your first few versions but broke recently :(

Cheers Lolz - great work.
Title: Re: SFML Light System - Let There Be Light
Post by: lolz123 on May 27, 2012, 01:13:58 pm
I didn't update the example program in the manual properly yet (sorry about that  :P), instead of Light it is now Light_Point which inherits from Light.

For the texture lighting problem, I am not quite sure how you are getting that. You must render the light texture at the very end of a frame, or else the multiplicative blending won't work. It sounds like you are getting normal alpha blending instead of multiplicative blending somehow.
Title: Re: SFML Light System - Let There Be Light
Post by: Roose Bolton of the Dreadfort on May 28, 2012, 01:25:20 am
It might have been something I was doing but I was definetly rendering the lights last - I want to test with this version now but still getting problems.

I have fixed up your example code to the new naming conversions as follows;

 

#include <LTBL\Light\LightSystem.h>
#include <LTBL\Light\Light_Point.h>

#include <assert.h>


#include <SFML/Graphics.hpp>

int main(int argc, char* args[])
{

        sf::VideoMode vidMode;
        vidMode.width = 800;
        vidMode.height = 600;
        vidMode.bitsPerPixel = 32;
       
        sf::RenderWindow win;
        win.create(vidMode, "Let there be Light - Demo");
        // ---------------------- Background Image ---------------------
        sf::Texture backgroundImage;
        backgroundImage.loadFromFile("data/background.png");

        // Tiling background
        backgroundImage.setRepeated(true);

        sf::Sprite backgroundSprite(backgroundImage);
        backgroundSprite.setTextureRect(sf::IntRect(0, 0, vidMode.width, vidMode.height));

        // --------------------- Light System Setup ---------------------
        ltbl::LightSystem ls(AABB(Vec2f(0.0f, 0.0f), Vec2f(static_cast<float>(vidMode.width), static_cast<float>(vidMode.height))), &win, "data/lightFin.png", "data/shaders/lightAttenuationShader.frag");
        // Create a light
        ls.m_ambientColor = sf::Color(10, 255, 10);

        ltbl::Light_Point* testLight = new ltbl::Light_Point();
        testLight->m_center = Vec2f(200.0f, 200.0f);
        testLight->m_radius = 500.0f;
        testLight->m_size = 30.0f;
        testLight->m_spreadAngle = 2.0f * static_cast<float>(3.14159265);
        testLight->m_softSpreadAngle = 0.0f;
        testLight->CalculateAABB();

        ls.AddLight(testLight);

        sf::Event eventStructure;

        bool quit = false;

        while(!quit)
        {
                while(win.pollEvent(eventStructure))
                if(eventStructure.type == sf::Event::Closed)
        {

        quit = true;
        break;

        }
        sf::Vector2i mousePos = sf::Mouse::getPosition(win);
        // Update light
        //testLight->SetCenter(Vec2f(static_cast<float>(mousePos.x), static_cast<float>(vidMode.height - mousePos.y)));

        win.clear();

        // Draw the background
        win.draw(backgroundSprite);

        // Calculate the lights
        ls.RenderLights();

        // Draw the lights
        ls.RenderLightTexture();

        win.display();
        }

        win.close();
}

 

but no lights draw at all, is it possible you can upload your test sample code to pastebin or something?

Cheers Lolz!!
Title: Re: SFML Light System - Let There Be Light
Post by: zackhovatter on May 28, 2012, 03:39:04 pm
With the authors permission, I've created a git repository for this project and made a few changes.

https://github.com/hovatterz/light

- Uses Boost instead of C++0x
- Uses SMFL 2.0
- Uses CMake

Feel free to file issues or submit pull requests.
Title: Re: SFML Light System - Let There Be Light
Post by: DJuego on May 28, 2012, 05:16:26 pm
Thank you very much zackhovatter. I am anxious to be witness of any progress. :-D. I expect to take advantage of them medium-term.  ;D

DJuego

Sorry for My English

Cheers Lolz123!! Our Hero
Title: Re: SFML Light System - Let There Be Light
Post by: DJuego on June 01, 2012, 06:31:34 pm
OS: Windows 7 64bits 8GB RAM NVIDIA GeForce GT 220


zackhovatter... I tried your distribution

 - Visual Studio 2010
 - MinGW SJLJ GCC 4.6.2 - 32bits (official distribution)
 - CMake 2.88
 - SFML(Git) 2012-06-01 (Today)
 - Thor(Git)  2012-06-01 (Today) <- Unrelated.

In CMake I get the warning-for-developer:

(http://i302.photobucket.com/albums/nn103/DJuego_bucket/SFML/A.jpg)

and when i build:

(http://i302.photobucket.com/albums/nn103/DJuego_bucket/SFML/B.jpg)

It seems a problem with the SFML include path management. I have not knowledge about how CMake works internally.  :(. I am a ignorant.  :-[

DJuego.


Sorry for my English. :(

Title: Re: SFML Light System - Let There Be Light
Post by: Orobu on June 08, 2012, 07:20:21 pm
I have a question regarding viewport scaling. I'm currently working on a game were you can switch resolution and the viewport is scaling accordingly.

I'm trying to get this working with Let there be light as well but so far I haven't been able to get it to scale correctly if the window and viewport resolution does not match. this is how my viewport looks when the internal reoslution is 1600x900 and the window is 1024x600. How would I go about to make it correctly scale to my viewport?


[attachment deleted by admin]
Title: Re: SFML Light System - Let There Be Light
Post by: lolz123 on June 08, 2012, 09:47:47 pm
At the moment, it assumes the viewport is the same as the screen resolution. I can change that in a future version, but for now, try this:

In the LightSystem::RenderLightTexture() function, there is the following code:

glBegin(GL_QUADS);
                        glTexCoord2i(0, 0); glVertex2f(0.0f, 0.0f);
                        glTexCoord2i(1, 0); glVertex2f(viewSize.x, 0.0f);
                        glTexCoord2i(1, 1); glVertex2f(viewSize.x, viewSize.y);
                        glTexCoord2i(0, 1); glVertex2f(0.0f, viewSize.y);
                glEnd();

                if(m_useBloom)
                {
                        m_bloomTexture.getTexture().bind();

                        glBlendFunc(GL_ONE, GL_ONE);

                        glBegin(GL_QUADS);
                                glTexCoord2i(0, 0); glVertex2f(0.0f, 0.0f);
                                glTexCoord2i(1, 0); glVertex2f(viewSize.x, 0.0f);
                                glTexCoord2i(1, 1); glVertex2f(viewSize.x, viewSize.y);
                                glTexCoord2i(0, 1); glVertex2f(0.0f, viewSize.y);
                        glEnd();
                }

Change it to:

sf::Vector2u viewSizeui(m_pWin->getSize());

glBegin(GL_QUADS);
                        glTexCoord2i(0, 0); glVertex2f(0.0f, 0.0f);
                        glTexCoord2i(1, 0); glVertex2f(viewSizeui.x, 0.0f);
                        glTexCoord2i(1, 1); glVertex2f(viewSizeui.x, viewSizeui.y);
                        glTexCoord2i(0, 1); glVertex2f(0.0f, viewSizeui.y);
                glEnd();

                if(m_useBloom)
                {
                        m_bloomTexture.getTexture().bind();

                        glBlendFunc(GL_ONE, GL_ONE);

                        glBegin(GL_QUADS);
                                glTexCoord2i(0, 0); glVertex2f(0.0f, 0.0f);
                                glTexCoord2i(1, 0); glVertex2f(viewSizeui.x, 0.0f);
                                glTexCoord2i(1, 1); glVertex2f(viewSizeui.x, viewSizeui.y);
                                glTexCoord2i(0, 1); glVertex2f(0.0f, viewSizeui.y);
                        glEnd();
                }


I haven't tested it, but it should work.

Keep in mind that if you want to change internal resolution of the light system, you need to re-created it, since it relies on render textures.
Title: Re: SFML Light System - Let There Be Light
Post by: Orobu on June 09, 2012, 12:59:36 am
thanks for your quick reply!

I tried what you described and it is indeed stretched properly in the window. Only problem is that the lights are not properly scaled, meaning that if I create a light with a radius at 200 it will be the same size no matter the window resolution.
Title: Re: SFML Light System - Let There Be Light
Post by: lolz123 on June 11, 2012, 12:27:06 am
In LightSystem, where it says:

void LightSystem::CameraSetup()
{
        glLoadIdentity();
        glTranslatef(-m_viewAABB.m_lowerBound.x, -m_viewAABB.m_lowerBound.y, 0.0f);
}
 

Try changing it to:

void LightSystem::CameraSetup()
{
        glLoadIdentity();
        glScalef(m_viewAABB.GetDims().x / m_pWin->getSize().x, m_viewAABB.GetDims().y / m_pWin->getSize().y, 1.0f);
        glTranslatef(-m_viewAABB.m_lowerBound.x, -m_viewAABB.m_lowerBound.y, 0.0f);
}
 

Again, I didn't actually try it, but it should work. The next version of the light system will definitely have a scaling system  ;)
Title: Re: SFML Light System - Let There Be Light
Post by: 8p4hxc2 on June 17, 2012, 12:42:09 am
hi and thanks for this awesome library !!!!

Can you give us the source code of the sample? It could be helpfull since the doc is not up to date.

Thanks !!!
Title: Re: SFML Light System - Let There Be Light
Post by: lolz123 on June 17, 2012, 04:46:29 am
Of course! I uploaded it to Source Forge, you should be able to find it in the "Files" section. It is a .cpp called "Example".
Title: Re: SFML Light System - Let There Be Light
Post by: 8p4hxc2 on June 17, 2012, 09:49:32 am
there is only the 4 .zip, but there is 5 items, maybe a right problem?!
Title: Re: SFML Light System - Let There Be Light
Post by: 8p4hxc2 on June 18, 2012, 07:03:39 pm
it's ok now thx a lot !
Title: Re: SFML Light System - Let There Be Light
Post by: nulloid on June 19, 2012, 11:24:35 pm
Hi there again!

I know I should've asked it sooner, but... I think you have noticed the similiarity of the names between your library and my game. I want to ask: is it okay for you if I keep the name for my game (which I plan to release commercially), or should I change it?
Title: Re: SFML Light System - Let There Be Light
Post by: lolz123 on June 20, 2012, 03:23:35 am
Yes, I noticed. You can use it if you like, I don't mind.
Title: Re: SFML Light System - Let There Be Light
Post by: nulloid on June 20, 2012, 05:39:51 pm
Many thanks :)
Title: Re: SFML Light System - Let There Be Light
Post by: jmcmorris on June 23, 2012, 12:10:05 am
I am once again looking into lighting for my project.

lolz123, did hull transparency make it's way into LTBL? If so then how does it work? What I'm hoping to do is something along the lines of Terraria where each layer of the ground partially blocks the light. http://terraria.org/media.html (http://terraria.org/media.html).

The tricky part seems to be having the ground cast shadows as well as partially block the light. So I want it to act as a hull but not completely. I'm going to continue researching this but I was just checking to see if you have any suggestions on how I should go about doing this.

Thanks! :)
Title: Re: SFML Light System - Let There Be Light
Post by: lolz123 on June 23, 2012, 03:43:05 pm
It's in there, but not quite working yet. It has some blending issues. However, you don't really need it for the effect you see in Terraria. It would actually be way to processing intensive to have a single hull for every one of those tiny tiles. Terraria doesn't even have shadows, it just lights up grids depending on the distance from the surface and the sides. If you want both the effect in Terraria as well as shadows, you can set the shadows to not fill the hulls (using renderLightOverHull), and then just darken the tiles yourself. Then, you can group lots of tiles into larger hulls to increase performance.
Title: Re: SFML Light System - Let There Be Light
Post by: jmcmorris on June 23, 2012, 08:34:47 pm
Thanks for the reply. I did consider using renderLightOverHull and I know how I would darken the tiles with the ambient light (sun). I was thinking that the problem then would be darkening/lighting the tiles with dynamic light. Thinking about it more, I believe I would just need to do tile lighting calculations myself.

If I did things this way then I believe I would only need to have hulls for the surface facing tiles. I think I would only keep hulls around that are nearby the player to further optimize things.

Thanks for the thoughts lolz123. :)
Title: Re: SFML Light System - Let There Be Light
Post by: DJuego on July 29, 2012, 04:33:14 am
Lolz123, Do you consider to expand -Let There Be Light- to other post-effects like Fog of War (FOW), blur, illusory or sickest vision, ...?

If not, would you consider to create a separate library?  ;D

* I want to say a explicit|true Fog of War.  Perhaps a very generic|basic FOW encapsulated in a library. (Hard, soft, translucent fog)

And... a new -Let There Be light- release in the inmediate future, perhaps? :P

DJ

P.S: My English is crap, I know.  >:(
Title: Re: SFML Light System - Let There Be Light
Post by: Grimshaw on July 29, 2012, 08:57:44 pm
Lolz123 I have a very big thing to ask you.

As you may know i support a cross platform engine, with mobile support etc.
I wanted to use your library along with it, but it will only be possible if you separate the render from logic, so i can easily extend and write a GLES renderer.

Is that something possible for you to do? You would see your work in iOS, android etc :P
Title: Re: SFML Light System - Let There Be Light
Post by: kurasu1415 on July 29, 2012, 11:38:31 pm
Are using the CPU or the GPU to render the shadows?
Title: Re: SFML Light System - Let There Be Light
Post by: Grimshaw on July 30, 2012, 12:39:21 am
All cpu so far if im not mistaken.
Title: Re: SFML Light System - Let There Be Light
Post by: jmcmorris on July 30, 2012, 12:40:55 am
Yeah, all of the shadows are calculated on CPU. The only shader that is used is for light attenuation.
Title: Re: SFML Light System - Let There Be Light
Post by: Beernutts on August 03, 2012, 05:31:28 am
Hi Lolz123,

Just wanted to let you know I had to modify v1.5 to get ti to run on my system properly.

I'm using Code::Blocks, Mingw 4.6 on Win7.  Here's the what happens:

After moving around a bit, I'm constantly calling Light_Point::SetCenter(), and eventually, in QuadTreeOccupant::TreeUpdate(), it calls m_pQuadTreeNode->Update(this);

However, it seems in QuadTreeNode::Update(), m_pQuadTree == NULL, so it crashes at the calls m_pQuadTree->m_outsideRoot.insert(pOc);

So, to fix this, I added this check in QuadTreeOccupant::TreeUpdate() (see past else)
        void QuadTreeOccupant::TreeUpdate()
        {
                if(m_pQuadTree == NULL)
                        return;

                if(m_pQuadTreeNode == NULL)
                {
                        // If fits in the root now, add it
                        QuadTreeNode* pRootNode = m_pQuadTree->m_pRootNode.get();

                        if(pRootNode->m_region.Contains(m_aabb))
                        {
                                // Remove from outside root and add to tree
                                m_pQuadTree->m_outsideRoot.erase(this);

                                pRootNode->Add(this);
                        }
                }
                else
                {
                    if (m_pQuadTreeNode->GetTree() == NULL)
                    {
                        m_pQuadTreeNode->m_pQuadTree = m_pQuadTree;
                    }
                    m_pQuadTreeNode->Update(this);
                }

        }
 

There's probably a more efficient way to do this, but it's what I did to get it working.

Thanks!
Title: Re: SFML Light System - Let There Be Light
Post by: lolz123 on August 03, 2012, 12:24:41 pm
Sorry for the late response!

@DJuego: You can modify the light system to act as fog of war, you just need to change the blending equation in LightSystem::Render() as well as the ambient color. I don't think I will make a general shader effects library. Writing things like blur shaders is not very hard, a quick google search will give you the code to do it.

@DevilWithin: I don't really understand what you want to do. The shadow calculation cannot be separated from rendering, if that is what you mean. You cannot have rendering occur without CPU driven logic in between, since you need to switch FBO's all the time which makes it hard to render batches of polygons.

@Beernutts: It is probably unrelated, but I found a big bug in the QuadTreeNode::Remove() function. It can actually infinitely loop, since I forgot to advance the parent node pointer  :P. To fix it, change QuadTreeNode::Remove() to:

void QuadTreeNode::Remove(QuadTreeOccupant* pOc)
        {
                assert(!m_pOccupants.empty());

                // Remove from node
                m_pOccupants.erase(pOc);

                // Propogate upwards, merging if there are enough occupants in the node
                QuadTreeNode* pNode = this;

                while(pNode != NULL)
                {
                        pNode->m_numOccupantsBelow--;

                        if(pNode->m_numOccupantsBelow >= minNumOccupants)
                        {
                                pNode->Merge();

                                break;
                        }

                        pNode = pNode->m_pParent;
                }
        }
 

I also uploaded a new version with this fix in it (1.5.1).

The fix you implemented will just hide any quad tree reshaping issues, so it is only a temporary solution.

I am working on a new 2D light system that uses more modern OpenGL (no more glBegin/glEnd stuff) and is completely independent from SFML (OpenGL/GLEW only). So you can also use it with GLUT, SDL, or whatever you prefer. It will use deferred shading for normal mapping. I may still update this one as well though.
Title: Re: SFML Light System - Let There Be Light
Post by: Beernutts on August 03, 2012, 01:57:58 pm
Hi Lolz123,

Thanks for the relpy:
Quote
The fix you implemented will just hide any quad tree reshaping issues, so it is only a temporary solution.

Well, that's not good.  Any idea why, in QuadTreeNode::Update(), m_pQuadTree is NULL, which causes a crash (much worse that hiding quadtree reshaping issues :) ? 

Either way, I'll keep an eye out for your new library.  I'm not dependent on the SFML parts of the code, so I should be fine using the new one.

Thanks!
Title: Re: SFML Light System - Let There Be Light
Post by: panithadrum on August 03, 2012, 01:58:26 pm
I am working on a new 2D light system that uses more modern OpenGL (no more glBegin/glEnd stuff) and is completely independent from SFML (OpenGL/GLEW only). So you can also use it with GLUT, SDL, or whatever you prefer. It will use deferred shading for normal mapping. I may still update this one as well though.

I wanted to do the same for my future games. I would love to contribute, but my experience in OpenGL is quite inexistent. You could host it at Github :P There are lots of us coding there.
Title: Re: SFML Light System - Let There Be Light
Post by: Ruckamongus on August 03, 2012, 07:17:10 pm
Hello everybody, I'm having some issues getting this to work. I thought maybe I wasn't setting up the world or the shapes properly so I compiled the example code. I made absolutely no modifications to it at all, and it compiles and runs, but this is what I see:

http://postimage.org/image/hh9kokr75/ (http://postimage.org/image/hh9kokr75/)


This is the case with 1.5 and 1.5.1. I'm using GCC 4.7 and the latest SFML source. Any help would really be appreciated. :)
Title: Re: SFML Light System - Let There Be Light
Post by: lolz123 on August 03, 2012, 07:56:04 pm
Oh, I accidentally set the transparency of the hull in the example to 0. Remove the line that does that, and it should work. I'll update the example.

Transparency doesn't quite work yet, the shadow fins don't blend properly.
Title: Re: SFML Light System - Let There Be Light
Post by: Grimshaw on August 04, 2012, 12:44:17 am
Okay, the new lighting system idea sounds perfect!

Can you leave a little room for extending? I would want GL ES rendering as well, even if i have to implement it :)
Title: Re: SFML Light System - Let There Be Light
Post by: Verra on August 19, 2012, 11:32:32 pm
so first off pretty great library dude, i'm going to be doing a lot of stuff with it and modifying it.  :) second I did have a lot of trouble with your 1.5.1 release in EclipseCDT - MinGW - gcc 4.7 a lot of errors were being thrown. So my friend and I took about 7 hours to fix it all :( so now it works pretty well with everything I've got. I'm going to be building an archive file of it soon so you don't have to stick the source in to your project.

Now for the fun part this is the test project I was using. It combines box2d and the ltbl library similar to how you used it in your gore factor remake. I had a few questions about optimization. I've noticed that it has some issues with objects on the same plane, it likes to render shadows on top of things it shouldn't I don't know if it's just because it doesn't take into account other blocks when it renders each one, but is there a way to stop shadows from going through other blocks. Second how would I turn down the intensity of the shadow I noticed in your gore factor game that the shadows were very soft and not quite as hard as the ones in 1.5.1 how would I replicate that. And lastly :) what's the easiest way to optimize ltbl with box2d so that when you render the shadow it actually keeps up with the physics shape. I've noticed that when I throw a box instead of just being slow to render things the box2d will render faster than the shadow does even though they happen sequentially before I display them on the screen. i.e the shadow will be in a previous position of the box.

Just to show what is happening in my test project here are some screen shots.
(http://i.imgur.com/ogscn.png)
(http://i.imgur.com/xXrsM.png)
(http://i.imgur.com/0TOmb.png)
Title: Re: SFML Light System - Let There Be Light
Post by: posva on August 21, 2012, 01:33:43 pm
Is there anyway to get this working without C++11 ? I'm trying to use boost to replace unordered_set but unique_ptr does not exists and I was wondering if an auto_ptr would be enough. Anyway it would be great to have this also working for non C++11 compilers. I also noticed some errors at compilation like determining a class a friend of himself.
Thanks, keep up the good work!

Edit: I tried what I said and I managed to correctly launch the example you provide. But I still don't know if an auto_ptr is enough for you or not. I can upload what I modified if you want. I really like your light and being able to use it would be great! :D

Edit: There are a lot of warning I'm trying to correct, also not used variables like m_render in convexhull and not initialized variables on constructors. Not initialized variables may give unexpected behaviours

Edit: I found this portion of code weird:
void Light_Point::RenderLightSolidPortion()
    {
        float renderIntensity = m_intensity;

        // Clamp the render intensity
        if(renderIntensity > 1.0f)
            renderIntensity = 1.0f;

        assert(renderIntensity >= 0.0f);

        float r = m_color.r * m_intensity;
        float g = m_color.g * m_intensity;
        float b = m_color.b * m_intensity;

        glBegin(GL_TRIANGLE_FAN);

        glVertex2f(m_center.x, m_center.y);
     
        // Set the edge color for rest of shape
        int numSubdivisions = static_cast<int>(m_spreadAngle / m_lightSubdivisionSize);
        float startAngle = m_directionAngle - m_spreadAngle / 2.0f;
     
        for(int currentSubDivision = 0; currentSubDivision <= numSubdivisions; currentSubDivision++)
        {
            float angle = startAngle + currentSubDivision * m_lightSubdivisionSize;
            glVertex2f(m_radius * cosf(angle) + m_center.x, m_radius * sinf(angle) + m_center.y);  
        }

        glEnd();
    }

You don't use the color created, also why calculating renderIntensity and then use m_itensity? Is that what you meant to write? :
...
Color3f(m_color.r * renderIntensity, m_color.g * renderIntensity, m_color.b * renderIntensity).GL_Set();
glBegin(....
Title: Re: SFML Light System - Let There Be Light
Post by: lolz123 on August 22, 2012, 03:39:27 am
@Verrazano

Quote
it likes to render shadows on top of things it shouldn't
At the moment, there are only 2 settings for how the shadows are drawn over the hulls. One with hull self-shadowing and one without. There is not yet a setting to leave hulls completely unaffected by shadows. I am working on a more generalized OpenGL 2D lighting system, I'll include this feature in there  ;).

Quote
Second how would I turn down the intensity of the shadow I noticed in your gore factor game that the shadows were very soft and not quite as hard as the ones in 1.5.1 how would I replicate that
The intensity of the shadow cannot be adjusted at the moment.  That would require hull transparency, but that isn't really the effect you want in your case anyways. Actually, hull transparency is available in the library, but it doesn't quite work with the soft portion of the shadows yet.

In Gore Factor, I just raised the ambient light level.

Quote
what's the easiest way to optimize ltbl with box2d so that when you render the shadow it actually keeps up with the physics shape
The easiest way to make LTBL work with Box2D is to construct a hull from the transformed points of a b2PolygonShape, and update this hull whenever the shape's body is active. The problem you are having with the shadow being a frame behind is caused by rendering the lights before the physics are performed in a frame.

@posva

Quote
But I still don't know if an auto_ptr is enough for you or not
You can use auto_ptr instead of unique_ptr. I didn't put any unique_ptrs into STL containers, so it doesn't matter (auto_ptr cannot be copied).

Quote
I also noticed some errors at compilation like determining a class a friend of himself
I google'd this, it only seems to happen with gcc. But, it seems like you can just leave it out with gcc, since the class is implicitly a friend of itself.

Quote
I found this portion of code weird
The color thing is indeed a mistake, thanks for finding this! I didn't notice it, since the color values end up being clamped to a [0, 1] range anyways when rendering. So, you can just remove everything up until the glBegin statement, it doesn't do anything.

Quote
There are a lot of warning I'm trying to correct, also not used variables like m_render in convexhull and not initialized variables on constructors. Not initialized variables may give unexpected behaviours
m_render is indeed not used, thanks for finding this. However, you don't need to initialize variables in a constructor if that constructor value is never used for anything. They are set later on, so there shouldn't be any unexpected behavior.
Title: Re: SFML Light System - Let There Be Light
Post by: DJuego on September 24, 2012, 04:57:55 pm
Quote from: lolz123
I am working on a more generalized OpenGL 2D lighting system

Any update about this, Lolz? You have us in total suspense.  ;D

DJuego


Title: Re: SFML Light System - Let There Be Light
Post by: danikaze on December 02, 2012, 01:25:42 am
Sorry for asking this but...
how it's installed?

I tried to include <LightSystem.h> as the manual says but I get lots of errors (like inexistent Vec2f class).

I'm using codeblocks and I added the LTBL directory to the Build Options -> Search Directories -> Compiler.

Am I doing something wrong? :S
Title: Re: SFML Light System - Let There Be Light
Post by: lolz123 on December 03, 2012, 01:55:51 am
Unfortunately, I am not very familiar with Code::Blocks. Try adding it under Build Options -> Search Directories -> Linker.
Title: Re: SFML Light System - Let There Be Light
Post by: Predator106 on December 03, 2012, 01:56:51 am
are there any plans/progress on that opengl lighting system? i'd really, really like something like that.
Title: Re: SFML Light System - Let There Be Light
Post by: lolz123 on December 03, 2012, 02:39:32 am
It is still being developed, slowly, as a side project. I can speed up the development though if you are interested in using it :). I uploaded the project to Github, so you can view progress there.

https://github.com/222464/GLLight2D (https://github.com/222464/GLLight2D)
Title: Re: SFML Light System - Let There Be Light
Post by: Predator106 on December 03, 2012, 02:42:26 am
hell yeah i'm interested in it :D

I so would like something like this for my terraria clone of a game. just please make sure it uses cmake and compiles on linux out of the box. so annoying when people use visual studio's crappy buildsystem.
Title: Re: SFML Light System - Let There Be Light
Post by: DJuego on December 03, 2012, 04:18:57 pm
Quote
just please make sure it uses cmake and compiles on linux out of the box

I agree.  ;)

 I will wait until the previous functionality (Let There Be Light 1.51) be stable in the new GLLight2D.

Thank you very much lolz123 for the work, and thank you for  uploading the project to Github!  ;D

DJuego

Title: Re: SFML Light System - Let There Be Light
Post by: Predator106 on December 03, 2012, 04:45:45 pm
oh yes indeed, glad it's on github as well, way easier to look at/use, and if we need to patch it..say hello to merge requests ;)
Title: Re: SFML Light System - Let There Be Light
Post by: danikaze on December 04, 2012, 04:30:37 am
Unfortunately, I am not very familiar with Code::Blocks. Try adding it under Build Options -> Search Directories -> Linker.

But the linker is for .dll, .a and so, right?
Does the code needs to be compiled?

I'm not very used to C::B either... I come from VS2010 but wanted to try this in order to portability to Linux and Mac...
Title: Re: SFML Light System - Let There Be Light
Post by: danikaze on December 06, 2012, 09:14:21 pm
Ok. Finally I moved back to MSVC2010 and tried to use LTBT, but this is what I get...

Code: [Select]
1>AABB.obj : error LNK2001: unresolved external symbol __imp__glVertex2f@8
1>AABB.obj : error LNK2001: unresolved external symbol __imp__glEnd@0
1>AABB.obj : error LNK2001: unresolved external symbol __imp__glBegin@4
1>Color3f.obj : error LNK2001: unresolved external symbol __imp__glColor3f@12
1>ConvexHull.obj : error LNK2001: unresolved external symbol __imp__glVertex3f@12
1>ConvexHull.obj : error LNK2001: unresolved external symbol __imp__glTranslatef@12
1>EmissiveLight.obj : error LNK2001: unresolved external symbol __imp__glColor4f@16
1>EmissiveLight.obj : error LNK2001: unresolved external symbol __imp__glPopMatrix@0
1>EmissiveLight.obj : error LNK2001: unresolved external symbol __imp__glPushMatrix@0
1>EmissiveLight.obj : error LNK2001: unresolved external symbol __imp__glRotatef@16
1>EmissiveLight.obj : error LNK2001: unresolved external symbol __imp__glTexCoord2i@8
1>Light.obj : error LNK2001: unresolved external symbol __imp__glOrtho@48
1>Light.obj : error LNK2001: unresolved external symbol __imp__glMatrixMode@4
1>Light.obj : error LNK2001: unresolved external symbol __imp__glViewport@16
1>Light.obj : error LNK2001: unresolved external symbol __imp__glEnable@4
1>Light.obj : error LNK2001: unresolved external symbol __imp__glLoadIdentity@0
1>LightSystem.obj : error LNK2001: unresolved external symbol __imp__glColor4b@16
1>LightSystem.obj : error LNK2001: unresolved external symbol __imp__glDisable@4
1>LightSystem.obj : error LNK2001: unresolved external symbol __imp__glBlendFunc@8

Any idea? Anyone?
Title: Re: SFML Light System - Let There Be Light
Post by: lolz123 on December 06, 2012, 09:35:51 pm
You have to link to OpenGL.

Just add OpenGL32.lib under linker > input.
Title: Re: SFML Light System - Let There Be Light
Post by: danikaze on December 06, 2012, 10:15:37 pm
You have to link to OpenGL.

Just add OpenGL32.lib under linker > input.

Thanks, now it works! :)
It would be nice if you included depencencies, or at least a list of them in your git/svn/sourceforge releases :)

Anyway, a question. It's worth using this LTBL 1.5.1? Or the GL version will change the API too much?
Title: Re: SFML Light System - Let There Be Light
Post by: lolz123 on December 07, 2012, 01:07:27 am
It will be a while until GLLight2D is done, so it would probably be best to stick with LTBL 1.5.1 for a while. The API will change quite a bit. However, if you don't need any of the additional features (normal and specular mapping, HDRR with tone mapping and bloom), it is probably better to stay with LTBL anyways since it works better with SFML.
Title: Re: SFML Light System - Let There Be Light
Post by: foobarbaz on December 10, 2012, 11:05:51 am
Hi, I just started with SFML today and set up my basic framework and decided to get your light system in it since it looks absolutely beautiful :)

The demo works fine on my computer, but for some reason when I compile your example myself against the latest SFML on GIT I get the screenshot below (I had to add a few cmath and stdlib includes here and there, and also comment out the m_lightAttenuationShader.unbind(); line in LighSystem.cpp). Which version is this supposed to be compiled against?

(http://s18.postimage.org/sbmajtsx5/screeny.png)

EDIT: I fixed it! It's working fine now. It turns out m_lightAttenuationShader.unbind(); was important. I replaced it with:

Code: [Select]
//this is the replacement for unbind
sf::priv::GlContext::ensureContext();
glCheck(glUseProgramObjectARB(0));

since the unbind function was removed in this commit: https://github.com/SFML/SFML/commit/121cfeb6a3685e2529b717d5667ee6601533c30e
Title: Re: SFML Light System - Let There Be Light
Post by: Laurent on December 10, 2012, 10:46:48 pm
You can safely remove the call to sf::priv::GlContext::ensureContext().
Title: Re: SFML Light System - Let There Be Light
Post by: foobarbaz on December 11, 2012, 12:28:12 am
Awesome, thanks!
Title: Re: SFML Light System - Let There Be Light
Post by: grant on December 14, 2012, 06:02:41 am
Hi, I made a game with 3 other students for a term project and we used LTBL in it.  I thanked CireNeikual in the credits.  Here's a link to the website if you want to download and play it: https://sites.google.com/site/offby1games/ (https://sites.google.com/site/offby1games/).  Also here's a link to the trailer: http://www.youtube.com/watch?v=6sDYMHgCiDc (http://www.youtube.com/watch?v=6sDYMHgCiDc).  Anyways thanks lolz123 for the light system you made, and thank you, Laurent for SFML.  This is the first game I've made besides game maker games, and I really enjoyed it and intend to make more.
Title: AW: SFML Light System - Let There Be Light
Post by: eXpl0it3r on December 14, 2012, 11:14:27 am
This looks really great!
You should open a thread in the project section of this forum, so more people could discover it. :)
Title: Re: SFML Light System - Let There Be Light
Post by: pjuke on January 15, 2013, 02:28:00 pm
Nice one, looking good!
I've one question tho:

What would be the best approach when dealing with circular objects, like a ball for example?
A circle has "endless" number of corners, which makes it a bit difficult to point out all the vertices in the shape, I guess.

So, how would I go by defining those kind of objects with soft corners?
Title: Re: SFML Light System - Let There Be Light
Post by: Stormblessed on January 17, 2013, 06:01:48 am
I was wondering if anyone could perhaps state what exactly you need to have linked to get this to compile, I know it says SFML and GLEW, but I read somewhere that SFML includes GLEW for you, which confuses me.  I'm using Code::Blocks as my IDE so that I can run it off of a flash drive, not sure if that matters at all, probably not... 

As of right now I've got all the stuff in SFML/lib/ linked under Build Options -> Linker settings.
And under Build  Options -> Search directories -> linker  as well as Build Options -> Search directories -> compiler I've got LTBL included, as well as SFML/include under compiler and SFML/lib under linker.

I've been using SFML in my project, so that works for sure.  But whenever I try to #include any of the LTBL files it can't find them.

Some tips would be greatly appreciated, as in all honesty I sometimes find setting up the IDE to work with what you want to be the hardest part of programming...
Title: Re: SFML Light System - Let There Be Light
Post by: kralo9 on January 30, 2013, 04:54:14 pm
Quote
EDIT: I fixed it! It's working fine now. It turns out m_lightAttenuationShader.unbind(); was important. I replaced it with:

Code: [Select]
//this is the replacement for unbind
sf::priv::GlContext::ensureContext();
glCheck(glUseProgramObjectARB(0));

since the unbind function was removed in this commit: https://github.com/SFML/SFML/commit/121cfeb6a3685e2529b717d5667ee6601533c30e

I can't call function glCheck(glUseProgramObjectARB(0));
Where is it implemented?
Title: Re: SFML Light System - Let There Be Light
Post by: Laurent on January 30, 2013, 05:00:50 pm
With recent sources you can now call sf::Shader::bind(NULL) instead.
Title: Re: SFML Light System - Let There Be Light
Post by: kralo9 on February 04, 2013, 08:13:56 pm
Amazin. Actually with latest sources unbind() is available and working too. But I got a new problem. When im calling SetCenter() on a ltbl::light_point the program seems to crash as soon as I move a light long distances. For example from 0,0 to 800,400 (immediatly).

What may cause that problem?
Removing that call to the function makes the program uncrashable, but this is not what I'm looking for.
Title: Re: SFML Light System - Let There Be Light
Post by: Laurent on February 04, 2013, 08:22:21 pm
Quote
Actually with latest sources unbind() is available and working too
Hmmm... no?

Quote
But I got a new problem. When im calling SetCenter() on a ltbl::light_point the program seems to crash as soon as I move a light long distances. For example from 0,0 to 800,400 (immediatly).
You're trying to move your light faster than the speed of light, it creates a wormhole in the universe which obviously makes your program crash.
Seriously? I have no idea, but it's not a SFML bug. Moving something doesn't do anything critical, just assigning a few floats. And for SFML there's no difference between a small move and a big move.
Title: Re: SFML Light System - Let There Be Light
Post by: kralo9 on February 04, 2013, 08:44:45 pm
Hm. Maybe I downloaded somehow wrong version of sfml2... where do I really download the latest sources?? :/
Maybe this causes the problem too.
Sorry if I'm too stupid for that.

Github or sfml homepage? I tried sfml2rc...
Github is a bit confusing me because it is not handy enough for me
Title: Re: SFML Light System - Let There Be Light
Post by: natchos on February 04, 2013, 10:52:20 pm
Excuse me if this sounds dumb, but with the the version of SFML I have(downloaded a week or so ago) sf::shader::bind() can no longer be called with no arguments. Should I replace all calls to bind with no arguments with bind(NULL)?
Title: Re: SFML Light System - Let There Be Light
Post by: Laurent on February 04, 2013, 11:04:49 pm
Build the API documentation, and read it ;)

// bind a shader
sf::Shader::bind(&shader);

// bind nothing
sf::Shader::bind(NULL);
Title: Re: SFML Light System - Let There Be Light
Post by: kralo9 on February 04, 2013, 11:06:24 pm
I dont want to be inpolite, but in my opinion you cant be sure if that what you downloaded is really the latest version. Seems like I am not the only one having problems with that. Some explicit hints/links to the latest sources would be great. I would find 2 different downloads of SFML2 (like it seels to be) in the download section on the sfml homepage.

Edit: Ok only I am too stupid for downloading :/
Title: Re: SFML Light System - Let There Be Light
Post by: Laurent on February 04, 2013, 11:14:09 pm
Isn't the "Latest development snapshot" section of the download page explicit enough?
Title: Re: SFML Light System - Let There Be Light
Post by: kralo9 on February 04, 2013, 11:19:07 pm
Isn't the "Latest development snapshot" section of the download page explicit enough?
Well, it is yes. But why that big table under it? That confused me.
Ok I will try that snapshot and hope it is not crashing anymore when moving lights faster than its speed...
Sorry for my incompetence. Seems I am stupid.

I wanted to add that I like non-oversized-communities line this is, where you even get answers from developers.
Title: Re: SFML Light System - Let There Be Light
Post by: Laurent on February 05, 2013, 08:08:00 am
Quote
Well, it is yes. But why that big table under it?
The latest sources are just one archive, a single link is enough.
A release has many many pre-compiled packages, thus it requires a big table ;)
Title: Re: SFML Light System - Let There Be Light
Post by: natchos on February 05, 2013, 09:29:25 am
Build the API documentation, and read it ;)

// bind a shader
sf::Shader::bind(&shader);

// bind nothing
sf::Shader::bind(NULL);

But what did the old call to ::bind with no arguments do? Did it do the same thing as calling ::bind(NULL)? Since I don't know what the old calls did, I don't know if ::bind(NULL) does the same thing.
Title: Re: SFML Light System - Let There Be Light
Post by: Laurent on February 05, 2013, 10:37:38 am
// the old...
shader.bind();

// ...is equivalent to the new...
sf::Shader::bind(&shader);

// the old...
shader.unbind();

// ...is equivalent to the new...
sf::Shader::bind(NULL);
Title: Re: SFML Light System - Let There Be Light
Post by: natchos on February 05, 2013, 04:45:04 pm
// the old...
shader.bind();

// ...is equivalent to the new...
sf::Shader::bind(&shader);

// the old...
shader.unbind();

// ...is equivalent to the new...
sf::Shader::bind(NULL);

Okay, thank you for clearing that up.

EDIT: is this true for other classes ::bind, such as sf::texture::bind?
Title: Re: SFML Light System - Let There Be Light
Post by: Laurent on February 05, 2013, 08:15:46 pm
Yes.
Title: Re: SFML Light System - Let There Be Light
Post by: kralo9 on February 05, 2013, 11:03:03 pm
Are there any plans about implementing a lighting system into sfml? And why 'no'?
Title: Re: SFML Light System - Let There Be Light
Post by: eXpl0it3r on February 06, 2013, 01:49:19 am
Are there any plans about implementing a lighting system into sfml? And why 'no'?
No, because SFML is a low level library (not a framework nor engine), that provides a nice API for accessing multimedia related things. With such an API you get the chance to implement a lighting system on your own on top of it, like 'Let There Be Light' proves to work. :)
Title: Re: SFML Light System - Let There Be Light
Post by: kralo9 on February 07, 2013, 03:02:18 pm
After downloading latest snapshot, sf::Shader::bind(); is working. Had to rewrite some texturebindings to sf::Texture::bind(&sf::Texture); is it right, that there is no call for sf::Texture::bind(NULL); ? and when compiling, my IDE (MSVC) throws error, that he can't find the sf::Shader::bind() in the DLLs or sth.

Here the errorcode (german):

1>LightSystem.obj : error LNK2001: Nicht aufgelöstes externes Symbol ""__declspec(dllimport) public: static void __cdecl sf::Shader::bind(class sf::Shader const *)" (__imp_?bind@Shader@sf@@SAXPBV12@@Z)".
1>LightSystem.obj : error LNK2001: Nicht aufgelöstes externes Symbol ""__declspec(dllimport) public: static void __cdecl sf::Texture::bind(class sf::Texture const *,enum sf::Texture::CoordinateType)" (__imp_?bind@Texture@sf@@SAXPBV12@W4CoordinateType@12@@Z)".


Help me please :)
PS: There aren't any sfml-*.lib files in the snapshot... (so I didn't replace the old ones)
Title: Re: SFML Light System - Let There Be Light
Post by: eXpl0it3r on February 07, 2013, 03:13:53 pm
After downloading latest snapshot, sf::Shader::bind(); is working.
PS: There aren't any sfml-*.lib files in the snapshot... (so I didn't replace the old ones)
You obviously have to also build SFML... ::)
There aren't any official binaries other than the SFML 2 RC ones.
Title: Re: SFML Light System - Let There Be Light
Post by: Foaly on February 07, 2013, 03:21:31 pm
You can't just use the old .lib files. If you use the new source you either have to recompile it yourself (http://www.sfml-dev.org/tutorials/2.0/compile-with-cmake.php) or use the precompiled unofficial nightly builds (http://en.sfml-dev.org/forums/index.php?topic=9513.0).
Title: Re: SFML Light System - Let There Be Light
Post by: kralo9 on February 07, 2013, 03:22:26 pm
After downloading latest snapshot, sf::Shader::bind(); is working.
PS: There aren't any sfml-*.lib files in the snapshot... (so I didn't replace the old ones)
You obviously have to also build SFML... ::)
There aren't any official binaries other than the SFML 2 RC ones.

Ah, yes ofcourse... :)
Title: Re: SFML Light System - Let There Be Light
Post by: kralo9 on February 07, 2013, 09:14:54 pm
So, that is what I did:
-CMaked the latest snapshot and built in msvc as release (game also running release mode)
-Changed some calls to sf::Shader::bind() and sf::Texture::bind()
=> Building now properly, but the game still crashes. I can't call ls->RemoveLight(pLight) without crash, either.

What to do? Maybe some Heap Errors?


EDIT: Finally solved my problem. Turned out, that there were some mistakes managing the pointers and their assigned memory, because std::vector seems to construct its objects again after erasing single elements. I had a std::vector<Ammo> where Ammo has its own light. When erasing an Ammo they kinda get reconstructed for sorting the vector's list (closing gaps). Now i used a vector of pointers: std::vector<Ammo*> addind new Ammo with *.push_back(new Ammo()). So the vector is recreating the pointers, not my objects. (Of course I configured the destructors for deleting the objects properly).

Dat Heap :)
Thank you for the help anyway :)
Title: Re: SFML Light System - Let There Be Light
Post by: Deftwun on May 01, 2013, 02:39:33 pm
Has anyone out there ever managed to get LTBL to work without convex hulls and instead with line segments? I'm just curious if this is possible as I use box2d with Chain shapes as my level terrain collision.
Title: Re: SFML Light System - Let There Be Light
Post by: lolz123 on May 01, 2013, 09:50:34 pm
If you make a convex hull with only 2 points (a line segment), it should still work.
Title: Re: SFML Light System - Let There Be Light
Post by: dragondgold on May 14, 2013, 04:48:40 pm
Hello! I am trying to get started with this. I downloaded the latest release from http://sourceforge.net/projects/letthebelight/files/ and added the source folder to my include path. But when I try to write a simple code to test:

#include <SFML/System.hpp>
#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
#include <LTBL/Light/LightSystem.h>
#include <LTBL/Light/Light.h>
#include <LTBL/Constructs/AABB.h>
#include <iostream>
#include <assert.h>

using namespace std;

int main() {

        sf::VideoMode vidMode;
        vidMode.width = 800;
        vidMode.height = 600;
        vidMode.bitsPerPixel = 32;
        assert(vidMode.isValid());

        sf::RenderWindow mWindow(vidMode, "Prueba Light");

        // Light System
        ltbl::LightSystem ls(AABB(Vec2f(0.0f, 0.0f),
                Vec2f(static_cast<float>(vidMode.width), static_cast<float>(vidMode.height))), &mWindow,
                "lightFin.png", "lightAttenuationShader.frag");


        // Create a light
        ltbl::Light_Point* testLight = new ltbl::Light_Point();
        testLight->m_center = Vec2f(200.0f, 200.0f);
        testLight->m_radius = 500.0f;
        testLight->m_size = 30.0f;
        testLight->m_spreadAngle = 2.0f * static_cast<float>(3.14159265);
        testLight->m_softSpreadAngle = 0.0f;
        testLight->CalculateAABB();
        lightSystem.AddLight(testLight);


        while(mWindow.isOpen()){
                sf::Event mEvent;
                while (mWindow.pollEvent(mEvent)){
                        if (mEvent.type == sf::Event::Closed ||
                                ((mEvent.type == sf::Event::KeyPressed) && (mEvent.key.code == sf::Keyboard::Escape))){
                                mWindow.close();
                        }
                }
                mWindow.clear();
                mWindow.display();
        }

        return 0;
}

In the line:

ltbl::Light* testLight = new ltbl::Light();

I get the error:
The type 'ltbl::Light' must implement the inherited pure virtual method 'ltbl::Light::RenderLightSolidPortion'


I don't know if I have to compile it and add libraries like in SFML I haven't found anything, so I tried building with cmake with this git repository: https://github.com/hovatterz/light
I am on Ubuntu 12.04 so installed boost with:

sudo apt-get install libboost-all-dev

Then cmake . and then when I do make i get an error, here is what I get in the console:

andres@Andres-NT:~/Dropbox/Development/light$ cmake .
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Boost version: 1.53.0
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for connect
-- Looking for connect - found
-- Looking for remove
-- Looking for remove - found
-- Looking for shmat
-- Looking for shmat - found
-- Looking for IceConnectionNumber in ICE
-- Looking for IceConnectionNumber in ICE - found
-- Found X11: /usr/lib/x86_64-linux-gnu/libX11.so
Found SFML: /usr/local/include
-- Configuring done
-- Generating done
-- Build files have been written to: /home/andres/Dropbox/Development/light
andres@Andres-NT:~/Dropbox/Development/light$ make
Scanning dependencies of target ltbl
[  9%] Building CXX object CMakeFiles/ltbl.dir/src/Constructs.o
[ 18%] Building CXX object CMakeFiles/ltbl.dir/src/ConvexHull.o
In file included from /home/andres/Dropbox/Development/light/include/LTBL/QuadTreeNode.h:4:0,
                 from /home/andres/Dropbox/Development/light/include/LTBL/QuadTree.h:14,
                 from /home/andres/Dropbox/Development/light/include/LTBL/ConvexHull.h:6,
                 from /home/andres/Dropbox/Development/light/src/ConvexHull.cpp:1:
/home/andres/Dropbox/Development/light/include/LTBL/QuadTreeOccupant.h:39:17: warning: class ‘qdt::AABB’ is implicitly friends with itself [enabled by default]
In file included from /home/andres/Dropbox/Development/light/include/LTBL/QuadTree.h:14:0,
                 from /home/andres/Dropbox/Development/light/include/LTBL/ConvexHull.h:6,
                 from /home/andres/Dropbox/Development/light/src/ConvexHull.cpp:1:
/home/andres/Dropbox/Development/light/include/LTBL/QuadTreeNode.h:55:16: warning: class ‘qdt::QuadTreeNode’ is implicitly friends with itself [enabled by default]
[ 27%] Building CXX object CMakeFiles/ltbl.dir/src/Light.o
In file included from /home/andres/Dropbox/Development/light/include/LTBL/QuadTreeNode.h:4:0,
                 from /home/andres/Dropbox/Development/light/include/LTBL/QuadTree.h:14,
                 from /home/andres/Dropbox/Development/light/include/LTBL/Light.h:6,
                 from /home/andres/Dropbox/Development/light/src/Light.cpp:1:
/home/andres/Dropbox/Development/light/include/LTBL/QuadTreeOccupant.h:39:17: warning: class ‘qdt::AABB’ is implicitly friends with itself [enabled by default]
In file included from /home/andres/Dropbox/Development/light/include/LTBL/QuadTree.h:14:0,
                 from /home/andres/Dropbox/Development/light/include/LTBL/Light.h:6,
                 from /home/andres/Dropbox/Development/light/src/Light.cpp:1:
/home/andres/Dropbox/Development/light/include/LTBL/QuadTreeNode.h:55:16: warning: class ‘qdt::QuadTreeNode’ is implicitly friends with itself [enabled by default]
[ 36%] Building CXX object CMakeFiles/ltbl.dir/src/LightSystem.o
In file included from /home/andres/Dropbox/Development/light/include/LTBL/QuadTreeNode.h:4:0,
                 from /home/andres/Dropbox/Development/light/include/LTBL/QuadTree.h:14,
                 from /home/andres/Dropbox/Development/light/include/LTBL/Light.h:6,
                 from /home/andres/Dropbox/Development/light/include/LTBL/LightSystem.h:4,
                 from /home/andres/Dropbox/Development/light/src/LightSystem.cpp:1:
/home/andres/Dropbox/Development/light/include/LTBL/QuadTreeOccupant.h:39:17: warning: class ‘qdt::AABB’ is implicitly friends with itself [enabled by default]
In file included from /home/andres/Dropbox/Development/light/include/LTBL/QuadTree.h:14:0,
                 from /home/andres/Dropbox/Development/light/include/LTBL/Light.h:6,
                 from /home/andres/Dropbox/Development/light/include/LTBL/LightSystem.h:4,
                 from /home/andres/Dropbox/Development/light/src/LightSystem.cpp:1:
/home/andres/Dropbox/Development/light/include/LTBL/QuadTreeNode.h:55:16: warning: class ‘qdt::QuadTreeNode’ is implicitly friends with itself [enabled by default]
[ 45%] Building CXX object CMakeFiles/ltbl.dir/src/Light_Beam.o
In file included from /home/andres/Dropbox/Development/light/include/LTBL/QuadTreeNode.h:4:0,
                 from /home/andres/Dropbox/Development/light/include/LTBL/QuadTree.h:14,
                 from /home/andres/Dropbox/Development/light/include/LTBL/Light.h:6,
                 from /home/andres/Dropbox/Development/light/include/LTBL/Light_Beam.h:4,
                 from /home/andres/Dropbox/Development/light/src/Light_Beam.cpp:1:
/home/andres/Dropbox/Development/light/include/LTBL/QuadTreeOccupant.h:39:17: warning: class ‘qdt::AABB’ is implicitly friends with itself [enabled by default]
In file included from /home/andres/Dropbox/Development/light/include/LTBL/QuadTree.h:14:0,
                 from /home/andres/Dropbox/Development/light/include/LTBL/Light.h:6,
                 from /home/andres/Dropbox/Development/light/include/LTBL/Light_Beam.h:4,
                 from /home/andres/Dropbox/Development/light/src/Light_Beam.cpp:1:
/home/andres/Dropbox/Development/light/include/LTBL/QuadTreeNode.h:55:16: warning: class ‘qdt::QuadTreeNode’ is implicitly friends with itself [enabled by default]
[ 54%] Building CXX object CMakeFiles/ltbl.dir/src/QuadTree.o
In file included from /home/andres/Dropbox/Development/light/include/LTBL/QuadTreeNode.h:4:0,
                 from /home/andres/Dropbox/Development/light/include/LTBL/QuadTree.h:14,
                 from /home/andres/Dropbox/Development/light/src/QuadTree.cpp:1:
/home/andres/Dropbox/Development/light/include/LTBL/QuadTreeOccupant.h:39:17: warning: class ‘qdt::AABB’ is implicitly friends with itself [enabled by default]
In file included from /home/andres/Dropbox/Development/light/include/LTBL/QuadTree.h:14:0,
                 from /home/andres/Dropbox/Development/light/src/QuadTree.cpp:1:
/home/andres/Dropbox/Development/light/include/LTBL/QuadTreeNode.h:55:16: warning: class ‘qdt::QuadTreeNode’ is implicitly friends with itself [enabled by default]
[ 63%] Building CXX object CMakeFiles/ltbl.dir/src/QuadTreeNode.o
In file included from /home/andres/Dropbox/Development/light/include/LTBL/QuadTreeNode.h:4:0,
                 from /home/andres/Dropbox/Development/light/src/QuadTreeNode.cpp:1:
/home/andres/Dropbox/Development/light/include/LTBL/QuadTreeOccupant.h:39:17: warning: class ‘qdt::AABB’ is implicitly friends with itself [enabled by default]
In file included from /home/andres/Dropbox/Development/light/src/QuadTreeNode.cpp:1:0:
/home/andres/Dropbox/Development/light/include/LTBL/QuadTreeNode.h:55:16: warning: class ‘qdt::QuadTreeNode’ is implicitly friends with itself [enabled by default]
[ 72%] Building CXX object CMakeFiles/ltbl.dir/src/QuadTreeOccupant.o
In file included from /home/andres/Dropbox/Development/light/src/QuadTreeOccupant.cpp:1:0:
/home/andres/Dropbox/Development/light/include/LTBL/QuadTreeOccupant.h:39:17: warning: class ‘qdt::AABB’ is implicitly friends with itself [enabled by default]
In file included from /home/andres/Dropbox/Development/light/src/QuadTreeOccupant.cpp:3:0:
/home/andres/Dropbox/Development/light/include/LTBL/QuadTreeNode.h:55:16: warning: class ‘qdt::QuadTreeNode’ is implicitly friends with itself [enabled by default]
[ 81%] Building CXX object CMakeFiles/ltbl.dir/src/SFML_OpenGL.o
[ 90%] Building CXX object CMakeFiles/ltbl.dir/src/ShadowFin.o
Linking CXX shared library lib/libltbl.so
[ 90%] Built target ltbl
[100%] Building CXX object bin/CMakeFiles/sample.dir/main.o
In file included from /home/andres/Dropbox/Development/light/include/LTBL/QuadTreeNode.h:4:0,
                 from /home/andres/Dropbox/Development/light/include/LTBL/QuadTree.h:14,
                 from /home/andres/Dropbox/Development/light/include/LTBL/Light.h:6,
                 from /home/andres/Dropbox/Development/light/include/LTBL/LightSystem.h:4,
                 from /home/andres/Dropbox/Development/light/sample/main.cpp:1:
/home/andres/Dropbox/Development/light/include/LTBL/QuadTreeOccupant.h:39:17: warning: class ‘qdt::AABB’ is implicitly friends with itself [enabled by default]
In file included from /home/andres/Dropbox/Development/light/include/LTBL/QuadTree.h:14:0,
                 from /home/andres/Dropbox/Development/light/include/LTBL/Light.h:6,
                 from /home/andres/Dropbox/Development/light/include/LTBL/LightSystem.h:4,
                 from /home/andres/Dropbox/Development/light/sample/main.cpp:1:
/home/andres/Dropbox/Development/light/include/LTBL/QuadTreeNode.h:55:16: warning: class ‘qdt::QuadTreeNode’ is implicitly friends with itself [enabled by default]
/home/andres/Dropbox/Development/light/sample/main.cpp: In function ‘int main(int, char**)’:
/home/andres/Dropbox/Development/light/sample/main.cpp:144:51: error: ‘snprintf’ was not declared in this scope
make[2]: *** [bin/CMakeFiles/sample.dir/main.o] Error 1
make[1]: *** [bin/CMakeFiles/sample.dir/all] Error 2
make: *** [all] Error 2
 

Hope you can help me  :)
Title: Re: SFML Light System - Let There Be Light
Post by: lolz123 on May 15, 2013, 02:43:01 am
ltbl::Light* testLight = new ltbl::Light();

As far as I can tell, this isn't in the code sample you posted. ltbl::Light is a base class only, and cannot be instantiated by itself. Use ltbl::Light_Point to create a point light.
Title: Re: SFML Light System - Let There Be Light
Post by: dragondgold on May 15, 2013, 03:31:21 am
ltbl::Light* testLight = new ltbl::Light();

As far as I can tell, this isn't in the code sample you posted. ltbl::Light is a base class only, and cannot be instantiated by itself. Use ltbl::Light_Point to create a point light.

Sorry, yeah, I am getting this error using Light() as the PDF in v1.5.1 says. I changed it to use Light_Point and after adding some includes and deleting -std=c++0x flag from my compiler some errors have dissapeared but I still get this errors:

make all
Building file: ../src/PruebaLightSFML.cpp
Invoking: GCC C++ Compiler
g++ -I/home/andres/Dropbox/Development/SFML-2.0/include -I/home/andres/Dropbox/Development/Let_There_Be_Light_v1.5.1/Source -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/PruebaLightSFML.d" -MT"src/PruebaLightSFML.d" -o "src/PruebaLightSFML.o" "../src/PruebaLightSFML.cpp"
In file included from /usr/include/c++/4.6/unordered_set:35:0,
                 from /home/andres/Dropbox/Development/Let_There_Be_Light_v1.5.1/Source/LTBL/QuadTree/QuadTreeNode.h:9,
                 from /home/andres/Dropbox/Development/Let_There_Be_Light_v1.5.1/Source/LTBL/QuadTree/QuadTree.h:4,
                 from /home/andres/Dropbox/Development/Let_There_Be_Light_v1.5.1/Source/LTBL/QuadTree/StaticQuadTree.h:4,
                 from /home/andres/Dropbox/Development/Let_There_Be_Light_v1.5.1/Source/LTBL/Light/LightSystem.h:30,
                 from ../src/PruebaLightSFML.cpp:7:
/usr/include/c++/4.6/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the upcoming ISO C++ standard, C++0x. This support is currently experimental, and must be enabled with the -std=c++0x or -std=gnu++0x compiler options.
In file included from /home/andres/Dropbox/Development/Let_There_Be_Light_v1.5.1/Source/LTBL/QuadTree/QuadTreeNode.h:4:0,
                 from /home/andres/Dropbox/Development/Let_There_Be_Light_v1.5.1/Source/LTBL/QuadTree/QuadTree.h:4,
                 from /home/andres/Dropbox/Development/Let_There_Be_Light_v1.5.1/Source/LTBL/QuadTree/StaticQuadTree.h:4,
                 from /home/andres/Dropbox/Development/Let_There_Be_Light_v1.5.1/Source/LTBL/Light/LightSystem.h:30,
                 from ../src/PruebaLightSFML.cpp:7:
/home/andres/Dropbox/Development/Let_There_Be_Light_v1.5.1/Source/LTBL/Constructs/AABB.h:54:15: warning: class ‘AABB’ is implicitly friends with itself [enabled by default]
In file included from /home/andres/Dropbox/Development/Let_There_Be_Light_v1.5.1/Source/LTBL/QuadTree/QuadTree.h:4:0,
                 from /home/andres/Dropbox/Development/Let_There_Be_Light_v1.5.1/Source/LTBL/QuadTree/StaticQuadTree.h:4,
                 from /home/andres/Dropbox/Development/Let_There_Be_Light_v1.5.1/Source/LTBL/Light/LightSystem.h:30,
                 from ../src/PruebaLightSFML.cpp:7:
/home/andres/Dropbox/Development/Let_There_Be_Light_v1.5.1/Source/LTBL/QuadTree/QuadTreeNode.h:21:39: warning: ‘>>’ operator will be treated as two right angle brackets in C++0x [-Wc++0x-compat]
/home/andres/Dropbox/Development/Let_There_Be_Light_v1.5.1/Source/LTBL/QuadTree/QuadTreeNode.h:21:39: note: suggest parentheses around ‘>>’ expression
/home/andres/Dropbox/Development/Let_There_Be_Light_v1.5.1/Source/LTBL/QuadTree/QuadTreeNode.h:21:43: error: ‘m_children’ was not declared in this scope
/home/andres/Dropbox/Development/Let_There_Be_Light_v1.5.1/Source/LTBL/QuadTree/QuadTreeNode.h:21:43: error: ‘*’ cannot appear in a constant-expression
/home/andres/Dropbox/Development/Let_There_Be_Light_v1.5.1/Source/LTBL/QuadTree/QuadTreeNode.h:21:39: error: ‘>>’ should be ‘> >’ within a nested template argument list
/home/andres/Dropbox/Development/Let_There_Be_Light_v1.5.1/Source/LTBL/QuadTree/QuadTreeNode.h:24:3: error: ‘unordered_set’ in namespace ‘std’ does not name a type
/home/andres/Dropbox/Development/Let_There_Be_Light_v1.5.1/Source/LTBL/QuadTree/QuadTreeNode.h:41:26: error: ‘std::unordered_set’ has not been declared
/home/andres/Dropbox/Development/Let_There_Be_Light_v1.5.1/Source/LTBL/QuadTree/QuadTreeNode.h:41:39: error: expected ‘,’ or ‘...’ before ‘<’ token
In file included from /home/andres/Dropbox/Development/Let_There_Be_Light_v1.5.1/Source/LTBL/QuadTree/StaticQuadTree.h:4:0,
                 from /home/andres/Dropbox/Development/Let_There_Be_Light_v1.5.1/Source/LTBL/Light/LightSystem.h:30,
                 from ../src/PruebaLightSFML.cpp:7:
/home/andres/Dropbox/Development/Let_There_Be_Light_v1.5.1/Source/LTBL/QuadTree/QuadTree.h:16:3: error: ‘unordered_set’ in namespace ‘std’ does not name a type
/home/andres/Dropbox/Development/Let_There_Be_Light_v1.5.1/Source/LTBL/QuadTree/QuadTree.h:18:3: error: ‘unique_ptr’ in namespace ‘std’ does not name a type
In file included from ../src/PruebaLightSFML.cpp:7:0:
/home/andres/Dropbox/Development/Let_There_Be_Light_v1.5.1/Source/LTBL/Light/LightSystem.h:47:3: error: ‘unordered_set’ in namespace ‘std’ does not name a type
/home/andres/Dropbox/Development/Let_There_Be_Light_v1.5.1/Source/LTBL/Light/LightSystem.h:49:3: error: ‘unordered_set’ in namespace ‘std’ does not name a type
/home/andres/Dropbox/Development/Let_There_Be_Light_v1.5.1/Source/LTBL/Light/LightSystem.h:51:3: error: ‘unordered_set’ in namespace ‘std’ does not name a type
make: *** [src/PruebaLightSFML.o] Error 1

And this is my code:

#include <iostream>
#include <cmath>
#include <assert.h>
#include <SFML/System.hpp>
#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
#include <LTBL/Light/LightSystem.h>

using namespace std;
using namespace ltbl;

int main() {

        sf::VideoMode vidMode;
        vidMode.width = 800;
        vidMode.height = 600;
        vidMode.bitsPerPixel = 32;
        assert(vidMode.isValid());

        sf::RenderWindow mWindow(vidMode, "Prueba Light");

        // Light System
        LightSystem ls(AABB(Vec2f(0.0f, 0.0f),
                Vec2f(static_cast<float>(vidMode.width), static_cast<float>(vidMode.height))), &mWindow,
                "lightFin.png", "lightAttenuationShader.frag");


        // Create a light
        Light_Point* testLight = new Light_Point();
        testLight->m_center = Vec2f(200.0f, 200.0f);
        testLight->m_radius = 500.0f;
        testLight->m_size = 30.0f;
        testLight->m_spreadAngle = 2.0f * static_cast<float>(M_PI);
        testLight->m_softSpreadAngle = 0.0f;
        testLight->CalculateAABB();
        ls.AddLight(testLight);

        while(mWindow.isOpen()){
                sf::Event mEvent;
                while (mWindow.pollEvent(mEvent)){
                        if (mEvent.type == sf::Event::Closed ||
                                ((mEvent.type == sf::Event::KeyPressed) && (mEvent.key.code == sf::Keyboard::Escape))){
                                mWindow.close();
                        }
                }
                mWindow.clear();
                mWindow.display();
        }

        return 0;
}
 
Title: Re: SFML Light System - Let There Be Light
Post by: lolz123 on May 15, 2013, 03:39:44 am
LTBL needs C++11 in order to compile. Try compiling it again with C++11 features enabled.
Title: Re: SFML Light System - Let There Be Light
Post by: dragondgold on May 15, 2013, 03:47:55 am
LTBL needs C++11 in order to compile. Try compiling it again with C++11 features enabled.

I get this errors compiling with C++11

make all
Building file: ../src/PruebaLightSFML.cpp
Invoking: GCC C++ Compiler
g++ -I/home/andres/Dropbox/Development/SFML-2.0/include -I/home/andres/Dropbox/Development/Let_There_Be_Light_v1.5.1/Source -O0 -g3 -Wall -c -fmessage-length=0 -std=c++0x -MMD -MP -MF"src/PruebaLightSFML.d" -MT"src/PruebaLightSFML.d" -o "src/PruebaLightSFML.o" "../src/PruebaLightSFML.cpp"
In file included from /home/andres/Dropbox/Development/Let_There_Be_Light_v1.5.1/Source/LTBL/QuadTree/QuadTreeNode.h:4:0,
                 from /home/andres/Dropbox/Development/Let_There_Be_Light_v1.5.1/Source/LTBL/QuadTree/QuadTree.h:4,
                 from /home/andres/Dropbox/Development/Let_There_Be_Light_v1.5.1/Source/LTBL/QuadTree/StaticQuadTree.h:4,
                 from /home/andres/Dropbox/Development/Let_There_Be_Light_v1.5.1/Source/LTBL/Light/LightSystem.h:30,
                 from ../src/PruebaLightSFML.cpp:7:
/home/andres/Dropbox/Development/Let_There_Be_Light_v1.5.1/Source/LTBL/Constructs/AABB.h:54:15: warning: class ‘AABB’ is implicitly friends with itself [enabled by default]
../src/PruebaLightSFML.cpp: In function ‘int main()’:
../src/PruebaLightSFML.cpp:29:2: error: ‘Light_Point’ was not declared in this scope
../src/PruebaLightSFML.cpp:29:15: error: ‘testLight’ was not declared in this scope
../src/PruebaLightSFML.cpp:29:31: error: expected type-specifier before ‘Light_Point’
../src/PruebaLightSFML.cpp:29:31: error: expected ‘;’ before ‘Light_Point’
make: *** [src/PruebaLightSFML.o] Error 1
Title: Re: SFML Light System - Let There Be Light
Post by: lolz123 on May 15, 2013, 04:33:51 am
You have to #include <LTBL/Light/Light_Point.h>
Title: Re: SFML Light System - Let There Be Light
Post by: dragondgold on May 15, 2013, 04:50:44 am
You have to #include <LTBL/Light/Light_Point.h>

Almost the same error  :-\

make all
Building file: ../src/PruebaLightSFML.cpp
Invoking: GCC C++ Compiler
g++ -I/home/andres/Dropbox/Development/SFML-2.0/include -I/home/andres/Dropbox/Development/Let_There_Be_Light_v1.5.1/Source -O0 -g3 -Wall -c -fmessage-length=0 -std=c++0x -MMD -MP -MF"src/PruebaLightSFML.d" -MT"src/PruebaLightSFML.d" -o "src/PruebaLightSFML.o" "../src/PruebaLightSFML.cpp"
In file included from /home/andres/Dropbox/Development/Let_There_Be_Light_v1.5.1/Source/LTBL/Constructs.h:5:0,
                 from /home/andres/Dropbox/Development/Let_There_Be_Light_v1.5.1/Source/LTBL/Light/Light.h:29,
                 from /home/andres/Dropbox/Development/Let_There_Be_Light_v1.5.1/Source/LTBL/Light/Light_Point.h:25,
                 from ../src/PruebaLightSFML.cpp:7:
/home/andres/Dropbox/Development/Let_There_Be_Light_v1.5.1/Source/LTBL/Constructs/AABB.h:54:15: warning: class &#8216;AABB&#8217; is implicitly friends with itself [enabled by default]
Finished building: ../src/PruebaLightSFML.cpp
 
Building target: PruebaLightSFML
Invoking: GCC C++ Linker
g++ -L/home/andres/Dropbox/Development/SFML-2.0/lib -o "PruebaLightSFML"  ./src/PruebaLightSFML.o   -lthor -lsfml-graphics -lsfml-audio -lsfml-window -lsfml-system
./src/PruebaLightSFML.o: In function `main':
/home/andres/Dropbox/workspace/PruebaLightSFML/Debug/../src/PruebaLightSFML.cpp:31: undefined reference to `ltbl::Light_Point::Light_Point()'
/home/andres/Dropbox/workspace/PruebaLightSFML/Debug/../src/PruebaLightSFML.cpp:32: undefined reference to `Vec2f::Vec2f(float, float)'
collect2: ld returned 1 exit status
make: *** [PruebaLightSFML] Error 1

PD: Also I have the same errors with LightSystem, seems like nothing of ltbl is working. I will try creating a new Eclipse project tomorrow.
Title: Re: SFML Light System - Let There Be Light
Post by: Grimshaw on May 15, 2013, 01:54:42 pm
It seems to me like you re misusing its classes, or in case you re compiling the sample, it just is outdated..

Not sure tho. But this lighting system does work
Title: Re: SFML Light System - Let There Be Light
Post by: Sakurazaki on June 04, 2013, 05:18:03 pm
Hi There,

I tried this code:

        // LTBL
        ls = ltbl::LightSystem(AABB(Vec2f(0.0f, 0.0f), Vec2f(static_cast<float>(WIN_WIDTH), static_cast<float>(WIN_HEIGHT))), window.get(), "data/lightFin.png", "data/shaders/lightAttenuationShader.frag");

        ltbl::Light_Point* dLight = new ltbl::Light_Point();
        dLight->SetCenter(Vec2f(0.0f, 0.0f));
        dLight->SetRadius(750.f);
        dLight->m_size = 30.f;
        dLight->SetSpreadAngle(2.0f * static_cast<float>(M_PI));
        dLight->m_softSpreadAngle = 0.0f;
        dLight->CalculateAABB();

        ls.AddLight(dLight);

And i get this when compiling:

1>------ Build started: Project: Testing, Configuration: Release Win32 ------
1>  main.cpp
1>F:\SFML-2.0-x64\include\SFML/Graphics/Shader.hpp(521): error C2248: 'sf::NonCopyable::operator =' : cannot access private member declared in class 'sf::NonCopyable'
1>          F:\SFML-2.0-x64\include\SFML/System/NonCopyable.hpp(79) : see declaration of 'sf::NonCopyable::operator ='
1>          F:\SFML-2.0-x64\include\SFML/System/NonCopyable.hpp(42) : see declaration of 'sf::NonCopyable'
1>          This diagnostic occurred in the compiler generated function 'sf::Shader &sf::Shader::operator =(const sf::Shader &)'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Am i doing something wrong?

I'm using LTBL 5.1 + SFML 2.0
Title: Re: SFML Light System - Let There Be Light
Post by: lolz123 on June 04, 2013, 07:51:31 pm
It looks like you are copying the light system. Try initializing it like this:

ltbl::LightSystem ls(AABB(Vec2f(0.0f, 0.0f), Vec2f(static_cast<float>(WIN_WIDTH), static_cast<float>(WIN_HEIGHT))), window.get(), "data/lightFin.png", "data/shaders/lightAttenuationShader.frag");
Title: Re: SFML Light System - Let There Be Light
Post by: Sakurazaki on June 04, 2013, 07:57:48 pm
It looks like you are copying the light system. Try initializing it like this:

ltbl::LightSystem ls(AABB(Vec2f(0.0f, 0.0f), Vec2f(static_cast<float>(WIN_WIDTH), static_cast<float>(WIN_HEIGHT))), window.get(), "data/lightFin.png", "data/shaders/lightAttenuationShader.frag");

that did work somehow but now I get this:

1>------ Build started: Project: Testing, Configuration: Release Win32 ------
1>  main.cpp
1>main.obj : error LNK2001: unresolved external symbol "public: __thiscall Vec2f::Vec2f(float,float)" (??0Vec2f@@QAE@MM@Z)
1>main.obj : error LNK2001: unresolved external symbol "public: __thiscall AABB::AABB(class Vec2f const &,class Vec2f const &)" (??0AABB@@QAE@ABVVec2f@@0@Z)
1>main.obj : error LNK2001: unresolved external symbol "public: void __thiscall ltbl::LightSystem::RenderLightTexture(void)" (?RenderLightTexture@LightSystem@ltbl@@QAEXXZ)
1>main.obj : error LNK2001: unresolved external symbol "public: void __thiscall ltbl::LightSystem::RenderLights(void)" (?RenderLights@LightSystem@ltbl@@QAEXXZ)
1>main.obj : error LNK2001: unresolved external symbol "public: __thiscall ltbl::LightSystem::~LightSystem(void)" (??1LightSystem@ltbl@@QAE@XZ)
1>main.obj : error LNK2001: unresolved external symbol "public: __thiscall ltbl::LightSystem::LightSystem(class AABB const &,class sf::RenderWindow *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0LightSystem@ltbl@@QAE@ABVAABB@@PAVRenderWindow@sf@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@2@Z)
1>main.obj : error LNK2001: unresolved external symbol "public: void __thiscall ltbl::Light::SetCenter(class Vec2f)" (?SetCenter@Light@ltbl@@QAEXVVec2f@@@Z)
1>main.obj : error LNK2001: unresolved external symbol "public: void __thiscall ltbl::Light::SetRadius(float)" (?SetRadius@Light@ltbl@@QAEXM@Z)
1>main.obj : error LNK2001: unresolved external symbol "public: void __thiscall ltbl::Light_Point::SetSpreadAngle(float)" (?SetSpreadAngle@Light_Point@ltbl@@QAEXM@Z)
1>main.obj : error LNK2001: unresolved external symbol "public: __thiscall ltbl::Light_Point::Light_Point(void)" (??0Light_Point@ltbl@@QAE@XZ)
1>F:\Bibliotecas\Documentos\Visual Studio 2012\Projects\SlimeWorld\Release\Testing.exe : fatal error LNK1120: 10 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I've include the headers to my MSVS IDE. How should I do this to also compile LTLB? Because
I believe those errors are because when compiling, since LTBL has no libraries it's looking for them.
Title: Re: SFML Light System - Let There Be Light
Post by: lolz123 on June 04, 2013, 08:02:17 pm
You need to add the source as a library directory as well. Go to VC++ Directories and add the Source folder under Library Directories.
Title: Re: SFML Light System - Let There Be Light
Post by: Sakurazaki on June 04, 2013, 08:22:35 pm
You need to add the source as a library directory as well. Go to VC++ Directories and add the Source folder under Library Directories.

I did it but i get the same error
Title: Re: SFML Light System - Let There Be Light
Post by: lolz123 on June 04, 2013, 08:28:05 pm
Try adding the source to your project directly (so it appears in the solution explorer).
Title: Re: SFML Light System - Let There Be Light
Post by: Sakurazaki on June 04, 2013, 08:40:41 pm
Try adding the source to your project directly (so it appears in the solution explorer).

I already tried and when compiling it says it cant find LTLB/QuadTree/StaticQuadTree.h

Damn I only want to use this library >.<
Title: Re: SFML Light System - Let There Be Light
Post by: Sakurazaki on June 06, 2013, 02:04:26 pm
Okay,

I finally added all the library to my project as internal, changing includes and everything.

Now after compiling, every light or convexhull i create, doesnt render.

See this screenshot:
http://screencloud.net/v/gJEC (http://screencloud.net/v/gJEC)

As you can see, No lights are rendered, despite I can see their AABB debugRender rectangle.
Also, no light is emitted and no shadow is cast. The hull can't also be seen.

Is it because I'm missing something?

Btw I had to change some parts of the code. Some of the textures where calling .bind() function
and since now bind is bind(sf::texture*) I changed those lines for sf::Texture::bind(&texture);
Title: Re: SFML Light System - Let There Be Light
Post by: lolz123 on June 06, 2013, 04:54:21 pm
Are you rendering a background? You won't be able to see the lights without non-black background. Also, can you share the code where you are rendering the light system?
Title: Re: SFML Light System - Let There Be Light
Post by: Sakurazaki on June 06, 2013, 07:46:20 pm
EDIT:

Putting background AND adding a view made it work.

Thanks!
Title: Re: SFML Light System - Let There Be Light
Post by: Sakurazaki on June 06, 2013, 08:48:18 pm
Anyone using this lib knows how can I add a light without the central big light?

I want it to emit light as if it was a point but with no central circle.

I tried changing size, intensity and so but didnt change anything.

Thanks!
Title: Re: SFML Light System - Let There Be Light
Post by: lolz123 on June 07, 2013, 05:32:39 am
Try setting the bleed to 0. You can also disable it globally in the LightSystem.
Title: Re: SFML Light System - Let There Be Light
Post by: DJuego on June 08, 2013, 12:01:17 am
It's a pity that the development of GLLight2D remains frozen.  :-\  It seemed so promising... At least it would be interesting to update the current library to the last version of SFML. And update the documentacion accordingly! ;D.

In any case I humbly encourage to create/maintain an extension for SFML on illumination.  ::) And yes. I kind of wonder if Nexus ( ;) would consider to add to Thor a module for illumination with outstanding design.  :D A module too big perhaps but too cool too.  8)

DJuego
Title: Re: SFML Light System - Let There Be Light
Post by: fatum on June 13, 2013, 06:33:35 am
Currently I'm trying to use LTBL in my project like this:

Code: [Select]
private:
ltbl::LightSystem *ls;
ltbl::Light_Point *testLight;

Code: [Select]
World::World(sf::RenderWindow &rwin)
{
ls = new ltbl::LightSystem(AABB(Vec2f(0.0f, 0.0f), Vec2f(static_cast<float>(screenWidth), static_cast<float>(screenHeight))), &rwin, "res/images/lightFin.png", "res/shaders/lightAttenuationShader.frag");

testLight = new ltbl::Light_Point();
testLight->SetCenter(Vec2f(400.0f, 400.0f));
testLight->SetRadius(500.05f);
testLight->m_size = 30.f;
testLight->m_spreadAngle = 2.f * static_cast<float>(M_PI);
testLight->m_softSpreadAngle = 0.f;
testLight->CalculateAABB();

ls->AddLight(testLight);
}

void World::draw(sf::RenderWindow &rwin)
{
rwin.setView(vw_main);
//Drawing logic (background, player, etc)
ls->RenderLights();
ls->RenderLightTexture();
}

However, there haven't been any changes to my scene after adding all of the necessary functions.  How could I further troubleshoot this?  Thanks for any help!
Title: Re: SFML Light System - Let There Be Light
Post by: Estivo on July 03, 2013, 07:54:33 pm
Hi, guys. I have to edit blend functions in LTBL to made more realistic darkness.  I had problems with white spot so I changed two lines in RenderLightTexture. In Game

(http://warsztat.gd/screens/bf2c6108853d2d4c8050f53f2cfc3f3a.png)

Function

Quote
void LightSystem::RenderLightTexture()
   {
      Vec2f viewSize(m_viewAABB.GetDims());

      // Translate by negative camera coordinates. glLoadIdentity will not work, probably
      // because SFML stores view transformations in the projection matrix
      glTranslatef(m_viewAABB.GetLowerBound().x, m_viewAABB.GetLowerBound().y, 0.0f);

      m_compositionTexture.getTexture().bind(&m_compositionTexture.getTexture());

      // Set up color function to multiply the existing color with the render texture color
      //glBlendFunc(GL_DST_ALPHA, GL_ZERO); // Seperate allows you to set color and alpha functions seperately
        glBlendFunc(GL_DST_COLOR, GL_ONE);
      glBegin(GL_QUADS);
         glTexCoord2i(0, 0); glVertex2f(0.0f, 0.0f);
         glTexCoord2i(1, 0); glVertex2f(viewSize.x, 0.0f);
         glTexCoord2i(1, 1); glVertex2f(viewSize.x, viewSize.y);
         glTexCoord2i(0, 1); glVertex2f(0.0f, viewSize.y);
      glEnd();

      if(m_useBloom)
      {
         m_bloomTexture.getTexture().bind(&m_bloomTexture.getTexture());

         //glBlendFunc(GL_ONE, GL_ONE);
            glBlendFunc(GL_DST_COLOR, GL_SRC_COLOR);
         glBegin(GL_QUADS);
            glTexCoord2i(0, 0); glVertex2f(0.0f, 0.0f);
            glTexCoord2i(1, 0); glVertex2f(viewSize.x, 0.0f);
            glTexCoord2i(1, 1); glVertex2f(viewSize.x, viewSize.y);
            glTexCoord2i(0, 1); glVertex2f(0.0f, viewSize.y);
         glEnd();
      }

      // Reset blend function
      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

      m_pWin->resetGLStates();
   }

I hope I help someone.
Title: Re: SFML Light System - Let There Be Light
Post by: eXpl0it3r on July 03, 2013, 08:42:04 pm
(http://warsztat.gd/screens/bf2c6108853d2d4c8050f53f2cfc3f3a.png)
That looks nice! Do you have some more specifics? :)
Title: Re: SFML Light System - Let There Be Light
Post by: Estivo on July 03, 2013, 10:06:44 pm
More specifics about project? It's screen from my game "Zombienation". I write the game for WSoC Contest. It will be 2d top down shooter like old Dead Frontier, but it will be single player game. All graphics are placeholders. More screenshoots here -> http://warsztat.gd/projects/Zombienation
Title: Re: SFML Light System - Let There Be Light
Post by: Estivo on July 05, 2013, 03:47:08 pm
Another modification that I made is load shader from memory. QT 5 doesn't allow to load id from file (don"t know why)
Title: Re: SFML Light System - Let There Be Light
Post by: jamesl22 on August 08, 2013, 10:56:47 am
Hi,

I am trying to implement LTBL into my game engine but I am struggling. I cannot get lights to render in the scene. Here is my code:

Engine::LightSystem::LightSystem(sf::RenderWindow &Window)
{
    ls = new ltbl::LightSystem(AABB(Vec2f(0.0f, 0.0f), Vec2f(16384.0f, 16384.0f)), &Window, "data/lightFin.png", "data/shaders/lightAttenuationShader.frag");

    Light = new ltbl::Light_Point();
    Light->m_center = Vec2f(200.0f, 1000.0f);
    Light->m_radius = 64.0f;
    Light->m_size = 30.0f;
    Light->m_intensity = 1.0f;
    Light->m_spreadAngle = 2.0f * 3.14159f;
    Light->m_softSpreadAngle = 0.0f;
    Light->CalculateAABB();
    ls->AddLight(Light);
}

void Engine::LightSystem::RenderLights(sf::View &View)
{
    ls->SetView(View);
    // Calculate the lights
    ls->RenderLights();
    // Draw the lights
    ls->RenderLightTexture();
}
 

I have attached an image of the problem. You will notice that LTBL is rendering the dark texture over the top.
Title: Re: SFML Light System - Let There Be Light
Post by: Estivo on August 11, 2013, 12:38:01 pm
Set light intensity to 2.f. for better effects you could modify two lines in blending mode .
Title: Re: SFML Light System - Let There Be Light
Post by: Nutomic on September 04, 2013, 11:34:27 pm
I tried to integrate the ltbl version from https://github.com/hovatterz/light (https://github.com/hovatterz/light) into my project, but I'm unable to really get it working.

No matter what I do, the area where shadows are is always the same size, and always in the same position (see attachment).

Does anyone know what I have to do to resize/move this area?
Title: Re: SFML Light System - Let There Be Light
Post by: Estivo on September 05, 2013, 05:59:01 pm
I think your code look like that
app.draw(smth);
lightSystem.renderLights();
lightSystem.renderLightTexture();
but it have to look like this
app.setView(view);
app.draw(smth);
app.setView(app.getDefaultView());
lightSystem.setView(app.getdefaultView());
lightSystem.renderLights();
lightSystem.renderLightTexture();
Title: Re: SFML Light System - Let There Be Light
Post by: Nutomic on September 05, 2013, 11:29:17 pm
I think your code look like that
app.draw(smth);
lightSystem.renderLights();
lightSystem.renderLightTexture();
but it have to look like this
app.setView(view);
app.draw(smth);
app.setView(app.getDefaultView());
lightSystem.setView(app.getdefaultView());
lightSystem.renderLights();
lightSystem.renderLightTexture();

That's exactly how my current code looks (I basically copied the example into my project), but doing this only makes the light texture that is shown completely black (the previous code shows light correctly).
Title: Re: SFML Light System - Let There Be Light
Post by: Estivo on September 05, 2013, 11:53:49 pm
Show me your code.
Title: Re: SFML Light System - Let There Be Light
Post by: Nutomic on September 06, 2013, 03:29:58 pm
Initialization:
        ltbl::LightSystem mLightSystem(qdt::AABB(Vec2f(0, 0), Vec2f(800, 600)), &mWindow);
        // Create a light
        ltbl::Light* mLight = new ltbl::Light();
        mLight->center = Vec2f(200.0f, 200.0f);
        mLight->radius = 500.0f;
        mLight->size = 30.0f;
        mLight->softSpreadAngle = 0.0f;
        mLight->CalculateAABB();

        mLightSystem.AddLight(mLight);

        // Create a hull by loading it from a file
        ltbl::ConvexHull* testHull = new ltbl::ConvexHull();

        testHull->LoadShape("data/testShape.txt");

        // Pre-calculate certain aspects
        testHull->CalculateNormals();
        testHull->GenerateAABB();

        testHull->SetWorldCenter(Vec2f(0, 0));

        mLightSystem.AddConvexHull(testHull);

        // Create a hull by loading it from a file
        ltbl::ConvexHull* testHull2 = new ltbl::ConvexHull();

        testHull2->LoadShape("data/testShape.txt");

        // Pre-calculate certain aspects
        testHull2->CalculateNormals();
        testHull2->GenerateAABB();

        testHull2->SetWorldCenter(Vec2f(300.0f, 300.0f));

        mLightSystem.AddConvexHull(testHull2);

Rendering:
        mWindow.clear();

        mWorldView.setCenter(mPlayer->getPosition());

        // Render world and dynamic stuff.
        mWindow.setView(mWorldView);
        mWindow.draw(mWorld);

        // Update light
        mLight->center.x = mPlayer->getPosition().x;
        mLight->center.y = mPlayer->getPosition().y;
        mLight->UpdateTreeStatus();

        mWindow.setView(mWindow.getDefaultView());
        mLightSystem.view = mWindow.getDefaultView();
         mLightSystem.RenderLights();
        mLightSystem.RenderLightTexture();

        // Render GUI.
        mWindow.drawGUI();
        mWindow.draw(mCrosshair);

        mWindow.display();

As I said, I just took the example and copied it in there.
Title: Re: SFML Light System - Let There Be Light
Post by: Estivo on September 06, 2013, 10:02:28 pm
I saw different sample.

Quote
mLightSystem.view = mWindow.getDefaultView();
to
Quote
mLightSystem.setView(mWindow.getDefaultView());

should solve problem You hardly set up view. setView function make some more than setting up view

Quote
   void LightSystem::SetView(const sf::View &view)
   {
      sf::Vector2f viewSize(view.getSize());
      m_viewAABB.SetDims(Vec2f(viewSize.x, viewSize.y));
      sf::Vector2f viewCenter(view.getCenter());

      // Flipped
      m_viewAABB.SetCenter(Vec2f(viewCenter.x, viewCenter.y));
   }
Title: Re: SFML Light System - Let There Be Light
Post by: Nutomic on September 06, 2013, 11:55:56 pm
The thing is, the github version (https://github.com/hovatterz/light/blob/master/include/LTBL/LightSystem.h) does not have setView, only a public member view.

I would try the version in the op, but gcc doesn't like the absolute include paths.

So I guess I'll try and reach the dev of this version and see if he can help.
Title: Re: SFML Light System - Let There Be Light
Post by: Estivo on September 07, 2013, 04:38:05 pm
Ah I see now. You're using older version. http://sourceforge.net/projects/letthebelight/ here you have 1.5.1 that I'm using in Zombination
Title: Re: SFML Light System - Let There Be Light
Post by: Daffern on September 08, 2013, 01:03:37 am
Hi, i've been trying to implement this into my game, but i have a problem with it. Has anyone gotten a bug looking like the one in this picture?

I changed the shader.bind() to sf::Shader::bind(shader) and texture.bind() to sf::Texture::bind(texture) as someone posted, but i cant figure this bug out. Help is very much appreciated!

Edit: the below ground he is standing on is not a convexHull, but the one above it is. The light is shining through the left part of it and there is a shading part on the right part of the screen which should not be there.
Title: Re: SFML Light System - Let There Be Light
Post by: Estivo on September 08, 2013, 12:34:53 pm
Take screen shot of this without lighting and with lighting in debug mode.
Title: Re: SFML Light System - Let There Be Light
Post by: Daffern on September 08, 2013, 01:24:16 pm
These are all in debug mode, the last one without any lighting. I noticed that if i the light gets really close to the hull, it seems to render correctly.
Title: Re: SFML Light System - Let There Be Light
Post by: Daffern on September 08, 2013, 03:38:44 pm
My bad, my bad! The size of my light was set way too high which caused the light to overlap the hull  :P. Thank you very much for the reply anyway!
Title: Re: SFML Light System - Let There Be Light
Post by: ThreeDumps on September 09, 2013, 09:50:31 pm
Well... Author probably don't read this topic anymore but I need help so I will risk

in example code from author side everything goes ok but when I change
testLight->m_radius = 600.0f;
to
testLight->m_radius = 20.0f;
(i need little spot light)
I got "Access violation reading location" when mouse moved outside of render window. Visual shows me xhash code on line 1003 so probably something goes wrong in QuadTree in std::unordered_set.


Title: Re: SFML Light System - Let There Be Light
Post by: Daffern on September 09, 2013, 10:24:47 pm
Yes, i had this problem too. You can fix it by setting the AABB to larger than your screen size(i put mine to 20000x20000) in this code

lightSystem(AABB(Vec2f(-10000.0f, -10000.0f), Vec2f(20000,20000)), &rw, "data/shaders/lightFin.png", "data/shaders/lightAttenuationShader.frag")
Title: Re: SFML Light System - Let There Be Light
Post by: ThreeDumps on September 09, 2013, 10:30:46 pm
It wouldn't be overkill for app? I guess that AABB is render area?
Title: Re: SFML Light System - Let There Be Light
Post by: Daffern on September 09, 2013, 11:44:02 pm
AABB is the quadtree limits, and im pretty sure the quadtree works well :)
Title: Re: SFML Light System - Let There Be Light
Post by: Estivo on September 10, 2013, 12:25:06 am
Better option to avoid access violation is set AABB to 0,0,0,0. And I think QuadTree is broken.
Title: Re: SFML Light System - Let There Be Light
Post by: Daffern on September 11, 2013, 12:19:30 am
I don't know if there is a fix for this, but is there any way to make the shadow fill where it's supposed to fill below the ground rectangle?
Title: Re: SFML Light System - Let There Be Light
Post by: Nutomic on September 11, 2013, 07:37:20 pm
I finally got it working, but even after playing around with Light::m_color and LightSystem::m_ambientColor, colors aren't like I want them:

At the position of the light, anything below it is drawn with a white overlay instead of a transparent one.
Also, I want pitch black if there is no light, instead of gray.

Example pic (single point light at player position):
http://i.imgur.com/oEzrgh1.png
        mLight->m_radius = 250.0f;
        mLight->m_size = 50.0f;
        mLight->m_softSpreadAngle = 0.0f;
        mLight->m_spreadAngle = 2.0f * M_PI;
        mLight->m_intensity = 1.5f;
        mLight->m_bleed = 0;

Edit: Or, can you give some example settings that you used which give good, realistic results?
Title: Re: SFML Light System - Let There Be Light
Post by: Estivo on September 11, 2013, 08:05:53 pm
Edit: Or, can you give some example settings that you used which give good, realistic results?
http://warsztat.gd/screens/2522b9f8e41887617078274713c0d4c2.png
like that?

I don't know if there is a fix for this, but is there any way to make the shadow fill where it's supposed to fill below the ground rectangle?

Make black texture ? What do you want at all?
Title: Re: SFML Light System - Let There Be Light
Post by: Nutomic on September 11, 2013, 08:48:42 pm
Edit: Or, can you give some example settings that you used which give good, realistic results?
http://warsztat.gd/screens/2522b9f8e41887617078274713c0d4c2.png
like that?

Minus the halo (which is probably m_bleed?), this would be perfect!
Title: Re: SFML Light System - Let There Be Light
Post by: Estivo on September 11, 2013, 08:55:18 pm
Yep it's with m_bleed. Here you are.
        void LightSystem::RenderLightTexture()
        {
                Vec2f viewSize(m_viewAABB.GetDims());

                // Translate by negative camera coordinates. glLoadIdentity will not work, probably
                // because SFML stores view transformations in the projection matrix
                glTranslatef(m_viewAABB.GetLowerBound().x, m_viewAABB.GetLowerBound().y, 0.0f);

                m_compositionTexture.getTexture().bind(&m_compositionTexture.getTexture());

                // Set up color function to multiply the existing color with the render texture color
                //glBlendFunc(GL_DST_ALPHA, GL_ZERO); // Seperate allows you to set color and alpha functions seperately
       glBlendFunc(GL_DST_COLOR, GL_ONE);
                glBegin(GL_QUADS);
                        glTexCoord2i(0, 0); glVertex2f(0.0f, 0.0f);
                        glTexCoord2i(1, 0); glVertex2f(viewSize.x, 0.0f);
                        glTexCoord2i(1, 1); glVertex2f(viewSize.x, viewSize.y);
                        glTexCoord2i(0, 1); glVertex2f(0.0f, viewSize.y);
                glEnd();

                if(m_useBloom)
                {
                        m_bloomTexture.getTexture().bind(&m_bloomTexture.getTexture());

                        //glBlendFunc(GL_ONE, GL_ONE);
            glBlendFunc(GL_DST_COLOR, GL_SRC_COLOR);
                        glBegin(GL_QUADS);
                                glTexCoord2i(0, 0); glVertex2f(0.0f, 0.0f);
                                glTexCoord2i(1, 0); glVertex2f(viewSize.x, 0.0f);
                                glTexCoord2i(1, 1); glVertex2f(viewSize.x, viewSize.y);
                                glTexCoord2i(0, 1); glVertex2f(0.0f, viewSize.y);
                        glEnd();
                }

                // Reset blend function
                glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

                m_pWin->resetGLStates();
        }

I modified blend modes. Minus of this is broken penumbra if you would change transparency.
Title: Re: SFML Light System - Let There Be Light
Post by: Nutomic on September 11, 2013, 10:23:49 pm
This is perfect, thanks  :D

Another question, why does it sometimes take a few seconds (or more) until fins are loaded on a light? (There are no errors or warnings, and the file path is given correctly).

Edit: Maybe it has to do with me starting outside of a Quadtree (or maybe I am just interpreting DebugDraw wrong).
Title: Re: SFML Light System - Let There Be Light
Post by: Estivo on September 11, 2013, 10:35:46 pm
are you talking about penumbra?
Title: Re: SFML Light System - Let There Be Light
Post by: Nutomic on September 11, 2013, 10:59:48 pm
Yeah right, I see you mentioned that (I didn't change any color/transparency settings in my code though).

Do you have any idea how I could fix this?

Edit: It definitely has nothing to do with those changes, I reverted them and still have the same problem:
(http://i.imgur.com/yHmx6Ph.png)

The directional light has the following values:
mPlayerDirectionLight->m_radius = 500.0f;
        mPlayerDirectionLight->m_size = 50.0f;
        mPlayerDirectionLight->m_softSpreadAngle = 0.1f * M_PI;
        mPlayerDirectionLight->m_spreadAngle = 0.5f * M_PI;
        mPlayerDirectionLight->m_intensity = 1.5f;
        mPlayerDirectionLight->m_bleed = 0;
        mPlayerDirectionLight->m_color =  Color3f(1, 0.95, 0.40);

So softspread should work no problem, but it only does sometimes after waiting.
Title: Re: SFML Light System - Let There Be Light
Post by: Daffern on September 12, 2013, 12:25:40 am
Have you tried turning the bloom off?
Title: Re: SFML Light System - Let There Be Light
Post by: Estivo on September 12, 2013, 08:22:21 am
ConvexHull parameters please ;)
Title: Re: SFML Light System - Let There Be Light
Post by: Nutomic on September 12, 2013, 10:17:40 am
Have you tried turning the bloom off?

That didn't solve it, but now the light/shadows look much more like I want, thanks :D

ConvexHull parameters please ;)

I didn't have any hulls in there yet. Now I just inserted some, and it seems the penumbra effect only works from the moment the light hits a ConvexHull. Obviously a bug, but for now, I can work around it.

Title: Re: SFML Light System - Let There Be Light
Post by: Estivo on September 12, 2013, 11:40:50 am
Hmm I think I know about what are you talking. Try to set position to 0,0 and then to position that you want.
Title: Re: SFML Light System - Let There Be Light
Post by: ThreeDumps on September 15, 2013, 02:48:08 pm
Awww... Still have problems ;)

(http://img834.imageshack.us/img834/1977/my65.png)

Does anyone have an idea what to do to get situation from second image instead from first? And situation from third is actual but not satisfactory.

First is when
hull->m_renderLightOverHull = true;

Third is when
hull->m_renderLightOverHull = false;

Of course I can redraw all walls but then I will have all walls visible, also in chambers next to.

Title: Re: SFML Light System - Let There Be Light
Post by: Estivo on September 15, 2013, 04:08:12 pm
Disable render over hull and set hull transparency to 0.5f
Title: Re: SFML Light System - Let There Be Light
Post by: ThreeDumps on September 16, 2013, 12:40:01 am
@Estivo, not exactly does it work the way I wanted.

I give bigger framgnet map and more situations.

(http://img707.imageshack.us/img707/3408/55uk.png)

1. m_renderLightOverHull false, m_transparency 0, redrawing walls.
Bad: Whole labrinth can be seen, all walls have same brightness.

2. m_renderLightOverHull true, m_transparency 0. 
Bad: Shadows on walls.

3. m_renderLightOverHull true, m_transparency 0.5.
Bad: Shadows on walls, light in separated chamber. 

4. m_renderLightOverHull false, m_transparency 0.
Bad: Walls are unlighted.

5. m_renderLightOverHull false, m_transparency 0.5.
Bad: Walls are unlighted, light in separated chamber.

I'm trying to get situation from picture number 2, but without shadows on wall but still have darkens out of room.
Title: Re: SFML Light System - Let There Be Light
Post by: Daffern on September 16, 2013, 01:54:31 am
You could try render the tiles on top of the shadows
Title: Re: SFML Light System - Let There Be Light
Post by: Estivo on September 16, 2013, 05:31:01 pm
I think that the easiest way to do it is only to make wide line and make it transparent with rendering over hull.
Title: Re: SFML Light System - Let There Be Light
Post by: ThreeDumps on September 16, 2013, 07:01:55 pm
@Daffren, I'm rendering tiles on top of shadows in first case.

@Estivo, this would have worked if the whole labyrinth was one shape but it must be build using convex shapes. It will still makeing bad looking shadows on convex shapes contacting each other.
Title: Re: SFML Light System - Let There Be Light
Post by: Nutomic on September 20, 2013, 02:55:13 pm
I created a Github repository for this project, where I patched it for the latest SFML version and added CMake.

Link (https://github.com/Nutomic/Let-There-Be-Light)

Feel free to open pull requests or issues.

Awww... Still have problems ;)

(http://img834.imageshack.us/img834/1977/my65.png)

Does anyone have an idea what to do to get situation from second image instead from first? And situation from third is actual but not satisfactory.

First is when
hull->m_renderLightOverHull = true;

Third is when
hull->m_renderLightOverHull = false;

Of course I can redraw all walls but then I will have all walls visible, also in chambers next to.

I would be very interested in this as well, but I suppose it requires editing the library.

Maybe I'll get around to have a look at the shadow rendering code.
Title: Re: SFML Light System - Let There Be Light
Post by: Estivo on September 20, 2013, 06:48:43 pm
It's not LTBL fault. You have to make one big shape.
Title: Re: SFML Light System - Let There Be Light
Post by: Daffern on September 22, 2013, 02:03:39 am

I don't know if there is a fix for this, but is there any way to make the shadow fill where it's supposed to fill below the ground rectangle?

Make black texture ? What do you want at all?

As you can see in the picture the light penetrates the hull. This seems to happen when the hulls shape is too long in one direction compared to the other direction, because it works perfect with a square hull. I was wondering if there was a fix for this or if i have to split the hull up into several smaller hulls. The blue part is the hull and there are two lights at the player. Some of the shadow is drawn bellow the hull(the black line directly bellow the hull).
Title: Re: SFML Light System - Let There Be Light
Post by: ThreeDumps on September 25, 2013, 03:10:28 am
It's not LTBL fault. You have to make one big shape.

But what if you can't? LTBL requires convex shapes so all scene will never be one big shape.
Title: Re: SFML Light System - Let There Be Light
Post by: Estivo on September 25, 2013, 07:07:21 am
Yes, but Convex !〓 Concave. Make a big quads.
Title: Re: SFML Light System - Let There Be Light
Post by: Mlikaon on September 29, 2013, 08:54:48 pm
Hello everybody!

I've been really excited when i saw this project, but i must admit i'm now losing my faith trying to add it into my SFML project.

Please help me someone! ^_

Let me try to explain my situation :

I'm using VS11(2012) and i already succeeded in including and using SFML 2.1.
My project is actually working, but i now want to add lights into it.

So :
-I downloaded LTBL 1.5
-I read the .pdf many times
-I pasted the Source directory into my project directory (in order to access to headers)
-I added all the .cpp from Constructs, Light, QuadTree (and the 'utils' one) to my project
-I pasted the example from the .pdf step by step
-I corrected a few changes in my code (for example Light() is no more accepted, i had to use a Light_point())
-I tried to compile and run

Here are the errors VS then returns :

Erreur  4       error C2039: 'unbind' : n'est pas membre de 'sf::Shader'        C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    732     1       SFML TEST
Erreur  3       error C2660: '
sf::Shader::bind' : la fonction ne prend pas 0 arguments  C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    717     1       SFML TEST
Erreur  1       error C2660: '
sf::Texture::bind' : la fonction ne prend pas 0 arguments C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\EmissiveLight.cpp  58      1       SFML TEST
Erreur  2       error C2660: '
sf::Texture::bind' : la fonction ne prend pas 0 arguments C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    267     1       SFML TEST
Erreur  5       error C2660: '
sf::Texture::bind' : la fonction ne prend pas 0 arguments C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    777     1       SFML TEST
Erreur  6       error C2660: '
sf::Texture::bind' : la fonction ne prend pas 0 arguments C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    795     1       SFML TEST
Erreur  7       error C2660: '
sf::Texture::bind' : la fonction ne prend pas 0 arguments C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    820     1       SFML TEST
Erreur  8       error C2660: '
sf::Texture::bind' : la fonction ne prend pas 0 arguments C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    845     1       SFML TEST
Erreur  9       error C2660: '
sf::Texture::bind' : la fonction ne prend pas 0 arguments C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    870     1       SFML TEST
Erreur  10      error C2660: '
sf::Texture::bind' : la fonction ne prend pas 0 arguments C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    898     1       SFML TEST
Erreur  11      error C2660: '
sf::Texture::bind' : la fonction ne prend pas 0 arguments C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    965     1       SFML TEST
Erreur  12      error C2660: '
sf::Texture::bind' : la fonction ne prend pas 0 arguments C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    979     1       SFML TEST

Can someone help me please?
I think there are few changes that have not been updated, and i'm not able to find them.
Title: Re: SFML Light System - Let There Be Light
Post by: Estivo on September 29, 2013, 11:20:46 pm
Really? Are you new user of sfml or you couldn't read? You have to change some lines. Read errors and documentation of actual API w.
Title: Re: SFML Light System - Let There Be Light
Post by: SLC on September 30, 2013, 09:57:19 am
Erreur  4       error C2039: 'unbind' : n'est pas membre de 'sf::Shader'        C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    732     1       SFML TEST
Erreur  3       error C2660: '
sf::Shader::bind' : la fonction ne prend pas 0 arguments  C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    717     1       SFML TEST
Erreur  1       error C2660: '
sf::Texture::bind' : la fonction ne prend pas 0 arguments C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\EmissiveLight.cpp  58      1       SFML TEST
Erreur  2       error C2660: '
sf::Texture::bind' : la fonction ne prend pas 0 arguments C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    267     1       SFML TEST
Erreur  5       error C2660: '
sf::Texture::bind' : la fonction ne prend pas 0 arguments C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    777     1       SFML TEST
Erreur  6       error C2660: '
sf::Texture::bind' : la fonction ne prend pas 0 arguments C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    795     1       SFML TEST
Erreur  7       error C2660: '
sf::Texture::bind' : la fonction ne prend pas 0 arguments C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    820     1       SFML TEST
Erreur  8       error C2660: '
sf::Texture::bind' : la fonction ne prend pas 0 arguments C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    845     1       SFML TEST
Erreur  9       error C2660: '
sf::Texture::bind' : la fonction ne prend pas 0 arguments C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    870     1       SFML TEST
Erreur  10      error C2660: '
sf::Texture::bind' : la fonction ne prend pas 0 arguments C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    898     1       SFML TEST
Erreur  11      error C2660: '
sf::Texture::bind' : la fonction ne prend pas 0 arguments C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    965     1       SFML TEST
Erreur  12      error C2660: '
sf::Texture::bind' : la fonction ne prend pas 0 arguments C:\Users\Shacker\Documents\Visual Studio 2012\Projects\SFML TEST\SFML TEST\Source\LTBL\Light\LightSystem.cpp    979     1       SFML TEST

Do you think everyone speaks your language to understand what the error says? Anyways read here (http://www.cplusplus.com/forum/general/1152/)

Quote from: 'Grey Wolf'
The function prototype dose not match the function definition

SFML API has changed and LTBL doesn't comply with the API so you must rewrite/update the LTBL code if you want to use it with the latest SFML version :)
Title: Re: SFML Light System - Let There Be Light
Post by: Mlikaon on September 30, 2013, 10:01:05 am
Well, i'm actually a new user,  yes.
I tried SFML a week ago for the first time.

And I actually read the documentation about Textures and other classes, but my code is still not working.

Here is where i need a few help precisely:

(in the LightSystem.cpp, for example)

m_softShadowTexture->bind();

This function is no more accepted, and so i have to change it.
So i look at the documentation, as usual, and see the Texture class have a bind() public method :

static void    bind (const Texture *texture, CoordinateType coordinateType=Normalized)
    Bind a texture for rendering.


I tried to replace with something like :
sf::Texture::bind(&m_softShadowTexture);

No more errors, but no lights appear!

Can somebody tell me where i am wrong please?


Edit : sorry for the lack of traduction, i didn't notice in time
Title: Re: SFML Light System - Let There Be Light
Post by: 0-Guillaume-0 on October 02, 2013, 07:13:32 pm
Hi everyone,

I'm actually a new sfml user too, and i wanted to use "let there be light" library as well, but i've got the same problem as Mlikaon, at the exact same places.

It comes from some functions like "bind()", "unbind()" (this last one doesen't seem to exist anymore in the library).
VisualStudio tells me that "the function doesn't accept 0 arguments", it takes an argument witch type is "const sf::Texture *texture"

I began to search for solutions, trying some variables, rewrite some lines, but i didn't find anything that goes on.

I'd like to have some help on this problem too.

I read that maybe we should make an update of the library or rewrite some parts of it, it sounds good but actually i've no ideas of which part to rewrite, or how i should update it.

If someone has solved this problem before, i think it would be helpfull for everyone in the same situation to have a little tutorial about it, and if i find a solution with one of you, maybe i'll write one.

This library seems really powerfull, even though it's not easy to put it in place, if someone found a solution or has a little more explainations about this setup, please contact me or just post there, it will be really helpfull!
Title: Re: SFML Light System - Let There Be Light
Post by: G. on October 02, 2013, 07:54:27 pm
unbind() is sf::Texture::bind(NULL); (http://en.sfml-dev.org/forums/index.php?topic=6635.msg72584#msg72584) now.
Title: Re: SFML Light System - Let There Be Light
Post by: Estivo on October 02, 2013, 07:55:49 pm
Try this
m_softShadowTexture->bind(&m_softShadowTexture);
m_softShadowTexture->bind(nullptr);

It's working for me perfectly.

LTBL is not powerful ;) Is simple, easy to use. If you want powerful light library try GLLight by lolz123 (author of LTBL).
Title: Re: SFML Light System - Let There Be Light
Post by: Laurent on October 02, 2013, 08:41:55 pm
The bind function is static, no need to use an instance to call it.
Title: Re: SFML Light System - Let There Be Light
Post by: polkom21 on November 11, 2013, 08:57:51 pm
Hi everyone!

I'm writing to you because I have problem with LTBL. So when I compiling my project with example I have error's:
Code: [Select]
obj\Debug\main.o||In function `main':|
gmail.com\ltbl\main.cpp|23|undefined reference to `Vec2f::Vec2f(float, float)'|
gmail.com\ltbl\main.cpp|23|undefined reference to `Vec2f::Vec2f(float, float)'|
gmail.com\ltbl\main.cpp|23|undefined reference to `AABB::AABB(Vec2f const&, Vec2f const&)'|
gmail.com\ltbl\main.cpp|23|undefined reference to `ltbl::LightSystem::LightSystem(AABB const&, sf::RenderWindow*, std::string const&, std::string const&)'|
gmail.com\ltbl\main.cpp|23|undefined reference to `ltbl::LightSystem::~LightSystem()'|
gmail.com\ltbl\main.cpp|32|undefined reference to `ltbl::Light_Point::Light_Point()'|
gmail.com\ltbl\main.cpp|23|undefined reference to `ltbl::LightSystem::~LightSystem()'|
gmail.com\ltbl\main.cpp|33|undefined reference to `ltbl::LightSystem::AddLight(ltbl::Light*)'|
gmail.com\ltbl\main.cpp|35|undefined reference to `ltbl::ConvexHull::ConvexHull()'|
gmail.com\ltbl\main.cpp|36|undefined reference to `ltbl::ConvexHull::LoadShape(char const*)'|
gmail.com\ltbl\main.cpp|39|undefined reference to `ltbl::ConvexHull::CalculateNormals()'|
gmail.com\ltbl\main.cpp|40|undefined reference to `ltbl::ConvexHull::CalculateAABB()'|
gmail.com\ltbl\main.cpp|41|undefined reference to `Vec2f::Vec2f(float, float)'|
gmail.com\ltbl\main.cpp|41|undefined reference to `ltbl::ConvexHull::SetWorldCenter(Vec2f const&)'|
gmail.com\ltbl\main.cpp|42|undefined reference to `ltbl::LightSystem::AddConvexHull(ltbl::ConvexHull*)'|
gmail.com\ltbl\main.cpp|56|undefined reference to `Vec2f::Vec2f(float, float)'|
gmail.com\ltbl\main.cpp|56|undefined reference to `ltbl::Light::SetCenter(Vec2f)'|
gmail.com\ltbl\main.cpp|61|undefined reference to `ltbl::LightSystem::RenderLights()'|
gmail.com\ltbl\main.cpp|62|undefined reference to `ltbl::LightSystem::RenderLightTexture()'|
gmail.com\ltbl\main.cpp|66|undefined reference to `ltbl::LightSystem::~LightSystem()'|
gmail.com\ltbl\main.cpp|66|undefined reference to `ltbl::LightSystem::~LightSystem()'|
What I have to do to LTBL work in my project?
Title: Re: SFML Light System - Let There Be Light
Post by: Grimshaw on November 11, 2013, 09:40:59 pm
Add LTBL sources to your project.. When they compile right you should stop having undefined reference errors
Title: Re: SFML Light System - Let There Be Light
Post by: polkom21 on November 11, 2013, 09:55:40 pm
I include all source to my project who are needed

#include <LTBL/Light/LightSystem.h>
#include <LTBL/Light/Light_Point.h>
#include <LTBL/Utils.h>
#include <assert.h>
#include <SFML/Graphics.hpp>
int main(int argc, char* args[])
{
    sf::VideoMode vidMode;
    vidMode.width = 800;
    vidMode.height = 600;
    vidMode.bitsPerPixel = 32;
    assert(vidMode.isValid());
    sf::RenderWindow win;
    win.create(vidMode, "Let there be Light - Demo");
    // ---------------------- Background Image ---------------------
    sf::Texture backgroundImage;
    assert(backgroundImage.loadFromFile("data/background.png"));
    // Tiling background
    backgroundImage.setRepeated(true);
    sf::Sprite backgroundSprite(backgroundImage);
    backgroundSprite.setTextureRect(sf::IntRect(0, 0, vidMode.width, vidMode.height));
    // --------------------- Light System Setup ---------------------
    ltbl::LightSystem ls(AABB(Vec2f(0.0f, 0.0f), Vec2f(static_cast<float>(vidMode.width), static_cast<float>(vidMode.height))), &win, "data/lightFin.png", "data/shaders/lightAttenuationShader.frag");
    // Create a light
    /*ltbl::Light* testLight = new ltbl::Light();
    testLight->m_center = Vec2f(200.0f, 200.0f);
    testLight->m_radius = 500.0f;
    testLight->m_size = 30.0f;
    //testLight->m_spreadAngle = 2.0f * static_cast<float>(M_PI);
    //testLight->m_softSpreadAngle = 0.0f;
    testLight->CalculateAABB();*/

    ltbl::Light_Point * testLight = new ltbl::Light_Point();
    ls.AddLight(testLight);
    // Create a hull by loading it from a file
    ltbl::ConvexHull* testHull = new ltbl::ConvexHull();
    if(!testHull->LoadShape("data/testShape.txt"))
    abort();
    // Pre-calculate certain aspects
    testHull->CalculateNormals();
    testHull->CalculateAABB();
    testHull->SetWorldCenter(Vec2f(300.0f, 300.0f));
    ls.AddConvexHull(testHull);
    // ------------------------- Game Loop --------------------------
    sf::Event eventStructure;
    bool quit = false;
    while(!quit)
    {
        while(win.pollEvent(eventStructure))
            if(eventStructure.type == sf::Event::Closed)
            {
                quit = true;
                break;
            }
        sf::Vector2i mousePos = sf::Mouse::getPosition(win);
        // Update light
        testLight->SetCenter(Vec2f(static_cast<float>(mousePos.x), static_cast<float>(vidMode.height - mousePos.y)));
        win.clear();
        // Draw the background
        win.draw(backgroundSprite);

        ls.RenderLights();
        ls.RenderLightTexture();

        win.display();
    }
    win.close();
}
 
Title: Re: SFML Light System - Let There Be Light
Post by: Estivo on November 11, 2013, 10:04:52 pm
eh if you have linked in project (added as your file) you shouldn't use < >. Use " " for #include.
Title: Re: SFML Light System - Let There Be Light
Post by: polkom21 on November 11, 2013, 10:13:28 pm
All source files are added to mingw folder so I use <>
Title: Re: SFML Light System - Let There Be Light
Post by: Grimshaw on November 12, 2013, 01:30:33 pm
Ill try again.. When I said "add sources" it means adding the LTBL sources to your project, so they can compile. This means the .cpp files in your project tree / makefile... Nothing to do with #includes..
Title: Re: SFML Light System - Let There Be Light
Post by: zachprinz on November 16, 2013, 01:50:25 am
Views seem really wonky.

(http://i.imgur.com/ctWPUfk.png)

I'm getting this. It's the same problem everyone else was having quite a few pages ago.

The only time I can see lights is if I set the view the the default view of the panel. But then I can't see lights anywhere else.

You can see the light trailing up into the top right hand corner of the darkened area.

Anyone know a fix?


   view.setCenter();
   panel.setView(view);
        Draw(panel);
   panel.setView(panel.getDefaultView());
   lightSystem.SetView(panel.getDefaultView());
   lightSystem.RenderLights();
   lightSystem.RenderLightTexture();
   lightSystem.DebugRender();
Title: Re: SFML Light System - Let There Be Light
Post by: zachprinz on November 18, 2013, 09:35:45 pm
My solution to the problem I posted above was to create the sf::RenderTexture window I have the sprite panel on at the size of the quad tree for ltbl.

Then I just set a view on the sprite panel and keep the light systems view to the whole 4096x4096 map.

This is resulting in very poor performance when you add in more than a few lights.

I've added checks to see if the lights are contained in the visible part of the map but it doesn't help much, about a 35 fps drop when there are 5 lights on screen.

Any thoughts would be appreciated.
Title: Re: SFML Light System - Let There Be Light
Post by: emplace on November 27, 2013, 04:05:04 pm
Anyone got a working sample of this ?
Title: Re: SFML Light System - Let There Be Light
Post by: Daffern on December 02, 2013, 07:32:01 pm
When im setting the m_intensity to lower than 1.0 no light is shown at all when m_useBloom is true.

The light works when m_useBloom is false, however m_intensity doesnt affect the intensity of the light at all ???

Anyone know why this happens?
Title: Re: SFML Light System - Let There Be Light
Post by: Estivo on December 02, 2013, 07:57:43 pm
Mess in code. Set intensity to 2.0, manipulate attentuation.
Title: Re: SFML Light System - Let There Be Light
Post by: Daffern on December 02, 2013, 10:27:28 pm
Okey! Thanks for the quick answer
Title: Re: SFML Light System - Let There Be Light
Post by: polkom21 on December 18, 2013, 11:23:45 pm
Hello everybody!

I have problem with y-axis because I want flip this axis and I don't know how to do it. Help me!

EDIT:
Ok. I know how to do it. Now I have a problem with rotation ConvexHull. Whether is something function who sets angle?
Title: Re: SFML Light System - Let There Be Light
Post by: Daffern on December 21, 2013, 03:39:29 pm
No, there is no such function. However you can get each point from a sf::Shape by using getPoint(int). Example:

hull->m_vertices.clear();
int count = dRect.rect.getPointCount();
         for (int i = count; i>0 ; i--){
            sf::Vector2f point =  rect.getTransform().transformPoint(rect.getPoint(i));
            hull->m_vertices.push_back(Vec2f(point.x,options.screenHeight-point.y));
         }

You probably have to fit it to your code, but this was how i did it ;)
Title: Re: SFML Light System - Let There Be Light
Post by: polkom21 on December 21, 2013, 05:46:20 pm
Thanks for the idea. I have another problem. When I set light point position like static position all it's ok how I set position from object position light isn't rendered.
Title: Re: SFML Light System - Let There Be Light
Post by: polkom21 on December 27, 2013, 11:55:01 pm
Ok. I repaired it. How to change position convexHull?
Title: Re: SFML Light System - Let There Be Light
Post by: Daffern on December 28, 2013, 03:01:46 am
Use the same code as above
Title: Re: SFML Light System - Let There Be Light
Post by: polkom21 on January 15, 2014, 11:13:30 pm
Hi everybody.

I come back to writing my game and I have next problem with lights. Why penumbra isn't rendered as it should be?
(http://screenshu.com/static/uploads/temporary/sy/e6/vu/c1w2d4.jpg)
And next problem. Why when I set m_renderLightOverHull on false  shadow looks like:
(http://screenshu.com/static/uploads/temporary/7u/i7/1o/npz89j.jpg)
Title: Re: SFML Light System - Let There Be Light
Post by: The Illusionist Mirage on January 16, 2014, 12:16:12 pm
I get this when I try to follow the walk through:
(http://puu.sh/6mNrO.png)

(http://puu.sh/6mNs6.png)
Title: Re: SFML Light System - Let There Be Light
Post by: eXpl0it3r on January 16, 2014, 01:11:29 pm
I get this when I try to follow the walk through
What walk through?

ltbl::Light is, as the compiler says, an abstract class and thus can't be instantiated. You most likely want to use ltbl::Ligh_Point instead, as shown in the example file. ;)
Title: Re: SFML Light System - Let There Be Light
Post by: BaneTrapper on March 21, 2014, 02:50:00 pm
Can someone who actually can find stuff here i bean true all the 21 pages and downloaded bunch of files cannot get to compile and build it for win7 Visual studio 2010-11.
I just want to get this thing running on my system, no luck yet.
Please some guidance.


I downloaded from first post "Let there be light" added to my project and i get following errors:
I got no idea how to get it to build with Cmake, its prompting errors as well.
Code: [Select]
1>------ Build started: Project: Test, Configuration: Debug Win32 ------
1>Light_Point.obj : error LNK2019: unresolved external symbol __imp__glBegin@4 referenced in function "public: void __thiscall std::_Wrap_alloc<class std::allocator<char> >::construct<char *,char * &>(char * *,char * &)" (??$construct@PADAAPAD@?$_Wrap_alloc@V?$allocator@D@std@@@std@@QAEXPAPADAAPAD@Z)
1>ShadowFin.obj : error LNK2001: unresolved external symbol __imp__glBegin@4
1>AABB.obj : error LNK2001: unresolved external symbol __imp__glBegin@4
1>ConvexHull.obj : error LNK2001: unresolved external symbol __imp__glBegin@4
1>EmissiveLight.obj : error LNK2001: unresolved external symbol __imp__glBegin@4
1>LightSystem.obj : error LNK2001: unresolved external symbol __imp__glBegin@4
1>Light_Point.obj : error LNK2019: unresolved external symbol __imp__glEnd@0 referenced in function "public: void __thiscall std::_Wrap_alloc<class std::allocator<char> >::construct<char *,char * &>(char * *,char * &)" (??$construct@PADAAPAD@?$_Wrap_alloc@V?$allocator@D@std@@@std@@QAEXPAPADAAPAD@Z)
1>ShadowFin.obj : error LNK2001: unresolved external symbol __imp__glEnd@0
1>AABB.obj : error LNK2001: unresolved external symbol __imp__glEnd@0
1>ConvexHull.obj : error LNK2001: unresolved external symbol __imp__glEnd@0
1>EmissiveLight.obj : error LNK2001: unresolved external symbol __imp__glEnd@0
1>LightSystem.obj : error LNK2001: unresolved external symbol __imp__glEnd@0
1>Light_Point.obj : error LNK2019: unresolved external symbol __imp__glVertex2f@8 referenced in function "public: void __thiscall std::_Wrap_alloc<class std::allocator<char> >::destroy<char *>(char * *)" (??$destroy@PAD@?$_Wrap_alloc@V?$allocator@D@std@@@std@@QAEXPAPAD@Z)
1>ShadowFin.obj : error LNK2001: unresolved external symbol __imp__glVertex2f@8
1>AABB.obj : error LNK2001: unresolved external symbol __imp__glVertex2f@8
1>ConvexHull.obj : error LNK2001: unresolved external symbol __imp__glVertex2f@8
1>EmissiveLight.obj : error LNK2001: unresolved external symbol __imp__glVertex2f@8
1>LightSystem.obj : error LNK2001: unresolved external symbol __imp__glVertex2f@8
1>Color3f.obj : error LNK2019: unresolved external symbol __imp__glColor3f@12 referenced in function "public: void __thiscall Color3f::GL_Set(void)" (?GL_Set@Color3f@@QAEXXZ)
1>EmissiveLight.obj : error LNK2001: unresolved external symbol __imp__glColor3f@12
1>QuadTree.obj : error LNK2001: unresolved external symbol __imp__glColor3f@12
1>ConvexHull.obj : error LNK2019: unresolved external symbol __imp__glTranslatef@12 referenced in function "public: void __thiscall ltbl::ConvexHull::DebugDraw(void)" (?DebugDraw@ConvexHull@ltbl@@QAEXXZ)
1>EmissiveLight.obj : error LNK2001: unresolved external symbol __imp__glTranslatef@12
1>LightSystem.obj : error LNK2001: unresolved external symbol __imp__glTranslatef@12
1>ConvexHull.obj : error LNK2019: unresolved external symbol __imp__glVertex3f@12 referenced in function "public: void __thiscall ltbl::ConvexHull::RenderHull(float)" (?RenderHull@ConvexHull@ltbl@@QAEXM@Z)
1>LightSystem.obj : error LNK2001: unresolved external symbol __imp__glVertex3f@12
1>EmissiveLight.obj : error LNK2019: unresolved external symbol __imp__glColor4f@16 referenced in function "public: void __thiscall ltbl::EmissiveLight::Render(void)" (?Render@EmissiveLight@ltbl@@QAEXXZ)
1>LightSystem.obj : error LNK2001: unresolved external symbol __imp__glColor4f@16
1>ShadowFin.obj : error LNK2001: unresolved external symbol __imp__glColor4f@16
1>EmissiveLight.obj : error LNK2019: unresolved external symbol __imp__glPopMatrix@0 referenced in function "public: void __thiscall ltbl::EmissiveLight::Render(void)" (?Render@EmissiveLight@ltbl@@QAEXXZ)
1>EmissiveLight.obj : error LNK2019: unresolved external symbol __imp__glPushMatrix@0 referenced in function "public: void __thiscall ltbl::EmissiveLight::Render(void)" (?Render@EmissiveLight@ltbl@@QAEXXZ)
1>EmissiveLight.obj : error LNK2019: unresolved external symbol __imp__glRotatef@16 referenced in function "public: void __thiscall ltbl::EmissiveLight::Render(void)" (?Render@EmissiveLight@ltbl@@QAEXXZ)
1>EmissiveLight.obj : error LNK2019: unresolved external symbol __imp__glTexCoord2i@8 referenced in function "public: void __thiscall ltbl::EmissiveLight::Render(void)" (?Render@EmissiveLight@ltbl@@QAEXXZ)
1>LightSystem.obj : error LNK2001: unresolved external symbol __imp__glTexCoord2i@8
1>ShadowFin.obj : error LNK2001: unresolved external symbol __imp__glTexCoord2i@8
1>Light.obj : error LNK2019: unresolved external symbol __imp__glEnable@4 referenced in function "public: void __thiscall ltbl::Light::SetAlwaysUpdate(bool)" (?SetAlwaysUpdate@Light@ltbl@@QAEX_N@Z)
1>LightSystem.obj : error LNK2001: unresolved external symbol __imp__glEnable@4
1>Light.obj : error LNK2019: unresolved external symbol __imp__glLoadIdentity@0 referenced in function "private: void __thiscall ltbl::Light::SwitchStaticTexture(void)" (?SwitchStaticTexture@Light@ltbl@@AAEXXZ)
1>LightSystem.obj : error LNK2001: unresolved external symbol __imp__glLoadIdentity@0
1>Light.obj : error LNK2019: unresolved external symbol __imp__glMatrixMode@4 referenced in function "private: void __thiscall ltbl::Light::SwitchStaticTexture(void)" (?SwitchStaticTexture@Light@ltbl@@AAEXXZ)
1>LightSystem.obj : error LNK2001: unresolved external symbol __imp__glMatrixMode@4
1>Light.obj : error LNK2019: unresolved external symbol __imp__glOrtho@48 referenced in function "private: void __thiscall ltbl::Light::SwitchStaticTexture(void)" (?SwitchStaticTexture@Light@ltbl@@AAEXXZ)
1>LightSystem.obj : error LNK2001: unresolved external symbol __imp__glOrtho@48
1>Light.obj : error LNK2019: unresolved external symbol __imp__glViewport@16 referenced in function "private: void __thiscall ltbl::Light::SwitchStaticTexture(void)" (?SwitchStaticTexture@Light@ltbl@@AAEXXZ)
1>LightSystem.obj : error LNK2001: unresolved external symbol __imp__glViewport@16
1>LightSystem.obj : error LNK2019: unresolved external symbol __imp__glBlendFunc@8 referenced in function "private: void __thiscall ltbl::LightSystem::ClearLightTexture(class sf::RenderTexture &)" (?ClearLightTexture@LightSystem@ltbl@@AAEXAAVRenderTexture@sf@@@Z)
1>ShadowFin.obj : error LNK2001: unresolved external symbol __imp__glBlendFunc@8
1>LightSystem.obj : error LNK2019: unresolved external symbol __imp__glColor4b@16 referenced in function "public: void __thiscall ltbl::LightSystem::RenderLights(void)" (?RenderLights@LightSystem@ltbl@@QAEXXZ)
1>LightSystem.obj : error LNK2019: unresolved external symbol __imp__glDisable@4 referenced in function "private: void __thiscall ltbl::LightSystem::MaskShadow(class ltbl::Light *,class ltbl::ConvexHull *,bool,float)" (?MaskShadow@LightSystem@ltbl@@AAEXPAVLight@2@PAVConvexHull@2@_NM@Z)
1>C:\C++\Projects\Test\Debug\Test.exe : fatal error LNK1120: 19 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


Win 7 32bit, Visual studio 11 the .exe works fine but i cannot get to compile into my project
Title: Re: SFML Light System - Let There Be Light
Post by: lolz123 on March 22, 2014, 05:15:13 pm
You must link to OpenGL. Add OpenGL32.lib in to the linker input.
Title: Re: SFML Light System - Let There Be Light
Post by: BaneTrapper on March 22, 2014, 07:53:25 pm
EDIT:: Fixed the errors by doing:
Going true posts and getting "lightAttenuationShader.frag" that doesn't make errors,
There is still a issue of light not being rendered when the light is "left of hull", everything works fine but the light when it is left of the hull, the hull is not rendered at all...

EDIT::Ignore Fixed, use for code if want its working, but the light Point 2 is broken.
Thank you, including openGL fixed that error.
But i am getting very bad visuals and console errors with "what i think is the user updated latest example code"

"Console screenshot"
http://postimg.org/image/u8z3icnlb/

Any ideas why there is an "openGL" failure, my gpu drivers up to date and same issue.
Also why the "Point light" gives error ("Cannot create texture invalid size(50, 0)"), i tried messing up with the code and i cannot make it work.
Code: [Select]
int main(int argc, char* args[])
{
sf::VideoMode vidMode;
vidMode.width = 800;
vidMode.height = 600;
vidMode.bitsPerPixel = 32;
assert(vidMode.isValid());

sf::RenderWindow win;
win.create(vidMode, "Let there be Light - Demo");

sf::View view;
sf::Vector2u windowSize(win.getSize());
view.setSize(sf::Vector2f(static_cast<float>(windowSize.x), static_cast<float>(windowSize.y)));
view.setCenter(view.getSize() / 2.0f);

// ---------------------- Background Image ---------------------

sf::Texture backgroundImage;

assert(backgroundImage.loadFromFile("data/background.png"));

// Tiling background
backgroundImage.setRepeated(true);

sf::Sprite backgroundSprite(backgroundImage);
backgroundSprite.setTextureRect(sf::IntRect(0, 0, vidMode.width * 2, vidMode.height * 2));
backgroundSprite.setPosition(-400.0f, -400.0f);
std::cout<<"Hello:"<<std::endl;
// --------------------- Light System Setup ---------------------

ltbl::LightSystem ls(AABB(Vec2f(0.0f, 0.0f), Vec2f(static_cast<float>(vidMode.width), static_cast<float>(vidMode.height))), &win, "data/lightFin.png", "data/shaders/lightAttenuationShader.frag");

// Create a light
ltbl::Light_Point* testLight = new ltbl::Light_Point();
testLight->m_intensity = 2.0f;
testLight->m_center = Vec2f(200.0f, 200.0f);
testLight->m_radius = 600.0f;
testLight->m_size = 15.0f;
testLight->m_spreadAngle = ltbl::pifTimes2;
testLight->m_softSpreadAngle = 0.0f;
testLight->CalculateAABB();

testLight->m_bleed = 0.4f;
testLight->m_linearizeFactor = 0.2f;

ls.AddLight(testLight);

testLight->SetAlwaysUpdate(true);

std::cout<<"Create a light BEFORE:"<<std::endl;
// Create a light
ltbl::Light_Point* testLight2 = new ltbl::Light_Point();
testLight2->m_center = Vec2f(200.0f, 200.0f);
testLight2->m_radius = 50.0f;
testLight2->m_size = 30.0f;
testLight2->m_color.r = 0.5f;
testLight2->m_intensity = 1.5f;
testLight2->m_spreadAngle = ltbl::pifTimes2;
testLight2->m_softSpreadAngle = 0.0f;
testLight2->CalculateAABB();

ls.AddLight(testLight2);

testLight2->SetAlwaysUpdate(false);

std::cout<<"Create a emissive light BEFORE:"<<std::endl;
// Create an emissive light
ltbl::EmissiveLight* emissiveLight = new ltbl::EmissiveLight();

sf::Texture text;

if(!text.loadFromFile("data/emissive.png"))
abort();

emissiveLight->SetTexture(&text);

emissiveLight->SetRotation(45.0f);

emissiveLight->m_intensity = 1.3f;

ls.AddEmissiveLight(emissiveLight);

emissiveLight->SetCenter(Vec2f(500.0f, 500.0f));

std::cout<<"Create a hull BEFORE:"<<std::endl;
// Create a hull by loading it from a file
ltbl::ConvexHull* testHull = new ltbl::ConvexHull();

if(!testHull->LoadShape("data/testShape.txt"))
abort();

// Pre-calculate certain aspects
testHull->CalculateNormals();
testHull->CalculateAABB();

testHull->SetWorldCenter(Vec2f(300.0f, 300.0f));

testHull->m_renderLightOverHull = true;

ls.AddConvexHull(testHull);

// ------------------------- Game Loop --------------------------

sf::Event eventStructure;

bool quit = false;

ls.m_useBloom = true;

while(!quit)
{
while(win.pollEvent(eventStructure))
if(eventStructure.type == sf::Event::Closed)
{
quit = true;
break;
}

if(sf::Keyboard::isKeyPressed(sf::Keyboard::A))
view.move(sf::Vector2f(-1.0f, 0.0f));
else if(sf::Keyboard::isKeyPressed(sf::Keyboard::D))
view.move(sf::Vector2f(1.0f, 0.0f));

if(sf::Keyboard::isKeyPressed(sf::Keyboard::W))
view.move(sf::Vector2f(0.0f, -1.0f));
else if(sf::Keyboard::isKeyPressed(sf::Keyboard::S))
view.move(sf::Vector2f(0.0f, 1.0f));

sf::Vector2i mousePos = sf::Mouse::getPosition(win);
//testLight2->IncCenter(ltbl::Vec2f(0.1f, 0.0f));
// Update light
testLight->SetCenter(Vec2f(static_cast<float>(mousePos.x), static_cast<float>(vidMode.height) - static_cast<float>(mousePos.y)));

win.clear();

win.setView(view);
ls.SetView(view);

// Draw the background
win.draw(backgroundSprite);

// Calculate the lights
ls.RenderLights();

// Draw the lights
ls.RenderLightTexture();

//ls.DebugRender();

win.display();
}

win.close();
}
Title: Re: SFML Light System - Let There Be Light
Post by: Voroz on April 26, 2014, 01:20:22 am
Hello. I'm using "let there be light" and i like it. The only problem i'm having is that in the top left corner and also some on the left side of the screen there is a spot where one light will make it so the whole screen lights up.
Maybe you wanted this as a spot for a sun or something but it doesn't work for my top view game. If i move up to that corner with my characters light it will get too bright.

I tried identifying the problem. My characters light was always the light that worked this way, my testlight on mouse position didn't have that effect at all.
So i tried switching spawn time of those 2 lights so the mouselight spawned before the characters light, and then the problem was gone (i thought).
 I then made it so that light didn't attach to mouse anymore but spawned outside the screen. That didn't work, it only worked if i had atleast 1 pixel of that light on my screen, so i adjusted it so i had (didn't even notice that small light anyway).

Later i noticed that when i added more lights the problem would come back and another light would become the "sun" light. The light that makes the screen light up much more if you move the light to the top left corner.

You can see this same problem in the "let there be light" demo program. Just move the light up to the corner and you see it. The problem is not that big in that application but i use bigger lights so i don't have to move that close to the corner for it to happen.

I've looked through the source code in search of any function that was made to cause that, but can't find anything and i'm not such a good programmer yet. Anyway do you know of a solution for this problem?

Thanks for your time.

Title: Re: SFML Light System - Let There Be Light
Post by: Estivo on April 26, 2014, 01:45:04 am
I think this is a quad tree bug. Try to set bigger quad or make size of quad to 0, 0. That's all that I could say without code.
Title: Re: SFML Light System - Let There Be Light
Post by: Voroz on April 26, 2014, 02:45:46 am
I think this is a quad tree bug. Try to set bigger quad or make size of quad to 0, 0. That's all that I could say without code.
And what is the quad? This part?
ltbl::LightSystem ls(AABB(Vec2f(0.0f, 0.0f), Vec2f(static_cast<float>(0), static_cast<float>(0))), &App, "data/lightFin.png", "data/shaders/lightAttenuationShader.frag");
I did already set it to 0 after reading that someone had issue with crashes and after that i also had that issue when reducing size of one of my lights.

In your zombie game do you also have this issue if you have only 1 light source and try moving it to the top left corner? I've noticed that it's only 1 of the lights at a time that will cause this.


Here most relevant code for the lighting.

// --------------------- Light System Setup ---------------------
//Set AABB to 0 to avoid crashes with some light sizes
ltbl::LightSystem ls(AABB(Vec2f(0.0f, 0.0f), Vec2f(static_cast<float>(0), static_cast<float>(0))), &App, "data/lightFin.png", "data/shaders/lightAttenuationShader.frag");
newLight(&ls, &characterLight); /*This sets all the settings and adds the light etc.
didn't include the function because it would get messy and my bug is even represented in the ltbl demo so i don't think it's a coding issue.
*/


//Update light
for (int i = 0; i < characterLight.size(); i++){
    characterLight[i].lightPoint->SetCenter(Vec2f(character.back().circle.body->GetPosition().x*PPM, screenSize.y-character.back().circle.body->GetPosition().y*PPM)); //Y axis inverted
}

//Lights
ls.SetView(View1);
ls.RenderLights();
ls.RenderLightTexture();
Title: Re: SFML Light System - Let There Be Light
Post by: Estivo on April 26, 2014, 11:21:56 am
I'm creating light system by "create" function. I have some glitches when I was using only constructor.

Maybe large size (int_min, int_max) could solve your problem. I have bug in editor map. When I add new light i have to "reload" light system by setting view position to 0,0.

When I had only 1 (flashlight) I have ugly effect. No penumbra. I had at first add light and then I had to move it, that was only solve I know.

I have 0,0 x 10k,10k quad tree and all works fine.
Title: Re: SFML Light System - Let There Be Light
Post by: Voroz on April 26, 2014, 02:10:32 pm
I'm creating light system by "create" function. I have some glitches when I was using only constructor.

Maybe large size (int_min, int_max) could solve your problem. I have bug in editor map. When I add new light i have to "reload" light system by setting view position to 0,0.

When I had only 1 (flashlight) I have ugly effect. No penumbra. I had at first add light and then I had to move it, that was only solve I know.

I have 0,0 x 10k,10k quad tree and all works fine.

what do you mean with "large size (int_min, int_max)"? I've tried making a new light view twice as big as the screen view so the corner that gives extra light won't often be a problem.
But that makes it so all lights becomes twice as big and they don't move where they should.

edit: I tried what you said with using create and also the 10k quadtree. it's the same problem still. I think you might have it too but just not noticed it in your app.
Title: Re: SFML Light System - Let There Be Light
Post by: Estivo on April 26, 2014, 02:26:54 pm
I mean make quad with max int value. Could you post screen shot? Are you set alwaysUpdate to true?
Title: Re: SFML Light System - Let There Be Light
Post by: Voroz on April 26, 2014, 02:43:16 pm
I mean make quad with max int value. Could you post screen shot? Are you set alwaysUpdate to true?
ok. one second for screenshot

edit: http://imgur.com/gAtE9D2 (http://imgur.com/gAtE9D2)

last picture is when my character is at the top left corner with that light.

edit2: Also i tried using AlwaysUpdate(). Not sure if i did it correctly though. I'm just suppoed to write
light->back().lightPoint->AlwaysUpdate();
? It takes no argument like true or false.
Title: Re: SFML Light System - Let There Be Light
Post by: Estivo on April 26, 2014, 02:58:58 pm
There is function setAlwaysUpdate. At first you have to add light to light system and then setAlwaysUpdate.

Quote
lSystem.AddLight(player.getLight());
    player.getLight()->SetAlwaysUpdate(true);
Title: Re: SFML Light System - Let There Be Light
Post by: Voroz on April 26, 2014, 03:05:10 pm
There is function setAlwaysUpdate. At first you have to add light to light system and then setAlwaysUpdate.

Quote
lSystem.AddLight(player.getLight());
    player.getLight()->SetAlwaysUpdate(true);
Ah ok. Yeah i tried it now but it made no differance. I update every light manually in my code anyway.

edit: Are you using light_point or normal light or emissive light or what btw? I'm using Light_Point because that's what i could get to work.
Title: Re: SFML Light System - Let There Be Light
Post by: Estivo on April 26, 2014, 03:45:11 pm
Light class is pure virtual so you only could use it as base class for your own light class. Emmisive is light for rendering a light with a shape of texture. I use only Point_Light class.

Your bug is strange. I did't occur this kind of glitches. You could try to rebuild your whole code ;) When I get back to home I'll upload my version of ltbl with my blend modes and changes.
Title: Re: SFML Light System - Let There Be Light
Post by: Voroz on April 26, 2014, 04:22:27 pm
Light class is pure virtual so you only could use it as base class for your own light class. Emmisive is light for rendering a light with a shape of texture. I use only Point_Light class.

Your bug is strange. I did't occur this kind of glitches. You could try to rebuild your whole code ;) When I get back to home I'll upload my version of ltbl with my blend modes and changes.
The thing is that i think this is a bug with ltbl and i think your code also has the bug because if you run the ltbl demo app that you have in your ltbl folder the same bug is there if you move the cursor to the top left corner. I want to know what change can be done to ltbl to fix this :/.
Title: Re: SFML Light System - Let There Be Light
Post by: Voroz on April 26, 2014, 05:52:22 pm
If you have time you can try reproducing this by having max 1 light and placing it near the top left corner in your application. If that works for you i'd like to know.
There is always max 1 light with this problem but which light it is changes almost randomly it seems so to know which light is the bugged one you should only have 1 light spawned.

You can download the app here if you wanna see the issue for yourself: https://dl.dropboxusercontent.com/u/150244750/Release.rar (https://dl.dropboxusercontent.com/u/150244750/Release.rar)

You can notice if you right click in the top left corner to make a light there the issue is not there. Only the characters light gives the issue because i spawned the character light first. But if i start shooting alot of fireballs(lights) it will sometimes make another light the issue for a while. It's acting very weird.


This is a version where i remove the character light and you can instead right click or fireball to see the issue with those lights. For example if you use the rightclick light and then fireball at the same time the issue will stay only with the right click light, but if you shut that light down then the issue is with the fireballs instead. Sounds a bit complicated and it is, but you can try it for yourself:
https://dl.dropboxusercontent.com/u/150244750/noCharLight.rar (https://dl.dropboxusercontent.com/u/150244750/noCharLight.rar)
Title: Re: SFML Light System - Let There Be Light
Post by: Voroz on April 27, 2014, 09:25:25 pm
If anyone else has this problem a temporary solution that works well is to put a convex hull with
"m_renderLightOverHull = false;"
in the top left corner. That will solve the problem. It worked for me with a 6x6 sized square, but you can probably make it even smaller.
Title: Re: SFML Light System - Let There Be Light
Post by: Theshooter7 on May 03, 2014, 11:01:03 am
Hi, I've been trying to get LTBL to work with my Tile-based 2D SFML game.

I made the necessary changes to 1.5.1 to get it to work with the latest SFML (changing to sf::Texture::bind() etc). I finally got it working except the shadows always come up in the wrong place. What gives?

I'm using the tmx (Tiled) map format for my levels, and constructing the hulls based on collision objects read in from the loader. I've checked the debug drawing and the hulls are all in their correct places and the light is where it should be but the shadows are simply drawing for things that don't exist.

Anyone encounter this issue and know how to fix it?

[EDIT] Ok so I figured out the issue, the Hull verticies are relative to 0, 0 so I had to basically take the hull box being read in by loader and subtract it's width/height from the vertex position to get the correct location for the hull's placement.

However I've found that the hulls are only relative to your viewport/window. For instance, I have a 1024 x 768 Tile map (of which tiles are 32x32 so that's 32x24 tiles). When I try to place the Hull using SetWorldCenter, it comes up with the wrong y coordinate whenever I just get the center location from the loader. But if I use the Window's height and subtract the Hull's y from it, then it is placed properly. So the question is: how would I handle this with varying map sizes since it seems the hulls are all relative to the window?
Title: Re: SFML Light System - Let There Be Light
Post by: Voroz on May 04, 2014, 07:45:55 pm
So the question is: how would I handle this with varying map sizes since it seems the hulls are all relative to the window?
Not sure what you mean here. You just need to do
viewSize.y - worldposition.y
and the size of the map doesn't matter.
Title: Re: SFML Light System - Let There Be Light
Post by: Theshooter7 on May 05, 2014, 02:26:39 am
So the question is: how would I handle this with varying map sizes since it seems the hulls are all relative to the window?
Not sure what you mean here. You just need to do
viewSize.y - worldposition.y
and the size of the map doesn't matter.
That's the exact bit of code I used to fix it. :P But there is one last problem: it seems like I have to match the size of the sf::View to the size of my window, otherwise I get problems:
How it looks with sf::View set to 0, 0, 800, 600 and Window at 1024x768:
http://i.imgur.com/ogkRiU5.png (http://i.imgur.com/ogkRiU5.png)
How it should look (sf::View size and Window size are the same, in this picture it's 800x600)
http://i.imgur.com/61juo4M.png (http://i.imgur.com/61juo4M.png)

I want to make the sf::View a fixed size so that the game world looks the same no matter what your resolution is. But the light system seems to dislike that or something. Any ideas?
Title: Re: SFML Light System - Let There Be Light
Post by: Voroz on May 05, 2014, 03:51:48 am
Ok the fix for this (i just tried) is to create another view with the screen resolution instead of using the normal one and then use screenSize instead of viewSize for the
screenSize.y - worldposition.y
part like this:
sf::View lightView;
lightView.setSize(screenSize.x, screenSize.y);
lightView.setCenter(View1.getCenter().x, View1.getCenter().y);

screenSize.y - worldposition.y

ls.SetView(lightView);
Title: Re: SFML Light System - Let There Be Light
Post by: Theshooter7 on May 05, 2014, 04:09:45 am
That works perfectly! Thank you so much. ;D

[EDIT] another small question if you happen to know anything about it, but the light system affects everything that is drawn (unless you draw it after calling RenderLights()/RenderLightTexture()). I wanted to be able to draw a backdrop (such as a sky) with it's own brightness/color settings that would ignore the light system. However, since the backdrop has to be drawn first and then everything over it, and finally the lights are rendered, the sky is affected as well (and usually takes on the light system's ambient color setting).

I don't know any way around this. I thought maybe two render textures might work if I composite them after all is said and done (with the lights being drawn on the non-backdrop render texture), but realized the light system uses raw OpenGL and doesn't interact with SFML's drawing calls, making this impossible.
Title: Re: SFML Light System - Let There Be Light
Post by: Voroz on May 05, 2014, 04:50:27 am
I don't know if this is what you're looking for but maybe move the lightview down a bit.
lightView.setCenter(View1.getCenter().x, View1.getCenter().y+300);

Edit: I realize this doesn't give you 2 different light systems but it's 5 am here so i can't experiment with that atm, but i assume you could just create one more lightsystem and name it something else, and instead of moving it down like i just did, you could move most of it up outside the screen and have only the 300 pixels inside.
Title: Re: SFML Light System - Let There Be Light
Post by: Theshooter7 on May 05, 2014, 04:59:26 am
Edit: I realize this doesn't give you 2 different light systems but it's 5 am here so i can't experiment with that atm, but i assume you could just create one more lightsystem and name it something else, and instead of moving it down like i just did, you could move most of it up outside the screen and have only the 300 pixels inside.
Huh, that's actually a clever idea. I'll give it a try soon. Thanks for your help. :)

[EDIT] Creating a secondary light system gave me some control over the sky brightness, but it looks like it can only go as bright as the main light system's ambient color.

To explain further, I mean a sky or background like a texture that is stretched to fit the whole screen, with things drawn over it.
Title: Re: SFML Light System - Let There Be Light
Post by: Voroz on May 05, 2014, 02:57:20 pm
So you want two equally big lightsystems stacked on eachother? Well i'm no expert but it's very hard to get any help about this light system since the developer seems to have abandoned this project.

I have never tried this and don't know of the issues with it but ofourse the front layer can't become brighter than the back one if that's your issue. Maybe post some screenshots again of your new issue so i understand better, but i don't think i will be able to help you, especially if it requires changes of the lightsystem itself, since i don't have a big understanding of how this lightsystem works.
Title: Re: SFML Light System - Let There Be Light
Post by: Theshooter7 on May 05, 2014, 08:56:33 pm
So you want two equally big lightsystems stacked on eachother? Well i'm no expert but it's very hard to get any help about this light system since the developer seems to have abandoned this project.

I have never tried this and don't know of the issues with it but ofourse the front layer can't become brighter than the back one if that's your issue. Maybe post some screenshots again of your new issue so i understand better, but i don't think i will be able to help you, especially if it requires changes of the lightsystem itself, since i don't have a big understanding of how this lightsystem works.
This is what I was aiming for (using photoshop since I can't get it to work for real)
http://i.imgur.com/1uFZAMf.png (http://i.imgur.com/1uFZAMf.png)
(Note the contrast of the sky texture against how dark the tiles are)

I understand if this is outside of the scope of just a simple implementation detail. I do appreciate all your help so far and I can see that this is basically abandoned.
Title: Re: SFML Light System - Let There Be Light
Post by: zsbzsb on May 05, 2014, 09:04:12 pm
Not having used LTBL myself, but you could probably draw all your tiles [including the lighting] onto a render texture. Then draw that render texture on top of your sky background in the window.
Title: Re: SFML Light System - Let There Be Light
Post by: Voroz on May 05, 2014, 09:20:25 pm
If i understand correctly i think i would draw the background stuff first, then the background lightsystem and then foreground boxes etc and the lightsystem and set
m_renderLightOverHull = false;
if you want it like the image.
Title: Re: SFML Light System - Let There Be Light
Post by: Voroz on May 05, 2014, 10:05:53 pm
I have a problem myself btw. I'm trying to change the brightness of the shadows.

This does nothing to the black color which i have for shadows, but the lights works:
ls.m_ambientColor = sf::Color(50,50,50);
ls.m_useBloom = false;

If i change bloom to true then i can change the shadows color but then the lights wont work anymore.

edit: To be clear my game is completely black, i want to be able to make it less dark :).

edit2: Managed to make it work with bloom on now by setting intensity to over 1, but bloom doesn't work well at all so i need it off.
Title: Re: SFML Light System - Let There Be Light
Post by: Theshooter7 on May 06, 2014, 01:05:23 am
Not having used LTBL myself, but you could probably draw all your tiles [including the lighting] onto a render texture. Then draw that render texture on top of your sky background in the window.
I was going to do this but the problem is LTBL uses raw OpenGL, and thus bypasses any way to use the Render Textures with it. :(
If i understand correctly i think i would draw the background stuff first, then the background lightsystem and then foreground boxes etc and the lightsystem and set
m_renderLightOverHull = false;
if you want it like the image.
I've tried this, and the result is the same unfortunately. Although I have not provided a hull for the backdrop, so I'm not sure if I should experiment with that, and if so, where to start? Make the hull as big as the window? That doesn't seem right.
I have a problem myself btw. I'm trying to change the brightness of the shadows.

This does nothing to the black color which i have for shadows, but the lights works:
ls.m_ambientColor = sf::Color(50,50,50);
ls.m_useBloom = false;

If i change bloom to true then i can change the shadows color but then the lights wont work anymore.

edit: To be clear my game is completely black, i want to be able to make it less dark :).

edit2: Managed to make it work with bloom on now by setting intensity to over 1, but bloom doesn't work well at all so i need it off.
What if you used a different shadow fin image? Like, you take the existing one, modify it so the dark portion is lighter, and use that with your/a light system? I think that would in turn make the shadows themselves brighter and combined with ambient lighting will brighten things up overall.
Title: Re: SFML Light System - Let There Be Light
Post by: Voroz on May 06, 2014, 02:45:24 am
I've tried this, and the result is the same unfortunately. Although I have not provided a hull for the backdrop, so I'm not sure if I should experiment with that, and if so, where to start? Make the hull as big as the window? That doesn't seem right.
I don't think creating a hull would help you with this problem.

If your objective is to have your playing area in the middle and the background around that, then perhaps if you create a strong emissive light size and shape of your playing area in the background lightsystem. I read that those are shapeable and if you can also set the sharpness so there is no smoothing then that should give you the correct level of darkness in the center of your game after you draw the front lightsystem over it all.

What if you used a different shadow fin image? Like, you take the existing one, modify it so the dark portion is lighter, and use that with your/a light system? I think that would in turn make the shadows themselves brighter and combined with ambient lighting will brighten things up overall.
I guess the shadow fin is for the shadow part only, i was unsure what to call the dark area, but basically i want everything brighter, not just the shadow. I see in your screenshots it's not entirely black.

Basically m_ambientColor doesn't work at all with bloom turned off for me.
Title: Re: SFML Light System - Let There Be Light
Post by: Theshooter7 on May 06, 2014, 04:27:28 am
I guess the shadow fin is for the shadow part only, i was unsure what to call the dark area, but basically i want everything brighter, not just the shadow. I see in your screenshots it's not entirely black.

Basically m_ambientColor doesn't work at all with bloom turned off for me.
Oh. Yeah I have bloom enabled and m_ambientColor doesn't work for me with it off either. :/
Title: Re: SFML Light System - Let There Be Light
Post by: Voroz on May 06, 2014, 05:51:05 am
I guess the shadow fin is for the shadow part only, i was unsure what to call the dark area, but basically i want everything brighter, not just the shadow. I see in your screenshots it's not entirely black.

Basically m_ambientColor doesn't work at all with bloom turned off for me.
Oh. Yeah I have bloom enabled and m_ambientColor doesn't work for me with it off either. :/
Well i fixed it :).
In the parts where it says:
glBegin(GL_QUADS);
                        glVertex2f(0.0f, 0.0f);
                        glVertex2f(width, 0.0f);
                        glVertex2f(width, height);
                        glVertex2f(0.0f, height);
                glEnd();
in the lightsystem.cpp file, comment all that out. Then it works fine. He is clearing 2 times. First normally and then with the clearing shown above.
Title: Re: SFML Light System - Let There Be Light
Post by: Theshooter7 on May 06, 2014, 06:57:23 am
Well i fixed it :).
In the parts where it says:
glBegin(GL_QUADS);
                        glVertex2f(0.0f, 0.0f);
                        glVertex2f(width, 0.0f);
                        glVertex2f(width, height);
                        glVertex2f(0.0f, height);
                glEnd();
in the lightsystem.cpp file, comment all that out. Then it works fine. He is clearing 2 times. First normally and then with the clearing shown above.
Exact lines? There are several instances where this shows up. But good job!

[EDIT] Ok took another swing at the problem I'm having (didn't realize you could setActive() a render texture so that's a step forward), but I get odd results; the play area comes up pure white and the sky comes out gray. This is the code I've got:
Code: [Select]
sf::RenderTexture rt1, rt2;
        rt1.create(app->GetWindow()->getSize().x, app->GetWindow()->getSize().y);
        rt2.create(app->GetWindow()->getSize().x, app->GetWindow()->getSize().y);

                        /* ... */

                //app->GetWindow()->draw(app->GetBackdrop());
rt1.setActive();
rt1.clear();
rt1.draw(app->GetBackdrop());
world->GetBackgroundLightSystem()->RenderLights();
world->GetBackgroundLightSystem()->RenderLightTexture();
rt1.display();
sf::Sprite tempsprite1(rt1.getTexture());

//app->GetWindow()->draw(*world->GetLevel());
rt2.setActive();
rt2.clear();
rt2.draw(*world->GetLevel());
world->GetLightSystem()->RenderLights();
world->GetLightSystem()->RenderLightTexture();
rt2.display();
sf::Sprite tempsprite2(rt2.getTexture());

app->GetWindow()->setActive();

app->GetWindow()->draw(tempsprite1);
app->GetWindow()->draw(tempsprite2);

app->GetWindow()->display();

[EDIT 2] this code just gets me black render textures, as if nothing is being drawn to them for some reason.

Code: [Select]
//app->GetWindow()->draw(app->GetBackdrop());
rt1.setActive();
rt1.clear();
//rt1.draw(app->GetBackdrop());
world->GetBackgroundLightSystem()->RenderLights();
rt1.setActive();
world->GetBackgroundLightSystem()->RenderLightTexture();
rt1.resetGLStates();
rt1.display();
sf::Sprite tempsprite1(rt1.getTexture());

//app->GetWindow()->draw(*world->GetLevel());
rt2.setActive();
rt2.clear();
//rt2.draw(*world->GetLevel());
world->GetLightSystem()->RenderLights();
rt2.setActive();
world->GetLightSystem()->RenderLightTexture();
rt2.resetGLStates();
rt2.display();
sf::Sprite tempsprite2(rt2.getTexture());

app->GetWindow()->setActive();

app->GetWindow()->draw(app->GetBackdrop());
app->GetWindow()->draw(tempsprite1);
app->GetWindow()->draw(*world->GetLevel());
app->GetWindow()->draw(tempsprite2);

app->GetWindow()->display();
}
Title: Re: SFML Light System - Let There Be Light
Post by: StormWingDelta on May 07, 2014, 02:21:10 am
Wonder if this was ever ported to C#?  If so it would be nice to use. :)
Title: Re: SFML Light System - Let There Be Light
Post by: Estivo on May 08, 2014, 11:23:03 pm
        void LightSystem::RenderLights()
        {
                // So will switch to main render textures from SFML projection
                m_currentRenderTexture = cur_lightStatic;

                Vec2f viewCenter(m_viewAABB.GetCenter());
                Vec2f viewSize(m_viewAABB.GetDims());

                glDisable(GL_TEXTURE_2D);

                if(m_useBloom)
                {
                        // Clear the bloom texture
                        SwitchBloom();
                        glLoadIdentity();

            m_bloomTexture.clear(m_ambientColor);

            glColor4f(0.5f, 0.5f, 0.5f, 0.5f);

                        glBlendFunc(GL_ONE, GL_ZERO);

                        // Clear with quad, since glClear is not working for some reason... if results in very ugly artifacts
            /*glBegin(GL_QUADS);
                                glVertex2f(0.0f, 0.0f);
                                glVertex2f(viewSize.x, 0.0f);
                                glVertex2f(viewSize.x, viewSize.y);
                                glVertex2f(0.0f, viewSize.y);
                        glEnd();

            glColor4f(1.0f, 1.0f, 1.0f, 1.0f);*/

                }

#589 line
Title: Re: SFML Light System - Let There Be Light
Post by: Estivo on June 03, 2014, 09:52:50 am
std::vector<ltbl::ConvexHull* > test;

for(int i = 0; i < walls.size(); i ++)
    {
        test.push_back(new ltbl::ConvexHull() );
        test->loadShape("data/testShape.txt");
        test->calculateNormals();
        test->generateAABB();
        test->setWorldCenter(Vec2f(walls.getPosition().x + 32,720 - walls.getPosition().y + 32));
        ls.addConvexHull(test);
    }

You made some local variables and each loop pass alloc memory for new ConvexShape and leave in memory old.
Title: Re: SFML Light System - Let There Be Light
Post by: Epiplon on June 17, 2014, 05:56:13 am
Wonder if this was ever ported to C#?  If so it would be nice to use. :)
I thought about that. Started to make the port, but ran in some doubts about the C++ behaviour of certain methods.
Anyone have an idea how to translate QuadTreeNode::Partition to C# language? I don't know how to proceed with resize and the Create method. There are better ways to implement this and I want to set the m_hasChildren property to the right value in the end.
Title: Re: SFML Light System - Let There Be Light
Post by: Cyraxx on June 28, 2014, 03:41:09 pm
Hi,
I'm trying to use LTBL for my platformer but I encountered a wierd problem. When I was testing LTBL it was fine, I managed to implement it with a view following my character around and it worked perfectly.
Altough when I tried to implement it to my main game where we have a really wide map, and an sf::View with zoom centered on the player I just can get the LightSystem's view to be the same size as the window and to follow the player's movement. I tried multiple ways to fix it but it is never at the correct position. (mostly the Y axis)
Could anyone help me out with this one?  :-\
Title: Re: SFML Light System - Let There Be Light
Post by: eXpl0it3r on June 30, 2014, 01:08:31 pm
If you don't provide useful information, no one can help you. ;)
Title: Re: SFML Light System - Let There Be Light
Post by: Jabberwocky on November 19, 2014, 01:16:14 pm
*** (edit)  See update next post ***

Hi,

I have the LTBL sample compiled and running.  But the only effect I can see is the ambient light.

SFML version:  2.1
LTBL version:  1.5.1

Here's the program, which is copied directly from the Let there be Light manual.pdf
The only changes are:

Code: [Select]
#include <LTBL/Light/LightSystem.h>
#include <LTBL/Light/Light_Point.h>
#include <assert.h>
#include <SFML/Graphics.hpp>

int main(int argc, char* args[])
{
   sf::VideoMode vidMode;
   vidMode.width = 800;
   vidMode.height = 600;
   vidMode.bitsPerPixel = 32;
   assert(vidMode.isValid());
   sf::RenderWindow win;
   win.create(vidMode, "Let there be Light - Demo");

   // ---------------------- Background Image ---------------------
   sf::Texture backgroundImage;
   assert(backgroundImage.loadFromFile("D:/SFML/Let_There_Be_Light_v1.5.1/Let_There_Be_Light_v1.5/data/background.png"));
   // Tiling background
   backgroundImage.setRepeated(true);
   sf::Sprite backgroundSprite(backgroundImage);
   backgroundSprite.setTextureRect(sf::IntRect(0, 0, vidMode.width, vidMode.height));


   // --------------------- Light System Setup ---------------------
   ltbl::LightSystem ls(AABB(Vec2f(0.0f, 0.0f), Vec2f(static_cast<float>(vidMode.width), static_cast<float>(vidMode.height))), &win, "D:/SFML/Let_There_Be_Light_v1.5.1/Let_There_Be_Light_v1.5/data/lightFin.png", "D:/SFML/Let_There_Be_Light_v1.5.1/Let_There_Be_Light_v1.5/data/shaders/lightAttenuationShader.frag");
   ls.m_ambientColor = sf::Color(55,55,110);
   ls.SetView(win.getView());

   // Create a light
   ltbl::Light* testLight = new ltbl::Light_Point();
   testLight->m_center = Vec2f(200.0f, 200.0f);
   testLight->m_radius = 500.0f;
   testLight->m_size = 30.0f;
   testLight->CalculateAABB();
   ls.AddLight(testLight);

   // Create a hull by loading it from a file
   ltbl::ConvexHull* testHull = new ltbl::ConvexHull();
   if (!testHull->LoadShape("D:/SFML/Let_There_Be_Light_v1.5.1/Let_There_Be_Light_v1.5/data/testShape.txt"))
      abort();
   // Pre-calculate certain aspects
   testHull->CalculateNormals();
   testHull->CalculateAABB();
   testHull->SetWorldCenter(Vec2f(300.0f, 300.0f));
   ls.AddConvexHull(testHull);


   // ------------------------- Game Loop --------------------------
   sf::Event eventStructure;
   bool quit = false;
   while (!quit)
   {
      while (win.pollEvent(eventStructure))
      if (eventStructure.type == sf::Event::Closed)
      {
         quit = true;
         break;
      }
      sf::Vector2i mousePos = sf::Mouse::getPosition(win);
      // Update light
      testLight->SetCenter(Vec2f(static_cast<float>(mousePos.x), static_cast<float>(vidMode.height - mousePos.y)));
      win.clear();
      // Draw the background
      win.draw(backgroundSprite);
      // Calculate the lights
      ls.RenderLights();
      // Draw the lights
      ls.RenderLightTexture();
      win.display();
   }
   win.close();
}

Screenshot attached.
It is blue/purple because of the ambient colour setting.  But no light or shadow other than that appears.

Thanks for any help!
Title: Re: SFML Light System - Let There Be Light
Post by: Jabberwocky on November 20, 2014, 12:04:42 am
Update:  the LTBL source from here works with SFML 2.1:  https://github.com/hovatterz/light

Unfortunately it is an older version that ltbl 1.5.1, so is missing some key functionality like LightSystem::SetView.  Between this functional version in github, and the 1.5.1 source, hopefully I should be able to create a working version 1.5.1.

I understand it happens with open source projects, but it's a real shame that ltbl isn't maintained.  I am sure it would be very popular functionality for sfml users as some sort of official add-on.
Title: Re: SFML Light System - Let There Be Light
Post by: FRex on November 20, 2014, 11:21:22 am
Is there the source code of the original example exe from the 1.5.1 zip anywhere?
It works for me but the code from 2 posts above doesn't and I'm not sure if it's SFML or the above code causing that...
Title: Re: SFML Light System - Let There Be Light
Post by: Jabberwocky on November 20, 2014, 03:25:13 pm
Is there the source code of the original example exe from the 1.5.1 zip anywhere?

If there is, I never found it.

It works for me but the code from 2 posts above doesn't and I'm not sure if it's SFML or the above code causing that...

Weird.  As I noted above, I had the exact opposite problem.
What doesn't work with the github code?
How did you get the 1.5.1 code working with SFML 2.x?  (or are you using SFML 1.x?)
Title: Re: SFML Light System - Let There Be Light
Post by: FRex on November 20, 2014, 04:21:40 pm
No, no, you misunderstood me.
The 1.5.1 exe ('it' from second sentence) from the first post is working (via wine even).
With your example code for 1.5.1 (which is what I meant by code from '2 posts above') I too get just purple screen.
I made late SFML 2.1 and LTBL 1.5.1 work together the same way you did.
I didn't try the LTBL version from your github link at all.
So I'd say we have the same problem - 1.5.1 doesn't work with 2.1. Does the exe from the first post work for you too?
Title: Re: SFML Light System - Let There Be Light
Post by: Jabberwocky on November 20, 2014, 04:28:30 pm
So I'd say we have same problem - 1.5.1 doesn't work with 2.1.

Ahh right.  Yes, we both have the same problem.

Does the exe from the first post work for you too?
Yes it does.
Title: Re: SFML Light System - Let There Be Light
Post by: eXpl0it3r on November 20, 2014, 04:35:59 pm
Is this the example code (http://sourceforge.net/projects/letthebelight/files/Example.cpp/download)?

/*
        Let There Be Light
        Copyright (C) 2012 Eric Laukien

        This software is provided 'as-is', without any express or implied
        warranty.  In no event will the authors be held liable for any damages
        arising from the use of this software.

        Permission is granted to anyone to use this software for any purpose,
        including commercial applications, and to alter it and redistribute it
        freely, subject to the following restrictions:

        1. The origin of this software must not be misrepresented; you must not
                claim that you wrote the original software. If you use this software
                in a product, an acknowledgment in the product documentation would be
                appreciated but is not required.
        2. Altered source versions must be plainly marked as such, and must not be
                misrepresented as being the original software.
        3. This notice may not be removed or altered from any source distribution.
*/


#include <LTBL/Light/LightSystem.h>
#include <LTBL/Light/Light_Point.h>
#include <LTBL/Utils.h>

#include <assert.h>

#include <SFML/Graphics.hpp>

#include <sstream>

int main(int argc, char* args[])
{
        sf::VideoMode vidMode;
        vidMode.width = 800;
        vidMode.height = 600;
        vidMode.bitsPerPixel = 32;
        assert(vidMode.isValid());

        sf::RenderWindow win;
        win.create(vidMode, "Let there be Light - Demo");

        sf::View view;
        sf::Vector2u windowSize(win.getSize());
        view.setSize(sf::Vector2f(static_cast<float>(windowSize.x), static_cast<float>(windowSize.y)));
        view.setCenter(view.getSize() / 2.0f);

        // ---------------------- Background Image ---------------------

        sf::Texture backgroundImage;

        assert(backgroundImage.loadFromFile("data/background.png"));

        // Tiling background
        backgroundImage.setRepeated(true);

        sf::Sprite backgroundSprite(backgroundImage);
        backgroundSprite.setTextureRect(sf::IntRect(0, 0, vidMode.width * 2, vidMode.height * 2));
        backgroundSprite.setPosition(-400.0f, -400.0f);

        // --------------------- Light System Setup ---------------------

        ltbl::LightSystem ls(AABB(Vec2f(0.0f, 0.0f), Vec2f(static_cast<float>(vidMode.width), static_cast<float>(vidMode.height))), &win, "data/lightFin.png", "data/shaders/lightAttenuationShader.frag");

        // Create a light
        ltbl::Light_Point* testLight = new ltbl::Light_Point();
        testLight->m_intensity = 2.0f;
        testLight->m_center = Vec2f(200.0f, 200.0f);
        testLight->m_radius = 600.0f;
        testLight->m_size = 15.0f;
        testLight->m_spreadAngle = ltbl::pifTimes2;
        testLight->m_softSpreadAngle = 0.0f;
        testLight->CalculateAABB();

        testLight->m_bleed = 0.4f;
        testLight->m_linearizeFactor = 0.2f;

        ls.AddLight(testLight);

        testLight->SetAlwaysUpdate(true);

        // Create a light
        ltbl::Light_Point* testLight2 = new ltbl::Light_Point();
        testLight2->m_center = Vec2f(200.0f, 200.0f);
        testLight2->m_radius = 500.0f;
        testLight2->m_size = 30.0f;
        testLight2->m_color.r = 0.5f;
        testLight2->m_intensity = 1.5f;
        testLight2->m_spreadAngle = ltbl::pifTimes2;
        testLight2->m_softSpreadAngle = 0.0f;
        testLight2->CalculateAABB();

        ls.AddLight(testLight2);

        testLight2->SetAlwaysUpdate(false);

        // Create an emissive light
        ltbl::EmissiveLight* emissiveLight = new ltbl::EmissiveLight();

        sf::Texture text;

        if(!text.loadFromFile("data/emissive.png"))
                abort();

        emissiveLight->SetTexture(&text);

        emissiveLight->SetRotation(45.0f);

        emissiveLight->m_intensity = 1.3f;

        ls.AddEmissiveLight(emissiveLight);

        emissiveLight->SetCenter(Vec2f(500.0f, 500.0f));

        // Create a hull by loading it from a file
        ltbl::ConvexHull* testHull = new ltbl::ConvexHull();

        if(!testHull->LoadShape("data/testShape.txt"))
                abort();

        // Pre-calculate certain aspects
        testHull->CalculateNormals();
        testHull->CalculateAABB();

        testHull->SetWorldCenter(Vec2f(300.0f, 300.0f));

        testHull->m_renderLightOverHull = true;

        ls.AddConvexHull(testHull);

        // ------------------------- Game Loop --------------------------

        sf::Event eventStructure;

        bool quit = false;

        ls.m_useBloom = true;

        while(!quit)
        {
                while(win.pollEvent(eventStructure))
                        if(eventStructure.type == sf::Event::Closed)
                        {
                                quit = true;
                                break;
                        }

                if(sf::Keyboard::isKeyPressed(sf::Keyboard::A))
                        view.move(sf::Vector2f(-1.0f, 0.0f));
                else if(sf::Keyboard::isKeyPressed(sf::Keyboard::D))
                        view.move(sf::Vector2f(1.0f, 0.0f));

                if(sf::Keyboard::isKeyPressed(sf::Keyboard::W))
                        view.move(sf::Vector2f(0.0f, -1.0f));
                else if(sf::Keyboard::isKeyPressed(sf::Keyboard::S))
                        view.move(sf::Vector2f(0.0f, 1.0f));

                sf::Vector2i mousePos = sf::Mouse::getPosition(win);
                //testLight2->IncCenter(ltbl::Vec2f(0.1f, 0.0f));
                // Update light
                testLight->SetCenter(Vec2f(static_cast<float>(mousePos.x), static_cast<float>(vidMode.height) - static_cast<float>(mousePos.y)));

                win.clear();

                win.setView(view);
                ls.SetView(view);

                // Draw the background
                win.draw(backgroundSprite);

                // Calculate the lights
                ls.RenderLights();

                // Draw the lights
                ls.RenderLightTexture();

                //ls.DebugRender();

                win.display();
        }

        win.close();
}
Title: Re: SFML Light System - Let There Be Light
Post by: Jabberwocky on November 20, 2014, 11:58:32 pm
Thanks eXpl0it3r.
I'm not sure how I missed that before.

I don't think it solves the fundamental problem of the 1.5.1 LTBL / 2.x SFML compatibility issue.  But it should be helpful to myself and others who are trying to get things working.
Title: Re: SFML Light System - Let There Be Light
Post by: eXpl0it3r on November 22, 2014, 11:46:05 am
I've setup my own repository now. It contains all the "historical" source files from SourceForge and I've updated the code base to make it work with SFML 2.x. Besides making sure the CMake script works and the original example builds and runs fine, I haven't done much more on the code base, so if there were other issues, they'll still exist. Let me know which ones and I can fix them, or you can send in a PR.

Based off the LTBL 1.5.1 code base: https://github.com/eXpl0it3r/LTBL
Title: Re: SFML Light System - Let There Be Light
Post by: FRex on November 22, 2014, 05:03:28 pm
That's very nice of you. ;)
With no offence to lolz, the LTBL code feels very legacy/weird/unclear:
1. AABB is friend with itself.
2. Redundancy - example closes the window just before end of main, RenderLightTexture resets the blend func before calling resetGLStates etc.
3. Members are often public and named m_...
4. LightSystem calls std::abort if loading something fails.
5. Gratuitous use of GL, especially glBegin/glEnd.
6. Some of constructs (Vec2f and Point2i notably) are kind of useless, yes - lolz said he might want to reuse his quad tree but that would be better done by typedef in the headers instead of making a new incompatible class while this is meant to be an SFML library.

Do you intend to fix stuff like that?
Title: Re: SFML Light System - Let There Be Light
Post by: eXpl0it3r on November 22, 2014, 05:19:52 pm
Yeah, I've noticed some odd things as well. I'm not really sure, how far I'll go in cleaning things up. I think, I'll try to implement a better error handling that std::abort and fix some other C++ related things, but I don't know, if I'll be touching the OpenGL code. On one hand I've no experience with it and on the other it's legacy OpenGL, not something I want to learn and work with too much. ;)

But I guess if there are others making suggestions and helping out, I'll certainly try to fix things.
Title: Re: SFML Light System - Let There Be Light
Post by: FRex on November 22, 2014, 05:39:24 pm
When cloning your link I immediately get CRLF issue - working directory is not clear:
        modified:   bin/data/background.png
        modified:   bin/data/emissive.png
        modified:   bin/data/lightFin.png
        modified:   doc/manual.pdf
        modified:   license.txt
 
Can you just yourself convert license.txt to LF endings and remove the .gitattributes file?
(Or maybe I will make a pull request for it -- done.)
Title: Re: SFML Light System - Let There Be Light
Post by: Nexus on November 22, 2014, 06:19:18 pm
Keep in mind that there is also GLLight2D (http://en.sfml-dev.org/forums/index.php?topic=11939.0), the "sequel" to LTBL according to lolz123. GLLight2D seems to take a different approach rather than representing a refactored LTBL, but you might still take it into consideration when extending the work.
Title: Re: SFML Light System - Let There Be Light
Post by: Jabberwocky on November 23, 2014, 12:57:33 am
I've setup my own repository now. It contains all the "historical" source files from SourceForge and I've updated the code base to make it work with SFML 2.x. Besides making sure the CMake script works and the original example builds and runs fine, I haven't done much more on the code base, so if there were other issues, they'll still exist. Let me know which ones and I can fix them, or you can send in a PR.

Based off the LTBL 1.5.1 code base: https://github.com/eXpl0it3r/LTBL

THANK YOU!!!

Keep in mind that there is also GLLight2D (http://en.sfml-dev.org/forums/index.php?topic=11939.0), the "sequel" to LTBL according to lolz123. GLLight2D seems to take a different approach rather than representing a refactored LTBL, but you might still take it into consideration when extending the work.

LTBL provides significantly different functionality than GLLight2D. 
I can safely say that most users are looking for what LTBL offers, and not GLLight2D.

GLLight2D is a much more technical approach that allows things like global illumination.  But this is generally not the approach you want to take for a real-time application like a video game.  Especially a graphically "simple" 2D game which would otherwise run on lower level hardware.

Basically, it's just not worth the performance hit.

Quote from the GLLight2D post:

For now, GLLight2D is real time @60fps / resolution of 900x600 on a moderate rig and remains dynamic but looks grainy unless you let it sit there and accumulate samples for a bit. If this is unacceptable, you could then just use it for computing static lighting on level load (a 2D light map). That, or you could just use a blur shader and blur away the graininess (although it doesn't look quite as good then).

That performance is very likely unacceptable for many applications.  Remember, that's just GLLight2D, with no other physics/graphics/AI/game logic/etc running.  He specifically points out 900x600 (tiny) because anything larger is going to have even worse performance.

Lightmaps are generally unacceptable for any kind of dynamic lighting scenario, and add a significant complication to your content pipeline.

Title: Re: SFML Light System - Let There Be Light
Post by: lolz123 on November 29, 2014, 07:48:55 am
Hello everyone,

Due to the apparent demand for a 2D lighting system, I have started finally remaking LTBL, calling it LTBL2. With clean code, vastly superior performance, easier to use, CMake support, directional lights, dynamic quad tree root, and zoomable views that actually work. It also relies exclusively on SFML now. Furthermore, custom light types are super easy to do now (requires no code).

It should be done in 2 to 4 days. I will post here again when it goes up.

Edit: I forgot to add: It can render antumbras now. Here is an image of what that means :)

(http://upload.wikimedia.org/wikipedia/commons/2/2e/Diagram_of_umbra,_penumbra_%26_antumbra.png)
Title: AW: SFML Light System - Let There Be Light
Post by: eXpl0it3r on November 29, 2014, 11:47:58 am
Nice! Looking forward to it! :)
Title: Re: SFML Light System - Let There Be Light
Post by: Jabberwocky on November 29, 2014, 11:54:02 am
Hi lolz123 -

That's wonderful news!  Thanks for revisiting LTBL, and thanks again to eXpl0it3r for helping out as well.

A couple quick notes I have from working with LTBL1, in case it helps with LTBL2.

1.  Transparent hulls visible seam:
When you use transparent hulls, you can see a visible seam between the main umbra and the shadow fins.  I'm pretty sure I tracked this down to being a problem of the fin tris (created by function MaskShadow) overlapping with the main umbra created in that same function.  The overlap results in the dark seam due to rendering the overlapping alpha-blended geometry.

Transparent hulls are a pretty important feature, as without them the shadows appear completely black, rather than using the ambient color.  So I ended up using hull transparency to work around this.

2.  Static QuadTree crash:
There was a crash associated with the Static QuadTree related to these functions:
Code: [Select]
StaticQuadTree::StaticQuadTree(const AABB &rootRegion)
: m_created(false)
{
m_pRootNode.reset(new QuadTreeNode(rootRegion, 0));

m_created = true;
}

void StaticQuadTree::Create(const AABB &rootRegion)
{
m_pRootNode.reset(new QuadTreeNode(rootRegion, 0));

m_created = true;
}

There are two versions of the QuadTreeNode constructor.  The one used above does not pass in a QuadTree pointer.  So the root node of the StaticQuadTree has an uninitialized m_pQuadTree pointer.

This causes a crash later when Update is called on the StaticQuadTree's root node.

My solution was to change the above code to:

Code: [Select]
StaticQuadTree::StaticQuadTree(const AABB &rootRegion)
: m_created(false)
{
m_pRootNode.reset(new QuadTreeNode(rootRegion, 0, NULL, this));

m_created = true;
}

void StaticQuadTree::Create(const AABB &rootRegion)
{
m_pRootNode.reset(new QuadTreeNode(rootRegion, 0, NULL, this));

m_created = true;
}

3.  Offset shadows
If the view dims don't match the screen dims, the shadows are drawn in the wrong place.
This is solved by making this change in LightSystem::SetUp

Code: [Select]
void LightSystem::SetUp(const AABB &region)
{
// Create the quad trees
m_lightTree.Create(region);
m_hullTree.Create(region);
m_emissiveTree.Create(region);

// Base RT size off of window resolution
// *** CHANGE THIS LINE
// sf::Vector2u viewSizeui(m_pWin->getSize());

// *** TO THIS
sf::Vector2u viewSizeui;
// - adding 0.1f for float imprecision so we don't round down to the lower unsigned int.
viewSizeui.x = (unsigned int)(m_viewAABB.GetDims().x + 0.1f);
viewSizeui.y = (unsigned int)(m_viewAABB.GetDims().y + 0.1f);

For this to work, you must also set the m_viewAABB before setup is called.

4.  Window resizing support

LTBL doesn't handle window resizing.  It would need to hook into the resize event, and recreate the m_compositionTexture at the appropriate size.  I believe this is also necessary for view size changes.

______

I very much appreciate the work you've done with LTBL.
Title: Re: SFML Light System - Let There Be Light
Post by: Jabberwocky on November 29, 2014, 12:14:12 pm
I also have one other issue I've been trying to resolve.
I wanted to ask your advice, if you have time.

My game is top-down.  I want the shadows to draw on the ground, but not overtop other "tall" entities/sprites.

For example, let's say there are two trees by a light.  Currently, LTBL would draw the shadow of the first tree overtop the second tree.  I don't want it to.  I only want the shadow on the ground.

Conceptually, what I'm trying to do is this:

Render loop
1.  Draw the ground, and any "low" entities/sprites which should be shadowed
2.  Render LTBL's shadows
3.  Render any "tall" entities/sprites

That works... but not quite.
The ground properly receives shadows.  Good
The tall entities do not receive shadows.  Good
The tall entities are completely bright, and not affected by the light at all.  Bad.

I think what I need to do is something like this:
1.  Draw the ground, and any "low" entities/sprites which should be shadowed
2.  Render LTBL's light with shadows
3.  Activate a new fullscreen render texture, with a clear alpha transparency
4.  Render any "tall" entities/sprites on this 2nd fullscreen render texture
5.  Render LTBL again on the fullscreen render texture, disabling any hull shadows in this LTBL pass
6.  Render the fullscreen render texture onto the main render window.

This way, the tall entities receive light, but now shadow.
I certainly don't expect you to support this feature for me.  But does this seem like a reasonable approach for me to take?
Title: Re: SFML Light System - Let There Be Light
Post by: lolz123 on November 29, 2014, 07:19:09 pm
Hello Jabberwocky,

A similar feature already exists in the original LTBL. It will exist in LTBL2 as well.
On a hull, set m_renderLightOverHull to true. It will make hulls not become shadowed by their own shadow, but can receive shadows from other hulls.

This may not be quite what you are looking for, but I can add what you describe to LTBL2, it shouldn't be too hard.
Title: Re: SFML Light System - Let There Be Light
Post by: Jabberwocky on November 30, 2014, 12:47:47 am
On a hull, set m_renderLightOverHull to true. It will make hulls not become shadowed by their own shadow, but can receive shadows from other hulls.

Thanks lolz123.

Unfortunately that doesn't quite solve the problem, because the hull geometry is always an approximation of the graphics, and doesn't account for any sprite transparency.  In the tree example I gave, the tree canopy has lots of transparency (between the leaves) through which the shadow would need to display on the ground below.

Quote
I can add what you describe to LTBL2, it shouldn't be too hard.

I appreciate the offer!  I'll wait for LTBL2 and see what I can do with that.