1
Computer Graphics
Marco Tarini
Università dell’Insubria
Facoltà di Scienze MFN di Varese Corso di Laurea in Informatica Anno Accademico 2012/13
Lezione Lezione Lezione Lezione 17: 17: 17: 17:
Geometry Shader (cenni)
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 2 / 1 3 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Fr ammenti & a tt ri b u ti & a tt ri b u ti & a tt ri b u ti & a tt ri b u ti in te rp o la ti in te rp o la ti in te rp o la ti in te rp o la ti Ver tic i & l or o at tr ib u ti & l or o at tr ib u ti & l or o at tr ib u ti & l or o at tr ib u ti
Screen buffer Ver tic i por ie ttati & a tt ri b u ti & a tt ri b u ti & a tt ri b u ti & a tt ri b u ti c o m p u ta ti c o m p u ta ti c o m p u ta ti c o m p u ta ti
rasterizer triangoli set-
up rasterizer segmenti set-
up rasterizer
punti set-
up
c o m p u ta z io n i p e r v e rti c e c o m p u ta z io n i p e r fra m m e n to
Nuove + vecchie primitive!
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 2 / 1 3 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Fr ammenti & a tt ri b u ti & a tt ri b u ti & a tt ri b u ti & a tt ri b u ti in te rp o la ti in te rp o la ti in te rp o la ti in te rp o la ti Ver tic i & l or o at tr ib u ti & l or o at tr ib u ti & l or o at tr ib u ti & l or o at tr ib u ti
Screen buffer Ver tic i por iettati & a tt ri b u ti & a tt ri b u ti & a tt ri b u ti & a tt ri b u ti c o m p u ta ti c o m p u ta ti c o m p u ta ti c o m p u ta ti ra s te ri z e r tri a n g o li s e t- u p ra s te ri z e r s e g m e n ti s e t- u p
ra s te ri z e r p u n ti s e t- u p
c o m p u ta z io n i p e r v e rti c e c o m p u ta z io n i p e r fra m m e n to
geometry shader
Geometry Shader: in breve
• agisce dopo il vertex shader
• è programmabile (GLSL in OpenGL)
+ comandi come: emitVertex endPrimitive
• accede:
+ agli N vertici (già processati) della primitiva + loro attributi
+ qualche informazione di adiacenza
• produce nuove primitive – “on-card primitive generation”
– aka: “on-card geometry amplification”
(mando poche primitive, ne escono tante)
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 2 / 1 3 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Geometry Shader
• da OpenGL 3.2 (o Direct3D 10)
• estensione molto flessibile
• potenzialmente utile in molti algoritmi, es:
– suddividere (sup. di suddivisione) – displacement mapping
– marching cubes on the GPU
– calcolo di proprietà per faccia! (es: normali?) – etc... (potenzialità ancora da esplorare!)
• MA: cara
– spesso: impatto negativo sulle performance
– diffusione del supporto HW ancora non pervasiva (su PC)
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 2 / 1 3 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Geometry shader: esempio
bump-mapping
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 2 / 1 3 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a