PDA

View Full Version : Custom DOF help/question



musichopper
11-07-2009, 05:38 PM
Hello, I have recently been doing some programming in UNITY and I made my own depth of field effect that would actually raytrace the camera from its center to whatever the player happened to look at. It would send back the distance between the camera and the object that was being observed by either being at the center of the screen (hit by the raycast) or I also had an option to let the player use a "look" cursor to move the mouse around screen to focus on different objects.

This is how human vision works. The default setup for DOF in the Unreal 3 engine has it set to only distance where if the player looks or centers their vision on a nearby object or far away object, the DOF distance value doesn't change. I need to find a way to have it calculate the object including any scenery on the map that collides with a raycast from the camera out and then use the value to change the DOF settings live so it acts like real human vision.

Any idea how this could work in Unreal 3?

I used to work with the old Unreal stuff a while back but I am new to the latest stuff on this end of things.

I am pretty sure since I was able to hand code it in (the sorta crappy) Unity that Unreal 3 should also allow it. Just need to figure out how and the best way.
Thanks for help!

micahpharoh
11-07-2009, 05:55 PM
I know it works. They did it in GOW2.

musichopper
11-07-2009, 10:58 PM
A trace is Unreal's method of raycasting

GetTraceRange() should give a distance I am guessing. Then I would just have to have it change the values of the DOF with the same type of math I used when I did this for unity.

My problem at this moment is fear of messing all the current engine code up with my personal additions/upgrades lol. Also, how in Unreal do I get the code to execute every "frame"?... without causing any lag issues with other process priority etc?

Then again, A nonstop raycast...I mean trace from the player shouldn't be too much of a hit on the FPS. I mean I did it in unity and that is laggy as hell lol.

I wish I already know all of the engine code inside and out so I could more easily know what other functions I would need to call and stuff. I can't wait to get a handle on it all.

Seems that the confusing part right now is how to send the trace from the player camera's vector using their local rotation coordinates so it always casts the ray directly from the center of the camera out until it hits something. (Up to a certain max distance to reduce lag of course).

Any help would be awesome.

EDIT:... I also just noticed that "GetCameraLocation( out vector CameraLocation, out rotator CameraRotation )" Was what to use in Engine 2... I wonder if it still would work.

SIDE NOTE:
Once I get it working on here I should totally make a side app that uses a zoomed in web cam on the players eyes where they can initialize it by looking to center sides bottom top and corners. Then using those as variables and the math to detect where they are looking on screen with their actual eyes and then cast rays from that vector instead lol. Would suck to have the player keep their head in one position tho lol. I guess that is why they are making a headgear based version of that already.

feanix
11-19-2009, 02:44 AM
Once I get it working on here I should totally make a side app that uses a zoomed in web cam on the players eyes where they can initialize it by looking to center sides bottom top and corners. Then using those as variables and the math to detect where they are looking on screen with their actual eyes and then cast rays from that vector instead lol. Would suck to have the player keep their head in one position tho lol. I guess that is why they are making a headgear based version of that already.

Props for your ambition! :D