Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Radial Grid (Unity3D 2018b Shader Graph) (GPU issue)

Discussion in 'Shaders' started by Antypodish, Apr 19, 2018.

  1. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    7,289
    Hi all.


    Firstly, this topic I think falls anything between Graphics, Shaders, and Unity Experimental 2018).


    Introduction

    I was attempting to create radial grid, but not sure if my approach was correct here. I used shaders instead of textures, due to the fact, that I would need higher resolution of the radial grid. But hit bad GPU performance, caused by shaders of the circular grid.

    The video shows briefly what I did (with caption text, but sorry no voice).



    0:00 - Start
    2:59 - Shader Graph
    4:30 - Shader - GPU bad performance

    On the video you can see two circular grids. Horizontal and vertical.


    Describing circular grid

    So in principle, I have created shader, which is applied by script on the objects. Each object is rendering 9 circles of same width via material. There is 20 objects per each set. And there is 3 set (small, medium, large), which are scaled by 1, 10, 100 factor. This gives better perception, of which grid you are looking at, yet gives high distance grid capabilities. But not required to generate smallest circular grid far away. So in total, there is 60 renderable objects per circular grid.

    Camera movement allows to scale whole group of such set, by log10 of the distance.

    Shader is constructed of 9 sub-shaders, of which all are blended together, to generate map. Each 1 of 9 subsets is created of 2 procedural generated white circles, of slightly different radius, which by blending and differentiating, generate the rim. So in the result, I got 9 rims per shader.

    At the start, cs script generates objects, and apply radius offset to the shader and scale objects respectively.



    GPU issue.

    However, I have experienced with this method, high GPU usage, reducing my fps to round 30 fps, caused by Gfx.WaitForPresent

    Completely not expected that.

    So I understand that I have either too many different shaders, or I have something very none optimized.


    Mind, I was using Unity 2018 b13, Shader Graph, as I am not shader expert by any means.


    Question on any ideas

    So my question is, how I could fix the issue. Or should I change the approach completely, to generate circular grid? Is the shader approach even right one?

    Any suggestions are welcome.


    Many thx
    Anty
     
  2. Deleted User

    Deleted User

    Guest

    any chance of a unityproject of this?
    couldnt it just be planes with a texture?
     
    GameDevCouple likes this.
  3. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    7,289
    Hi, I can share the Shader Graph bit. But rest is part of the bigger project, which currently is not suitable for sharing, as I am using html5 to generate animations.

    Problem with texture as such, is the resolution vs size of texture. As you want to look up closer at the grid, you will see pixels. Or you need much bigger resolution of textures.

    In fact, now I reworked shader part and learned to write my own shader for radial grid system, instead using Shader Graphs. Works much better, but still need tweaks.And is using only few objects.
     
unityunity