brett19 / rosebrowser

ROSEBrowser is a free and open-source implementation of the ROSE Online 3D MMORPG for web browsers written from scratch using the latest web standards (WebGL, HTML5, Javascript, Threads, ...).
Other
20 stars 17 forks source link

Generate the indices for the chunks only once. #4

Closed Jiwan closed 10 years ago

Jiwan commented 10 years ago

Note: I am wondering if parsing a json with all indices is faster than parsing this function that will later generate the indices.

Jiwan commented 10 years ago

Now it should be pullable !

exjam commented 10 years ago

OK this is really weird, I'm seeing a significant increase in chunk load times with this patch???? Not a clue why though - the code seems to be good in principle. Are you also seeing increased load times / laggier loads?

Jiwan commented 10 years ago

Well yeah. The first lag makes sense (the time to generate all the indices), but it should be faster for the long run. It looks like the whole buffer is re-send everytime on the GPU. Can you try with lmonly option ? Since the lmonly have 256 blocks for each chunks, this time, my version should have a less memory footprint (GPU and RAM) and should be faster. If not, it would confirm the fact that the buffer is send everytime no matter this "optimization".

exjam commented 10 years ago

geometry.computeVertexNormals is iterating through the 24k index vert buffer for every single 4x4 chunk. See three.js line 8549, maybe the geometry.offsets should be different? What this is currently saying is that we have 24k indices for every 4x4 block? Should it not be .start into correct position in the index buffer and .count limited to 4_4_2*3 ?

exjam commented 10 years ago

Nevermind, its because you need to move the line chunkMesh.geometry.offsets = [{index: 0, count: blockCount * 4_4_2*3, start: 0}];

to be BEFORE geometry.computeXXX.

So put it straight after the addAttributes and problem is fixed!

Jiwan commented 10 years ago

Many thanks Sir Benton!

exjam commented 10 years ago

:+1: