Upload
others
View
0
Download
0
Embed Size (px)
Citation preview
Texture MappingTexture Mapping
• 표면 세부사항을 더하는 방법표면 세부사항을 더하는 방법– 표면을 자세한 polygon 으로 모델
• 렌더링 속도 저하• 렌더링 속도 저하• 세부 특징 묘사 모델링 어려움
– 표면을 texture 사용해서 map
• 오늘 강의 내용!
• 이미지의 복잡도는 계산량의 복잡함에 영향과 상관없음관없음
The textureThe texture
• Texture 는 비트맵 이미지임Texture 는 비트맵 이미지임• 2차원 배열 : texture[height][width][4]
• 텍스쳐의 픽셀을 texels 라고 부름• Texel 좌표계 (s t) 스케일 up 또는Texel 좌표계 (s,t) 스케일 up 또는down
Texture 를 표면에 mapTexture 를 표면에 map
폴리건은 임의의 크기와 모양을 가질 수 있음폴리건은 임의의 기와 양을 가질 수 있음
The drawing iteselfThe drawing iteself
• vertex( , , ,s, t) 를 사용하여 텍스쳐 좌표를 명시• 예제: 200 by 200 크기 사각형에
400 by 400 텍스쳐 매핑
PImage img;void setup(){
i l dI ("b li 1 j ")img = loadImage("berlin-1.jpg");}void draw(){
beginShape();beginShape(); texture(img); vertex(-100, -100, 0, 0, 0); vertex(100 -100 0 400 0);vertex(100, -100, 0, 400, 0); vertex(100, 100, 0, 400, 400); vertex(-100, 100, 0, 0, 400);endShape();endShape();
}
Texture 좌표계Texture 좌표계• textureMode(NORMALIZED);
– 텍스쳐 좌표를 [0, 1] 범위로 스케일
( )• texutureMode(IMAGE);– 텍츠쳐 좌표를 이미지 크기 그대로 사용
PImage a = loadImage("ah.jpg"); textureMode(IMAGE);
PImage a = loadImage("ah.jpg"); textureMode(NORMALIZED); b i Sh ()beginShape();
texture(a); vertex(10, 20, 0, 0);
beginShape(); texture(a); vertex(10, 20, 0, 0); vertex(80 5 100 0);vertex(80, 5, 100, 0);
vertex(95, 90, 100, 100); vertex(40, 95, 0, 100); dSh ()
vertex(80, 5, 100, 0); vertex(95, 90, 100, 100); vertex(40, 95, 0, 100); ndShape();ndShape(); ndShape();
Texture Value LookupTexture Value Lookup
• 주어진 텍츠쳐 좌표 (s,t)로부터 그 위치 텍스쳐 소스에 대응하는 unique한 이미지 값을 찾을 수 있다.
큐브 모델에 texture mapping큐브 모델에 texture mapping
• 각 면에 texture 매핑각 면에 texture 매핑(1,-1, -1)
(-1,-1,-1)
x
// +Z "front" face vertex(-1, -1, 1, 0, 0); vertex( 1, -1, 1, 1, 0);
(1,-1, 1)(-1,-1, 1)
e te ( , , , , 0);vertex( 1, 1, 1, 1, 1); vertex(-1, 1, 1, 0, 1); (1,1,-1)(-1,1,-1)
z Face 의 vertex 순서가 위, 아래 결정!
(1,1,1)(-1,1,1)
y
Cube의 6개 face 에 같은 이미지 매핑 예제
ExampleExample
• Cube 환경 Map – 방!Cube 환경 Map 방!
천장c 천장c정면
바닥
ViewingViewing
• Perspective vs. OrthographicPerspective vs. Orthographic
perspective(PI/3.0, width/height, cameraZ/10.0, cameraZ*10.0) where cameraZ is ((height/2.0) / tan(PI*60.0/360.0));
ortho(-width/2, width/2, -height/2, height/2, -10, 10);
camera
camera
camera
camera
Viewing WindowViewing Window
카메라 위치
바라보는 시선
위
( idth/2 0 h i ht/2 0 (h i ht/2 0) / t (PI /6 0)camera(width/2.0, height/2.0, (height/2.0) / tan(PI*/6.0), width/2.0, height/2.0, 0,
0, 1, 0)
camera
ExampleExample// Change height of the camera with mouseY
( //camera(30.0, mouseY, 220.0, // eyeX, eyeY, eyeZ
0.0, 0.0, 0.0, // centerX, centerY, centerZ
0.0, 1.0, 0.0); // upX, upY, upZ, , ) // p , p , p
Example1. Change the position of the camerap g p
;객체 주위를 한 바퀴 도는 카메라 워킹
http://www.processing.org/learning/3d/bird.htmlhttp //www.processing.org/learning/3d/bird.html
HomeworkHomework1. Texture mapping 으로 아래와 같은 환경 셋팅
Sky – 구름 texture
vertical – no texture
땅땅 – 잔디 또는 흙 texture
참고 : http://www.processing.org/learning/3d/bird.html2. 새가 날아다니는 시뮬레이션
3. 새 모델링은 box 1나와 rect 2 개인데 그 위에 texture mapping!