qvolray
diff sdr/volray.p.glsl @ 20:68c6eb619d1c
normals from gradient map
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Wed, 11 Apr 2012 06:43:34 +0300 |
parents | a6765984e057 |
children | 4c62be57fc1a |
line diff
1.1 --- a/sdr/volray.p.glsl Sun Apr 08 14:31:03 2012 +0300 1.2 +++ b/sdr/volray.p.glsl Wed Apr 11 06:43:34 2012 +0300 1.3 @@ -40,15 +40,19 @@ 1.4 gl_FragColor = vec4(color, 1.0); 1.5 } 1.6 1.7 -float eval(vec3 pos) 1.8 +float eval(vec3 pos, out vec3 grad) 1.9 { 1.10 vec3 tc = pos * 0.5 + 0.5; 1.11 1.12 if(tc.x < 0.0 || tc.y < 0.0 || tc.z < zclip || tc.x > 1.0 || tc.y > 1.0 || tc.z > 1.0) { 1.13 + grad = vec3(0.0, 0.0, 0.0); 1.14 return 0.0; 1.15 } 1.16 1.17 - return texture1D(xfer_tex, texture3D(volume, tc).a).x; 1.18 + vec4 texel = texture3D(volume, tc); 1.19 + grad = texel.xyz; 1.20 + 1.21 + return texture1D(xfer_tex, texel.a).x; 1.22 } 1.23 1.24 #define OFFS 0.01 1.25 @@ -63,14 +67,10 @@ 1.26 vec3 pos = ray.origin + ray.dir * t; 1.27 t += ray_step; 1.28 1.29 - float val = eval(pos); 1.30 vec3 norm; 1.31 + float val = eval(pos, norm); 1.32 1.33 - norm.x = eval(pos + vec3(OFFS, 0.0, 0.0)) - val; 1.34 - norm.y = eval(pos + vec3(0.0, OFFS, 0.0)) - val; 1.35 - norm.z = eval(pos + vec3(0.0, 0.0, OFFS)) - val; 1.36 - 1.37 - col += shade(ray, pos, normalize(norm)) * val * energy; 1.38 + col += /*shade(ray, pos, normalize(norm))*/ norm * val * energy; 1.39 energy -= val; 1.40 if(energy < 0.001) { 1.41 break;