Visibilidade MO603/MC930. Visibilidade Algoritmos básicos de visibilidade Algoritmo pintor Z-buffer Estilos de Shading Ray-casting.

Slides:



Advertisements
Similar presentations
Computer Graphics - Rasterization -
Advertisements

Visible-Surface Detection(identification)
GR2 Advanced Computer Graphics AGR
15.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 15 – Visible Surfaces and Shadows.
GR2 Advanced Computer Graphics AGR
8.1si31_2001 SI31 Advanced Computer Graphics AGR Lecture 8 Polygon Rendering.
Collisions and Intersections When objects move, test for collision. When projecting surfaces, check for intersections. (Many slides adapted from Amitabh.
CSC418 Computer Graphics n Polygon normals n Back Faces n Visibility Algorithms.
Polygon Rendering Flat Rendering Goraud Rendering Uses Phong Reflectance Phong Rendering.
CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
More HSR, OpenGL Buffers & Tests Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Monday, February 2, 2004.
Graphics Pipeline.
2 COEN Computer Graphics I Evening’s Goals n Discuss the fundamentals of lighting in computer graphics n Analyze OpenGL’s lighting model n Show.
Computer Graphics(Fall 2003) COMS 4160, Lecture 7: OpenGL 3 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
CS 4363/6353 BASIC RENDERING. THE GRAPHICS PIPELINE OVERVIEW Vertex Processing Coordinate transformations Compute color for each vertex Clipping and Primitive.
Week 7 - Monday.  What did we talk about last time?  Specular shading  Aliasing and antialiasing.
Week 10 - Monday.  What did we talk about last time?  Global illumination  Shadows  Projection shadows  Soft shadows.
Lecture Fall 2001 Visibility Back-Face Culling Painter’s Algorithm.
CAP4730: Computational Structures in Computer Graphics Visible Surface Determination.
CECS461 Computer Graphics II University of Missouri at Columbia Hidden Surface Removal.
Visibility in Computer Graphics Toni Sellarès Unversitat de Girona
Computer Graphics Visible Surface Determination. Goal of Visible Surface Determination To draw only the surfaces (triangles) that are visible, given a.
Graphics Graphics Korea University cgvr.korea.ac.kr 1 Hidden Surface Removal 고려대학교 컴퓨터 그래픽스 연구실.
Part I: Basics of Computer Graphics
Chapter 6: Vertices to Fragments Part 2 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley Mohan Sridharan Based on Slides.
1 Dr. Scott Schaefer Hidden Surfaces. 2/62 Hidden Surfaces.
CS 4731: Computer Graphics Lecture 18: Hidden Surface Removal Emmanuel Agu.
Tomas Mőller © 2000 Speeding up your game The scene graph Culling techniques Level-of-detail rendering (LODs) Collision detection Resources and pointers.
Hidden Surface Elimination Wen-Chieh (Steve) Lin Institute of Multimedia Engineering I-Chen Lin’ CG Slides, Rich Riesenfeld’s CG Slides, Shirley, Fundamentals.
1 CSCE 441: Computer Graphics Hidden Surface Removal (Cont.) Jinxiang Chai.
Visibilidade MO603/MC930. Visibilidade Algoritmos básicos de visibilidade Algoritmo pintor Z-buffer Ray-casting.
Vertices and Fragments III Mohan Sridharan Based on slides created by Edward Angel 1 CS4395: Computer Graphics.
Basic Ray Tracing CMSC 435/634. Visibility Problem Rendering: converting a model to an image Visibility: deciding which objects (or parts) will appear.
CSE 872 Dr. Charles B. Owen Advanced Computer Graphics1 Other Rendering Techniques Types of rendering – Wireframe techniques – Scan-line conversion – Reyes.
10/11/2001CS 638, Fall 2001 Today Kd-trees BSP Trees.
Introduction to 3D Graphics John E. Laird. Basic Issues u Given a internal model of a 3D world, with textures and light sources how do you project it.
Hidden Surface Removal
Graphics Pipeline Hidden Surfaces CMSC 435/634. Visibility We can convert simple primitives to pixels Which primitives (or parts of primitives) should.
Shadows Computer Graphics. Shadows Shadows Extended light sources produce penumbras In real-time, we only use point light sources –Extended light sources.
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 19 Other Graphics Considerations Review.
Visible-Surface Detection Jehee Lee Seoul National University.
Basic Ray Tracing CMSC 435/634. Visibility Problem Rendering: converting a model to an image Visibility: deciding which objects (or parts) will appear.
2 COEN Computer Graphics I Evening’s Goals n Discuss application bottleneck determination n Discuss various optimizations for making programs execute.
1Computer Graphics Implementation II Lecture 16 John Shearer Culture Lab – space 2
Implementation II Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Binary Space Partitioning Trees Ray Casting Depth Buffering
Implementation II.
David Luebke11/26/2015 CS 551 / 645: Introductory Computer Graphics David Luebke
Chapters 5 2 March Classical & Computer Viewing Same elements –objects –viewer –projectors –projection plane.
Ray Tracing Fall, Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer.
Computer Graphics I, Fall 2010 Implementation II.
Real-Time Dynamic Shadow Algorithms Evan Closson CSE 528.
1 CSCE 441: Computer Graphics Hidden Surface Removal Jinxiang Chai.
CS559: Computer Graphics Lecture 12: Antialiasing & Visibility Li Zhang Spring 2008.
01/28/09Dinesh Manocha, COMP770 Visibility Computations Visible Surface Determination Visibility Culling.
Visible-Surface Detection Methods. To identify those parts of a scene that are visible from a chosen viewing position. Surfaces which are obscured by.
Computer Graphics (Fall 2003) COMS 4160, Lecture 5: OpenGL 1 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
Basic Ray Tracing CMSC 435/634.
Computer Graphics Implementation II
Week 7 - Monday CS361.
Solid Area Scan Conversion or Visible Surface Detection
CSC418 Computer Graphics Back Faces Visibility Algorithms.
CSCE 441: Computer Graphics Hidden Surface Removal (Cont.)
Visible-Surface Detection Methods
CSCE 441: Computer Graphics Hidden Surface Removal
Implementation II Ed Angel Professor Emeritus of Computer Science
CSCE 441: Computer Graphics Hidden Surface Removal (Cont.)
CSCE 441: Computer Graphics Hidden Surface Removal (Cont.)
Introduction to Computer Graphics with WebGL
Implementation II Ed Angel Professor Emeritus of Computer Science
Presentation transcript:

Visibilidade MO603/MC930

Visibilidade Algoritmos básicos de visibilidade Algoritmo pintor Z-buffer Estilos de Shading Ray-casting

The visibility problem What is the nearest surface seen at any point in the image? How would YOU solve this problem?

Removendo superfícies ocultas A B

while (1) { get_viewing_point_from_mouse_position(); glClear(GL_COLOR_BUFFER_BIT); draw_3d_object_B(); draw_3d_object_A(); }

Removendo superfícies ocultas while (1) { get_viewing_point_from_mouse_position(); glClear(GL_COLOR_BUFFER_BIT); draw_3d_object_A(); draw_3d_object_B(); }

Removendo superfícies ocultas B A

Image Space Visibility Algorithms

Painters Algorithm Sort objects by depth (Z) Loop over objects in back-to-front order Project to image scan convert: image[x,y] = shade(x,y)

Sorting Objects by Depth Z Z min A B A B A B Sorting Objects by Depth R B G R1 R2 B G

Painter´s Algorithm Strengths –Simplicity: draw objects one-at-a-time, scan convert each –Handles transparency well Drawbacks –Sorting can be expensive (slower than linear in the number of objects) –Clumsy when ordering is cyclic, because of need to split –Interpenetrating polygons need to be split, too –Hard to sort non-polygonal objects Sometimes no need to sort –If objects are arranged in a grid, e.g. triangles in a height field z(x,y), such as a triangulated terrain Who uses it? –Postscript interpreters –OpenGL, if you dont glEnable(GL_DEPTH_TEST);

Representando objetos por malhas triangulares Divide objeto em faces triangulares A junção de todas as faces forma a casca do objeto Triangulo = estrutura (P1, P2, P3) T1={P1,P2,P3}, T2={P2,P4,P3} T3={P2, P5, P6}, T4={P6, P1, P2}, … Objeto = T1, T2, T3, T4, …

Backface culling Each polygon is either front-facing or back-facing –A polygon is backfacing if its normal points away from the viewer, –i.e. VN >= 0 When it works –If object is closed, back faces are never visible so no need to render them –Easy way to eliminate half your polygons –Can be used with both z-buffer and painters algorithms –If object is convex, backface culling is a complete visibility algorithm! When it doesnt work –If objects are not closed, back faces might be visible V N1 N2

Z-Buffer Algorithm Initialization loop over all x,y zbuf[x,y] = infinity Drawing steps loop over all objects scan convert object (loop over x,y) if z(x,y) < zbuf[x,y] compute z of this object at this pixel & test zbuf[x,y] = z(x,y) update z-buffer image[x,y] = shade(x,y) update image (typically RGB)

Z-Buffer Algorithm Strengths –Simple, no sorting or splitting –Easy to mix polygons, spheres, other geometric primitives Drawbacks –Cant handle transparency well –Need good Z-buffer resolution or you get depth ordering artifacts In OpenGL, this resolution is controlled by choice of clipping planes and number of bits for depth Choose ratio of clipping plane depths (zfar/znear) to be as small as possible Who uses it? –OpenGL, if you glEnable(GL_DEPTH_TEST);

Usando o buffer de profundidade glutInitDisplayMode (GLUT_DEPTH |.... ); glEnable(GL_DEPTH_TEST);... while (1) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); get_viewing_point_from_mouse_position(); draw_3d_object_A(); draw_3d_object_B(); }

Ray Casting A very flexible visibility algorithm loop y loop x shoot ray from eye through pixel (x,y) into scene intersect with all surfaces, find first one the ray hits shade surface point to compute pixel (x,y)s color

Comparing visibility algorithms Painters: –Implementation: moderate to hard if sorting & splitting needed –Speed: fast if objects are pre-sorted, otherwise slow –Generality: sorting & splitting make it ill-suited for general 3-D rendering Z-buffer: –Implementation: moderate, it can be implemented in hardware –Speed: fast, unless depth complexity is high –Generality: good but wont do transparency Ray Casting: –Implementation: easy, but hard to make it run fast –Speed: slow if many objects: cost is O((#pixels)´(#objects)) –Generality: excellent, can even do CSG, transparency, shadows

Really Hard Visibility Problems Extremely high scene complexity –a building walkthrough (QUAKE)? –A fly-by of the Grand Canyon (or any outdoor scene!) Z-buffering requires drawing EVERY triangle for each image –Not feasible in real time Usually Z-buffering is combined with spatial data structures –BSP trees are common (similar concept to octrees) For really complex scenes, visibility isnt always enough –Objects WAY in the distance are too small to matter –Might as well approximate far-off objects with simpler primitives –This is called geometry simplification

Programa exemplo (esfera) #include

Programa exemplo (esfera) void init(void) { GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat mat_shininess[] = { 50.0 }; GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; glClearColor (0.0, 0.0, 0.0, 0.0); glShadeModel (GL_SMOOTH); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); glLightfv(GL_LIGHT0, GL_POSITION, light_position); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_DEPTH_TEST); }

Programa exemplo (esfera) void display(void) { glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glutSolidSphere (1.0, 20, 16); glFlush (); }

Programa exemplo (esfera) void reshape (int w, int h) { glViewport (0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode (GL_PROJECTION); glLoadIdentity(); if (w <= h) glOrtho (-1.5, 1.5, -1.5*(GLfloat)h/(GLfloat)w, 1.5*(GLfloat)h/(GLfloat)w, -10.0, 10.0); else glOrtho (-1.5*(GLfloat)w/(GLfloat)h, 1.5*(GLfloat)w/(GLfloat)h, -1.5, 1.5, -10.0, 10.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); }

Programa exemplo (esfera) int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize (500, 500); glutInitWindowPosition (100, 100); glutCreateWindow (argv[0]); init (); glutDisplayFunc(display); glutReshapeFunc(reshape); glutMainLoop(); return 0; }

Resultado

Comentários Definir vetores normais para todos vértices: glutSolidSphere() faz isso. Criar, posicionar e habilitar uma (ou mais) fontes de luz: glLightfv(), glEnable(), glLight*() Ex: GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; glLightfv(GL_LIGHT0, GL_POSITION, light_position); default: GL_POSITION é (0, 0, 1, 0), eixo-Z negativo Selecionar um modelo de iluminação: glLightModel*() Definir propriedades materiais para os objetos na cena

Lembre-se Voce pode usar valores defaults para alguns parâmetros, de iluminação; outros devem ser modificados Não se esqueça de habilitar todas as luzes que pretende usar e também habilitar o cálculo de iluminação Voce pode usar display lists para maximizar eficiência quando é necessário mudar as condições de iluminação

Computing Z for Z-buffering How to compute Z at each point for z-buffering? Can we interpolate Z? –Linear interpolation along edge, along span –Not quite. World space Z does not interpolate linearly in image space But if we linearly interpolate image space Z, it works! –Perspective transforms planes to planes –Note that image space Z is a nonlinear function of world space Z