0
\$\begingroup\$

I'm creating a procedural world with LWJGL and GLSL. I want to better visualize the biome map being produced and the height map it creates, but my attempts so far have been very inefficient. My first idea was to make a vec3[] holding the biome color for each vertex, but that very quickly took the game from 150 fps to 10-15. The time to render a 512x512 chunk went from around 3 per second to one per five seconds. As you could expect, there was also a problem with it very quickly using up 12gb of ram.

I then thought about making an int[] array for each vertex where each point of the mesh would be able to use as a dictionary to grab a vec3 for the color. So 512*512 integers in an array getting from an array of 15 colors intead of a single array of 512*512 vec3s. This seemed even worse somehow in both FPS and chunk rendering time.

To summarize again, I'm trying to color each vertex with its own color to visually show the biomes. What is a more efficient way to do this?

\$\endgroup\$
1
  • 1
    \$\begingroup\$ This is something we'd usually do with a vertex colour channel. If you're seeing performance drops that bad from a single terrain mesh, there's likely a bigger problem in your update or rendering code. We'd need to see more of how you're doing this to be able to advise on how to fix it. \$\endgroup\$
    – DMGregory
    Aug 19 '20 at 13:02
1
\$\begingroup\$

The answer is obvious in retrospect, but the solution was to create a texture and use that instead of an array. I created an image based on the biome map for that chunk when it was generated. I loaded the texture into OpenGL, and the framerate is smooth once again without half of the work.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.