Assignment presentation
- Share the link to your GIThub repo through this form.
- Make sure the repo contains a gif file presenting your assignment (use screenTogif application)
- The practical assignment has to reside in a branch named PA2.
Requirements
Use sources from Practical assignment #1 adding new functionality as follows:
- Implement vertex and pixel shaders that calculate intensity of illumination for the surface coming from a single light source: Irgb=Ambient+Diffuse+Specular
- Make sure the surface is rendered with filled polygons (triangles).
Resources
The project we started to code at the lecture is here WebGL PA2
Details on Normals Calculation
- implement the function calculating tangent vectors along U and V directions of your surface for Analytic case; to calculate the normal take the cross product of two tangents and normalize the result;
- Sum all facet normals that are adjacent to the vertex to form Facet Average vertex normal;
- pass the vertex normals as vertex attributes to GPU;
- calculate NormalMatrix by taking transposition of ModelView matrix inverse;
- pass NormalMatrix to GPU as uniform parameter;
Details on Gouraud/Phong shading
- calculate lighting model summing the influence from ambient, diffuse and specular components implementing the code in vertex/fragment shader.
Details on Local/Directional/Spot 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/othographic 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;
- as soon as there is no way to get pixel world coordinates in fragment shader you need to find its position interpolating vertex coordinates using hardware interpolator (varying keyword);
- Interpolate normals along primitive passing them to fragment shader using varying keyword.
TR-31mp/TR-32mp
Variant* | Light Local |
Light Dir |
Light Spot |
Shading Gouraud |
Shading Phong |
Projection Perspect |
Projection Ortho |
Normal Analytic |
Normal Facet average |
|||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | V | V | V | V | ||||||||||
2 | V | V | V | V | ||||||||||
3 | V | V | V | V | ||||||||||
4 | V | V | V | V | ||||||||||
5 | V | V | V | V | ||||||||||
6 | V | V | V | V | ||||||||||
7 | V | V | V | V | ||||||||||
8 | V | V | V | V | ||||||||||
9 | V | V | V | V | ||||||||||
10 | V | V | V | V | ||||||||||
11 | V | V | V | V | ||||||||||
12 | V | V | V | V | ||||||||||
13 | V | V | V | V | ||||||||||
14 | V | V | V | V | ||||||||||
15 | V | V | V | V | ||||||||||
16 | V | V | V | V | ||||||||||
17 | V | V | V | V | ||||||||||
18 | V | V | V | V | ||||||||||
19 | V | V | V | V | ||||||||||
20 | V | V | V | V | ||||||||||
21 | V | V | V | V | ||||||||||
22 | V | V | V | V | ||||||||||
23 | V | V | V | V | ||||||||||
24 | V | V | V | V | ||||||||||
25 | V | V | V | V | ||||||||||
26 | V | V | V | V | ||||||||||
27 | V | V | V | V | ||||||||||
28 | V | V | V | V | ||||||||||
29 | V | V | V | V | ||||||||||
30 | V | V | V | V |
Comments
Post a Comment