Hey guys,
Short version:
Ive been working on depth of field for my iron sight views for a few days now and still could not come up with something that worked out. Ok here is what I want to achieve.

A Depth of Field effect that just blurs out the weapon in iron sight and nothing else. How to do this?
Long version:
At first I tried to make my cam autofocus through unreal script using the default bokeh dof post process wich worked out well. The huge problem with that is that it blurs to much space on the screen. It just does not work out for a game. Its more suited for cutscence and stuff and I just couldn't achieve a good localized effect.
The next thing I tried was a material effect wich uses scenedepth as a mask to lerp the normal scene with cheaply blurred scene(using UV Offset on the SceneTexture) but SceneDepth does not seem to work with foreground stuff like first person meshes.
Even tho I think this is the right way to go I gave up on this one.
Right now I use a photoshop painted mask to lerp between the untouched sceneTexture and the blured one and then enable/disable the effect via unrealscript, wich works out as intended, BUT. the mask is rigid. It does not move with the weaponbob. So every time I walk the mask is off a bit. The other problem I have is that my custom blur does not look good. Its just a simple box blur and I really would love to achieve the quality of the post process DoF and I have no clue how to do that.
So what I really want is an hight quality DoF effect that just blurs the close parts of a weapon when in iron sight.
please help me
EDIT: I solved this with an Material Effect and a scene depth node and a custom blur.
CUSTOM DOF FOR MOTHERJAVA
Hey, I found a few mins yesterday to take screenshots, but I had no time left to post
so here we go:
first thing you have to do is to create PostProcessChain or use a existing one.
[SHOT]http://i41.tinypic.com/vfwcv9.jpg[/SHOT]
After that you have to create or edit an UberPostProcess node
[SHOT]http://i40.tinypic.com/2m46nep.jpg[/SHOT]
The next step:
[SHOT]http://i40.tinypic.com/212ixq8.jpg[/SHOT]
The most important step for the code to work is the Effect Name, also make sure to set DOF to FOCUS_Position, since this example only works with that and set MaxNear and MaxFar to something else than 0.
Final Step in UDK:
[SHOT]http://i43.tinypic.com/i39mxi.jpg[/SHOT]
you have to set your PostProcessChain in the level. You have to redo this step for every new level you create.
Now lets talk unrealscript.
You have to find the PlayerTick function in your PlayerController Class and add these lines of code
Final notes:
This effect only works with FOCUS_Position, if you want to change it to FOCUS_Distance, you have to calculate the distance between HitLocation and OutCamLocation and then you have to set UberEffect.FocusDistance = CalculatedDistance;
Ok, there is absolutley no tweaking whatsoever. Its just quick and dirty code it threw together in 15mins of sparetime.
Anyways. I don't think that this effect will ever work on a FPS game. In my opinion you have to write your own DOF Material Effect if you want real time DOF calculations that dont look ugly. The standard DOF effect really show a lot of artifacts and because of that it should just be used on CutScenes.
Short version:
Ive been working on depth of field for my iron sight views for a few days now and still could not come up with something that worked out. Ok here is what I want to achieve.

A Depth of Field effect that just blurs out the weapon in iron sight and nothing else. How to do this?
Long version:
At first I tried to make my cam autofocus through unreal script using the default bokeh dof post process wich worked out well. The huge problem with that is that it blurs to much space on the screen. It just does not work out for a game. Its more suited for cutscence and stuff and I just couldn't achieve a good localized effect.
The next thing I tried was a material effect wich uses scenedepth as a mask to lerp the normal scene with cheaply blurred scene(using UV Offset on the SceneTexture) but SceneDepth does not seem to work with foreground stuff like first person meshes.
Even tho I think this is the right way to go I gave up on this one.
Right now I use a photoshop painted mask to lerp between the untouched sceneTexture and the blured one and then enable/disable the effect via unrealscript, wich works out as intended, BUT. the mask is rigid. It does not move with the weaponbob. So every time I walk the mask is off a bit. The other problem I have is that my custom blur does not look good. Its just a simple box blur and I really would love to achieve the quality of the post process DoF and I have no clue how to do that.
So what I really want is an hight quality DoF effect that just blurs the close parts of a weapon when in iron sight.
please help me

EDIT: I solved this with an Material Effect and a scene depth node and a custom blur.
CUSTOM DOF FOR MOTHERJAVA
Hey, I found a few mins yesterday to take screenshots, but I had no time left to post

so here we go:
first thing you have to do is to create PostProcessChain or use a existing one.
[SHOT]http://i41.tinypic.com/vfwcv9.jpg[/SHOT]
After that you have to create or edit an UberPostProcess node
[SHOT]http://i40.tinypic.com/2m46nep.jpg[/SHOT]
The next step:
[SHOT]http://i40.tinypic.com/212ixq8.jpg[/SHOT]
The most important step for the code to work is the Effect Name, also make sure to set DOF to FOCUS_Position, since this example only works with that and set MaxNear and MaxFar to something else than 0.
Final Step in UDK:
[SHOT]http://i43.tinypic.com/i39mxi.jpg[/SHOT]
you have to set your PostProcessChain in the level. You have to redo this step for every new level you create.
Now lets talk unrealscript.
You have to find the PlayerTick function in your PlayerController Class and add these lines of code
Code:
function PlayerTick(float DeltaTime) { local UberPostProcessEffect UberEffect; local LocalPlayer PC; local vector HitLocation, HitNormal; local Actor HitActor; local vector OutCamLoc; local Rotator OutCamRot; GetPlayerViewPoint(OutCamLoc, OutCamRot); HitActor = Trace(HitLocation, HitNormal, vector(OutCamRot) * 5000 * 20 + OutCamLoc, OutCamLoc, true); if(HitActor == none) { HitLocation = vector(OutCamRot) * 5000 * 20 + OutCamLoc; } PC = LocalPlayer(Player); if(PC != none && PC.PlayerPostProcess != none) { //this line uses the Effect Name we set in UDK to get a referenceof the UberPostProcessEffect UberEffect = UberPostProcessEffect( PC.PlayerPostProcess.FindPostProcessEffect('Uber')); if(UberEffect != none) { UberEffect.FocusPosition = HitLocation; } } //this line is not need if you add this code to PlayerController.uc Super.PlayerTick(DeltaTime); }
Final notes:
This effect only works with FOCUS_Position, if you want to change it to FOCUS_Distance, you have to calculate the distance between HitLocation and OutCamLocation and then you have to set UberEffect.FocusDistance = CalculatedDistance;
Ok, there is absolutley no tweaking whatsoever. Its just quick and dirty code it threw together in 15mins of sparetime.
Anyways. I don't think that this effect will ever work on a FPS game. In my opinion you have to write your own DOF Material Effect if you want real time DOF calculations that dont look ugly. The standard DOF effect really show a lot of artifacts and because of that it should just be used on CutScenes.
Comment