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