This is a vertex shader, which wil change the z of vertex according to x and y.

 

Source code

Vertex shader

// Wave shader

// Created by Zhiyong Yang, younthu@yahoo.com.cn

void main()

{

vec4 position= gl_Vertex;

position.z=(sin(position.x*5)+cos(position.y*5))*0.2;

gl_Position = gl_ModelViewProjectionMatrix * position;

gl_FrontColor = gl_Color;

gl_TexCoord[0] = gl_MultiTexCoord0;

}

Fragment shader

// simple fragment shader

// 'time' contains seconds since the program was linked.

uniform float time;

uniform sampler2D tex;

void main()

{

  gl_FragColor = gl_Color*texture2D(tex,gl_TexCoord[0].xy);

}

 

 

Screenshot

WaveShader

Last edited Mar 16, 2013 at 4:28 AM by younthu, version 1

Comments

No comments yet.