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

Author Topic: GLLight2D  (Read 19769 times)

0 Members and 1 Guest are viewing this topic.

lolz123

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
GLLight2D
« on: June 21, 2013, 09:22:19 pm »
Hi,

The development of GLLight2D has resumed! Development might still be a bit slow (since I have a lot of other projects too  ;D), but I decided to work on GLLight2D (the "sequel" to Let There Be Light) some more during down times with my other projects. It has absolutely nothing in common with the original codebase I put on Github though, since it is now a 2D adaptation of my real-time path tracer, instead of just a cleaner and more generic version of LTBL.

Since it is a path tracer, it has full blown global illumination!

GitHub page: https://github.com/222464/GLLight2D

Here is an image of the progress so far:

« Last Edit: June 26, 2013, 02:23:25 am by lolz123 »
Have you heard about the new Cray super computer?  It’s so fast, it executes an infinite loop in 6 seconds.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Re: GLLight2D
« Reply #1 on: June 21, 2013, 09:40:28 pm »
Looks very nice! :)

I hope we get to try it soon.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

foobarbaz

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
Re: GLLight2D
« Reply #2 on: June 21, 2013, 11:19:15 pm »
Woot! I can't wait for this!

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: GLLight2D
« Reply #3 on: June 21, 2013, 11:37:04 pm »
Looks indeed very nice!

By the way, what does "GLLight2D" mean, does the "GL" refer to OpenGL? And I found "Let There Be Light" quite a fitting name :)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

lolz123

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
Re: GLLight2D
« Reply #4 on: June 22, 2013, 12:05:09 am »
@ Nexus: Yes, the GL refers to OpenGL. It is a bit too different from LTBL to have the same name I think, since it isn't merely an improvement over LTBL, but an entirely different way of doing things.

SFML is used mostly for windowing and input, all the rendering is done manually with OpenGL.

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).

Some technical details:

The scene is actually 3D with an orthographic projection. The scene is stored in a BSP tree, with all triangles stored in the leaves (duplicates are made if necessary). The tree, triangles, and material data are all loaded into OpenGL texture buffer objects for random access in the shader. Samples are accumulated in a GL_RGB32F FBO. Global illumination is rendered using a random Monte Carlo path sampling technique (that's where the graininess comes from).
Have you heard about the new Cray super computer?  It’s so fast, it executes an infinite loop in 6 seconds.

hayer

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Re: GLLight2D
« Reply #5 on: June 23, 2013, 12:00:48 am »
This seems very interesting, and looks awesome!

But why not just put it up on GitHub? I would love to put in some work. Even if it is just my own fork it would still be epic :)

lolz123

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
Re: GLLight2D
« Reply #6 on: June 23, 2013, 06:27:47 pm »
Here it is on Github. I still need to add CMake support.

https://github.com/222464/GLLight2D

I haven't gotten the release mode version to work yet, strange things going on  :P You can run it in debug if you have VS2012 though.
Have you heard about the new Cray super computer?  It’s so fast, it executes an infinite loop in 6 seconds.

panithadrum

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
    • Skyrpex@Github
    • Email
Re: GLLight2D
« Reply #7 on: June 25, 2013, 08:10:59 pm »
Hi lolz123!

Very impressive work! I wanted to implement 2D Pixel Perfect Shadows but now I want to test path tracing!

I see you calculate the rays in the fragment shader... could you explain the process a bit? I mean, how you send the data and so.

I also wonder if you could provide a Windows executable! Thanks
« Last Edit: June 25, 2013, 09:58:10 pm by panithadrum »

lolz123

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
Re: GLLight2D
« Reply #8 on: June 25, 2013, 08:29:16 pm »
@ panithadrum: A windows executable (release mode) will come as soon as I fix the strange possible compiler bug I have going on  :P. For now, you can compile it yourself by just linking to SFML2, OpenGL, GLU, and GLEW (and the Source).

The tracer stores all occluders (3D triangles), the acceleration structure, and material data in texture buffer objects (textures that get their data from buffer objects). This way, I have random access to the triangles and the acceleration structure in the shader.
I then simply cast rays against the scene with an orthographic projection, and sample in random directions depending on how diffuse a surface is to achieve global illumination. The tree traversal itself works by ray marching in steps defined by the leaf sizes. Each sampling step, it also calculates direct illumination from the light sources with a random shadow sampling step. Steps are integrated, and the result is averaged over time in a 32 bit float FBO to reduce noise.
Have you heard about the new Cray super computer?  It’s so fast, it executes an infinite loop in 6 seconds.

panithadrum

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
    • Skyrpex@Github
    • Email
Re: GLLight2D
« Reply #9 on: June 25, 2013, 11:49:45 pm »
Thank you for the explanation. I will look at your code tomorrow now I know what your code does :-).

By the way, I got it running with MinGW32 4.8, but nothing renders at all (just a black window). Any ideas what couldn't be working?
« Last Edit: June 25, 2013, 11:55:47 pm by panithadrum »

lolz123

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
Re: GLLight2D
« Reply #10 on: June 25, 2013, 11:57:35 pm »
Hmm, that's strange. Any errors in the console (like shader version errors perhaps)?
Have you heard about the new Cray super computer?  It’s so fast, it executes an infinite loop in 6 seconds.

panithadrum

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
    • Skyrpex@Github
    • Email
Re: GLLight2D
« Reply #11 on: June 26, 2013, 12:01:34 am »
Hmm, that's strange. Any errors in the console (like shader version errors perhaps)?
Nothing at all! Shader is loaded, uniform locations are found and the event loop works fine.

I will investigate a bit more tomorrow.

panithadrum

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
    • Skyrpex@Github
    • Email
Re: GLLight2D
« Reply #12 on: June 26, 2013, 08:35:50 pm »
I've tested it in Visual Studio 2012, Windows 8. I've noticed that you don't actually link to Glu32.lib so it doesn't compile as is.

When I fix that I see a black screen another time.

lolz123

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
Re: GLLight2D
« Reply #13 on: June 26, 2013, 08:47:50 pm »
Can you use gDEBugger to see if the FBO has something drawn to it? You can also try changing the format of the FBO. It is possible that your machine doesn't support GL_RGB32F, so try GL_RGB16F.
Also, did you run it in debug or release? I can't get release to work at all for some very bizarre reason.

Thank you for helping me get this to work on more than my own machine :)
Have you heard about the new Cray super computer?  It’s so fast, it executes an infinite loop in 6 seconds.

panithadrum

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
    • Skyrpex@Github
    • Email
Re: GLLight2D
« Reply #14 on: June 26, 2013, 09:05:04 pm »
I'm compiling in debug mode (I tried also linking to the debug SFML libraries). Just tried changing the format to GL_RGB16F in SamplerBuffer.cpp and TracerScene.cpp. No luck, I'm cursed!

My graphics card is a GTX295.

Edit: I'm installing gDEBugger, let's see how it works :P

 

anything