From 5ae298a813b98ba966531636de37d50abdef4cef Mon Sep 17 00:00:00 2001 From: mcrcortex <18544518+MCRcortex@users.noreply.github.com> Date: Sun, 17 Sep 2023 19:09:58 +1000 Subject: [PATCH] Bump version to 0.2.0-beta and fixed section culling --- gradle.properties | 2 +- .../me/cortex/nvidium/managers/SectionManager.java | 5 ++++- .../shaders/occlusion/section_raster/mesh.glsl | 14 +++++++++----- .../nvidium/shaders/terrain/translucent/mesh.glsl | 4 ++-- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/gradle.properties b/gradle.properties index 5f660111..d8b37d27 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ loader_version=0.14.21 fabric_version=0.84.0+1.20.1 # Mod Properties -mod_version=0.1.17-alpha +mod_version=0.2.0-beta maven_group=me.cortex archives_base_name=nvidium # Dependencies diff --git a/src/main/java/me/cortex/nvidium/managers/SectionManager.java b/src/main/java/me/cortex/nvidium/managers/SectionManager.java index 7797ca32..873c0cf2 100644 --- a/src/main/java/me/cortex/nvidium/managers/SectionManager.java +++ b/src/main/java/me/cortex/nvidium/managers/SectionManager.java @@ -81,8 +81,11 @@ public void uploadChunkBuildResult(ChunkBuildOutput result) { Vector3i min = output.min(); Vector3i size = output.size(); + //NOTE:TODO: The y encoded height position only has a range of like 6 bits max, that gives 18 bits free/spare for something + // realistically it would only be 16 free bits cause ee but still thats 2 bytes free + int px = section.getChunkX()<<8 | size.x<<4 | min.x; - int py = section.getChunkY()<<24 | size.y<<4 | min.y; + int py = section.getChunkY()<<24 | size.y<<4 | min.y;//TODO: figure out how to make this << 8 just like the others int pz = section.getChunkZ()<<8 | size.z<<4 | min.z; int pw = addr; new Vector4i(px, py, pz, pw).getToAddress(segment); diff --git a/src/main/resources/assets/nvidium/shaders/occlusion/section_raster/mesh.glsl b/src/main/resources/assets/nvidium/shaders/occlusion/section_raster/mesh.glsl index 615528fb..02f5221b 100644 --- a/src/main/resources/assets/nvidium/shaders/occlusion/section_raster/mesh.glsl +++ b/src/main/resources/assets/nvidium/shaders/occlusion/section_raster/mesh.glsl @@ -42,6 +42,7 @@ void emitParital(int visIndex) { gl_MeshPrimitivesNV[gl_LocalInvocationID.x+8].gl_PrimitiveID = visIndex; } +//TODO: Check if the section can be culled via fog void main() { int visibilityIndex = (int)(_visOutBase|gl_WorkGroupID.x); @@ -53,9 +54,10 @@ void main() { vec3 mins = (header.xyz&0xF)-ADD_SIZE; vec3 maxs = mins+((header.xyz>>4)&0xF)+1+(ADD_SIZE*2); ivec3 chunk = ivec3(header.xyz)>>8; - chunk.y >>= 16; + chunk.y >>= 16;//TODO: figure out how to remove this from here and in the SectionManager, when i remove it everything dies ivec3 relativeChunkPos = (chunk - chunkPosition.xyz); vec3 corner = vec3(relativeChunkPos<<4); + vec3 cornerCopy = corner; //TODO: try mix instead or something other than just ternaries, i think they get compiled to a cmov type instruction but not sure corner += vec3(((gl_LocalInvocationID.x&1)==0)?mins.x:maxs.x, ((gl_LocalInvocationID.x&4)==0)?mins.y:maxs.y, ((gl_LocalInvocationID.x&2)==0)?mins.z:maxs.z); @@ -68,12 +70,14 @@ void main() { emitParital(prim_payload); } if (gl_LocalInvocationID.x == 0) { - //ivec3 absRelPos = abs(relativeChunkPos); - //int maxDist = min(absRelPos.x, min(absRelPos.y, absRelPos.z)); + cornerCopy += subchunkOffset.xyz; + vec3 minPos = mins + cornerCopy; + vec3 maxPos = maxs + cornerCopy; + bool isInSection = all(lessThan(minPos, vec3(ADD_SIZE))) && all(lessThan(vec3(-ADD_SIZE), maxPos)); //Shift and set, this gives us a bonus of having the last 8 frames as visibility history - //sectionVisibility[visibilityIndex] = uint8_t(lastData<<1) | uint8_t(maxDist<=1?1:0);//Inject visibility aswell - sectionVisibility[visibilityIndex] = uint8_t(lastData<<1) | uint8_t(0); + sectionVisibility[visibilityIndex] = uint8_t(lastData<<1) | uint8_t(isInSection?1:0);//Inject visibility aswell + //sectionVisibility[visibilityIndex] = uint8_t(lastData<<1) | uint8_t(0); gl_PrimitiveCountNV = 12; } diff --git a/src/main/resources/assets/nvidium/shaders/terrain/translucent/mesh.glsl b/src/main/resources/assets/nvidium/shaders/terrain/translucent/mesh.glsl index 1c345a98..b471113f 100644 --- a/src/main/resources/assets/nvidium/shaders/terrain/translucent/mesh.glsl +++ b/src/main/resources/assets/nvidium/shaders/terrain/translucent/mesh.glsl @@ -74,8 +74,8 @@ void main() { vec4 addiAO; vec4 tintBO; vec4 addiBO; - computeFog(isSphericalFog, posA+subchunkOffset.xyz, tintA, fogColour, fogStart, fogEnd, tintAO, addiAO); - computeFog(isSphericalFog, posB+subchunkOffset.xyz, tintB, fogColour, fogStart, fogEnd, tintBO, addiBO); + computeFog(isCylindricalFog, posA+subchunkOffset.xyz, tintA, fogColour, fogStart, fogEnd, tintAO, addiAO); + computeFog(isCylindricalFog, posB+subchunkOffset.xyz, tintB, fogColour, fogStart, fogEnd, tintBO, addiBO); OUT[(gl_LocalInvocationID.x<<1)|0].tint = tintAO; OUT[(gl_LocalInvocationID.x<<1)|0].addin = addiAO; OUT[(gl_LocalInvocationID.x<<1)|1].tint = tintBO;