Jump to content

Sprite occlusion for performance - Part II


simon_bg
 Share

Recommended Posts

Hi peeps, I've already published a similar topic not a while ago, but we couldn't really reach any conclusion:
http://www.html5gamedevs.com/topic/32079-sprite-occlusion-for-performance/

I have this demo: http://devel.arinnova.com/tests/3dmaps/babylon_demo/

I'm trying to get a similar forest to this three.js scene: https://www.piste.io/#!/cortina . Notice how the forest is really dense and the FPS are really good.

What I've already tried without success: 

1) Loading meshes instead of sprites and applying LOD mechanism resulted in very low FPS.
2) Using mesh instances instead of sprites, still very low FPS 
2) Temechon kindly helped me and coded a LOD function for sprites, but unfortunately it was more or less the same FPS as without the LOD.
4) Showing all the 54k trees, but using a particle system instead of sprites, which helped to reduce the draw calls, but the FPS were still low.
5) I've implemented a "poor man's LOD". I separated the 54k trees into 9 chunks, each chunk corresponding to a specific area. Then at every frame I calculated the distance from the camera to the central point of each area. If it was close enough to the camera, I showed the area trees and if not, I removed them. This way at each frame I had to calculate distances to only 9 points instead of 54k points, which helped but visually it was not pretty at all. Even applying a brown texture on the terrain underneath the trees, the chunks of trees appearing and disappearing all at once are very noticeable.
6) I also reduced the tree image size to 128x128, just in case, but I'm not sure it had an effect on FPS.

Using an image of a pine tree or a leafy tree would create much more perception of a dense forest, but unfortunately I can't use those. The scene is a winter map of a specific real-world area with leafless trees and I'm trying to be as realistic as possible.
A silly idea I've also tried was using an image of a group of trees instead of an image of a single tree. It obviously looked fake, especially when rotating the camera.  

Some other ideas that I've had but have not tried: 
    Solid Particle System -> as it has more effect on performance than a simple particle system and I've already tried that.
    Octrees -> could this help me? I've read the tutorial but I'm not sure I understand how could I apply it to sprites. 
    I don't know how camera.maxZ works internally, but is there possibly any way to apply it only to sprites, so the nearest sprites only are visible?   Could I implement my own camera that does this?

tldr; I'd like to show ~200.000 trees in my scene with minimal performance drawback.

Thanks a lot in advance!
    

Link to comment
Share on other sites

Let's be faire. You won't be able to do that WITHOUT a custom shader.

As I was pretty sure, they use this technique, I looked into the example you gave on piste.io. 

To better understand what they are doing, I highly recommend that you install Spector.js extension on your browser. Then just go to the page and do a capture.

Here is a quick summary of what I found:

- The trees are rendered in one call with 98304 vertices:

Capture.thumb.JPG.d07fe8c341a6d60f2c22731cdf7249f6.JPG

The custom vertex shader is really smart and is mostly responsible to prepare data to render the correct sprites and ground and snow :D basically the technique used by my WorldMonger demo but instead of a grass texture they generate small trees with shadow.

All the interesting code appends in the custom pixel shader.

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...