ZBlur?

Blitz3D Forums/Blitz3D Programming/ZBlur?

CyBeRGoth(Posted 2003) [#1]
Hi

Has anyone tried to make a Zbuffer Blur like you get in Zelda The Windwaker? You know where anything over say 100 feet from you is blurry?

I suppose effects like this would be impossible without access to the Z buffers tho.


Mustang(Posted 2003) [#2]
ZBlur = DoF, Depth-of-Field?

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/graphics/programmingguide/TutorialsAndSamplesAndToolsAndTips/Samples/DepthOfField.asp


Ross C(Posted 2003) [#3]
You could do multilpe renders. Render all entities that are are so far away from the camera, then blur them, then set the camera clear mode so it doesn't clear the backbuffer, then rednder all the near entities. That should work. Except if you have a long corridor your in and it's all the one entity :S


CyBeRGoth(Posted 2003) [#4]
Yeah mustang thats about right

Ross I am sure its sort of done like that, multiple pass rendering would maybe work but would be slow


sswift(Posted 2003) [#5]
Use this code:

http://www.blitzbasic.com/codearcs/codearcs.php?code=815

I just added it to the code archives. It was a system I was working on for speeding up the rendering of distant objects. I'm pretty sure that's why Zelda does what it does. I found though that at least in Blitz, there is little benefit to this method since you cannot render to a texture directly (the copy operation takes some time) the blurring operation takes some time, (no direct hardware blur, which the gamecube probably has) and even if you solve those problems, without the ability to render images with alpha, you can't optimize it by rendering the stuff that's farther away less often than the stuff that's nearby, which I'm sure is another optimization they're doing in Zelda.

But luckilly for you that doesn't matter if all you want is for stuff to be blurry when it's far away. And this code is really simple to use. You'll have to have a sky which is large enough to encompass your world (no render order tricks) and then you just specify the distance to which your main camera renders with the far clipping plane and everything beyond that is rendered with the special camera and then a skybox is generated.

You may or may not be able to speed things up by rendering only one view instead of six but rendering it every frame and placing that on a plane in front of the camera instead of rendering a skybox. The advantage rendering a skybox provides is that you can turn around in one spot with no cost at all once the maps are rendered, and you can move around a bit without having to have the maps rerendered.

You could also speed up the algorithm by creating "nodes" around the player and attempting to render skyboxes from the node which the player is moving towards over the course of several frames to get rid of the jittering from the sudden rendering of six images. That way you could render just one of the six images each frame till they get to the new node and then swap in the new node's textures when they get there.


CyBeRGoth(Posted 2003) [#6]
Cheers sswift that code sounds exactly like what I am after, I will check it out when I get home :)


sswift(Posted 2003) [#7]
Note that this isn't the same thing as depth of field. It'll look good though if you use it on stuff that's relatively distant so it's hard to see where it goes from being normal to being blurred.

Combinging multiple renders with this method is not an option because there's no alpha.

It may however be possible to do a truish multiple render DOF effect by rendering multiple camera views and offsetting them and then copying those to a set of textures which you then overlay over the screeen using that blur2 style blurring I have in the above code, which uses alpha... There's a trick to blending multiple images together with alpha. :-) That shows you what levels of alpha you should use for each layer.

Anyhow that would of course be a lot slower than normal and would make even the sharpest graphics fuzzier cause the texture wouldn't be the same size as the screen exactly.