Spin-Wave Dynamics in a Hexagonal 2-D Magnonic Crystal
Total Page:16
File Type:pdf, Size:1020Kb
Real-Time Simulation of Depth of Field with Bokeh Dongmiao Liu School of Computing Science Newcastle University [email protected] Figure 1: A photograph with blurry defocused far field and bokeh, shot by a 24-70mm lens, ƒ/2. The simulation is going to focus on Depth of Field effect with customizable bokeh. A pattern reader is provided in order to ABSTRACT customize the bokeh effects caused by apertures features. To enhance the realism of real-time rendering, a considerable amount of research has been done on lens effects simulation during KEYWORDS the last decade. Figure 1 illustrates the bokeh in the defocused field Depth of Field; Bokeh; Post-processing; real-time rendering; shot in a real-world camera with an aperture of ƒ/2.8 (In shader; lens aberrations; photography, the f-number is the ratio of the focal length to the I. INTRODUCTION diameter of the aperture, which defines the amount of light that goes through the lens in an optical system). With the innovation of advanced rendering techniques and hardware improvements, real-time rendering benefits much in an Bokeh, the blurry spot in the shape of the aperture (usually circular) expanding field, including video games, architects and engineers. which appears in the out-of-focus area as an eye-pleasing lens On the other hand, photo effects simulation, a popular subject in effect, has been regarded as a costly effect in real-time rendering. computational photography, has been introduced to the domain of On the other hand, certain effects such as swirly bokeh caused by real-time rendering. This photorealistic rending technique aims at certain lens defects in real-world cameras are often neglected. producing special photographic phenomena caused by camera lens Much work has been reported on simulating swirly bokeh effect in artefacts, such as bokeh effects and lens flare, to improve the static photography editing and computational photography as realism and artistic sense. presented in Computer Vision Meets Arts: Stereo Computational Photography [1], while there is no research on this sought-after However, although there is a significant trend to improve the effect in real-time rendering. simulation performance, depth of field with bokeh effect is still very costly to compute for real-time rendering. A classic scatter- This report introduces an efficient gather-based approach to based approach (i.e. point-splatting) which produces pleasant result implement a post-processing depth of field effect, with flexible is demonstrated in How To Fake Bokeh [2] by Pettineo in 2011. A bokeh whose aperture shape is customizable, as well as a swirly more efficient method is to simulate bokeh in a gathering approach bokeh effect which normally appears in wide apertures caused by lens defects. A novel approach is applied to alleviate unpleasant with extended post-processing shaders. artefacts (i.e. pixel bleeding). As inspired by [L. McIntosh, B. E. Riecke and S. DiPaola, 2012], this report is going to focus on simulating depth of field using this efficient gather-based approach. Additionally, swirly bokeh (also known as cat-eye effect) which has not been implemented in other studies for real-time rendering, will be applied in this approach. Therefore, we shall first briefly introduce the concepts of camera models and the lens effects which are popular in studies of photorealistic rendering. A. Camera Models for Real-Time Rendering Modern render technique generally consists of two main courses: simulating the 3-demension scene and render the scene into 2- dimension pixels. The second pass is based on the camera model, Figure 3: Comparison of CoC that produced in defocused near which plays an essential part of processing the final pixels with a field and far field. Note that only the focused source will produce a high degree of realism. A standard camera model known as pin- small spot, which will turn into part of the sharp image. hole camera model is commonly used in computer graphics as a simplified camera model, with a thin lens model of a tiny aperture, camera and thin-lens model with post-processing shaders which are which provides an infinite depth of field [3]. extended to compute required lens data (i.e. aperture, focal length However, lens effects may enhance the quality of realism in and focal distance), to achieve a sought-after lens effect in an computational photographic, movie production and video games, efficient way. for instance, a storytelling scene may require a depth of field effect B. Depth of Field and Circle of Confusion which provides a blurred background, or bokeh with certain aperture shape, to enhance the immersive experience of users. Depth of field (DOF) defines the focused area within the distance Therefore, much studies on physically-based-camera-model have between blurred near field and far field objects, as shown in figure been reported to simulate a realistic camera lens which can produce 4. It can be determined by the circle of confusion (CoC), an optical many photographic-like effects including lens flare, depth of field, cone spot caused by the defocused light rays when processing a lens aberration and vignette. As presented by [4, B. Steinert, H. point source, as illustrated in Figure 3. Dammertz, J. Hanika and H. P. A. Lensch, 2011]. However, due to The CoC value can be calculated by a series of lens data including the computational complexity of ray tracing in this camera model, aperture, focal length and focal distance [5]. The approximate value another approach is commonly used in real-time rendering: a pin- can be given by: hole camera model applied with post-processing shaders can be extended to achieve the same lens effect efficiently. (1) This report presents a real-time simulation using a classic pinhole Where C is the CoC value, f is the focal length, N is the F-number, u is the distance to subject [6][7]. The acceptably sharp, which (a) (b) Figure 4: Depth of Field effect produced by a 24-70mm lens, ƒ/5.0, shot with different focal length. 2 A2 A1 Figure 6: The shadow area presents the cat-eye effect which is clipped to a cat-eye shape by the main lens A1 and the second aperture A2. The intersection area of the two apertures will Figure 5: A portrait photo of Katherine Maher demonstrates the determine the actual bokeh shape. swirly bokeh effect in a defocused background[8]. Photographed with a Lomography Petzval lens. depends on how the final image is processed, is determined by whether the current blur spot is smaller than the acceptable circle of confusion. The diameter of the CoC can be calculated from the following formula: (2) Where A is the aperture diameter, S1 is the focal distance, S2 is the depth value of the current object (with a range of 0 to 1, applicable Figure 7: The cat-eye shape caused by two apertures A and A(2) on a thin lens camera model[1]. for the data from a depth map in OpenGL), and f is the focal length, namely the on-focus distance. For a 35mm full-frame format (24 mm × 36 mm, 43 mm diagonal), a widely used circle of model which illustrates the process of producing swirly bokeh in confusion limit is d/1500, while 0.030mm and 0.033mm are also an optical device, as shown in [9, Figure 7]. The secondary aperture common for 35mm format. A(2) partially blocks the off-axis light that should go into the The depth of field simulation presented in this report uses a aperture (the diameter of A(2) is assumed to be larger than A). 0.024mm CoC limit to simulate a 35mm full-frame format, for this value produces an ideal result. the actual bokeh result can be calculated according to Dblock, the distance between the centres of A and A(2). According to the thin- C. Swirly Bokeh lens formula as addressed in [9], for each position p at the Image Swirly bokeh, which is also known as cat-eye effect, could be carrier, we have produced by certain lenses (i.e. Lomography Petzval and Helios) while the diameter of aperture is large enough. This effect produces the illusion of rotational movement of the blur bokeh, see [8, Figure 퐷푏푙표푐푘 = ∆ ∙ tan(휃) (3) 5]. Swirly bokeh is caused by the “secondary aperture”. The optical structures may block part of the off-axis light which should go ||푝푂|| 2 1 1 tan(휃) = = ||푝푂||2 ∗ ( − ) (4) through the lens; therefore, the circular bokeh is clipped into cat- ||푂푂′|| 푓 푆1 eye shape by the second aperture, see figure 6. 2 A camera lens model which simulates swirly bokeh was first reported in [1]. This research demonstrates an ideal result of the Where ∆ is the distance between the two apertures, O′ is the simulation of this effect on computational photography, with a thin optical centre of the lens, pO is the distance between p and the lens image centre. 3 On the other hand, the shape of bokeh is depend on the aperture, for the CoC is produced by the light cone when defocused light rays pass through, especially from a point source. Therefore, the pattern of CoC could be seen as a mapping of the aperture with specific size. Accordingly, masks with various shapes are applied in front of the apertures by photographers, otherwise the bokeh shape will monotonously remain to be circular for most optical devices. See figure 8. For real-time rendering, asymmetric patterns are always costly and hard to compute for the ways of samplings and the number of samplers. Therefore, this project is designed to have a function of generating pattern samples by reading pattern data from a 24*24 raw image.