Depth of Field (GPU Gems 3) Problems

Started by
0 comments, last by mancubit 12 years, 5 months ago
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..
Advertisement
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!)

instead of this:


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

This topic is closed to new replies.

Advertisement