Git Product home page Git Product logo

jklintan / opengl Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 28.5 MB

Different projects using OpenGL, labs in a computer graphics class at Linköping University as well as my own experimenting. Contains both a template for OpenGL in Visual Studio, object handling and a version of Phong's local reflection model using glsl.

HTML 49.08% CSS 0.74% C 48.47% JavaScript 0.08% C++ 1.23% GLSL 0.05% Objective-C 0.35%

opengl's Introduction

OpenGL

Different projects using OpenGL with the purpose of learning how to implement various models in OpenGL and write shaders in GLSL. Some of the projects are related to my studies at Linköping University and the laboratory course in the class "Computer Graphics" (TNM046)

Phong Lightning Model

The Phong Lightning Model consists of three terms: The ambient, the diffuse and the specular term.


In the images we can see the difference between only ambient lightning and when the diffuse term also is added.

Ambient light

The ambient term comes from the physical model of light and the fact that it scatters around us and when hitting other things it will reflect and therefore result in that some light reaches the object looked at. This is called ambient lightning and in this simple model it is implement as just the product between the ambient strength (that we set between 0 and 1) and the color of the light.

Diffuse light

The diffuse light simulates the light that actually hits the object itself. We will give the pixels that are closer to the light rays from the light source more brightness than the pixels farther away.

Specular light

Specular light is simulated based on the reflections of the light and how the viewer sees this. With the help of the position of the light and the viewer and the normal of the surface we can calculate the angular difference between the reflected light and the view direction. The closer angle between them, the greater influence of the specular light we will get. We will raise the specular component to a power of a number which we define as the 'shininess' of the object. The higher the value, the more the object reflects light instead of scattering and therefore we will get a more defined circle and smaller highlight.


After the specular light is added. The difference between an exponent of 4 and one of 64.

Texturing

Implementations of texturing from images and with help of texturing coordinates calculated for the box.



In the two images on the top you can see how the box looks when getting textures. In the lower images it is the same textures but now implemented in the Phong Shading Model as showed above. The diffuse term now comes from the texture instead of color.

opengl's People

Contributors

jklintan avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.