• 沒有找到結果。

Chapter 4 The Algorithm

4.2 Dynamic Mask

13

silhouette are added to produce shadow polygons. Figure 4.1 shows the whole scene and the moving object is the dragon. Figure 4.2 shows the stencil mask generated from the object and the shadow volume. Light is in the left of the scene. The mask marks the changed results of ray marching which can not be reused. The results of ray marching of other parts remain the same as the previous frame.

4.2 Dynamic Mask

The stencil mask of current moving objects is not enough for specifying all changed pixels, because it only includes samples that are changed from visible to invisible. We should also consider visibility of samples that are changed from invisible to visible. This usually happens in the shadow volume of moving objects of the previous frame.

Both the previous and current shadow volumes of moving objects are considered.

Actually, we consider all shadow volumes of moving objects from the previous frame to the current frame. But since the time step between two frames is very small, the previous and current shadow volumes of moving objects can approximately cover all pixels that we want to mask. Figure 4.3 shows that we back trace positions of moving objects of the previous frame and generate shadow volumes of them, and do the same procedure for the current frame.

Notice that there is no need to compute all pixels in the current frame. We show all the scenes just for helping understanding. Figure 4.4 shows that we combine two stencil masks from Figure 4.3. This combined mask help indicate which pixels are needed to ray marching due to movements of objects. We then use it to compute pixels that are marked changed. Figure 4.5 shows that we combine the results from the previous frame and the current frame by updating red regions from the previous frame.

14

Figure 4.1 The whole scene with scattering effects

Figure 4.2 The mask of moving objects and the shadow volume

15

Experiments show this approximate strategy can handle all changed pixels expect the frame rate is slow. In some special cases, such as scenes with a lot of moving objects, scenes with sophisticated objects or moving objects covering almost all screen pixels, our algorithm can not perform well. The frame rates of these special cases are slow. Difference will become a little more obvious in these cases. Totally, the quality can remain the same. We capture the frames produced with our algorithm and the hybrid ray marching. The difference image of these two frames shows zeroes for all pixels if the frame rate is high. We notice that types of motion also affect the dynamic stencil mask. A linear motion will not lose pixels in general, but a rotate motion may leave some pixels out of the mask. We can handle this situation by updating whole frames with a definite number of frames. We call this number the reused frame number, and give more details in the following chapter. Using a large time step to build the mask is also a solution, but it will cause much overhead since more shadow volumes are needed.

16

Stencil mask from the previous frame Stencil mask from the current frame Previous frame

Current frame with blue objects moving to the right

Back trace moving objects and generate the shadow volume of them

Generate the shadow volume of moving objects

Figure 4.3 Generate shadow volumes of objects of the previous frame and current frame

17

Combine

Figure 4.4 Generate a stencil mask from the generated shadow volume

Stencil mask for regions that are needed to do actually ray marching

Ray marching for only red regions

18

Combine

Update red regions of the previous frame

Result

Figure 4.5 Combine results from the previous frame and current frame

19

Chapter 5

Implementation Detail

We develop our algorithm based on openGL and GLSL. Most jobs are stored as textures from different rendering passes and combined to get the rendering effects. Our temporally adaptive sampling technique dedicates to reducing samples by reusing ray marching results from the precious frame. Therefore, at least two rendering passes are added to the rendering system. One is for building a stencil mask and another is for combining the reusable parts and the actually recomputed parts.

5.1 Stencil Mask Setting

As Figure 4.4 (red parts) shows, our mask includes not only rasterization of moving objects and the shadow volume, but also the parts in the previous frame. This is done with stencil operations and stencil function sets. Stencil operations specify actions when stencil or depth tests pass or not. When building this mask, we do not need to consider about depth information and depth test is disabled. Stencil functions specify stencil tests that decide whether pixels pass the mask or not. During the rendering pass, all the changed parts of the screen will be set to non-zero in the stencil mask. Therefore we use GL_NOTEQUAL parameters to distinguish pixels which need ray marching.

After setting stencil operations and stencil functions, a shader is performed to generate a shadow volume of moving objects. We perform this shader twice separately for the current positions of moving objects and the same moving objects but with positions of the previous frame. Pixels with different ray marching results due to moving objects are then marked as non-zeroes in the stencil mask.

20

Note that as above mentioned, we store different rendering passes as different textures.

We use off-screen rendering techniques to do so. Frame buffer object of openGL is convenient to do this, but it is only a manager of memory to help us control off-screen render. Each render buffer should be created before it is used, such as depth buffer, stencil buffer and so on.

5.2 Combine Temporal Frame

Once we finish building the stencil mask, a texture with results of the changed parts can be generated, as shown in Figure 4.2. We need to compute the whole scene at least once and imagine it as background. Then a shader is applied to combine this background texture and the current changed part of the texture. Actually it is not necessary to process every pixel. We just take the background texture as render targets and process only pixels that are within the stencil mask.

The reused frame number should be taken into account with this combined strategy. We compute the whole scene per this reused frame number (see Figure 5.1). Assume the camera is fixed, we only need to compute the background texture once. We can get the best speedup in this case. That is, assume that we generate a background texture where whole pixels are considered taking 200ms and a texture with only pixels covered by stencil mask taking 50ms.

If we reuse the more frames, the closer to 50ms per frame we can reach (see Figure 5.2). In our case, we set the reused frame number to 3, because the stencil mask sometimes can not fully cover the regions that we want. If we set the reused frame number to more than a definite number, some unwanted colors would be accumulated and it produces obvious artifacts, as shown in Figure 5.3. Fortunately, 3 reused frames can achieve almost 70% of the best speed.

Figure 5.1 Reused frame number = n-1 Whole Figure 5.2 Relation between reused frame number

and frame rate for scene “dragon”

22

Figure 5.3 Artifacts when reused frame number exceeds a number. (a) Normal (b) with artifacts

(a)

(b)

23

Chapter 6

Results and Discussion

We run our algorithm on a PC with 3.33 GHz Core™ i7 CPU and 8.0GB of memory.

The graphics card is an NVDIA GeForce GTX 295. Table 6.1 shows the running time of our temporally adaptive sampling and of the hybrid ray marching. In most scenes, such as dragon, bunny and buddha, we can reach a definite speedup with almost the same quality. However, the speedup is coming from reusing ray marching results from the previous frame. Therefore, performance is directly proportional to moving objects and the shadow volume of the moving objects covering pixels. Moving objects of scenes “donuts & dragon” cover almost the whole scene, as shown as Figure 6.2. Therefore, there is no speedup due to reuse rare pixels. Figure 6.3 and Figure 6.4 gain more speedups due to less pixels are changed, which means that we reuse most parts of the previous frame. Figure 6.5 shows the scene bigScene. The speedup is not so obvious due to more moving objects. We generate the shadow volume of moving objects so that more objects will produce more overhead. Besides, the big dragon covers almost fifty percent of the screen. Figure 6.6 shows less speedup to scene yeahRight which is because of sophisticated model and the overhead of building shadow volumes making frame rate increasement limited.

There are three factors for affecting speedups: the number of moving objects, the stencil mask occupying pixels and the complexity of moving objects. All these factors exist when the performance of our algorithms becomes slow. As shown in Table 6.1, scene donuts & dragon is slow because of the number of moving objects and the stencil mask occupying pixels.

Scene bigScene is due to the number of moving objects and scene yeahRight is influenced by the complexity of moving objects. Generate a shadow volume for our stencil mask is an

24

important reason to these factors. We could improve this condition by a more efficient method to generate shadow volume of moving objects.

Scene Our approach (fps) Hybrid ray marching (fps)

dragon 46.08 35.24

bunny 59.93 44.73

buddha 58.76 41.63

donuts & dragon 41.32 43.31

bigScene 31.54 28.78

yeahRight 29.34 26.75

Table 6.1 Results of scenes

25

Figure 6.1 Scene “dragon”.

(a) 46.08 fps by our algorithm, (b) 35.24 fps by hybrid ray marching

(a)

(b)

26

(a)

Figure 6.2 Scene “donuts & dragon”.

(a) 41.32 fps by our algorithm, (b) 43.31 fps by hybrid ray marching (b)

27

Figure 6.3 Scene “bunny”.

(a) 59.93 fps by our algorithm, (b) 44.73fps by hybrid ray marching (a)

(b)

28

Figure 6.4 Scene “buddha”.

(a) 58.76 fps by our algorithm, (b) 41.63 fps by hybrid ray marching (a)

(b)

29

Figure 6.5 Scene “bigScene”.

(a) 31.54 fps by our algorithm, (b) 28.78 fps by hybrid ray marching (a)

(b)

30

Figure 6.6 Scene “yeahRight”.

(a) 29.34 fps by our algorithm, (b) 26.75 fps by hybrid ray marching (a)

(b)

31

Chapter 7

Conclusions and Future Work

In this thesis, we propose a temporally adaptive sampling method and actually reduce sample numbers needed. We achieve a definite speedup compared to [23] and we believe that more speedups can be reached if this method is adopted to ray marching techniques with better quality, because down-sampling has been done with the proposed rendering techniques.

Besides, this method can be easily integrated to other rendering techniques due to two rendering passes are needed only.

There are some limitations in our method. If moving objects and their shadow volumes cover too many pixels of the screen, speedup will be limited. And if the camera is keeping moving, there will be no pixels reusable. Therefore, we show a little speedup or no speedup in these cases. volumes cover over a definite percentage of the screen, we do not use this method.

32

References

[1] BARAN, I., CHEN, J., RAGAN-KELLEY, J., DURAND, F., AND LEHTINEN, J. 2010.

A hierarchical volumetric shadow algorithm for single scattering. ACM Transactions on Graphics 29, 5.

[2] BILLETER, M., SINTORN, E., AND ASSARSSON, U. 2010. Real time volumetric shadows using polygonal light volumes. In Proc. High Performance Graphics 2010.

[3] BIRI, V., ARQUES, D., AND MICHELIN, S. 2006. Real time rendering of atmospheric scattering and volumetric shadows. Journal of WSCG, 14:65-72.

[4] CHEN, J., BARAN, I., DURAND, F., AND JAROSZ, W. 2011. Real-Time volumetric shadows using 1D min-max mipmaps. In ACM Symposium on Interactive 3D Graphics and Games.

[5] DOBASHI, Y., YAMAMOTO, T., AND NISHITA, T. 2000. Interactive rendering method for displaying shafts of light. In Proc. Pacific Graphics, IEEE Computer Society, Washington, DC, USA, 31.

[6] DOBASHI, Y., YAMAMOTO, T., AND NISHITA, T. 2002. Interactive rendering of atmospheric scattering effects using graphics hardware. In Proc. Graphics hardware, 99–107.

[7] ENGELHARDT, T., AND DACHSBACHER, C. 2010. Epipolar sampling for shadows and crepuscular rays in participating media with single scattering. In Proc. 2010 ACM SIGGRAPH symposium on Interactive 3D Graphics and Games, ACM, 119–125.

[8] HACHISUKA, T., JAROSZ, W., WEISTROFFER, R, P., DALE, K., HUMPHREYS, G., ZWICKER, M., AND JENSEN, H, W. 2008. Multidimensional adaptive sampling and reconstruction for ray tracing. ACM Transactions on Graphics 27, 3.

[9] HU, W., DONG, Z., IHRKE, I., GROSCH, T., YUAN, G., AND SEIDEL, H.-P. 2010.

Interactive volume caustics in single-scattering media. In I3D ’10: Proceedings of the

33

2010 symposium on Interactive 3D graphics and games, ACM, 109–117.

[10] IMAGIRE, T., JOHAN, H., TAMURA, N., AND NISHITA, T. 2007. Anti-aliased and real-time rendering of scenes with light scattering effects. The Visual Computer 23, 9–11 (Sept.), 935–944.

[11] JAROSZ, W., ZWICKER, M., AND JENSEN, H. W. 2008. The beam radiance estimate for volumetric photon mapping. Computer Graphics Forum 27, 2 (Apr.), 557–566.

[12] JENSEN, H. W., AND CHRISTENSEN, P. H. 1998. Efficient simulation of light transport in scenes with participating media using photon maps. In Proc. SIGGRAPH 98, 311–320.

[13] LEFEBVRE, S. AND GUY, S. 2002. Volumetric lighting and shadowing.

http://www.aracknea-core.com/sylefeb/page.php?c=Shaders.

[14] MAX, N. L. 1986. Atmospheric illumination and shadows. In Computer Graphics (Proc.

SIGGRAPH ’86), ACM, New York, NY, USA, 117–124.

[15] MECH, R. 2001. Hardware-accelerated real-time rendering of gaseous phenomena.

Journal of Graphics Tools, 6(3):1-16.

[16] MITCHELL, K. 2008. Volumetric light scattering as a post-process. In GPU Gems 3, Addison-Wesley.

[17] NISHITA, T., MIYAWAKI, Y. AND NAKAMAE, E. 1987. A shading model for atmospheric scattering considering luminous distribution of light sources. In Proceedings of SIGGRAPH, pages 303–310.

[18] PEGORARO, V., AND PARKER, S. 2009. An analytical solution to single scattering in homogeneous participating media. Computer Graphics Forum 28, 2.

[19] PEGORARO, V., SCHOTT, M., AND PARKER, S. G. 2010. A closed-form solution to single scattering for general phase functions and light distributions. Computer Graphics Forum 29, 4, 1365–1374.

[20] PHARR, M., AND HUMPHREYS, G. 2004. Physically Based Rendering: From Theory

34

to Implementation. Morgan Kaufmann

[21] SUN, B., RAMAMOORTHI, R., NARASIMHAN, S., AND NAYAR, S. 2005. A practical analytic single scattering model for real time rendering. ACM Trans. Graph. 24, 3.

[22] SUN, X., ZHOU, K., LIN, S., AND GUO, B. 2010. Line space gathering for single scattering in large scenes. ACM Trans. Graph. 29, 4.

[23] WYMAN, C., AND RAMSEY, S. 2008. Interactive volumetric shadows in participating media with single-scattering. In Proc. IEEE Symposium on Interactive Ray Tracing, 87-92.

[24] WYMAN, C. 2011. Voxelized shadow volumes. ACM/EG Symposium on High Performance Graphics, 33-40.

相關文件