Bài giảng Đồ họa và hiện thực ảo - Lesson 2: Các giải thuật sinh các thực thể cơ sở

z screen space- không gian màn hình

z model space Không gian mô hình

(a.k.a. object space or world space)

z 3 loại phép biến đổi:

– Modeling transforms

– Viewing transforms

– Projection transforms

Bài giảng Đồ họa và hiện thực ảo - Lesson 2: Các giải thuật sinh các thực thể cơ sở trang 1

Trang 1

Bài giảng Đồ họa và hiện thực ảo - Lesson 2: Các giải thuật sinh các thực thể cơ sở trang 2

Trang 2

Bài giảng Đồ họa và hiện thực ảo - Lesson 2: Các giải thuật sinh các thực thể cơ sở trang 3

Trang 3

Bài giảng Đồ họa và hiện thực ảo - Lesson 2: Các giải thuật sinh các thực thể cơ sở trang 4

Trang 4

Bài giảng Đồ họa và hiện thực ảo - Lesson 2: Các giải thuật sinh các thực thể cơ sở trang 5

Trang 5

Bài giảng Đồ họa và hiện thực ảo - Lesson 2: Các giải thuật sinh các thực thể cơ sở trang 6

Trang 6

Bài giảng Đồ họa và hiện thực ảo - Lesson 2: Các giải thuật sinh các thực thể cơ sở trang 7

Trang 7

Bài giảng Đồ họa và hiện thực ảo - Lesson 2: Các giải thuật sinh các thực thể cơ sở trang 8

Trang 8

Bài giảng Đồ họa và hiện thực ảo - Lesson 2: Các giải thuật sinh các thực thể cơ sở trang 9

Trang 9

pdf 9 trang Danh Thịnh 09/01/2024 680
Bạn đang xem tài liệu "Bài giảng Đồ họa và hiện thực ảo - Lesson 2: Các giải thuật sinh các thực thể cơ sở", để tải tài liệu gốc về máy hãy click vào nút Download ở trên

Tóm tắt nội dung tài liệu: Bài giảng Đồ họa và hiện thực ảo - Lesson 2: Các giải thuật sinh các thực thể cơ sở

Bài giảng Đồ họa và hiện thực ảo - Lesson 2: Các giải thuật sinh các thực thể cơ sở
1Các giải thuật sinh các thực thể 
cơ sở
Le Tan Hung
hunglt@it-hut.edu.vn
0913030731
Rendering Pipeline: 3-D
Transform
Illuminate
Transform
Clip
Project
Rasterize
Model & Camera
Parameters Rendering Pipeline Framebuffer Display
The Rendering Pipeline: 3-D
Scene graph
Object geometry
Lighting
Calculations
Clipping
• Các điểm của hệ thống tọa độ 3D thế giới thực 
• Các điểm bóng theo mô hình chiếu sáng
• Các điểm trong mô hình hệ tọa độ Camera hay tọa độ điểm nhìn
• Các tọa độ điểm của vùng hình chóp cụt với điểm nhìn xác định
• Điểm 2-D theo tọa độ màn hình sau phép chiếu được xén tỉa
Modeling
Transforms
Viewing
Transform
Projection
Transform
Phép biến đổi Transformations
z screen space- không gian màn hình
z model space Không gian mô hình 
(a.k.a. object space or world space)
z 3 loại phép biến đổi:
– Modeling transforms
– Viewing transforms
– Projection transforms
Rendering: Transformations
z Modeling transforms
– Size, place, scale, and rotate objects parts of the 
model w.r.t. each other
– Object coordinates Æ world coordinates
Z
X
Y
X
Z
Y
Rendering: Transformations
z Viewing transform
– Rotate & translate the world to lie directly in front of 
the camera
z Typically place camera at origin
z Typically looking down -Z axis
– World coordinates Æ view coordinates
2Rendering: Transformations
z Projection transform
– Apply perspective foreshortening
z Distant = small: the pinhole camera model
– View coordinates Æ screen coordinates
Rendering: Transformations
z All these transformations involve shifting 
coordinate systems (i.e., basis sets)
z Oh yeah, that’s what matrices do
z Represent coordinates as vectors, transforms 
as matrices
z Multiply matrices = concatenate transforms!
⎥⎦
⎤⎢⎣
⎡⎥⎦
⎤⎢⎣
⎡ −=⎥⎦
⎤⎢⎣
⎡
′
′
Y
X
Y
X
θθ
θθ
cossin
sincos
Rendering: Transformations
z Homogeneous coordinates: represent 
coordinates in 3 dimensions with a 4-vector
– Denoted [x, y, z, w]T
z Note that w = 1 in model coordinates
– To get 3-D coordinates, divide by w:
[x’, y’, z’]T = [x/w, y/w, z/w]T
z Transformations are 4x4 matrices
z Why? To handle translation and projection
The Rendering Pipeline: 3-D
Modeling
Transforms
Scene graph
Object geometry
Lighting
Calculations
Viewing
Transform
Clipping
Projection
Transform
Result:
• All vertices of scene in shared 3-D “world” coordinate system
• Vertices shaded according to lighting model
• Scene vertices in 3-D “view” or “camera” coordinate system
• Exactly those vertices & portions of polygons in view frustum
• 2-D screen coordinates of clipped vertices
Rendering: Ánh sáng - Lighting
z Illuminating a scene: coloring pixels according to 
some approximation of lighting
– Global illumination: solves for lighting of the whole 
scene at once
– Local illumination: local approximation, typically 
lighting each polygon separately
z Interactive graphics (e.g., hardware) does only 
local illumination at run time
The Rendering Pipeline: 3-D
Modeling
Transforms
Scene graph
Object geometry
Lighting
Calculations
Viewing
Transform
Clipping
Projection
Transform
Result:
• All vertices of scene in shared 3-D “world” coordinate 
system
• Vertices shaded according to lighting model
• Scene vertices in 3-D “view” or “camera” coordinate 
system
• Exactly those vertices & portions of polygons in view 
frustum
• 2-D screen coordinates of clipped vertices
3Rendering: Clipping
z Clipping a 3-D primitive returns its intersection 
with the view frustum:
Rendering: Xén tỉa - Clipping
z Clipping is tricky!
– We will have a whole assignment on clipping
In: 3 vertices
Out: 6 verticesClip
Clip In: 1 polygon
Out: 2 polygons
The Rendering Pipeline: 3-D
Transform
Illuminate
Transform
Clip
Project
Rasterize
Model & Camera
Parameters Rendering Pipeline Framebuffer Display
Modeling: The Basics
z Common interactive 3-D primitives: points, 
lines, polygons (i.e., triangles)
z Organized into objects
– Collection of primitives, other objects
– Associated matrix for transformations
z Instancing: using same geometry for multiple 
objects 
– 4 wheels on a car, 2 arms on a robot
Modeling: The Scene Graph
z Đồ thị cảnh scene graph : cây đồ thị lưu trữ đối 
tượng, quan hệ giũa các đối tượng và các phép 
biến đổi trên đối tượng đó
z Nút là đối tượng;
z Cành là các thực thể biến đổi
– Tương ứng là các ma trận Robot
BodyHead
ArmTrunkLegEyeMouth
Modeling: The Scene Graph
z Traverse the scene graph in depth-first order, 
concatenating transformations
z Maintain a matrix stack of transformations
ArmTrunkLegEyeMouth
Head Body
Robot
Foot
Matrix
Stack
Visited
Unvisited
Active
4Modeling: The Camera
z Finally: need a model of the virtual camera
– Can be very sophisticated
z Field of view, depth of field, distortion, chromatic aberration
– Interactive graphics (OpenGL):
z Camera pose: position & orientation
– Captured in viewing transform (i.e., modelview matrix)
z Pinhole camera model
– Field of view
– Aspect ratio
– Near & far clipping planes
Modeling: The Camera
z Camera parameters (FOV, etc) are encapsulated 
in a projection matrix
– Homogeneous coordinates Æ 4x4 matrix!
– See OpenGL Appendix F for the matrix
z The projection matrix premultiplies the viewing 
matrix, which premultiplies the modeling matrices
– Actually, OpenGL lumps viewing and modeling 
transforms into modelview matrix
Rời rạc hoá điểm ảnh
(Scan Conversion rasterization)
z Là tiến trình sinh các đối tượng hình học cơ sở bằng
phương pháp xấp xỉ dựa trên lưới phân giải của màn
hình
z Tính chất các đối tượng cần đảm bảo :
– smooth
– continuous
– pass through specified points
– uniform brightness
– efficient
Biểu diễn đoạn thẳng
z Biểu diễn tường minh
(y-y1)/( x-x1) = ( y2-y1)/( x2-x1)1
y = kx + m
– k = (y2-y1)/( x2-x1) 
– m = y1- kx1
– Δy = k Δx 
z Biểu diễn không tường minh
(y2-y1)x - (x2-x1)y + x2y1 - x1y2 = 0
hay rx + sy +

File đính kèm:

  • pdfbai_giang_do_hoa_va_hien_thuc_ao_lesson_2_cac_giai_thuat_sin.pdf