Jump to content


Photo

Volumetric Lighting - Updated to v2.0!


  • Please log in to reply
50 replies to this topic

#1 Phantom107

Phantom107

    Engineer

  • GMC Member
  • 2598 posts
  • Version:GM:Studio

Posted 01 May 2010 - 10:50 AM

Volumetric Lighting

Hey there 3d users of the GMC,

I've been working on something special lately, and I think it's finally ready to show off.
Proudly I present to you: Volumetric Lighting.

So what is volumentric lighting?
Wikipedia states the following: "Volumetric lighting is a technique used in 3D computer graphics to add lighting effects to a rendered scene. It allows the viewer to see beams of light shining through the environment; seeing sunbeams streaming through an open window is an example of volumetric lighting, also known as God rays."

Why is the surface fix needed and how does it work?
The surface fix by amd24 is crucial in this technique. It allows me to render to a texture, which is exactly what I'm doing. In the step event, I make a seperate render of the scene, just like in my glow example. Except this time, everything in the scene will be black, except for 1 object: the light. The light will still use it's default texture.

My idea is that by scaling this 2d rendered "light-surface", you can create beams of light. But to do so, it needs to be scaled around a focus point. This focus point is the 3d position of the light. Problem is that we need to convert that 3d point to a 2d point on the screen, in order to do the scaling. That's where Yourself's conversion scripts come into play, which I made an example of here.

Using the resulting 2d focus point, it's possible to draw the "light-surface" a number of times with various scaling, around a certain 2d point on the screen. When drawing it on top of the normal scene render, light beams will come out really nicely.

Controls in the example:
  • Move around using WASD
  • Change height with QE
  • Look around with the mouse
Brand new version (v2.0)

- It now takes into account the angle you're looking at it, smoothly fading away!
- Because of the nature of how this works, the sun gets brighter when you look directly into it.
- In this new version the game only needs 1 render of the scene instead of 2, making this a lot more efficient!
- When the sun is outside the defined borders the effect will not be computed, saving performance.

Posted Image

Download link: right here!
File size: 0.51 MB

Old version (v1.0):

http://img153.imageshack.us/img153/8162/volumentric.png
http://img265.imageshack.us/img265/5086/volumentic2.png
http://host-a.net/Ph.....ing Fixed.zip

Enjoy!

- Phantom107

Edited by Phantom107, 09 December 2011 - 11:28 AM.

  • 1

#2 Advokara

Advokara

    GMC Member

  • New Member
  • 116 posts

Posted 01 May 2010 - 10:55 AM

FIRST POST!
... Ok I'll stop trolling now.

For an actual review
Cool! :D
I've seen some nice effects and this wins :(
  • 0

#3 RamboFox

RamboFox

    Tainted Fortune

  • New Member
  • 992 posts

Posted 01 May 2010 - 12:43 PM

Very, very nice! It's great to see the members of the Game Maker Community open sourcing/creating examples of cleverly coded engines.

And I'm sorry about that posts that I did in your other thread *deflates* I hope you can forgive me :D
  • 0

#4 Endorel

Endorel

    GMC Member

  • Banned Users
  • 191 posts

Posted 01 May 2010 - 02:24 PM

Hahaha, UGE is coming up with something even faster and smoother (oooo I can't wait), but still, this is pretty neat!
. . . Except not exactly hard to do.

Edited by Endorel, 01 May 2010 - 02:25 PM.


#5 Phantom107

Phantom107

    Engineer

  • GMC Member
  • 2598 posts
  • Version:GM:Studio

Posted 01 May 2010 - 02:28 PM

Hahaha, UGE is coming up with something even faster and smoother (oooo I can't wait)

It's just a matter of time before I figure out shader programming with OGRE. Then we'll see.

edit: In other words, you won't stand a chance if you don't use DirectX9 (or up) and GPU shaders.

Edited by Phantom107, 01 May 2010 - 02:34 PM.

  • 0

#6 Endorel

Endorel

    GMC Member

  • Banned Users
  • 191 posts

Posted 01 May 2010 - 02:37 PM

*removed by author*
Sorry!


Edited by Endorel, 01 May 2010 - 04:12 PM.


#7 Phantom107

Phantom107

    Engineer

  • GMC Member
  • 2598 posts
  • Version:GM:Studio

Posted 01 May 2010 - 02:41 PM

Don't mess up my topic, send a PM.
  • 0

#8 Endorel

Endorel

    GMC Member

  • Banned Users
  • 191 posts

Posted 01 May 2010 - 03:32 PM

Okay sorry! That was embarrassing!

#9 THE_GAME_EDITOR

THE_GAME_EDITOR

    GMC Member

  • GMC Member
  • 798 posts
  • Version:GM8.1

Posted 01 May 2010 - 04:12 PM

You pwned crysis it's graphics with full fps. :D

Edited by THE_GAME_EDITOR, 02 May 2010 - 08:57 AM.

  • 0

#10 Endorel

Endorel

    GMC Member

  • Banned Users
  • 191 posts

Posted 01 May 2010 - 04:16 PM

Not exactly, but we can still make some pretty neat things with properly working surfaces. I don't think anybody is going to program realtime radiosity or ambient occlusion.

#11 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • Global Moderators
  • 14393 posts
  • Version:GM:Studio

Posted 01 May 2010 - 04:23 PM

it's perty :D

it's not perfect<you stated> as it seems the light source and the casting is not adjusted properly to the 3d
  • 0

#12 Phantom107

Phantom107

    Engineer

  • GMC Member
  • 2598 posts
  • Version:GM:Studio

Posted 01 May 2010 - 10:55 PM

I don't think anybody is going to program realtime radiosity or ambient occlusion.

No need, I've got a tool to bake ambient occlusion in the texture itself. Looks great, runs fast. :D
  • 0

#13 Endorel

Endorel

    GMC Member

  • Banned Users
  • 191 posts

Posted 01 May 2010 - 11:02 PM

What we really need is multi-textures support.

#14 Phantom107

Phantom107

    Engineer

  • GMC Member
  • 2598 posts
  • Version:GM:Studio

Posted 01 May 2010 - 11:05 PM

What we really need is multi-textures support.

Use the surface fix to do it?
  • 0

#15 slayer 64

slayer 64

    GMC Member

  • GMC Member
  • 3278 posts
  • Version:GM8.1

Posted 02 May 2010 - 12:34 AM

wowzers!
  • 0

#16 Schyler

Schyler

    Noskcirderf Derf

  • GMC Member
  • 2445 posts
  • Version:GM8.1

Posted 02 May 2010 - 01:26 AM

So pretty... .__.
  • 0

#17 Robert3DG+

Robert3DG+

    VR Games

  • GMC Member
  • 1850 posts
  • Version:GM:Studio

Posted 02 May 2010 - 01:58 AM

Very cinematic looking. Great work Phantom107. I always get excited when I see you have a new thread.
  • 0

#18 Newly Discovered

Newly Discovered

    Harmonious Genius

  • New Member
  • 2467 posts
  • Version:GM8

Posted 02 May 2010 - 05:04 AM

Looks great Phantom! Another gorgeous effect added to my library! pretty fps
Next up?

Also, what tool are you talking about for AO?

Edited by Newly Discovered, 02 May 2010 - 05:06 AM.

  • 0

#19 THE_GAME_EDITOR

THE_GAME_EDITOR

    GMC Member

  • GMC Member
  • 798 posts
  • Version:GM8.1

Posted 02 May 2010 - 08:56 AM

We pwned crysis it's graphics with full fps.

You pwned it Phantom. :P
http://www.thefs.net...ee-sun-rays.jpg

Not exactly, but we can still make some pretty neat things with properly working surfaces. I don't think anybody is going to program realtime radiosity or ambient occlusion.

Everything is possible. :D
Nvidia say's: Ambient occlusion adds realism to scenes by reducing the intensity of ambient light on surfaces blocked by surrounding objects.

I think it would be possible.
It's just a surface after all.
  • 0

#20 Phantom107

Phantom107

    Engineer

  • GMC Member
  • 2598 posts
  • Version:GM:Studio

Posted 02 May 2010 - 09:32 AM

Looks great Phantom! Another gorgeous effect added to my library! pretty fps
Next up?

I think I'll make the heat haze next. I think that users with fire in their games will really like it.

I might take requests if I find them really interesting.

Also, what tool are you talking about for AO?

Check this out!

This program is straight up amazing. Besides nice AO, it's also capable of making normal maps and height maps which are useable in GM OGRE, but unfortunately not in GM-D3D.

Everything is possible. :D
Nvidia say's: Ambient occlusion adds realism to scenes by reducing the intensity of ambient light on surfaces blocked by surrounding objects.

I think it would be possible.
It's just a surface after all.

Sorry, but not in real-time. For this we would need access to the depth buffer, which compares pixel depth. I don't think there is any way to fake that using a surface.

edit: Here's an example of the generated ambient occlusion: http://img219.images...ntocclusion.png

edit 2:
------------------------------------------------------------------------------------------------------------------------------
I just noticed I made a bit of a mistake in the example. I accidentally put view_hview[0] on 800 instead of 600. That made the 3d-to-2d conversion go a bit off so the focus point wasn't very accurate. But that's fixed now. I changed the value and re-uploaded. The focus point is accurate now and the effect is as it should be.

If you have downloaded it already just change view_hview[0] in the room editor from 800 to 600. That should fix it.

Here's the fixed version anyway:
http://host-a.net/Ph.....ing Fixed.zip
------------------------------------------------------------------------------------------------------------------------------

Edited by Phantom107, 02 May 2010 - 05:24 PM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users