Ejemplo n.º 1
0
        public override DrawStackNode Allocate(DrawInfo info, SurfaceTexture tex, ref int stackID)
        {
            // Stack required.

            // Allocate a target stack now:
            int       targetStack = stackID;
            DrawStack stack       = tex.GetStack(targetStack, info);

            stackID++;

            int subID = SubMaterialID;

            // Create the material:
            Material material = GetMaterial(TypeID, subID);

            // _Data (Seed, Frequency, Amplitude, Jitter):
            material.SetVector(
                "_Data",
                DataVector
                );

            if (subID == 3)
            {
                // Minkowski number required.

                // Get the input node:
                TextureNode input = MinkowskiNumber;

                // Allocate it now (must not allocate targetStack in the direct kids):
                int           inputStacks = (targetStack == 0)?1:0;
                DrawStackNode drawNode    = input.Allocate(info, tex, ref inputStacks);

                // Apply it to our material:
                material.SetTexture("_Src0", drawNode.Texture);
            }

            // Create our node:
            MaterialStackNode matNode = new MaterialStackNode();

            DrawStore        = matNode;
            matNode.Mesh     = info.Mesh;
            matNode.Material = material;
            matNode.Stack    = stack;

            return(matNode);
        }
Ejemplo n.º 2
0
        public override DrawStackNode Allocate(DrawInfo info, SurfaceTexture tex, ref int stackID)
        {
            // Stack required.

            // Allocate a target stack now:
            int       targetStack = stackID;
            DrawStack stack       = tex.GetStack(targetStack, info);

            stackID++;

            // Allocate sources all to use the exact same stack for their output:

            for (int i = 0; i < Sources.Length; i++)
            {
                // Get the input node:
                TextureNode input = Sources[i];

                // Allocate it now, always allocating the same one as our target:
                int           inputStacks = targetStack;
                DrawStackNode dsn         = input.Allocate(info, tex, ref inputStacks);

                // If it's cleared, set cleared to false for anything but i=0:
                if (i != 0)
                {
                    dsn.Clear = false;
                }
            }

            // Create our node:
            StackerStackNode matNode = DrawStore as StackerStackNode;

            if (matNode == null)
            {
                matNode   = new StackerStackNode();
                DrawStore = matNode;
            }

            matNode.Stack = stack;

            return(matNode);
        }
Ejemplo n.º 3
0
        public override DrawStackNode Allocate(DrawInfo info, SurfaceTexture tex, ref int stackID)
        {
            // Stack required.

            // Allocate a target stack now:
            int       targetStack = stackID;
            DrawStack stack       = tex.GetStack(targetStack, info);

            stackID++;

            int subID = SubMaterialID;

            // Create the material:
            Material material = GetMaterial(TypeID, subID);

            // Allocate Src0:
            TextureNode   input       = Sources[0];
            int           inputStacks = (targetStack == 0)?1:0;
            DrawStackNode drawNode    = input.Allocate(info, tex, ref inputStacks);

            // Apply it to our material:
            material.SetTexture("_Src0", drawNode.Texture);

            // _Data (Rx,Ry,Rx,-Ry):
            material.SetVector(
                "_Data",
                GetDataVector(info)
                );

            // Create our node:
            MaterialStackNode matNode = new MaterialStackNode();

            DrawStore        = matNode;
            matNode.Mesh     = info.Mesh;
            matNode.Material = material;
            matNode.Stack    = stack;

            return(matNode);
        }
Ejemplo n.º 4
0
        protected void AllocateSources(Material material, DrawInfo info, SurfaceTexture tex, int targetStack, int count)
        {
            int inputStacks = (targetStack == 0)?1:0;

            for (int i = 0; i < count; i++)
            {
                // Get the input node:
                TextureNode input = Sources[i];

                // Allocate it now (must not allocate targetStack in the direct kids):

                DrawStackNode drawNode = input.Allocate(info, tex, ref inputStacks);

                if (inputStacks == targetStack)
                {
                    // Skip:
                    inputStacks++;
                }

                // Apply it to our material:
                material.SetTexture("_Src" + i, drawNode.Texture);
            }
        }
Ejemplo n.º 5
0
        /// <summary>Allocates GPU drawing meta now.</summary>
        public virtual DrawStackNode Allocate(DrawInfo info, SurfaceTexture tex, ref int stackID)
        {
            // If the source is a constant or a graph
            // then we don't allocate a material for it.
            // We do, however, create a texture:

            // CONSTANT: 1 * 1 (Texture)
            // GRAPH   : info.ImageX * 1 (Texture)
            // ELSE    : info.ImageX * info.ImageY (Stack)

            int dimensions = OutputDimensions;

            if (dimensions == 2)
            {
                // Stack required.

                // Allocate a target stack now:
                int       targetStack = stackID;
                DrawStack stack       = tex.GetStack(targetStack, info);
                stackID++;

                // Create the material:
                Material material = GetMaterial(MaterialID, SubMaterialID);

                if (Sources != null)
                {
                    int inputStacks = (targetStack == 0)?1:0;

                    for (int i = 0; i < Sources.Length; i++)
                    {
                        // Get the input node:
                        TextureNode input = Sources[i];

                        // Allocate it now (must not allocate targetStack in the direct kids):

                        DrawStackNode drawNode = input.Allocate(info, tex, ref inputStacks);

                        if (inputStacks == targetStack)
                        {
                            // Skip:
                            inputStacks++;
                        }

                        // Apply it to our material:
                        material.SetTexture("_Src" + i, drawNode.Texture);
                    }
                }

                // Create our node:
                MaterialStackNode matNode = DrawStore as MaterialStackNode;

                if (matNode == null)
                {
                    matNode      = new MaterialStackNode();
                    DrawStore    = matNode;
                    matNode.Mesh = info.Mesh;
                }

                matNode.Material = material;
                matNode.Stack    = stack;

                return(matNode);
            }

            // It'll be baked/ drawn by the CPU.

            // Get the width of the texture:
            int width = (dimensions == 1)?info.ImageX : 1;

            TextureStackNode constNode = DrawStore as TextureStackNode;

            if (constNode == null)
            {
                constNode = new TextureStackNode(this, info.HDR, width);
                DrawStore = constNode;
            }

            // Ok:
            return(constNode);
        }