qvolray

view 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
line source
1 #define NBALLS 3
3 uniform float energy[NBALLS];
4 uniform vec3 pos[NBALLS];
6 float eval(vec3 p)
7 {
8 float val = 0.0;
10 for(int i=0; i<NBALLS; i++) {
11 vec3 dif = p - pos[i];
12 float len_sq = dot(dif, dif);
13 val += 0.1 * energy[i] / len_sq;
14 }
15 return val;
16 }
18 #define OFFS 0.01
20 void main()
21 {
22 vec3 pos = gl_TexCoord[0].xyz * 2.0 - 1.0;
24 float val = eval(pos);
26 vec3 grad;
27 grad.x = eval(pos + vec3(OFFS, 0.0, 0.0)) - eval(pos - vec3(OFFS, 0.0, 0.0));
28 grad.y = eval(pos + vec3(0.0, OFFS, 0.0)) - eval(pos - vec3(0.0, OFFS, 0.0));
29 grad.z = eval(pos + vec3(0.0, 0.0, OFFS)) - eval(pos - vec3(0.0, 0.0, OFFS));
31 gl_FragColor = vec4(grad, val);
32 }