-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathterrain.frag
56 lines (30 loc) · 952 Bytes
/
terrain.frag
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#version 150 // GLSL 150 = OpenGL 3.2
out vec4 fragColor;
in vec2 out_TexCoord;
uniform sampler2D tex;
out vec4 fragColor2;
in vec2 out_TexCoord2;
uniform sampler2D tex2;
in vec3 out_Normal; // Fragment position normal vector
out vec4 normal_color;
vec3 camPos = vec3(2,2,2); // I'm not sure about this at all!
in vec4 light_position_in_camera; // position of the light in camera coordinates
float diffuseScalar(vec3 normal, vec3 lightDir, bool frontBackSame)
{
/* Basic equation for diffuse shading */
float diffuse = dot(normalize(lightDir), normalize(normal.xyz));
if(frontBackSame)
diffuse = abs(diffuse);
else
diffuse = clamp(diffuse, 0, 1);
diffuse = diffuse/2 + .5;
return diffuse;
}
void main()
{
//vec3 normalized_normal_vector = (normalize(out_Normal));
fragColor = texture(tex, out_TexCoord);
fragColor = texture(tex2, out_TexCoord2);
normal_color.xyz = out_Normal;
normal_color.a = 1;
}