We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
Depth of field - (Read 1160 times)
Depth of field -
Dec 16th, 2006, 12:59am
 
Has anyone messed around with DOF in jogl? I want to blur flat primitives based on Z-depth, or figure out an efficient way to simulate DOF. So far my best guess is to jitter each object's coords and decrease alpha as the Z-depth increases.
so (pseudocode):

for objects:visible
  for z
      jitter[] = jitter[z]
           for jitter
               fill(alpha/z)
               visible.render(x+jitter[0],y+jitter[2],z)


jitter(depth):
return jitter[math.abs(depth)]
where jitter arrays are [n][x,y] of floats

or something like that.
Is there a faster/better way in openGL? I think I could get it to look OK by tweaking the jitter arrays and it wouldnt be too slow.
THanks,
Brian
Re: Depth of field -
Reply #1 - Dec 17th, 2006, 3:00pm
 
Unfortunately, I don't think there's any way of doing it that doesn't require rendering everything multiple times.
Re: Depth of field -
Reply #2 - Dec 18th, 2006, 6:02pm
 
Well, it works well enough. I have one big static array of jitter points and scale the number of points used by z-depth.
Its still not as good as box blur or guassian, but with more tweaking it might get close.
Page Index Toggle Pages: 1