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