29 lines
894 B
GLSL
29 lines
894 B
GLSL
#version 330
|
|
|
|
uniform float time;
|
|
uniform sampler2D ourTexture;
|
|
|
|
out vec4 FragColor;
|
|
flat in int vID;
|
|
in vec2 texCoord;
|
|
in vec3 position;
|
|
in vec3 normal;
|
|
|
|
|
|
float rand(float n)
|
|
{
|
|
return fract(sin(n) * 43758.5453123);
|
|
}
|
|
|
|
void main()
|
|
{
|
|
vec3 color = vec3(rand(float(vID + int(time))), rand(float(vID + int(time))), rand(float(vID + int(time))));
|
|
vec3 n = normalize(vec3(50. * cos(time), 50., 50. * sin(time)) - position);
|
|
//vec3 n = normalize(vec3(0., 50., 0.) - position);
|
|
float phong = 0.2 + 0.8 * max(0., dot(n, normalize(normal)));
|
|
float specular = pow(max(dot(reflect(n, normalize(normal)), normalize(vec3(0, 0, -9) - position)), 0.), 10.);
|
|
FragColor = vec4(color * 0.001 + texture(ourTexture, texCoord).rgb * phong + vec3(1.) * specular, 1.);
|
|
//FragColor = vec4(color * 0.001 + vec3(0.5) * phong + vec3(1.) * specular, 1.);
|
|
//FragColor = vec4(color * 0.001 + normal, 1.);
|
|
}
|