qvolray
diff sdr/volray.p.glsl @ 26:f4cc61b5a3eb
foo
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 14 Apr 2012 04:59:14 +0300 |
parents | 63bc059778d0 |
children | 437e1ba9cf39 |
line diff
1.1 --- a/sdr/volray.p.glsl Sat Apr 14 01:13:43 2012 +0300 1.2 +++ b/sdr/volray.p.glsl Sat Apr 14 04:59:14 2012 +0300 1.3 @@ -21,7 +21,7 @@ 1.4 1.5 vec3 sky(Ray ray); 1.6 vec3 ray_march(Ray ray, float t0, float t1); 1.7 -vec3 shade(Ray ray, vec3 pos, vec3 norm); 1.8 +vec3 shade(Ray ray, vec3 pos, vec3 norm, vec3 ldir); 1.9 Ray get_primary_ray(); 1.10 ISect intersect_aabb(Ray ray, AABBox aabb); 1.11 ISect intersect_sphere(Ray ray, float rad); 1.12 @@ -78,6 +78,7 @@ 1.13 float energy = 1.0; 1.14 float t = t0; 1.15 vec3 col = vec3(0.0, 0.0, 0.0); 1.16 + const vec3 ldir = normalize(vec3(-1, 1, -4)); 1.17 1.18 1.19 while(t < t1) { 1.20 @@ -90,7 +91,7 @@ 1.21 float energy_drop = exp(val * -ray_step); // * scatter_coeff ? 1.22 energy *= energy_drop; 1.23 1.24 - vec3 irrad = shade(ray, pos, normalize(norm)); 1.25 + vec3 irrad = shade(ray, pos, normalize(norm), ldir); 1.26 1.27 col += (1.0 - energy_drop) * energy * irrad; 1.28 if(energy < 0.001) { 1.29 @@ -101,11 +102,10 @@ 1.30 return col; 1.31 } 1.32 1.33 -vec3 shade(Ray ray, vec3 pos, vec3 norm) 1.34 +vec3 shade(Ray ray, vec3 pos, vec3 norm, vec3 ldir) 1.35 { 1.36 - vec3 ldir = -normalize(ray.dir); 1.37 - vec3 vdir = ldir; 1.38 - vec3 hdir = ldir;//normalize(ldir + vdir); 1.39 + vec3 vdir = -normalize(ray.dir); 1.40 + vec3 hdir = normalize(ldir + vdir); 1.41 1.42 float ndotl = abs(dot(ldir, norm)); 1.43 float ndoth = abs(dot(hdir, norm));