Ejemplo n.º 1
0
        public override TextureContent Process(TextureContent input, ContentProcessorContext context)
        {
            Logger = context.Logger;
            Logger.LogMessage("sending texture to base TextureProcessor for initial processing");

            var textureContent = base.Process(input, context);
            var bmp            = (PixelBitmapContent <Color>)textureContent.Faces[0][0];
            var destData       = bmp.GetData();

            // process the data
            if (FlattenImage)
            {
                Logger.LogMessage("flattening image");
                destData = TextureUtils.CreateFlatHeightmap(destData, OpaqueColor, TransparentColor);
            }

            if (BlurType != BlurType.None)
            {
                Logger.LogMessage("blurring image width blurDeviation: {0}", BlurDeviation);
                if (BlurType == BlurType.Color)
                {
                    destData = TextureUtils.CreateBlurredTexture(destData, bmp.Width, bmp.Height,
                                                                 (double)BlurDeviation);
                }
                else
                {
                    destData = TextureUtils.CreateBlurredGrayscaleTexture(destData, bmp.Width, bmp.Height,
                                                                          (double)BlurDeviation);
                }
            }

            Logger.LogMessage("generating normal map with {0}", EdgeDetectionFilter);
            destData = TextureUtils.CreateNormalMap(destData, EdgeDetectionFilter, bmp.Width, bmp.Height,
                                                    NormalStrength, InvertX, InvertY);

            bmp.SetData(destData);

            return(textureContent);
        }