Added a basic skylight engine. Currently it's really laggy.
Also tried fixing the autobuild action since it fetches the repo without submodules.
This commit is contained in:
+18
-16
@@ -10,7 +10,7 @@
|
||||
#ifndef SERVER
|
||||
#ifndef LEGACY_GL
|
||||
|
||||
MeshData GenerateChunkMesh(ChunkRenderData chunkRenderData, Chunk chunk, int chunkWorldX, int chunkWorldY, uint8_t sideMask)
|
||||
MeshData GenerateChunkMesh(World &world, ChunkRenderData chunkRenderData, Chunk chunk, int chunkWorldX, int chunkWorldY, uint8_t sideMask)
|
||||
{
|
||||
MeshData out = {0};
|
||||
|
||||
@@ -31,6 +31,10 @@ MeshData GenerateChunkMesh(ChunkRenderData chunkRenderData, Chunk chunk, int chu
|
||||
uint8_t crdata = chunkRenderData.sides[index];
|
||||
if (crdata == 0) continue;
|
||||
|
||||
int wx = (chunkWorldX * CHUNK_SIZE + x);
|
||||
int wy = (y);
|
||||
int wz = (chunkWorldY * CHUNK_SIZE + z);
|
||||
|
||||
int this_block = fetch_block(chunk, x,y,z);
|
||||
|
||||
BlockDef definition = BLOCKS[this_block];
|
||||
@@ -45,10 +49,7 @@ MeshData GenerateChunkMesh(ChunkRenderData chunkRenderData, Chunk chunk, int chu
|
||||
bool shaded = chunk.highestBlock[GetIndexChunk2D(x, z)] != y;
|
||||
Color color = {255, 255, 255, 255};
|
||||
Color colorShaded = {128, 128, 172, 255};
|
||||
|
||||
float wx = (float)(chunkWorldX * CHUNK_SIZE + x);
|
||||
float wy = (float)(y);
|
||||
float wz = (float)(chunkWorldY * CHUNK_SIZE + z);
|
||||
|
||||
/*if(GetCloud(wx, wz)) {
|
||||
color = ColorLerp(color, colorShaded, 0.5f);
|
||||
}*/
|
||||
@@ -72,7 +73,8 @@ MeshData GenerateChunkMesh(ChunkRenderData chunkRenderData, Chunk chunk, int chu
|
||||
positions.push_back(verts[3]);
|
||||
|
||||
normals.push_back(normal);
|
||||
colors.push_back(colorShaded);
|
||||
Color clr = GetLight(world, wx-1, wy, wz);
|
||||
colors.push_back(clr);
|
||||
|
||||
uvs.push_back(corners[0]);
|
||||
uvs.push_back(corners[1]);
|
||||
@@ -111,7 +113,8 @@ MeshData GenerateChunkMesh(ChunkRenderData chunkRenderData, Chunk chunk, int chu
|
||||
positions.push_back(verts[3]);
|
||||
|
||||
normals.push_back(normal);
|
||||
colors.push_back(colorShaded);
|
||||
Color clr = GetLight(world, wx+1, wy, wz);
|
||||
colors.push_back(clr);
|
||||
|
||||
uvs.push_back(corners[0]);
|
||||
uvs.push_back(corners[1]);
|
||||
@@ -150,7 +153,8 @@ MeshData GenerateChunkMesh(ChunkRenderData chunkRenderData, Chunk chunk, int chu
|
||||
positions.push_back(verts[3]);
|
||||
|
||||
normals.push_back(normal);
|
||||
colors.push_back(colorShaded);
|
||||
Color clr = GetLight(world, wx, wy-1, wz);
|
||||
colors.push_back(clr);
|
||||
|
||||
uvs.push_back(corners[0]);
|
||||
uvs.push_back(corners[1]);
|
||||
@@ -189,12 +193,8 @@ MeshData GenerateChunkMesh(ChunkRenderData chunkRenderData, Chunk chunk, int chu
|
||||
positions.push_back(verts[3]);
|
||||
|
||||
normals.push_back(normal);
|
||||
if(shaded) {
|
||||
colors.push_back(colorShaded);
|
||||
}
|
||||
else {
|
||||
colors.push_back(color);
|
||||
}
|
||||
Color clr = GetLight(world, wx, wy+1, wz);
|
||||
colors.push_back(clr);
|
||||
|
||||
uvs.push_back(corners[0]);
|
||||
uvs.push_back(corners[1]);
|
||||
@@ -233,7 +233,8 @@ MeshData GenerateChunkMesh(ChunkRenderData chunkRenderData, Chunk chunk, int chu
|
||||
positions.push_back(verts[3]);
|
||||
|
||||
normals.push_back(normal);
|
||||
colors.push_back(colorShaded);
|
||||
Color clr = GetLight(world, wx, wy, wz+1);
|
||||
colors.push_back(clr);
|
||||
|
||||
uvs.push_back(corners[0]);
|
||||
uvs.push_back(corners[1]);
|
||||
@@ -272,7 +273,8 @@ MeshData GenerateChunkMesh(ChunkRenderData chunkRenderData, Chunk chunk, int chu
|
||||
positions.push_back(verts[3]);
|
||||
|
||||
normals.push_back(normal);
|
||||
colors.push_back(colorShaded);
|
||||
Color clr = GetLight(world, wx, wy, wz-1);
|
||||
colors.push_back(clr);
|
||||
|
||||
uvs.push_back(corners[0]);
|
||||
uvs.push_back(corners[1]);
|
||||
|
||||
Reference in New Issue
Block a user