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