annotate sdr/demo.p.glsl @ 37:450d4c50470f
- 16bit floating point textures halve gpu texture memory usage
- slower transfer function change
author |
John Tsiombikas <nuclear@member.fsf.org> |
date |
Wed, 01 Jan 2014 00:23:57 +0200 |
parents |
2d0dfb5751dc |
children |
|
rev |
line source |
nuclear@36
|
1 #define NBALLS 3
|
nuclear@36
|
2
|
nuclear@36
|
3 uniform float energy[NBALLS];
|
nuclear@36
|
4 uniform vec3 pos[NBALLS];
|
nuclear@36
|
5
|
nuclear@36
|
6 float eval(vec3 p)
|
nuclear@36
|
7 {
|
nuclear@36
|
8 float val = 0.0;
|
nuclear@36
|
9
|
nuclear@36
|
10 for(int i=0; i<NBALLS; i++) {
|
nuclear@36
|
11 vec3 dif = p - pos[i];
|
nuclear@36
|
12 float len_sq = dot(dif, dif);
|
nuclear@36
|
13 val += 0.1 * energy[i] / len_sq;
|
nuclear@36
|
14 }
|
nuclear@36
|
15 return val;
|
nuclear@36
|
16 }
|
nuclear@36
|
17
|
nuclear@36
|
18 #define OFFS 0.01
|
nuclear@36
|
19
|
nuclear@18
|
20 void main()
|
nuclear@18
|
21 {
|
nuclear@21
|
22 vec3 pos = gl_TexCoord[0].xyz * 2.0 - 1.0;
|
nuclear@18
|
23
|
nuclear@36
|
24 float val = eval(pos);
|
nuclear@21
|
25
|
nuclear@36
|
26 vec3 grad;
|
nuclear@36
|
27 grad.x = eval(pos + vec3(OFFS, 0.0, 0.0)) - eval(pos - vec3(OFFS, 0.0, 0.0));
|
nuclear@36
|
28 grad.y = eval(pos + vec3(0.0, OFFS, 0.0)) - eval(pos - vec3(0.0, OFFS, 0.0));
|
nuclear@36
|
29 grad.z = eval(pos + vec3(0.0, 0.0, OFFS)) - eval(pos - vec3(0.0, 0.0, OFFS));
|
nuclear@36
|
30
|
nuclear@36
|
31 gl_FragColor = vec4(grad, val);
|
nuclear@18
|
32 }
|