private ShadingLine GetShadingLine()
 {
     Vector3 fromPoint = fromObject.transform.localToWorldMatrix.MultiplyPoint(new Vector3(0.0f, 0.0f, 0.0f));
     Vector3 toPoint   = toObject.transform.localToWorldMatrix.MultiplyPoint(new Vector3(0.0f, 0.0f, 0.0f));
     ShadingLine line = new ShadingLine ();
     line.Add (new ShadingLinePoint (fromPoint, this.color));
     line.Add (new ShadingLinePoint (toPoint, this.color));
     return line;
 }
        private List<ShadingLine> GetSpecularShadingLine(Vector3 lightDirection, Vector3 normal, int nDistro)
        {
            
            Vector3 lightU = Vector3.Dot (-lightDirection, normal) * normal;
            Vector3 lightH = -lightDirection - lightU;
            Vector3 reflect = (-lightDirection - 2.0f * lightH).normalized;

            List<ShadingLine> shadingLines = new List<ShadingLine> ();
            {
                ShadingLine line = new ShadingLine ();
                line.Add( new ShadingLinePoint( new Vector3(), Color.blue ));
                line.Add( new ShadingLinePoint( reflect, Color.blue ));
                shadingLines.Add (line);
            }

            if (Vector3.Dot (lightDirection, normal) > 0)
            {
                return shadingLines;
            }

            float PhongPower = shadingUIController.PhongPower;
            float PhongIntensity = 1.0f;
            while(shadingLines.Count < nDistro+1)
            {
                Vector3 v = GetDistVector ();//-view direction
                if (Vector3.Dot (v, reflect) < 0.0f)
                {
                    v = -v;
                }
                if (Vector3.Dot (v, normal) > 0)
                {
                    float p = Mathf.Pow(Mathf.Abs(Vector3.Dot (reflect, v)), PhongPower) * PhongIntensity;
                    if (p > 0.001)
                    {
                        ShadingLine line = new ShadingLine ();
                        line.Add (new ShadingLinePoint (new Vector3 (), Color.red));
                        line.Add (new ShadingLinePoint (p * v, Color.red));
                        shadingLines.Add (line);
                    }
                }
            }
            return shadingLines;
        }
        void Update()
        {
            Light l = fromObject.GetComponent<Light> ();
            if (l != null)
            {
                this.color = l.color;
            }

            Matrix4x4 lineMat = directionObject.transform.worldToLocalMatrix;
            this.LightLine = GetShadingLine();

            Vector3 fromPoint = lineMat.MultiplyVector (LightLine.Points[0].Position);
            Vector3 toPoint = lineMat.MultiplyVector (LightLine.Points[1].Position);
            if (this.directionObject != null)
            {
                ShadingLine line = new ShadingLine();
                line.Add( new ShadingLinePoint(fromPoint, color) );
                line.Add( new ShadingLinePoint(toPoint, color) );
                ShadingLineController shadingLineController = directionObject.GetComponent<ShadingLineController>();
                shadingLineController.Initialize (line);
            }
        }