Download presentation
Presentation is loading. Please wait.
Published byBuddy Little Modified over 9 years ago
1
Buffers Textures and more Rendering Paul Taylor & Barry La Trobe University 2009
2
Clearing up the OpenGL Perspective Functions OpenGL uses a Right Handed Coordinate System This means that the Z axis is positive out of the screen Unfortunately for our heads the OpenGl functions glOrtho(left, right, bottom, top, near, far) And GluPerspective(…) glFrustrum(…) All take znear and zfar in positive values as the forward distance from the COP (Center of Projection) 0,0,0 What it all means is that remembering Z is negative into the screen: To create an Orthogonal Clipping Box that goes from z = -1 (1 unit infront of you) back to z=-10 (10 units infront of you) means calling glOrtho(left, right, bottom, top, 1.0f, 10.0f)
3
Your OpenGL Objects Basically your OpenGL Objects should still have a central point of 0,0,0 in Object Coordinates Your Render Function should translate all Objects into the MODELVIEW Matrix using a Translation Matrix that pushes the objects backwards and into the clipping Plane glTranslatef(x,y,-5.0f) // Middle of a z=0-10 clipping Box
4
Normal A Normal is a Vector is a Perpendicular vector to the Surface, Pixel or Vertex it relates to They are extremely useful for many, many reasons in Graphics They are easily calculated by the Cross Product of 2 non-parallel sides of a polygon http://mathworld.wolfram.com/NormalVector.html
5
Unit Vector A Unit vector is exactly 1 unit long! Any Vector can be tuned into a Unit vector by dividing all components of the vector by its Magnitude Normal V = x/|v| + y / |v| + z / |v| Where |v| 2 = (x 2 + y 2 + z 2 ) Unit Vectors are very useful as they are non scalar, and results from operations will always continue to be unit length In the Matrix world the Dot Product of 2 Unit Vectors is equal to their cosine
6
Single Face Rendering www.freakyzoo.com/2Headed%20Turtle.html
7
Finishing off your Basic Polygons Clockwise Polygons Counter-Clockwise Polygons Polygon Normals – RHS Polygons – LHS Polygons Z-Positive is typically the Polygon Normal (In Object Coordinates)
8
So Far our Polygons have been 2-faced FrontBack
9
So Far our Polygons have been 2-faced FrontBack
10
This is the front and back view of a 1 faced Polygon FrontBack
11
To make rendering more efficient we should only consider the front faces of polygons This reduces the rendering load very quickly when you consider a complex 3D scene
12
http://www-graphics.stanford.edu/courses/cs348b-competition/cs348b-05/forest/index.html
13
Fast Culling http://www.soc.staffs.ac.uk/pal2/QMT/Formula/astc.gif Remember the Dot Product of 2 Vectors is the Cosine Angle Combining the Polygon Normal and the Viewport Direction If A.B < 0 Polygon is facing away
14
Basic Texturing There are 2 types of Buffer in you video card* Color and Depth Buffers Only Color Buffers can be drawn to your output device So far we have been using 3 Buffers – A Front Buffer – A Back Buffer – A Depth Buffer (Z Buffer) * According to OpenGL
15
Buffers and Formats A Buffer is an X x Y array of Values where X and Y are the resolution of the screen – In this course typically Values will be 32bit floats Bits Pixels and Bitplanes – Firstly in OpenGL a Bitmap is an X x Y array (or image) with a 1 bit depth! Bit Block Transfers (BitBlt) are covered in other subjects so we’ll skip them
16
Pixel Maps These are much more like what most would consider a ‘Bitmap’ (Windows Type) – An array X x Y of Pixels Here is a 24bit Image / Texture declaration Glubyte stupidImage[512][512][3] To create a 32bit version we just need to extend the depth to 4 bytes.
17
Using the Images / Textures in OpenGL Texture Maps Bump Maps Normal Maps Environment Maps (Reflection Maps) www.zanir.szm.sk/dx10-19.html www.bencloward.com/tutorials_normal_maps12.shtml http://www.lavaprodu ctions.com/ChurchSto ne1Bump.jpg
18
Texture Formats 1D, 2D or 3D Textures can be used Typically you will only be using 2D Textures, as a 3D Texture can create an incredible load on the graphic Processing (And Video / Hardware Memory Use)
19
Texture Mapping In OpenGl Texture Coordinates range [0.0f->1.0f] These are known as the Parametric Surface Coordinates and commonly reffered to as UV Coordinates www.codersger.de/mags/cscene/CS8/CS8-02.html
20
Theoretically…. OpenGL Takes the XYZ Coordinates of a Vertex, then uses the related U,V coordinates of the Texture to apply it to the Object in World Coordinates. This object is then rendered to the Screen Buffer Actually the Texture is NOT mapped onto the object up until writing the Pixel Buffer (After Perspective Transformation)
21
For Simple Objects Cubes (Squares / Rectangles) Triangles Cylinders Spheres (less simple) www- evasion.imag.fr/.../sgi_html /ch07.html
22
UV Mapping For Complex Objects www.highend3d.com/.../texturing/248-2.html
23
The End (for now)
24
Mip Maps
25
Texturing Odd shaped Geometry
26
Using Intermediate Objects
27
Using UV Maps
28
Aliasing Aliasing is when the data representing your 3D world becomes corrupted with artifacts
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.