Join Pablo Colapinto for an in-depth discussion in this video Adding normals and lighting, part of Learning OpenGL.
There's one more attribute…that I'd like us to consider sending to the GPU,…along with our position, texture, and color,…and that is the normal.…The normal is a unit length, outward facing vector…that is typically used for lighting.…Consider a cube.…At each vertex of a cube,…we can specify the direction of the outward facing normal.…Let's see how we can use these normals…to calculate lighting on our shader.…Our vertex shader now contains…a new attribute vec three, called "normal".…
Also, we've added a new uniform mat three,…a three by three matrix, called "normal matrix".…We're going to use this normal matrix…to transform the incoming normals…so that we can calculate an appropriate level…of brightness on our shader.…Here on line 52, we have the simplest function…we can use to calculate lighting.…It takes our incoming normal…and multiplies it by our normal matrix.…We'll see what the normal matrix is…and how we create it in a second.…We've also specified a particular light direction.…
Here, we've specified that our light source…
- What is OpenGL?
- Setting up an OpenGL workflow
- Creating a window with GLFW
- Working with geometric primitives
- Rotating, translating, and scaling
- Understanding matrix transformations
- Creating mesh data structures
- Buffering mesh data
- Getting mouse and keyboard input
Skill Level Intermediate
Q: Why am I getting errors saying I don’t have GLEW installed when I try to create the Xcode projects with Cmake?
1) Download, Install, and Run Xcode
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
brew install glew
./bootstrap && make && make install
brew install cmake
cd Exercise Filesmkdir xcodecd xcodecmake -G "Xcode" ..