Texturing and Lighting with OpenGL and GLSL

OpenGL GLSL Texturing and Lighting

OpenGL GLSL Texturing and Lighting

In this article I will demonstrate how to apply 2D textures to your 3D models. I will also show how to define lights that are used to illuminate the objects in your scene.
I assume that the reader has a basic knowledge of C++ and how to create and compile C++ programs. If you have never created an OpenGL program, then I suggest that you read my previous article titled [Introduction to OpenGL and GLSL] before continuing with this article.

Continue reading

Transformation and Lighting in Cg 3.1

Lighting with Cg 3.1

Lighting with Cg 3.1

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.

Continue reading

Introduction to Shader Programming with Cg 3.1

NVIDIA Cg

NVIDIA Cg

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.

Continue reading

Rendering Primitives with OpenGL

Rendering Primitives

Rendering Primitives


In this article, I will examine multiple methods for rendering primitives in OpenGL. The first method I will look at is using immediate-mode rendering to render simple primitives in 3D. Another method of rending primitives in OpenGL uses vertex arrays. And finally I will also examine the use of display lists to generate a set of render calls that can be executed at another point in time. The reader is expected to have a basic understanding of programming techniques in C++. If you want to know how you can get started with OpenGL, you can refer to my previous article titled [Introduction to OpenGL].

Continue reading

Projected Shadow Mapping with Cg and OpenGL

Projective Shadow Mapping

Projective Shadow Mapping

In this article, I will show how to implement projective shadow mapping in OpenGL using Cg shaders.
The basis of this post comes from the article titled [Transformation and Lighting in Cg]. I will assume the reader has a basic understanding of OpenGL and already knows how to setup an application that uses OpenGL. If you require a refresher on setting up an application using OpenGL, you can refer to my previous article titled [Introduction to OpenGL for Game Programmers].

I will take advantage of a few OpenGL extensions such as GL_ARB_framebuffer_object to create a offscreen framebuffer to render to and and GL_ARB_texture_border_clamp for clamping to the border color of the projective textures.

Continue reading

Normal Mapping with Cg and OpenGL

Environment Mapping

Environment Mapping

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].

Continue reading

Environment Mapping with Cg and OpenGL

Environment Mapping with Cg

Environment Mapping

In this article I will demonstrate an effect called Environment Mapping. Environment mapping attempts to simulate the effect of reflective or refractive surfaces in a shader rasterizer. I assume the reader has a basic understanding of OpenGL and Cg. If you require an introduction in OpenGL, you can refer to my article titled [Introduction to OpenGL for Game Programmers]. And for an introduction to Cg, you can refer to my article titled [Introduction to Cg Runtime with OpenGL].
Continue reading

GPU Skinning of MD5 Models in OpenGL and Cg

Bob with Lamp (GPU Skinning)

Bob with Lamp (GPU Skinning)

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

Transformation and Lighting in Cg

Spotlight Shader Effect

Spotlight Shader Effect

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].

Continue reading

Introduction to Cg Runtime with OpenGL

Cg Runtime - Example 2

Cg Runtime - Example 2

In this article I will provide a brief introduction to the Cg runtime and I will show a very simple example that uses the Cg shader language.

I will assume that the reader has some basic knowledge of OpenGL and how to create an application that uses OpenGL to render graphics to the screen. If you need a brief introduction to OpenGL, you can refer to my article [Introduction to OpenGL for Game Programmers]

Continue reading