Find Jobs
Hire Freelancers

Interactive Shading

$10-30 USD

Selesai
Disiarkan sekitar 5 tahun yang lalu

$10-30 USD

Dibayar semasa penghantaran
In this project, you will implement an interactive system for shading of a 3D object. 1 Assign normal vectors In OpenGL, you need to specify a normal vector to each vertex of a face (polygon). For example, the following statements indicate that the vertex (1,1,1) is assigned with a normal vector (1,0,0). glNormal3f(1, 0, 0); glVertex3f(1, 1, 1); If a face consists of 4 vertices, then there are 4 pairs of glNormal3f() and glVertex3f(). Strictly speaking, a normal vector of a vertex (that is a point) is not well-defined. In other words, we may have different ways to assign a normal vector to a vertex v. A simple way is to assign the normal vector of the face that v belongs to as v’s normal vector. Note that the normal vector of the face is uniquely determined by any three vertices as long as these vertices are not in the same line. Therefore, the same vertex can be assigned by different normal vectors because it may belong to multiple faces. The above simple way can be used to assign normal vectors in flat shading. But for Gouraud shading, you will need to average multiple normal vectors “inherited” from intersecting polygons to compute the final normal vector of a vertex. 2 Create light sources In OpenGL, you can create a light source with a specific property, such as position, color and direction by a function called glLightfv() or glLightf(), as follows: void glLightfv(GLenum light, GLenum pname, const TYPE *param); void glLightf(GLenum light, GLenum pname, TYPE param); glLightfv() has three function parameters. The first one indicates the identity of a light source, which can be one of the values from GL LIGHT0 to GL LIGHT7. The second one indicates the name of a property, which can be one of the following values  GL POSITION  GL AMBIENT, GL DIFFUSE, GL SPECULAR  GL SPOT DIRECTION 1 There are some other properties, such as GL SPOT EXPONENT, GL CONSTANT ATTENUATION, etc. But we will only consider the properties of position, color and direction, in this project. The third parameter indicates the values of a specific property of the light source. Note that the values of a property of position, color or direction are usually reprsented as a vector, and thus we use the function glLightfv(). For example, the following statement specifies the position of LIGHT0 to be (1.0, 1.0, 1.0, 1.0) (homogenous form). GLfloat light_position = {1.0, 1.0, 1.0, 1.0}; void glLightfv(GL_LIGHT0, GL_POSITION, light_position); In this project, you will create 2 light sources. One is initially located in (1.0, 0.0, 0.0, 1.0) and the other is initially located in (-1.0, 0.0, 0.0, 1.0). After a light source is created, you will need to enable the light source by glEnable(), such as the following: glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); 3 Shading In the class, we have learned three shading models: flat, Gouraud, and phong. With the flat model, the colors of points in the same face are identical. So, it is common that the flat model is not good at retaining 3D strucutre of an object. With the Gouraud model, the colors of points in a face are interpolated by the colors of the vertex of the face. Recall that the colors of different vertices of a face are usually different even if they are assigned with the same normal vector. Therefore, the colors of points in a face are different. OpenGL provides implementation of the flat and Gouraud shading. In OpenGL, you can specify a shading model by the following function: void glShadeModel(GLenum mode); where mode can be GL FLAT or GL SMOOTH. GL SMOOTH implies the Gouraud shading model.
ID Projek: 19213904

Tentang projek

3 cadangan
Projek jarak jauh
Aktif 5 tahun yang lalu

Ingin menjana wang?

Faedah membida di Freelancer

Tetapkan bajet dan garis masa anda
Dapatkan bayaran untuk kerja anda
Tuliskan cadangan anda
Ianya percuma untuk mendaftar dan membida pekerjaan
Dianugerahkan kepada:
Avatar Pengguna
Hi, I'd like to help with OpenGL programming. I write clean and commented code explaining each step.
$35 USD dalam 1 hari
5.0 (337 ulasan)
7.5
7.5
3 pekerja bebas membida secara purata $52 USD untuk pekerjaan ini
Avatar Pengguna
Hi, I am full stack developer and have experience of C/OpenGL programming. I have done job as same as your requirement before. I checked your requirement. I'm sure that I can easily do this project. I will do my best for you. best regards.
$111 USD dalam 3 hari
5.0 (35 ulasan)
5.3
5.3
Avatar Pengguna
Do your school assignments on your own young boy! You will learn a lot. It's a simple assignment and there are tons of material out there to help you.
$10 USD dalam 1 hari
5.0 (1 ulasan)
1.2
1.2

Tentang klien

Bendera UNITED STATES
COLUMBUS, United States
4.5
4
Kaedah pembayaran disahkan
Ahli sejak Nov 11, 2016

Pengesahan Klien

Terima kasih! Kami telah menghantar pautan melalui e-mel kepada anda untuk menuntut kredit percuma anda.
Sesuatu telah berlaku semasa menghantar e-mel anda. Sila cuba lagi.
Pengguna Berdaftar Jumlah Pekerjaan Disiarkan
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Memuatkan pratonton
Kebenaran diberikan untuk Geolocation.
Sesi log masuk anda telah luput dan telah dilog keluar. Sila log masuk sekali lagi.