]> icculus.org git repositories - divverent/nexuiz.git/blob - misc/gtkradiant/singlepatches/q3map2-UTlmexposure.diff
add GtkRadiant patch set
[divverent/nexuiz.git] / misc / gtkradiant / singlepatches / q3map2-UTlmexposure.diff
1 Index: tools/quake3/q3map2/game_ja.h
2 ===================================================================
3 --- tools/quake3/q3map2/game_ja.h       (revision 191)
4 +++ tools/quake3/q3map2/game_ja.h       (working copy)
5 @@ -67,6 +67,7 @@
6         qfalse,                         /* wolf lighting model? */
7         128,                            /* lightmap width/height */
8         1.0f,                           /* lightmap gamma */
9 +       1.0f,                           /* lightmap exposure */
10         1.0f,                           /* lightmap compensate */
11         "RBSP",                         /* bsp file prefix */
12         1,                                      /* bsp file version */
13 Index: tools/quake3/q3map2/game_tremulous.h
14 ===================================================================
15 --- tools/quake3/q3map2/game_tremulous.h        (revision 191)
16 +++ tools/quake3/q3map2/game_tremulous.h        (working copy)
17 @@ -70,6 +70,7 @@
18         qfalse,                         /* wolf lighting model? */
19         128,                            /* lightmap width/height */
20         1.0f,                           /* lightmap gamma */
21 +       1.0f,                           /* lightmap exposure */
22         1.0f,                           /* lightmap compensate */
23         "IBSP",                         /* bsp file prefix */
24         46,                                     /* bsp file version */
25 Index: tools/quake3/q3map2/game_wolfet.h
26 ===================================================================
27 --- tools/quake3/q3map2/game_wolfet.h   (revision 191)
28 +++ tools/quake3/q3map2/game_wolfet.h   (working copy)
29 @@ -66,6 +66,7 @@
30         qtrue,                          /* wolf lighting model? */
31         128,                            /* lightmap width/height */
32         1.0f,                           /* lightmap gamma */
33 +       1.0f,                           /* lightmap exposure */
34         1.0f,                           /* lightmap compensate */
35         "IBSP",                         /* bsp file prefix */
36         47,                                     /* bsp file version */
37 Index: tools/quake3/q3map2/game_wolf.h
38 ===================================================================
39 --- tools/quake3/q3map2/game_wolf.h     (revision 191)
40 +++ tools/quake3/q3map2/game_wolf.h     (working copy)
41 @@ -129,6 +129,7 @@
42         qtrue,                          /* wolf lighting model? */
43         128,                            /* lightmap width/height */
44         1.0f,                           /* lightmap gamma */
45 +       1.0f,                           /* lightmap exposure */
46         1.0f,                           /* lightmap compensate */
47         "IBSP",                         /* bsp file prefix */
48         47,                                     /* bsp file version */
49 Index: tools/quake3/q3map2/game_sof2.h
50 ===================================================================
51 --- tools/quake3/q3map2/game_sof2.h     (revision 191)
52 +++ tools/quake3/q3map2/game_sof2.h     (working copy)
53 @@ -139,6 +139,7 @@
54         qfalse,                                 /* wolf lighting model? */
55         128,                                    /* lightmap width/height */
56         1.0f,                                   /* lightmap gamma */
57 +       1.0f,                                   /* lightmap exposure */
58         1.0f,                                   /* lightmap compensate */
59         "RBSP",                                 /* bsp file prefix */
60         1,                                              /* bsp file version */
61 Index: tools/quake3/q3map2/game_etut.h
62 ===================================================================
63 --- tools/quake3/q3map2/game_etut.h     (revision 191)
64 +++ tools/quake3/q3map2/game_etut.h     (working copy)
65 @@ -148,6 +148,7 @@
66         qfalse,                         /* wolf lighting model? */
67         128,                            /* lightmap width/height */
68         2.2f,                           /* lightmap gamma */
69 +       1.0f,                           /* lightmap exposure */
70         1.0f,                           /* lightmap compensate */
71         "IBSP",                         /* bsp file prefix */
72         47,                                     /* bsp file version */
73 Index: tools/quake3/q3map2/game_jk2.h
74 ===================================================================
75 --- tools/quake3/q3map2/game_jk2.h      (revision 191)
76 +++ tools/quake3/q3map2/game_jk2.h      (working copy)
77 @@ -64,6 +64,7 @@
78         qfalse,                         /* wolf lighting model? */
79         128,                            /* lightmap width/height */
80         1.0f,                           /* lightmap gamma */
81 +       1.0f,                           /* lightmap exposure */
82         1.0f,                           /* lightmap compensate */
83         "RBSP",                         /* bsp file prefix */
84         1,                                      /* bsp file version */
85 Index: tools/quake3/q3map2/game_qfusion.h
86 ===================================================================
87 --- tools/quake3/q3map2/game_qfusion.h  (revision 191)
88 +++ tools/quake3/q3map2/game_qfusion.h  (working copy)
89 @@ -115,6 +115,7 @@
90         qfalse,                         /* wolf lighting model? */
91         512,                            /* lightmap width/height */
92         1.0f,                           /* lightmap gamma */
93 +       1.0f,                           /* lightmap exposure */
94         1.0f,                           /* lightmap compensate */
95         "FBSP",                         /* bsp file prefix */
96         1,                                      /* bsp file version */
97 Index: tools/quake3/q3map2/game_tenebrae.h
98 ===================================================================
99 --- tools/quake3/q3map2/game_tenebrae.h (revision 191)
100 +++ tools/quake3/q3map2/game_tenebrae.h (working copy)
101 @@ -112,6 +112,7 @@
102         qfalse,                         /* wolf lighting model? */
103         512,                            /* lightmap width/height */
104         2.0f,                           /* lightmap gamma */
105 +       1.0f,                           /* lightmap exposure */
106         1.0f,                           /* lightmap compensate */
107         "IBSP",                         /* bsp file prefix */
108         46,                                     /* bsp file version */
109 Index: tools/quake3/q3map2/game_quake3.h
110 ===================================================================
111 --- tools/quake3/q3map2/game_quake3.h   (revision 191)
112 +++ tools/quake3/q3map2/game_quake3.h   (working copy)
113 @@ -112,6 +112,7 @@
114         qfalse,                         /* wolf lighting model? */
115         128,                            /* lightmap width/height */
116         1.0f,                           /* lightmap gamma */
117 +       1.0f,                           /* lightmap exposure */
118         1.0f,                           /* lightmap compensate */
119         "IBSP",                         /* bsp file prefix */
120         46,                                     /* bsp file version */
121 Index: tools/quake3/q3map2/game_ef.h
122 ===================================================================
123 --- tools/quake3/q3map2/game_ef.h       (revision 191)
124 +++ tools/quake3/q3map2/game_ef.h       (working copy)
125 @@ -113,6 +113,7 @@
126         qfalse,                         /* wolf lighting model? */
127         128,                            /* lightmap width/height */
128         1.0f,                           /* lightmap gamma */
129 +       1.0f,                           /* lightmap exposure */
130         1.0f,                           /* lightmap compensate */
131         "IBSP",                         /* bsp file prefix */
132         46,                                     /* bsp file version */
133 Index: tools/quake3/q3map2/light_ydnar.c
134 ===================================================================
135 --- tools/quake3/q3map2/light_ydnar.c   (revision 191)
136 +++ tools/quake3/q3map2/light_ydnar.c   (working copy)
137 @@ -49,6 +49,7 @@
138         int             i;
139         float   max, gamma;
140         vec3_t  sample;
141 +       float   inv, dif;
142         
143         
144         /* ydnar: scaling necessary for simulating r_overbrightBits on external lightmaps */
145 @@ -72,16 +73,51 @@
146                 /* gamma */
147                 sample[ i ] = pow( sample[ i ] / 255.0f, gamma ) * 255.0f;
148         }
149 +
150 +       if (lightmapExposure == 1)
151 +       {
152 +               /* clamp with color normalization */
153 +               max = sample[ 0 ];
154 +               if( sample[ 1 ] > max )
155 +                       max = sample[ 1 ];
156 +               if( sample[ 2 ] > max )
157 +                       max = sample[ 2 ];
158 +               if( max > 255.0f )
159 +                       VectorScale( sample, (255.0f / max), sample );
160 +       }
161 +       else
162 +       {
163 +               if (lightmapExposure==0)
164 +               {
165 +                       lightmapExposure=1.0f;
166 +               }
167 +               inv=1.f/lightmapExposure;
168 +               //Exposure
169 +       
170 +               max = sample[ 0 ];
171 +               if( sample[ 1 ] > max )
172 +                       max = sample[ 1 ];
173 +               if( sample[ 2 ] > max )
174 +                       max = sample[ 2 ];  
175 +      
176 +               dif = (1-  exp(-max * inv) )  *  255;
177 +
178 +               if (max >0) 
179 +               {
180 +                       dif = dif / max;
181 +               }
182 +               else
183 +               {
184 +                       dif = 0;
185 +               }
186 +
187 +               for (i=0;i<3;i++)
188 +               {
189 +                       sample[i]*=dif;
190 +               }
191 +       }
192 +
193         
194 -       /* clamp with color normalization */
195 -       max = sample[ 0 ];
196 -       if( sample[ 1 ] > max )
197 -               max = sample[ 1 ];
198 -       if( sample[ 2 ] > max )
199 -               max = sample[ 2 ];
200 -       if( max > 255.0f )
201 -               VectorScale( sample, (255.0f / max), sample );
202 -       
203         /* compensate for ingame overbrighting/bitshifting */
204         VectorScale( sample, (1.0f / lightmapCompensate), sample );
205         
206 Index: tools/quake3/q3map2/light.c
207 ===================================================================
208 --- tools/quake3/q3map2/light.c (revision 191)
209 +++ tools/quake3/q3map2/light.c (working copy)
210 @@ -1836,6 +1893,14 @@
211                         i++;
212                 }
213                 
214 +               else if( !strcmp( argv[ i ], "-exposure" ) )
215 +               {
216 +                       f = atof( argv[ i + 1 ] );
217 +                       lightmapExposure = f;
218 +                       Sys_Printf( "Lighting exposure set to %f\n", lightmapExposure );
219 +                       i++;
220 +               }
221 +               
222                 else if( !strcmp( argv[ i ], "-compensate" ) )
223                 {
224                         f = atof( argv[ i + 1 ] );
225 Index: tools/quake3/q3map2/q3map2.h
226 ===================================================================
227 --- tools/quake3/q3map2/q3map2.h        (revision 191)
228 +++ tools/quake3/q3map2/q3map2.h        (working copy)
229 @@ -543,6 +545,7 @@
230         qboolean                        wolfLight;                                              /* when true, lights work like wolf q3map  */
231         int                                     lightmapSize;                                   /* bsp lightmap width/height */
232         float                           lightmapGamma;                                  /* default lightmap gamma */
233 +       float                           lightmapExposure;                               /* default lightmap exposure */
234         float                           lightmapCompensate;                             /* default lightmap compensate value */
235         char                            *bspIdent;                                              /* 4-letter bsp file prefix */
236         int                                     bspVersion;                                             /* bsp version to use */
237 @@ -2117,6 +2132,7 @@
238  
239  /* ydnar: lightmap gamma/compensation */
240  Q_EXTERN float                         lightmapGamma Q_ASSIGN( 1.0f );
241 +Q_EXTERN float                         lightmapExposure Q_ASSIGN( 1.0f );
242  Q_EXTERN float                         lightmapCompensate Q_ASSIGN( 1.0f );
243  
244  /* ydnar: for runtime tweaking of falloff tolerance */