summaryrefslogtreecommitdiff
path: root/progs
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2001-05-09 21:36:52 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2001-05-09 21:36:52 +0000
commitb9f2494bfc990fe7269feeb441a3893aceb7569e (patch)
tree76f19b13bc1dd1f6925db5cf8c0f9aee40bc2ae1 /progs
parent91979127ecec0f3d60507f9197b1f9fd00e4e145 (diff)
fixed FP underflow problem in kfact computation
Diffstat (limited to 'progs')
-rw-r--r--progs/demos/ray.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/progs/demos/ray.c b/progs/demos/ray.c
index 44289b7f96..2173b54fd4 100644
--- a/progs/demos/ray.c
+++ b/progs/demos/ray.c
@@ -386,8 +386,7 @@ colorcheckmap(float ppos[3], float c[3])
h[1] = 0.5f * (vdir[1] + ldir[1]);
h[2] = 0.5f * (vdir[2] + ldir[2]);
kfact = dprod(h, norm);
- kfact =
- kfact * kfact * kfact * kfact * kfact * kfact * kfact * 7.0f * 255.0f;
+ kfact = pow(kfact, 6.0) * 7.0 * 255.0;
r = r * dfact + kfact;
g = g * dfact + kfact;
@@ -487,12 +486,10 @@ updatereflectmap(int slot)
h[1] = 0.5f * (vdir[1] + ldir[1]);
h[2] = 0.5f * (vdir[2] + ldir[2]);
kfact = dprod(h, norm);
- kfact *= kfact;
- kfact *= kfact;
- kfact *= kfact;
- kfact *= kfact;
- kfact *= 10.0f;
- }
+ kfact = pow(kfact, 4.0);
+ if (kfact < 1.0e-10)
+ kfact = 0.0;
+ }
r = dfact + kfact;
g = dfact + kfact;