top of page

Studying Computer Graphics Part 4: Lighting

  • Apr 26, 2020
  • 2 min read

The next topic for Computer Graphics subject was Direct Lighting. In this topic we learnt about different kinds of lights and lighting models in games and 3D environments. The types of lighting we covered included ambient, directional, point and spot lighting. Ambient lighting is light that is simulated that doesn’t shine directly onto any objects or surfaces. Directional lighting is light that falls on objects and surfaces in a set direction. A point light has a direction that is based on a vector of the distance between the position of a surface and the position of the light itself. Depending on the distance between the two the intensity of the light increases and decreases.


Spotlights use two angles to determine its cone shaped range of light, these angles are phi and theta. Theta is the inner most angle where the light is most intense whilst phi is the outer most angle where the light grows less and less intense. These qualities are similar to the previously mentioned point light.


Here are some hand-drawn diagrams demonstrating this in two different scenarios. Based off information and similar demonstrations in this posts references.


As part of this subject our next exercise was to implement to a phong model shader into our OpenGL graphics project. Phong light models use the ambient, diffuse and specular light reflection properties combined with material properties, to colour and light a surface. Diffuse reflections occur when light is reflecting off of a rough surface, meaning that the light rays are reflecting in many different directions. This is in contrast to specular reflections, which occur when light reflects off of a smooth surface and light rays reflect in a shared direction.


To do this the Mesh class was updated to handle surface normals and the phong mathematical model was written into a vertex and fragment shader for our light, starting with handling diffuse reflections. In this exercise we set the lights colour to yellow and made it rotate in front of a 3D object, giving the effect you see below.



References:

Direct Lighting Lecture

Direct Lighting Tutorial

Stanford OBJ Models

Comments


Commenting on this post isn't available anymore. Contact the site owner for more info.
  • Twitter
  • LinkedIn
  • Mail_edited_edited_edited_edited
bottom of page