In this article I will demonstrate how to implement a basic lighting model using the Cg shader language. If you are unfamiliar with using Cg in your own applications, then please refer to my previous article titled Introduction to Shader Programming with Cg 3.1.
This article is an updated version of the previous article titled Transformation and Lighting in Cg. In this article, I will not use any deprecated features of OpenGL. I will only use the core OpenGL 3.1 API.
In this article I will introduce the reader to shader programming using the Cg shader programming language. I will use OpenGL graphics API to communicate with the Cg shaders. This article does not explain how use OpenGL. If you require an introduction to OpenGL, you can follow my previous article titled Introduction to OpenGL.
In this article, I will discuss a technique called normal mapping. Normal mapping is a shader technique that encodes pre-computed surface normals in a texture that can be used to add extra detail to a surface without the requirement of adding extra geometry. Before reading this article, you should have a basic understanding of OpenGL and you should know how to setup a Cg shader. For a review on OpenGL, you can refer to my previous article titled [Introduction to OpenGL for Game Programmers] and to learn how to incorporate Cg shaders in your own applications, you can refer to my article titled [Introduction to Cg Runtime with OpenGL].
This tutorial builds upon the previous article titled [Loading and Animating MD5 Models with OpenGL]. It is highly recommended that you read the previous article before following this one. In this tutorial, I will extend the MD5 model rendering to provide support for GPU skinning. I will also provide an example shader that will perform the vertex skinning in the vertex shader and do per-fragment lighting on the model using a single point light. For a complete discussion on lighting in CgFX, you can refer to my previous article titled [Transformation and Lighting in Cg]. Continue reading →
In this article I will demonstrate how to implement a basic lighting model using the Cg shader language. In this article, I assume the reader is familiar with the OpenGL graphics API and how to setup an application that uses OpenGL. If you want to see how you can setup an application that can be used to do OpenGL graphics rendering, you can refer to my previous article titled [Introduction to OpenGL for Game Programmers].
In this article, I will discuss matrices and operations on matrices. It is assumed that the reader has some experience with Linear Algebra, vectors, operations on vectors, and a basic understanding of matrices.