Hello everyone.

The Mixed Reality Forums here are no longer being used or maintained.

There are a few other places we would like to direct you to for support, both from Microsoft and from the community.

The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.

For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.

If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.

And always feel free to hit us up on Twitter @MxdRealityDev.

Hololens and Unity ParticleSystem

TachoronTachoron
edited November 2017 in Questions And Answers

Hi Guys,

I draw 3D-Graphs with HoloLens and the Unity Particle System.

Example:

But i have really problems with the Framerate. For the Example Graph with 100x100 = 10.000 Particles and the HoloLens FastConfigurable Shader without any additional LightEffects the Framerate drops at ca. 10FPS.

Has a anyone an idea to increase the Framerate:

  • Is there an option to optimize the Shader?
  • Are there Settings to Tweak the Particle System?
  • Any other Unity Performance Tweaks? I tried Single Pass Stereo Rendering but there are no Performance improvements.

Thanks for any Help!

Best
Regards

Tagged:

Answers

  • I did one a while ago using formula . I think I did not see any frame drops.
    How are the graphs generated?

  • TachoronTachoron
    edited November 2017

    This Way:

    public class Graph : MonoBehaviour
    {
    
        public bool MeasurementRunning = false;
    
        [Range(10, 100)]
        public int X_Resolution = 100;
        private int X_CurrentResolution;
    
        [Range(10, 100)]
        public int Z_Resolution = 100;
        private int Z_CurrentResolution;
    
        private ParticleSystem.Particle[] AllParticles;
    
        //Possible Functions
        public enum FunctionOption
        {
            Sine,
        }
        public FunctionOption GraphFunction;
    
        //Function Delegates
        private delegate float FunctionDelegate(Vector3 p, float t);
        private static FunctionDelegate[] functionDelegates = {
            Sine,
        };
    
        void Start()
        {
            CreatePoints();
        }
    
        private void CreatePoints()
        {
            if (X_Resolution < 10 || X_Resolution > 100 ||
                Z_Resolution < 10 || Z_Resolution > 100)
            {
                Debug.LogWarning("Grapher resolution out of bounds, resetting to minimum.", this);
                X_Resolution = 10;
                Z_Resolution = 10;
            }
    
            X_CurrentResolution = X_Resolution;
            Z_CurrentResolution = Z_Resolution;
    
            AllParticles = new ParticleSystem.Particle[X_Resolution * Z_Resolution];
    
            float X_Increment = 1f / (X_Resolution - 1);
            float Z_Increment = 1f / (Z_Resolution - 1);
            int i = 0;
            for (int x = 0; x < X_Resolution; x++)
            {
                for (int z = 0; z < Z_Resolution; z++)
                {
                    Vector3 p = new Vector3(x * X_Increment, 0f, z * Z_Increment);
                    AllParticles[i].position = p;
                    AllParticles[i].startColor = new Color(p.x, 0f, p.z);
                    AllParticles[i].startSize = 0.1f;
                    i++;
                }
            }
        }
    
        void Update()
        {
            if ((X_CurrentResolution != X_Resolution) ||
                (Z_CurrentResolution != Z_Resolution) ||
                (AllParticles == null))
            {
                CreatePoints();
            }
    
            FunctionDelegate f = functionDelegates[(int)GraphFunction];
            float t = Time.timeSinceLevelLoad / 5;
    
                for (int i = 0; i < AllParticles.Length; i++)
                {
                     Vector3 p = AllParticles[i].position;
                     p.y = f(p, t);
                     AllParticles[i].position = p;
    
                     Color c = AllParticles[i].GetCurrentColor(GetComponent<ParticleSystem>());
                     c.g = p.y;
                     c.r = 1f - p.y;
                     AllParticles[i].startColor = c;
                }
    
            GetComponent<ParticleSystem>().SetParticles(AllParticles, AllParticles.Length);
        }
    
    
        private static float Sine(Vector3 p, float t)
        {
            return 0.50f +
                0.25f * Mathf.Sin(4f * Mathf.PI * p.x + 4f * t) * Mathf.Sin(2f * Mathf.PI * p.z + t) +
                0.10f * Mathf.Cos(3f * Mathf.PI * p.x + 5f * t) * Mathf.Cos(5f * Mathf.PI * p.z + 3f * t) +
                0.15f * Mathf.Sin(Mathf.PI * p.x + 0.6f * t);
        }
    
    }
    
  • Hi,

    have you resolved your performance problem ?
    I encounter a similar issue.

Sign In or Register to comment.