Skip to main content

Control Task (Shading and Lighting)


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 ControlTask.
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 (branch PA2)

Details on Normals Calculation
  • 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 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.
Variants
  • Chagovets O. Shading model Gouraud, Facet Average Normal
  • Kandaurov S. Shading model Phong, weighted Facet Average Normal


Comments