Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

Shader Complexity

Discussion in 'General Graphics' started by FuzzyShan, Jun 25, 2018.

  1. FuzzyShan

    FuzzyShan

    Joined:
    Jul 30, 2012
    Posts:
    174
    https://docs.unrealengine.com/en-us/Engine/UI/LevelEditor/Viewports/ViewModes#shadercomplexity

    Hi, I want to create something like this, my knowledge with creating something like this is limited. So I was hoping some experts in Unity would able to answer my questions about this.

    So my idea creating this for unity would be
    1. getting all the materials and its shader currently been rendered on the screen. So I am thinking about getting all the mesh renderer that's visible then iterate through all the material to get all the shaders.
    2. after getting all the shaders... is there a way to determine the instructions count for each shader during runtime? if not I guess I would have to create an asset that's keep track all the shader's instruction count for different platforms...
    3. after getting all the instructions I will then need to write to different material using a special shader which final fragment color is returned with the number of instructions count that I assume should be normal(is there a way to calculate on current platform what is the normal instruction count?).
    4. lastly, I will then render the final texture to camera.
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    7,652
    This is the tripping point you'll have. Unity does not provide a way to do this. You would have to select each shader by hand and click on the "Compiled Shader" button, then find the instruction count in the txt file that generates and copy that into another file by hand. There is no way to do this from code!

    It should also be noted that Unreal's implementation is also very approximate, and really only good for getting a rough idea of where you have overdraw problems. It's totally wrong for opaque objects!
     
  3. FuzzyShan

    FuzzyShan

    Joined:
    Jul 30, 2012
    Posts:
    174
    Hi, I totally understand that, having 2 different functions would mean totally different processing speed, however it is still good to have an estimate, maybe once the system is there, I could get more information and go from there, I just think this is very good for visually trying to findout what's going on, maybe if framedebugger exposed runtime API, i would able to do more about the informations. I think one key is even if I manually compiled those, how do i get the instruction count?