Debian Codegraph @

tests/manual/compute-particles/shaders/gl45/particles.frag

raw
1 #version 450 core
2
3 layout(location = 0) out vec4 color;
4
5 layout(location = 0) in VertexBlock
6 {
7 flat vec3 color;
8 vec3 pos;
9 vec3 normal;
10 } frag_in;
11
12 const vec4 lightPosition = vec4(0.0, 0.0, 0.0, 0.0);
13 const vec3 lightIntensity = vec3(1.0, 1.0, 1.0);
14 const vec3 ka = vec3(0.1, 0.1, 0.1);
15 const vec3 ks = vec3(0.8, 0.8, 0.8);
16 const float shininess = 50.0;
17
18 vec3 ads()
19 {
20 vec3 n = normalize( frag_in.normal);
21 vec3 s = normalize( vec3(lightPosition) - frag_in.pos );
22 vec3 v = normalize( -frag_in.pos );
23 vec3 h = normalize( v + s );
24 return lightIntensity * (ka +
25 frag_in.color * max( dot(s, frag_in.normal ), 0.0 ) +
26 ks * pow( max( dot( h, n ), 0.0 ), shininess ) );
27 }
28
29
30 void main(void)
31 {
32 color = vec4(ads(), 1.0);
33 }