qvolray

diff sdr/volray.p.glsl @ 35:6ca076bf5084

sucks ass
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 15 Apr 2012 02:22:13 +0300
parents 437e1ba9cf39
children
line diff
     1.1 --- a/sdr/volray.p.glsl	Sun Apr 15 00:11:38 2012 +0300
     1.2 +++ b/sdr/volray.p.glsl	Sun Apr 15 02:22:13 2012 +0300
     1.3 @@ -125,6 +125,7 @@
     1.4  	return ray;
     1.5  }
     1.6  
     1.7 +#ifdef USE_AABB
     1.8  ISect intersect_aabb(Ray ray, AABBox aabb)
     1.9  {
    1.10  	ISect res;
    1.11 @@ -172,7 +173,7 @@
    1.12  	res.hit = true;
    1.13  	return res;
    1.14  }
    1.15 -
    1.16 +#else
    1.17  
    1.18  ISect intersect_sphere(Ray ray, float rad)
    1.19  {
    1.20 @@ -193,11 +194,12 @@
    1.21  	float t0 = (-b + sqrt_d) / (2.0 * a);
    1.22  	float t1 = (-b - sqrt_d) / (2.0 * a);
    1.23  
    1.24 -	res.t0 = min(t0, t1);
    1.25 -	res.t1 = max(t0, t1);
    1.26 +	res.t0 = max(min(t0, t1), 0.0);
    1.27 +	res.t1 = max(max(t0, t1), 0.0);
    1.28  	res.hit = true;
    1.29  
    1.30  	/*res.pos = ray.origin + ray.dir * res.t0;
    1.31  	res.normal = normalize(res.pos);*/
    1.32  	return res;
    1.33  }
    1.34 +#endif