# fasterthanlime/IntroGraphics-Ex5

Switch branches/tags
Nothing to show
Fetching contributors…
Cannot retrieve contributors at this time
75 lines (56 sloc) 2.37 KB
 Exercise 5 - Introduction to computer graphics

Introduction to computer graphics

by Amos Wenger and Javier Martín de Valmaseda

4.1 Introduction

In this exercise we only have to follow the instuctions of the assignement.

L and N was given to us, and we need to calculate the diffuse coefficient D = max(dot(N,L) ,0) to do a lookup in a 1D texture. The final color is the 1D texture multiplied by the previous calculated color.

4.3 Contour

4.3.1 Linear Depth

Since the camera is looking along the negative Z axis, taking the z coordinate of a given vertex and scaling it according to the far plane and near plane uniforms was enough.

depth = - ( vertex.z - near ) / ( far - near );

4.3.2 Edge Detection

This exercise was a bit confusing at first, but reading articles from Wikipedia and careful review of the statement led us to the solution.

We added two auxiliary functions for the purpose of the Prewitt operator computation: I(i, j) retrieves a given point of the texture, using dx and dy - set in the C++ code to be the width and height of a pixel in world coordinates. And C(m, i, j), which computed 2D discrete convolution, given a matrix and x, y coordinates in the texture image.

Finally we computed the final color applying the equation 1 -10* M(i, j) as given in the statement to obtain a rudimentary contour of the edge.

4.4 Blending

As the assignement says we have to multiply the toon-shading image (cartoonColor) and the edge image (edgeColor) and that's it.