double-hit-balls/assets/simple_shading.fragment

19 lines
554 B
Plaintext
Raw Permalink Normal View History

2018-05-30 15:36:00 +00:00
precision mediump float;
uniform sampler2D Texture;
uniform float Transparency;
uniform vec4 LightDirection;
varying vec2 texCoord;
varying vec3 fragNormal;
2018-05-31 14:47:36 +00:00
varying vec3 fragColor;
2018-05-30 15:36:00 +00:00
void main() {
2018-05-31 15:10:02 +00:00
vec4 color = vec4((fragColor.rgb * texture2D(Texture, texCoord).rgb), 1.0);
float intensity = clamp(dot(normalize(LightDirection.xyz), -normalize(fragNormal)), 0, 1);
2018-05-30 15:36:00 +00:00
2018-05-31 15:10:02 +00:00
gl_FragColor = vec4(color.rgb * intensity + vec3(0.2, 0.2, 0.2), color.a * Transparency);
2018-05-30 15:36:00 +00:00
//gl_FragColor = vec4((fragNormal.rgb + vec3(1.0, 1.0, 1.0))*0.5, 1.0);
}