Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

An exercice to increase framerate

Discussion in 'General Graphics' started by Thomas12, Mar 15, 2015.

  1. Thomas12

    Thomas12

    Joined:
    Dec 24, 2014
    Posts:
    36
    Hello everyone,

    I'm trying to push up the frame rate in the following situation:

    *one directional light
    *10,000 spheres placed at random with no shadows (nor casting or receiving) and a diffuse shader with only a color specified. The spheres have no rigidbodies and no colliders.
    *the camera is put in a position where all the spheres can be seen at the same time.

    Things I have tried
    *using an unlit shader with as texture a simple unicolor png file. It was effective in increasing the framerate.
    *replacing the spheres by planes. This made things worse (so a sphere is easier to render than a plane?)
    *replacing the spheres by quads. No difference. We do however save A LOT by batching in this case, although this does not change the framerate.
    *adding a simple script to make every quad billboarding the camera (why do I do that, well because with a sphere it does not matter from where you look at it, something not true for a quad except if you make it billboard the camera) made things very bad => we are better off using spheres in this case.

    I feel stuck at this point. I have 10,000 spheres with no rigidbodies or colliders. I have an unlit shader with a unicolor png file. What I can I do from here to increase the framerate? I was convinced that having quads billboarding the camera with a texture of a circle on it would be better, but even with only a squared unicolor quad (thus no circle on the quad yet), the billboarding routine seems much more expensive than drawing spheres.

    Please throw away any suggestion and I will test it and tell you if it worked.
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Use the profiler to tell you where the bottleneck is, then focus on that.

    --Eric
     
  3. Thomas12

    Thomas12

    Joined:
    Dec 24, 2014
    Posts:
    36
    Didn't know about the profiler.

    On the GPU side: Camera.Render 100% = 60% RenderTexture.SetActive + 39.4% for drawing.
    On the CPU side: Camera.Render 97.2% = 81.6% Drawing and 15.4% Culling.

    What now? Any tips (or suggestion for reading)?
     
  4. Ippokratis

    Ippokratis

    Joined:
    Oct 13, 2008
    Posts:
    1,521
    I guess you want to exercise, right ?
    You could try your hand at the Viking village project instead, it could prove more educational.
     
  5. Thomas12

    Thomas12

    Joined:
    Dec 24, 2014
    Posts:
    36
    I don't know what that is, but be sure I'm going to check that out :)
     
  6. Ippokratis

    Ippokratis

    Joined:
    Oct 13, 2008
    Posts:
    1,521