]> icculus.org git repositories - taylor/freespace2.git/blob - include/lighting.h
rendering functions mostly done; more complete shader setup
[taylor/freespace2.git] / include / lighting.h
1 /*
2  * Copyright (C) Volition, Inc. 1999.  All rights reserved.
3  *
4  * All source code herein is the property of Volition, Inc. You may not sell 
5  * or otherwise commercially exploit the source or things you created based on
6  * the source.
7  */
8
9 /*
10  * $Logfile: /Freespace2/code/Lighting/Lighting.h $
11  * $Revision$
12  * $Date$
13  * $Author$
14  *
15  * Include file for lighting functions
16  *
17  * $Log$
18  * Revision 1.2  2002/06/09 04:41:13  relnev
19  * added copyright header
20  *
21  * Revision 1.1.1.1  2002/05/03 03:28:12  root
22  * Initial import.
23  *
24  * 
25  * 4     6/18/99 5:16p Dave
26  * Added real beam weapon lighting. Fixed beam weapon sounds. Added MOTD
27  * dialog to PXO screen.
28  * 
29  * 3     5/09/99 6:00p Dave
30  * Lots of cool new effects. E3 build tweaks.
31  * 
32  * 2     10/07/98 10:53a Dave
33  * Initial checkin.
34  * 
35  * 1     10/07/98 10:49a Dave
36  * 
37  * 13    4/10/98 5:20p John
38  * Changed RGB in lighting structure to be ubytes.  Removed old
39  * not-necessary 24 bpp software stuff.
40  * 
41  * 12    2/13/98 5:00p John
42  * Made lighting push functions return number of releveent lights.
43  * 
44  * 11    1/29/98 8:14a John
45  * Added support for RGB lighting
46  * 
47  * 10    1/23/98 5:08p John
48  * Took L out of vertex structure used B (blue) instead.   Took all small
49  * fireballs out of fireball types and used particles instead.  Fixed some
50  * debris explosion things.  Restructured fireball code.   Restructured
51  * some lighting code.   Made dynamic lighting on by default. Made groups
52  * of lasers only cast one light.  Made fireballs not cast light.
53  * 
54  * 9     12/12/97 3:02p John
55  * First Rev of Ship Shadows
56  * 
57  * 8     11/07/97 7:24p John
58  * changed lighting to take two ranges.
59  * In textest, added test code to draw nebulas
60  * 
61  * 7     11/04/97 9:19p John
62  * Optimized dynamic lighting more.
63  * 
64  * 6     10/29/97 5:05p John
65  * Changed dynamic lighting to only rotate and calculate lighting for
66  * point lights that are close to an object.  Changed lower framerate cap
67  * from 4 to .5.
68  * 
69  * 5     4/08/97 5:18p John
70  * First rev of decent (dynamic, correct) lighting in FreeSpace.
71  * 
72  * 4     2/17/97 5:18p John
73  * Added a bunch of RCS headers to a bunch of old files that don't have
74  * them.
75  * 
76  * 3     1/30/97 9:35a Hoffoss
77  * Added header for files.
78  *
79  * $NoKeywords: $
80  */
81
82 #ifndef _LIGHTING_H
83 #define _LIGHTING_H
84
85 // Light stuff works like this:
86 // At the start of the frame, call light_reset.
87 // For each light source, call light_add_??? functions.
88 // To calculate lighting, do:
89 // call light_filter_reset or light_filter.
90 // set up matrices with g3 functions
91 // call light_rotatate_all to rotate all valid
92 // lights into current coordinates.
93 // call light_apply to fill in lighting for a point.
94
95 void light_reset();
96 void light_set_ambient(float ambient_light);
97
98 // Intensity - how strong the light is.  1.0 will cast light around 5meters or so.
99 // r,g,b - only used for colored lighting. Ignored currently.
100 void light_add_directional( vector *dir, float intensity, float r, float g, float b );
101 void light_add_point( vector * pos, float r1, float r2, float intensity, float r, float g, float b, int ignore_objnum );
102 void light_add_point_unique( vector * pos, float r1, float r2, float intensity, float r, float g, float b, int affected_objnum);
103 void light_add_tube(vector *p0, vector *p1, float r1, float r2, float intensity, float r, float g, float b, int affected_objnum);
104 void light_rotate_all();
105
106 // Reset the list of lights to point to all lights.
107 void light_filter_reset();
108
109 // Makes a list of only the lights that will affect
110 // the sphere specified by 'pos' and 'rad' and 'objnum'.
111 // Returns number of lights active.
112 int light_filter_push( int objnum, vector *pos, float rad );
113 int light_filter_push_box( vector *min, vector *max );
114 void light_filter_pop();
115
116 // Applies light to a vertex.   In order for this to work, 
117 // it assumes that one of light_filter or light_filter_reset
118 // have been called.  It only uses 'vert' to fill in it's light
119 // fields.  'pos' is position of point, 'norm' is the norm.
120 ubyte light_apply( vector *pos, vector * norm, float static_light_val );
121
122 // Same as above only does RGB.
123 void light_apply_rgb( ubyte *param_r, ubyte *param_g, ubyte *param_b, vector *pos, vector * norm, float static_light_val );
124
125 // return the # of global light sources
126 int light_get_global_count();
127
128 // Fills direction of global light source N in pos.
129 // Returns 0 if there is no global light.
130 int light_get_global_dir(vector *pos, int n);
131
132 // Set to non-zero if we're in a shadow.
133 void light_set_shadow( int state );
134
135
136 #endif
137