double-hit-balls/assets/simple_shading.fragment

17 lines
491 B
Plaintext
Executable File

precision mediump float;
uniform sampler2D Texture;
uniform float Transparency;
uniform vec4 LightDirection;
varying vec2 texCoord;
varying vec3 fragNormal;
void main() {
vec4 color = texture2D(Texture, texCoord).rgba;
float intensity = dot(normalize(LightDirection.xyz), -normalize(fragNormal));
gl_FragColor = vec4(color.rgb * intensity*0.5 + vec3(0.5, 0.5, 0.5), color.a * Transparency);
//gl_FragColor = vec4((fragNormal.rgb + vec3(1.0, 1.0, 1.0))*0.5, 1.0);
}