Skip to main content

Practical assignment #2



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

*Variants higher than 30 start counting from 1

Comments

Popular posts from this blog

Practical assignment #1 (Surface Rendering)

Assignment presentation Share the link to your GIThub repo through this form . Make sure the repo contains two screenshots presenting your assignment. The practical assignment has to reside in a branch named PA1. Prerequisites The credit module is based on WebGL interface brought in JS language. Suggested IDE for JavaScript is VisualStudio Code. How to start Use a skeleton WebGL project:  Project  as a fast way to start. https://webglfundamentals.org  is a comprehensive resource for studying WebGL protocol. Link to handbook The book of surfaces (the password equals to the first letters of the name of this credit module) Requirements Render wire-frame  model representing analytical surface using WebGL as per individual variant. The list of variants of Analytical Surfaces for the course is as follows: Supplementary material The document describing the difference between OpenGL and OpenGL ES implementations:  Document The document describing details of the

Calculation and graphics work (Operations on texture coordinates )

Assignment presentation Share the link to your  GIThub repo through this form . Make sure the repo contains a paper presenting your assignment The practical assignment has to reside in a branch named CGW. Operations on texture coordinates Scale and rotate a texture around user specified point. Requirements Map the texture over the surface from practical assignment #2. Implement texture scaling (texture coordinates) scaling / rotation around user specified point- odd variants implement scaling, even variants implement rotation It has to be possible to move the point along the surface (u,v) space  using a keyboard. E.g. keys A and D move the point along u parameter and keys W and S move the point along v parameter. Paperwork Prepare a digital  report that holds: a title page; a chapter describing the task (1 page); a chapter describing theory (2 pages); a chapter describing the implementation details (2 pages); a chapter of user's instruction with screenshots