Sunday, November 9, 2008

ComG Lecture 3

[Lecture 3 –3D Graphics Rendering] leh.
This certainly is Lecture THREE because it's the start of THREE DIMENSIONAL GRAPHICS RENDERING! Ok back to business.
As usual.

Recap :
[
Color

-Perception of Color.
-3 basic color –Red, Green & Blue.
-RGB color model.

Displays

-Frame buffer.
-2D rendering.
-Double Buffering.

And the answer to the Crazy Question in Lecture 2. ~507 textures.(If you round UP)

OpenGL.
-Graphics rendering API.
-GL/ GLU (OpenGL Utility Library).
-GLUT (OpenGL Utility Toolkit) -> FreeGLUT.

#include "gl/freeglut.h"

Include freeglut will automatically include gl.h and glu.h.
]
That's the end of Recap 3.

In this lecture, we'll be learning, or rather we've learned about...

-3D Rendering Pipeline.
-Cartesian Coordinates System.
-3D Geometrics Primitives.
-3D Object Representation.

[3D Rendering Pipeline]
A pipelined sequence of operations to draw a 3D primitive into a 2D image.

( 3D Geometric Primitives -> Modeling Transformation -> Illumination -> Viewing Transformation -> Projection Transformation -> Clipping -> Rasterization -> Image )

The Modeling Transformation phase TRANSFORMS into 3D world coordinate System.
The Illumination phase ILLUMINATES according to lighting & reflectance.

The Viewing Transformation phase TRANSFORMS into 3D camera coordinate System.
The Projection Transformation phase TRANSFORMS into 2D camera coordinate System.

The Clipping phase CLIPS primitives outside camera's view.
The Rasterization phase DRAWS pixels.

So what happens first? Before the Modeling Transformation phase is our glBegin(); and glEnd();.

Basically, you enter your code, which would be 3D object coordinates like glVertex3f(0.5,0.25,0.125);, which would be TRANSFORMED into 3D world coordinates, which would then be illuminated, which would be TRANSFORMED into 3D camera coordinates, which would then be TRANSFORMED into 2D camera coordinates, which would then do a Window-to-Viewport transformation through Rasterization, and out comes 2D image coordinates!

Next we see the Cartesian Coordinate System. The y-axis points upwards, while the x-axis points towards the right. Now we see the difference between Direct3D and OpenGL - the z-axis. For Direct3D, the z-axis is pointing inwards, which means in a 2D view it points away from the user, however, for OpenGL, the z-axis points outwards, or towards the user in a 2D view.

Next we see the difference between a hand modeled with less or more vertices. Apparently, more vertices = more good looking. We also learned that ALL models can be described with triangles, like "The cube you modeled is made up of 12 triangles!" or something like that.

What is a vertex? A vertex is what makes a polygon. For example, a square has 4 vertices, while a cube has 8 vertices. NOTE: 3D no.of vertices != 2D no.of vertices *2. A triangle has 3 vertices, while a pyramid has 5 vertices.

Finally, we learned about 2D Rendering of the PRESENT. We learned about what is V-Sync, which is the synchronization of frame changes with the vertical blanking interval.

Here's how to do it!


-Obtain memory pointer to VRAM.
-Obtain double buffer memory.
-Modify double buffer memory.
-Wait for V-Sync.
-Copy double buffer to VRAM.
-Modify double buffer memory again.

and we're done.

No comments: