Пример #1
0
    public static GameObject CreateCloud()
    {
        GameObject cloudObject = new GameObject("Cloud");

        //cloudObject.transform.position = planetObject.transform.position;
        //cloudObject.transform.parent = planetObject.transform;
        //cloudObject.AddComponent<Clouds> ();

        cloudObject.AddComponent <MeshFilter> ().mesh = SolarBodyGeneration.GetSphereMesh();
        cloudObject.transform.localScale = new Vector3(1.03f, 1.03f, 1.03f);

        int   pixWidthC  = 128;
        int   pixHeightC = 128;
        int   scaleC     = 10;
        float xOrgC      = Random.Range(0, 999.9f);
        float yOrgC      = Random.Range(0, 999.9f);

        cloudObject.AddComponent <MeshRenderer> ();

        //r = gameObject.GetComponent<MeshRenderer> ();

        //noiseTex = new Texture2D (pixWidth, pixHeight);
        //pix = new Color[noiseTex.width * noiseTex.height];

        //r.material.mainTexture = noiseTex;

        //NewCloud (_scale,_rotationSpeed);



        MeshRenderer mr = cloudObject.GetComponent <MeshRenderer> ();



        mr.material.mainTexture = Noise.CalculatePerlinNoise(pixWidthC, pixHeightC, scaleC, xOrgC, yOrgC, PlanetColour.GetCloudColour());


        mr.material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
        mr.material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
        mr.material.SetInt("_ZWrite", 0);
        mr.material.DisableKeyword("_ALPHATEST_ON");
        mr.material.EnableKeyword("_ALPHABLEND_ON");
        mr.material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
        mr.material.renderQueue = 3000;

        return(cloudObject);
    }