-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtessellation_fs.glsl
60 lines (45 loc) · 1.35 KB
/
tessellation_fs.glsl
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
57
58
59
60
#version 430
uniform sampler2D tex;
layout(location=6) uniform int pass;
out vec4 fragcolor;
in vec3 N;
in float dist;
in vec2 tex_coord;
in vec4 p_eye;
in float depth;
in float visibility;
//layout(location = 0) out vec4 RefractionColor;
layout(location = 1) out vec4 depthColor;
void main(void)
{
const vec3 light = vec3(0.0, 0.0, 1.0); //light direction
const vec4 ambient_color = vec4(0.7, 0.7, 0.65, 1.0);
const vec4 diffuse_color = vec4(0.722, 0.627, 0.545, 1.0);
const vec4 spec_color = vec4(0.120, 0.120, 0.060, 1.0);
vec3 v = p_eye.xyz;
vec3 r = reflect(-light, N);
if(pass==1)
{if(depth < 0.5)
{
discard;
}
fragcolor = texture(tex, tex_coord)*(ambient_color + diffuse_color*max(0.0, dot(N, light)) + spec_color*pow(max(0.0, dot(r, v)), 15.0));
}
if(pass==2)
{
if(depth > 0.0)
{
discard;
}
fragcolor = texture(tex, tex_coord)*(ambient_color + diffuse_color*max(0.0, dot(N, light)) + spec_color*pow(max(0.0, dot(r, v)), 15.0));
depthColor = vec4(pow(1.0-gl_FragCoord.z*gl_FragCoord.w,20.0));
}
else{
if(depth < 0.5)
{
discard;
}
fragcolor = texture(tex, tex_coord)*(ambient_color + diffuse_color*max(0.0, dot(N, light)) + spec_color*pow(max(0.0, dot(r, v)), 15.0));
}
fragcolor=mix(vec4(0.24,0.34,0.38,1.0)*1.3,fragcolor,exp(0.008*dist));
}