java - Few questions regarding OpenGL (culling and optimization) in a cube-based voxel engine -


i'm using lwjgl create minecraft voxel engine, i'm running in difficulties optimization. now, culling have great positive impact on performance, face culling did this:

    if (chunk.getworld().getgame().cam.getz() >= zz)      {         gltexcoord2f(1, 1);         glvertex3f(1, 1, 0);         gltexcoord2f(0, 1);         glvertex3f(0, 1, 0);         gltexcoord2f(0, 0);         glvertex3f(0, 0, 0);         gltexcoord2f(1, 0);         glvertex3f(1, 0, 0);     } 

and works okay, until run few problems. invisible faces still drawn (faces between blocks) , doesn't update if use display lists. here's questions, how 1 cull display lists? tried doing glenable(gl11.gl_cull_face); gave me in return, seems cull front faces rather back:

culling enabled

culling disabled

this out culling enabled through glenable, culling disabled (because lists it's pointless). looks fine, performance, believe, can improved.

this code, if i'm missing please ask, can upload whole project if need:

edit: copied other code draw cube , still doesn't right culling enabled.

at first - description

"invisible faces still drawn (faces between blocks) "

it appears there design issue. whether there face or not should depend on model, not on view, , culling view-related concept.


"doesn't update if use display lists"

look @ chapter "what’s stored in display list" of red book.


"but gave me in return, seems cull front faces rather back:"

likely normals don't fit polygon mode.

for cubes, calculating normals faces quite cheap: take cube center cc_ , center cf_ of face (in pseudocode)

n_ = (cf_ - cc_); n_ = normalize(n_); 

yields outward pointing face normal.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -