OpenGL 2D lighting using shaders

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
5,136
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Aug 8, 2011

Light halo is drawn using pixel shader, shadows are rendered on top as black quads. Rendered in FBO and saved as a texture. The process is repeated for each light, and then the textures get rendered on top of world geometry using blending.

Also, quadtree is rendered on top. It's also a part of the object oriented engine, and i forgot to turn it off during filming... :)

Written in C++ using OpenGL and GLSL.

Check out my blog : http://staniks.blogspot.com

Some people asked for shader, so there it is: http://www.mediafire.com/?8122n5zc5kef9p6

Category:

Science & Technology

Tags:

License:

Standard YouTube License

Link to this comment:

Share to:

Uploader Comments (geomancer120)

  • how would this perform on Android ?

  • @vlastos Not really sure. AFAIK FBOs are not really an option on most android devices, so im thinking something like directly rendering the lighting on top of the scene using blending.

  • You do something similar to us in the way that you bind a texture of the light. You don't seem to have any ambient light, though, and you render your entire world geometry as black. How is it that you can blend together the texture of the light together with the blackness? Do you bind the world geometry to a second texture or something like that? We're struggling with being able to have an ambient "darkness" that gets put into the lightmap texture. ie. (.2f, .2f, .2f, .2f). Thanks!

  • @RejechtedGaming Nope, i render lights to a FBO first (offscreen render). Then i render world geometry, and then for each light, i enable GL_BLEND with GL_ONE,GL_ONE (additive) mode, then render the light using pixel shader, and then shadow as well. There is no, in fact, ambient light - everything is black (0.0f, 0.0f, 0.0f). You can achieve that by simply setting the color of all objects to certain amount, or by drawing a fullscreen colored quad with blending, BEFORE the lights, after geometry.

see all

All Comments (11)

Sign In or Sign Up now to post a comment!
  • trippy

  • This is awesome great work.

  • @alexgrinkov Sure, i posted the link in the video description.

  • @geomancer120

    can you share the shader that writes the lights?

  • @idoopeynolan Thanks. It's both for fun and bigger project :) I plan to use it in a platform game.

Loading...
Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more