volray
diff volray.p.glsl @ 8:ae10631bb11b
cleaning up a bit to expand
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 07 Apr 2012 16:07:12 +0300 |
parents | f40e4edfee7e |
children |
line diff
1.1 --- a/volray.p.glsl Thu Apr 05 00:52:11 2012 +0300 1.2 +++ b/volray.p.glsl Sat Apr 07 16:07:12 2012 +0300 1.3 @@ -63,15 +63,14 @@ 1.4 vec3 pos = ray.origin + ray.dir * t; 1.5 t += ray_step; 1.6 1.7 - float val = eval(pos) * energy; 1.8 + float val = eval(pos); 1.9 vec3 norm; 1.10 1.11 norm.x = eval(pos + vec3(OFFS, 0.0, 0.0)) - val; 1.12 norm.y = eval(pos + vec3(0.0, OFFS, 0.0)) - val; 1.13 norm.z = eval(pos + vec3(0.0, 0.0, OFFS)) - val; 1.14 - norm = normalize(norm); 1.15 1.16 - col += shade(ray, pos, norm) * val; 1.17 + col += shade(ray, pos, normalize(norm)) * val * energy; 1.18 energy -= val; 1.19 if(energy < 0.001) { 1.20 break; 1.21 @@ -84,15 +83,15 @@ 1.22 1.23 vec3 shade(Ray ray, vec3 pos, vec3 norm) 1.24 { 1.25 - vec3 ldir = normalize(vec3(10.0, 10.0, -10.0) - pos); 1.26 + vec3 ldir = -pos;//normalize(vec3(10.0, 10.0, -10.0) - pos); 1.27 vec3 vdir = -ray.dir; 1.28 vec3 hdir = normalize(ldir + vdir); 1.29 1.30 float ndotl = dot(ldir, norm); 1.31 float ndoth = dot(hdir, norm); 1.32 1.33 - vec3 dcol = vec3(1.0, 1.0, 1.0) * max(ndotl, 0.0); 1.34 - vec3 scol = vec3(0.6, 0.6, 0.6) * pow(max(ndoth, 0.0), 50.0); 1.35 + vec3 dcol = vec3(0.9, 0.9, 0.9) * max(ndotl, 0.0); 1.36 + vec3 scol = vec3(0.5, 0.5, 0.5) * pow(max(ndoth, 0.0), 50.0); 1.37 1.38 return vec3(0.01, 0.01, 0.01) + dcol + scol; 1.39 }