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. Dismiss Notice

Overlap vs Non overlap draw

Discussion in 'Scripting' started by sabin, Dec 8, 2014.

  1. sabin

    sabin

    Joined:
    Nov 24, 2012
    Posts:
    34
    Can anyone explain why its gives low frame rates when drawing circles one on top(over drawing circles with different radius and different material)?. Is there any way to achieve good FPS?. I am using Non transparent shader.

    OverlapCircleDraw.png Non OverLapCircel Draw.png
     
    Last edited: Dec 8, 2014
  2. Fluzing

    Fluzing

    Joined:
    Apr 5, 2013
    Posts:
    815
    Look up Drawcalls. That is probably what is killing the frame rate.
     
  3. sabin

    sabin

    Joined:
    Nov 24, 2012
    Posts:
    34
    I am getting 72 Drawcalls in both cases. But FPS have huge deference, may be because of drawing one on top. any way to avoid this?
     
    Last edited: Dec 8, 2014
  4. Fluzing

    Fluzing

    Joined:
    Apr 5, 2013
    Posts:
    815
    How are you drawing them exactly?
     
  5. sabin

    sabin

    Joined:
    Nov 24, 2012
    Posts:
    34
    I am drawing them one on top just like this. But camera will on top of the stack. stack.jpg on on top.
     
  6. Fluzing

    Fluzing

    Joined:
    Apr 5, 2013
    Posts:
    815
    No, I mean what does your code look like.
     
  7. sabin

    sabin

    Joined:
    Nov 24, 2012
    Posts:
    34
    you mean shader Code?
    Code (CSharp):
    1. Shader "Custom/SolidColor" {
    2.     SubShader {
    3.         Pass {
    4.             CGPROGRAM
    5.  
    6.             #pragma vertex vert
    7.             #pragma fragment frag
    8.  
    9.             float4 vert(float4 v:POSITION) : SV_POSITION {
    10.                 return mul (UNITY_MATRIX_MVP, v);
    11.             }
    12.  
    13.             fixed4 frag() : COLOR {
    14.                 return fixed4(1.0,1.0,1.0,1.0);
    15.             }
    16.  
    17.             ENDCG
    18.         }
    19.     }
    20. }
    There is no CPU code(except material creation). Just duplicated in editor and added material at run time.
     
  8. Fluzing

    Fluzing

    Joined:
    Apr 5, 2013
    Posts:
    815
    The problem probably lies with the material creation. Try creating the material, storing it and then assigning it to the objects.
     
  9. sabin

    sabin

    Joined:
    Nov 24, 2012
    Posts:
    34
    If that was the problem why not its happening in non overlapping case. I think its because of drawing one on top. Since i am not good in graphics i couldn't be able find the reason.