smooth fluid voxel animation
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
This commit is contained in:
parent
db8ad7d10a
commit
077cffa2e2
@ -303,3 +303,6 @@ Constant Thunderstorms and lots of lightning strikes
|
|||||||
## Sky Reefs
|
## Sky Reefs
|
||||||
Full of kelp dangling from island, lots of sea-themed flying creatures
|
Full of kelp dangling from island, lots of sea-themed flying creatures
|
||||||
|
|
||||||
|
## Ghost Water in the Sky
|
||||||
|
Idk what this means but I just came up with it and it sounds cool
|
||||||
|
|
||||||
|
|||||||
@ -37,6 +37,9 @@ public class FluidCell {
|
|||||||
static Texture groundTextureTwo = new Texture("/Textures/Ground/Dirt1.png");
|
static Texture groundTextureTwo = new Texture("/Textures/Ground/Dirt1.png");
|
||||||
static Texture groundTextureThree = new Texture("/Textures/Ground/Dirt1.png");
|
static Texture groundTextureThree = new Texture("/Textures/Ground/Dirt1.png");
|
||||||
static Texture groundTextureFour = new Texture("/Textures/Ground/Dirt1.png");
|
static Texture groundTextureFour = new Texture("/Textures/Ground/Dirt1.png");
|
||||||
|
|
||||||
|
//the value of an empty fluid cell weight that is not neighbored by a fluid value
|
||||||
|
public static final float ISO_SURFACE_EMPTY = -1;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// groundTextureOne = new Texture("/Textures/Ground/GrassTileable.png");
|
// groundTextureOne = new Texture("/Textures/Ground/GrassTileable.png");
|
||||||
@ -137,14 +140,14 @@ public class FluidCell {
|
|||||||
} else {
|
} else {
|
||||||
for(int i = 0; i < ServerTerrainChunk.CHUNK_DIMENSION; i++){
|
for(int i = 0; i < ServerTerrainChunk.CHUNK_DIMENSION; i++){
|
||||||
for(int j = 0; j < ServerTerrainChunk.CHUNK_DIMENSION; j++){
|
for(int j = 0; j < ServerTerrainChunk.CHUNK_DIMENSION; j++){
|
||||||
weights[ServerTerrainChunk.CHUNK_DIMENSION][i][j] = -1;
|
weights[ServerTerrainChunk.CHUNK_DIMENSION][i][j] = ISO_SURFACE_EMPTY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for(int i = 0; i < ServerTerrainChunk.CHUNK_DIMENSION; i++){
|
for(int i = 0; i < ServerTerrainChunk.CHUNK_DIMENSION; i++){
|
||||||
for(int j = 0; j < ServerTerrainChunk.CHUNK_DIMENSION; j++){
|
for(int j = 0; j < ServerTerrainChunk.CHUNK_DIMENSION; j++){
|
||||||
weights[ServerTerrainChunk.CHUNK_DIMENSION][i][j] = -1;
|
weights[ServerTerrainChunk.CHUNK_DIMENSION][i][j] = ISO_SURFACE_EMPTY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -160,14 +163,14 @@ public class FluidCell {
|
|||||||
} else {
|
} else {
|
||||||
for(int i = 0; i < ServerTerrainChunk.CHUNK_DIMENSION; i++){
|
for(int i = 0; i < ServerTerrainChunk.CHUNK_DIMENSION; i++){
|
||||||
for(int j = 0; j < ServerTerrainChunk.CHUNK_DIMENSION; j++){
|
for(int j = 0; j < ServerTerrainChunk.CHUNK_DIMENSION; j++){
|
||||||
weights[i][ServerTerrainChunk.CHUNK_DIMENSION][j] = -1;
|
weights[i][ServerTerrainChunk.CHUNK_DIMENSION][j] = ISO_SURFACE_EMPTY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for(int i = 0; i < ServerTerrainChunk.CHUNK_DIMENSION; i++){
|
for(int i = 0; i < ServerTerrainChunk.CHUNK_DIMENSION; i++){
|
||||||
for(int j = 0; j < ServerTerrainChunk.CHUNK_DIMENSION; j++){
|
for(int j = 0; j < ServerTerrainChunk.CHUNK_DIMENSION; j++){
|
||||||
weights[i][ServerTerrainChunk.CHUNK_DIMENSION][j] = -1;
|
weights[i][ServerTerrainChunk.CHUNK_DIMENSION][j] = ISO_SURFACE_EMPTY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -183,14 +186,14 @@ public class FluidCell {
|
|||||||
} else {
|
} else {
|
||||||
for(int i = 0; i < ServerTerrainChunk.CHUNK_DIMENSION; i++){
|
for(int i = 0; i < ServerTerrainChunk.CHUNK_DIMENSION; i++){
|
||||||
for(int j = 0; j < ServerTerrainChunk.CHUNK_DIMENSION; j++){
|
for(int j = 0; j < ServerTerrainChunk.CHUNK_DIMENSION; j++){
|
||||||
weights[i][j][ServerTerrainChunk.CHUNK_DIMENSION] = -1;
|
weights[i][j][ServerTerrainChunk.CHUNK_DIMENSION] = ISO_SURFACE_EMPTY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for(int i = 0; i < ServerTerrainChunk.CHUNK_DIMENSION; i++){
|
for(int i = 0; i < ServerTerrainChunk.CHUNK_DIMENSION; i++){
|
||||||
for(int j = 0; j < ServerTerrainChunk.CHUNK_DIMENSION; j++){
|
for(int j = 0; j < ServerTerrainChunk.CHUNK_DIMENSION; j++){
|
||||||
weights[i][j][ServerTerrainChunk.CHUNK_DIMENSION] = -1;
|
weights[i][j][ServerTerrainChunk.CHUNK_DIMENSION] = ISO_SURFACE_EMPTY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -206,12 +209,12 @@ public class FluidCell {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for(int i = 0; i < ServerTerrainChunk.CHUNK_DIMENSION; i++){
|
for(int i = 0; i < ServerTerrainChunk.CHUNK_DIMENSION; i++){
|
||||||
weights[ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION][i] = -1;
|
weights[ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION][i] = ISO_SURFACE_EMPTY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for(int i = 0; i < ServerTerrainChunk.CHUNK_DIMENSION; i++){
|
for(int i = 0; i < ServerTerrainChunk.CHUNK_DIMENSION; i++){
|
||||||
weights[ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION][i] = -1;
|
weights[ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION][i] = ISO_SURFACE_EMPTY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//edge X-Z
|
//edge X-Z
|
||||||
@ -226,12 +229,12 @@ public class FluidCell {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for(int i = 0; i < ServerTerrainChunk.CHUNK_DIMENSION; i++){
|
for(int i = 0; i < ServerTerrainChunk.CHUNK_DIMENSION; i++){
|
||||||
weights[ServerTerrainChunk.CHUNK_DIMENSION][i][ServerTerrainChunk.CHUNK_DIMENSION] = -1;
|
weights[ServerTerrainChunk.CHUNK_DIMENSION][i][ServerTerrainChunk.CHUNK_DIMENSION] = ISO_SURFACE_EMPTY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for(int i = 0; i < ServerTerrainChunk.CHUNK_DIMENSION; i++){
|
for(int i = 0; i < ServerTerrainChunk.CHUNK_DIMENSION; i++){
|
||||||
weights[ServerTerrainChunk.CHUNK_DIMENSION][i][ServerTerrainChunk.CHUNK_DIMENSION] = -1;
|
weights[ServerTerrainChunk.CHUNK_DIMENSION][i][ServerTerrainChunk.CHUNK_DIMENSION] = ISO_SURFACE_EMPTY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//edge Y-Z
|
//edge Y-Z
|
||||||
@ -246,12 +249,12 @@ public class FluidCell {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for(int i = 0; i < ServerTerrainChunk.CHUNK_DIMENSION; i++){
|
for(int i = 0; i < ServerTerrainChunk.CHUNK_DIMENSION; i++){
|
||||||
weights[i][ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION] = -1;
|
weights[i][ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION] = ISO_SURFACE_EMPTY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for(int i = 0; i < ServerTerrainChunk.CHUNK_DIMENSION; i++){
|
for(int i = 0; i < ServerTerrainChunk.CHUNK_DIMENSION; i++){
|
||||||
weights[i][ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION] = -1;
|
weights[i][ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION] = ISO_SURFACE_EMPTY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(
|
if(
|
||||||
@ -263,10 +266,39 @@ public class FluidCell {
|
|||||||
if(currentChunk != null){
|
if(currentChunk != null){
|
||||||
weights[ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION] = currentChunk.getWeight(0, 0, 0);
|
weights[ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION] = currentChunk.getWeight(0, 0, 0);
|
||||||
} else {
|
} else {
|
||||||
weights[ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION] = -1;
|
weights[ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION] = ISO_SURFACE_EMPTY;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
weights[ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION] = -1;
|
weights[ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION] = ISO_SURFACE_EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
//now set neighboring air weights based on nearby fluid count
|
||||||
|
//idea being that we dont have the snapping behavior from iso surface jumping from -1->0.01
|
||||||
|
int[] neighborIndexX = new int[]{-1,1,0,0,0,0};
|
||||||
|
int[] neighborIndexY = new int[]{0,0,-1,1,0,0};
|
||||||
|
int[] neighborIndexZ = new int[]{0,0,0,0,-1,1};
|
||||||
|
for(int x = 0; x < ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE; x++){
|
||||||
|
for(int y = 0; y < ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE; y++){
|
||||||
|
for(int z = 0; z < ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE; z++){
|
||||||
|
if(weights[x][y][z] > 0){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for(int i = 0; i < 6; i++){
|
||||||
|
int currX = x + neighborIndexX[i];
|
||||||
|
int currY = y + neighborIndexY[i];
|
||||||
|
int currZ = z + neighborIndexZ[i];
|
||||||
|
if(
|
||||||
|
currX >= 0 && currX < ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE &&
|
||||||
|
currY >= 0 && currY < ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE &&
|
||||||
|
currZ >= 0 && currZ < ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE &&
|
||||||
|
(1 + weights[x][y][z]) < weights[currX][currY][currZ]
|
||||||
|
){
|
||||||
|
System.out.println("set neighbor weight");
|
||||||
|
weights[x][y][z] = -(1 - weights[currX][currY][currZ]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -12,6 +12,7 @@ import org.joml.Vector3i;
|
|||||||
|
|
||||||
import electrosphere.client.fluid.cache.ClientFluidCache;
|
import electrosphere.client.fluid.cache.ClientFluidCache;
|
||||||
import electrosphere.client.fluid.cache.FluidChunkData;
|
import electrosphere.client.fluid.cache.FluidChunkData;
|
||||||
|
import electrosphere.client.fluid.cells.FluidCell;
|
||||||
import electrosphere.client.scene.ClientWorldData;
|
import electrosphere.client.scene.ClientWorldData;
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.entity.types.fluid.FluidChunkModelData;
|
import electrosphere.entity.types.fluid.FluidChunkModelData;
|
||||||
@ -166,7 +167,7 @@ public class ClientFluidManager {
|
|||||||
for(int z = 0; z < FluidChunkData.CHUNK_SIZE; z++){
|
for(int z = 0; z < FluidChunkData.CHUNK_SIZE; z++){
|
||||||
weights[x][y][z] = floatBuffer.get();
|
weights[x][y][z] = floatBuffer.get();
|
||||||
if(weights[x][y][z] <= 0){
|
if(weights[x][y][z] <= 0){
|
||||||
weights[x][y][z] = -1f;
|
weights[x][y][z] = FluidCell.ISO_SURFACE_EMPTY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -602,7 +602,7 @@ public class FluidChunkModelGeneration {
|
|||||||
weightGrid[x+0][y+1][z+0], weightGrid[x+0][y+1][z+1], weightGrid[x+1][y+1][z+1], weightGrid[x+1][y+1][z+0]
|
weightGrid[x+0][y+1][z+0], weightGrid[x+0][y+1][z+1], weightGrid[x+1][y+1][z+1], weightGrid[x+1][y+1][z+0]
|
||||||
);
|
);
|
||||||
//polygonize the current gridcell
|
//polygonize the current gridcell
|
||||||
polygonize(currentCell, 0.0f, triangles, vertMap, verts, normals, trianglesSharingVert);
|
polygonize(currentCell, 0.01f, triangles, vertMap, verts, normals, trianglesSharingVert);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user