예제 #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);
        }
예제 #2
0
            public static EntityBuilder <Player> UntrackedPlayer()
            {
                var texture = Core.Content.Load <Texture2D>(Content.Textures.Test);

                var sprite = new SpriteRenderer(texture)
                             .SetRenderLayer(Constants.RenderLayerPlayer)
                             .SetMaterial(new DeferredSpriteMaterial(TextureUtils.CreateNormalMap(texture, TextureUtils.EdgeDetectionFilter.FiveTap)));

                var light = new PointLight(Color.White)
                            .SetRadius(250f)
                            .SetIntensity(1.8f)
                            .SetZPosition(2);

                light.RenderLayer = Constants.RenderLayerLight;

                return(new EntityBuilder <Player>()
                       .With <Velocity>()
                       .With <Mover>()
                       .With(new CircleCollider(4f))
                       .With <PlayerCollisionTriggerListener>()
                       .With(light)
                       .With(sprite));
            }