Pages

vineri, 13 august 2010

OpenGL and Python - GLSL example

Today I played a bit with GLSL.
Here is the final result in the image below:

The source code used by me:

vertex shader
varying vec3 normal;
void main() {
  normal = gl_NormalMatrix * gl_Normal;
  gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
 }
fragment shader
varying vec3 normal;
void main() {
 float scale = 1.0 / 10.0;
 float frx = fract(gl_FragCoord.x * scale);
 float fry = fract(gl_FragCoord.y * scale);
 gl_FragColor = vec4(frx,fry,0.0,1.0);
 }