Advice on infinite world space grid

Hi folks,

I’m wondering what the best approach for rendering an infinite world space grid would be? Eg the user moves around in the 3d world and the grid remains as long as the camera can scroll.

At the moment, I’m creating a Batch object of “fixed” size ie:

mWirePlane = gl::Batch::create(geom::WirePlane().size(vec2(mGridWidth, mGridHeight)).subdivisions(ivec2(numSubdivisionsX, numSubdivisionsY)), mColorShader);

I guess I could work out the locations to start a grid and then re-generate this every time the camera moves for example, but I thought this approach may be slow performance wise. Is there a better approach to use, maybe using shaders etc?

Thanks for any steer

Hi,

I would try something like creating a grid big enough to cover the viewport and move it to the camera position rounded to the closest cell position.

-Gabor

2 Likes

Yep, this works well, thanks for that. I can set the size of the grid/recreate it based on camera altitude and perf is good. :slight_smile: :+1:

1 Like