private bool ComputeHeatmapColorAt(Vector2 currPnt, Vector2 origPivot, out Color?col)
        {
            col = null;


            float spread              = drawBrushSize;
            float amplitude           = drawIntensity;
            float distCenterToCurrPnt = Vector2.Distance(origPivot, currPnt) / spread;

            float B = 2f;
            float scaledInterest = 1 / (1 + Mathf.Pow(Mathf.Epsilon, -(B * distCenterToCurrPnt)));
            float delta          = scaledInterest / amplitude;

            if (delta < minThreshDeltaHeatMap)
            {
                return(false);
            }

            Color baseColor          = MyDrawTexture.GetPixel((int)currPnt.x, (int)currPnt.y);
            float normalizedInterest = Mathf.Clamp(baseColor.a + delta, 0, 1);

            // Get color from given heatmap ramp
            if (HeatmapLookUpTable != null)
            {
                col = HeatmapLookUpTable.GetPixel((int)(normalizedInterest * (HeatmapLookUpTable.width - 1)), 0);
                col = new Color(col.Value.r, col.Value.g, col.Value.b, normalizedInterest);
            }
            else
            {
                col = Color.blue;
                col = new Color(col.Value.r, col.Value.g, col.Value.b, normalizedInterest);
            }

            return(true);
        }
        private IEnumerator DrawAt(Vector2 posUV)
        {
            if (MyDrawTexture != null)
            {
                // Reset on first draw
                if (neverDrawnOn)
                {
                    for (int ix = 0; ix < MyDrawTexture.width; ix++)
                    {
                        for (int iy = 0; iy < MyDrawTexture.height; iy++)
                        {
                            MyDrawTexture.SetPixel((int)(ix), (int)(iy), new Color(0, 0, 0, 0));
                        }
                    }
                    neverDrawnOn = false;
                }

                // Assign colors
                yield return(null);

                StartCoroutine(ComputeHeatmapAt(posUV, true, true));
                yield return(null);

                StartCoroutine(ComputeHeatmapAt(posUV, true, false));
                yield return(null);

                StartCoroutine(ComputeHeatmapAt(posUV, false, true));
                yield return(null);

                StartCoroutine(ComputeHeatmapAt(posUV, false, false));
                yield return(null);

                MyDrawTexture.Apply();
            }
        }
        private void DrawAt(Vector2 posUV, Color col)
        {
            if (MyDrawTexture != null)
            {
                Debug.LogFormat("New draw point at ( {0}; {1} )", posUV.x, posUV.y);
                MyDrawTexture.SetPixel(
                    (int)(posUV.x * MyDrawTexture.width),
                    (int)(posUV.y * MyDrawTexture.height),
                    col);

                MyDrawTexture.Apply();
            }
        }
        private IEnumerator ComputeHeatmapAt(Vector2 currPosUV, bool positiveX, bool positiveY)
        {
            yield return(null);

            // Determine the center of our to be drawn 'blob'
            Vector2 center  = new Vector2(currPosUV.x * MyDrawTexture.width, currPosUV.y * MyDrawTexture.height);
            int     sign_x  = (positiveX) ? 1 : -1;
            int     sign_y  = (positiveY) ? 1 : -1;
            int     start_x = (positiveX) ? 0 : 1;
            int     start_y = (positiveY) ? 0 : 1;

            for (int dx = start_x; dx < MyDrawTexture.width; dx++)
            {
                float tx = currPosUV.x * MyDrawTexture.width + dx * sign_x;
                if ((tx < 0) || (tx >= MyDrawTexture.width))
                {
                    break;
                }

                for (int dy = start_y; dy < MyDrawTexture.height; dy++)
                {
                    float ty = currPosUV.y * MyDrawTexture.height + dy * sign_y;
                    if ((ty < 0) || (ty >= MyDrawTexture.height))
                    {
                        break;
                    }

                    Color?newColor = null;
                    if (ComputeHeatmapColorAt(new Vector2(tx, ty), center, out newColor))
                    {
                        if (newColor.HasValue)
                        {
                            MyDrawTexture.SetPixel((int)(tx), (int)(ty), newColor.Value);
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }
        }
        private void DrawAt2(Vector2 posUV, int maxRadius, float intensity)
        {
            if (MyDrawTexture != null)
            {
                // Reset on first draw
                if (neverDrawnOn)
                {
                    for (int ix = 0; ix < MyDrawTexture.width; ix++)
                    {
                        for (int iy = 0; iy < MyDrawTexture.height; iy++)
                        {
                            MyDrawTexture.SetPixel((int)(ix), (int)(iy), new Color(0, 0, 0, 0));
                        }
                    }
                    neverDrawnOn = false;
                }

                // Determine the center of our to be drawn 'blob'
                Vector2 center = new Vector2(posUV.x * MyDrawTexture.width, posUV.y * MyDrawTexture.height);

                // Determine appropriate radius based on viewing duration: The longer looking in a small region the larger the radius
                float dist = maxRadius;
                for (int ix = -(int)(dynamicRadius / 2); ix < dynamicRadius / 2; ix++)
                {
                    for (int iy = -(int)(dynamicRadius / 2); iy < dynamicRadius / 2; iy++)
                    {
                        float tx = posUV.x * MyDrawTexture.width + ix;
                        float ty = posUV.y * MyDrawTexture.height + iy;

                        Vector2 currPnt = new Vector2(tx, ty);

                        float distCenterToCurrPnt = Vector2.Distance(center, currPnt);

                        if (distCenterToCurrPnt <= dynamicRadius / 2)
                        {
                            float normalizedDist = (distCenterToCurrPnt / dynamicRadius / 2); // [0.0, 1.0]
                            float B = 4f;
                            float localNormalizedInterest = Mathf.Clamp(1 / (1 + Mathf.Pow(Mathf.Epsilon, -(B * normalizedDist))), 0, 1);

                            Color baseColor = MyDrawTexture.GetPixel((int)tx, (int)ty);
                            float delta     = intensity * (1 - Mathf.Abs(localNormalizedInterest));

                            float normalizedInterest = baseColor.a + delta;
                            Color col = Color.red;
                            // Get color from  given heatmap ramp
                            if (HeatmapLookUpTable != null)
                            {
                                col = HeatmapLookUpTable.GetPixel((int)(normalizedInterest * HeatmapLookUpTable.width), 0);
                                col = new Color(col.r, col.g, col.b, normalizedInterest);
                            }
                            else
                            {
                                col = new Color(col.r, col.g, col.b, normalizedInterest);
                            }


                            MyDrawTexture.SetPixel((int)(tx), (int)(ty), col);

                            Color baseColor2 = MyDrawTexture.GetPixel((int)tx, (int)ty);
                        }
                    }
                }

                MyDrawTexture.Apply();
            }
        }