Cube  Diff

Differences From Artifact [38a360a277]:

To Artifact [05ada5ded7]:


38
39
40
41
42
43
44
45

46
47

48
49
50
51
52
53
54
55
56
38
39
40
41
42
43
44

45


46


47
48
49
50
51
52
53







-
+
-
-
+
-
-







	if (hasoverbright) {
		l /= lightscale;
		stepl /= lightscale;

		// coloured light version, special case because most lights are
		// white
		if (light.attr3 || light.attr4) {
			int dimness = rnd(
			int dimness = rnd((255 - (light.attr2 + light.attr3 +
			    (255 -
			        (light.attr2 + light.attr3 + light.attr4) / 3) /
			    light.attr4) / 3) / 16 + 1);
			        16 +
			    1);
			x += stepx * dimness;
			y += stepy * dimness;

			if (OUTBORD(x >> PRECBITS, y >> PRECBITS))
				return;

			int g = light.attr3 << PRECBITS;
144
145
146
147
148
149
150
151

152
153


154

155
156
157
158



159
160
161
162
163

164
165
166
167
168
169
170
141
142
143
144
145
146
147

148
149
150
151
152

153




154
155
156

157
158
159
160
161
162
163
164
165
166
167
168







-
+


+
+
-
+
-
-
-
-
+
+
+
-




+







}

// median filter, smooths out random noise in light and makes it more mipable
void
postlightarea(const struct block *a)
{
	// assumes area not on edge of world
	for (int x = 0; x < a->xs; x++)
	for (int x = 0; x < a->xs; x++) {
		for (int y = 0; y < a->ys; y++) {
			struct sqr *s = S(x + a->x, y + a->y);

			// median is 4/2/1 instead
#define median(m)                                                            \
#define median(m)							 \
	s->m =                                                               \
	    (s->m * 2 + SW(s, 1, 0)->m * 2 + SW(s, 0, 1)->m * 2 +            \
	        SW(s, -1, 0)->m * 2 + SW(s, 0, -1)->m * 2 + SW(s, 1, 1)->m + \
	        SW(s, 1, -1)->m + SW(s, -1, 1)->m + SW(s, -1, -1)->m) /      \
	s->m = (s->m * 2 + SW(s, 1, 0)->m * 2 + SW(s, 0, 1)->m * 2 +	 \
	    SW(s, -1, 0)->m * 2 + SW(s, 0, -1)->m * 2 + SW(s, 1, 1)->m + \
	    SW(s, 1, -1)->m + SW(s, -1, 1)->m + SW(s, -1, -1)->m) / 14;
	    14; // median is 4/2/1 instead
			median(r);
			median(g);
			median(b);
		}
	}

	remip(a, 0);
}

void
calclight()
{