Upload
adi-susilo
View
17
Download
0
Embed Size (px)
Citation preview
Komputer GrafikKuliah 1: Prinsip Dasar Komputer Grafik
Dr. Trias Aditya
Rute• Computer Graphic Pipeline Proses Operasi Komputer Grafik Teknik Geodesi & Geomatika & Komputer Grafik Contoh Aplikasi
• Geometri 2D & Geometri 3D Sistem Koordinat Transformasi Koordinat Proyeksi
Computer Graphics Pipeline
Definisi 101
• Komputer Grafik: mencakup tampilan,manipulasi dan penyimpanan gambar dandata eksperimental untuk penyajianmenarik memanfaatkan komputer
• Komputer grafik terdiri dari komputer,memori dan: monitor berwarna, pirantikeras penunjang pemgolahan data dantampilan serta piranti lunak data grafis
Definisi 101
• Komputer Grafik: mencakup tampilan,manipulasi dan penyimpanan gambar dandata eksperimental untuk penyajianmenarik memanfaatkan komputer
• Komputer grafik terdiri dari komputer,memori dan: monitor berwarna, pirantikeras penunjang pemgolahan data dantampilan serta piranti lunak data grafis
• Proses memproduksi gambar atau citramenggunakan komputer proses menulis program untukmenghasilkan/mengolah grafik gambar yang dihasilkan tertayang dilayar komputer sebagai element grafikdisebut “pixel”
ObjectSpecification
SceneDescription
ModelTransformation
SceneDescription
Clipping &Hidden Surface
Removal
ViewTransformation
View & LightSpecification
Shading Image
Image DisplayTransformation
Output
MODELING
RENDERING
DISPLAY
McConnell 2006
Komputer Grafik untuk TeknikGeodesi & Geomatika
• Ragam AplikasiKomputer Grafik:- 3D object modeliing- animation- visualization
3D surface model
Depth image Triangle mesh Texture image
Textured 3DWireframe model
• intermap_harrier2.avigallery_30.mpeg
Supporting Disciplines
• Computer science (algorithms, datastructures, software engineering, …)
• Mathematics (geometry, numerical, …)• Physics (Optics, mechanics, …)• Psychology (Colour, perception)• Art and design
Applications
• Computer Aided Design (CAD)• Computer Aided Geometric Design
(CAGD)• Entertainment (animation, games, …)• Geographic Information Systems (GIS)• Visualization (Scientific Vis., Inform. Vis.)• Medical Visualization• …
Interactive Computer Graphics
User
Application
Screen
input
image
A detailedpolygonmesh(thank
you, WetaDigital)
Graphics pipeline
User
Screen
Model
Geometry, colour
Map
Display
Edit
Manipulation of geometry andcolor…
Monsters, Inc
Manipulation of geometry andcolor…
Manipulation of geometry andcolor…
Manipulation of geometry andcolor…
Manipulation of geometry andcolor…
Representations in graphics
Vector Graphics• Image is represented by continuous
geometric objects: lines, curves, etc.
Raster Graphics• Image is represented as an rectangular
grid of coloured squares
Vector graphics
• Graphics objects: geometry + colour• Complexity ~ O(number of objects)• Geometric transformation possible without
loss of information (zoom, rotate, …)• Diagrams, schemes, ...• Examples: PowerPoint, CorelDraw, ...
Raster graphics• Generic• Image processing techniques• Geometric Transformation: loss of
information• Complexity ~ O(number of pixels)• Jagged edges, anti-aliasing• Realistic images, textures, ...• Examples: Paint, PhotoShop, ...
Conversion
Vector graphics
Rasterization, Pattern recognition
Scan conversion
Raster graphics
Hardware
• Vector graphics• Raster graphics• Colour lookup table• 3D rendering hardware
I/O Devices
3D Scanner 2D ScannerCCDCharge couple device
Vector Graphics Hardware
V E C T O R
Display Controller
move 10 20
line 20 40
...
char O
char R
Display list
continuous & smoothlines
no filled objects
random scan
refresh speed dependson complexity of thescene
Raster Graphics Hardware
Video Controller
jaggies (stair casing)
filled objects
(anti)aliasing
R A S T E R
refresh speed independent ofscene complexity
pixel
scan conversion
resolution
bit planes
0 0 0 0 0 00 7 7 7 60 7 7 70 0 00 00
Frame buffer
Colour Lookup Table
0 0 0 0 0 00 7 7 7 6
0 7 7 70 0 0
0 00
Frame buffer
0 0 0
102 255 53
255 255 204
255 102 153
102 0 51
RR GG BB
0
1
2
4
7
...
colourindex
CLUT:
pixel = code
True colour:
pixel = R,G,B
Geometri Komputer Grafik
2D geometric modelling
• Coordinates• Transformations
Coordinates
• Point: position on planep = (px , py)x = (x, y)x = (x1 , x2)x = x1 e1 + x2 e2, e1 = (1, 0), e2 = (0, 1)
• Vector: direction and magnitudev = (vx , vy), etc.
x
yp
v
Vector arithmetic
• Addition of two vectors:v + w = (vx + wx , vy + wy)
• Multiplication vector-scalar:v = (vx , vy)
x
yw
v
v+w
x
y
v
2v
Why??
Pendefinisian Sistem Koordinatpenting karena….
• Terdapat banyak sistem koordinat padaproses/operasi komputer grafik: WorldCoordinates, Model Coordinates, ViewCoordinates
• Perlu kerangka referensi untukmemposisikan obyek dalam dunia nyata,model maupun dalam tampilan.
Contoh
• Penggambaran obyek 2D pada komputer:
x
y
x
y
Koordinat Peta
Koordinat Layar
Transformasi Geometri
Transformasi Geometri padaKomputer Grafik
• Transformasi geometri memegang perananpenting di komputer grafik karena : obyekdipindah, diperbesar untuk menghasilkanefek/modifikasi
• Graphics API (Application ProgrammingInterface) melakukan transformasi untukmenempatkan/merepresentasikan obyeksebagai tampilan
• Perlu dilakukan transformasi 3D ke 2D (obyekdengan geometri 3D ke layar 2D)
Transformation Pipeline
• World Transformation– Model coordinates World coordinates
• View Transformation– World coordinates Camera space
• Projection Transformation– Camera space View Plane
• These are a series of matrix multiplications
World Transformation
• Translation• Rotation• Scaling
+x
+z
+y
World origin
World Coordinates
Local model coordinates
Local model coordinates
View Transformation
+x
+z
+y
World origin
World Coordinates
+y
+x
+z
• Cameraposition
• Look vector
• Perbesaran (scaling), Rotation (rotasi) dantranslasi (translation) merupakan jenistransformasi yang penting pada komputergrafik.
Skala
Rotasi
Pemotongan (Shear)
Translasi (Translation)
NOT LINEAR!!!Perkalian matrix tidak dapat digunakan
Homogeneous Coordinates
• Pada komputer grafik, transformasi yangkompleks (menggunakan matrix)diperlukan.
• Dengan pendekatan Kartesian, translasidan rotasi, perbesaran tidak dapatdigabung menjadi satu proses
Xn
Yn=
X
YT *
Koordinat Homogen
• Untuk merepresentasikan transformasisebagai matrix diperlukan sistem koordinatyang mampu mewadahi rotasi, perbesarandan translasi sebagai matrix multiplikasi.
• X,y,z pada koord. Homogen = x/z, y/zpada koord. Kartesian
• (X0, y0) pada koord. Kartesian = (x0,y0,1)pada koord. Homogen = (z.x0, z.y0, z)dimana z # 0
Koord. Homogen
Translasi pada Koord. Homogen
Frank Klawonn, Intro to Computer Graphics
Koordinat Homogen• Kartu grafis pada komputer bisa bekerja
cepat karena komposisi matrix utuktransformasi dapat dirangkai menjadi satu
• urutan transformasi penting!• secara default dari kanan ke kiri
contoh
Aplikasi Transformasi (contoh)
Frank Klawonn, Intro to Computer Graphics
3D coordinate system
• Pada koordinat 2D : semua datar• Untuk merepresentasikan kedalaman
diperlukan koordinat z• 3 sumbu koordinat!!• Semua titik pada ruang 3D dapat
dinyatakan sebagai x,y,z
3D coordinate system
x
y
z
(5,0,0)
(5,5,0)
(5,5,5)
(0,0,0)
(0,0,5)
(0,5,5)
(5,0,5)
(0,5,5)
a
b
c
d
e
fg
h
i
j
k
l
Koordinat Homogen
• Melibatkan tidak hanya koordinat x,y dan ztetapi juga nilai w (matrix 4 x 4)
• Titik 3D (x,y,z) direpresentasikan sebagai(x,y,z,1).
• Jika nilai w tidak 1 (x/w, y/w, z/w, 1)
Terms and definitions
C
x
y
z A
B
A’
B’
screenz extent
x extent
y extent
view volume
centre of projection
2D -> 3D• good news is that we can still use our drawing, shape, line
and point classes.
• bad news is that they are all going to require some (hopefullysmall) alterations to work in 3d.
3D Points
1zyx•Still using homogenous
coordinates
•Need 4 coords )1,,,( zyx
3D Transformations
– Since we now have an additional coordinateto cope with, our transformation matricesmust also expand to cope.
– each transformation matrix with require anextra row and an extra column to become4x4 matrices.
Scaling
x
y
z
1
.
1000000000000
1zyx
SS
S
zyx
z
y
x
Translation
x
y
z
1
.
1000100010001
1zyx
TTT
zyx
z
y
x
Rotation (about axes)• In 2 dimensions, rotation were defined to take place about
some stationary point - the centre of rotation.
• In 3d, all rotation take place about one of the axes.
x
y
z
x
y
z
x
y
z
+ve
+ve
+ve
Rotation (about axes)
x
y
z
=-90°
-90 about x axis
Rotation
• x-axis
• y-axis
• z-axis
1
.
10000cossin0
0sincos00001
1z
yx
z
yx
1
.
10000cos0sin
00100sin0cos
1z
yx
z
yx
1
.
10000100
00cossin00sincos
1z
yx
z
yx
Local Rotation
• translate the object tobe rotated to theorigin, perform therotation and translateit back to where itstarted from
x
y
z
=-90°
Proyeksi
• Representasi object 3D di atas layar 2D• Asal muasalnya dan seringnya digunakan
oleh juru gambar dan arsitek dalammenggambar desain
• Several different projections existBergantung dari arah penglihatanpengamat
Terms and definitions
C
x
y
z A
B
A’
B’
screenz extent
x extent
y extent
view volume
centre of projection
(also called plane)
Macam Proyeksi
…so?
• We need to calculate the screen coordinates(xsys) of each projected point from the 3dcoordinates– (they’re not the same!)
• Usually!
• Fortunately – we can consider this calculationas a transformation.
• Can use matrices to represent the variousways of doing it.
Parallel Projection
1
.
10000000
00100001
10 z
yx
yx
s
s
Perspective Projection
1
.
1/100000000100001
1
0 zyx
ddz
yx
s
s
Perspective Projection
p (x,y,z)
z
x
screen
ps (xs,ys)C
d
By similar triangles:
dx
dzx s
dz
xxs
1
dz
yys
1
Perspective Projection
10
1
1
.
dz
ydz
x
want So….Divide by
dz
1
Perspective Projection
1
.
1/100000000100001
1
0 zyx
ddz
yx
s
s
Oblique Parallel Projections• A parallel projection is one where all the lines that are
parallel in 3d space remain parallel when projected.
• An oblique parallel projection is one where the object inquestion is viewed “from the side” - unlike the (plain)parallel projection.
• The z axis is drawn at some angle () to the x axis
• A number of standard oblique parallelprojections are used in engineering drawing:
– cavalier
– cabinet
– orthogonal
Cavalier Projection
The length of a line onthe screen is equal to itslength in the model.
This causes a distortionby over emphasising thez-axis
Cabinet Projection
The foreshortening of the zaxis is increased to provide amore “realistic” view.
Orthogonal Projection
The orthogonal projection isjust the simple parallelprojection
Oblique Parallel Projections
x
y
(xs,ys)
(0,0,1)P
Consider the point P:
P can be represented in 3Dspace - (0,0,1)
P can be represented in 2D(screen coords) - (xs,ys)
P can be represented in 2Dvia polar coordinates - (,)
Oblique Parallel Projections
• At (0,0,1)xs = cos ys = sin
• Generally– multiply by z and allow for (non-zero) x and y
xs= x + z..cos ys = y + z..sin
Oblique Parallel Projection
x
y
z
(0,0,1)
Cavalier cabinetand orthogonalprojections can allbe specified interms of ()
-or () since
tan = 1/
Oblique Parallel Projection
= 0 – 360Orthogonal projection= 90=0
= 0 – 360Cabinet projection= 63.4=0.5
= 0 - 360Cavalier projection= 45=1
Oblique Parallel Projectionas a matrix
1
.
100000000sin100cos01
10 z
yx
yx
s
s
Isometric Projection
1000060cos060sin0010060cos060sin
All 3 axes are equally foreshortened allowingmeasurements along the axes to made with the same scale.