Setting up to starting with GLSL can be little complicated. This requires a few library setups and using OpenGL API to setup the pipeline. First you will need an IDE like Windows Visual Studios 2010 C++ express. You will than need to set OpenGL Extension Wrangler Library (GLEW) for the OpenGL API project. Next you will need windows management library like freeglut. Freeglut is an updated version of GLUT (OpenGL Unility Toolkit) which allows users to create and manage windows for OpenGL. Freeglut can read mouse, keyboard, and joysticks functions. Lastly you will need a math Library like GLM (OpenGL Mathematics). Here is a great link to set up GLEW and freglut.
Tag Archives: computer graphics
Computer graphics processing unit (GPU) has come a long way that now they are being used for molecular modeling, oil exploration, and machine learning. OpenGL shading language (GLSL) can harness that power using shaders. A shader is a program that runs on the graphics card. There are several different shaders with each having a specific task to accomplish on the pipeline. The shaders are linked together using an OpenGL program. The OpenGL program will send vertices and attributes down the pipeline. The shaders will use this information to create different effects from color and brightness to more complex effects like bump mapping, distortion, edge detection and motion detection.
GLSL has come a long way since it replaced OpenGL ARB Assembly Lanuage in OpenGL version 1.4. Newer graphics cards runs a higher version of GLSL that gives the ability to program different types of shaders in the pipeline These additional shaders will give you more flexibility. Today’s graphics cards also have unified shaders which allow for any type shaders to run on any computational unit on the GPU. There is also parallel processing on the GPU on which gives user rich graphics in real time.
This is my last post on GLSL. To tell the truth after all these post on GLSL I do not fully understand it. Either way here is bump mapping using GLSL. To make more sense of bump mapping here is an except from my project.
Bump mapping is an alternative to normal mapping in that it uses a grayscale height map instead of an RGB map. The height map determines how high something is. However, we won’t be actually moving any vertices. Like normal mapping, we will only change the normals.
As you may recall, the normal is perpendicular to the surface underneath. Another way to put it is that the normal is perpendicular to the tangent of the surface. Hence, we need to first calculate two tangents. To calculate a tangent, we need to know the height value just above and below (or to the left and to the right) of the current position. We can offset the texture coordinates in four different ways and use these offsets in four calls to texture2D. Note, for some maps, you may need to fiddle with this offset value to get something right (….this is probably why normal mapping is more prevalent in industry….). Once you have the two tangents, simply cross them and normalize to get the new normal.
Here is my version of GLSL Normal Mapping. A normal map is an RGB texture where the RGB value corresponds to the XYZ of the normal. Since we are only doing mapping onto a quad, we simply need to replace (not offset) the old normal with this new read normal. There is one caveat, however. RGB values range from [0,1] while normal directional values can range from [-1,1]. The same should go for green and blue.
I tried to do Blinn-Phong reflection but i am not sure if it is correct.
I recently wrote a program for class the compared Phong and Gouard shading using the OpenGL shader language GLSL. To sum it up in a couple of sentences, Gouard shading uses per-vertex shading and Phong uses per fragment/pixel shading. Gouard will look more flat shading because the triangles (triangle mesh) will have a solid color. Phong shading colors per pixel so the triangles can vary in color inside the triangles. In GLSL the lightening calculation will be calculated in the vertex shader for Gouard and in the fragment shader for Phong.
This post is the third installment from my post (How to detect a collision between a circle and a line). In this post I will show how to find the closest point to a point or circle. It is pretty straight forward after you know how to determine the distance between 2 points.
This post is the second installment from my previous post (How to detect a collision between a circle and a line). In this post I will show how to determine if a circle or point is above a line. If you know anything about a dot product of two vectors then you probably could come up with the ‘if’ statement yourself. Without going in to too deep of details about dot products, it is basically means if two vectors point the same direction then their dot product will be greater then zero.
I just now finished another computer graphic school project and want to share a few things. As you can tell there is a few bugs, but that is a different story. So far I am going to do this any many parts. I wanted to start off by talking about how to detect a collision between a circle/ball with a line. I will later talk about how to find the reflection, what to with many different lines and what else I can brew up.
Here is a visual of what I am talking about: