aboutsummaryrefslogtreecommitdiff
path: root/games/minimal/mods/default/textures/default_grass.png
blob: 1d76708a046ebb96f6ce1548b824db4bfea0dfef (plain)
ofshex dumpascii
0000 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 00 10 00 00 00 10 08 02 00 00 00 90 91 68 .PNG........IHDR...............h
0020 36 00 00 00 01 73 52 47 42 00 ae ce 1c e9 00 00 00 09 70 48 59 73 00 00 0b 13 00 00 0b 13 01 00 6....sRGB.........pHYs..........
0040 9a 9c 18 00 00 00 07 74 49 4d 45 07 db 04 1c 15 25 34 88 c8 4d 62 00 00 00 06 62 4b 47 44 00 ff .......tIME.....%4..Mb....bKGD..
0060 00 ff 00 ff a0 bd a7 93 00 00 02 8e 49 44 41 54 18 19 05 c1 4b 72 db 36 00 00 50 12 3f 12 fc 8b ............IDAT....Kr.6..P.?...
0080 a4 e8 58 8d 9a 58 ce 24 de 64 26 99 f4 00 cd a2 eb 2e 7a 8c 1e a3 b7 6b 0f d0 74 dc 36 b2 63 5b ..X..X.$.d&.......z....k..t.6.c[
00a0 16 25 f1 27 12 20 08 80 c8 7b f6 ef 7f 7c 0c 42 9f 26 44 1b bb 3f 32 d7 c1 8c 8b eb 9b 95 14 9a .%.'.....{...|.B.&D..?2.........
00c0 da 4e 3f cf 87 d3 3e f2 dc 55 fe f2 70 7a 7c bc af 40 b6 0e 35 98 2d 44 2e a2 c2 b7 c8 d5 0f 31 .N?...>..U..pz|..@..5.-D.......1
00e0 25 68 b7 3b 89 4e 1d 76 6d 7d 38 33 a6 1c 1f 9f d8 43 73 e6 36 4a 40 ba cc 10 b6 fb 93 74 a1 73 %h.;.N.vm}83.....Cs.6J@......t.s
0100 f5 ee 15 67 4a 1b 0d a1 b3 dd 56 cb cb 98 06 aa ab c6 ae 19 a3 24 4d 8a 22 4c 3d 24 7b 0b 10 80 ...gJ.....V..........$M."L=${...
0120 e4 20 4d 1d 11 67 5b 0f 06 01 6a c3 2c a4 65 d5 03 1f 5d df 44 5a 5b 55 d5 1f ee 47 c6 26 b0 af ..M..g[...j.,.e...].DZ[U...G.&..
0140 9e 9a aa 9f 6d 9b 4b b9 7b 6e 26 23 09 f5 f7 cf 6c 73 53 90 60 da 97 1d 82 98 b3 29 f5 1d 0f 8a ....m.K.{n&#....lsS.`......)....
0160 ab 77 31 da 95 e3 c2 73 2d 65 3d dc 37 fd a0 97 cb d8 31 ee e6 c3 d2 c2 da 08 a8 b5 ae bb 91 20 .w1....s-e=.7.....1.............
0180 8b b7 ce b1 9b 6b 53 c3 5f 7e db ac 8a b8 a9 46 4c 60 44 83 b2 ec 00 10 bc 67 67 d3 6b 25 7c 4c .....kS._~.....FL`D......gg.k%|L
01a0 30 05 18 d8 83 b4 5e 24 45 14 c7 f0 c3 cf cb 19 98 34 5d 62 a4 98 18 1c d7 9e b4 59 67 1b 39 eb 0.....^$E........4]b.......Yg.9.
01c0 be 1b 5e e6 19 76 9d c7 87 ee eb 7f 95 d4 03 a4 06 9c 2b 25 d8 2c 04 9f 47 0b cd 08 01 cf 48 fb ..^..v............+%.,..G.....H.
01e0 f6 f6 76 6c eb 55 11 14 2f 56 77 ff 9c 7c 6a e7 79 e0 2f b0 e3 21 84 6c 88 5c 6f 96 f1 6c 1a 37 ..vl.U../Vw..|j.y./..!.l.\o..l.7
0200 44 bb 1d 4f 42 e2 2f 1c e4 b2 ba 19 39 ff 96 5d 62 3f 71 0d e0 7c 52 10 53 f4 fe a7 fc 6e cb ca D..OB./.....9..]b?q..|R.S....n..
0220 fe bc 7e 9d 44 be 1f 85 54 99 c1 b6 e0 f6 6f 26 6d 23 34 4b 2f a8 06 13 6b 45 5a a4 96 1e d0 30 ..~.D...T.....o&m#4K/...kEZ....0
0240 b2 34 c6 41 8e 08 b1 66 61 1f db b6 57 bd 4b 31 f0 c0 3a 0f 84 b1 5d e2 d5 6d fd 66 93 1b 07 de .4.A...fa...W.K1..:...]..m.f....
0260 df 1d 40 f9 28 f2 45 98 c7 71 7b ec 9f 4f 07 35 4f 23 b3 3c 12 5c bd 5a 32 2d f9 a4 30 c6 6a 42 ..@.(.E..q{..O.5O#.<.\.Z2-..0.jB
0280 17 c5 6a fb e5 e8 3b 06 98 11 a5 e9 6a fb e5 e8 02 6b 91 85 bc 85 99 47 d4 d9 04 41 d1 d5 4e 59 ..j...;.....j....k.....G...A..NY
02a0 8d 7f fe f5 95 75 ea df ff 9f b2 4b bc 5c 67 f0 f3 af 3f 32 a1 90 2b 21 c4 41 40 92 9c 10 07 f1 .....u.....K.\g...?2..+!.A@.....
02c0 c6 52 46 ba 56 40 a9 67 49 3e ce e2 58 0d 80 40 44 6c 78 fd 29 7d 7a ee a0 03 83 c4 3d 57 53 b3 .RF.V@.gI>..X..@Dlx.)}z.....=WS.
02e0 ef 95 34 61 10 01 3c 7e 7b 2a b9 10 6f de a6 7d 3f 15 17 41 48 a3 aa 6e bf 03 40 f7 72 57 cb b7 ..4a..<~{*..o..}?..AH..n..@.rW..
0300 58 f8 00 00 00 00 49 45 4e 44 ae 42 60 82 X.....IEND.B`.
'n192' href='#n192'>192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430
/*
Minetest
Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#include "content_mapblock.h"
#include "util/numeric.h"
#include "util/directiontables.h"
#include "mapblock_mesh.h"
#include "settings.h"
#include "nodedef.h"
#include "client/tile.h"
#include "mesh.h"
#include <IMeshManipulator.h>
#include "client/meshgen/collector.h"
#include "client/renderingengine.h"
#include "client.h"
#include "noise.h"

// Distance of light extrapolation (for oversized nodes)
// After this distance, it gives up and considers light level constant
#define SMOOTH_LIGHTING_OVERSIZE 1.0

// Node edge count (for glasslike-framed)
#define FRAMED_EDGE_COUNT 12

// Node neighbor count, including edge-connected, but not vertex-connected
// (for glasslike-framed)
// Corresponding offsets are listed in g_27dirs
#define FRAMED_NEIGHBOR_COUNT 18

static const v3s16 light_dirs[8] = {
	v3s16(-1, -1, -1),
	v3s16(-1, -1,  1),
	v3s16(-1,  1, -1),
	v3s16(-1,  1,  1),
	v3s16( 1, -1, -1),
	v3s16( 1, -1,  1),
	v3s16( 1,  1, -1),
	v3s16( 1,  1,  1),
};

// Standard index set to make a quad on 4 vertices
static constexpr u16 quad_indices[] = {0, 1, 2, 2, 3, 0};

const std::string MapblockMeshGenerator::raillike_groupname = "connect_to_raillike";

MapblockMeshGenerator::MapblockMeshGenerator(MeshMakeData *input, MeshCollector *output)
{
	data      = input;
	collector = output;

	nodedef   = data->m_client->ndef();
	meshmanip = RenderingEngine::get_scene_manager()->getMeshManipulator();

	enable_mesh_cache = g_settings->getBool("enable_mesh_cache") &&
		!data->m_smooth_lighting; // Mesh cache is not supported with smooth lighting

	blockpos_nodes = data->m_blockpos * MAP_BLOCKSIZE;
}

void MapblockMeshGenerator::useTile(int index, u8 set_flags, u8 reset_flags, bool special)
{
	if (special)
		getSpecialTile(index, &tile, p == data->m_crack_pos_relative);
	else
		getTile(index, &tile);
	if (!data->m_smooth_lighting)
		color = encode_light(light, f->light_source);

	for (auto &layer : tile.layers) {
		layer.material_flags |= set_flags;
		layer.material_flags &= ~reset_flags;
	}
}

// Returns a tile, ready for use, non-rotated.
void MapblockMeshGenerator::getTile(int index, TileSpec *tile)
{
	getNodeTileN(n, p, index, data, *tile);
}

// Returns a tile, ready for use, rotated according to the node facedir.
void MapblockMeshGenerator::getTile(v3s16 direction, TileSpec *tile)
{
	getNodeTile(n, p, direction, data, *tile);
}

// Returns a special tile, ready for use, non-rotated.
void MapblockMeshGenerator::getSpecialTile(int index, TileSpec *tile, bool apply_crack)
{
	*tile = f->special_tiles[index];
	TileLayer *top_layer = nullptr;

	for (auto &layernum : tile->layers) {
		TileLayer *layer = &layernum;
		if (layer->texture_id == 0)
			continue;
		top_layer = layer;
		if (!layer->has_color)
			n.getColor(*f, &layer->color);
	}

	if (apply_crack)
		top_layer->material_flags |= MATERIAL_FLAG_CRACK;
}

void MapblockMeshGenerator::drawQuad(v3f *coords, const v3s16 &normal,
	float vertical_tiling)
{
	const v2f tcoords[4] = {v2f(0.0, 0.0), v2f(1.0, 0.0),
		v2f(1.0, vertical_tiling), v2f(0.0, vertical_tiling)};
	video::S3DVertex vertices[4];
	bool shade_face = !f->light_source && (normal != v3s16(0, 0, 0));
	v3f normal2(normal.X, normal.Y, normal.Z);
	for (int j = 0; j < 4; j++) {
		vertices[j].Pos = coords[j] + origin;
		vertices[j].Normal = normal2;
		if (data->m_smooth_lighting)
			vertices[j].Color = blendLightColor(coords[j]);
		else
			vertices[j].Color = color;
		if (shade_face)
			applyFacesShading(vertices[j].Color, normal2);
		vertices[j].TCoords = tcoords[j];
	}
	collector->append(tile, vertices, 4, quad_indices, 6);
}

// Create a cuboid.
//  tiles     - the tiles (materials) to use (for all 6 faces)
//  tilecount - number of entries in tiles, 1<=tilecount<=6
//  lights    - vertex light levels. The order is the same as in light_dirs.
//              NULL may be passed if smooth lighting is disabled.
//  txc       - texture coordinates - this is a list of texture coordinates
//              for the opposite corners of each face - therefore, there
//              should be (2+2)*6=24 values in the list. The order of
//              the faces in the list is up-down-right-left-back-front
//              (compatible with ContentFeatures).
void MapblockMeshGenerator::drawCuboid(const aabb3f &box,
	TileSpec *tiles, int tilecount, const LightInfo *lights, const f32 *txc)
{
	assert(tilecount >= 1 && tilecount <= 6); // pre-condition

	v3f min = box.MinEdge;
	v3f max = box.MaxEdge;

	video::SColor colors[6];
	if (!data->m_smooth_lighting) {
		for (int face = 0; face != 6; ++face) {
			colors[face] = encode_light(light, f->light_source);
		}
		if (!f->light_source) {
			applyFacesShading(colors[0], v3f(0, 1, 0));
			applyFacesShading(colors[1], v3f(0, -1, 0));
			applyFacesShading(colors[2], v3f(1, 0, 0));
			applyFacesShading(colors[3], v3f(-1, 0, 0));
			applyFacesShading(colors[4], v3f(0, 0, 1));
			applyFacesShading(colors[5], v3f(0, 0, -1));
		}
	}

	video::S3DVertex vertices[24] = {
		// top
		video::S3DVertex(min.X, max.Y, max.Z, 0, 1, 0, colors[0], txc[0], txc[1]),
		video::S3DVertex(max.X, max.Y, max.Z, 0, 1, 0, colors[0], txc[2], txc[1]),
		video::S3DVertex(max.X, max.Y, min.Z, 0, 1, 0, colors[0], txc[2], txc[3]),
		video::S3DVertex(min.X, max.Y, min.Z, 0, 1, 0, colors[0], txc[0], txc[3]),
		// bottom
		video::S3DVertex(min.X, min.Y, min.Z, 0, -1, 0, colors[1], txc[4], txc[5]),
		video::S3DVertex(max.X, min.Y, min.Z, 0, -1, 0, colors[1], txc[6], txc[5]),
		video::S3DVertex(max.X, min.Y, max.Z, 0, -1, 0, colors[1], txc[6], txc[7]),
		video::S3DVertex(min.X, min.Y, max.Z, 0, -1, 0, colors[1], txc[4], txc[7]),
		// right
		video::S3DVertex(max.X, max.Y, min.Z, 1, 0, 0, colors[2], txc[ 8], txc[9]),
		video::S3DVertex(max.X, max.Y, max.Z, 1, 0, 0, colors[2], txc[10], txc[9]),
		video::S3DVertex(max.X, min.Y, max.Z, 1, 0, 0, colors[2], txc[10], txc[11]),
		video::S3DVertex(max.X, min.Y, min.Z, 1, 0, 0, colors[2], txc[ 8], txc[11]),
		// left
		video::S3DVertex(min.X, max.Y, max.Z, -1, 0, 0, colors[3], txc[12], txc[13]),
		video::S3DVertex(min.X, max.Y, min.Z, -1, 0, 0, colors[3], txc[14], txc[13]),
		video::S3DVertex(min.X, min.Y, min.Z, -1, 0, 0, colors[3], txc[14], txc[15]),
		video::S3DVertex(min.X, min.Y, max.Z, -1, 0, 0, colors[3], txc[12], txc[15]),
		// back
		video::S3DVertex(max.X, max.Y, max.Z, 0, 0, 1, colors[4], txc[16], txc[17]),
		video::S3DVertex(min.X, max.Y, max.Z, 0, 0, 1, colors[4], txc[18], txc[17]),
		video::S3DVertex(min.X, min.Y, max.Z, 0, 0, 1, colors[4], txc[18], txc[19]),
		video::S3DVertex(max.X, min.Y, max.Z, 0, 0, 1, colors[4], txc[16], txc[19]),
		// front
		video::S3DVertex(min.X, max.Y, min.Z, 0, 0, -1, colors[5], txc[20], txc[21]),
		video::S3DVertex(max.X, max.Y, min.Z, 0, 0, -1, colors[5], txc[22], txc[21]),
		video::S3DVertex(max.X, min.Y, min.Z, 0, 0, -1, colors[5], txc[22], txc[23]),
		video::S3DVertex(min.X, min.Y, min.Z, 0, 0, -1, colors[5], txc[20], txc[23]),
	};

	static const u8 light_indices[24] = {
		3, 7, 6, 2,
		0, 4, 5, 1,
		6, 7, 5, 4,
		3, 2, 0, 1,
		7, 3, 1, 5,
		2, 6, 4, 0
	};

	for (int face = 0; face < 6; face++) {
		int tileindex = MYMIN(face, tilecount - 1);
		const TileSpec &tile = tiles[tileindex];
		for (int j = 0; j < 4; j++) {
			video::S3DVertex &vertex = vertices[face * 4 + j];
			v2f &tcoords = vertex.TCoords;
			switch (tile.rotation) {
			case 0:
				break;
			case 1: // R90
				tcoords.rotateBy(90, irr::core::vector2df(0, 0));
				break;
			case 2: // R180
				tcoords.rotateBy(180, irr::core::vector2df(0, 0));
				break;
			case 3: // R270
				tcoords.rotateBy(270, irr::core::vector2df(0, 0));
				break;
			case 4: // FXR90
				tcoords.X = 1.0 - tcoords.X;
				tcoords.rotateBy(90, irr::core::vector2df(0, 0));
				break;
			case 5: // FXR270
				tcoords.X = 1.0 - tcoords.X;
				tcoords.rotateBy(270, irr::core::vector2df(0, 0));
				break;
			case 6: // FYR90
				tcoords.Y = 1.0 - tcoords.Y;
				tcoords.rotateBy(90, irr::core::vector2df(0, 0));
				break;
			case 7: // FYR270
				tcoords.Y = 1.0 - tcoords.Y;
				tcoords.rotateBy(270, irr::core::vector2df(0, 0));
				break;
			case 8: // FX
				tcoords.X = 1.0 - tcoords.X;
				break;
			case 9: // FY
				tcoords.Y = 1.0 - tcoords.Y;
				break;
			default:
				break;
			}
		}
	}

	if (data->m_smooth_lighting) {
		for (int j = 0; j < 24; ++j) {
			video::S3DVertex &vertex = vertices[j];
			vertex.Color = encode_light(
				lights[light_indices[j]].getPair(MYMAX(0.0f, vertex.Normal.Y)),
				f->light_source);
			if (!f->light_source)
				applyFacesShading(vertex.Color, vertex.Normal);
		}
	}

	// Add to mesh collector
	for (int k = 0; k < 6; ++k) {
		int tileindex = MYMIN(k, tilecount - 1);
		collector->append(tiles[tileindex], vertices + 4 * k, 4, quad_indices, 6);
	}
}

// Gets the base lighting values for a node
void MapblockMeshGenerator::getSmoothLightFrame()
{
	for (int k = 0; k < 8; ++k)
		frame.sunlight[k] = false;
	for (int k = 0; k < 8; ++k) {
		LightPair light(getSmoothLightTransparent(blockpos_nodes + p, light_dirs[k], data));
		frame.lightsDay[k] = light.lightDay;
		frame.lightsNight[k] = light.lightNight;
		// If there is direct sunlight and no ambient occlusion at some corner,
		// mark the vertical edge (top and bottom corners) containing it.
		if (light.lightDay == 255) {
			frame.sunlight[k] = true;
			frame.sunlight[k ^ 2] = true;
		}
	}
}

// Calculates vertex light level
//  vertex_pos - vertex position in the node (coordinates are clamped to [0.0, 1.0] or so)
LightInfo MapblockMeshGenerator::blendLight(const v3f &vertex_pos)
{
	// Light levels at (logical) node corners are known. Here,