PDA

View Full Version : Terrain tessellation in chunks?



glararan
09-15-2013, 02:18 PM
Hi,

Is there any possible "very fast" way to create mapchunks for tessellation?

I have some pre-alpha ver, but it's laggy, because I'm using glTexImage2D to port heightmap to shader. There it's laggy problem.
Do you know anyone better solution? Or it's very old technique using map chunks? And what I'm doing? 3D Map Editor, that's why is better use more chunks than one big map for more textures.

Program class hiearchy:
-> MapChunk
-> MapTile(16x16 MapChunk) -> MapTile::draw call MapChunk::draw Vertex Array Object ==> glDrawArrays
-> World (max 64x64 MapTile, currently using one MapTile) -> World::draw foreach MapTile do MapTile::draw
-> MapView (QGLWidget) -> MapView::paintGL call World::draw
-> MainWindow setCentralWidget

Thanks for any reply!

glararan
09-17-2013, 03:03 AM
No one have any idea?

When I use 4x4 MapChunk its still good, but 8x8 is little laggy, 16x16 ultra laggy.

Function which lagging it is:

void Material::bind()
{
m_shader->bind(); // QOpenGLShaderProgramPtr == typedef QSharedPointer<QOpenGLShaderProgram> QOpenGLShaderProgramPtr; its binding shader...

foreach(const GLuint unit, m_unitConfigs.keys())
{
const TextureUnitConfiguration& config = m_unitConfigs.value(unit);

// Bind the texture
m_funcs->glActiveTexture(GL_TEXTURE0 + unit); // m_funcs = QOpenGLFunctions, its in Qt.. working as normal glActiveTexture BUT there come slow down
config.texture()->bind();

// Bind the sampler
config.sampler()->bind(unit);

// Associate with sampler uniform in shader (if we know the name or location)
if(m_samplerUniforms.contains(unit))
m_shader->setUniformValue(m_samplerUniforms.value(unit).cons tData(), unit); // BIGGEST SLOW DOWN because it sending a lot uniforms, any idea how to post uniform with multi values fast?
}
}

glararan
09-18-2013, 01:45 PM
BUMPING!

I have new result from debugging.

Big enemy is still same = uniform. But not caused by textures, it slowed because each chunk in (16*16 = 256) use mapData[MAP_WIDTH / 16 * MAP_HEIGHT / 16 * sizeof(float)] which is binded to texture (glTexImage2D) and there is main problem, sending 256 uniforms per 16ms is alot! Have you any idea with better solution how to send through uniform 256 mapData (256 mean each chunk) (mapData == buffer with height).