To follow up here… I took out the mousex and mousey and things got a lot better. Then, I reduced the number of triangles I’m drawing and rotated the plane so I’m achieving basically the same effect with a lot less computation.
I also installed the experimental openGL drivers and bumped GPU memory allocation to 256 instead of 64.
This this is running smoother now, but it still has a little jitter to it, so I’m going to try and keep optimizing. Do you all see anything below that I should look into optimizing?
int cols, rows;
int scale = 30;
int w = 1200;
int h = 650;
float flying = 0;
float terrainHeight;
float[][] terrain;
color c1, c2;
void setup() {
fullScreen(P3D);
noCursor();
stroke(255);
noFill();
cols = w / scale;
rows = h / scale;
terrain = new float[cols][rows];
c1 = color(0, 255);
c2 = color(0, 0);
}
void draw() {
background(0);
flying -= 0.025;
float yOffset = flying;
for (int y=0; y < rows; y++) {
float xOffset = 0;
for (int x=0; x < cols; x++) {
terrainHeight = 155;
terrain[x][y] = map(noise(xOffset, yOffset), 0, 1, -terrainHeight, terrainHeight);
xOffset += 0.1;
}
yOffset += 0.1;
}
translate(width/2, height/2);
rotateX(PI/3);
translate(-w/2, -h/2);
for (int y=0; y < rows-1; y++) {
beginShape(TRIANGLE_STRIP);
for (int x=0; x < cols; x++) {
stroke(map(terrain[x][y], 0, 100, 150, 255), 125, 255, map(y, 0, rows, 0, 255));
vertex(x*scale, y*scale, terrain[x][y]);
vertex(x*scale, (y+1)*scale, terrain[x][y+1]);
}
endShape();
}
}
Thank you!