i'm going to write a software rendered occlusion culling mechanism for block game 😤
-
even if i set the visible chunk radius to 16 (which is quite far!) the occlusion culling runs in 11ms* and my fps above ground is 55
which i would say is solid for this early in the project
*with 8 subchunks per chunk
Oh. Most of the gains are from the frustum culling. I can cull a significant % of chunks if I use 64 subchunks per chunk, but that is also very very slow. But it does bring cull % up to like 75%
But just frustum culling chunks culls like 45-50% of chunks and is very very fast :|
8 subchunks per chunks is just a regular amount of slow but also not very effective
So hm. Well I guess at least I learned how to do efficient frustum culling? Womp womp 😔
-
Oh. Most of the gains are from the frustum culling. I can cull a significant % of chunks if I use 64 subchunks per chunk, but that is also very very slow. But it does bring cull % up to like 75%
But just frustum culling chunks culls like 45-50% of chunks and is very very fast :|
8 subchunks per chunks is just a regular amount of slow but also not very effective
So hm. Well I guess at least I learned how to do efficient frustum culling? Womp womp 😔
oh hey i got it down to 54ms from 93 at 16 visible chunk radius with 64 subchunks per chunk by only processing subchunks that have visible faces
i was using visible *blocks* before. but a theoretically visible block (not void/air) surrounded by blocks has no visible faces, so can't actually be seen
-
oh hey i got it down to 54ms from 93 at 16 visible chunk radius with 64 subchunks per chunk by only processing subchunks that have visible faces
i was using visible *blocks* before. but a theoretically visible block (not void/air) surrounded by blocks has no visible faces, so can't actually be seen
oops i had a bug that was causing a bunch of subchunks to not get occluded when they should be. so now the number of depth occluded subchunks is up by 50% and there's 1 depth occluded subchunk for every 2 frustum culled subchunks
-
oops i had a bug that was causing a bunch of subchunks to not get occluded when they should be. so now the number of depth occluded subchunks is up by 50% and there's 1 depth occluded subchunk for every 2 frustum culled subchunks
Had an idea to try tomorrow
Only render occluders nearby the camera and skip depth culling, because far away occluders will be tiny and unlikely to occlude much
Then depth cull far away (sub)chunks, since they're tiny and so only cover a few pixels and so are more likely to be culled
-
Had an idea to try tomorrow
Only render occluders nearby the camera and skip depth culling, because far away occluders will be tiny and unlikely to occlude much
Then depth cull far away (sub)chunks, since they're tiny and so only cover a few pixels and so are more likely to be culled
Actually it could be interesting to treat subchunks like mipmaps 🤔 so level 0 is 1 block per subchunk, level 1 is 2, 2 is 4, 3 is 8 and 4 is the whole chunk
Then I can use lower levels up close for better occlusion and higher levels far away for quicker culling
-
Actually it could be interesting to treat subchunks like mipmaps 🤔 so level 0 is 1 block per subchunk, level 1 is 2, 2 is 4, 3 is 8 and 4 is the whole chunk
Then I can use lower levels up close for better occlusion and higher levels far away for quicker culling
aha! i might be onto something! only rendering occluders into the depth buffer for nearby subchunks and only depth culling far away subchunks dropped the run time from 0.21x original to 0.14x original
i bet if i reduce the number of subchunks far away by making subchunks larger i can get even better gains
-
aha! i might be onto something! only rendering occluders into the depth buffer for nearby subchunks and only depth culling far away subchunks dropped the run time from 0.21x original to 0.14x original
i bet if i reduce the number of subchunks far away by making subchunks larger i can get even better gains
so uh, wow, holy shit!
my new subchunk levels method (where each level is smaller) is a 7x improvement over my last attempt, and my software occluder now runs in 0.02x the time it did before i started optimizing. in other words, it runs 50x faster now! for 12 visible chunk radius its down from 155ms to fucking *4*
interestingly though, even though i have 3 levels, 16, 8 and 4 blocks, i didn't even need the middle level. i just switch straight to whole chunks for depth occlusion
-
so uh, wow, holy shit!
my new subchunk levels method (where each level is smaller) is a 7x improvement over my last attempt, and my software occluder now runs in 0.02x the time it did before i started optimizing. in other words, it runs 50x faster now! for 12 visible chunk radius its down from 155ms to fucking *4*
interestingly though, even though i have 3 levels, 16, 8 and 4 blocks, i didn't even need the middle level. i just switch straight to whole chunks for depth occlusion
in hindsight this makes sense. occluders should be small, since they set up the depth buffer, but then occlusion culling can be done on whole chunks since it doesn't matter how big the area you're testing at one time is so long as the occlusion map is filled up properly
so next i might try rendering single blocks into the occlusion map and depth culling entire chunks always and see how that performs
-
in hindsight this makes sense. occluders should be small, since they set up the depth buffer, but then occlusion culling can be done on whole chunks since it doesn't matter how big the area you're testing at one time is so long as the occlusion map is filled up properly
so next i might try rendering single blocks into the occlusion map and depth culling entire chunks always and see how that performs
16 visible chunk radius now runs at 68 fps above ground (1 short of being truly nice 😔) and the occlusion culler runs in only 5ms
-
16 visible chunk radius now runs at 68 fps above ground (1 short of being truly nice 😔) and the occlusion culler runs in only 5ms
simplified everything and split occluders from depth culling candidate chunks
also trying to be more picky and granular about what occluders to use, so now i'm rendering single blocks nearby the camera. hopefully more granular occluders will improve the culling percentage
-
simplified everything and split occluders from depth culling candidate chunks
also trying to be more picky and granular about what occluders to use, so now i'm rendering single blocks nearby the camera. hopefully more granular occluders will improve the culling percentage
you can call me weird but it is very fun to build a little box around myself and watch my fps go up from 110 to 450 because of the depth occlusion system
-
you can call me weird but it is very fun to build a little box around myself and watch my fps go up from 110 to 450 because of the depth occlusion system
hmm hmm so my subchunk levels go 1³, 2³, 4³, 8³, 16³
but im betting anything above 2³ is gonna be exceedingly rare since a new requirement is having a block with an exposed face. though i havent tested this
but i feel like maybe 1³, then 2²x1 4²x1 8²x1 16²x1 for each axis would probably work a *lot* better given how human construction tends to go
and also ground planes/cliff faces
-
hmm hmm so my subchunk levels go 1³, 2³, 4³, 8³, 16³
but im betting anything above 2³ is gonna be exceedingly rare since a new requirement is having a block with an exposed face. though i havent tested this
but i feel like maybe 1³, then 2²x1 4²x1 8²x1 16²x1 for each axis would probably work a *lot* better given how human construction tends to go
and also ground planes/cliff faces
i'm *sure* you'll all find this as riveting as i do, but while there are loads of 8x8x8 areas of fully opaque blocks with at least one visible exterior face, there appear to be literally no 16x16x16 areas of the same description in any given chunk >_>
-
i'm *sure* you'll all find this as riveting as i do, but while there are loads of 8x8x8 areas of fully opaque blocks with at least one visible exterior face, there appear to be literally no 16x16x16 areas of the same description in any given chunk >_>
here's photographic evidence of all the 8x8x8 blobs out in their natural habitat
-
here's photographic evidence of all the 8x8x8 blobs out in their natural habitat
so i've tweaked all the parameters and above ground its now culling 75% ish of chunks that survive frustum culling. even at 24 chunk radius it runs in ~8ms so about half a frame (and it's threaded so that's fine)
and i'm getting 75 fps above ground at 16 render dist, and 115 at 12. and indoors or in caves its more like 300-400
so i'd call this feature a success and also done for the time being!
-
so i've tweaked all the parameters and above ground its now culling 75% ish of chunks that survive frustum culling. even at 24 chunk radius it runs in ~8ms so about half a frame (and it's threaded so that's fine)
and i'm getting 75 fps above ground at 16 render dist, and 115 at 12. and indoors or in caves its more like 300-400
so i'd call this feature a success and also done for the time being!
being in a cave make fps go zoom! :3
(lol the alt badge hides the fps counter. it reads 450)
-
being in a cave make fps go zoom! :3
(lol the alt badge hides the fps counter. it reads 450)
ngl this never gets old (turning occlusion culling on and off to show how much its culling)
-
ngl this never gets old (turning occlusion culling on and off to show how much its culling)
@eniko «Look at all the stuff you can't see!»