Thread: opengl Light rays

  1. #1
    Registered User
    Join Date
    Sep 2009
    Posts
    37

    opengl Light rays

    anyone knows a technique to make light rays visible?? or information about it?

  2. #2
    Amazingly beautiful user.
    Join Date
    Jul 2005
    Location
    If you knew I'd have to kill you
    Posts
    254
    What you're looking for is called volumetric light. I've never attempted it before, but there's lots of info on google. Looks like you might need some complex math with shaders.
    Programming Your Mom. http://www.dandongs.com/

  3. #3
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,739
    Of course volumetric light is much more realistic, but you could just add fog and blending and with a few calculations you'll have a basic light ray! Simple and easily-rendered, but not very realistic. It's up to you.

  4. #4
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,739
    Those i described are also known as static light rays because it's too much to recalculate them every frame, so you let them fixed at the position you want to appear as heavily lit or/and misty.

  5. #5
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Light rays can be done via world-oriented primitives. The rays will need a density and some spacial information to render correctly.

    Trying to do light rays in a shader is probably not going to yield the results you want. Post processing will probably not work b/c the image would have to be filtered many times to get a bright area to streak out enough to become a light ray. It is much easier to cast rays from the object in question to the light source creating the rays. If a certain percentage of the rays reach the light source you can then create a primitive along this ray and use colors to color the primitive to look like the color of the light source. Blending can be used to gradually blend out and/or alpha out the light ray primitive. Then post-processing can be applied to the final render which will create the bloom and glow you are looking for.

    I highly recommend you read Real Time Rendering as it explains the concept very well. It is a great book if not the single greatest book about rendering ever published. It is now in it's third edition and is worth every penny. You will be hard pressed to find graphics docs on the internet that do not in some way reference material either in the book or by the authors of the book.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Critique my lighting model.
    By psychopath in forum Game Programming
    Replies: 4
    Last Post: 08-12-2006, 06:23 PM
  2. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  3. geometry won't display!?
    By psychopath in forum Game Programming
    Replies: 17
    Last Post: 09-21-2004, 10:10 AM
  4. OpenGL .dll vs video card dll
    By Silvercord in forum Game Programming
    Replies: 14
    Last Post: 02-12-2003, 07:57 PM
  5. MISC questions about OpenGL
    By Silvercord in forum Game Programming
    Replies: 12
    Last Post: 01-25-2003, 04:20 PM