Skip to content

Commit

Permalink
dispatch real number of cubes
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoy committed Dec 5, 2024
1 parent 2ed8b82 commit 8415f64
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
1 change: 1 addition & 0 deletions prismarine-viewer/examples/Cube.frag.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ fn main(
let tileSize: vec2<f32> = vec2<f32>(16.0, 16.0);
let tilesPerTexture: vec2<f32> = textureSize / tileSize;
let pixelColor = textureSample(myTexture, mySampler, fragUV / tilesPerTexture + vec2f(trunc(TextureIndex % tilesPerTexture.y), trunc(TextureIndex / tilesPerTexture.x)) / tilesPerTexture);
// return vec4f(pixelColor.rgb * ColorBlend / 255, pixelColor.a); // Set alpha to 1.0 for full opacity
return vec4f(pixelColor.rgb * ColorBlend / 255, 1.0); // Set alpha to 1.0 for full opacity
}
2 changes: 1 addition & 1 deletion prismarine-viewer/examples/scenes/layers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default class Scene extends BasePlaygroundScene {
for (let x = start; x <= end; x++) {
for (let z = start; z <= end; z++) {
const isEven = x === z
worldView!.world.setBlockStateId(this.targetPos.offset(x, y, z), fullBlocks[y / STEP]!.defaultState)
worldView!.world.setBlockStateId(this.targetPos.offset(x, y, z), y === 0 ? fullBlocks.find(block => block.name === 'glass')!.defaultState : fullBlocks[y / STEP]!.defaultState)
}
}
}
Expand Down
10 changes: 4 additions & 6 deletions prismarine-viewer/examples/webgpuRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class WebgpuRenderer {
chunkBindGroup: GPUBindGroup
debugBuffer: GPUBuffer

actualBufferSize = 0
realNumberOfCubes = 0
occlusionTexture: GPUBuffer
computeSortPipeline: GPUComputePipeline
depthTextureBuffer: GPUBuffer
Expand Down Expand Up @@ -592,8 +592,6 @@ export class WebgpuRenderer {
})
}

realNumberOfCubes = 0

updateSides () {
}

Expand Down Expand Up @@ -698,7 +696,7 @@ export class WebgpuRenderer {

this.notRenderedBlockChanges++
console.timeEnd('updateBlocks')
this.realNumberOfCubes = this.NUMBER_OF_CUBES
this.realNumberOfCubes = allBlocks.length
if (!DEBUG_DATA) {
chunksStorage.clearRange(updateOffset, updateOffset + updateSize)
}
Expand Down Expand Up @@ -737,7 +735,7 @@ export class WebgpuRenderer {
tweenJs.update()
const fov = 90
this.camera.fov = fov
this.camera.near = 0.001;
this.camera.near = 0.001
this.camera.updateProjectionMatrix()
const oversize = 1.1

Expand Down Expand Up @@ -846,7 +844,7 @@ export class WebgpuRenderer {
computePass.setBindGroup(0, this.computeBindGroup)
computePass.setBindGroup(1, this.chunkBindGroup)
computePass.setBindGroup(2, this.textureSizeBindGroup)
computePass.dispatchWorkgroups(Math.ceil(this.NUMBER_OF_CUBES / 256))
computePass.dispatchWorkgroups(Math.ceil(this.realNumberOfCubes / 256))
computePass.end()
device.queue.submit([this.commandEncoder.finish()])
}
Expand Down

0 comments on commit 8415f64

Please sign in to comment.