My Struggle

Although I know just enough to be dangerous, I am working on a 3d game project. One of my issues is that part of the game involves movement throughout an open world which is being based off of a 900x900 array map that I am importing with edits from the previous episode. Because for the outdoor area the view is expansive, I am currently only getting about 20-30fps without any of the rest of the game 'guts' even operating yet and only maybe half of my model diversity in place. This frightens me a bit so I have been focusing on trying to improve this. The base terrain on the outdoor world is being built from textured 'unit cube models' (1.0x1.0x1.0) and some (slightly) more complex objects (like large rocks, grasses, a variety of trees, etc.) are being placed upon the terrain. For dungeons, I plan to have the ability to stack 6-10 levels of such terrain (think Minecraft) but for the outdoors I have already resolved that this can likely only be 2 (base terrain and 'top-layer' objects) as the horizon is occluded in dungeons while outdoors I am currently drawing much less than I desire resulting in tall objects 'popping' suddenly into view on the horizon. I am willing to live with this for now but still would like to be able to render further into the distance. Currently, my loop runs 2height x 35depth x 40width sending models based on the view direction. Here are my thoughts and would love any comments/suggestions:

1. I am currently rendering far to near because it allows me to place transparent water. This is probably a big hit and I am willing to live without transparent water if need be.

2. My textures are not currently all powers of 2; I am definitely working to revise the textures in use to powers of 2. Not sure what the impact will be on fps.

3. I did several 'tests' to try to see if my bottleneck is CPU or GPU and it seems that it is GPU related.

4. My loop currently sends quite a few objects that are not in the view left/right or behind. This is currently needed for my turning routine to look acceptable. I'm not sure if sending these draws is a hit. If so, I can try to revise this.

5. Much of my 'cube terrain' textures could probably be moved to an atlas. I'm not sure how to do this. I know that there is a raylib example but I have not tried to dissect it yet.

There are some pictures of what I am trying to accomplish here:

So there you have it. Would love some guidance on best place to focus if anyone has an opinion. Thanks!


  • Update: Switching to rendering near to far had very little impact on fps. Complicating my loop to skip objects that are not in the view took me from around 30fps to around 40fps. Most importantly, my brother (who works with me on non-coding aspects of development) ran the demo on his computer and the fps was pegged at the targeted 60 the whole time. This created a new issue for me in that I will need to devise a method to ensure that aspects of the game like movement speed are somewhat normalized from computer to computer. Hmm.
  • hey oklabsoft! These days I'm out of the computer and it's difficult to write a long answer on my phone... but to improve performance, you should use a texture atlas, it should improve performance a lot! Also, what function do you use to draw the cubes? It would be better to build your own meshes or check GenMeshCubemap() function and example. Keep me updated with your changes!
  • Thank you, Ray! I value your responses/advice very much but it is never a problem if they are brief, delayed, or you can't get to it at all. :)

    I will try to figure out how to group my 'block terrain' textures into an atlas.

    Right now, my models are a mix of GenMeshCube() generated and those I have made with blender but I am in the process of replacing all of the GenMeshCube's with my own blender cube model because it is easier to know how the textures are placed based on the way I unwrapped it. As 'low-poly' as even my most complex models are, I was surprised to encounter performance issues at this point but my methods may be playing a role. I will also have to check to see what the hit from my 'fake' lighting routine in the draw loop is but it is really only a single distance calculation per model.

    I will keep you posted and thanks again.
Sign In or Register to comment.