• me: Marco Tarini
e-mail: marco.tarini@isti.cnr.it
• Consulting hours :
after each lecture, or, contact me
• course web page:
1. google for: “Marco Tarini”
2. follow 1st link (that’s me) 3. tab “teaching” (page bottom!) 4. “Computer Graphics 16/17”
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
1
Computer Graphics
Marco Tarini
Università dell’Insubria
Corso di Laurea in Informatica Anno Accademico 2016/17
Lez 0: Intro and applications
2
Needed tools
• A bit of math
– Linear Algebra:
• esp. vector, matrices (3x3 or 4x4)
• A bit of algorithms
– E.g. evaluating the complexity of an algo
• A lot of willingness to learn
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
3
A definition
CG: Computer Graphics
a sub-field of computer science which studies methods for digitally synthesizing and manipulating visual content.
CGI: Computer Generated Imagery
• In general terms:
1. Digital modelling of (generally) 3D entities 2. From those, to synthetic images
• A large fields
– this is an introductory course
• Rapidly advancing field
– in the last ~ three dozens years
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
5
CG: technologies
• HW
– input:
• keyboard, mouse
• gloves, trackballs, gamepads,
• tracked devices (e.g. nintendo Wii)
• scanning device (e.g. xbox kinect)
• … – output:
• monitors, projectors
• multiple projector systems
• stereo (“3D”) video systems
• holographic displays
• ...
– input + ouput:
• haptic interfaces
• VR / oculus rift
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
6
Scientific fields surrounding Computer Graphics
Algorithms and Data Structures
(like anything in computer science?)
Hardware architectures
as CG uses a lot of dedicated hardware (“GPU”)
Computational Geometry
algorithms for tasks with an immediate geometric interpretation
Computer Vision
robotic vision, in a sense, the inverse problems of CG
Image Processing
the cousin on the 2D side
Parallel Computing
because they reuse the dedicated hardware designed for CG
Interactive techniques (HCI – human computing interaction)
GUI: Graphics User Interfaces
Scientific Visualization (and Data Visualization) uses CG at its core
FIELDSUSEDBYCGFIELDSBOUNDINGCGFIELDSUSINGCG
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
7
Computer Graphics: applicazioni
• Cultural heritage
– musei virtuali – supporto al restauro – supporto all’analisi – monitoring
• Medicina
– supporto alla diagnosi – telechirurgia
– simulazioni
• Architetturali
– Supporto al design – Previews
• …
• Videogiochi
• Cinematografia
– Visual effects – Film di animazione
• Scientific Visualization
• Manufacturing industry
– e.g. Computer Aided Design
• Telecommunications
– Personalized Avatars – E–commerce
• Virtual Reality
– e augmented reality
• Visualizzazione Scientifica
– aka: SciVis , visual data analysis ...
(TACC Scientific Visualization group)
(Pittsburg Supercomputing center) (NASA)
• Visualizzazione di dati scientifici
• fenomeni meteorologicici, medici, biologici, chimici, fisici, astrofisici, etc etc
• Origine dei dati:
• l’output di una simulazione
• acquisiti con qualche sistema di misura
Tipicamente: grandi quantità di dati
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
9
Visualizzazione Scientifica
Onde gravitazionali durante una collisione di buchi neri
(Max Planck Insitute for Gravitational Physics) Rhinovirus 3 protein
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
10
Visualizzazione Scientifica
• Visualizzazione Scientifica – aka: SciVis ,
visual data analysis ...
(superficie di un vetro -- Nanorobotics Lab (Carnegie Mellon University )
(Pittsburg Supercomputing center) (NASA)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
11
Visualizzazione Scientifica
• Visualizzazione Scientifica
– aka: SciVis , visual data analysis ...
parentesi parentesi parentesi parentesi parentesi
• dati astratti (N dimensionali)
• Scopo:
chiarezza/leggibilità
• Mezzi:
i più vari
13
• dati con un interpretazione 3D “naturale”
– spesso:
+ dimensione tempo
• Scopo:
chiarezza/leggibilità
• Mezzi:
realismo, oppure …
parentesi parentesi parentesi parentesi parentesi
parentesi parentesi parentesi parentesi parentesi VS
14
Scientific Visualization Data Visualization
Simulaz.
relazione fra due fluidi di densità diverse
Data Visualzion: an early example
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
15 Charles Minard, 1869: Napoelon Campaign
Computer Graphics: applicazioni
• Cultural heritage
– musei virtuali – supporto al restauro – supporto all’analisi – monitoring
• Medicina
– supporto alla diagnosi – telechirurgia
– simulazioni
• Architetturali
– Supporto al design – Previews
• …
• Videogiochi
• Cinematografia
– Visual effects – Film di animazione
• Scientific Visualization
• Manufacturing industry
– e.g. Computer Aided Design
• Telecommunications
– Personalized Avatars – E–commerce
• Virtual Reality
– e augmented reality
• applicazioni medicali – supporto alla diagnosi
• e.g. visualizz. CAT scans
– chirurgia virtuale – tele-chirurgia
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
18
Computer Graphics: applicazioni
• Industria Manifatturiera – CAD
– Rapid Prototyping – Simulazioni
di funzionamento – Defect detection – …
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
19
Computer Graphics: applicazioni
• Entertainment: movie industry – visual effects (non special fx)
Jurassic Park - Universal Studios 1993M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a Star Wars: The Phantom Manace - Lucasart 1999
20
parentesi parentesi parentesi parentesi parentesi
Effetti Visuali VS Effetti Speciali
• (in post-produzione) (sul set)
(es: stuntmen, corde, esplosioni, …)
• Entertainment: movie industry – CG shorts
Luxo Jr - Pixar 1986 Geri's Game - Pixar 1997
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
22
Computer Graphics: applicazioni
• Entertainment: movie industry – CG shorts
– Feature movies
Toy Story - Pixar 1995Geri's Game - Pixar 1997
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
23
Computer Graphics: applicazioni
• Entertainment:
movie industry – Feature movies
fotorealistici
Final Fantasy – Squaresoft 2001
Final Flight Of the Osiris – Squaresoft 2003M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a Avatar – ILM 2009
24
parentesi parentesi parentesi parentesi parentesi
Uncanny valley
• Entertainment: giochi
– forza trainante del settore (crederci o no) ...
Battlezone – Atari 1980
Tailgunner - Cinematronics 1979
26
Computer Graphics: applicazioni
• Entertainment: giochi
– forza trainante del settore (crederci o no) ...
Doom – IDsoft 1993
Virtua Fighter - Sega 1993
27
Computer Graphics: applicazioni
• Entertainment: giochi
– forza trainante del settore (crederci o no) ...
Doom 3- ID soft 2004
World of Warcraft,
Blizzard Entertainment 2004
28
GTA -
Computer Graphics: applicazioni
• Entertainment: giochi
• Beni Culturali – Presentazione
• musei virtuali
• cataloghi di musei reali
• supporto alla didattica
• documentaristica...
– Supporto al restauro
• Modello 3D come GIS
• Simulazioni...
– Studio
• Analisi dei dati
• vedi SciVis
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
30
Beni Culturali
• Uso:
– fruizione (musei virtuali..) – documentaristica – didattica – monitoraggio
• Mezzi:
– acquisizione della forma ( 3DScanning ) – acquisizione del colore
– Tecniche di visualizzazione di grandi moli di dati (multiresolution, out of core rendering)
Visual Computing Lab – ISTI-CNR Pisa
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
31
Beni Culturali: Fruizione
• Chioschi: supporti multimediali ai musei tradizionali – PC + video, l’utente esamina le opere, legge note informative – esempi: il Davide di Michelangelo alla Galleria dell’Accademia di Firenze – esempi: Il monumento funebre di Arrigo VII all’Arcivescovado
• Diffusione via rete
– L’utente visita un museo (o una singola opera) dal PC di casa
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
32
Beni Culturali: Fruizione
• Beni Culturali
– musei virtuali
– supporto multimediale musei tradizionali
• Beni Culturali
– presentazione in rete
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
34
Beni Culturali: Restauro
• Il restauratore si faceva fare degli schizzi su carta dell’opera da restaurare per fare una mappa degli interventi: col il modello virtuale può gestire tutto su PC
• Acquisizione dell’opera prima e dopo il restauro e confronto geometrico delle differenze
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
35
Computer Graphics: applicazioni
• Beni Culturali
– modello 3D come "GIS"
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
36
Beni Culturali: Studio
• ES: Simulazione caduta contaminanti
15 degrees
5 degrees
• es: monitorare nel tempo la variazioni sui materiali deformabili
foresta di Dunarobba
http://www.forestafossile.it/public/new/
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
38
Beni Culturali: i mezzi
oggetto reale Rappresentazione digitale
Strumento di acquisizione
processing dei dati
• Acquisizione della forma geometrica (3D scanning)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
39
Beni Culturali: i mezzi
• Acquisizione della forma geometrica
(es: 3D scanning)
Visual Computing Lab – Stanford Uni 2000
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
40
Beni Culturali: i mezzi
• Acquisizione del colore
– semplici fotografie
• approssimato, dipende dalla luce
– Tecniche di calcolo della BRDF
Ci torniamo sopra con calma
– musei virtuali – supporto al restauro – supporto all’analisi – monitoring
• Medicina
– supporto alla diagnosi – telechirurgia
– simulazioni
• Architetturali
– Supporto al design – Previews
• …
• Cinematografia
– Visual effects – Film di animazione
• Scientific Visualization
• Manufacturing industry
– e.g. Computer Aided Design
• Telecommunications
– Personalized Avatars – E–commerce
• Virtual Reality
– e augmented reality
Computer Graphics: applicazioni
• Architettura:
– supporto al design
ArchiCAD (Graphsoft)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
43
Computer Graphics: applicazioni
• Architettura:
– preview:
• comunicazione
• assessment
Brazil – SputterFish
44
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Summary
• Grafica Computazionale (Computer Graphics - CG ):
– molteplici applicazioni
– medicali – industriali – beni culturali – militari
– telecomunicazioni – commerciali
– ricerca scientifica (scivis)
– intrattenimento: games
– intrattenimento: movies
applicazione interattiva
informazione
modellazione
rappresentazione adeguata
(per...)
Immagine/i
rendering /visualizzazione
preprocessing modelling
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
46
esempio: acquisizione 3D per beni culturali
chiosco museale
Statua reale Range scanning (scansione laser) Mesh poligonale 3D
Immagine/i
rendering
Semplificazione, flitering…
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
47
esempio: games
videogame
Artista
(conent creator) modellazione manuale
(e.g. 3Dstudio max, Maya, Blender…)
Mesh low-poly + textures
Immagine/i
rendering /visualizzazione
semplificazione, u-v mapping, rigging…
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
48
esempio: sci-vis analisi di un terremoto
Modello matematico
del terremoto Simulazione fisica
Campo di altezza (time-varying)
Immagine/i
rendering /visualizzazione
processing vari…
(es color-coding)
• A very general term
Something rendering Image
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
50
Rendering
• Example: in web browsers
the image appearing in the browser
rendering
...
HTML page + images, ccs, etc (which models a Web Page)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
51
Rendering
• In our case
3D Scene 3D rendering Image
ultimately, composed by a set of primitives
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
52
rasterized:
a 2D grid of pixels
Rendering
• Rendering 3D
Immagine Scena 3D
...
3D model
• 3D point
3D rendering
• Due tipi:
– On-Line Rendering
• Interattivo: circa 1 – 10 frames per sec ("fps")
• Real-Time: circa 10-100 fps
– Off-line Rendering
• Tipicamente: da minuti ad ore per fotogramma
• Molto differenti:
– nelle applicazioni – nei vincoli
– nella qualità visiva raggiunta (e.g. fotorealismo) – negli algoritmi e SD usate
insomma: approcci diversi, mondi diversi.
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
54
Real Time VS Offline rendering
• Distanza si accorcia
Jurassic Park - Universal Studios 1993
real time
1993
Virtua Fighter - Sega 1993
Jurassic Park - Universal Studios 1993
offline
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
55
Real Time VS Offline rendering
• Distanza si accorcia
Jurassic Park - Universal Studios 1993
Final Fintasy – Squaresoft 2001 nVIDIA tech demo at SIGGRAPH 2001
nVIDIA quadro
2001
real time offline
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
56
Real Time VS Offline rendering
• Distanza si accorcia
2007
GPUGems III, d'Eon & Luebke (NVidia), 2007
real time offline
Spiederman 3– Squaresoft 2007
• Rendering 3D
Scena 3D rendering Immagine
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
58
Immagine: su che display hardware ?
• Su un monitor, naturalmente!
• Il tubo catodico: un fascio di elettroni viene diretto su una superficie coperta di materiale fosforescente
– Display vettoriali:
il fascio veniva pilotato direttamente in maniera totalmente libera
– Display CRT:
raster linea per linea,
si spazza tutto lo schermo un certo numero di volte al secondo (refresh rate)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
59
Immagine: su che display hardware ?
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
60
1980(Asteroids – Atari )1984(Bomb jack – Tehkan)
Display vettoriali
Display CRT
Frame buffer
• Una porzione di memoria dedicata alla memorizzazione dell’immagine
– come array 2D di pixel da mostrare a video.
• Caratteristiche:
– Risoluzione (numero di pixel)
• Range tipici 320x200 .. 1600x1200
– Profondità (bit per pixel)
• Range tipici 1 .. 32 (128)
• Divisi in tipicamente 4 (o 3) canali ( R, G, B e Alpha)
• Ci occuperemo principalmente di:
Real Time 3D Rendering
Scena 3D rendering Immagine
screen buffer
( array 2D di pixel )
N volte al sec
( es N=60 )
dal resto dell' applicazione
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
62
Real Time 3D Rendering
Problema challanging! per esempio:
• pixel = 32 bit = 4 bytes ("pixel depth")
• screen buffer = 1024 x 768 pixels ("screen resolution")
• frame rate = 60 Hrz ("fps")
188 MegaBytes / sec
(in questo esempio)
• total = 4 x 1024 x 768 x 60 byte al sec ("fill-rate", in bytes )
(e mancano altri fattori moltiplicativi, come depth complexity, multipassate… vedremo) 63
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Real Time 3D Rendering
• Fill-rates molto elevati – Anticipazione:
...e il fill-rate non è sempre il collo di bottiglia – Anticipazione 2:
...e questa è una sottostima del fill-rate.
• manca il fattore depth-complexity ~ x2.5 (come vedremo...)
• sono piu' di 32 bit x pixel
• C'è bisogno di muscoli potenza di calcolo
~
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
64
Real Time 3D Rendering
• Problema difficile – fortunatamente,
processo massicciamente parallelizzabile – "embarrassingly parallel"
• Ingrediente base della soluzione:
hardware specializzato
Real-Time
Hardware-Based 3D Rendering
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
66
Ci occuperemo poco (o nulla) di altri aspetti della CG: sono solo 6 CFU !
• Altri paradigmi di rendering
– es. offline rendering, radiosity, global illumination, raytracing…
• Data representation
– es. volumetric data, polygonal meshes, NURBS, splines, subdivision surfaces, LODs, multiresolution structures…
• 3D acquisition (catturare modelli 3D dalla realtà)
– es . “shape from shading (silhouettes)”, range scanning, BRDF acquisition…
• Modellazione di superfici
– es. surface simplification, filtering, denoising, parametrization…
• Image-based rendering + modelling – es. light fields, mixed representations,
• Applicazioni specifiche della CG
– es. scientific or data visualization, beni culturali, games
• Animation techniques
– es. keyframing, cinematica diretta /inversa, skeletal animations, rigging…
• GP-GPU, o CUDA, o OpenCL
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
67
Text books
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 6 / 1 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a