# Depth of Field (GPU Gems 3) Problems

This topic is 2601 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I am currently trying to implement the depth of field algorithm as described in gpu gems 3 (link)

I am having some difficulties to get it running. My biggest problem is finding suitable parameters to test it out properly.

In the downsample shader (1. step):
dofEqWorld - what exactly is stored in this vector?
its used in the equation:

 sceneCoc = saturate( dofEqWorld.x * depth + dofEqWorld.y ); 

according to its usage i think its the cocScale and cocBias value as described here but i am not sure about this (it also uses abs instead of saturate)

if this is the case, what are usual values for aperture and focallength? and should the depth value in this equation be provided as view-depth? or normalized depth? and should the depth value be linear?

there is also a similar vector used in the last step:

 farCoc = saturate( dofEqFar.x * depth + dofEqFar.y );

i guess these would be the same values, right?

hopefully someone can answer these questions, because i kept playing around with values but never get any reasonable results..

##### Share on other sites
finally found the problem:

there is a mistake in the bias term (which is stated in the GPU Gems article - also found this mistake in a siggraph presentation!)

 CoCBias = (aperture * focallength * (znear - planeinfocus)) / ((planeinfocus * focallength) * znear) 

you have to use this:

 CoCBias = (aperture * focallength * (znear - planeinfocus)) / ((planeinfocus - focallength) * znear) 

hope this helps others too

1. 1
2. 2
Rutin
19
3. 3
khawk
15
4. 4
A4L
13
5. 5

• 13
• 26
• 10
• 11
• 44
• ### Forum Statistics

• Total Topics
633744
• Total Posts
3013657
×