View Full Version : God Rays PostProcess
Hi everyone,
I'm currently trying to create a GodRays post process material.
To achieve this effect, i need to access the position of the light in ScreenSpace. Since it seems that I can't access it, I tried using the LensFlareSourceDistance, it seems to work, but only within a Lens Flare Actor.
Is there a way to access light coordinates by using the Custom node maybe ?
micahpharoh
11-08-2009, 01:49 PM
I'm not quite sure what you mean. Do you just mean a post process material for lightbeams?
DazJW
11-08-2009, 02:52 PM
Wouldn't it be easier to do god rays with a mesh like other light beams?
majkel
11-08-2009, 03:05 PM
I remember I've seen something likt you want to achieve in old trailer for Elveon, so it should be possible to do.
Yes a post process material to create dynamic light beams. I'll have a look at the code in the material editor and see if I can link this to my custom hlsl code in the Custom node.
Like DazJW said wouldn't it be easier to use a mesh with a light rays material applied to it? If you want it animated a texture panner (forgot the correct name) node in the material editor should work.
evilmrfrank
11-08-2009, 06:10 PM
I think he means light rays like crysis has. Brothers in Arms Hells Highway has dynamic light rays using lens flares but I'm pretty sure that was programmed special :P
Yup, the whole point is to have light rays that could work in any map, anywhere, without having to place manually light beam meshes. I'll keep this topic updated if I find a way to acheive this :)
Crozz
11-08-2009, 07:43 PM
Yup, the whole point is to have light rays that could work in any map, anywhere, without having to place manually light beam meshes. I'll keep this topic updated if I find a way to acheive this :)
Looking forward to that :)
CUBICcube
11-08-2009, 09:20 PM
I'll be watching this thread for sure, this would be awesome.
chrustec
11-08-2009, 11:33 PM
Take a look in the DM-Deck map - near the two lifts that take the player to the rocket launcher (redeemer in full UT3) the back wall as two columns of broken windows with God Rays (light beams) coming through them - maybe that will help you with setting up this effect.
micahpharoh
11-08-2009, 11:40 PM
Subscribed for instant email notifications :)
now there's people counting on you, don't let us down ;)
micahpharoh
11-08-2009, 11:40 PM
Take a look in the DM-Deck map - near the two lifts that take the player to the rocket launcher (redeemer in full UT3) the back wall as two columns of broken windows with God Rays (light beams) coming through them - maybe that will help you with setting up this effect.
nope, just light cones aka static meshes made to look like volumetric lights.
chrustec
11-08-2009, 11:57 PM
hmmm Ok Ill take another look tonight when I get home from work. If memory serves its done off of an emitter. At least in that map anyway - it MIGHT be a mesh emitter but cant look at it atm so I will double check tonight
Done !
I will still tweak it a little and add a lot more samples to make it smoother.
http://pix.wefrag.com/i/2/8/9/a/4/77864fa5ac6e220e82a50895df3cffb.jpg
micahpharoh
11-09-2009, 06:24 PM
WOW! Not quite there, IMO, but getting very close. Please tell us how you did it :)
I will post the UPK when I'm happy with the look and optimization :)
Piranhi
11-09-2009, 07:25 PM
Good work and thanks Jerc.
Brexer
11-09-2009, 07:30 PM
This is quite nice, while yes, it needs a tid bit more work, i would also love to see how you did this (purely out of tech interest) :).
Here is a new version, I added some parameters that can be tweaked from a material instance :
- Light Coordinates
- Samples
- Intensity
- Athmosphere color
- Decay
http://pix.wefrag.com/i/4/b/1/b/9/78039eacf2383c1d5e8a20ab1e542a4.jpg
Kaldrick
11-10-2009, 08:56 AM
Will you submit a tutorial how to do this? ;]
evilmrfrank
11-10-2009, 09:13 AM
Nice :) How much does this hurt the FPS? When can we expect to use this effect ourselves? :D
The framerate seems to stabilize around 40 fps instead of 40-60 fps without the post effect material.
I will release it when I'm happy with it ;) , I still have glitches when the light source is behind the player.
Piranhi
11-10-2009, 11:27 AM
Looking even better, keep it up!
jeffro11
11-10-2009, 01:16 PM
This is fantastic, great work!
micahpharoh
11-10-2009, 02:32 PM
fantasitc! When you get it to how you want it make sure you post a video on youtube so we can see it in motion :D
Froyok
11-10-2009, 05:34 PM
fantasitc! When you get it to how you want it make sure you post a video on youtube so we can see it in motion :D
Totally agree, a video, a code/material, and you will make many of happy ! :D
Lost Haven
11-10-2009, 06:53 PM
That is awesome , what cry engine never heard of it lol . Man that is gorgeous wow.
Allar
11-10-2009, 07:02 PM
That is awesome , what cry engine never heard of it lol . Man that is gorgeous wow.
Yo dawg
http://media.moddb.com/cache/images/mods/1/13/12988/thumb_620x2000/ScreenShot0231.1.jpg
FarCry1...
There are some config settings in crysis you can change to enable god rays, just forget which ones they are...
Indeed very impressive! Great work, Jerc!
Will follow this thread and not very surprisingly we're also interested in these kinds of effects for Sanctum!
Keep up the great work!
eh_gm
11-18-2009, 03:27 PM
where are you Jerc?
we want to see your final result and how you did that.
I didn't have much time to work on the post process this week, I'm still having trouble with Z-axis and when the light is behind the player.
I'm also trying to figure out how to downsample the ScreenDepth so I would need less samples for a better result.
Be sure I will ipdate this topic as soon as I made some progress :)
eh_gm
11-19-2009, 07:16 AM
thanks Jerc,Keep it trying.
katana2665
11-19-2009, 08:13 AM
That's a nice effect you came up with. I think the angle needs to be a bit sharper or there needs to be more stuff in the way to break up those rays, but the intensity was blinding, so you did a great job...congratz.
With some research I found that most of the issues I have are common to all light beams implementations and it's just a matter of setting the parameters right so the player doesn't see the glitches ;)
Right now I sample the SceneDepth multiple times to create my "rays", I will try to find a way to use a cheaper pass like a color pass but displaying only the sky with black instead of the foreground meshes, that would be ideal.
I don't know if it makes much sense to you guys without seeing the code ^^
micahpharoh
11-19-2009, 11:55 AM
I'd settle for even the expensive way just so I could get it into some of my machinimas/cinematics.
eosteric
11-19-2009, 04:52 PM
judging from the pictures you've posted it doesn't look like you know what god-rays is
God rays, sun beams, crepuscular rays, call it volumetric light scattering if you want, it's basically the same effect.
Moose_Head!
11-19-2009, 08:04 PM
judging from the pictures you've posted it doesn't look like you know what god-rays is
Judging from the words you have posted, it doesn't appear that you know what grammar is.
...
Great work, Jerc!
Piranhi
11-19-2009, 08:07 PM
Crepuscular rays, in atmospheric optics are rays of sunlight that appear to radiate from a single point in the sky. These rays, which stream through gaps in clouds or between other objects, are columns of sunlit air separated by darker cloud-shadowed regions. The name comes from their frequent occurrences during crepuscular hours (those around dawn and dusk), when the contrasts between light and dark are the most obvious.
http://upload.wikimedia.org/wikipedia/commons/thumb/e/e1/Lunar_Crepuscular_Rays_2.jpg/800px-Lunar_Crepuscular_Rays_2.jpg
Seems like you don't know what God Rays are, Eosteric.
eosteric
11-19-2009, 08:31 PM
the description god rays have commonly been reserved for the beams of light coming through clouds
volumetric lighting is a more general term, when hearing god rays most people think about the lights breaking through clouds
but still, looking at the images I don't see much volumetric lighting either, just looks more like blurred and overexposed
ambershee
11-19-2009, 08:36 PM
UDK does not have volumetric lighting.
sueds
11-19-2009, 11:55 PM
nice work Jerc. The screen look kind a nice even if it's a tricky not volumetric light or so. 3d light isn't not physically processed ( except for some tools) so I don't know the point of criticize the work of jerc since as a 3d developers you need to use trick all the time so yeah, even if it's not a real volumetric light like in Crysis as long as they look cool why bother?
It's the same trick in Crysis and in most games using that kind of effect, it's a simple but expensive post process. I achieved it in UDK by using a custom node in my material
By looking closely at some Crysis screenshots during my search for answer to my problems, I saw the same limitations and artifacts.
In the following screenshot, the light beam continues on the right part of the ocean, which is completely inacurate and physically illogical. This is one of the flaws of this method.
http://pix.wefrag.com/i/0/c/b/c/2/808626e2da51efc94e8a2879c216fa8.jpg
Here is a snapshot of the shader :
http://pix.wefrag.com/i/e/a/4/6/6/8085670f6dd0f81d614db9907c87e6d.jpg
I will try to find some time to create a simple map with a sun and trees so the effect is more visible.
Here is a bettr screenshot, you can even see the light icon sprite impacting the light going through the windows.
http://pix.wefrag.com/i/b/4/1/9/e/8087ed0bbf7022343a834ad7e77c380.jpg
Piranhi
11-20-2009, 05:38 AM
http://pix.wefrag.com/i/0/c/b/c/2/808626e2da51efc94e8a2879c216fa8.jpg
Damn nice work!
Brexer
11-20-2009, 08:11 AM
It's the same trick in Crysis and in most games using that kind of effect, it's a simple but expensive post process. I achieved it in UDK by using a custom node in my material
By looking closely at some Crysis screenshots during my search for answer to my problems, I saw the same limitations and artifacts.
In the following screenshot, the light beam continues on the right part of the ocean, which is completely inacurate and physically illogical. This is one of the flaws of this method.
I will try to find some time to create a simple map with a sun and trees so the effect is more visible.
Pretty awesome, looking forward for you to be happy with it, and to share the upk :)
Btw, whats the amount of draw calls so far (at your current stage) ?
Xendance
11-20-2009, 09:14 AM
Could you please post a bigger picture of the material? I'd like to replicate it.
weephun
11-20-2009, 05:14 PM
UDK does not have volumetric lighting.
http://udn.epicgames.com/Three/VolumetricLightingGuide.html
Elude
11-20-2009, 07:07 PM
What are those last two boxes with the addition/subtraction numbers, I cant seem to find anything in the material editor to add such numbers.
micahpharoh
11-20-2009, 08:07 PM
when you get it done, it'd be nice if you could put it up for download, or at least make an in depth tutorial telling us what each node does. Looking nice, btw.
docmorbid
11-20-2009, 09:02 PM
Great work, yep, in games development it's all about trickery to achieve the desired effect.
fallingbrickwork
11-21-2009, 02:30 PM
Pretty please, with some nice looking bells affectionately placed, could you release this to the community when complete.... I'm just looking at my warehouse scene and if i squint enough i can see your godrays coming through my windows ;)
Great work!,
Matt.
AreDub3D
11-21-2009, 06:11 PM
Wow — that's the most impressive thing I've seen done with UDK so far. Way to go, Jerc.
I'd like to join the throngs and ask for a tutorial on this akin to Horences' water shader tutorial. I have a steamy jungle level going that could really "shine" with something like this.
Killer diller.
KazeoHin
11-21-2009, 06:40 PM
I was able to do this whilst working on my graphics-intensive map, but the project never made it in-game.
http://sites.google.com/site/kazeohin/HumidLight2.jpg
This is an image from my discontinued WIP map (it was made in UT3, not UDK) I can share with you how it works, if you'dd like. But it needs code.
darthviper107
11-22-2009, 02:48 AM
Share what you have, it'd be useful.
micahpharoh
11-22-2009, 02:51 AM
Maybe you can team up to make an optimized version
Piranhi
11-22-2009, 08:31 AM
<3 KazeoHin. I'm still trying to replicate your water material.
DJorKID
11-25-2009, 01:49 PM
damn that looks so nice Jerc :P and that tropical stuff looks good two
LordAero
11-25-2009, 07:26 PM
For some reason i can't see the screenshots... but if i have to choose... i'd ask for a Tut on how to do it... i suppose learning is better...
<3 KazeoHin. I'm still trying to replicate your water material.
That sounded like "post a tutorial !!! i'm going insane !!!"... if so, i'll add to it... you can never have enough water materials...
Piranhi
11-25-2009, 08:09 PM
haha, tutorials are nice, but you learn more by trying yourself. I do want to know how he gives his water "waves" though. It can't be a flat mesh or BSP, I'm guessing it's a cloth material, but I haven't tried that yet.
If you don't know what I'm talking about by the way, it's here:
http://www.moddb.com/mods/warm-gun/videos/warm-gun-effects1
TheAgent
11-27-2009, 01:09 PM
any Updates?
ambershee
11-27-2009, 01:29 PM
http://udn.epicgames.com/Three/VolumetricLightingGuide.html
That's not volumetric lighting. That's static meshes with a 'lighting' effect.
eosteric
11-27-2009, 03:39 PM
How else would you think volumetric lighting was done in games?
It's always faked in one way or another. Everything in games is.
musichopper
11-27-2009, 04:11 PM
wrong!! My games produce real life volumetric light!!! I can reach right into the screen and my own physical hand casts a shadow in mid air with rays of light!!!! LOL
Well, once we are able to use raytracing like back in the old days there will be great lighting but instead of a an 8 hour rendering time on one scene it will be live and amazing!
ambershee
11-28-2009, 12:04 PM
How else would you think volumetric lighting was done in games?
It's always faked in one way or another. Everything in games is.
Of course the effect is faked - but there's an enormous difference between lighting and placed static meshes. Manually placed static meshes do not constitute 'volumetric lighting'.
Some games do have volumetric lighting, usually by tracing out from the near plane of the camera, sampling, and comparing to shadow values, either mapped, or in another buffer. Unreal 3 does not do this.
Brexer
11-28-2009, 12:13 PM
So where you at now Jerc, managed those things you talking about needing to fix ?
Any new screenshots on process ? :)
KazeoHin
11-29-2009, 08:14 AM
The effect I made was using the depth buffer, sampled many times and increased in size with each sample (zoomed in) this creates a 'coming closer' effect. However this approach needs code to send floats to the shader telling it where to place the 'epicenter' of the effect. This is ultimately why such an approach is unlikely to work in UDK: the CPU would be processing the clumsy game-code in an attempt to produce a real-time result. It could work in theory but I have yet to see it.
The effect I made was using the depth buffer, sampled many times and increased in size with each sample (zoomed in) this creates a 'coming closer' effect. However this approach needs code to send floats to the shader telling it where to place the 'epicenter' of the effect. This is ultimately why such an approach is unlikely to work in UDK: the CPU would be processing the clumsy game-code in an attempt to produce a real-time result. It could work in theory but I have yet to see it.
This is almost exactly how I did it, by writing the code in the shader custom node.
Here is a UPK file with the shader in it's current state. and a new Screenshot :)
Grab the file HERE ! (http://raisingfallen.free.fr/LightScattering.upk)
All you have to do to use it is create a material effect in your post process shader and plug this shader in it.
You must also set the main light world position in the shader itself.
(you can find i in the "movement" properties tab in your light or lens flare properties).
http://pix.wefrag.com/i/f/2/d/9/9/84319f49a3619d725be3e0633909fd6.jpg
katana2665
11-29-2009, 10:56 AM
Great looking effect and thanks for sharing the file
DJorKID
11-29-2009, 11:22 AM
could you explain it more clearly for me i really dont know how to do it :(
Piranhi
11-29-2009, 12:08 PM
Cheers, Jerc.
micahpharoh
11-29-2009, 05:52 PM
That's great, but I'm really confused on how to actually use it. I created a postprocesschain, but I don't know if that's what you mean, or what.
KazeoHin
11-29-2009, 05:55 PM
This is almost exactly how I did it, by writing the code in the shader custom node.
Here is a UPK file with the shader in it's current state. and a new Screenshot :)
Grab the file HERE ! (http://raisingfallen.free.fr/LightScattering.upk)
All you have to do to use it is create a material effect in your post process shader and plug this shader in it.
You must also set the main light world position in the shader itself.
(you can find i in the "movement" properties tab in your light or lens flare properties).
My hero!
ten chars
Brexer
11-29-2009, 06:10 PM
Had a look at it, looking good, though a few ideas...
Light location, should be taken from scene, having to manually set it pr map is not that good.
If you stand with your back, looking at a object, it looks like its casting the rays forward (or is it just me ?)
Still though, excellent and thanks for your hard work on this, and im awere your still working on it, and so far, performance seems excellent.
TheAgent
11-29-2009, 06:40 PM
The explanation on how to use it should be a little more detailed.
theron
11-29-2009, 09:05 PM
Could someone make a tutorial or something pls... It doesn't work for me... :(
TheAgent
11-30-2009, 08:31 PM
bump anyone?
micahpharoh
11-30-2009, 09:07 PM
Jerc? Are you still alive?
Yep, I will post a step by step tutorial today, as soon as my boss isn't around ;)
Piranhi
12-01-2009, 08:22 AM
Where shall I send the box of chocolates, Jerc?
ambershee
12-01-2009, 08:43 AM
Yep, I will post a step by step tutorial today, as soon as my boss isn't around ;)
I used to describe tutorial-writing-at-work as 'a vital step in better understanding your own work' - and for anyone wishing to modify it in future, of course ;)
Here it is. You should be able to apply quickly the PostProcess by following these steps :)
http://pix.wefrag.com/i/4/1/3/4/7/th60085517415ab35deb887d5c1630d6424f.jpg (http://pix.wefrag.com/pages/see.php?i=8551)
http://pix.wefrag.com/i/a/d/1/a/f/th6008548fb632fc4792d1d979aa498c4063.jpg (http://pix.wefrag.com/pages/see.php?i=8548)
http://pix.wefrag.com/i/9/d/7/e/e/th6008549e834fdf914562309f16b3710be9.jpg (http://pix.wefrag.com/pages/see.php?i=8549)
http://pix.wefrag.com/i/5/b/e/8/a/th6008550adbf6d6567a4e439546c8b2b296.jpg (http://pix.wefrag.com/pages/see.php?i=8550)
Piranhi
12-01-2009, 03:02 PM
Cheers again, Jerc.
TheAgent
12-01-2009, 03:17 PM
Thank you very much:D
Piranhi
12-01-2009, 03:24 PM
Somethings playing up in mine, I got his effect.
http://img130.imageshack.us/img130/3290/35952930.jpg
Edit: I'm using a Dominant Directional Light btw
Edit2: It looks fine in the editor though!
TheAgent
12-01-2009, 03:36 PM
Mine isnt working im just getting a foggy effect
fritzmonkey
12-01-2009, 03:54 PM
I don't think he posted the code for that custom node.
TheAgent
12-01-2009, 04:10 PM
Maybe not , i just get a sqare foggy looking box in game yellowish or so, in the editor i get messed up streaks
Piranhi
12-01-2009, 04:13 PM
The code is already in the CustomNode as far as I'm aware.
Elude
12-01-2009, 04:13 PM
Lol I'm not even getting any effect, I'm just getting a black screen.
TheAgent
12-01-2009, 06:29 PM
it works but it doesnt look good when all u have is terrain
Keep in mind that this is in fact simulating light going through atmosphere, so if you don't have anything in your map but a simple terrain or bsp box, all you will see is fog.
You will need a skybox and some objects in the foreground to see the effect properly.
Piranhi, there might be a conflict between my post process and the DoF effect, I only tested it without DoF.
TheAgent
12-02-2009, 11:05 AM
Cool ill wait for ur full release version :]
LordAero
12-02-2009, 11:11 PM
haha, tutorials are nice, but you learn more by trying yourself. I do want to know how he gives his water "waves" though. It can't be a flat mesh or BSP, I'm guessing it's a cloth material, but I haven't tried that yet.
If you don't know what I'm talking about by the way, it's here:
http://www.moddb.com/mods/warm-gun/videos/warm-gun-effects1
Can't see it... must be my bloody 3g connection...
I just depend on tut's right now... i'm clueless about everything... i'm merely creating a scene with stuff i've modeled in blender... and just got a single mesh with two materials on it to "kind of" show properly... say kind of because i get an "only uses unlit materials" error when building lights...
BTW what mat are you using for water ?
@Jerc: Thanks a whole lot for sharing and sorry for the off topic !
Sheepdog
12-16-2009, 03:15 PM
I tried editing the default Post Process Effect, which worked fine, but it won't let me save changes to it.
I've been trying to figure out how to get a custom Post Process Effect to actually work in the game, but at this point I'm clueless. Can anyone help me out?
V8matey
01-25-2010, 10:07 AM
Dunno if its any help or if its in anyones interest but Unreal 1 the first game had inbuilt volumetrics. you can even see it ingame in the first level in the ship in the tunnels etc. a green volumetrics if i recall.
Great job tho Jerc im curious does your God rays work with speedtree?
RoelBartstra
01-26-2010, 11:42 AM
That looks amazing :)
ZixXer
01-26-2010, 04:06 PM
looks realy cool!!
leviatan1001
01-27-2010, 03:05 AM
Well, its a nice trying, but it doesnt work properly. Sometimes it work, sometimes not and when its working, it looks like this:
http://img200.imageshack.us/img200/9489/godrays.th.jpg (http://img200.imageshack.us/img200/9489/godrays.jpg)
Also, it doesnt work ingame for me. Just in editor.
Jackson311
01-27-2010, 04:42 AM
Wow, this looks really good Jerc, this is an effect I've wanted to be able to use in UE3 for ages, if only i could get it to work as you have in your screencaptures :(
similar to the post above my effect isnt really working, see example:
http://dl.dropbox.com/u/1542202/failrays.jpg
i tried changing the effect to be rendered in 'foreground' instead of 'post process', that didn't help, it seems as if the entire effect has been offset from the world or it's scaled wrong or something, i may need to post a video for you to fully understand what i mean.
PS; i copied the light co-ordinates strait from the movement tab of my main scene light just like in your tutorial
Anyway, I would reeeally appreciate you're help in getting this working as it's meant to, thanks.
Sheepdog
02-07-2010, 09:01 PM
It works in editor perfectly... but becomes horribly misaligned when I play it in-game.
In editor, working fine: (and super exaggerated to make it easy to see)
http://i638.photobucket.com/albums/uu109/FireproofAshes/GR_InEditor.jpg
...and, after I go in-game:
http://i638.photobucket.com/albums/uu109/FireproofAshes/GR_InGame.jpg
...
Has anyone been able to make this work? There's too much potential here to let a stupid issue like this ruin it.
micahpharoh
02-08-2010, 12:30 AM
I just saw "God Rays" in the Dark Void Demo the other day, which was also made in UE3. It's defiantly possible, it's just going to take some more work.
jheaton
03-20-2010, 12:31 PM
I just finished Dark Void, so I too have seen what this engine can do... It's realistic enough that it gets annoying. Making it hard to see aerial enemies, etc. Undoubtedly the intended effect. The point is that god-rays are very possible, and Jerc seems to be on to the method to handle them.. Three cheers for Jerc.
BloodReyvyn
03-21-2010, 06:26 AM
This is a really awesome effect and will be doubly so when it's working alright.
Currently, it doesn't work at all for me. I still just get fog even with plenty in the foreground and a nice skydome.
Still, awesome. Subscribed to this thread.
I didn't think that UE/UDK could do volumetrics, even faking it. This really goes to show that with some creativity and necessity you can almost always find a way to do something that you want to do.
ambershee
03-21-2010, 06:40 AM
Volumetric light beams are commonly just a post process effect - there's nothing really stopping it from working in Unreal. A proper, native implementation would be nice though. I'm surprised it doesn't exist.
BloodReyvyn
04-16-2010, 07:15 AM
Wow, no progress/updates on this front? Was looking forward to trying this out if it ever got up and running, assuming it was shared info of course.
darthviper107
04-16-2010, 09:01 AM
I was taking a look through some of the files in Dark Void--I'm pretty sure they setup their volumetric lighting through a similar method so there must be some way to get it right
micahpharoh
04-16-2010, 05:02 PM
I saw them use dynamic volumetric lighting in an old Gears of War 2 commercial the other day. I was astounded that epic has apparently made the effect before but wont share it with us.
http://www.youtube.com/watch?v=FL_ZjJgbDmc
about 28 second in
ambershee
04-16-2010, 05:09 PM
If they had the effect, I'd expect they'd have used it in the game. I expect what you see for a split second in the advert is the result of post-render editing.
micahpharoh
04-16-2010, 06:24 PM
If they had the effect, I'd expect they'd have used it in the game. I expect what you see for a split second in the advert is the result of post-render editing.
That's very possible. But it's also possible that the did it in engine and decided it wouldn't be worth the power needed to do it in game. Performance wise, that is. The game chugs pretty good sometimes just keeping the fps at 30.
Dreamcube017
04-17-2010, 03:22 AM
Wow I love this effect... I've yet to try it, but I'll take some things and throw something together to see what it looks like and I hope it works.
It'd be cool if it was updated though.
Also some water shaders would be good and would take some legwork out of making them.
DannRees
04-17-2010, 06:00 AM
Not sure if this is needed anymore but here it is; World Space to Screen Space
You'll have to convert the pixel value into a point on the near viewing plane (which represents the screen), then cast a ray from the viewpoint (camera position) through that point, with a length equal to the depth buffer value times the distance between the near and far viewing plane (which is usually how the depth value is figured out in your scene...with 0 being the near plane and 1 being the far plane). That's not going to be perfect though...since the precision of the z-buffer isn't perfect even with a high bit-rate (http://www.sjbaker.org/steve/omniv/love_your_z_buffer.html).
But for the math of it...imagine the viewing plane as being a plane that's always in front of the camera with the same orientation as the camera. So the camera's forward vector will always point at the center of the viewing plane. To figure out the dimensions of the viewing plane, you need to use the field of view and aspect ratio along with the distance from the camera to the near viewing plane. This gives you a right triangle where you know one side (distance to near plane) and all three angles (fov/2, 90, and 90 - fov/2). Some simple trig should help you figure out the other sides, with the non-hypotenuse side being the half-width of the viewing plane (which again, represents the screen). Using the aspect ratio will give you the height.
Once you have that, you still need to rotate the viewing plane to match your camera's coordinate system. However, since you have the camera's forward (z), up (y) and right values (x), this should be easy. Then, figure out the center of the pixel you're interested in, and convert that to a point on the viewing plane by multiplying the normalized right vector by the pixel's x value, the normalized up vector by the pixel's y value, and using the near viewing plane distance as the z value. Remember, the viewing plane coordinates are from -1 to 1 instead of 0 to 1 (screen coordinates), so you'll need to convert your screen pixels to a -1 to 1 range.
Once you have the pixel you're interested in converted to a point on the viewing plane, you just have to do some raycasting. You subtract the camera's position from the point's position to figure out the ray. Then, to the camera position, add the normalized ray times the depth value. The depth value should be multiplied by the distance between the near and far viewing plane to get actual depth. So your equation should be:
WorldCoord = (PointOnNearPlane - CameraPosition) * (DepthValue * (FarPlaneDistance - NearPlaneDistance)).
So basically, look up raycasting - you'll probably find all the equations you'll ever need. My explanation is probably too muddled to make much sense of anyway (it's 3:00 am and I've been studying ethnology all day =P).
Your other option is just to render world positions to a color buffer like Shawn said. It'll at least give you a point of reference while you figure out the math, and if you don't need much precision, it could work just fine.
I'd also suggest you try coding a square that will stay in the camera's near viewing plane while you move around. That'll give you some idea of how to convert screen pixels to viewing plane coordinates.
Credit Kyle Schouviller (http://forums.xna.com/forums/p/1733/8644.aspx)
Daiboken
04-19-2010, 02:11 PM
http://pix.wefrag.com/i/0/c/b/c/2/808626e2da51efc94e8a2879c216fa8.jpg
I think there is not a problem with this image, i'm seeing the mountain continuation under the sea level, not the godray casting over it :_
Froyok
04-26-2010, 09:22 AM
I just want to try the effect today but... doesn't work at all.
That's work for you under the april verison of the udk ?
I follow the step, try on my map and on Necropolis, no effect at all...
ambershee
04-26-2010, 10:16 AM
I think there is not a problem with this image, i'm seeing the mountain continuation under the sea level, not the godray casting over it :_
No, it is a god ray. The ocean shader in the image (and Crysis) is completely opaque to any reasonable depth.
Piranhi
04-26-2010, 10:20 AM
You have to use the UTPostProcess_console post process in the hit effects now.
Froyok
04-26-2010, 01:16 PM
Ho, ok, thanks for the tips.
What mean the "_console" at the end compared with the UTpostprocess ?
prophet64
04-26-2010, 05:43 PM
Looks great! DO Want!
Piranhi
04-26-2010, 05:46 PM
The post processing uses this file now:
http://img202.imageshack.us/img202/193/postpx.jpg
Not UTPostProcess like before.
darthviper107
04-26-2010, 09:13 PM
http://pix.wefrag.com/i/0/c/b/c/2/808626e2da51efc94e8a2879c216fa8.jpg
I think there is not a problem with this image, i'm seeing the mountain continuation under the sea level, not the godray casting over it :_
Plus that's Crysis, not UDK
Xendance
05-03-2010, 05:05 AM
Well well....
http://udn.epicgames.com/Three/ContentBlog.html#Light Shafts
KazeoHin
05-03-2010, 05:17 AM
Well, I bet It would not have gotten in unless there was a significant amount of forum members expressing interest. so indeed, it is a victory.
BloodReyvyn
05-03-2010, 05:25 AM
Very Nice.
I only have one very small map that I wanted to use this effect on, since it will be a very dusty environment, so I guess I will wait until the next release to start on that environment.
Piranhi
05-03-2010, 07:57 AM
Finally, this looks great as well.
ambershee
05-03-2010, 11:01 AM
Looks like we'll be getting our hands on that fairly soon then :)
ThePriest909
05-03-2010, 01:54 PM
Well well....
http://udn.epicgames.com/Three/ContentBlog.html#Light Shafts
Hmmm! That sounds like another good reason for quiting smoking at last and get addicted into something else (lighting creation).
Froyok
05-03-2010, 04:32 PM
These can be enabled by checking bRenderLightShafts on a directional light:
Hu, where ?
I see anything...
This feature is available or not ?
ambershee
05-03-2010, 04:36 PM
It is not available yet.
Froyok
05-03-2010, 04:45 PM
It is not available yet.
Ok, thank you.
CoffeeGrunt
05-03-2010, 06:21 PM
Awww. Disappoint. :/
pulse0o0
05-04-2010, 11:56 PM
There is documentation on the website on how to do this the only problem is when it tells you to check the box "bRenderlightshafts" on a directional light there is no such option it might only be exclusive to UE3 in which case you'll need to go buy Unreal Tournament 3 or gears of war 2.
ThePriest909
05-05-2010, 01:05 AM
It's just not available yet guys.
BloodReyvyn
05-05-2010, 01:20 AM
^ What he said, expect it in the next UDK release. I think they are just showing off that they have it implemented and ready.
Dreamcube017
05-05-2010, 02:31 AM
Where is this at? can someone link to the documentation for this? (I really just wanna see screeen shots, but still... and yeah it may very well be in the next version.
Dreamcube017
05-05-2010, 03:15 AM
Nevermind I saw it.
fL4M3R
09-28-2010, 05:13 AM
great work man ! thank you so much!
Powered by vBulletin® Version 4.1.6 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.