0
\$\begingroup\$

My terrain rendering shows these jagged peaks along the edges of some hills:

Jagged peaks in back right

More jagged peaks

Why do these occur, and how can I fix this?

Here is the code I use to initialize my surface and draw a frame:

@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {

    GLES30.glClearColor(184.0f / 255.0f, 213.0f / 255.0f, 238.0f / 255.0f, 1.0f);
    
    terrain = new Terrain(context);

}

@Override
public void onDrawFrame(GL10 gl) {

    GLES30.glClear(GLES30.GL_COLOR_BUFFER_BIT | GLES30.GL_DEPTH_BUFFER_BIT);
    
    camera.Update();
    terrain.draw(gl, camera.camera_model, camera.camera_view, camera.camera_projection);
    
}
\$\endgroup\$
1
  • 1
    \$\begingroup\$ It looks like certain vertices are getting an invalid position - maybe zero, maybe infinity, maybe even NaN - causing alternating triangles along the ridge to either abort rendering or stretch out to some distant location. To diagnose this, we'd need to know what the source is for the vertex positions you're drawing (are you reading them from a heightmap texture, or procedurally generating the terrain in some way?) and see the vertex shader code that transforms these vertices to their rendered positions. Try editing your question to include a minimal reproducible example of the problem. \$\endgroup\$
    – DMGregory
    Jul 14, 2023 at 17:37

0

You must log in to answer this question.

Browse other questions tagged .