Continuation fo the above... (justin case my PC crashes cause it did the first time I wrote this)
So let's say you want to render four pass depth of feild.
Your depths are as follows:
1-64
64-128
128-256
256-512
Now let's assume our display is 1024x768.
For speed reasons we're going to take a shortcut and render the most distant regions to a smaller camera view. But you could instead blur the full size image. However, that is unlikely to be fast enough for realtime use. Even this method is probably pushing it with 1024x768 res.
So we render the first layer. The mist distant layer.
Set the camera range to 256, 512. (You'll have to correct the fog since the near and far planes are different. I'll leave that as an excerise for the reader) Your sky should be visible in this first pass.
Now, render the view to a 128x96 viewport. Copy to a texture. Do not blur. There is no need to.
Next create a quad in front of the camera filling the camera view, and texture it with our new texture. Check out my distant object rendering code in the code archives for an example of how to do this. Set it's entityorder so it renders before everything else.
Now, render your view again. But this time render a 256x192 image. You will now have a texture that has blurry stuff behind it and stuff that's in focus in front of it.
Repeat this process, doubling the camera view size each time until you get to 1024x768, and changing the camera's range each time to those values I listed above. The distance between the near and far camera planes should be half that which it was the previous time each time you render.
On the last full-screen pass you don't need to copy to a texture. Just flip so the player can see the final scene. Objects will get blurrier as they recceed into the distance.
Don't ask me how to do Depth of Feild which can vary and make stuff up close blurry and stuff in the distance sharp, that's up to you to figure out. :-) I'm sure it's not nearly as easy though.
So let's say you want to render four pass depth of feild.
Your depths are as follows:
1-64
64-128
128-256
256-512
Now let's assume our display is 1024x768.
For speed reasons we're going to take a shortcut and render the most distant regions to a smaller camera view. But you could instead blur the full size image. However, that is unlikely to be fast enough for realtime use. Even this method is probably pushing it with 1024x768 res.
So we render the first layer. The mist distant layer.
Set the camera range to 256, 512. (You'll have to correct the fog since the near and far planes are different. I'll leave that as an excerise for the reader) Your sky should be visible in this first pass.
Now, render the view to a 128x96 viewport. Copy to a texture. Do not blur. There is no need to.
Next create a quad in front of the camera filling the camera view, and texture it with our new texture. Check out my distant object rendering code in the code archives for an example of how to do this. Set it's entityorder so it renders before everything else.
Now, render your view again. But this time render a 256x192 image. You will now have a texture that has blurry stuff behind it and stuff that's in focus in front of it.
Repeat this process, doubling the camera view size each time until you get to 1024x768, and changing the camera's range each time to those values I listed above. The distance between the near and far camera planes should be half that which it was the previous time each time you render.
On the last full-screen pass you don't need to copy to a texture. Just flip so the player can see the final scene. Objects will get blurrier as they recceed into the distance.
Don't ask me how to do Depth of Feild which can vary and make stuff up close blurry and stuff in the distance sharp, that's up to you to figure out. :-) I'm sure it's not nearly as easy though.