1 /**
2 Copyright: Copyright (c) 2017-2018 Andrey Penechko.
3 License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
4 Authors: Andrey Penechko.
5 */
6 
7 module voxelman.world.mesh.sidemeshers.full;
8 
9 import voxelman.container.buffer;
10 import voxelman.math;
11 import voxelman.geometry;
12 
13 import voxelman.world.block;
14 import voxelman.world.mesh.chunkmesh;
15 
16 import voxelman.world.mesh.sidemeshers.utils;
17 
18 void meshFullSideOccluded(CubeSide side, ubyte[4] cornerOcclusion, SideParams d)
19 {
20 	immutable float mult = shadowMultipliers[side];
21 	float[3] color = [mult * d.color.r, mult * d.color.g, mult * d.color.b];
22 
23 	meshOccludedQuad(*d.buffer, cornerOcclusion, color, d.uv, d.blockPos,
24 		cubeSideVertIndices[side], cubeVerticies.ptr);
25 }
26 /*
27 void meshFullSideOccluded2(CubeSide side, ubyte[4] cornerOcclusion, SideParams d)
28 {
29 	immutable float mult = shadowMultipliers[side];
30 
31 	// apply fake lighting
32 	float r = mult * d.color.r;
33 	float g = mult * d.color.g;
34 	float b = mult * d.color.b;
35 
36 	// Ambient occlusion multipliers
37 	float vert0AoMult = occlusionTable[cornerOcclusion[0]];
38 	float vert1AoMult = occlusionTable[cornerOcclusion[1]];
39 	float vert2AoMult = occlusionTable[cornerOcclusion[2]];
40 	float vert3AoMult = occlusionTable[cornerOcclusion[3]];
41 
42 	immutable ubyte[3][4] finalColors = [
43 		[cast(ubyte)(vert0AoMult * r), cast(ubyte)(vert0AoMult * g), cast(ubyte)(vert0AoMult * b)],
44 		[cast(ubyte)(vert1AoMult * r), cast(ubyte)(vert1AoMult * g), cast(ubyte)(vert1AoMult * b)],
45 		[cast(ubyte)(vert2AoMult * r), cast(ubyte)(vert2AoMult * g), cast(ubyte)(vert2AoMult * b)],
46 		[cast(ubyte)(vert3AoMult * r), cast(ubyte)(vert3AoMult * g), cast(ubyte)(vert3AoMult * b)]];
47 
48 	const(ubyte)[] faces;
49 	const(ubyte)[] faceIndexes;
50 
51 	if(vert0AoMult + vert2AoMult > vert1AoMult + vert3AoMult)
52 	{
53 		faces = flippedCubeFaces[];
54 		faceIndexes = flippedFaceCornerIndexes[];
55 	}
56 	else
57 	{
58 		faces = cubeFaces[];
59 		faceIndexes = faceCornerIndexes[];
60 	}
61 
62 	d.buffer.put(
63 		MeshVertex(
64 			faces[18*side  ] + d.blockPos.x,
65 			faces[18*side+1] + d.blockPos.y,
66 			faces[18*side+2] + d.blockPos.z,
67 			finalColors[faceIndexes[0]]),
68 		MeshVertex(
69 			faces[18*side+3] + d.blockPos.x,
70 			faces[18*side+4] + d.blockPos.y,
71 			faces[18*side+5] + d.blockPos.z,
72 			finalColors[faceIndexes[1]]),
73 		MeshVertex(
74 			faces[18*side+6] + d.blockPos.x,
75 			faces[18*side+7] + d.blockPos.y,
76 			faces[18*side+8] + d.blockPos.z,
77 			finalColors[faceIndexes[2]]),
78 		MeshVertex(
79 			faces[18*side+9] + d.blockPos.x,
80 			faces[18*side+10] + d.blockPos.y,
81 			faces[18*side+11] + d.blockPos.z,
82 			finalColors[faceIndexes[3]]),
83 		MeshVertex(
84 			faces[18*side+12] + d.blockPos.x,
85 			faces[18*side+13] + d.blockPos.y,
86 			faces[18*side+14] + d.blockPos.z,
87 			finalColors[faceIndexes[4]]),
88 		MeshVertex(
89 			faces[18*side+15] + d.blockPos.x,
90 			faces[18*side+16] + d.blockPos.y,
91 			faces[18*side+17] + d.blockPos.z,
92 			finalColors[faceIndexes[5]])
93 	);
94 }
95 */