top of page

Software Rendering Pipeline similar to OpenGL


I developed a software implementation of a very simplified version of OpenGL rendering pipeline.As a overview, the software implementation consists of all the principal blocks of the graphics pipeline: vertex transformation, clipping, rasterization, texturing, and framebuffer operations.

To be more specific, I started with creating a framebuffer class, which is a 2D matrix, that containes the pixel information that will be rendered on the screen. The entire pipeline works to fill this framebuffer ultimately.Once a sample data drawn in framebuffer is rendered successfuly by sending it to GPU, I started implementing the pipeline through the following steps.


1. Vertex Transformation - I implemented the modelview and projection matrices given the eye position, view direction, field-of-view, etc, just as is done in OpenGL. In particular, to create the modelview matrix I used the view direction (expressed by eye_theta and eye_phi) and the distance from the viewer to the world-space origin (eye_pos). The output of this stage is the vertices in clip-space (after multiplication by the MVP matrix).


2. Clipping – The traingles were clipped against the x = ±w, y = ±w, and z = ±w planes. Basically, by working out the line equation that represents the edge of the triangle between the vertices and by intersecting that against the appropriate plane, the traingles were clipped . I had to generate new triangles that include the vertices that I added.

3. Rasterization - I implemented edge walking algorithm that provided an accelerated raterisation compared to interpolation using barycentric coordinates.


4. Texture Mapping – Now that I have interpolated the texture coordinate at every fragment, I performed a bilinear texture lookup on the texture that is bound at that triangle. I used that color as the output color for the fragment.

5. z-buffer – Once the texture mapped triangles were drawn correctly on the screen, a depth buffer that stores the depth values of the nearest fragment at every pixel location is implemented.


Tags:

bottom of page