MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / ShadeLightmapInfoEdges

Function ShadeLightmapInfoEdges

Descent3/lightmap_info.cpp:196–324  ·  view source on GitHub ↗

TODO: MTS: unused? Softens the edges of lightmaps so there are fewer artifaces

Source from the content-addressed store, hash-verified

194// TODO: MTS: unused?
195// Softens the edges of lightmaps so there are fewer artifaces
196void ShadeLightmapInfoEdges(int type) {
197 int i;
198
199 for (i = 0; i < MAX_LIGHTMAP_INFOS; i++) {
200 if (LightmapInfo[i].used && LightmapInfo[i].type == type) {
201 uint16_t *src_data;
202 uint16_t *dest_data = lm_data(LightmapInfo[i].lm_handle);
203 int w = lmi_w(i);
204 int h = lmi_h(i);
205 int x, y;
206
207 src_data = (uint16_t *)mem_malloc(w * h * 2);
208 ASSERT(src_data);
209
210 memcpy(src_data, dest_data, w * h * 2);
211
212 for (y = 0; y < h; y++) {
213 for (x = 0; x < w; x++) {
214 if (!(src_data[y * w + x] & OPAQUE_FLAG)) {
215 int r = 0, g = 0, b = 0;
216 int num = 0;
217 ddgr_color color;
218 uint16_t color16;
219
220 // Left edge
221 if (x != 0) {
222
223 color16 = src_data[y * w + (x - 1)];
224 if (color16 & OPAQUE_FLAG) {
225 color = GR_16_TO_COLOR(color16);
226 r += GR_COLOR_RED(color);
227 g += GR_COLOR_GREEN(color);
228 b += GR_COLOR_BLUE(color);
229 num++;
230 }
231
232 if (y != 0) {
233 color16 = src_data[(y - 1) * w + (x - 1)];
234 if (color16 & OPAQUE_FLAG) {
235 color = GR_16_TO_COLOR(color16);
236 r += GR_COLOR_RED(color);
237 g += GR_COLOR_GREEN(color);
238 b += GR_COLOR_BLUE(color);
239 num++;
240 }
241 }
242
243 if (y != h - 1) {
244 color16 = src_data[(y + 1) * w + (x - 1)];
245 if (color16 & OPAQUE_FLAG) {
246 color = GR_16_TO_COLOR(color16);
247 r += GR_COLOR_RED(color);
248 g += GR_COLOR_GREEN(color);
249 b += GR_COLOR_BLUE(color);
250 num++;
251 }
252 }
253 }

Callers 2

DoRadiosityForRoomsFunction · 0.85
DoRadiosityForTerrainFunction · 0.85

Calls 8

lm_dataFunction · 0.85
lmi_wFunction · 0.85
lmi_hFunction · 0.85
GR_16_TO_COLORFunction · 0.85
GR_COLOR_REDFunction · 0.85
GR_COLOR_GREENFunction · 0.85
GR_COLOR_BLUEFunction · 0.85
GR_RGB16Function · 0.85

Tested by

no test coverage detected