Jiawei Wang
This project is a simple version of CUDA software rasterizer without using any OpenGL functions. The CUDA based graphic rasterization pipeline is similar to the OpenGL pipeline, which includes: vertex shading, primitive assembly, perspective transformation, rasterization, fragment shading, and write the resulting fragments to a framebuffer then rendering image out.
I have implemented all the basic pipeline steps as following:
- Vertex Shading
- Primitive Assembly with support for triangle VBOs/IBOs
- Perspective Transformation
- Rasterization through either a scanline or a tiled approach
- Fragment Shading
- A depth buffer for storing and depth testing fragments
- Fragment to framebuffer writing
- A simple lighting/shading scheme, such as Lambert or Blinn-Phong, implemented in the fragment shader
Also implemented additional features as following:
- Correct color interpolation between points on a primitive
- WireFrame mode and Vertices mode
- Mouse and keyboard view control
The Youtube video is a demo of these features.
Without fragmentShade implementation, without lights:
If show the color with BaryCenter Interpolation:
After implementing fragmentShade, add diffuse and specular effect to models:
Also, there is an interesting colorful bunny when I debug the missing triangles for the scanline rasterization part, the colorful bunny looks pretty:
By rasterizing only the triangle frames or triangle vertices, we can get another two view for models, wireframe and vertices:
Not only the primitive normals can be used in the fragmentShade part, but also can be used as debug tool, just assign color to the normal:
A complicated and interesting objects:
- Add glfw mouse callback function to enable moving eye position on a sphere based space.
- Left mouse button to rotate object, hold and drag right mouse button for zoom in/out
- hold and move middle button for changing screen center and view direction
- Keys: press 'n' to change mode between body/wireframe/vertices
- Keys: press 'm' to enable/disable BaryCenter Interpolation
- Other Keys: 'q','e','w','s','a','d' simply moving eye postion by steps
I can only see when the geometry object getting complicated, the rasterizer takes longer time to render image and fps drops as well. Need to implement back face culling to reduce the noise points on the rendered geometry.
- Scanline triangle intersection algorithm: http://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect
- BaryCenter Interpolation algorithm: http://mathworld.wolfram.com/BarycentricCoordinates.html