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

Author Topic: SFML Light System - Let There Be Light  (Read 257940 times)

0 Members and 5 Guests are viewing this topic.

lolz123

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
SFML Light System - Let There Be Light
« Reply #60 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.
Have you heard about the new Cray super computer?  It’s so fast, it executes an infinite loop in 6 seconds.

Alejandro

  • Newbie
  • *
  • Posts: 27
    • View Profile
SFML Light System - Let There Be Light
« Reply #61 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 :)

heishe

  • Full Member
  • ***
  • Posts: 121
    • View Profile
SFML Light System - Let There Be Light
« Reply #62 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.

lolz123

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
SFML Light System - Let There Be Light
« Reply #63 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:

Have you heard about the new Cray super computer?  It’s so fast, it executes an infinite loop in 6 seconds.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
SFML Light System - Let There Be Light
« Reply #64 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?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML Light System - Let There Be Light
« Reply #65 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.
Laurent Gomila - SFML developer

lolz123

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
SFML Light System - Let There Be Light
« Reply #66 on: March 20, 2012, 03:37:11 am »
New version (1.3) is out, with the new attenuation shader and light bloom!
Have you heard about the new Cray super computer?  It’s so fast, it executes an infinite loop in 6 seconds.

Ockonal

  • Jr. Member
  • **
  • Posts: 58
    • ICQ Messenger - 449909010
    • View Profile
    • WinCode
SFML Light System - Let There Be Light
« Reply #67 on: March 20, 2012, 01:45:00 pm »
Good job!
Developing 2d engine&game using: sfml, box2d, librocket, spark2, zoom&zoost, thor

Ockonal

  • Jr. Member
  • **
  • Posts: 58
    • ICQ Messenger - 449909010
    • View Profile
    • WinCode
SFML Light System - Let There Be Light
« Reply #68 on: March 20, 2012, 01:46:38 pm »
Btw, are there any ideas you want implement into project too?
Developing 2d engine&game using: sfml, box2d, librocket, spark2, zoom&zoost, thor

lolz123

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
SFML Light System - Let There Be Light
« Reply #69 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.
Have you heard about the new Cray super computer?  It’s so fast, it executes an infinite loop in 6 seconds.

jmcmorris

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Re: SFML Light System - Let There Be Light
« Reply #70 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.
  • Create a square hull for each tile.
  • Create a huge hull surrounding several connected tiles.
  • Go in and modify the light system so that it knows about my tiles and handles them separate from hulls.
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!

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
Re: SFML Light System - Let There Be Light
« Reply #71 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..

jmcmorris

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Re: SFML Light System - Let There Be Light
« Reply #72 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...
« Last Edit: March 26, 2012, 02:24:27 am by jmcmorris »

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
Re: SFML Light System - Let There Be Light
« Reply #73 on: March 26, 2012, 02:57:14 am »
I've done that either, its not the solution, there are some weird things in here..

jmcmorris

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Re: SFML Light System - Let There Be Light
« Reply #74 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...