voxel fixes
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2024-11-04 22:28:59 -05:00
parent d2ccf3c479
commit c02959efee
5 changed files with 35 additions and 12 deletions

View File

@ -931,6 +931,13 @@ Refactoring generator code
Optimizations
Fix transvoxel xnzn edge generation
(11/04/2024)
Major draw cell optimizations
Fix normals calculation in transvoxel rasterizer
Fix draw cell LOD joining bug
Fix draw cell bounding sphere calculation
Hill Gen tweaks
# TODO

View File

@ -28,12 +28,12 @@ public class ClientDrawCellManager {
/**
* The distance to draw at full resolution
*/
public static final double FULL_RES_DIST = 5 * ServerTerrainChunk.CHUNK_DIMENSION;
public static final double FULL_RES_DIST = 12 * ServerTerrainChunk.CHUNK_DIMENSION;
/**
* The distance for half resolution
*/
public static final double HALF_RES_DIST = 15 * ServerTerrainChunk.CHUNK_DIMENSION;
public static final double HALF_RES_DIST = 16 * ServerTerrainChunk.CHUNK_DIMENSION;
/**
* The octree holding all the chunks to evaluate
@ -355,7 +355,7 @@ public class ClientDrawCellManager {
!node.isLeaf() &&
(
(
node.getLevel() == this.chunkTree.getMaxLevel() &&
node.getLevel() == this.chunkTree.getMaxLevel() - 1 &&
this.getMinDistance(pos, node) > FULL_RES_DIST
)
||

View File

@ -892,13 +892,15 @@ public class TerrainChunkModelGeneration {
//bounding sphere logic
float halfChunk = ServerTerrainChunk.CHUNK_DIMENSION / 2.0f;
mesh.updateBoundingSphere(
halfChunk,
halfChunk,
halfChunk,
(float)Math.sqrt(halfChunk * halfChunk + halfChunk * halfChunk + halfChunk * halfChunk)
);
ServerTerrainChunk.CHUNK_DIMENSION,
ServerTerrainChunk.CHUNK_DIMENSION,
ServerTerrainChunk.CHUNK_DIMENSION,
(float)Math.sqrt(
ServerTerrainChunk.CHUNK_DIMENSION * ServerTerrainChunk.CHUNK_DIMENSION +
ServerTerrainChunk.CHUNK_DIMENSION * ServerTerrainChunk.CHUNK_DIMENSION +
ServerTerrainChunk.CHUNK_DIMENSION * ServerTerrainChunk.CHUNK_DIMENSION
));

View File

@ -375,7 +375,7 @@ public class TransvoxelModelGeneration {
* @param vertMap The vert map
* @param verts The list of verts
* @param normals The normal map
* @param trianglesSharingVert The indices of triangles sharing verts
* @param trianglesSharingVert The indices of triangles sharing verts -- Used for making sure normals are pointing correctly
* @return The number of triangles created
*/
protected static int polygonizeTransition(
@ -491,7 +491,8 @@ public class TransvoxelModelGeneration {
//the class of transition cell
short cellClass = (short)(transitionCellClass[caseIndex]);
short cellClass = transitionCellClass[caseIndex];
int windingOrder = (cellClass >>> 7) & 1;
LoggerInterface.loggerRenderer.DEBUG("Cell class: " + cellClass + " " + String.format("0x%02X", cellClass));
@ -700,6 +701,11 @@ public class TransvoxelModelGeneration {
int index1 = getVertIndex(vert1,vertMap,verts);
int index2 = getVertIndex(vert2,vertMap,verts);
if(windingOrder == 1){
index0 = getVertIndex(vert2,vertMap,verts);
index2 = getVertIndex(vert0,vertMap,verts);
}
//add 0's to normals until it matches vert count
while(trianglesSharingVert.size() < verts.size()){
trianglesSharingVert.add(0);
@ -978,6 +984,14 @@ public class TransvoxelModelGeneration {
}
}
/**
* Mixes two normals given a proportion value for each
* @param normal0 The first vector
* @param proportion0 The proportion of the first vector
* @param normal1 The second vector
* @param proportion1 The proportion of the second vector
* @return The mixed vector
*/
private static Vector3f averageNormals(Vector3f normal0, float proportion0, Vector3f normal1, float proportion1){
Vector3f rVal = new Vector3f(normal0);
rVal = rVal.mul(proportion0).add(new Vector3f(normal1).mul(proportion1));

View File

@ -16,7 +16,7 @@ public class HillsGen implements HeightmapGenerator {
/**
* Scales the input positions
*/
static final float POSITION_SCALE = 0.005f;
static final float POSITION_SCALE = 0.01f;
/**
* Scales the output height