top of page
Search
denebf33

Realization of Phong Illumination Model with OpenGL

Introduction

A technical demo based on Phong illumination model. Both of the floor and the box in the scene have diffuse map and spectular map, and the light source is a spotlight from the camera, which is a simulation of a flashlight.


Reference

https://learnopengl.com/

Download



Features

Camera

In the render loop, maintain some variables that represent the camera's position, rotation, and pitch angle. These variables will be controlled by the keyboard and mouse input, and we can use these variables to create a LookAt matrix to apply the camera.


Illumination Effect

Light source

The light source was programmed as a flashlight. In order to do that, besides ambient, diffuse, and specular weight in the fragment shader output, there still need other parameters to simulate a spotlight. An illuminating range would be calculated in the fragment shader to correspond to both the distance between each fragment and the camera and the camera's direction. Everything out of this range should not be illuminated. And also the distance can decide the intensity of the reflection light.


Illumination Effect

Reflection

The reflection of game objects was calculated in the shader with the Phong illumination model. In this model, the spotlight was programmed as white, the calculation among diffuse map, specular map, material parameters, and light parameters can yield the color that showed on the screen.


19 views0 comments

Comments


文章: Blog2 Post
bottom of page