예제 #1
0
        public override void Calculate()
        {
            base.Calculate();

//			if (!verified)
//				return;
            if (!changed)
            {
                return;
            }
//			CTextureNode ShininessMap = (CTextureNode)getNode (Inputs, 0);
            CTextureNode Heightmap = (CTextureNode)getNode(Inputs, 0);
            CTextureNode ColorMap  = (CTextureNode)getNode(Inputs, 1);
            CTextureNode NormalMap = (CTextureNode)getNode(Inputs, 2);

            if (NormalMap == null || ColorMap == null || Heightmap == null)
            {
                return;
            }



            Heightmap.Calculate();
            ColorMap.Calculate();
            NormalMap.Calculate();


/*			if (ShininessMap!=null)
 *                              ShininessMap.Calculate();
 */
            changed = false;
        }
예제 #2
0
        public override void GenerateTexture()
        {
            foreach (CConnection ct in Inputs)
            {
                if (ct.pointer != null)
                {
                    if (ct.pointer.parent != null)
                    {
                        ((CTextureNode)ct.pointer.parent).GenerateTexture();
                    }
                }
            }
            CTextureNode m1 = (CTextureNode)getNode(Inputs, 0);

            CNodeManager.Progress();
            if (m1 == null)
            {
                return;
            }
            if (!updateTexture)
            {
                return;
            }
            map.CopyFrom(m1.map);
            map.Normalize(1);
            texture = NormalMap.CreateDOT3(m1.map, getValue("contrast") * 1.5f, 0);
            CNodeManager.Progress();
            updateTexture = false;
        }
예제 #3
0
        public override void Calculate()
        {
            base.Calculate();

            if (!verified)
            {
                return;
            }

            if (!changed)
            {
                return;
            }

            CTextureNode m1 = (CTextureNode)getNode(Inputs, 0);

            if (m1 == null)
            {
                return;
            }
            m1.Calculate();

            float curvtype = getValue("curvtype");
            float scale    = getValue("scale");


            if (normals == null)
            {
                normals = new Vector3[C2DMap.sizeX, C2DMap.sizeY];
            }
            if (normals.GetLength(0) != C2DMap.sizeX)
            {
                normals = new Vector3[C2DMap.sizeX, C2DMap.sizeY];
            }

            m1.map.calculateNormals(100, normals);


            for (int i = 0; i < C2DMap.sizeX; i++)
            {
                for (int j = 0; j < C2DMap.sizeY; j++)
                {
                    map [i, j] = m1.map.getCurvature(i, j, scale, (int)curvtype, normals);
                }
            }
            //map.Smooth(1);


            map.ScaleMap(getValue("amplitude"), 0);
            GenerateHeightTexture();
            CNodeManager.Progress();
            updateTexture = true;

            changed = false;
        }
예제 #4
0
        public override void Calculate()
        {
            base.Calculate();
            if (!verified)
            {
                return;
            }

            CTextureNode m1 = (CTextureNode)getNode(Inputs, 0);

            if (m1 == null)
            {
                verified = false;
                return;
            }

            m1.Calculate();

            if (!changed)
            {
                return;
            }

            float curvtype = getValue("curvtype");
            float scale    = getValue("scale");
            Color c1       = getColor("color1");

            if (normals == null)
            {
                normals = new Vector3[C2DMap.sizeX, C2DMap.sizeY];
            }
            if (normals.GetLength(0) != C2DMap.sizeX)
            {
                normals = new Vector3[C2DMap.sizeX, C2DMap.sizeY];
            }

            m1.map.calculateNormals(100, normals);
            for (int i = 0; i < C2DMap.sizeX; i++)
            {
                for (int j = 0; j < C2DMap.sizeY; j++)
                {
                    colors.colors [i, j] = c1 * Mathf.Pow(m1.map.getCurvature(i, j, scale, (int)curvtype, normals), 1);
                }
            }
            colors.Smooth(1);
            updateTexture = true;
            CNodeManager.Progress();

            changed = false;
        }
예제 #5
0
        public override void Calculate()
        {
            base.Calculate();
            if (!verified)
            {
                return;
            }

            CTextureNode m1 = (CTextureNode)getNode(Inputs, 0);

            if (m1 == null)
            {
                verified = false;
                return;
            }

            m1.Calculate();

            if (!changed)
            {
                return;
            }

            float scale = getValue("scale");
            float power = getValue("power");
            Color c1    = getColor("color1");
            Color c2    = getColor("color2");

            Color c = new Color(1, 1, 1);

            for (int i = 0; i < C2DMap.sizeX; i++)
            {
                for (int j = 0; j < C2DMap.sizeY; j++)
                {
                    float val = Mathf.SmoothStep(0, 1.0f, m1.map [i, j] - scale + 0.75f);
                    val = Mathf.Clamp(Mathf.Pow(val, power), 0, 1);
                    c   = c1 * val + c2 * (1 - val);
                    colors.colors [i, j] = c;
                }
            }
            updateTexture = true;
            CNodeManager.Progress();

            changed = false;
        }
예제 #6
0
        public void CalculateTextures()
        {
            CTextureNode Heightmap = (CTextureNode)getNode(Inputs, 0);
            CTextureNode ColorMap  = (CTextureNode)getNode(Inputs, 1);
            CTextureNode NormalMap = (CTextureNode)getNode(Inputs, 2);

            if (NormalMap == null || ColorMap == null || Heightmap == null)
            {
                return;
            }
            Heightmap.GenerateTexture();
            ColorMap.GenerateTexture();
            NormalMap.GenerateTexture();

            MaterialPreviewEditor.SetTextures(NormalMap.texture, Heightmap.texture, ColorMap.texture, MaterialPreviewEditor.currentMaterial);
            MaterialPreviewEditor.forceRepaint();
            CNodeManager.Progress();
        }
예제 #7
0
        public void Export(string file)
        {
//			CTextureNode ShininessMap = (CTextureNode)getNode (Inputs, 0);
            CTextureNode HeightMap = (CTextureNode)getNode(Inputs, 0);
            CTextureNode ColorMap  = (CTextureNode)getNode(Inputs, 1);
            CTextureNode NormalMap = (CTextureNode)getNode(Inputs, 2);

            string FileNormalMap = file + "_Normal";
            string FileColorMap  = file + "_Color";
            string FileHeightMap = file + "_Height";

            MaterialPreviewEditor.forceRepaint();

            if (NormalMap != null)
            {
                Util.SaveTextureFile(NormalMap.texture, "", FileNormalMap);
            }

            if (ColorMap != null)
            {
                Util.SaveTextureFile(ColorMap.texture, "", FileColorMap);
            }

            if (HeightMap != null)
            {
                Util.SaveTextureFile(HeightMap.texture, "", FileHeightMap);
            }

            AssetDatabase.Refresh();
            try {
                Material mat = new Material(file);                                                 //MaterialPreviewEditor.currentMaterial;
                AssetDatabase.CreateAsset(mat, file + ".mat");
                mat.shader = MaterialPreviewEditor.currentMaterial.shader;

                Texture2D T_hm = (Texture2D)AssetDatabase.LoadAssetAtPath(FileHeightMap + ".png", typeof(Texture2D));
                Texture2D T_c  = (Texture2D)AssetDatabase.LoadAssetAtPath(FileColorMap + ".png", typeof(Texture2D));
//			Texture2D T_ex = (Texture2D)AssetDatabase.LoadAssetAtPath(FileExtraMap + ".png", typeof(Texture2D));
                Texture2D T_nr = (Texture2D)AssetDatabase.LoadAssetAtPath(FileNormalMap + ".png", typeof(Texture2D));
                MaterialPreviewEditor.SetTextures(T_nr, T_hm, T_c, mat);
                MaterialPreviewEditor.SetProperties(mat);
            } catch (System.Exception e) {
                Debug.Log(e.Message);
            }
        }
예제 #8
0
        public override void Calculate()
        {
            //base.Calculate();

            if (!verified)
            {
                return;
            }

            if (!changed)
            {
                return;
            }


            CTextureNode combiner   = (CTextureNode)getNode(Inputs, 0);
            CTextureNode m1         = (CTextureNode)getNode(Inputs, 1);
            CTextureNode m2         = (CTextureNode)getNode(Inputs, 2);
            C2DMap       combineMap = null;

            if (combiner != null)
            {
                combiner.Calculate();
                combineMap = combiner.map;
            }
            if (m1 == null || m2 == null)
            {
                verified = false;
                return;
            }
            m1.Calculate();
            m2.Calculate();

//			map.Combine(m1.map, m2.map, combineMap, getValue("blendval"), Type);
            colors.Combine(m1.colors, m2.colors, combineMap, getValue("blendval"), Type);
            updateTexture = true;

            colors.Scale(getValue("amplitude"));
            //map.ScaleMap(getValue("amplitude"),0);
            //GenerateHeightTexture();
            CNodeManager.Progress();
            changed = false;
        }
예제 #9
0
        public override void Calculate()
        {
            if (!verified)
            {
                return;
            }

            if (!changed)
            {
                return;
            }
            CTextureNode m1 = (CTextureNode)getNode(Inputs, 0);

            if (m1 == null)
            {
                verified = false;
                return;
            }
            m1.Calculate();
            updateTexture = true;
            //		float scale = getValue("scale");
            map.CopyFrom(m1.map);
        }
예제 #10
0
        public override void Calculate()
        {
            base.Calculate();

            if (!verified)
            {
                return;
            }

            if (!changed)
            {
                return;
            }

            CTextureNode m1 = (CTextureNode)getNode(Inputs, 0);

            if (m1 == null)
            {
                return;
            }
            m1.Calculate();
            map.CopyFrom(m1.map);
            float ascale = 1;

            if (Type == TYPE_SMOOTH)
            {
                map.Smooth((int)(getValue("value1") * 40f), (int)(getValue("value2") * 3f));
            }
            if (Type == TYPE_SCALE)
            {
                map.ScaleMap((getValue("value1") - 0.5f) * 4, 2 * (getValue("value2") - 0.5f));
            }
            if (Type == TYPE_POWER)
            {
                map.Pow((getValue("value1") - 0.5f) * 3, 2 * (getValue("value2") - 0.5f));
            }
            if (Type == TYPE_CONTOURS)
            {
                map.Contour(getValue("value1") * 100f, 4 * (getValue("value2") - 0.5f));
            }
            if (Type == TYPE_CLAMP)
            {
                map.Clamp(getValue("value1"), (getValue("value2")));
                ascale *= 5;
            }
            if (Type == TYPE_PIXEL)
            {
                map.Pixelate(getValue("value1"));
            }


            map.ScaleMap(getValue("amplitude") * ascale, 0);
            GenerateHeightTexture();
            if (Type != TYPE_SMOOTH)
            {
                CNodeManager.Progress();
            }
            updateTexture = true;

            changed = false;
        }