formatting changes in voxel generation shader
This commit is contained in:
parent
0074bf1d1f
commit
95a27cfd50
2 changed files with 40 additions and 26 deletions
|
|
@ -101,22 +101,24 @@ bool isCave(vec3 worldPos) {
|
||||||
void main() {
|
void main() {
|
||||||
ivec3 localPos = ivec3(gl_GlobalInvocationID.xyz);
|
ivec3 localPos = ivec3(gl_GlobalInvocationID.xyz);
|
||||||
ivec3 worldPos = chunkPos * CHUNK_SIZE + localPos;
|
ivec3 worldPos = chunkPos * CHUNK_SIZE + localPos;
|
||||||
float YZone = floor(worldPos.y/150.0)*150.0;
|
|
||||||
float islandheight = valueNoise(vec2(worldPos.x + YZone * 2, worldPos.z + YZone * 2) * 0.005) * 100 + valueNoise(vec2(worldPos.x + YZone * 2, worldPos.z + YZone * 2) * 0.1) * 20 + valueNoise(vec2(worldPos.x + YZone * 2, worldPos.z + YZone * 2) * 0.1) * 5+ valueNoise(vec2(worldPos.x + YZone * 2, worldPos.z + YZone * 2)) * 0.5 - 15 + YZone;
|
|
||||||
float height = valueNoise(vec2(worldPos.x + YZone * 2, worldPos.z + YZone * 2) * 0.005) * 100 + valueNoise(vec2(worldPos.x + YZone * 2, worldPos.z + YZone * 2) * 0.01) * 10 + valueNoise(vec2(worldPos.x + YZone * 2, worldPos.z + YZone * 2) * 0.1) * 5+ valueNoise(vec2(worldPos.x + YZone * 2, worldPos.z + YZone * 2)) * 0.5 + YZone;
|
|
||||||
|
|
||||||
float YZone2 = floor(worldPos.y/75.0)*75.0;
|
float YZone = floor(worldPos.y/150.0)*150.0;
|
||||||
float islandheight2 = valueNoise(vec2(worldPos.x - YZone2 * 2, worldPos.z -YZone2 * 2) * 0.005) * 60 + valueNoise(vec2(worldPos.x + YZone2 * 2, worldPos.z + YZone2 * 2) * 0.1) * 20 + valueNoise(vec2(worldPos.x + YZone2 * 2, worldPos.z + YZone2 * 2) * 0.1) * 10+ valueNoise(vec2(worldPos.x + YZone2 * 2, worldPos.z + YZone2 * 2)) * 0.5 - 5 + YZone2;
|
float SurfaceHeight = valueNoise(vec2(worldPos.x + YZone * 2, worldPos.z + YZone * 2) * 0.005) * 100 +
|
||||||
float height2 = valueNoise(vec2(worldPos.x + YZone2 * 2, worldPos.z + YZone2 * 2) * 0.005) * 50 + valueNoise(vec2(worldPos.x + YZone2 * 2, worldPos.z + YZone2 * 2) * 0.01) * 10 + valueNoise(vec2(worldPos.x + YZone2 * 2, worldPos.z + YZone2 * 2) * 0.1) * 5+ valueNoise(vec2(worldPos.x + YZone2 * 2, worldPos.z + YZone2 * 2)) * 0.5 + YZone2;
|
valueNoise(vec2(worldPos.x + YZone * 2, worldPos.z + YZone * 2) * 0.01) * 10 +
|
||||||
|
valueNoise(vec2(worldPos.x + YZone * 2, worldPos.z + YZone * 2) * 0.1) * 5 +
|
||||||
|
valueNoise(vec2(worldPos.x + YZone * 2, worldPos.z + YZone * 2)) * 0.5 + YZone;
|
||||||
|
|
||||||
|
float IslandUnderneathHeight = valueNoise(vec2(worldPos.x + YZone * 2, worldPos.z + YZone * 2) * 0.005) * 100 +
|
||||||
|
valueNoise(vec2(worldPos.x + YZone * 2, worldPos.z + YZone * 2) * 0.1) * 20 +
|
||||||
|
valueNoise(vec2(worldPos.x + YZone * 2, worldPos.z + YZone * 2) * 0.1) * 5 +
|
||||||
|
valueNoise(vec2(worldPos.x + YZone * 2, worldPos.z + YZone * 2)) * 0.5 - 15 + YZone;
|
||||||
|
|
||||||
float grassNoise = valueNoise(vec2(worldPos.z + YZone * 2, worldPos.x + YZone * 2));
|
float grassNoise = valueNoise(vec2(worldPos.z + YZone * 2, worldPos.x + YZone * 2));
|
||||||
|
|
||||||
//float height2 = valueNoise(vec2(-worldPos.x, -worldPos.z) * 0.005) * 100 + valueNoise(vec2(-worldPos.x, -worldPos.z) * 0.01) * 10 + valueNoise(vec2(-worldPos.x, -worldPos.z) * 0.1) * 5+ valueNoise(vec2(-worldPos.x, -worldPos.z)) * 0.5 + 100;
|
|
||||||
//float islandheight2 = 100 + valueNoise(vec2(-worldPos.z, -worldPos.x) * 0.005) * 100 + valueNoise(vec2(-worldPos.x, -worldPos.z) * 0.1) * 20 + valueNoise(vec2(worldPos.x, worldPos.z) * 0.1) * 5+ valueNoise(vec2(worldPos.x, worldPos.z)) * 0.5 - 5;
|
|
||||||
//height = clamp(height, 4.0, 28.0);
|
|
||||||
uint voxelType = 0u;
|
uint voxelType = 0u;
|
||||||
|
|
||||||
if (float(worldPos.y) <= height && float(worldPos.y) >= islandheight) {
|
if (float(worldPos.y) <= SurfaceHeight && float(worldPos.y) >= IslandUnderneathHeight) {
|
||||||
float depthBelowSurface = height - float(worldPos.y);
|
float depthBelowSurface = SurfaceHeight - float(worldPos.y);
|
||||||
if (depthBelowSurface < 0.5) {
|
if (depthBelowSurface < 0.5) {
|
||||||
if(grassNoise < 0.65) voxelType = 4u; // Grass foliage
|
if(grassNoise < 0.65) voxelType = 4u; // Grass foliage
|
||||||
else voxelType = 0u;
|
else voxelType = 0u;
|
||||||
|
|
@ -128,13 +130,24 @@ void main() {
|
||||||
voxelType = 3u; // Stone
|
voxelType = 3u; // Stone
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (float(worldPos.y) <= height2 && float(worldPos.y) >= islandheight2) {
|
else{
|
||||||
|
float YZone2 = floor(worldPos.y/75.0)*75.0;
|
||||||
|
float IslandUnderneathHeight2 = valueNoise(vec2(worldPos.x - YZone2 * 2, worldPos.z -YZone2 * 2) * 0.005) * 60 +
|
||||||
|
valueNoise(vec2(worldPos.x + YZone2 * 2, worldPos.z + YZone2 * 2) * 0.1) * 20 +
|
||||||
|
valueNoise(vec2(worldPos.x + YZone2 * 2, worldPos.z + YZone2 * 2) * 0.1) * 10+
|
||||||
|
valueNoise(vec2(worldPos.x + YZone2 * 2, worldPos.z + YZone2 * 2)) * 0.5 - 5 + YZone2;
|
||||||
|
float height2 = valueNoise(vec2(worldPos.x + YZone2 * 2, worldPos.z + YZone2 * 2) * 0.005) * 50 +
|
||||||
|
valueNoise(vec2(worldPos.x + YZone2 * 2, worldPos.z + YZone2 * 2) * 0.01) * 10 +
|
||||||
|
valueNoise(vec2(worldPos.x + YZone2 * 2, worldPos.z + YZone2 * 2) * 0.1) * 5+
|
||||||
|
valueNoise(vec2(worldPos.x + YZone2 * 2, worldPos.z + YZone2 * 2)) * 0.5 + YZone2;
|
||||||
|
|
||||||
|
if (float(worldPos.y) <= height2 && float(worldPos.y) >= IslandUnderneathHeight2) {
|
||||||
float depthBelowSurface = height2 - float(worldPos.y);
|
float depthBelowSurface = height2 - float(worldPos.y);
|
||||||
|
|
||||||
if (depthBelowSurface < 0.5) {
|
if (depthBelowSurface < 0.5) {
|
||||||
if(grassNoise < 0.65) voxelType = 4u; // Grass foliage
|
if (grassNoise < 0.65) voxelType = 4u; // Grass foliage
|
||||||
else voxelType = 0u;
|
else voxelType = 0u;
|
||||||
}else if (depthBelowSurface < 1.5) {
|
} else if (depthBelowSurface < 1.5) {
|
||||||
voxelType = 1u; // Grass
|
voxelType = 1u; // Grass
|
||||||
} else if (depthBelowSurface < 6.0) {
|
} else if (depthBelowSurface < 6.0) {
|
||||||
voxelType = 2u; // Dirt(also stone rn)
|
voxelType = 2u; // Dirt(also stone rn)
|
||||||
|
|
@ -142,6 +155,7 @@ void main() {
|
||||||
voxelType = 3u; // Stone
|
voxelType = 3u; // Stone
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (voxelType != 0u) {
|
if (voxelType != 0u) {
|
||||||
if (isCave(vec3(worldPos*0.05))) {
|
if (isCave(vec3(worldPos*0.05))) {
|
||||||
|
|
|
||||||
|
|
@ -681,11 +681,11 @@ public class GameCore implements GameLogic {
|
||||||
Vector3f CamRot = cam.GetRotation();
|
Vector3f CamRot = cam.GetRotation();
|
||||||
Vector3i ChunkPos = new Vector3i((int)Math.floor(CamPos.x/ (float) VoxelChunkGenerator.CHUNK_SIZE),(int)Math.floor(CamPos.y/ (float)VoxelChunkGenerator.CHUNK_SIZE),(int)Math.floor(CamPos.z/ (float)VoxelChunkGenerator.CHUNK_SIZE));
|
Vector3i ChunkPos = new Vector3i((int)Math.floor(CamPos.x/ (float) VoxelChunkGenerator.CHUNK_SIZE),(int)Math.floor(CamPos.y/ (float)VoxelChunkGenerator.CHUNK_SIZE),(int)Math.floor(CamPos.z/ (float)VoxelChunkGenerator.CHUNK_SIZE));
|
||||||
if(ChunkPos.x != VoxelWorldManager.LastPosition.x || ChunkPos.y != VoxelWorldManager.LastPosition.y || ChunkPos.z != VoxelWorldManager.LastPosition.z || CamRot.x != LastCamRotation.x || CamRot.y != LastCamRotation.y || CamRot.z != LastCamRotation.z) {
|
if(ChunkPos.x != VoxelWorldManager.LastPosition.x || ChunkPos.y != VoxelWorldManager.LastPosition.y || ChunkPos.z != VoxelWorldManager.LastPosition.z || CamRot.x != LastCamRotation.x || CamRot.y != LastCamRotation.y || CamRot.z != LastCamRotation.z) {
|
||||||
VoxelWorldManager.UnloadFarChunks(ChunkPos, 20,cam.GetViewMatrix(),projection.GetProjectionMatrix());
|
VoxelWorldManager.UnloadFarChunks(ChunkPos, 12,cam.GetViewMatrix(),projection.GetProjectionMatrix());
|
||||||
VoxelWorldManager.GenerateChunks(ChunkPos, new Vector3i(20,8,20),cam.GetViewMatrix(),projection.GetProjectionMatrix());
|
VoxelWorldManager.GenerateChunks(ChunkPos, new Vector3i(12,8,12),cam.GetViewMatrix(),projection.GetProjectionMatrix());
|
||||||
} else {
|
} else {
|
||||||
VoxelWorldManager.UnloadFarChunks(ChunkPos, 64,cam.GetViewMatrix(),projection.GetProjectionMatrix());
|
VoxelWorldManager.UnloadFarChunks(ChunkPos, 24,cam.GetViewMatrix(),projection.GetProjectionMatrix());
|
||||||
VoxelWorldManager.GenerateChunks(ChunkPos, new Vector3i(32,12,32),cam.GetViewMatrix(),projection.GetProjectionMatrix());
|
VoxelWorldManager.GenerateChunks(ChunkPos, new Vector3i(24,12,24),cam.GetViewMatrix(),projection.GetProjectionMatrix());
|
||||||
}
|
}
|
||||||
LastCamRotation.set(CamRot);
|
LastCamRotation.set(CamRot);
|
||||||
if(PrimaryRuntime.IsServer){
|
if(PrimaryRuntime.IsServer){
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue