After a bit of a refresh on OpenGL 2's GLSL, I managed to get a multitexturing fragment shader working for water. The fragment code is as follows:
varying vec3 lightDir,normal;
uniform sampler2D color_texture;
uniform sampler2D color_texture2;
void main() {
float diffuse, alpha;
diffuse = max(dot(lightDir,normalize(normal)),0.0);
diffuse = diffuse * gl_FrontMaterial.ambient.rgb;
alpha = gl_FrontMaterial.diffuse.a;
vec3 color = diffuse * (texture2D(color_texture, gl_TexCoord[0].st).rgb +
texture2D(color_texture2, gl_TexCoord[0].st).rgb));
gl_FragColor = vec4(color, alpha);
}
The results for various coloured textures are as follows:
No comments:
Post a Comment