Stylanos Vassiliou
Python
PIL
- To render my triangle, I used the rusterizaton process.
- I gave the program the 3 points of the triangle, its color, and the size of the image (coded in the program)
- It creates the bounding box by finding the minimum and maximum between the 3 points and the border, so that it will iterate only through the pixels within those bounds
- Then I calculate the a, b and c for each edge for the equation E(x, y) = ax + by + c
- a is the rate of change on the edge for x
- b is the rate of change on the edge for y
- c is the point where the line intersects with the x-axis
- I then iterate over each pixel and check if it is within or at the edges, meaning that the E(x, y) = ax + by + c is positive for all 3, it colors it
- by replacing the x,y with those of the pixel, i basicaly compare the position of the pixel relative of the line, to find if it is left, right, or on the line.
- If it is right (or left) of all the lines, or on them, then it means that it is inside the triangle, or on it.
- First, to project an image, we have to move the triangles so that the center of the image is the 0,0. By default, the 0,0 is the top left corner
- Then we divide x and y by z, to place the triangles in their correct projected position. If the depth is 0, we ignore the triangle
- The process is still, mostly the same as in Assignment 1
- After Projection a triangle, it finds its bounding boxes
- For each pixel:
- It calculates the 3 edges and finds if a point os in the triangle
- It gives a weight of how close a point is to the 3 vertexes of the triangle, to calculate the point's depth. This helps determine the color of triangles overlap, or clip
- Finaly, if the depth is smaller than the current depth of the pixel, it colors it, and adds the depth to a depth buffer
- Downloaded object from The Stanford 3D Scanning Repository (https://graphics.stanford.edu/data/3Dscanrep/)
- Used blender to create a wavefront
- Used PyWavefront library to load the object
- When loading the object, the values were too small, so I scaled them up and placed them at WC 0, 0, 2
- Also when resizing, I made it so that the the smallest to biggest z had a difference of 2
- Used Phong equation to calculate local illumination.
- It simulates diffuce and speculat materials
- It uses a materia class that has 3 fields
- diffuce: the diffuce coefficient, that has 3 values, 1 for each color of the RGB
- specular: the specular coefficient that has 3 values too
- shininess: Shininess controls how sharp and concentrated the specular highlight is on a surface.
- It also uses a lighting class
- position: the position of the light
- intensity: the intensity of the light for each color (3 values), from 0 to 1
- The camera has the following fields
- position: the xyz position of the camera
- look at vector: the xyz vector for where to look
- up vector: the xyz vector for where is up
- field of view: how wide the camera will be in angles











