optimization of the chunks that needs to be displayed

alien58
New member
 
Posts: 7
Joined: Tue May 29, 2012 14:08

optimization of the chunks that needs to be displayed

by alien58 » Tue May 29, 2012 15:46

first off i'm not very good with c but have many years useing basic ( darkbasic pro ).


The overview of the optimization is simple to reduce the number of chunks that need to do display within the range of the player. This was of displaying is wasteful what i mean there are chunks that you can not get to within a set distance of the player. example of this is going into Creative mode and fly below the ground and you will see caves that are not connected to the surface.

Image

above is a example of distance culling in 2d. Each white block is the player that can move to , the blue block are chunks that the player can't move to ie solid stone within the chunk.

the memory needed is very little 6 veribles per chunk to store which chunks are connected together and 1 16x16x16 to be used for finding chunks connections. this 1 16x16x16 is reused to save memory for each check and 1 more verible to store has the connections be check. A list to store chunks that need to be check.

The call timeing should be when the player has moved 16 block from the last check position. There 3 more veribles for the memory.

The speed of the optimization depends on the time it take to load / unload / make gfx of a chunk.

final notes time to think about how to optimiz the lighing system.
 

User avatar
LolManKuba
Member
 
Posts: 939
Joined: Fri Feb 10, 2012 22:36

by LolManKuba » Tue May 29, 2012 23:09

alien58 wrote:Example of this is going into Creative mode and fly below the ground and you will see caves that are not connected to the surface.

That's normal...
 

User avatar
RabbiBob
Member
 
Posts: 335
Joined: Sat Jan 28, 2012 22:40

by RabbiBob » Wed May 30, 2012 00:28

LolManKuba wrote:
alien58 wrote:Example of this is going into Creative mode and fly below the ground and you will see caves that are not connected to the surface.

That's normal...


Doesn't matter, read the sentence prior to the one you quoted.
 

alien58
New member
 
Posts: 7
Joined: Tue May 29, 2012 14:08

by alien58 » Wed May 30, 2012 00:32

LolManKuba it may be normal but for speed there should not be drawned.

here is a breakdown of the optimization
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all

-- keep all chunk within 1 range of the player loaded

-- add player chunk to list of chunks to check plus a verible to store a counter. starting counter = 1

-- For every item in the list

   -- copy to test chunk a 18x18x18
   -- copy chunks next to the chunk in the list -- Only the blocks around the chunk.
       -There needs to be some currections to the data so only soilded blocks are added
  -- add player position to a second list
      --work for every item in the list 2 check to see if there are soilded or not around that pos ( XYZ )
         --IF not add these positions to the list 2
            --there need another check to see if it has check that position before
            --check to see if position is outside the chunk if yes set that direction to 1
         --if yes do nothing
      --when finished from the list 2 check to see if there are any directions set to 1
         --if yes add that chunk to the first list. the counter for that chunk = current count +1
            -IF the current counter + 1 is greater that max chunk draw distance do not add to list

--there you go a list of chunk that should be drawed.
--There are many little things that i did not add to this but should give you i ider of how it should work.

--There is a Lee / maze algorithm with some change for a chunk style world
-- i have use this algorithm before in a path finding ai 100x100 grid 2 to 3 ms to cal.
-- i did try A* but the range of the cal are 0 to 38ms to cal.

 

User avatar
LolManKuba
Member
 
Posts: 939
Joined: Fri Feb 10, 2012 22:36

by LolManKuba » Wed May 30, 2012 00:41

RabbiBob wrote:
LolManKuba wrote:
alien58 wrote:Example of this is going into Creative mode and fly below the ground and you will see caves that are not connected to the surface.

That's normal...


Doesn't matter, read the sentence prior to the one you quoted.

Doesn't matter, I can't do anything from here, I can't do c code or lua.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
#include <iostream>
 
int main()
{
   std::cout << "Hello, world!\n";
}

That's hard for me lol
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
function factorial(n)
  if n == 0 then
    return 1
  else
    return n * factorial(n - 1)
  end
end

That's easier by a bit for me.
By the way this is off topic.
 

alien58
New member
 
Posts: 7
Joined: Tue May 29, 2012 14:08

by alien58 » Wed May 30, 2012 01:00

lua is not that hard the way i do it. just copy and paste the code you want then change the veribles.

I spend over 1 hour adding charcoal to minetest useing a old mod then converting over to the new format.
I think time well spend no need to hunt for coal when starting a new world.
Last edited by alien58 on Wed May 30, 2012 01:01, edited 1 time in total.
 

celeron55
Member
 
Posts: 430
Joined: Tue Apr 19, 2011 10:10

by celeron55 » Thu May 31, 2012 10:59

alien58 wrote:example of this is going into Creative mode and fly below the ground and you will see caves that are not connected to the surface.


Minetest already does this using occlusion culling for chunks (MapBlocks). It gets shut off when you go inside ground, because not very much would be drawn there otherwise.

The way it works isn't exactly perfectly optimal, but it does work and helps a lot especially on slow GPUs.
 

alien58
New member
 
Posts: 7
Joined: Tue May 29, 2012 14:08

by alien58 » Fri Jun 01, 2012 01:13

celeron55...

I change a few textures to transparent just to see what you do for occlusion culling because i could not work out a way of useing chunks for culling. After a little while of running around looking at chunk loading / unloading then it hit me. I have to say who every made that form of culling is a genius i would have never come up with that idear of useing filled chunks as the occlusion box check and combine Viewing frustum culling with it.

after a little bit of thinking you could use occlusion culling with no filled chunks ie. chunks with some block in it. IF 1 or more of it sides are filled with a none transparent blocks. You can use that side for occusion box check. This sides check should be only use on chunks that are close to the player to reduce the number of checks.

useing this suggestion it could remove a lot of chunks that the culling have missed before.
 

alien58
New member
 
Posts: 7
Joined: Tue May 29, 2012 14:08

by alien58 » Sun Jun 03, 2012 23:03

after a little bit of thinking you could use occlusion culling with no filled chunks ie. chunks with some block in it. IF 1 or more of it sides are filled with a none transparent blocks. You can use that side for occusion box check. This sides check should be only use on chunks that are close to the player to reduce the number of checks.


some more notes. there are 6 face that need to be check on a chunk. You can get better speed if you look at the cornder first. If there are no block in that position you can skip 3 sides of that chunk that are connected to that position. still needs to check the sides for no blocks.
 


Return to Minetest Engine

Who is online

Users browsing this forum: Bing [Bot] and 4 guests

cron