]> git.lizzy.rs Git - minetest.git/blob - src/light.cpp
Disable word wrap in vertical texts in main menu
[minetest.git] / src / light.cpp
1 /*
2 Minetest-c55
3 Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #include "light.h"
21
22 #if 1
23 /*
24 Made using this and:
25 - adding 220 as the second last one
26 - replacing the third last one (212) with 195
27
28 #!/usr/bin/python
29
30 from math import *
31 from sys import stdout
32
33 # We want 0 at light=0 and 255 at light=LIGHT_MAX
34 LIGHT_MAX = 14
35 #FACTOR = 0.69
36 #FACTOR = 0.75
37 FACTOR = 0.83
38 START_FROM_ZERO = False
39
40 L = []
41 if START_FROM_ZERO:
42     for i in range(1,LIGHT_MAX+1):
43         L.append(int(round(255.0 * FACTOR ** (i-1))))
44     L.append(0)
45 else:
46     for i in range(1,LIGHT_MAX+1):
47         L.append(int(round(255.0 * FACTOR ** (i-1))))
48     L.append(255)
49
50 L.reverse()
51 for i in L:
52     stdout.write(str(i)+",\n")
53 */
54 u8 light_decode_table[LIGHT_MAX+1] = 
55 {
56 23,
57 27,
58 33,
59 40,
60 48,
61 57,
62 69,
63 83,
64 100,
65 121,
66 146,
67 176,
68 195,
69 220,
70 255,
71 };
72 #endif
73
74 #if 0
75 // This is good
76 // a_n+1 = a_n * 0.786
77 // Length of LIGHT_MAX+1 means LIGHT_MAX is the last value.
78 // LIGHT_SUN is read as LIGHT_MAX from here.
79 u8 light_decode_table[LIGHT_MAX+1] = 
80 {
81 8,
82 11,
83 14,
84 18,
85 22,
86 29,
87 37,
88 47,
89 60,
90 76,
91 97,
92 123,
93 157,
94 200,
95 255,
96 };
97 #endif
98
99 #if 0
100 // Use for debugging in dark
101 u8 light_decode_table[LIGHT_MAX+1] = 
102 {
103 58,
104 64,
105 72,
106 80,
107 88,
108 98,
109 109,
110 121,
111 135,
112 150,
113 167,
114 185,
115 206,
116 229,
117 255,
118 };
119 #endif
120
121 // This is reasonable with classic lighting with a light source
122 /*u8 light_decode_table[LIGHT_MAX+1] = 
123 {
124 2,
125 3,
126 4,
127 6,
128 9,
129 13,
130 18,
131 25,
132 32,
133 35,
134 45,
135 57,
136 69,
137 79,
138 255
139 };*/
140
141
142 // As in minecraft, a_n+1 = a_n * 0.8
143 // NOTE: This doesn't really work that well because this defines
144 //       LIGHT_MAX as dimmer than LIGHT_SUN
145 // NOTE: Uh, this has had 34 left out; forget this.
146 /*u8 light_decode_table[LIGHT_MAX+1] = 
147 {
148 8,
149 11,
150 14,
151 17,
152 21,
153 27,
154 42,
155 53,
156 66,
157 83,
158 104,
159 130,
160 163,
161 204,
162 255,
163 };*/
164
165 // This was a quick try of more light, manually quickly made
166 /*u8 light_decode_table[LIGHT_MAX+1] = 
167 {
168 0,
169 7,
170 11,
171 15,
172 21,
173 29,
174 42,
175 53,
176 69,
177 85,
178 109,
179 135,
180 167,
181 205,
182 255,
183 };*/
184
185 // This was used for a long time, manually made
186 /*u8 light_decode_table[LIGHT_MAX+1] = 
187 {
188 0,
189 6,
190 8,
191 11,
192 14,
193 19,
194 26,
195 34,
196 45,
197 61,
198 81,
199 108,
200 143,
201 191,
202 255,
203 };*/
204
205 /*u8 light_decode_table[LIGHT_MAX+1] = 
206 {
207 0,
208 3,
209 6,
210 10,
211 18,
212 25,
213 35,
214 50,
215 75,
216 95,
217 120,
218 150,
219 185,
220 215,
221 255,
222 };*/
223 /*u8 light_decode_table[LIGHT_MAX+1] = 
224 {
225 0,
226 5,
227 12,
228 22,
229 35,
230 50,
231 65,
232 85,
233 100,
234 120,
235 140,
236 160,
237 185,
238 215,
239 255,
240 };*/
241 // LIGHT_MAX is 14, 0-14 is 15 values
242 /*u8 light_decode_table[LIGHT_MAX+1] = 
243 {
244 0,
245 9,
246 12,
247 14,
248 16,
249 20,
250 26,
251 34,
252 45,
253 61,
254 81,
255 108,
256 143,
257 191,
258 255,
259 };*/
260
261 #if 0
262 /*
263 #!/usr/bin/python
264
265 from math import *
266 from sys import stdout
267
268 # We want 0 at light=0 and 255 at light=LIGHT_MAX
269 LIGHT_MAX = 14
270 #FACTOR = 0.69
271 FACTOR = 0.75
272
273 L = []
274 for i in range(1,LIGHT_MAX+1):
275     L.append(int(round(255.0 * FACTOR ** (i-1))))
276 L.append(0)
277
278 L.reverse()
279 for i in L:
280     stdout.write(str(i)+",\n")
281 */
282 u8 light_decode_table[LIGHT_MAX+1] = 
283 {
284 0,
285 6,
286 8,
287 11,
288 14,
289 19,
290 26,
291 34,
292 45,
293 61,
294 81,
295 108,
296 143,
297 191,
298 255,
299 };
300 #endif
301
302