This composition simulates depth of field. The left half is the normal rendering, the right half is passed through a Depth of Field filter. The filter takes a focal point, depth of field, normal image, blurred image, and depth image input, and combines them all to blur the frame based on distance from the focal point.

Despite the complex sounding nature, this composition runs at 30fps on my crappy GMA950 (!!). Enough to actually impress me, even :)

It's likely a bit difficult to see due to a small video, and vimeo transcoding. The original probably doesn't show it much better, but it'll have to do for now... :(

(depth buffer reading might make its way into the next GLTools release ;)

5 Likes

Tags

  • George Toledo plus 10 months ago
    dude.
  •  
  • vade 10 months ago
    Awesome! I have an SSAO shader that can use a better depth texture. Does it report in Intensity/Float format?
  •  
  • toneburst plus 10 months ago
    Are you reading the depth-buffer here, then?
    Very impressive! I'd vote for the depth-buffer to be made accessible, definitely! (and have already)

    Great stuff!!

    a|x
  •  
  • Christopher Wright 10 months ago
    Yeah, read as a Float single-channel image. Unfortunately, this crosses a few lines (CoreImage doesn't support single-channel images, so it's a bit confused, and QC still doesn't properly support them either, so this prints gl warnings in the console every frame when the depth texture is used in a core image filter [it tries to do some gl call that fails due to single-channelness] -- this harms performance).
  • George Toledo plus 10 months ago
    That's too bad... all the same, I am glad you have been looking into this!
  •  
  • vade 10 months ago
    Wait, QC specifically has A QCPluginPixelFormatF and I8 pixel formats? It does not support that?
  •  
  • Christopher Wright 10 months ago
    It supports them for some operations (imageWithString outputs an intensity image, for example), but it doesn't consistently handle them like other images. Specifically, it doesn't seem to like the way we create them, and doesn't like us using them in CoreImage Filters (or something related to this composition) -- I'm still trying to hunt it down.

    It looks like this: 1/18/09 8:41:23AM Quartz Composer[37161] *** OpenGL error 0x0502 (invalid operation) in function "-[QCImageTextureBuffer endRenderTextureAndFinish:]" (That's obviously not our code ;) -- though we might be mishandling something I guess. Like I said, still experimental, and this was a quick mock-up to see if performance was better than the old way.

    [Correction: Just added some more sanity checks/cleanup, and it went away. Looks like some texture property wasn't preserved correctly in some cases. -- Guess it makes the cut in the next GLTools release :)]
  •  
  • George Toledo plus 10 months ago
    A+, yes!
  •  
  • George Toledo plus 10 months ago
    So, there will be some kind of way to "tune in" the actual focal point on the x/y/z, or it will be different?
  •  
  • Christopher Wright 10 months ago
    There are 2 parameters: Focal Distance (how far from the camera the focal point is) and Focal Depth (how wide that in-focus region is). In real optics, this is a much more sophisticated and complex procedure, but what I've whipped up here is a simple approximation. This isn't necessarily general purpose, but it might be a sample composition just for kicks.
  •  
  • Michael Neely 8 months ago
    This is cool.
  •  
This conversation is missing your voice. Take five seconds to join Vimeo or log in.

Advertisement

2 Related collections

Groups Groups
Channels Channels

Statistics

  •  
    plays
    likes
    comments
  • Total
    plays 1,139
    likes 5
    comments 11
  • Dec 5th
    plays 0
    likes 0
    comments 0
  • Dec 4th
    plays 4
    likes 0
    comments 0
  • Dec 3rd
    plays 2
    likes 0
    comments 0
  • Dec 2nd
    plays 1
    likes 0
    comments 0
  • Dec 1st
    plays 1
    likes 0
    comments 0
  • Nov 30th
    plays 1
    likes 0
    comments 0
  • Nov 29th
    plays 3
    likes 0
    comments 0
  • Nov 28th
    plays 1
    likes 0
    comments 0
Previous Week

Downloads

Please join Vimeo or log in to download the original file. It only takes a few seconds.