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