Computer Graphics
Si Lu
Fall 2017
http://web.cecs.pdx.edu/~lusi/CS447/CS447_547_Comp uter_Graphics.htm 10/30/2017
Computer Graphics Si Lu Fall 2017 - - PowerPoint PPT Presentation
Computer Graphics Si Lu Fall 2017 http://web.cecs.pdx.edu/~lusi/CS447/CS447_547_Comp uter_Graphics.htm 10/30/2017 Last time o Rasterization 2 Today o Hidden Surface Removal 3 Demo o Lytro Volume Tracer n Light Field rendering solution for
http://web.cecs.pdx.edu/~lusi/CS447/CS447_547_Comp uter_Graphics.htm 10/30/2017
2
3
4
5
n Object precision: computations that operate on primitives n Image precision: computations at the pixel level
n World, View and Canonical Screen spaces might be used n Depth can be updated on a per-pixel basis as we scan convert polygons or lines n Actually, run Bresenham-like algorithm on z and w before perspective divide
6
n Choose an order for the polygons based on some choice (e.g. depth of a point
n Render the polygons in that
n doesn’t work in this form for most geometries - need at least better ways of determining ordering zs xs
Fails
Which point for choosing
7
n Color buffer stores the current color of each pixel
n Z-buffer stores at each pixel the depth of the nearest thing seen so far
n if depth < z-buffer depth, fill in pixel color and new depth n else disregard
8
n Simple and now ubiquitous in hardware
n Computing the required depth values is simple
n Over-renders – rasterizes polygons even if they are not visible n Depth quantization errors can be annoying n Can’t easily do transparency or filter-based anti-aliasing (Requires keeping information about partially covered polygons)
9
n To clear color and depth:
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
(windowing system dependent, and hardware may impose limits based on available memory)
10
n Coverage mask: Matrix of bits saying which parts of the pixel are covered
n if polygon is opaque and covers pixel, insert into list, removing all polygons farther away n if polygon is transparent or only partially covers pixel, insert into list, but don’t remove farther polygons
11
n At each pixel, traverse buffer using polygon colors and coverage masks to composite:
n Can do more than Z-buffer n Coverage mask idea can be used in other visibility algorithms
n Not in hardware, and slow in software n Still at heart a z-buffer: Over-rendering and depth quantization problems
12
n Tree gives a rendering order n A list-priority algorithm
n The world is broken into convex cells n Each cell is the intersection of all the half-spaces of splitting planes on tree path to the cell
13
A C B 2 4 1 3 A B C 3 2 4 1
+ +
14
n May have to chop polygons in two (Clipping!)
n Optimal means minimum number of polygon fragments in a balanced tree
15
2D, for a 3 room building
n Ignoring doors
shown
n “Back” side of edge is side with the number 1 2 3 4 5 6
16
1 2 3b 4b 5a
1
4a 3a
2
5b
3a + 4b + 4a 6 + 5a 3b 5b +
6
17
the viewpoint cannot obscure things on the same side as the viewpoint
the split plane before it hits the split plane and before it hits anything on the back side
plane can be closer than things on the near side
n Gives a relative ordering of the polygons, not absolute in terms of depth or any other quantity
Split plane
18
n Recurse down the side of the sub-tree that does not contain the viewpoint
n Draw the polygon in the splitting plane
n Recurse down the side of the tree containing the viewpoint
19
1
2
1 2 3b 4b 5a 6 4a 3a 5b 3a + 4b + 4a 6 + 5a 3b 5b + Back-to-front rendering order is 3a,4a,6,1,4b,5a,2,3b,5b 1 2 3 4 5 6 Eye 9 8 7
20
n One tree works for any viewing point n Filter anti-aliasing and transparency work
n Can be many small pieces of polygon n Over-rendering
21
n No over-rendering
n Small detail objects in an environment make it particularly difficult
22
n Simple shapes n Rooms in a building, for instance
n Doorways between rooms, windows, etc
n Then render visible rooms plus contents
23
View
24
25
View
26
View
27
View
28
View
29
View
30
31
32
n Do not forget to add all fltk\opengl libraries n Do not forget to add the four additional source files
libtarga.c; libtarga.h.
n Be careful to the image’s path
33
n Remove main.cpp, myWindow.h, myWindow.cpp in A n Download source code of project 2 from our website n Add all cpp/c and h files in project 2 to A n Add fltkdlld.lib, opengl32.lib, glu32.lib, fltkgld.lib, wsock32.lib, comctl32.lib to Project -> Properties -> Configuration Properties -> Linker ->Input -> Additional Dependencies n Delete “Fl::visual(FL_RGB);” in main function in World.cpp n Build and run, it works for me