Interac Comp Graph
Interac Comp Graph EECS 487
Popular in Course
Popular in Engineering Computer Science
This 29 page Class Notes was uploaded by Ophelia Ritchie on Thursday October 29, 2015. The Class Notes belongs to EECS 487 at University of Michigan taught by Sugih Jamin in Fall. Since its upload, it has received 15 views. For similar materials see /class/231524/eecs-487-university-of-michigan in Engineering Computer Science at University of Michigan.
Reviews for Interac Comp Graph
Report this Material
What is Karma?
Karma is the currency of StudySoup.
You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!
Date Created: 10/29/15
I I NonPhotorealistic Rendering Computer graphics provides tools to help human designers produce images that communicate visual information for some Computer Graphics purpose Whether to use photorealism depends on Lecture 21 the purpose of the image Storytelling NonPhotorealistic Rendering Artistic expression Visualization Volume Rendering Documentation Technical illustration Markosian NonPhotorealistic Rendering Motivation H Apply techniques from stylized art and illustration to represent natural complexity in 3D graphics Goals Extend expressive power of 3D graphics Evoke complexity using simple geometry Contro composition and detail Speed realtime Frametoframetemporal coherence Qualities of Handdrawn Images Amplification through simplification McCloud Many details left out Some details emphasized By simplifying and stripping out clutter one can amplify the effect of information relevant to the presentation I Stylization abstraction Simulation of painterly styles Simulation of natural media eg penampink charcoal watercolor etc i 39 P s i n 5 F a t I o o x I 139 I Recognizable IndIVIdual style 7 A 39 r r 5 Monet Charles Burns David Suter E v I I I x I I I 7 Iquot V I Vquot l I I 1 y I x I 4 x d IVquot I i 39 Elbow starting to bc i I 39 n 39 exed by braclualls 3 Bracmahs and biceps CoiltTaCUllg Louise Gordon Outline I Technical illustration I Pen amp Ink I Cartoonish rendering Vesalius Technical Illustration Saito and Takahashi Siggraph 90 I Purpose render 3D models in styles that are more comprehensible I Method Render various intermediate images Do imageprocessing operations on them Combine the results a shaded image b depth image c edge image 2 d enhanced image 2 Pen and Ink Winkenbach and Salesin Siggraph 94 I Purpose render 3D models as pen amp ink drawings I Method annotate model with procedural textures render tonal reference image use it to guide pen and ink textures 39mmiaihcombination of Dr pr pro le image mx4 combination of four enhanced images I l lll l39 l 39 ll illlI an 1 R x 4 i inning r quotl39 nraw PM f nquot 39 i lunm Iv ml lWMW rlllll lllllllgllll llliilquotlquotlrclil1 lll Mll lll rlllltllln llllllllltl 7 n Jillllll Minn Illglllllllll 39l lklll quotll39llllllll tllll Wm Lil i 1I Il ll JI Wnnwnln n I39 k s liquotl 11 ll himMWWmm 7 739 f Hv 11 quotV quot 14 4 t V A 1 I 7quot er r 1 3939 39 V A i n 2 TN74V quot r ti 3 i I quot 3975 ff 3 51 43942 51 JIMr s V 39 u Jf 5 ff37quotZrz 4 fgx 12 2quotquot I rill54 v I v c I r i 39 r 39 39 mm me a 7quot W 39 39 quot I 39 r 1 1quot 39 I 39 quot quot l 44de g T L Iquot quot39 quot quott39o I i il r rl i 39 N a 73 1 3 339 r 5 I 1 v quotz A It rm 39viaquot2 5 t quot 439 11quot 39 i mili vllv ll 39v 4 39 I I I quot7 ii El Itfafisz 39 L 39 5 v 39 l I 39l l J I I 5quot 2u 39ngr L 392 LII lll l r Pg T J Inn ll 39l Ill I39ll L E LuHI J39Ji III A L lcgiEr d rj I39 i I l i II 4 p i H 1quot 11quotquot Iiquot 39 i a I I ixw My Jim lift2 ml i 3 39l tum 45441 I3939ill39 til ll 7iquot s Li ia lg39rlaft firEWltt w p i i i Wng re n wt m Eliatitle 39 39I inquot 3 HM s 4m Wimzrxzm 39 flit quotlittllalu li viiia i 72w 2 39 395 r it that Mjm q in Lysif l 39pin l MERLE rug l39il flm39 25 w iglii39l f I m N il z i Ik 391 I l39 v39ll 3 5m PM HI I 39 I A v 39 w i Wipe 39 Ami th i me Ji iM Ji gft rt i gl Ec g i i 3V 1 l V II 1539 i 39 a H F g i 39tl lgizl K k 39l 39 i V 39i 33 M9114 i it quot it I I h39 whfi yl i hh m W 5 li Mitt Cartoonish Rendering I At its simplest objects are drawn with solid lines separating areas of different solid colors I Main issue finding silhouette usually rendered black I Categorization of edges in toon rendering boundaryborder edge edge belonging to only one polygon crease edge edge shared by two polygons and the angle between the two is greater than some threshold 60 e i I I I 1quot 39 39 A iif 7 39l l 39Il 39 M h 39739 Lug ghulllwlhi 139 material edge edge between two polygons quot quotmi r i 39quot39 I I I 3913939 yttrium l Mlit 39 armIM4 u a of different material attributes eg color il3939quotlquotlllrj yuItl I quotquot fl L39rii quot lj39ri P qi e quot I i H in I l I JIM Wilh39 quot 39 W mi M fe33773mltglgfgi l t izu dlh lightlliliygqg ifWWWWWWigwg ar I Silhouette edge edge shared by two polygons I I I I 39 h I i 1 it 1 Qt 2 f quot3quot 139 m mill iii 3 iit39frJ f n 3 facmg in different directions relative to some direction vector eg light or view vector 64 V V 39 ToonGooch Shading I Let ol be the dot product of unit light vector and surface normal fragments facing the lightdirectly has d 1 those perpendicular to the light direction has d O I Decide a dark color and a light color I Return output color based on cutoff do return d lt do darkcolor lightcolor fragment facing the light gets light color I Can get a soft transition by interpolating between the dark and light colors eg mixdarkcolor lightcolor addw l0 adarkcolor alightcolor Example 5 Gooch fragment shader i uniform vec3 ambient varying vec3 normal lightVec viewVec void main const float b 055 y 03 const float Ka 10 Kd 08 Ks 09 vec3 norm normalizenormal vec3 L normalizelightVec vec3 V normalizeviewVec vec3 halfAngle normalizeL V vec3 kCool vec3581076 vec3 kWarm vec3888149 vec3 specularcolor vec3l0 10 10 float NdotL dotL norm float NdotH clampdothalfAngle norm 00 10 float specular powNdotH 640 float blendval 05 NdotL 05 vec3 Cgooch mixkWarm kCool blendval vec3 result Ka ambient Kd Cgooch specularcolor Ks specular glFragColor vec4result 10 Example 5 Gooch vertex shader uniform vec4 lightPos varying vecB normal varying vecB lightVec varying vecB viewVec void main glPosition glModelViewProjectionMatrix glVertex vec4 vert glModelViewMatrix glVertex normal glNormalMatrix glNormal lightVec vec3lightPos vert viewVec vec3vert Example 5 Gooch Shading output Visualization Visualization Techniques Goals Present large quantities of data at high spatial I 2D scalar fields fxy dens39t39es Random density plots Make large data set manageable and coherent Gre scale densit and se docolor lot Show the fine detail while maintaining an overall y y p U D perspective Height plots Contour plots isocontours Hazards I 3D scalar fields fxyz Color confusion random colors Volume rendering bad color maps Extracting isosurfaces Visual confusion 39 RaytraClng getting lostinthe data Splatting new and strange shapes Rendering effects Contour Plots and Height Maps I Contourcurves in 2D I Height map represents various data value with levels of elevation Plots in 2D I Many different ways Fiquoton1 annverclt3m I Can be combined with pseudocolor plot I Random density plot scattergram w n 39 N Spadaccini 2007 GWOsborne SSCH ll i 3J4 255 FSCH I Pseudocolor plot Color map is required h EECS 487 Interactive Computer Graphics Lecture 13 Hemite and Bezier Curves Hermite Cubic Control points position and first derivative of endpoints 1 2 3 fua0ua1 ua2 ua3 1 0 0 0 p0f0 a001a1 O2a2 03a3 0 1 0 0 p1f390 a1201a2302a3 C1 1 1 1 p2f1 a0 11a1 12a2 13213 0 1 2 3 P3 f391 31 113231233 constraint matrix 1 0 0 0 BaSIs matrix 1 0 1 0 0 BC 3 2 3 1 2 1 2 1 Parametric Cubics A representation of piecewise cubic consists of four control points why four a set of basis functions There is no single best representation of piecewise cubic Interpolate Local Continuity Affine Convex VD Hermite yes yes 07 yes na na B zier endpoints no 07 yes yes yes natural yes no C2 yes na na BSplines no yes 02 yes yes yes na when some of the control points are tangents not points Hermite Cubic 1 BasisBlending functions 0 0 0 m 0 1 O 0 p1 3 2 3 1 p2 2 1 2 1 p3 Hm ammp uuzu i0 W W 3M2 1gtPo u3 M ugtp1lt 2u3 3u2gtp2 us Maps 3 fu m1 2am 1 i0 190u 2M3 3M2 1 b1u M3 2u2 u 192u 2u3 3M2 193u M3 L12 Fo39ley van Dam 90 l Hermite Cubic Example For the Hermite curve yu A gtX 0 0 p0 is most influential at u0 As u increases towards p1 b0 and b2 mainly determine the curve with b1 and b3 contributing The way the basis functions affect the curve is why they re called blending functions Control points weighted by the blending functions at u yu A Sum of weighied control points yu Foley van Dam 90 Hermite Cubic Chain Can achieve C7 continuity with q0 20 111 P2 11 f2390 f1391 p3 UM f2390 f1391 GT I p2 10 quotquot39o a o I p0 EU0quotquot Given 17 control points th cubic segments e chain contains n22 The chain interpolates the control points provides local control and is affine invanant Hermite Cubic More Examples yu A i H Only p1 s magnitude varies for each curve Only p1 s direction varies for each curve yu A gt XU Foley van Dam 90 B zier Curve Named after Pierre Bezier 39 39 an automobile designer at Renault Independently developed by Paul de Casteljau at Citroen Has an intuitive geometric feel easy to control common interface for creating curves in drawing programs used in font design Postscript Pi Watt 2000 Foley amp van Dam 90 B zier Curve Uses an arbitrary number of control points the first and last control points interpolate lie ON the curve the rest approximates the curve tangent at the start of the curve is propotional to the vector between the first and second control points tangent at the end of the curve is proportional to the vector between the second last and last control points the nth derivative at the start end of the curve depends on the first last n1 control points f3913p3 p2 15 45 Aquadratic B zier curve has 45 0 15 3 control points fu45 45 15 0 de Casteljau Algorithm l l 10 2 2P0 2P1 2 2P1 2P2 Or more generally fu 1 u1 uPo MP1 u1 uPt MP2 Which is the quadratic B zier curve p2 fu 1 u2p0 2u1 up1 M2P2 O u de Casteljau algorithm to create B zier curves 117 13 1u connect every adjacent set of control points U u u39 with straight lines 7 create the point on these lines that are the u interpolate there are n1 such points 1u connect the new points with straight lines repeat until only one new point is created de Casteljau Algorithm Connecting the control points into the control graph leads to i a curve with sharp corners nonsmooth We can smooth out this curve by repeatedly cutting off the sharp corners Subdivision scheme a process of breaking a simpler curve into smaller pieces The resulting limit curve will be piecewise smooth 0 39 s 39 s t O t t t E i Cubic B zier Curve Given four control points p0 p1 p2 p3 use de Casteljau algorithm to build a cubic B zier curve fu O S u S 1 with p0f0 p3f1 as shown 10 1 UPo P1 q1 1 up1 MP2 q2 1 uP2 MP3 1390 1 uqo qt 1391 1 uq1 12 fu 1 ur0 ur1 fu 1 u3p0 3u1 u2p1 3u21 up2 ug p3 Then f390 3P1 Po f391 3P3 P2 Cubic B zier Curve Control points endpoints interpolation and derivatives 1 fuaoual p0 f0 a0 0131 3p1 p0 f390 3p3 p2 f391 p3f1 aO 1131 Basis matrix B c1 3 uzaz u 33 1 O 0 0 0232 0333 1 13 0 0 al2gt 013230233 1 23 13 0 al2gtllt1laz3gtklza3 1 1 1 1 1232 13a3 constraint matrix 1 0 0 0 3 3 0 0 3 6 3 0 1 3 3 1 Bernstein Basis Polynomials The basis functions for B zier curves can in general be expressed as the Bernstein basis polynomials B zier curve eqn mi Epk k 0 n bknu kuk1 uquot39k n n 1am k Mk Lon k uk1 uquot39k kn k Various B zier curves of degree 26 r m r F i Cubic B zier Curve BasisBlending functions fu 1 3M 3w2 u3p0 3w 6M2 3u3p13u2 3u3p2 u3p3 H 2191300131quot y 2 19030 1 u3 1913u 3u1 u2 1923u 3u21 u 1933u u3 Since 219mm 1 bi3u 2 0 0 s u s 1 the control points form a Space of basis functions Watt 2000 Space of curve i0 convex hull bounding the curve The curves are symmetric reversing the control points yields the same curve The basis functions are everywhere nonzero except at the end points the control points do not exert local control lii Variation Diminishing Property 0 P2 0 Let s call the set of line segments p0 p0 p3 connecting the control points the control graph P3 39 compare convex hull P1 Control Graph A curve IS said to have variation diminishing property if it does not cross a line more than its control graph does B zier curves have variation diminishing property N39WwW amuaam 5W ct ilt 77 77 77 7 7 7 7 7 7 77 7 7 7 77 7 7 7 77 77 77 7 7 7 7 7 l W GM MJ W5 L25 I New Joj MA A Mpwp Log 0941 Mo o E L 3Cl3 3 V3 mww m m Po 7jiD lelt15m MA hm wsr 144 We Mr OH 1 u gt Uh Q1 7 HQ PLMU R0 3 FMx Q0 3939 M 1 2 HQ 4amp1 OK39VB 39L DMR kw wvxk My 5239 7 HM Mai5 3M ulr gt A 5 CL Q FLJr 167 7 WWMWnga 3 Cu Vk M04 MW CODCICN ML 91 03 Law Wch w M h EMA L M Wt 506 gm Mk L W 3 aweCc rm M13 zew G K 4 mu SW 73 39 Eek 1L mu VWA gWx 0 4 l 09 5 3rquot wm quotEL 5 hm m WW W bk 5W0 554 UfCK A M U C LM 39 WangL lb VJ ITJY TLXW 54g 15 ace M 1ach v4 gossg atquot M hb ek 0WW M M S Abkd gtk d V 142 Kg M M bkA 9M Md u M M MNL fuf39ht 39 75 Gk Wk 53quot 13 hark ff Hub 1 h EECS 487 Interactive Computer Graphics Lecture 2 Lines and Line Clipping Lines and Relative Position I Two pointsxoyo x1y1describe a line slope intercept form 3 ma b where m y yo mwo implicit form fx y y 7 mac 7 b 0 I Given a line segment betweena0y0 and1iy1 a point at1 27y2 is to the right of the line segment if the slope lt or may lt 0 Mat1 WA0 33292 Drawing a line segment in raster graphics I Raster graphics Raster a rectangular array of pixels Pixel picture element indexed bottomleft pixel is 00 I Discretize the parameter round the coordinates which pixels to set 5 4 3 2 1 0 01234567 Lines and Relative Position I fay gt 0 area above line fcy lt 0 area below line Drawing a line segment in raster graphics I Which pixel to set Want thinnest line possible with no gap Implicit 2D Lines I Two points330yo 331y1describe a line slope intercept form 3 ma b7 wherem b yo mwo implicit form x y y 7 mac 7 b 0 To avoid dealing with fractional slope or worse zero denominator ay y mi bxxl 10 WW I1 my 7 yr 7 yor e y011 e 10 yl 7 gm0 11 I0y yl y0I oni yozl Let C 1 11 90 yr fgt0 Then l l Drawing a line segment l in raster graphics I Simple case first assume 0 g mslope g 1 fgt0 flt0 I Compute midpoint between the two pixels if fmidpoint lt 0 line passes above midpoint set pixel xlyl else line passes on or below midpoint y set pixel xl y Y x x1 Incremental Line I Line can be computed incrementally fltI73 Ay fr1ly1 fIiyA Ay I and drawn incrementally y y0 dx xl xo dy yl yO d fx01 y005 for x x0 x lt x1 x setipixelx y if d lt 0 y d dx dy else d dy l assume 0 g m5l0pe g i fgt o fzy A yiAyzC fr17y Amy AyI1C A yiAyziAyC flt0 y1 Y x x1 Example3 37 to 1110 Integer only Line 1 10de xl XO dy yl yO dx 11 3 8 d fx01 y005 dy 10 7 3 for x x0 x lt x1 x d 4 75 l setjixelhn y if d lt 0 y d dx dy else d dy Can the line be drawn using only integers no float I t 1 L39 l n eger on y me Other slopes I Note that 2fx y 0 is also valid to describe the line fx7y 0 hence equally valid 1 10de 2xl x0 dy 2yl y07 d 2fx01 y005 for x x0 x lt x1 setJixelhn y if d lt 0 y d dx dy else d dy What if l0 S mslope g 1 7 lAlsothat aw xlizomwwymw 30 31195961960y0 fzy AzByC flt0 Other slopes Image coordmates I Case I done I Case ll swap the x and y coordinates I Pixel coverage conventions 1 I Case Ill swapthe two points OpenGL J I case IV swap the pOints and then X y Pixel center is at halfintegers j I What to do with negative slope PiXez397jisi7i 1xj7j 1 i i1 DirectX J 2 Pixel center is at integers Pixelz397jisli iilxlii 5mg 112 i12 i12 Parametrlc L1ne Cllppmg Cllppmg segments Cyrus Beck I Against a window p1 pm Two sides de ne a region Enter M V l Why that we enter and never leave To avoid rasterizing outside the range TWO other sides de ne a region 39 Makes wager Leave that we will eventually I HovW There are various methods leave AcceptReject bitmask test CohenSutherland Use me PenmanC ne equation and Exact trimming CyrusBeck LiangBarsky the nonnal 1V ofthe testing edge to 1 p0 find the edge iriteIsection If tsmauest for PL is lt t largegt for PE the Parametric 2D Lines I Given two pointspo mayo and p1 331m the line can be described as 20 J m0t170 y yo ty1 eye parametric form P05 p0 25pr 7 p0 It can also be described as just a point 0 and a vector d P05 0 t id Parametric Line Clipping Cyrus Beck Parametric Line Clipping Cyrus Beck Ni is the Normal of the edge 239 being tested 3 is the vector frompo to pl 1 P1 P0 p51 is an arbitrary point on the edgei being tested If Ni f 0 the line is parallelto the edge i Let ptibe the intersection of D and edge i p1 131 Solve for ti for each of the four edges p22 N Ni 39 132 Perl 0 Ni Po P1 Pom Pei 0 Po 7130 iNi D Line 2 For each edgel check 75139 D Lin 1 If ti lt Oor ti gt 1this edge NEE P my intersection is not on the clipping T tsmallesl T window PL gt Now classify each intersection point as Potentially Entering PE or Potentially Leaving PL a a 9 Ni D lt 0 intersection is PE why PE PE tlargesl Ni D gt O intersection is PL rwny line is outside the clipping window Line 2 Otherwise t Emma for PL and t meg for PE are the clipped line bounding points Convex polygon as clipping area EECS 487 Interactive Computer Graphics Lecture 10 Texture Mapping Texture Mapping I What determines the look of a pixel the lighting properties ofthe surface material viewer s position transparency and fog Texturing works by modifying the values used in lighting computation surface color image texturing shininess and reflection environment mapping surface normalroughness bump mapping i Riesenl eld 2006 Texture Mapping I How to make 3D objects look less like plastic objects floating in free spacequot add surface detail but too expensive to do geometrically too much geometric detail to model eg grass wood grain etc instead glue on a 2D image that captures the surface detail to the object providing an illusion of detail combine fragment color with a lookup value A or recompute fragment color based on a lookup value Catmull 1974 Blinn and Newell 1976 and others Wallpaper Analog Texture Map Riesenfeid 2006 77 Image Texturing I Textures image loaded from a le and stored in texture memory can be 1D 2D or 3D one two three four texture coordinates per vertex or with cube map or procedural function implemented in a shader I Texture coordinates index into the texture image to get texel corresponding to a vertex given or generated for every vertex projected and interpolated per fragment during rasterization I Mapping texels magni cation minification and antialiasing various regimes decal replace modulate More Analog Texture Maps Synthetic Wood Floor Riesenfeld 2006 Pipeline Texture Texture Coords per fragment Per fragment operations Coor pervertex Framebuffer Texture Coordinates I How do we paste a 2D image onto a 3D object I done during rasterization l relatively simple if the object can be described analytically as parametric surfaces 001 l natural examples 111 000 0 1 0 0 05 hy Riesenfeld 2006 Inverse Texture Mapping Texture space Object space Screen space 5 xw yw zw x3 yr Forward mapping W52 Surface parametrization Projection a Inverse mapping I primitive lt Preimagequot of primitive h t 2000 Forward Texture Mapping Texturv space Object space Parametric surface 149056521r vhOshsl Point on the parametric surface P 116 Xuv y yuv z zuv 1 rcosB y rsinB z h I linear mapping means equal size texture patches must be stretched to fit surface Watt amp Watt 1992 Inverse Texture Mapping Map to texture Project to surface 511 UN XSVYS y ys Image primitive Texture Surface project 4 corner pixels of primitive x5ys s onto parametric surface uv transform parametric surface values to texture space 5 sampletexels set image pixel values to texel values in practice you don t want to point sample we ll come back to this later Riesenfeld 2006 Inverse Texture Mapping Tcxlur space Object space Screen space Xvu yw 1w um 5 lt Forward mapping I D E iil palanrcmzn Ian PIOJCCllon I 1mm quotnapping Prerimage ur primitive b Object Surface cylin der Textu re Parametric Win dow Coord Coords Coords st u v x si umn ltyxgt VZ Inverse Texture Mapping I Mapping onto triangle is not difficult I Mapping onto triangular mesh is more difficult have to handle texture discontinuity I Mapping onto parametric surface is easier I Alternative use an intermediate projector function usually a simple parametric surface box cylinder sphere to approximate object or parts thereof Inverse Texture Mapping Image Pixel D Texture Problems I we mostly want to texture map onto a polygonal mesh representation not an analytically described parametric surface I with polygonal mesh we only have vertices not even surfaces Inverse Texture Mapping with an Intermediate Surface I Twostage mapping Map the texture to a simple intermediate surface sphere cylinder cube Map the intermediate surface with the texture onto the surface being rendered I For example 3 10 0u 1 th hm r is the radius of the cylinder 5 4 Texture Sur ce c d are scaling factors sit at 6D h position the texture on the cylinder Intermediate to Object Mapping Texture Mapping in OpenGL W1 quotWW 1 create a texture object y z 7 glGenTextures ngindTexture W omect I d 2 specify atexture forthat object Re ected Ray Obie N rmal Omen entmld Suggi dii al ngeXImaQBZD i 3 specify how the texture is to be applied to each pixel lmumm ngexEW Obiectcorrrad X 4 enable texture mapping ec en I39Ol X X X J 7 glEnable GL TEXTURE 2D Intermediate 7 7 Surface Normal 5 renderthe scene supplying both texture Reflected ray EM EM EM EM and geometric coords see next slide Blinn lt3 Newell 1976 Spec1fy1ng Texture Coordinates Texture Coordmates Per vertex Speci ed via ngexCoord o by hand wrapping around cylindrical objects special tools to unwrap polygonal mesh I Pervertex Single texture unit ngeglnGLiTRIANGLEisTRIP ngexCoorde 0 0f 0 0f Generated via ngeXGenk glVertexBfkl f 10f 00f Object coordinates texture fixed to object Eye coordinates pattern changes as object is transformed Cube map e GLiNORMALiMAP with GLiTEXTUREicUB EiMAP Sphere map Environment Mapping RedBook pp 425442 ngexCoorde 10f 00f glVertexB 10f 10f 00f ngexCoorde 00f 10f glVertexBfkl f 10f 00f ngexCoorde 10f 10f glVertexB 10f 10f 00f glEndo in OpenGL I OpenGL Example Rasterizing Texture Coordinates When rasterizing primitives inverse project primitive identify preimage in texture map Texture scan convert primitive ie interpolate texture coordinates across primitive i Pipeline Vertex p roce 55139 ng Te XtU r e stage 5 Texture Coords per vertex Coords per fragment Texture Space Object Space 11 s t 02 08 39gt A aquot g Per fragment operations Fr amebu cer v C quot 01304 0 0 1 0 Bilinear Inter olation J p i x B111near Interpolatlon 1n Perspectlve j I L39near 39nterpolat39on m 2D d Not only lack of foreshortening e 1 quota quoth worse effect if square is rotated f 1 uc Md 6 f WM 7 puv 1 Ve Vf 1 u1 Va u1 Vb 1 uvc uvd I Bilinear interpolation lacks foreshortening on perspective projected polygon X T lt A 2K Filnlul 1m imam V V v Effect is most visible on texture mapping but also presents in color shading though generally tolerated m 7 o Prevent with quotW ngint GLiPERSPECT1VE7 ORRECTION7HINT GLiNICEST 7 Image Texturing I Textures Perspectivecorrect Interpolation OBJEC T AFFINE SPACES SCREENAFFINE SPACES image loaded from a file and stored in texture memory texture space homogeneous texture space can be 1D 2D or 3D st swtw1w one two three four texture coordinates per vertex model space or with cube map or procedural function implemented in a shader world space homogeneous window space windowspace I Texture coordinates XW39yW39W39S39t39qzn div by W X39y index into the texture image to get teer corresponding to a vertex i given or generated for every vertex Ilgiizrinsveirr zztjtlon Window projected and interpolated per fragment during rasterization coordinates then divide by interpolated1w coordinates l Mapping texels magnification minification and antialiasing various regimes decal replace modulate 0 o 0 Surface Larger than Texture Flttlng Texture to Prlmltlve 01 Texture magnification 11 51 t1 st in 01 I What if st gt10 or lt00 I To repeat textures use just the fractional part Example 53 gt 03 I Repeatwraptile mirror clamp to edge clamp to border using ngexParameter 2 Akeni ne Mol 1 er 2002 39 39l39 IIIII 22 Texture minification l l I Magnification Many pixels per texel texture is too small for primitive nearest neighbor point sample teer repeated causing pixelation bilinear interpolation blurring I Minification Many texels per pixel nearest neighbor point sample aliasing causing moire pattern mipmapping with trilinear interpolation 7 GLiLINEARiMI PMAPiL INEAR Fitting Texture to Primitive Mini cation Mipmapping Single pixel maps onto many texels 0 Need to integrate effects of many texels Precomputeprefilterthat effect 0 MIP multum in parvoquot Many things in a small place 0 Image pyramid Halve width and height when going upwards Filtering while downsampling Simple box lter average over 4 quotparent texels to form a quotchild texel Or some better lter AkeninerMoller 0 2002 Aliasing I An artifact arising from insuf ciently high sampling rate I Resulting in a higher frequency signal reconstructed as a lower frequency signal an alias Acessing the Mipmap I Compute it aka level of detail tax pixel projected to texture space A approximate area of quadrilateral ll log2 1E approximate quad with square gives overblur I Given texels in 2 levels do trilinear interpolation bilinear interpolation in each level linear interpolation across levels AkeninerMoller 0 2002 MIP Mapping Level of Detail MUItiteXture Pipeline I Multitexturing allows for texture blending for lighting effects decals compositing I Multiple textures are applied one by one in a pipeline fashion I Each stage consists of a texture unit c fragmenl primary color inpul ro loxluring Riesenl eld 2006 Cquot rragmenr color ourpur rronr Iexturingr Memory requirement 33 not twice the amount of bytes aquotmmquot 39 39 quotquotquot quot kquot TE lextura environment i Accessing the Texture Units Each texture unit has identical setup texture ima e a Setting Up lMultitexture Pipeline ngegln GLiTRIANGLEisTRIP glColor3fl Of 1 Of 1 Of glMultiTexCoordZEGLTEXTUREO o 0 o 0 glMultiTexCoordZEGLTEXTURE1 o 0 o 0 glVertex3f71Of 710f 0 Of and texture state environment application texture matrix stack for transforming the texture auto texcoord generation etc g1Mu1tiTexCoord2f GLTEXTUREO grepeat0 o 0f g1Mu1tiTexCoord2fGLTEXTURE1 1 0 o 0 glVertex3f 105 7105 0 Of g1Mu1tiTexCoord2fGLTEXTUREO 0 Of grepeat0 g1Mu1tiTexCoord2fGLTEXTURE1 0 Of 1 Of glVertex3f71Of 10f 00f g1Mu1tiTexCoord2f GLTEXTUREO grepeat0 grepeat0 g1Mu1tiTexCoord2fGLTEXTURE1 1 Of 1 0 glVertex3f 10f 105 00f Haines 2006 glEndo To access select a particular texture unit use glActiveTexture after which calls to ngindTexture ngexImage ngexParameter ngexEnv ngexGen affect only the selected texture unit Applying Texture I How each texture unit applies the texture in combination with preexisting ones on the fragment can be controlled with ngexEnV ltgt Texture combiner functions REPLACE of OS A A5 Cf Af MODULATE I 39 Cc Ac of cxcs A AzAS BLEND Cf 1CJCf CCC5 A AfAS ADD cr of CS A AfA5 DECAL Cf 1 A5Cf ASC5 Ar Af Want 5 v Apply texture and compute diffuse shading 4 cfiAf Texturing with GLSL Vertex Shader Texture lookup in GLSL generally only worries about texcoords uniform vec4 lightPos Varying vec3 normal Varying vec3 lightVec varying VecZ tC fragment Shader Varying vec3 normal Varying vec3 lightVec Varying vec2 tc uniform 5ampler2D treeTeX void main gliPosition gliModelViewProjectionMatrix t gl7Vertex void main ec3 norm normalizenormal tc 0Olgl7VertexXZ vec3 L normalizelightVec Vec4 col textureZDitreeTex Vec4 vert gliModelViewMatrix t gl7VerteX normal gliNormalMatrix t gliNormal lightVec float NdotL dotL norm float diffuse Vec3lightPos e Vert 05 NdotL 05 gliFragColor e coltvec4vec3 i to diffusel0
Are you sure you want to buy this material for
You're already Subscribed!
Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'