Mercurial > hg > forks > gldragon
comparison shader.frag @ 65:71f6c5cc8eec
Add 'ftime' uniform for shaders, which is time in milliseconds from start of rendering loop.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 15 Dec 2019 02:54:39 +0200 |
parents | d2839cbfaad8 |
children |
comparison
equal
deleted
inserted
replaced
64:e8100c1c5d99 | 65:71f6c5cc8eec |
---|---|
1 varying vec3 snormal; | 1 varying vec3 snormal; |
2 varying vec3 svertex; | 2 varying vec3 svertex; |
3 uniform int nlights; | 3 uniform int nlights; |
4 uniform float ftime; | |
4 | 5 |
5 | 6 |
6 float maxdot(vec3 sveca, vec3 svecb) | 7 float maxdot(vec3 sveca, vec3 svecb) |
7 { | 8 { |
8 return max(dot(sveca, svecb), 0.0); | 9 return max(dot(sveca, svecb), 0.0); |
20 vec3 snormal = normalize(snormal); | 21 vec3 snormal = normalize(snormal); |
21 vec3 srcVec = normalize(-svertex); | 22 vec3 srcVec = normalize(-svertex); |
22 //vec4 poo = vec4(0.0, 0.0, 0.0, 0.0); | 23 //vec4 poo = vec4(0.0, 0.0, 0.0, 0.0); |
23 vec4 poo = gl_FragCoord; | 24 vec4 poo = gl_FragCoord; |
24 //poo += vec4(snormal.x, snormal.y, snormal.z, 0.0); | 25 //poo += vec4(snormal.x, snormal.y, snormal.z, 0.0); |
25 vec4 finalColor = vec4(poo.x * 0.1, poo.y * 0.001, poo.z, 1.0); | 26 vec4 finalColor = vec4(poo.x * 0.1, poo.y * 0.001, poo.z + sin(ftime * 0.001), 1.0); |
26 | 27 |
27 for (int i = 0; i < nlights; i++) | 28 for (int i = 0; i < nlights; i++) |
28 { | 29 { |
29 vec3 lightVec = normalize(gl_LightSource[i].position.xyz - svertex); | 30 vec3 lightVec = normalize(gl_LightSource[i].position.xyz - svertex); |
30 vec3 refVec = normalize(-reflect(lightVec, snormal)); | 31 vec3 refVec = normalize(-reflect(lightVec, snormal)); |