Jump to content


Photo

Volumetric Lighting - Updated to v2.0!


  • Please log in to reply
50 replies to this topic

#1 Phantom107

Phantom107

    Graphics Enthusiast

  • GMC Member
  • 2667 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.images...volumentric.png
http://img265.images...volumentic2.png
http://host-a.net/Ph.....ing Fixed.zip

Enjoy!

- Phantom107

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

  • 2

#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

    Graphics Enthusiast

  • GMC Member
  • 2667 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

    Graphics Enthusiast

  • GMC Member
  • 2667 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 Alvare

Alvare

    Allrounder

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

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

  • GMC Elder
  • 16059 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

    Graphics Enthusiast

  • GMC Member
  • 2667 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

    Graphics Enthusiast

  • GMC Member
  • 2667 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

    Slayer of gingers

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

Posted 02 May 2010 - 12:34 AM

wowzers!
  • 0

#16 Schyler

Schyler

    Noskcirderf Derf

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

Posted 02 May 2010 - 01:26 AM

So pretty... .__.
  • 0

#17 Robert3DG+

Robert3DG+

    Designer

  • GMC Member
  • 1925 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

  • GMC Member
  • 2475 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 Alvare

Alvare

    Allrounder

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

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

    Graphics Enthusiast

  • GMC Member
  • 2667 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

#21 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 16059 posts
  • Version:GM:Studio

Posted 02 May 2010 - 07:12 PM

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


Nice tool. You could convert vertices based d3d model to .obj. Well, people can use my tool for thatthen go to this tool. Great stuff

And your fix solves the problem I was trying to explain.
  • 0

#22 Phantom107

Phantom107

    Graphics Enthusiast

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

Posted 02 May 2010 - 07:21 PM

You could convert vertices based d3d model to .obj. Well, people can use my tool for that then go to this tool. Great stuff

Yes, I'm actually using GMModelFix to convert my OBJ model to d3d for my next example. Along with Ambient Occlusion. Stay tuned. :D
  • 0

#23 Desert Dog

Desert Dog

    GMC Member

  • GMC Elder
  • 6409 posts
  • Version:Unknown

Posted 02 May 2010 - 10:34 PM

Here's the fixed version anyway:

Do you want to remove the original download link in the first post then? I downloaded it, before reading the red.... :S :P

This effect's pretty cool looking, alright. Can't wait to see what else you come up with. :D
  • 0

#24 Robert3DG+

Robert3DG+

    Designer

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

Posted 03 May 2010 - 04:32 AM

Can't wait!

You can always count on Phantom107 to release some badass opensource stuff!
  • 0

#25 Alvare

Alvare

    Allrounder

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

Posted 03 May 2010 - 07:19 AM

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

Please, could you tell me what depth buffer is? :blink:
I can't find a simple explaination on internet. :D

..which compares pixel depth.. with what?
  • 0

#26 Newly Discovered

Newly Discovered

    Harmonious Genius

  • GMC Member
  • 2475 posts
  • Version:GM8

Posted 03 May 2010 - 09:23 AM

a depth buffer is like drawing everything white and setting a black fog, resulting in black and white and shown an obvious depth difference.
you'd then compare pixels to find similar depths, then apply a darkness?? to the AO surface??
comparing pixels like this in realtime with surfaces would be tremendously slow. pixel shaders are a ton faster as they retrieve pixel info directly from GPU? instead of having to render to a surface using an already slow game maker...

Edited by Newly Discovered, 03 May 2010 - 09:27 AM.

  • 0

#27 Alvare

Alvare

    Allrounder

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

Posted 03 May 2010 - 09:37 AM

a depth buffer is like drawing everything white and setting a black fog, resulting in black and white and shown an obvious depth difference.
you'd then compare pixels to find similar depths, then apply a darkness?? to the AO surface??
comparing pixels like this in realtime with surfaces would be tremendously slow. pixel shaders are a ton faster as they retrieve pixel info directly from GPU? instead of having to render to a surface using an already slow game maker...

Okay..

slow game maker

Yeah talking about slow gamemaker.. gamemaker doesn't react at the moment. :blink:
I just mirrored the sprite. That's all.
  • 0

#28 Phantom107

Phantom107

    Graphics Enthusiast

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

Posted 03 May 2010 - 10:09 AM

a depth buffer is like drawing everything white and setting a black fog, resulting in black and white and shown an obvious depth difference.
you'd then compare pixels to find similar depths, then apply a darkness?? to the AO surface??
comparing pixels like this in realtime with surfaces would be tremendously slow. pixel shaders are a ton faster as they retrieve pixel info directly from GPU? instead of having to render to a surface using an already slow game maker...

Because it will be so slow, I have used the pre-rendering tool (xNormal) to just bake the Ambient Occlusion to a fixed texture. That way it will barely cost anything extra to run in GM, but still give a great sense of visual enhancement. I know it isn't realtime, but you will be pleased with the results.
  • 0

#29 BattleRifle BR55

BattleRifle BR55

    Let Live

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

Posted 03 May 2010 - 10:27 AM

Great, yet another thing I can't (easily) try out from one of my favourite members here :blink:

Any chance we could get an .exe? (From anyone, at least?)
  • 0

#30 Phantom107

Phantom107

    Graphics Enthusiast

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

Posted 03 May 2010 - 10:34 AM

I replaced the non-fixed version with an EXE-version. Here you go:

http://host-a.net/Ph...ic Lighting.zip
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users