Assignment presentation
- Prepare a 2 min video presenting your software;
- Share the link to your GIThub repo through this form;
- The practical assignment has to reside in a branch named PA2.
Requirements
Use sources from PA#1 adding a new functionality as follows:
- Render the surface with filled triangles using VBO (Vertex Buffer Object) technology with indices;
- Add two sliders providing ability to control surface granularity over U and V directions;
- Implement triangle shading method as per variant;
- Implement vertex and pixel shaders that calculate intensity of illumination for the surface coming from a single light source: Irgb=Ambient+Diffuse+Specular that rotates in a circle motion around the surface.
Resources
The project we started to code at the lecture is here WebGL PA2
Details on Normals Calculation
- Analytic normal: implement the function calculating tangent vectors along U and V directions of your surface; to calculate the normal take the cross product of two surface tangents and normalize the result;
- Facet Average normal: sum all facet normals that are adjacent to the vertex to form a vertex normal, normalize the result;
- Facet Weighted Average normal: sum all facet normals that are adjacent to the vertex to form a vertex normal observing weight, normalize the result;
- pass the vertex normals as vertex attributes to GPU.
Details on Flat/Gouraud/Phong shading
Implement the necessary code in .js and/or vertex/fragment shader.
Details on a Local light source
- pass coordinates of a light source to GPU as uniform parameter;
- do not forget to multiply the coordinates by ModelView matrix before passing them to GPU.
Details on projection
use single point perspective/orthographic matrix.
Hint
- when calculating specular component you can take (0,0,1) direction vector as the vector pointing towards the viewer instead of calculating per-pixel direction (global viewer model);
- intensity of the light source components can be hardcoded in the shader;
- you can calculate the world coordinates of each point in fragment shader interpolating vertex coordinates using hardware interpolator (varying keyword);
- If you need to interpolate normals along primitive pass them to fragment shader using varying keyword.
Variant* | Shading Gouraud |
Shading Flat |
Shading Phong |
Normal Analytic |
Normal Facet average |
Normal Facet Weighted average |
||
---|---|---|---|---|---|---|---|---|
1 | V | V | ||||||
2 | V | V | ||||||
3 | V | V | ||||||
4 | V | V | ||||||
5 | V | V | ||||||
6 | V | V | ||||||
7 | V | V | ||||||
8 | V | V | ||||||
9 | V | V | ||||||
10 | V | V | ||||||
11 | V | V | ||||||
12 | V | V | ||||||
13 | V | V | ||||||
14 | V | V | ||||||
15 | V | V | ||||||
16 | V | V | ||||||
17 | V | V | ||||||
18 | V | V | ||||||
19 | V | V | ||||||
20 | V | V | ||||||
21 | V | V | ||||||
22 | V | V | ||||||
23 | V | V | ||||||
24 | V | V | ||||||
25 | V | V | ||||||
26 | V | V | ||||||
27 | V | V | ||||||
28 | V | V | ||||||
29 | V | V | ||||||
30 | V | V |
Comments
Post a Comment