Skip to content

Commit

Permalink
Bump version to 0.2.0-beta and fixed section culling
Browse files Browse the repository at this point in the history
  • Loading branch information
MCRcortex committed Sep 17, 2023
1 parent 601935a commit 5ae298a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/me/cortex/nvidium/managers/SectionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 5ae298a

Please sign in to comment.