• 沒有找到結果。

Controllable Defocus Blur

CHAPTER 3 Algorithm

3.5 Controllable Defocus Blur

People often want to control over depth of field parameters empirically, such as limit foreground blur or extend the in-focus range while preserving the foreground and background. MunKberg et al. [17] proposed a user controllable defocus blur method. We use their technique in our system.

We modify the circle of confusion by limited it’s size near the focus depth.

0 , w-focusDepth < ε C =

a + wb , otherwise

19

It is assumed that the clip space circle of confusion radius is linear in the interior of a triangle. Then we can increase the focus range or decrease the foreground blur easily. If the triangle vertex is inside the extended focus range, all samples pass stage 1 test. And set u = v = 0 to compute the stage 2 time bounds. Finally we modify the circle of confusion when doing the triangle intersection test and render the extended focus range blurry image.

20

Chapter 4

Implementation and Results

We develop our system based on openGL and GLSL. Our stochastic sample culling algorithm is implemented in pixel shader. In the CPU host, we bind the vertex stream and the transform matrix at shutter time t = 0. We also bind the texture coordinates and other shading attributes like vertex normal etc. as usual. We also bind the vertex at shutter time t = 1 as an additional vertex attribute.

Vertex Shader:

We transform the vertices into clip space at shutter time t = 0 and t = 1. Then we pass all vertex attributes to the geometry shader.

Geometry Shader:

In this shader, we convert each triangle into a 2D bounding box or a 2D convex hull as we described in Section 3.2. Since this method destroy the triangle’s structure, we should store the original all 6 vertices positions as output variables. Besides we pack each vertex’s circle of confusion and other vertex attributes from previous shader to every emitted vertex.

21

Pixel Shader:

In pixel shader, we deal with each pixel inside the 2D bounding box. The stochastic sample buffer is created in CPU host program, and passes into pixel shader as a texture. We create this buffer in 3 channels at time t and camera lens u, v. The time values are uniform in [0,1] as floating point. The camera lens value are uniform in [-1,1]. We set this buffer size as 128*128. Each pixel takes the stochastic samples from this texture.

We also use multi-sample antialiasing (MSAA) as well. For each pixel, we use a bit mask to store hit/miss of the samples. We use gl_SampleMask[] as the bit mask in openGL. Coverage for the current fragment will become the logical AND of the coverage mask and the output gl_SampleMask. That is, setting a bit in gl_SampleMask to zero will cause the corresponding sample to be considered uncovered for the purpose of multisample fragment operations. Finally we average the pixel values whose corresponding mask bit is equal to one. If the bit mask is all zero, we discard this pixel.

If the stochastic sample passes our culling test and the triangle intersection test, we draw the pixel color with the corresponding texture coordinate or the corresponding color. The GPU program flow is shown in Figure 4.1.

22

Figure 4.1: GPU program workflow Pixel shader:

23

In the remaining of this chapter, we present our result images rendered in real-time on a desktop PC with Intel Core i7 950 CPU 3.07GHz and NVIDIA GeForce GTX 580 video card. Our system is implemented in C++ Language using OpenGL and GLSL. All results are rendered with 1024 x 768 pixels.

For our stochastic rasterization culling algorithm, we compare two culling tests.

Namely Liane et al.’s dual space [10] culling algorithm. And the traditional culling algorithm with bounding box. We test four different scenes. The scene Hand is tested with object’s motion blur (Figure 5.2). The FlyingDragonfly is tested with camera’s motion blur (Figure 5.3). The FairyForest is tested with both motion blur and defocus blur (Figure5.4). We also show the image with enlarge focus range (Figure 5.5). With increasing the focus range, the whole fairy face can be seen clearly. Note that all scenes are rendered by 32 samples per pixel.

24

Figure 4.2: Defocus blur with different focus depths

25

Figure 4.3: RacingCar with/without motion blur

26

Figure 4.4: FlyingDragonfly with/without camera motion blur

27

Figure 4.5: FairyForest with/without both motion and defocus blur

28

Figure 4.6: Difference between enlarge focus range or not

29

Table 4.1 shows the result of STE. We compare our algorithm with the other two culling tests. The first scene Hand has 15k triangles, Car has 54k triangles ,Dragonfly and FairyForest has about 85k and 170k triangles. We can see that with motion blur or defocus blur only, our algorithm’s STE is almost the same as Dual space. Because our stages 1 and 2 culling algorithms are separately like the uv test and t test with Laine et al. [10]. But our algorithm comes better with both effects exist.

Scene Bbox Dual Space Our

Table 4.1: STE results with 16spp. Higher is better.

30

Table 4.2 shows the computation time for each scene in millisecond. Our algorithm takes a little more computation time than Laine et al. [10] while rendering large motion scenes. But, we perform better when both effects exist.

Scene Bbox Dual Space Our Table 4.2: Computation time results with 16spp. Lower is better.

31

Chapter 5

Conclusions and Future Work

In this thesis, we propose a 2-stage culling algorithm for stochastic rasterization.

We propose a new idea to compute the time bounds with relative camera lens in clip space. Using these bounds to cull and get higher STE.

We cull samples outside camera lens bounds in stage1 using the linear relationship between camera lens and vertex position. Stage 2 culls samples outside time bounds. We use the triangle similarity in clip space to find the intersection time easily. We use this idea to compute two linear bounds. Each pixel only needs to compute these bounds once. Our algorithm can handle motion blur and defocus blur simultaneously.

In the future we would find some other improvement to find bounding geometry easily and more accurately. We shall try to reduce the execution time, such as increase the test range from per pixel test to per tile test. Furthermore we can make the STE higher with more “accurate” stochastic samples. We can use stage 1 result to generate relative stochastic samples with different camera lens. Then use stage2 result to set each previous sample’s time dimension. These samples would hit the triangle with higher probability than fully stochastic samples.

32

References

[1] AKENINE-MÖ LLER, T., MUNKBERG, J., AND HASSELGREN, J. 2007.

Stochastic Rasterization using Time-Continuous Triangles. In Proc. Graphics Hardware, 7–16.

[2] AKENINE-MÖ LLER, T., TOTH, R., MUNKBERG, J., AND HASSELGREN, J.

2012. Efficient Depth of Field Rasterization using a Tile Test based on Half-Space Culling. Computer Graphics Forum, 31, 1, 3–18.

[3] BRUNHAVER, J., FATAHALIAN, K., AND HANRAHAN, P. 2010. Hardware Implementation of Micropolygon Rasterization with Motion and Defocus Blur.

In High-Performance Graphics, 1–9.

[4] FATAHALIAN, K., LUONG, E., BOULOS, S., AKELEY, K., MARK, W. R., AND HANRAHAN, P. 2009. Data-parallel rasterization of micropolygons with defocus and motion blur. In Proc. High Performance Graphics, 59–68.

[5] GRAHAM, R. 1972. An efficient algorithm for determining the convex hull of a finite planar set. Information processing letters 1, 132–133.

[6] GRIBEL, C. J., DOGGETT, M., AND AKENINE-MÖ LLER, T. 2010.

Analytical Motion Blur Rasterization with Compression. In High-Performance Graphics, 163–172.

[7] HAEBERLI, P., AND AKELEY, K. 1990. The accumulation buffer: hardware support for high-quality rendering. In Proc. ACM SIGGRAPH, 309–318.

[8] KOREIN, J., AND BADLER, N. 1983. Temporal anti-aliasing in computer generated animation, Computer Graphics, vol 17, no .3, p.377-388.

33

[9] LEE, S., EISEMANN, E., AND SEIDEL, H.-P. 2010. Real-Time Lens Blur Effects and Focus Control. ACM Transactions on Graphics, 29, 4 (2010), 65:1–

7.

[10] LAINE, S., AILA, T., KARRAS, T., AND LEHTINEN, J. 2011. Clipless Dual-Space Bounds for Faster Stochastic Rasterization. ACM Transactions on Graphics, 30, 4, 106:1–106:6.

[11] LAINE, S., AND KARRAS, T. 2011. Efficient Triangle Coverage Tests for Stochastic Rasterization. Technical Report NVR-2011-003, NVIDIA..

[12] LAINE, S., AND KARRAS, T. 2011. Improved Dual-Space Bounds for Simultaneous Motion and Defocus Blur. Technical Report NVR-2011-004, NVIDIA.

[13] MUNKBERG, J., AND AKENINE-MÖ LLER, T. 2011. Backface Culling for Motion Blur and Depth of Field. Journal of graphics, gpu, and game tools 15, 2, 123–139.

[14] MUNKBERG, J., AND AKENINE-MÖ LLER T. 2012. Hyperplane Culling for Stochastic Rasterization. In Eurographics Short Papers, page 105-108.

[15] MUNKBERG, J., CLARBERG, P., HASSELGREN, J., TOTH, R., SUGIHARA, M., AND AKENINE-MÖ LLER, T. 2011. Hierarchical Stochastic Motion Blur Rasterization. In High-Performance Graphics, pp. 107–118.

[16] MCGUIRE, M., ENDERTON, E., SHIRLEY, P., AND LUEBKE, D. 2010.

Real-Time Stochastic Rasterization on Conventional GPU Architectures. In High Performance Graphics, pp. 173–182.

[17] MUNKBERG, J., TOTH, R., AND AKENINE-MÖ LLER, T. 2012. Per-Vertex Defocus Blur for Stochastic Rasterization. Computer Graphics Forum (Eurographics Symposium on Rendering), vol. 31, no. 4, pp. 1385-1389.

[18] RAGAN-KELLEY, J., LEHTINEN, J., CHEN, J., DOGGETT, M., AND

34

DURAND, F. 2011. Decoupled Sampling for Graphics Pipelines. ACM Transactions on Graphics, 30, 3, 17:1–17:17

相關文件