home *** CD-ROM | disk | FTP | other *** search
- /*
- * bg.c -- background texturing.
- *
- * (c) 1993, 1994, Han-Wen Nienhuys <hanwen@stack.urc.tue.nl>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * This file is based on work by George Kyriazis.
- *
- * the background color can be changed to have any kind of background
- * texturing. (hint hint)
- */
-
- #include "ray.h"
- #include "proto.h"
- #include "extern.h"
-
- color
- bgcolor(struct ray *r)
- {
- color c;
- double factor;
-
-
-
- /* if it is above the appropriate axis just give a grey value */
- /* if below give a gradually whiter color */
- factor = vdot(bggradient, r->dir);
-
- if (factor >= -EPSILON)
- c = background_color;
- else {
- c.r = background_color.r * (1 - 0.8 * factor);
- c.g = background_color.g * (1 - 0.8 * factor);
- c.b = background_color.b * (1 - 0.8 * factor);
- }
-
- c = normcol(c);
-
- return c;
- }
-