Skip to content

Commit

Permalink
Fix blocks not rendering below Y 0 (i.e. In Negative bounds)
Browse files Browse the repository at this point in the history
(Hopefully won't cause performance regressions due to the Int to Float Casts + Mixed Integer + Float Workloads)
  • Loading branch information
thr3343 committed Nov 20, 2023
1 parent ed50187 commit dcff864
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
7 changes: 3 additions & 4 deletions src/main/java/net/vulkanmod/render/chunk/DrawBuffers.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,9 @@ private AreaBuffer getAreaBuffer(TerrainRenderType r) {
}

private static int encodeSectionOffset(int xOffset, int yOffset, int zOffset) {
final int xOffset1 = (xOffset & 127)>>4;
final int zOffset1 = (zOffset & 127)>>4;
final int yOffset1 = yOffset >> 4;
return zOffset1 << 16 | yOffset1 << 8 | xOffset1;
final int xOffset1 = (xOffset & 127);
final int zOffset1 = (zOffset & 127);
return yOffset << 18 | zOffset1 << 9 | xOffset1;
}

private void updateChunkAreaOrigin(double camX, double camY, double camZ, VkCommandBuffer commandBuffer, long ptr) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ const vec4 UNPACK_FACTOR = vec4(127.*16.);
const vec3 POSITION_INV = vec3(1.0 / 1900.0);

void main() {
const vec4 baseOffset = vec4(fma(Position,POSITION_INV,ChunkOffset), 1);
const vec4 xyz = fma(unpackSnorm4x8(gl_InstanceIndex),UNPACK_FACTOR,baseOffset);
gl_Position = MVP * xyz;
const vec3 baseOffset = bitfieldExtract(ivec3(gl_InstanceIndex)>> ivec3(0, 18, 9), 0, 9);
const vec3 pos = baseOffset+fma(Position, vec3(POSITION_INV), ChunkOffset);
const vec4 a = vec4(pos, 1);
gl_Position = MVP * a;

vertexDistance = length((ModelViewMat * xyz).xyz);
vertexDistance = length((ModelViewMat * a).xyz);
vertexColor = Color * sample_lightmap(Sampler2, UV2);
texCoord0 = UV0 * UV_INV;
// normal = MVP * vec4(Normal, 0.0);
Expand Down

0 comments on commit dcff864

Please sign in to comment.