KlassischeKeplerKriege/game/renderer_polygon_3d/gameobjects.frag
Andreas Ortmann 11fb091b34 nicer traces
2016-09-29 09:36:57 +02:00

28 lines
709 B
JavaScript

R"raw_string(
#version 120
varying vec3 vertex;
varying vec3 normal;
uniform vec3 color;
varying vec3 lightvec;
void main()
{
//gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
//gl_FragColor = vec4(0.5+0.5*vertex.xyz, 1.0);
vec3 Eye = normalize(-vertex);
vec3 Reflected = normalize(reflect( -lightvec, normal));
//todo materials (& light color)
vec4 IAmbient = vec4(0.2f, 0.2f, 0.2f, 1.0f);
vec4 IDiffuse = vec4(color, 0.0f) * max(dot(normal, lightvec), 0.0);
//todo shininess
vec4 ISpecular = vec4(1.0f, 0.0f, 0.0f, 0.0f) * pow(max(dot(Reflected, Eye), 0.0), 3);
gl_FragColor = vec4((IAmbient + IDiffuse) + ISpecular);
//gl_FragColor = vec4(0.5+0.5*normal, 1.0);
}
)raw_string"