SlideShare a Scribd company logo
1 of 74
Texturering & Modeling
                 a Procedual Approach



               김정근
Chapter 13
Real-time Procedural Solid Texturing
Agenda
  A Real-time Procedural Solid Texturing Algorithm

   Creating an Atlas For Procedural Solid Texturing

                           Avoiding Seam Artifacts

    Implementing Real-Time Texturing Procedures

                                      Applications

                                Acknowledgments


                                                  3
Introduction
Procedural Solid Texturing는
           production-quality image 로 통합할 때 아주 막강한 툴


            유저로 하여금 반복되지 않는 산들과 해안지대들,

              구름들로 만들어진 세계를 탐험할 수 있게 함

            불이나 폭발같은 동적으로 움직이는 Texture들은

            Procedural Texture 를 이용해 효율적으로 나타냄

     나무나 돌처럼 medium 으로 Texture 된 것으로 부터 조각된 물체들은
             Solid texturing 을 이용해서 Texturing 할수 있음

     Solid texturing 은 Surface을 Parameter로 나타낼 필요가 없기 때문에

                   Surface Texturing 보다 더 쉬움
                                                            4
Introduction
하지만 Procedural Solid Texturing는


  “장점 대부분이 Production-Quality Scene의
    오프라인 렌더링에만 제한되어 왔다 ”




                                       5
Introduction
 현재의 Procedural Solid Texturing는
    “Programmable Shading Hardware의 등장으로
게임과 가상환경에서 리얼타임 그래픽 요소의 유용한 툴이 됨”

      “작고 조밀해서 필요할때마다 통합 가능”

   “비디오게임과 가상환경에 추가 용량이 거의 없이
     방대한 Texture Variations 을 제공할 수 있다.”


                                           6
Introduction
이 챕터에서는

   “현재 그래픽 프로그래밍 라이브러리에서
     이미 사용할만한 특징을 이용해서
 리얼타임 시스템에 Procedural Solid Texturing 을
       어떻게 통합할 것인지를 기술”


    “기술을 이용해 실시간 피드백을 가지고
    인터렉티브한 Procedural Solid Texturing
    설계 시스템을 만드는데 사용하는 방법”

                                          7
A Real-time
Procedural Solid Texturing Algorithm

Renderman 기술을 기반
Surface Shading을 하는데 Texture Map을 허용함


모델의 구성
각각의 vertex가 좌표 축 3개로 구성되어 있다고 가정
Vertex 의 공간좌표 x, y, z는 모델(로컬) 스페이스에서의 vertex 위치를 의미
Vertex 의 u,v Parameter는 2D Texture Map 에서의 vertex 위치를 의미

Vertex 의 Solid Texture Coordinate 인 s, t ,r 은
3D Procedural Texture Space 에서 Vertex 가 어디로부터 Vertex Color 와
그 외 Shading정보를 얻어오는 지를 의미



                                                               8
A Real-time
Procedural Solid Texturing Algorithm

공간좌표와 Solid Texture 좌표들이 주어지면 자동
으로 Parameter들을 구축

종종 Solid Texture 좌표들은 공간좌표와 그냥 동일
한것으로 세팅하기도 하며 이 알고리즘은 공간좌표
만 주어져도 물체에 Texture를 입힐 수 있다
이 알고리즘은 Rasterization, Procedural
Evaluation그리고 Texture Mapping중일 때 동작할
것이다
                                        9
래스터라이즈?                                 A Real-time Procedural Solid Texturing
Algorithm




  물체의 Polygon들을 Texture Map에 기록하는 것
                 Vertex 들 좌표를 가지고 u, v 로 Parameter화하고
     Vertex 들의 Color (R=s, G=t, B=r) 를 가지고 Solid Texture Coordinate를 만든다




  그래픽 하드웨어는 오랫동안 Polygon 면에서
  Linear interpolation 을 지원, 예를 들어 Gouraud shading
               Texture Map 에 레스터라이즈된 Polygon 면들에 걸쳐
                   Solid Texture coordinate들을 자동으로 계산



                                                                                 10
래스터라이즈          A Real-time Procedural Solid Texturing Algorithm




  For each polygon p
        Begin polygon
        For each vertex i
               Color(p[i].str)
               Vertex(p[i].uv)
        End polygon
  Save image as texture map tex




                                                                   11
Procedural Evaluation
A Real-time Procedural Solid Texturing Algorithm




     Texture Map에서 모든 Pixel에 걸쳐 진행하고,
      Pixel의 RGB color 로 저장된 Solid Texture
               Coordinate (s,t,r)상에서
           Procedural으로 Texturing을 평가

            이 평가를 통해 Solid Texture space 상의 점(s,t,r)에서의 Texture 를
                  대표해주는새로운 RGB color 가 나올 것이며
              이 새로운 RGB color 는 Solid Texture coordinate에 대응하는
                     Procedural Texture color 로 덮어써서
                      Texture Map에서 현재 pixel 에 저장


                                                                    12
Procedural Evaluation
A Real-time Procedural Solid Texturing Algorithm




       For each pixel (x, y) in the Texture Maptex
             tex[x, y]=proc(tex[x, y])




                                                     13
Texture Mapping
A Real-time Procedural Solid Texturing Algorithm




                   물체의 u,v Parameter를 이용한
                     표준 Texture Mapping을
                   통해 물체위의 Texture를 위치
                  물체가 그려질때, 물체의 Polygon vertex 들의 공간좌표는
                       그래픽스 파이프라인을 걸쳐 지나간다




                 Polygon은 Polygon의 u,v Parameter와 interpolate 되어 Rasterization


                        Texture Map에 저장된 Procedural Solid Texture 로부터
                       Pixel 과 Mapping되는 지를 체크해서 Polygon에 Texturing

                                                                                 14
Texture Mapping
A Real-time Procedural Solid Texturing Algorithm




                      Set Texture Map totex
                      For each polygon p
                            Begin polygon
                            For each vertexi
                                   TexCoord(p[i].uv)
                                   Vertex(p[i].xyz)
                            End polygon




                                                       15
A Real-time Procedural
Solid Texturing Algorithm




                            16
A Real-time Procedural
Solid Texturing Algorithm


    이 기술이 동작하기 위해, 물체 표면상에 있는
         Polygon들은 overlap하지 않고
       Texture Map에 놓여질 필요가 있다



     이러한 Texture Mapping이   atlas
                                    17
A Real-time Procedural
Solid Texturing Algorithm

          atlas 구축단계는 이전 알고리즘에 선처리로 수행되고
              한 물체에 대해 한번만 계산될 필요가 있다

     모델은 일반적으로 Texture Map에 평평하게 놓이게 되는 순서에 따라 하
                  나 이상의 삭감이 필요하다.

     이러한 삭감은 Texture의 불연속으로 Seam이 보이는 결과를       발
                      생할 수 있다.


    일부 Texture 레이아웃 기법이 seam의 수와 길이의 감소에 초점을 맞췄다.




                                 “Avoiding Seam Artifacts” 에서…
                                                          18
A Real-time Procedural
Solid Texturing Algorithm


래스터화 및 Texture 매핑 단계 모두 하드웨어 가속이 되며
   Procedural 평가 단계에서는 병목현상이 있음




                                  19
Creating an Atlas
For Procedural Solid Texturing




                 Perlinnoise 기능을 바탕으로 이들
           특히 Procedural Texture의 효율적인 구현
                                        을
                         위한 몇 가지 기법을 설명
                                      20
Creating an Atlas
For Procedural Solid Texturing
아틀라스 기법의 다양함
 Texture Atlas를 만들기 위해 개발, 이러한 기술의 일부는 자동으로 표면에
 2 차원 Texture를 추가하기 위해 Object를 Parameter화하기 위해 개발


왜곡을 최소화
 Texture Map 이미지의 비율은 합리적으로 Texture 표면에 재현

 Texture Map에서 Pixel당 저장된 Solid Texture coordinate 로부터
 Texture를 계산하기 때문에 Atlas의 왜곡은
 Procedural Solid Texture 의 비율에 영향을 주지 않음


distortion 의 Scaling 컴포넌트는 stretch (Sander et al. 2001) 또는 상대
크기 (Carr 과 Hart 2002)처럼 다른 곳에서의 다양한 형태의 분량을 재는
     것은 Object 표면에 걸쳐 Sample의 분포에 영향을 줄 수 있다.
                                                           21
Creating an Atlas
For Procedural Solid Texturing

레스터화는..
Solid Texture Coordinate 로 Texture Map의 Pixel을 채우고 있기 때문에, Texture Map에서
서로 상대적인 Triangle의 위치가 부적절하게 만들 수 있음


Object의 인접한 Triangle은 Texture Map의 근처가 필요치 않음.


크게 Texture Atlas에서 Triangle을 평면 배치하는 과정을 단순화


가능한 한 사용 가능한 Texture Pixel만큼을 사용하려면,
전체 Texture Map에 걸쳐 Mesh에 Triangle을 배치




                                                                    22
Creating an Atlas
For Procedural Solid Texturing




           “매우 똑바른 방법으로 Pack 된
        이등변의 축 정렬된 직각 Triangle 행으로 구
                   성”                  23
Creating an Atlas
For Procedural Solid Texturing


     균일한 크기의 Texture Map Triangle으로 모든 Object Triangle을 평면배
            치 하는 것은 Texture Sample을 잘 분배하지 않는다.


      대형 Object Triangle은 작은 Triangle Object보다 더 많이 Procedural
     Solid Texture Sample이 있어야 하지만, 균일한 Mesh Atlas는 Triangle에
                     게 Sample의 같은 번호를 할당

     이것은 작은 Triangle에게 너무 많은 Texture Sample을 제공함으로써 큰
    Triangle에게 고르지 않는 Texture 아티펙트와 일반적으로 Texture 공간의
                         낭비가 발생할수 있음



             “매우 똑바른 방법으로 Pack 된 이등변의
              축 정렬된 직각 Triangle 행으로 구성”
                                                                 24
Creating an Atlas
For Procedural Solid Texturing




  “Strip 당 Triangle의 크기를 변화하여 물체의 표면에 걸쳐 고르게 사용
     가능한 Texture Sample을 분배하여 균일한 Mesh Atlas을 조정”

                                                    25
Creating an Atlas
For Procedural Solid Texturing


     증가하지 않는 영역의 알맞은 Texture Map안에 Triangle을 가늘게 Pack



     Texture 영역에 대한 표면적의 비율로 균일 규모 계수를 추정하고 각 수평
       Strip으로 Triangle의 크기를 설정하기 위해 이 Scale factor 를 사용.


     각 수평 Strip의 Texture Map 삼각 관계의 모든 Texture Sample을 낭비하
                    지 않도록 동일한 크기로 설정


  “Strip 당 Triangle의 크기를 변화하여 물체의 표면에 걸쳐 고르게 사용
     가능한 Texture Sample을 분배하여 균일한 Mesh Atlas을 조정”

                                                             26
Creating an Atlas
For Procedural Solid Texturing

     Area-Weighted Mesh Atlas를 사용하여 Procedural Solid Texture와 음형
                        형태의 Sample을 보여줌


    Triangle의 Strip당 사이즈 는 표면 전체 Texture Sample을 2에 n승에 가깝
        게 정량화된 또 다른 면적 가중 레이아웃보다 더 균등하게 준비


     면적 가중 Mesh가 낭비되는 Texture Sample의 고르지 않는 Edge를 가지
     고 있는 반면 이 테크닉은 더 쉽게 Texture Map을 작성하는 경향이 있다.


  “Strip 당 Triangle의 크기를 변화하여 물체의 표면에 걸쳐 고르게 사용
     가능한 Texture Sample을 분배하여 균일한 Mesh Atlas을 조정”

                                                                   27
또 다른 기술
Creating an Atlas For Procedural Solid Texturing




Maruya (1995)
  블록과 같은 균일한 Mesh Atlas의 Triangle을 취급하고
  2에 n승에 가깝게 정량화된 크기의 다양한 Triangle으로 이러한 블록을 Pack


Rioux, Soucy, and Godin (1996)
  사각형 블록 (2에 n승에 가깝게 정량화된)에 유사한 크기의 Triangle 이점과 이러한 블록을 Pack


Battke, Stalling, and Aege (1996)
  Texture Map에 견고하게 Strip을 Pack


Cignoni et al. (1998)
  유사한 Strip을 Pack 했지만 적당히 같은 Triangle은 제거




                                                       28
Skinny triangles
Creating an Atlas For Procedural Solid Texturing




 “Skinny Triangle의 상당수가 있는 Mesh는 가중면적 Atlas를
 사용하는 일부 Texture를 blockiness하게 보여질수 있음”



              Length-Weighted atlas
   Texture Map에 그 이미지의 크기를 set 하는 Triangle의 서피스 영역을 사
         용하는 대신에 Triangle의 가장 긴 가장자리의 길이를 사용

    Mesh의 긴 가장자리가 최대의 Sample을 얻을 것을 보장하지만 Skinny
   Triangle을 oversample하는 경향이 있어 다른 영역이 사용가능한 Sample
                          의 수를 줄여줌


                                                        29
MIP Mapping
Creating an Atlas For Procedural Solid Texturing



Sander et al. (2001)
  Triangle의 영역을 한 무리로 모으고 Atlas 안에 이 Cluster를 pack
  Cluster 사이의 영역은 MIP Mapping 될수 있으며 “합리적인” 색상으로 채워짐



Carr and Hart (2002)
  반드시 인근 아니라, 지역, 인접한의 계층 구조로 Triangle을 pack하기 위한
  MIP 매핑의 일부 속성을 사용




                                                       30
MIP Mapping
Creating an Atlas For Procedural Solid Texturing




         주어진 MIP Map 레벨에서 같은 사분면에 Mesh Triangle의 인접한
                 클러스터를 매핑한 인접한 MIP Map의 예


                                                       31
Avoiding Seam Artifacts


           Texture Filtering을 하다 보면,
   Texture Map내의 잘못된 Polygon 이미지로부터
  그려진 Polygon 경계 근처를 Sampling할 수도 있다

         Triangle 주변에서 Sampling했다면 심각하지는 않지만
     Polygon 주변을 무시하고 있기 때문에 이런 상황에 기댈 수 없다.




                                               32
Avoiding Seam Artifacts




 (a) Texture들은 하나의 pixel 배열로 저장된다
 (b) nearest-neighbor filter (제일 가까운 근방 필터) 를 사용하면 Sampling한 위치
 에서 가장 가까운 pixel color 를 준다.
 (c) 그 결과 seam artifact 가 발생한다. 밝은 Triangle color 가 어두운 Triangle의
 Sampling 영역에 새어 들어 간 것을 볼 수 있다.


                                                                    33
Avoiding Seam Artifacts


 Texture Map내에서 Triangle들을 Sampling이 정확하게
          될 수 있도록 위치시킬 필요가 있다


이 문제의 해결책은 Triangle의 빗변을 공유하는 부분에 수평
      으로 한 개 의 pixel 로 offset 을 주는 것
        (Rioux, Soucy, and Godin 1996)



                                            34
Avoiding Seam Artifacts




(a)세 vertex 들 (−0.5,−0.5), (5.5,−0.5),(−0.5, 5.5) 들로 이루어진 더 확장된 어두운
Triangle과 (0.5, 4.5), (5.5,−0.5), (5.5, 4.5) 로 이동된 밝은 Triangle을 레스터라이즈

(b) 각각의 Triangle에 주어진 pixel 수만큼 새로운 Triangle들을 Rasterization한것을
Shading
(c) 어두운 Triangle의 Texture 좌표 u, v 는 안 바뀐 상태이므로, 오버스캔된 Rasterization
로부터 더 작은 Triangle을 적당하게 Sampling

(d) 밝은 Triangle은 이동된 위치로부터 동일하게 Sampling
                                                                         35
Avoiding Seam Artifacts

    (d)의 Sampling 영역을 이용해서 Bilinear filtering
          (Carr and Hart 2002) 도 적용 가능


       atlas 에서 빗변을 공유하는 Triangle들은
           mesh에서 edge를 공유해야만 함


Sampling 영역의 vertex 들은 bilinear Filtering을 지원하기
위해 필요한 버퍼를 제공하는 차원에서 반 pixel을 추가해 왔
                     음

                                                36
Implementing
Real-Time Texturing Procedures

  리얼타임 Procedural Solid Texturing 알고리즘은
 레스터라이즈 단계에서 Solid Texture coordinate 들로
   Texture Atlas를 채운 후에 , Procedural 를 수행


  Procedural 평가 단계를 통해, RGB 값으로 저장된
  Solid Texture coordinate를 Texture color 로 교체

    Texture color 는 Texture Mapping 단계에서
                  Object에 적용

                                                 37
Implementing
Real-Time Texturing Procedures



 “현대 그래픽 가속기들은 각각 다른 콤포넌트들
  을 사용하고 있어 다양한 구현방식들이 존재한
              다”




                                 38
Implementing
Real-Time Texturing Procedures

 선형적으로 재구축한 필터(Mine and Neyret
1999)에 의한 랜덤값으로 이루어진 3D Texture
     를 이용해서 Noise 함수를 구현 가능

  Solid Texture coordinate 들이 존재하는
한 장의 Texture Atlas를 OpenGL pixel Texture
  확장버전이나 관련 Texturing을 사용해서
   이러한 Noise Sample들로 교체 가능

                                           39
Implementing
Real-Time Texturing Procedures

       Vertex Shader 로 (NVIDIA 2001)
Perlin Noise 함수를 구현하는 방법들도 있지만
  Vertex 한개당 Procedural Texture는 Vertex
color 들이나 Face끼리 보간된 Gouraud 속성의
      결과를 만듬 ( 단 그 결과는 좀 다름)

     그 결과 Noise의 frequency는
  테셀레이션의 frequency 에 의해 정해진다

                                          40
Implementing
Real-Time Texturing Procedures



 Multi-Pass 를 걸친 Pixel Shader 를 이용해서
     (Hart 2001) Perlin Noise 함수를 구현




                                       41
Implementing
Real-Time Texturing Procedures

0~1 사이의 랜덤값이 균등하게 분포된 3D 정
수개의 격자를 Perlin Noise 함수의 공식으로 만
         든다는 컨셉을 바탕




        랜덤값의 정수 격자(라벨 #0, #1,..,#7) 를
             바탕으로 한 Noise.
                                        42
Implementing
Real-Time Texturing Procedures



 이 불연속적인 lattice 값들은 보간을 통해 연속
        적인 함수로 재구성




                                 43
Implementing
Real-Time Texturing Procedures



  Perlin Noise 함수를 여러개의 Pass 로 구성된
 Pixel Shader로 구현하는 것은 Rayshade 구
 현을 바탕으로 한다(Skinner and Kolb 1991).


                                      44
Implementing
Real-Time Texturing Procedures

         Noise 함수 구현은
   진폭을 가진 각각의 정수 격자점들에게
     격자점 랜덤값으로 세팅해주는
     3D 재구축 필터 kernel을 사용




                                 45
Implementing
Real-Time Texturing Procedures

 s, t, r 점들을 포함하는 정육면체의 8군데 모서
 리 전부를 반복적으로 돌아가면서 랜덤값들을
                요약
 각각의 모서리들마다 Hash3d(x, y, z)함수는
  정수 좌표값들 x,y,z 상에서 임의로 정한
 비트 연산을 수행함으로써,정수 격자점 (x,y,z)
        즉, 랜덤값 t 를 구축


                                 46
Noise Multipass Pixel Shader 구현
의 기본적인 개요
Implementing Real-Time Texturing Procedures




1. 알고리즘은 래스터화 단계(Figure13.8(a))로부터 보간된
s, t, r coordinate 가 가지는 Atlas Color,
즉 일명 인풋 RGB Texture를 가지고 시작




                                              47
Noise Multipass Pixel Shader 구현
의 기본적인 개요
Implementing Real-Time Texturing Procedures




2. 검정색으로 출력 luminance Texture Noise를 초기화




                                              48
Noise Multipass Pixel Shader 구현
의 기본적인 개요
Implementing Real-Time Texturing Procedures




3.Pixel은 Atlas의 해당 Pixel의 정수 부분만 허용하는 RGB
Texture가 되게 만든다.

atlas_int의 각 Pixel은 Atlas(Figure 13.8(b))의 해당 Pixel의
좌표가 들어있는 Noise 격자 셀의 왼쪽 아래 앞 모서리의 좌
표들을 포함한다




                                                   49
Noise Multipass Pixel Shader 구현
의 기본적인 개요
Implementing Real-Time Texturing Procedures




4.Texture atlas_int++를 얻기위해 Texture atlas_int Pixel의
RGB 각각에 1 을 더한다.

atlas_int++의 각 Pixel은 현재 Atlas의 Pixel의 좌표가 들어
있는 Noise 격자의 오른쪽 위 뒤 코너의 좌표를 포함한다.

이제 Noise 격자 셀의 여덟 코너는 atlas_int 및 atlas_int++의
구성 요소의 조합으로 만들 수 있다.




                                                       50
Noise Multipass Pixel Shader 구현
의 기본적인 개요
Implementing Real-Time Texturing Procedures




5.Atlas내에 소숫점 영역과 대응되는 Pixel들을 하나의
Texture로 만들어보자 (결과:13.8(c) )




                                              51
Noise Multipass Pixel Shader 구현
의 기본적인 개요
Implementing Real-Time Texturing Procedures




6. k= 0 부터 7 까지 반복적으로 loop 돌리면서 a ~ f 과정을
각각 수행한다




                                              52
Noise Multipass Pixel Shader 구현
의 기본적인 개요
Implementing Real-Time Texturing Procedures




6-a. Color Mask(k&1, k&2, k&4) 를 사용해서 Texture
atlas_int++ 를 Texture atlas_int 에 덮어쓰기 해서 RGB
Texture 를 atlas_int 와 같게 만들어서 코너에 위치시켜라

(k&1, k&2, k&4).=> (k & 0x001, k&0x010, k&0x100 )

Texture 코너는 이제 셀 모서리에 # K의 정수 좌표를 포함




                                                    53
Noise Multipass Pixel Shader 구현
의 기본적인 개요
Implementing Real-Time Texturing Procedures




6-b. 코너의 해당 Pixel에 의한 랜덤 값 인덱스를 무작위로
배포하는 Luminance Texture를 만들어라


랜덤 Texture는 이제 코너 #K (Figure 13.9 (a))에서 Noise
값을 보유




                                                 54
Noise Multipass Pixel Shader 구현
의 기본적인 개요
Implementing Real-Time Texturing Procedures




6-c.
만약 (k & 1) 이면,
  (k & 0x001 ) => BGR & 001 => 00R
R채널과 랜덤이 곱해진다 (나머지는 비트연산에 의해 마스크)

만약 (k & 1) 이 아니면
(k & 0x001 ) 이 아니면 => (k & 110 ) => BG0
1 - R 과 랜덤이 곱해진다




                                              55
Noise Multipass Pixel Shader 구현
의 기본적인 개요
Implementing Real-Time Texturing Procedures




6-d.
만약 (k & 2) 이면,
  (k & 0x010 ) => BGR & 010 => 0G0
  G채널과 랜덤이 곱해진다

만약 (k & 2) 이 아니면
 (k & 0x010 ) 이 아니면 => (k & 101 ) => B0R
 1 - G 과 랜덤이 곱해진다




                                              56
Noise Multipass Pixel Shader 구현
의 기본적인 개요
Implementing Real-Time Texturing Procedures




6-d
만약 (k & 2) 이면,
  (k & 0x010 ) => BGR & 010 => 0G0
  G채널과 랜덤이 곱해진다

만약 (k & 2) 이 아니면
 (k & 0x010 ) 이 아니면 => (k & 101 ) => B0R
 1 - G 과 랜덤이 곱해진다




                                              57
Noise Multipass Pixel Shader 구현
의 기본적인 개요
Implementing Real-Time Texturing Procedures




6-e, b 채널도 마찬가지

이 세가지 연산들은 이제 trilinear 보간에서 해당 코너가 가
지는 값을 계산




                                              58
Noise Multipass Pixel Shader 구현
의 기본적인 개요
Implementing Real-Time Texturing Procedures




6-f, 계산된 랜덤을 Noise에 추가한다.




                                              59
Noise Multipass Pixel Shader 구현
의 기본적인 개요
Implementing Real-Time Texturing Procedures




7. 이 시점에서 luminance Texture Noise의 Pixel은 셀 코너
8개의 주변의 좌표에 의해 인덱스된 랜덤값을 리니어 보간
한 값을 가진다




         (a) atlas_int 로 계산한 랜덤값
         (b) 1-R 가중치로 곱한 랜덤값
         (c) 1-G 가중치로 곱한 랜덤값
                                                        60
         (d) 그리고 1-B 가중치로 곱한 랜덤값으로 정수격자점 코너 #0 위치를 만듬
Implementing
Real-Time Texturing Procedures




  여기서는 정수격자점 코너 #0 부터 #3까지 총 합친 것이 Noise,
  (정수격자점 코너 #4 부터 #7까지 는 검정색, 왜냐하면 Solid Texture coordinate
  (s,t,r) 중 r 이 정수이므로 테스트를 통해 0 이 되버리기 때문)


                                                              61
Implementing
Real-Time Texturing Procedures




 (a) (0,0,0)~ (1,1,1) 사이 범위의 Solid Texture coordinate (s,t,r) 을 Texture Map으로 나타낸 것,
 (b) 는 (a) 에서 정수 부분들 atlas_int 만 분리한 것
 (c) 는(a) 에서 소숫점 영역들을 분리한 것



                                                                                       62
Implementing
Real-Time Texturing Procedures

 이 알고리즘의 첫번째 구현은 8비트정밀도만 허용했던
      (Hart 2001)Pixel Shader에서 구현

    이 구현은 정수 4비트 fixed-point number와
         소숫점 4 점비트를 사용

      그리고 특별한 Pixel Shader 루틴은
    정수 부분과 소숫점 부분을 획득하기 위해,
       값들을 왼쪽으로 이동시키거나
     오른쪽으로 이동시키는 용도로 개발
                                       63
Implementing
Real-Time Texturing Procedures

       근대의 그래픽 하드웨어가 이제
       관련된 Texturing을 지원

 Index 된 Texture 코너의 RGB콤포넌트들을 이용해서
          랜덤값의 미리 계산된 Texture로
        랜덤Texture를 제너레이션시켜주는것


        원본 구현은 PixelShader에서
       랜덤 넘버 제너레이터 기능도 구현
                                      64
Applications


“실시간 Procedural Solid Texturing 메서드는
독자적이라고 볼 수 있으며 Object의 Atlas에
   계산될 때 실시간으로 볼 수 있음”




                                   65
Applications
   “실시간 Procedural Solid Texturing 과정의
    가장 비싼 작업은 Atlas의 생성”
        “다행히 Atlas는 오직 Object당
     한번 생성되는 것을 필요로 함”
         “Object의 모양이 변화할때

        Atlas는   재생성이 필요”
                                         66
Applications
Object가 오직 Vertex 위치를 변경하여 변형하는 경우에는
           Atlas는 여전히 바뀌지 않음


Object 표면에 Triangle의 상대적인 크기는 Texture Sample
   의 좋지않은 분포의 결과가 발생하여 변경될 수 있음


     Atlas는 Object의 Procedural Texturing을 보호
  Texture된 Atlas는 간단한 2D Texture Map처럼 Object 모델에 결속되
              며 이미 아주 많은 Object 파일포맷이 지원

                                                        67
Applications




   Object가 변형되지만 동일한 Mesh 구조를 유지한다면
       Procedural Solid Texture가 Object에 충실함
                                               68
Applications
     “실시간 Procedural Solid Texturing 과정의
두번째로 비싼 작업은 Procedural Texture 평가 단
               계”
  “레스터화 단계는 그래픽 하드웨어에서 수행하지만
그래픽 하드웨어에 제약을 주어        CPU에서 이 단계를 수행”
   첫 번째 이유는 CPU가 래스터라이즈된 Pixel의 비싼 readback을
     수행하지 않고 Procedural Texture를 적용하는 것을 허용
  두 번째 이유는 때때로 하드웨어 구현간에 다를 수 있지만 레스터화의
            규칙에 완전한 제어권을 주는 것

                                               69
Applications


“Readback 속도 개선 및 그래픽 하드웨어가 더 많
이 Programmable해짐에 따라, GPU의 모든 세 단계
    의 구현은 확실히 더 실용적인 선택될 것”




                                 70
Applications

 “Interactive Procedural Solid texturing design
 system을 구축하기 위해 이러한 기술을 사용”
  이 시스템은 Procedural Solid Texturing이 Parameter 슬라이더를
                  통해 조작할 수 있음
 슬라이더를 이동으로 인한 Procedural Solid 질감이 Object에 다시 적
                           용




                                                       71
Applications

     “Object의 모양이 변화되지 않는다면,
       Atlas는 재계산할 필요가 없지만,
Procedural Texture는 Atlas를 재계산할 필요가 있
                      음.”
  래스터화과 Texture 평가를 위한 호스트 프로세서를 사용하여 해상도
           2562의 Atlas와 10 Hz의 속도를 지원



  이 속도는 그래픽 하드웨어 성능이 빨라지고 있어 향상될 것!



                                            72
Q&A
감사합니다

More Related Content

Similar to 20120713 ch13

Texture Modeling a Procedual Approach #01
Texture Modeling a Procedual Approach #01Texture Modeling a Procedual Approach #01
Texture Modeling a Procedual Approach #01CARROTCG
 
09_motionblur
09_motionblur09_motionblur
09_motionblurnoerror
 
Practical methods for texture design web
Practical methods for texture design webPractical methods for texture design web
Practical methods for texture design webCARROTCG
 
3D 기술 세미나2주차
3D 기술 세미나2주차3D 기술 세미나2주차
3D 기술 세미나2주차Daniel Shin
 
october report in korean
october report in koreanoctober report in korean
october report in koreannao takatoshi
 
Deep Learning Into Advance - 1. Image, ConvNet
Deep Learning Into Advance - 1. Image, ConvNetDeep Learning Into Advance - 1. Image, ConvNet
Deep Learning Into Advance - 1. Image, ConvNetHyojun Kim
 

Similar to 20120713 ch13 (6)

Texture Modeling a Procedual Approach #01
Texture Modeling a Procedual Approach #01Texture Modeling a Procedual Approach #01
Texture Modeling a Procedual Approach #01
 
09_motionblur
09_motionblur09_motionblur
09_motionblur
 
Practical methods for texture design web
Practical methods for texture design webPractical methods for texture design web
Practical methods for texture design web
 
3D 기술 세미나2주차
3D 기술 세미나2주차3D 기술 세미나2주차
3D 기술 세미나2주차
 
october report in korean
october report in koreanoctober report in korean
october report in korean
 
Deep Learning Into Advance - 1. Image, ConvNet
Deep Learning Into Advance - 1. Image, ConvNetDeep Learning Into Advance - 1. Image, ConvNet
Deep Learning Into Advance - 1. Image, ConvNet
 

More from CARROTCG

20120713 ch12
20120713 ch1220120713 ch12
20120713 ch12CARROTCG
 
Procedural synthesis of geometry
Procedural synthesis of geometryProcedural synthesis of geometry
Procedural synthesis of geometryCARROTCG
 
120427 celluar texture
120427 celluar texture120427 celluar texture
120427 celluar textureCARROTCG
 
120413 making noises
120413 making noises120413 making noises
120413 making noisesCARROTCG
 
Texture Modeling a Procedual Approach Chater 2 : Building Procedural Textures
Texture Modeling a Procedual Approach Chater 2 : Building Procedural TexturesTexture Modeling a Procedual Approach Chater 2 : Building Procedural Textures
Texture Modeling a Procedual Approach Chater 2 : Building Procedural TexturesCARROTCG
 
Volumetric cloud modeling with implicit functions web
Volumetric cloud modeling with implicit functions webVolumetric cloud modeling with implicit functions web
Volumetric cloud modeling with implicit functions webCARROTCG
 
120216 ch 12_creating_elements
120216 ch 12_creating_elements120216 ch 12_creating_elements
120216 ch 12_creating_elementsCARROTCG
 
120119 ch 7_time_and_temporal_manipulations
120119 ch 7_time_and_temporal_manipulations120119 ch 7_time_and_temporal_manipulations
120119 ch 7_time_and_temporal_manipulationsCARROTCG
 
120106 ch 6_matte_creation_and_manipulation_web
120106 ch 6_matte_creation_and_manipulation_web120106 ch 6_matte_creation_and_manipulation_web
120106 ch 6_matte_creation_and_manipulation_webCARROTCG
 
120106 ch 5_basic image compositing_re
120106 ch 5_basic image compositing_re120106 ch 5_basic image compositing_re
120106 ch 5_basic image compositing_reCARROTCG
 
111118 ch 4_basic image manipulation_web
111118 ch 4_basic image manipulation_web111118 ch 4_basic image manipulation_web
111118 ch 4_basic image manipulation_webCARROTCG
 
111028 ch 3_the digital representation of visual information
111028 ch 3_the digital representation of visual information111028 ch 3_the digital representation of visual information
111028 ch 3_the digital representation of visual informationCARROTCG
 
The Art and Science of Digital Compositing Chapter 1,2
The Art and Science of Digital Compositing Chapter 1,2The Art and Science of Digital Compositing Chapter 1,2
The Art and Science of Digital Compositing Chapter 1,2CARROTCG
 

More from CARROTCG (15)

20120921
2012092120120921
20120921
 
20120810
2012081020120810
20120810
 
20120713 ch12
20120713 ch1220120713 ch12
20120713 ch12
 
Procedural synthesis of geometry
Procedural synthesis of geometryProcedural synthesis of geometry
Procedural synthesis of geometry
 
120427 celluar texture
120427 celluar texture120427 celluar texture
120427 celluar texture
 
120413 making noises
120413 making noises120413 making noises
120413 making noises
 
Texture Modeling a Procedual Approach Chater 2 : Building Procedural Textures
Texture Modeling a Procedual Approach Chater 2 : Building Procedural TexturesTexture Modeling a Procedual Approach Chater 2 : Building Procedural Textures
Texture Modeling a Procedual Approach Chater 2 : Building Procedural Textures
 
Volumetric cloud modeling with implicit functions web
Volumetric cloud modeling with implicit functions webVolumetric cloud modeling with implicit functions web
Volumetric cloud modeling with implicit functions web
 
120216 ch 12_creating_elements
120216 ch 12_creating_elements120216 ch 12_creating_elements
120216 ch 12_creating_elements
 
120119 ch 7_time_and_temporal_manipulations
120119 ch 7_time_and_temporal_manipulations120119 ch 7_time_and_temporal_manipulations
120119 ch 7_time_and_temporal_manipulations
 
120106 ch 6_matte_creation_and_manipulation_web
120106 ch 6_matte_creation_and_manipulation_web120106 ch 6_matte_creation_and_manipulation_web
120106 ch 6_matte_creation_and_manipulation_web
 
120106 ch 5_basic image compositing_re
120106 ch 5_basic image compositing_re120106 ch 5_basic image compositing_re
120106 ch 5_basic image compositing_re
 
111118 ch 4_basic image manipulation_web
111118 ch 4_basic image manipulation_web111118 ch 4_basic image manipulation_web
111118 ch 4_basic image manipulation_web
 
111028 ch 3_the digital representation of visual information
111028 ch 3_the digital representation of visual information111028 ch 3_the digital representation of visual information
111028 ch 3_the digital representation of visual information
 
The Art and Science of Digital Compositing Chapter 1,2
The Art and Science of Digital Compositing Chapter 1,2The Art and Science of Digital Compositing Chapter 1,2
The Art and Science of Digital Compositing Chapter 1,2
 

20120713 ch13

  • 1. Texturering & Modeling a Procedual Approach 김정근
  • 3. Agenda A Real-time Procedural Solid Texturing Algorithm Creating an Atlas For Procedural Solid Texturing Avoiding Seam Artifacts Implementing Real-Time Texturing Procedures Applications Acknowledgments 3
  • 4. Introduction Procedural Solid Texturing는 production-quality image 로 통합할 때 아주 막강한 툴 유저로 하여금 반복되지 않는 산들과 해안지대들, 구름들로 만들어진 세계를 탐험할 수 있게 함 불이나 폭발같은 동적으로 움직이는 Texture들은 Procedural Texture 를 이용해 효율적으로 나타냄 나무나 돌처럼 medium 으로 Texture 된 것으로 부터 조각된 물체들은 Solid texturing 을 이용해서 Texturing 할수 있음 Solid texturing 은 Surface을 Parameter로 나타낼 필요가 없기 때문에 Surface Texturing 보다 더 쉬움 4
  • 5. Introduction 하지만 Procedural Solid Texturing는 “장점 대부분이 Production-Quality Scene의 오프라인 렌더링에만 제한되어 왔다 ” 5
  • 6. Introduction 현재의 Procedural Solid Texturing는 “Programmable Shading Hardware의 등장으로 게임과 가상환경에서 리얼타임 그래픽 요소의 유용한 툴이 됨” “작고 조밀해서 필요할때마다 통합 가능” “비디오게임과 가상환경에 추가 용량이 거의 없이 방대한 Texture Variations 을 제공할 수 있다.” 6
  • 7. Introduction 이 챕터에서는 “현재 그래픽 프로그래밍 라이브러리에서 이미 사용할만한 특징을 이용해서 리얼타임 시스템에 Procedural Solid Texturing 을 어떻게 통합할 것인지를 기술” “기술을 이용해 실시간 피드백을 가지고 인터렉티브한 Procedural Solid Texturing 설계 시스템을 만드는데 사용하는 방법” 7
  • 8. A Real-time Procedural Solid Texturing Algorithm Renderman 기술을 기반 Surface Shading을 하는데 Texture Map을 허용함 모델의 구성 각각의 vertex가 좌표 축 3개로 구성되어 있다고 가정 Vertex 의 공간좌표 x, y, z는 모델(로컬) 스페이스에서의 vertex 위치를 의미 Vertex 의 u,v Parameter는 2D Texture Map 에서의 vertex 위치를 의미 Vertex 의 Solid Texture Coordinate 인 s, t ,r 은 3D Procedural Texture Space 에서 Vertex 가 어디로부터 Vertex Color 와 그 외 Shading정보를 얻어오는 지를 의미 8
  • 9. A Real-time Procedural Solid Texturing Algorithm 공간좌표와 Solid Texture 좌표들이 주어지면 자동 으로 Parameter들을 구축 종종 Solid Texture 좌표들은 공간좌표와 그냥 동일 한것으로 세팅하기도 하며 이 알고리즘은 공간좌표 만 주어져도 물체에 Texture를 입힐 수 있다 이 알고리즘은 Rasterization, Procedural Evaluation그리고 Texture Mapping중일 때 동작할 것이다 9
  • 10. 래스터라이즈? A Real-time Procedural Solid Texturing Algorithm 물체의 Polygon들을 Texture Map에 기록하는 것 Vertex 들 좌표를 가지고 u, v 로 Parameter화하고 Vertex 들의 Color (R=s, G=t, B=r) 를 가지고 Solid Texture Coordinate를 만든다 그래픽 하드웨어는 오랫동안 Polygon 면에서 Linear interpolation 을 지원, 예를 들어 Gouraud shading Texture Map 에 레스터라이즈된 Polygon 면들에 걸쳐 Solid Texture coordinate들을 자동으로 계산 10
  • 11. 래스터라이즈 A Real-time Procedural Solid Texturing Algorithm For each polygon p Begin polygon For each vertex i Color(p[i].str) Vertex(p[i].uv) End polygon Save image as texture map tex 11
  • 12. Procedural Evaluation A Real-time Procedural Solid Texturing Algorithm Texture Map에서 모든 Pixel에 걸쳐 진행하고, Pixel의 RGB color 로 저장된 Solid Texture Coordinate (s,t,r)상에서 Procedural으로 Texturing을 평가 이 평가를 통해 Solid Texture space 상의 점(s,t,r)에서의 Texture 를 대표해주는새로운 RGB color 가 나올 것이며 이 새로운 RGB color 는 Solid Texture coordinate에 대응하는 Procedural Texture color 로 덮어써서 Texture Map에서 현재 pixel 에 저장 12
  • 13. Procedural Evaluation A Real-time Procedural Solid Texturing Algorithm For each pixel (x, y) in the Texture Maptex tex[x, y]=proc(tex[x, y]) 13
  • 14. Texture Mapping A Real-time Procedural Solid Texturing Algorithm 물체의 u,v Parameter를 이용한 표준 Texture Mapping을 통해 물체위의 Texture를 위치 물체가 그려질때, 물체의 Polygon vertex 들의 공간좌표는 그래픽스 파이프라인을 걸쳐 지나간다 Polygon은 Polygon의 u,v Parameter와 interpolate 되어 Rasterization Texture Map에 저장된 Procedural Solid Texture 로부터 Pixel 과 Mapping되는 지를 체크해서 Polygon에 Texturing 14
  • 15. Texture Mapping A Real-time Procedural Solid Texturing Algorithm Set Texture Map totex For each polygon p Begin polygon For each vertexi TexCoord(p[i].uv) Vertex(p[i].xyz) End polygon 15
  • 16. A Real-time Procedural Solid Texturing Algorithm 16
  • 17. A Real-time Procedural Solid Texturing Algorithm 이 기술이 동작하기 위해, 물체 표면상에 있는 Polygon들은 overlap하지 않고 Texture Map에 놓여질 필요가 있다 이러한 Texture Mapping이 atlas 17
  • 18. A Real-time Procedural Solid Texturing Algorithm atlas 구축단계는 이전 알고리즘에 선처리로 수행되고 한 물체에 대해 한번만 계산될 필요가 있다 모델은 일반적으로 Texture Map에 평평하게 놓이게 되는 순서에 따라 하 나 이상의 삭감이 필요하다. 이러한 삭감은 Texture의 불연속으로 Seam이 보이는 결과를 발 생할 수 있다. 일부 Texture 레이아웃 기법이 seam의 수와 길이의 감소에 초점을 맞췄다. “Avoiding Seam Artifacts” 에서… 18
  • 19. A Real-time Procedural Solid Texturing Algorithm 래스터화 및 Texture 매핑 단계 모두 하드웨어 가속이 되며 Procedural 평가 단계에서는 병목현상이 있음 19
  • 20. Creating an Atlas For Procedural Solid Texturing Perlinnoise 기능을 바탕으로 이들 특히 Procedural Texture의 효율적인 구현 을 위한 몇 가지 기법을 설명 20
  • 21. Creating an Atlas For Procedural Solid Texturing 아틀라스 기법의 다양함 Texture Atlas를 만들기 위해 개발, 이러한 기술의 일부는 자동으로 표면에 2 차원 Texture를 추가하기 위해 Object를 Parameter화하기 위해 개발 왜곡을 최소화 Texture Map 이미지의 비율은 합리적으로 Texture 표면에 재현 Texture Map에서 Pixel당 저장된 Solid Texture coordinate 로부터 Texture를 계산하기 때문에 Atlas의 왜곡은 Procedural Solid Texture 의 비율에 영향을 주지 않음 distortion 의 Scaling 컴포넌트는 stretch (Sander et al. 2001) 또는 상대 크기 (Carr 과 Hart 2002)처럼 다른 곳에서의 다양한 형태의 분량을 재는 것은 Object 표면에 걸쳐 Sample의 분포에 영향을 줄 수 있다. 21
  • 22. Creating an Atlas For Procedural Solid Texturing 레스터화는.. Solid Texture Coordinate 로 Texture Map의 Pixel을 채우고 있기 때문에, Texture Map에서 서로 상대적인 Triangle의 위치가 부적절하게 만들 수 있음 Object의 인접한 Triangle은 Texture Map의 근처가 필요치 않음. 크게 Texture Atlas에서 Triangle을 평면 배치하는 과정을 단순화 가능한 한 사용 가능한 Texture Pixel만큼을 사용하려면, 전체 Texture Map에 걸쳐 Mesh에 Triangle을 배치 22
  • 23. Creating an Atlas For Procedural Solid Texturing “매우 똑바른 방법으로 Pack 된 이등변의 축 정렬된 직각 Triangle 행으로 구 성” 23
  • 24. Creating an Atlas For Procedural Solid Texturing 균일한 크기의 Texture Map Triangle으로 모든 Object Triangle을 평면배 치 하는 것은 Texture Sample을 잘 분배하지 않는다. 대형 Object Triangle은 작은 Triangle Object보다 더 많이 Procedural Solid Texture Sample이 있어야 하지만, 균일한 Mesh Atlas는 Triangle에 게 Sample의 같은 번호를 할당 이것은 작은 Triangle에게 너무 많은 Texture Sample을 제공함으로써 큰 Triangle에게 고르지 않는 Texture 아티펙트와 일반적으로 Texture 공간의 낭비가 발생할수 있음 “매우 똑바른 방법으로 Pack 된 이등변의 축 정렬된 직각 Triangle 행으로 구성” 24
  • 25. Creating an Atlas For Procedural Solid Texturing “Strip 당 Triangle의 크기를 변화하여 물체의 표면에 걸쳐 고르게 사용 가능한 Texture Sample을 분배하여 균일한 Mesh Atlas을 조정” 25
  • 26. Creating an Atlas For Procedural Solid Texturing 증가하지 않는 영역의 알맞은 Texture Map안에 Triangle을 가늘게 Pack Texture 영역에 대한 표면적의 비율로 균일 규모 계수를 추정하고 각 수평 Strip으로 Triangle의 크기를 설정하기 위해 이 Scale factor 를 사용. 각 수평 Strip의 Texture Map 삼각 관계의 모든 Texture Sample을 낭비하 지 않도록 동일한 크기로 설정 “Strip 당 Triangle의 크기를 변화하여 물체의 표면에 걸쳐 고르게 사용 가능한 Texture Sample을 분배하여 균일한 Mesh Atlas을 조정” 26
  • 27. Creating an Atlas For Procedural Solid Texturing Area-Weighted Mesh Atlas를 사용하여 Procedural Solid Texture와 음형 형태의 Sample을 보여줌 Triangle의 Strip당 사이즈 는 표면 전체 Texture Sample을 2에 n승에 가깝 게 정량화된 또 다른 면적 가중 레이아웃보다 더 균등하게 준비 면적 가중 Mesh가 낭비되는 Texture Sample의 고르지 않는 Edge를 가지 고 있는 반면 이 테크닉은 더 쉽게 Texture Map을 작성하는 경향이 있다. “Strip 당 Triangle의 크기를 변화하여 물체의 표면에 걸쳐 고르게 사용 가능한 Texture Sample을 분배하여 균일한 Mesh Atlas을 조정” 27
  • 28. 또 다른 기술 Creating an Atlas For Procedural Solid Texturing Maruya (1995) 블록과 같은 균일한 Mesh Atlas의 Triangle을 취급하고 2에 n승에 가깝게 정량화된 크기의 다양한 Triangle으로 이러한 블록을 Pack Rioux, Soucy, and Godin (1996) 사각형 블록 (2에 n승에 가깝게 정량화된)에 유사한 크기의 Triangle 이점과 이러한 블록을 Pack Battke, Stalling, and Aege (1996) Texture Map에 견고하게 Strip을 Pack Cignoni et al. (1998) 유사한 Strip을 Pack 했지만 적당히 같은 Triangle은 제거 28
  • 29. Skinny triangles Creating an Atlas For Procedural Solid Texturing “Skinny Triangle의 상당수가 있는 Mesh는 가중면적 Atlas를 사용하는 일부 Texture를 blockiness하게 보여질수 있음” Length-Weighted atlas Texture Map에 그 이미지의 크기를 set 하는 Triangle의 서피스 영역을 사 용하는 대신에 Triangle의 가장 긴 가장자리의 길이를 사용 Mesh의 긴 가장자리가 최대의 Sample을 얻을 것을 보장하지만 Skinny Triangle을 oversample하는 경향이 있어 다른 영역이 사용가능한 Sample 의 수를 줄여줌 29
  • 30. MIP Mapping Creating an Atlas For Procedural Solid Texturing Sander et al. (2001) Triangle의 영역을 한 무리로 모으고 Atlas 안에 이 Cluster를 pack Cluster 사이의 영역은 MIP Mapping 될수 있으며 “합리적인” 색상으로 채워짐 Carr and Hart (2002) 반드시 인근 아니라, 지역, 인접한의 계층 구조로 Triangle을 pack하기 위한 MIP 매핑의 일부 속성을 사용 30
  • 31. MIP Mapping Creating an Atlas For Procedural Solid Texturing 주어진 MIP Map 레벨에서 같은 사분면에 Mesh Triangle의 인접한 클러스터를 매핑한 인접한 MIP Map의 예 31
  • 32. Avoiding Seam Artifacts Texture Filtering을 하다 보면, Texture Map내의 잘못된 Polygon 이미지로부터 그려진 Polygon 경계 근처를 Sampling할 수도 있다 Triangle 주변에서 Sampling했다면 심각하지는 않지만 Polygon 주변을 무시하고 있기 때문에 이런 상황에 기댈 수 없다. 32
  • 33. Avoiding Seam Artifacts (a) Texture들은 하나의 pixel 배열로 저장된다 (b) nearest-neighbor filter (제일 가까운 근방 필터) 를 사용하면 Sampling한 위치 에서 가장 가까운 pixel color 를 준다. (c) 그 결과 seam artifact 가 발생한다. 밝은 Triangle color 가 어두운 Triangle의 Sampling 영역에 새어 들어 간 것을 볼 수 있다. 33
  • 34. Avoiding Seam Artifacts Texture Map내에서 Triangle들을 Sampling이 정확하게 될 수 있도록 위치시킬 필요가 있다 이 문제의 해결책은 Triangle의 빗변을 공유하는 부분에 수평 으로 한 개 의 pixel 로 offset 을 주는 것 (Rioux, Soucy, and Godin 1996) 34
  • 35. Avoiding Seam Artifacts (a)세 vertex 들 (−0.5,−0.5), (5.5,−0.5),(−0.5, 5.5) 들로 이루어진 더 확장된 어두운 Triangle과 (0.5, 4.5), (5.5,−0.5), (5.5, 4.5) 로 이동된 밝은 Triangle을 레스터라이즈 (b) 각각의 Triangle에 주어진 pixel 수만큼 새로운 Triangle들을 Rasterization한것을 Shading (c) 어두운 Triangle의 Texture 좌표 u, v 는 안 바뀐 상태이므로, 오버스캔된 Rasterization 로부터 더 작은 Triangle을 적당하게 Sampling (d) 밝은 Triangle은 이동된 위치로부터 동일하게 Sampling 35
  • 36. Avoiding Seam Artifacts (d)의 Sampling 영역을 이용해서 Bilinear filtering (Carr and Hart 2002) 도 적용 가능 atlas 에서 빗변을 공유하는 Triangle들은 mesh에서 edge를 공유해야만 함 Sampling 영역의 vertex 들은 bilinear Filtering을 지원하기 위해 필요한 버퍼를 제공하는 차원에서 반 pixel을 추가해 왔 음 36
  • 37. Implementing Real-Time Texturing Procedures 리얼타임 Procedural Solid Texturing 알고리즘은 레스터라이즈 단계에서 Solid Texture coordinate 들로 Texture Atlas를 채운 후에 , Procedural 를 수행 Procedural 평가 단계를 통해, RGB 값으로 저장된 Solid Texture coordinate를 Texture color 로 교체 Texture color 는 Texture Mapping 단계에서 Object에 적용 37
  • 38. Implementing Real-Time Texturing Procedures “현대 그래픽 가속기들은 각각 다른 콤포넌트들 을 사용하고 있어 다양한 구현방식들이 존재한 다” 38
  • 39. Implementing Real-Time Texturing Procedures 선형적으로 재구축한 필터(Mine and Neyret 1999)에 의한 랜덤값으로 이루어진 3D Texture 를 이용해서 Noise 함수를 구현 가능 Solid Texture coordinate 들이 존재하는 한 장의 Texture Atlas를 OpenGL pixel Texture 확장버전이나 관련 Texturing을 사용해서 이러한 Noise Sample들로 교체 가능 39
  • 40. Implementing Real-Time Texturing Procedures Vertex Shader 로 (NVIDIA 2001) Perlin Noise 함수를 구현하는 방법들도 있지만 Vertex 한개당 Procedural Texture는 Vertex color 들이나 Face끼리 보간된 Gouraud 속성의 결과를 만듬 ( 단 그 결과는 좀 다름) 그 결과 Noise의 frequency는 테셀레이션의 frequency 에 의해 정해진다 40
  • 41. Implementing Real-Time Texturing Procedures Multi-Pass 를 걸친 Pixel Shader 를 이용해서 (Hart 2001) Perlin Noise 함수를 구현 41
  • 42. Implementing Real-Time Texturing Procedures 0~1 사이의 랜덤값이 균등하게 분포된 3D 정 수개의 격자를 Perlin Noise 함수의 공식으로 만 든다는 컨셉을 바탕 랜덤값의 정수 격자(라벨 #0, #1,..,#7) 를 바탕으로 한 Noise. 42
  • 43. Implementing Real-Time Texturing Procedures 이 불연속적인 lattice 값들은 보간을 통해 연속 적인 함수로 재구성 43
  • 44. Implementing Real-Time Texturing Procedures Perlin Noise 함수를 여러개의 Pass 로 구성된 Pixel Shader로 구현하는 것은 Rayshade 구 현을 바탕으로 한다(Skinner and Kolb 1991). 44
  • 45. Implementing Real-Time Texturing Procedures Noise 함수 구현은 진폭을 가진 각각의 정수 격자점들에게 격자점 랜덤값으로 세팅해주는 3D 재구축 필터 kernel을 사용 45
  • 46. Implementing Real-Time Texturing Procedures s, t, r 점들을 포함하는 정육면체의 8군데 모서 리 전부를 반복적으로 돌아가면서 랜덤값들을 요약 각각의 모서리들마다 Hash3d(x, y, z)함수는 정수 좌표값들 x,y,z 상에서 임의로 정한 비트 연산을 수행함으로써,정수 격자점 (x,y,z) 즉, 랜덤값 t 를 구축 46
  • 47. Noise Multipass Pixel Shader 구현 의 기본적인 개요 Implementing Real-Time Texturing Procedures 1. 알고리즘은 래스터화 단계(Figure13.8(a))로부터 보간된 s, t, r coordinate 가 가지는 Atlas Color, 즉 일명 인풋 RGB Texture를 가지고 시작 47
  • 48. Noise Multipass Pixel Shader 구현 의 기본적인 개요 Implementing Real-Time Texturing Procedures 2. 검정색으로 출력 luminance Texture Noise를 초기화 48
  • 49. Noise Multipass Pixel Shader 구현 의 기본적인 개요 Implementing Real-Time Texturing Procedures 3.Pixel은 Atlas의 해당 Pixel의 정수 부분만 허용하는 RGB Texture가 되게 만든다. atlas_int의 각 Pixel은 Atlas(Figure 13.8(b))의 해당 Pixel의 좌표가 들어있는 Noise 격자 셀의 왼쪽 아래 앞 모서리의 좌 표들을 포함한다 49
  • 50. Noise Multipass Pixel Shader 구현 의 기본적인 개요 Implementing Real-Time Texturing Procedures 4.Texture atlas_int++를 얻기위해 Texture atlas_int Pixel의 RGB 각각에 1 을 더한다. atlas_int++의 각 Pixel은 현재 Atlas의 Pixel의 좌표가 들어 있는 Noise 격자의 오른쪽 위 뒤 코너의 좌표를 포함한다. 이제 Noise 격자 셀의 여덟 코너는 atlas_int 및 atlas_int++의 구성 요소의 조합으로 만들 수 있다. 50
  • 51. Noise Multipass Pixel Shader 구현 의 기본적인 개요 Implementing Real-Time Texturing Procedures 5.Atlas내에 소숫점 영역과 대응되는 Pixel들을 하나의 Texture로 만들어보자 (결과:13.8(c) ) 51
  • 52. Noise Multipass Pixel Shader 구현 의 기본적인 개요 Implementing Real-Time Texturing Procedures 6. k= 0 부터 7 까지 반복적으로 loop 돌리면서 a ~ f 과정을 각각 수행한다 52
  • 53. Noise Multipass Pixel Shader 구현 의 기본적인 개요 Implementing Real-Time Texturing Procedures 6-a. Color Mask(k&1, k&2, k&4) 를 사용해서 Texture atlas_int++ 를 Texture atlas_int 에 덮어쓰기 해서 RGB Texture 를 atlas_int 와 같게 만들어서 코너에 위치시켜라 (k&1, k&2, k&4).=> (k & 0x001, k&0x010, k&0x100 ) Texture 코너는 이제 셀 모서리에 # K의 정수 좌표를 포함 53
  • 54. Noise Multipass Pixel Shader 구현 의 기본적인 개요 Implementing Real-Time Texturing Procedures 6-b. 코너의 해당 Pixel에 의한 랜덤 값 인덱스를 무작위로 배포하는 Luminance Texture를 만들어라 랜덤 Texture는 이제 코너 #K (Figure 13.9 (a))에서 Noise 값을 보유 54
  • 55. Noise Multipass Pixel Shader 구현 의 기본적인 개요 Implementing Real-Time Texturing Procedures 6-c. 만약 (k & 1) 이면, (k & 0x001 ) => BGR & 001 => 00R R채널과 랜덤이 곱해진다 (나머지는 비트연산에 의해 마스크) 만약 (k & 1) 이 아니면 (k & 0x001 ) 이 아니면 => (k & 110 ) => BG0 1 - R 과 랜덤이 곱해진다 55
  • 56. Noise Multipass Pixel Shader 구현 의 기본적인 개요 Implementing Real-Time Texturing Procedures 6-d. 만약 (k & 2) 이면, (k & 0x010 ) => BGR & 010 => 0G0 G채널과 랜덤이 곱해진다 만약 (k & 2) 이 아니면 (k & 0x010 ) 이 아니면 => (k & 101 ) => B0R 1 - G 과 랜덤이 곱해진다 56
  • 57. Noise Multipass Pixel Shader 구현 의 기본적인 개요 Implementing Real-Time Texturing Procedures 6-d 만약 (k & 2) 이면, (k & 0x010 ) => BGR & 010 => 0G0 G채널과 랜덤이 곱해진다 만약 (k & 2) 이 아니면 (k & 0x010 ) 이 아니면 => (k & 101 ) => B0R 1 - G 과 랜덤이 곱해진다 57
  • 58. Noise Multipass Pixel Shader 구현 의 기본적인 개요 Implementing Real-Time Texturing Procedures 6-e, b 채널도 마찬가지 이 세가지 연산들은 이제 trilinear 보간에서 해당 코너가 가 지는 값을 계산 58
  • 59. Noise Multipass Pixel Shader 구현 의 기본적인 개요 Implementing Real-Time Texturing Procedures 6-f, 계산된 랜덤을 Noise에 추가한다. 59
  • 60. Noise Multipass Pixel Shader 구현 의 기본적인 개요 Implementing Real-Time Texturing Procedures 7. 이 시점에서 luminance Texture Noise의 Pixel은 셀 코너 8개의 주변의 좌표에 의해 인덱스된 랜덤값을 리니어 보간 한 값을 가진다 (a) atlas_int 로 계산한 랜덤값 (b) 1-R 가중치로 곱한 랜덤값 (c) 1-G 가중치로 곱한 랜덤값 60 (d) 그리고 1-B 가중치로 곱한 랜덤값으로 정수격자점 코너 #0 위치를 만듬
  • 61. Implementing Real-Time Texturing Procedures 여기서는 정수격자점 코너 #0 부터 #3까지 총 합친 것이 Noise, (정수격자점 코너 #4 부터 #7까지 는 검정색, 왜냐하면 Solid Texture coordinate (s,t,r) 중 r 이 정수이므로 테스트를 통해 0 이 되버리기 때문) 61
  • 62. Implementing Real-Time Texturing Procedures (a) (0,0,0)~ (1,1,1) 사이 범위의 Solid Texture coordinate (s,t,r) 을 Texture Map으로 나타낸 것, (b) 는 (a) 에서 정수 부분들 atlas_int 만 분리한 것 (c) 는(a) 에서 소숫점 영역들을 분리한 것 62
  • 63. Implementing Real-Time Texturing Procedures 이 알고리즘의 첫번째 구현은 8비트정밀도만 허용했던 (Hart 2001)Pixel Shader에서 구현 이 구현은 정수 4비트 fixed-point number와 소숫점 4 점비트를 사용 그리고 특별한 Pixel Shader 루틴은 정수 부분과 소숫점 부분을 획득하기 위해, 값들을 왼쪽으로 이동시키거나 오른쪽으로 이동시키는 용도로 개발 63
  • 64. Implementing Real-Time Texturing Procedures 근대의 그래픽 하드웨어가 이제 관련된 Texturing을 지원 Index 된 Texture 코너의 RGB콤포넌트들을 이용해서 랜덤값의 미리 계산된 Texture로 랜덤Texture를 제너레이션시켜주는것 원본 구현은 PixelShader에서 랜덤 넘버 제너레이터 기능도 구현 64
  • 65. Applications “실시간 Procedural Solid Texturing 메서드는 독자적이라고 볼 수 있으며 Object의 Atlas에 계산될 때 실시간으로 볼 수 있음” 65
  • 66. Applications “실시간 Procedural Solid Texturing 과정의 가장 비싼 작업은 Atlas의 생성” “다행히 Atlas는 오직 Object당 한번 생성되는 것을 필요로 함” “Object의 모양이 변화할때 Atlas는 재생성이 필요” 66
  • 67. Applications Object가 오직 Vertex 위치를 변경하여 변형하는 경우에는 Atlas는 여전히 바뀌지 않음 Object 표면에 Triangle의 상대적인 크기는 Texture Sample 의 좋지않은 분포의 결과가 발생하여 변경될 수 있음 Atlas는 Object의 Procedural Texturing을 보호 Texture된 Atlas는 간단한 2D Texture Map처럼 Object 모델에 결속되 며 이미 아주 많은 Object 파일포맷이 지원 67
  • 68. Applications Object가 변형되지만 동일한 Mesh 구조를 유지한다면 Procedural Solid Texture가 Object에 충실함 68
  • 69. Applications “실시간 Procedural Solid Texturing 과정의 두번째로 비싼 작업은 Procedural Texture 평가 단 계” “레스터화 단계는 그래픽 하드웨어에서 수행하지만 그래픽 하드웨어에 제약을 주어 CPU에서 이 단계를 수행” 첫 번째 이유는 CPU가 래스터라이즈된 Pixel의 비싼 readback을 수행하지 않고 Procedural Texture를 적용하는 것을 허용 두 번째 이유는 때때로 하드웨어 구현간에 다를 수 있지만 레스터화의 규칙에 완전한 제어권을 주는 것 69
  • 70. Applications “Readback 속도 개선 및 그래픽 하드웨어가 더 많 이 Programmable해짐에 따라, GPU의 모든 세 단계 의 구현은 확실히 더 실용적인 선택될 것” 70
  • 71. Applications “Interactive Procedural Solid texturing design system을 구축하기 위해 이러한 기술을 사용” 이 시스템은 Procedural Solid Texturing이 Parameter 슬라이더를 통해 조작할 수 있음 슬라이더를 이동으로 인한 Procedural Solid 질감이 Object에 다시 적 용 71
  • 72. Applications “Object의 모양이 변화되지 않는다면, Atlas는 재계산할 필요가 없지만, Procedural Texture는 Atlas를 재계산할 필요가 있 음.” 래스터화과 Texture 평가를 위한 호스트 프로세서를 사용하여 해상도 2562의 Atlas와 10 Hz의 속도를 지원 이 속도는 그래픽 하드웨어 성능이 빨라지고 있어 향상될 것! 72
  • 73. Q&A