58
이화여자대학교 대학원 2007학년도 석사학위 청구논문 그래픽스 하드웨어를 이용한 효과적 가시화 컬링 지형 그림자 생성 연구 2 0 0 8

이용한 컬링 및 지형 그림자 생성 연구graphics.ewha.ac.kr/people/theses/HYEUNG.pdf · 및 지형 그림자 생성 연구 컴 퓨 터 정 보 통 신 공 학 과 민 혜

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

  • 2007

    2 0 0 8

  • 2008 1

  • i

    ...................................................................................................

    I ........................................................................................................ 1

    1.1 ..................................................................................... 1

    1.1.1 ................................................ 1

    1.1.1.1 .................................................... 3

    1.1.2 ............................................................................. 6

    1.1.3 ...................................................... 8

    1.2 ..................................................................................... 10

    II ............................................................................................... 12

    2.1 ..................................................................................... 12

    2.1.1 .............................................................................. 12

    2.1.2 .................................................................... 14

    2.2 ..................................................................................... 15

    2.2.1 ............................................................... 15

    2.2.2 ............................................................ 16

    III .................... 18

    3.1 ..................................................................... 18

    3.1.1 ......................................................................... 20

    3.1.2 .............................................................................. 21

    3.1.3 .................................................................. 23

    IV ..................... 25

    4.1 ....................................................................... 25

    4.1.1 .................................................................................. 26

    4.2 ......................................................................... 29

    V ......................................................................................... 32

    5.1 ................................ 32

    5.2 ..................... 36

    VI ...................................................................................................... 40

  • ii

    6.1 ......................................................... 40

    6.2 ............................................... 40

    .................................................................................................... 42

    ABSTRACT.............................................................................................. 47

  • iii

    1-1 ................................... 3

    1-2 ..................................................... 5

    1-3 LOD ................................ 8

    1-4 .............................................................................. 9

    3-1 ............................................................................ 19

    3-2 ................................................................ 21

    3-3 ............................................................................. 22

    3-4 ...................................................... 24

    4-1 ...................................................................... 27

    5-1 ......................................................................... 33

    5-2 ..................................................... 34

    5-3 ................................................. 35

    5-4 .......................................................... 36

    5-5 .............................................................................. 38

    5-6 .......................................................... 39

  • iv

    5-1 ............................................................

    34

    5-2 ............................................................ 37

    4-1 ..................................................................

    28

    4-2 ........................................................... 31

    4-1 ......................................................................................... 29

  • v

    (GPU)

    (rasterization) CAD

    (visibility culling)

    (shadow map) .

    CAD

    ,

    (arrangement) .

    ,

    (directed distance field) GPU ,

    (fast marching method)

    (outer envelope) .

    (self-shadow)

    GPU (occlusion query) (ray-tracing)

    .

    3

    CAD , 70%

    , nVIDIA GeForce 7900GX2 Dual

  • vi

    AMD Athlon 64 2.6GHz PC 6.5 .

    1024 1024 (height map)

    nVIDIA GeForce 6800 AMD Athlon 64 2.2GHz PC 7.32

    .

  • 1

    I

    1.1

    1.1.1

    ,

    (animation), (virtual reality)

    . 3

    . 3

    (GPU)

    , GPU

    . PC GPU

    TV,

    , .

    3 3 .

    (application stage), (geometry stage),

    (rasterization stage)[35].

    , 3D .

  • 2

    (transformation) . (primitive)

    .

    (frame buffer)

    .

    1990 1 GPU

    . 1990 2000 2 GPU

    . 2000 3 GPU

    (pixel shader)

    (vertex shader) .

    GPU

    . GPU

    cg[35], HLSL[36], GLSL[37] C

    (shading language) ( 1-1).

    (unified shader) GPU

    [38].

  • 3

    1-1

    1.1.1.1

    GPU

    , (interpolation) , (texture)

    .

    (fragment) . 1-2 GPU

    . (scissor test)

    .

    (alpha test) .

  • 4

    .

    .

    (stencil test) . (stencil buffer)

    . (depth test, Z test) .

    (depth buffer)

    .

    , ,

    . GPU

    (occlusion query) .

    .

    . GL_LEQUAL

    0 (occluder)

    .

    0 , .

    (color buffer)

    (alpha blending) .

  • 5

    (depth buffering)

    .

    1-2

  • 6

    1.1.2

    , ,

    .

    .

    (model simplification)[11], LOD(level of detail) [14],

    (visibility culling)[16] .

    .

    CAD CAD

    ,

    .

    .

    ,

    .

  • 7

    .

    .

    , [15].

  • 8

    1.1.3

    (terrain) , , GIS(geographic information

    system), (flight simulation)

    .

    2 .

    .

    LOD

    [41] . LOD

    ( 1-

    3).

    1-3

    LOD [41]

  • 9

    ,

    ( 1-4)[19].

    (shadow map)[20], (ray-

    tracing)[28,29], (shadow polygon)[30], (shadow

    volume)[31] .

    .

    .

    .

    1-4

    . () ()

    [39]

  • 10

    1.2

    GPU

    .

    CAD

    . , GPU

    (bounding box)

    ,

    .

    .

    ,

    .

    . ,

    GL_GREATER

    . 1

  • 11

    .

    (image precision) .

    .

    cg

    .

  • 12

    II

    2.1

    2.1.1

    (visibility)

    , , [3].

    [16].

    ,

    .

    .

    . (back-face culling)

    , (viewing-

    frustum culling) .

    [2,13].

    (potentially visible set, PVS) [6,18]. PVS

  • 13

    (conservative visibility) .

    PVS

    [5]. PVS

    [4],

    [7], [8] .

    3

    [1,9,17,18].

    Ernst [15]

    3 .

    ,

    .

    Monte Carlo

    ,

    .

  • 14

    2.1.2

    (open cell) (decomposition)

    [10].

    , 3 ( log +

    log ) [10].

    (vertical decomposition) ,

    , , Davenport-Schinzel .

    3

    .

  • 15

    2.2

    Woo

    [19]. (image

    precision method) (object presicion method)

    .

    2.2.1

    (depth image)

    [20].

    GPU [21,22].

    (aliasing)

    . (edge) ,

    (perspective aliasing) (projective aliasing)

    [23].

    . . Reeves

    (percentage closer-filtering)

    [24]. Brabec

  • 16

    [25].

    (adaptive shadow map) [26].

    .

    [27].

    (perspective

    shadow map) [23].

    (ray-

    tracing) . PCs

    [28,29].

    GPU

    [38].

    2.2.2

    . Blinn

    (shadow polygon)

  • 17

    [30].

    .

    (shadow volume)

    [31].

    .

    . BSP

    [32,33].

    . Heidmann

    [34].

  • 18

    III

    GPU

    .

    CAD

    .

    , GPU ,

    .

    , .

    3.1

    ( 3-1).

  • 19

    .

    .

    ,

    [12].

    3 .

    1 GPU

    . 2

    3-1

    : 5 2

    c1, c2, c3, c4 .

    , .

  • 20

    .

    3

    , .

    3.1.1

    (distance field) 3 ( )

    , .

    (directed distance field)

    x-, x+, y-, y+, z-, z+ .

    ,

    2 .

    ,

    . GPU

    2 . ,

    ( 3-2).

  • 21

    2

    .

    ,

    .

    3.1.2

    ,

    .

    3-2

    : A

    D

    A .

    B A

    .

  • 22

    / .

    (front) (front

    propagation) ( 3-3).

    3

    , ' (K)',

    ' (T)', ' (F)' ,

    .

    T. /

    , .

    :

    3-3

  • 23

    1.

    K . P .

    2. P Q . Q K

    , P P Q

    . P Q

    . Q Q

    . Q .

    3. 1-2

    .

    / .

    3.1.3

    ,

    / ( 3-3).

    .

    ( 3-4),

    .

  • 24

    4

    .

    ,

    ,

    .

    3-4

    : A, C

    .

  • 25

    IV

    GPU

    .

    .

    GPU

    .

    . 1

    GPU

    ,

    . 2

    .

    4.1

    ,

  • 26

    . (directional light),

    (spot light), (point light)

    .

    4.1.1

    ,

    .

    (

    4-1). GPU

    .

    .

    GL_LEQUAL 0

    (occluder) .

    0 ,

    .

    GL_GREATER

  • 27

    . 1

    .

    ( 4-1).

    4-1

    : A C

    . B

    h

    .

  • 28

    glDepthMask(GL_FALSE);

    glDepthFunc(GL_GREATER);

    for (int X=0; X < MAP_SIZE; X += STEP_SIZE )

    for (int Y=0; Y < MAP_SIZE; Y += STEP_SIZE )

    {

    int x, y, z;

    x = X;

    y = Y;

    z = Height(pHeightMap, X, Y );

    glBeginOcclusionQueryNV(occlusionQueries[0]);

    glBegin (GL_LINES);

    glVertex3i(x, y, z);

    glVertex3f( lightPosition[0], lightPosition[1], lightPosition[2] );

    glEnd();

    glEndOcclusionQueryNV();

    glGetOcclusionQueryuivNV(occlusionQueries[0],

    GL_PIXEL_COUNT_NV, &pixelCount);

    if(pixelCount >= 1) fprintf(opFile_shadow, "%d\n", 1);

    else if (pixelCount == 0 ) fprintf(opFile_shadow, "%d\n", 0);

    }

    glDepthMask(GL_TRUE);

    glDepthFunc(GL_LEQUAL);

    4-1

    :

    .

  • 29

    4.2

    . (diffuse)

    (specular)

    ( 4-1).

    = + +

    = + + ( )

    ambient intensity

    N surface normal L light source direction

    H = (L+V)/|L+V|

    V view direction

    4-1

    3D cg

    (cg vertex program)

    ( 4-4).

  • 30

    void VertexLight(float4 position : POSITION,

    float3 normal : NORMAL,

    out float4 oPosition : POSITION,

    out float4 color : COLOR,

    uniform float4x4 modelViewProj,

    uniform float3 globalAmbient,

    uniform float3 lightColor,

    float3 lightPosition,

    float3 eyePosition,

    float3 Ka,

    float3 Kd,

    float 3 Ks,

    float shininess )

    {

    oPosition = mul(modelViewProj, position);

    float3 P = position.xyz;

    float3 N = normal;

    float3 ambient = Ka * globalAmbient;

    float3 L = normalize(lightPosition - P);

    float diffuseLight = max(dot(N, L), 0);

    float3 diffuse = Kd * lightColor * diffuseLight;

    float3 V = normalize(eyePosition - P);

    float3 H = normalize(L + V);

    float specularLight = pow(max(dot(N, H), 0), shininess);

    if (diffuseLight

  • 31

    color.xyz = ambient + diffuse + specular;

    color.w = 1;

    }

    4-2

    : Kd

    Ks , (ambient)

    .

  • 32

    V

    GPU

    .

    , , .

    5.1

    Microsoft

    Visual C++.Net OpenGL, OpenSG , nVIDIA

    GeForce 7900 GX2 Dual AMD Athlon 64 2.6GHz

    PC .

    ( 5-1).

  • 33

    5-1

    . (). 247 , 3 ().

    7177 , 2 7

    5-2, 5-3 ,

    , (

    ) . 247

    , 3

    128 175 71%

    . 7177 , 2 7

    64

    5915 82% ( 5-1).

  • 34

    (247 ,

    3 )

    128 175 71% 3.42 0.05

    256 170 69% 6.59 0.10

    (7177 ,

    2 7 )

    64 5915 82% 1.85 0.05

    128 4611 64% 4.26 0.40

    5-1

    5-2

    . () 64 ()

    128

  • 35

    5-3

    .

    . () 128 () 128

    () 256

  • 36

    5.2

    Microsoft Visual

    C++.Net OpenGL , cg ,

    nVIDIA GeForce 6800 AMD Athlon 64 2.2GHz

    PC .

    256 256, 512 512, 1024 1024 (

    5-4).

    5-4

    5-5, 5-6 ,

    , , ,

  • 37

    . 256 256

    0.50 , 512 512 1.81 , 1024 1024

    7.32 CPU

    5 ( 5-2).

    CPU

    GPU

    256 2.39 0.50

    512 9.56 1.81

    1024 38.24 7.32

    5-2

    0

    10

    20

    30

    40

    50

    256 512 1024

    (

    )

    GPU

    CPU

  • 38

    5-5

    . () () ()

  • 39

    5-6

    . () () (

    ) ()

  • 40

    VI

    6.1

    .

    (visibility ordering) .

    GPU

    .

    .

    6.2

    GPU

    , CPU

  • 41

    .

    (view frustum culling) ,

    (vertex buffer object) (shadow ray

    optimization), (multi-resolution)

    .

  • 42

    [1] J. M. Airey, J. H. Rohlf and Frederick P. Brooks, Jr, Towards

    image realism with interactive update rates in complex virtual

    building environments, In Computer Graphics(1990 Symposium on

    Interactive 3D Graphics), volume 24, pages 41-50, March, 1990.

    [2] U. Assarsson and T. Moller, Optimized view frustum culling

    algorithms for bounding boxes, Journal of Graphics Tool, 5(1):9-

    22, 2000.

    [3] D. Cohen-Or, Y. Chrysanthou and C. Silva, A Survey of Visibility

    for Walkthrough Applications, In IEEE Transaction on

    Visualization and Computer Graphics, 2002.

    [4] F. Durand, G. Drettakis, J. Thollot and C. Puech, Conservative

    Visibility Preprocessing using Extended Projections, In ACM

    SIGGRAPH, pages 239-248, 2000.

    [5] J. El-Sana, E. Azanli and A. Varshney, Integrating occlusion

    culling with view-dependent rendering, In IEEE Visualization,

    2001.

    [6] N. Govindaraju, B. Lloyd, S. Yoon, A. Sud and D. Manocha,

    Interactive Shadow Generation in Complex Environments, In ACM

    SIGGRAPH/ACM Trans. Graphics, volume 22, pages 501-510,

    2003.

    [7] N. Govindaraju, A. Sud, S.-E. Yoon and D. Manocha, Parallel

    Occlusion Culling for Interactive Walkthroughs using Multiple

    GPUs, Technical report, Univ. of North Carolina at Chapel Hill,

    2002.

    [8] N. Govindaraju, A. Sud, S.-E. Yoon and D. Manocha, Interactive

    visibility culling in complex environments using occlusion-

    switches, In ACM SIGGRAPH Symposium on Interactive 3D

  • 43

    Graphics, 2003.

    [9] N. Greene, M. Kass and G. Miller, Hierarchical z-buffer visibility,

    In Proceedings of SIGGRAPH 93, pages 231-240,1993.

    [10] D. Halperin, Handbook of Discrete and Computational Geometry,

    chapter 21, pages 389-412, CRC Press LLC, Boca Raton,

    FL.1997.

    [11] H. Hoppe, Progressive Meshes, In Proceedings of SIGGRAPH,

    pages 99-108, 1996.

    [12] Y. J. Kim, G. Varadhan, M. C. Lin and D. Manocha, Fast Swept

    Volume Approximation of Complex Polyhedral Models, In ACM

    Symposium on Solid Modeling and Applications, pages 11-22,

    Seattle, Washington, 2003.

    [13] S. Kumar, D. Manocha, W. Garrett and M. Lin, Hierarchical back-

    face computation, Computers and Graphics, 23(5):681-692,

    October, 1999.

    [14] D. Luebke, M. Reddy, J. Cohen, A. Varshney, B. Watson and R.

    Huebner, Level of Detail for 3D Graphics, Morgan Kaufmann as

    part of their series in Computer Graphics and Geometric

    Modeling, 2003.

    [15] E. Manfred, F. Firsching and R. Grosso, ENTKERNER: A System

    for Removal of Globally Invisible Triangles from Large Meshes, In

    Proceedings of 13th International Meshing Roundtable, 2004.

    [16] T. Moller and E. Haines, Real-Time Rendering, chapter 7, A.K.

    Peters Ltd, 1999.

    [17] S. Teller, Visibility Computations in Densely Occluded

    Environments, PhD thesis, Univ. of California, Chapel Hill, 1991.

    [18] S. J. Teller and C. H. Sequin, Visibility preprocessing for

    interactive walkthroughs, Computer Graphics (Proceedings of

    SIGGRAPH 91), 25(4):61-69, July, 1991.

  • 44

    [19] A. Woo , P. Poulin , A. Fournier, A Survey of Shadow Algorithms,

    IEEE Computer Graphics and Applications, 10(6):13-32,

    November, 1990.

    [20] L. Williams, Casting curved shadows on curved surfaces, In

    Computer Graphics (SIGGRAPH '78 Proceedings), volume 12,

    pages 270-274, August 1978.

    [21] M. Segal, C. Korobkin, R. van Widenfelt, J. Foran, and P. Haeberli,

    Fast shadows and lighting e ects using texture

    mapping, In Computer Graphics (SIGGRAPH '92 Proceedings),

    volume 26, pages 249-252, 1992.

    [22] W. Heidrich, H. P. Seidel, Realistic hardware-accelerated shading

    and lighting, In Proc. of ACM SIGGRAPH, 171-178, 1999.

    [23] M. Stamminger, and G. Drettakis, Perspective shadow maps, In

    Proceedings of ACM SIGGRAPH 2002, pages 557-562, 2002.

    [24] W. Reeves, D. Salesin, and R. Cook, Rendering antialiased

    shadows with depth maps, In Computer Graphics (ACM

    SIGGRAPH '87 proceedings), volume 21, pages 283-291, 1987.

    [25] S. Brabec, T. Annen, and H. Seidel, Hardware-accelerated

    rendering of antialiased shadows, In Proc. of Computer Graphics

    International, 2001.

    [26] R. Fernando, S. Fernandez, K. Bala, and D. Greenberg, Adaptive

    shadow maps, In Proceedings of ACM SIGGRAPH 2001, pages

    387-390, 2001.

    [27] K. Tadamura, X. Qin, G. Jiao, and E. Nakamae, Rendering optimal

    solar shadows with plural sunlight depth buffers, The Visual

    Computer 17(2), 2001.

    [28] I. Wald, P. Slusallek, and C. Benthin, Interactive distributed ray-

    tracing of highly complex models, In Rendering Techniques, pages

    274-285, 2001.

    [29] S. Parker, W. Martic, P. Sloan, P. Shirley, B. Smits, and C. Hansen,

    Interactive ray tracing, Symposium on Interactive 3D Graphics,

  • 45

    1999.

    [30] J. Blinn, Jim blinn's corner: Me and my (fake) shadow, IEEE

    Computer Graphics and Applications 8(1):82-86, January, 1988.

    [31] F. Crow, Shadow algorithms for computer graphics, volume 11,

    pages 242-248, 1977.

    [32] N. Chin, and S. Feiner, Near real-time shadow generation using

    BSP trees, In Computer Graphics (SIGGRAPH '89 Proceedings),

    volume. 23, pages 99-106, 1989.

    [33] Y. Chrysanthou, and M. Slater, Shadow volume BSP trees for

    computation of shadows in dynamic scenes, In 1995 Symposium

    on Interactive 3D Graphics, pages 45-50, 1995.

    [34] T. Heidmann, Real shadows real time, IRIS Universal volume 18,

    1991.

    [35] W.R. Mark, R.S. Glanville, K. Akeley, and M.J. Kilgard, Cg: A

    System for Programming GraphicsHardware in a C-like Language,

    ACM Transactions on Graphics, 22(3):896-907, July, 2003.

    [36] Microsoft HLSL, http://msdn2.microsoft.com/en-

    us/library/bb509638.aspx

    [37] The OpenGL Shading Language,

    http://www.opengl.org/registry/doc/GLSLangSpec.Full.1.20.8.pdf

    [38] V. Moya, C. Gonzalez, J. Roca, A. Fernandez, and R. Espasa,

    Shader Performance Analysis on a Modern GPU Architecture,

    Microarchitecture, MICRO-38. Proc. 38th Annual IEEE/ACM Intl

    Symp., 2005.

    [39] M. J. Kilgard, Interactive Geometric Computations Using Graphics

    Hardware, SIGGRAPH '02 Course 31, 2002

    [40] M. Marghidanu, Fast computation of terrain shadow maps,

    http://www.nervus.org, 2000

    http://www.nervus.org/
  • 46

    [41] D. Koller and P. Lindstrom, Real-Time, Continuous LOD

    Rendering of Height Fields, Siggraph 1996, pages 109-118,

    August, 1996.

  • 47

    ABSTRACT

    This dissertation addresses how one can exploit the fast rasterization

    and visibility functions available in graphics hardware (GPU) for efficient

    visibility culling for large CAD model and shadow generation for a large

    terrain model.

    The goal of our visibility culling is to remove the invisible triangles of a

    CAD model, consisting of millions of triangles, when the camera is located

    outside of the given model. We pose this problem as arrangement

    computation, and the arrangement of the given model is approximated by

    generating the directed distance field of the given model by using GPU

    and finding the outer envelope by fast marching method. From our

    experimentation, we could cull away more than 70% of hidden geometry

    by using our algorithm, taking 6.3 seconds on nVIDIA GeForce 7900GX2

    for a large CAD model consisting of three millions of triangles.

    Furthermore, we also compute shadow map for a large terrain model by

    combining ray tracing with GPU-supported occlusion query. The shadow

    map generation took 7.31 seconds for 10242 height map on nVIDIA

    GeForce 6800.

  • 48

    ,

    .

    , , , , ,

    , , , , ,

    , , .

    , , , ,

    ,

    .

    Virtual Builders

    , VB .

    ,

    , , VR ,

    .

    ,

    , .

    , .

  • 49

    , . ...

    , .

    .

    . .