#render Pbr in batches

8 messages · Page 1 of 1 (latest)

gaunt quest
#

Hey!
I´m trying to render 128*128 blocks like this:

let material = materials.add(Color::rgb(0.3, 0.5, 0.3).into());
    let mesh = meshes.add(Mesh::from(shape::Cube { size: 1.0 }));

for x in 0..128 {
    for y in 0..128 {
        commands.spawn(
            PbrBundle {
                mesh: mesh.clone(),
                material: material.clone(),
                transform: Transform::from_xyz(
                    x as f32 - 64.0,
                    0.0,
                    y as f32 - 64.0,
                ),
                ..default()
            }
        );
    }
}

I´m running this on windows using
CPU: AMD Ryzen 5 5600X 6-Core Processor
GPU: Geforce RTX 2070 Super

I get around 70 fps when all the blocks are in the view (90 in release mode).
I expected the performance to be way better as the amount of triangles is pretty low.

Am i simply doing something wrong?

humble canopy
gaunt quest
#

for that many blocks
Are 16384 Blocks actually that much?
To be more clear, i want to create a voxel style game and therefore need to render many blocks. I know there are things like block-mesh but in some situtations the engine still has to render that many single blocks.
Are shaders actually a valid way to implement what i´m trying to achieve?

humble canopy
#

it's not so much shaders, but instancing (aka batching) draw calls. This gives the GPU much more freedom to schedule and cache things it needs. When profilling currently you will find that the GPU is stalling a large percentage of the time (or perhaps even that the cpu usage is very high due to all the seperate draw calls)

#

16384 draw calls is actually indeed on the large side and I would say that max 90 fps is to be expected in that case

gaunt quest
graceful root
#

There is no support for batch rendering, so this is super slow
If you are building a voxel game, you need to be meshing each chunk as a single mesh
I highly recommend you use block-mesh

humble canopy