Exemple #1
0
		public Color UnpackNormal( Color c ) {
			Vector3 normal = Vector3.zero;

			normal = new Vector2( c.a, c.g ) * 2f - Vector2.one;
			normal.z = Mathf.Sqrt( 1f - normal.x * normal.x - normal.y * normal.y );

			// TODO: Check color clamp method!
			return SF_Tools.VectorToColor( normal );
		}
Exemple #2
0
        public override Vector4 EvalCPU()
        {
            if (!GetInputIsConnected("IN"))
            {
                return(Color.black);
            }


            Vector4 c = GetInputData("IN").dataUniform;
            Vector4 k = new Vector4(0, -1f / 3f, 2f / 3f, -1f);
            Vector4 p = Vector4.Lerp(new Vector4(c.z, c.y, k.w, k.z), new Vector4(c.y, c.z, k.x, k.y), Step(c.z, c.y));
            Vector4 q = Vector4.Lerp(new Vector4(p.x, p.y, p.w, c.x), new Vector4(c.x, p.y, p.z, p.x), Step(p.x, c.x));
            float   d = q.x - Mathf.Min(q.w, q.y);
            float   e = Mathf.Epsilon;

            Vector3 rgb = new Vector3();

            rgb.x = Mathf.Abs(q.z + (q.w - q.y) / (6f * d + e));
            rgb.y = d / (q.x + e);
            rgb.z = q.x;


            return(SF_Tools.VectorToColor(rgb));
        }