Simple Shading

This commit is contained in:
alexander.biryukov committed 2018-05-30 20:36:00 +05:00
1 parent 46b7b28b2b
commit c613d00511
3 files changed
+95 -40

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
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);
}
+14
View File
@@ -0,0 +1,14 @@
attribute vec3 vPosition;
attribute vec3 Normal;
attribute vec2 vTexCoord;
uniform mat4 ProjectionMatrix;
varying vec2 texCoord;
varying vec3 fragNormal;
void main() {
gl_Position = ProjectionMatrix * vec4(vPosition.xyz, 1.0);
texCoord = vTexCoord;
fragNormal = Normal;
}