示例#1
0
 public NebulaLayer()
 {
     blend = TextureTools.BlendingMode.Color;
     startColor = new Color(0,0,0);
     endColor= new Color(0,0,0);
     fractal = new Fractal();
     threshold = 0f;
     enable = true;
 }
示例#2
0
        public Color[] Render(Fractal.Face face, int quality)
        {
            //int size = Cosmos.instance.spaceBox.GetQuality2Int();

            Color[] colors = new Color[quality*quality];

            float[] rendu = FractalFactory.CreateNoiseTexture( fractal,face, quality);

            for( int i=0;i<rendu.Length;i++){

            float c=0;
            float min=0;
            float max=0;

            switch (blend){
            case TextureTools.BlendingMode.Color:
                c =  rendu[i];

                colors[i] = Color.Lerp( startColor,endColor,c*3);
                colors[i].a =  1;

                break;

            case TextureTools.BlendingMode.Alpha:
            case TextureTools.BlendingMode.Mask:
                min = 0f;
                max = threshold;
                c =  (((rendu[i]/2f) - min) / (max - min));
                if (c<0)c=0;
                if (c>1)c=1;
                colors[i] = Color.Lerp( startColor,endColor,c);
                colors[i].a =Mathf.Lerp( 0f,1f,c);

                break;
            }

            }

            return colors;
        }
示例#3
0
文件: Nebula.cs 项目: bjsvochak/hof16
        public Color[] Render(Fractal.Face face, int quality)
        {
            Color[] dest = new Color[quality*quality];

            foreach(NebulaLayer layer in layers){

            if (layer.enable) {

                Color[] source = layer.Render(face,quality);

                TextureTools.BlendingMode lastBend = TextureTools.BlendingMode.Color;

                for(int i=0;i<dest.Length;i++){
                    dest[i] = source[i] * TextureTools.GetBlendingFactor( layer.blend, source[i] , dest[i]) + dest[i] * TextureTools.GetBlendingFactor( lastBend, source[i] , dest[i]);
                    lastBend =  layer.blend;
                    dest[i].a=1;

                }
            }

            }
            for( int i=0;i<dest.Length;i++){
            dest[i] *= power;
            }

            dest[0]=dest[1];

            return dest;
        }