Beispiel #1
0
        // Called when the game should load its content
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            camera = new FreeCamera(new Vector3(1000, 650, 1000),
                                    MathHelper.ToRadians(45),
                                    MathHelper.ToRadians(-30),
                                    GraphicsDevice);

            Effect           effect = Content.Load <Effect>("Content/LightingEffect");
            LightingMaterial mat    = new LightingMaterial();

            for (int z = -1; z <= 1; z++)
            {
                for (int x = -1; x <= 1; x++)
                {
                    CModel model = new CModel(Content.Load <Model>("Content/teapot__cv1"),
                                              new Vector3(x * 500, 0, z * 500), Vector3.Zero,
                                              Vector3.One * 50, GraphicsDevice);

                    model.SetModelEffect(effect, true);
                    model.SetModelMaterial(mat);

                    model.Model.Meshes[0].MeshParts[0].Effect.Parameters["BasicTexture"].SetValue(
                        Content.Load <Texture2D>("Content/brick_texture_map"));
                    model.Model.Meshes[0].MeshParts[0].Effect.Parameters["TextureEnabled"].SetValue(true);

                    models.Add(model);
                }
            }

            CModel ground = new CModel(Content.Load <Model>("Content/ground"),
                                       Vector3.Zero, Vector3.Zero, Vector3.One, GraphicsDevice, false);

            //ground.SetModelEffect(effect, true);
            //ground.SetModelMaterial(mat);

            models.Add(ground);

            renderCapture = new RenderCapture(GraphicsDevice);
            postprocessor = new GaussianBlur(GraphicsDevice, Content, 2);

            depthEffect = Content.Load <Effect>("Content/DepthEffect");
            //depthCapture = new RenderCapture(GraphicsDevice, SurfaceFormat.HalfSingle);
            depthCapture = new RenderCapture(GraphicsDevice);

            blurCapture = new RenderCapture(GraphicsDevice, SurfaceFormat.Color);
            dof         = new DepthOfField(GraphicsDevice, Content);

            lastMouseState = Mouse.GetState();
        }
Beispiel #2
0
        public GaussianBlur(GraphicsDevice graphicsDevice, ContentManager Content,
                            float BlurAmount)
            : base(Content.Load <Effect>("GaussianBlur"), graphicsDevice)
        {
            this.blurAmount = BlurAmount;

            // Calculate weights/offsets for horizontal pass
            calcSettings(1.0f / (float)graphicsDevice.Viewport.Width, 0,
                         out weightsH, out offsetsH);

            // Calculate weights/offsets for vertical pass
            calcSettings(0, 1.0f / (float)graphicsDevice.Viewport.Height,
                         out weightsV, out offsetsV);

            capture = new RenderCapture(graphicsDevice);
        }
Beispiel #3
0
        // Called when the game should load its content
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            camera = new FreeCamera(new Vector3(1000, 650, 1000),
                                    MathHelper.ToRadians(45),
                                    MathHelper.ToRadians(-30),
                                    GraphicsDevice);

            Effect           effect = Content.Load <Effect>("Content/LightingEffect");
            LightingMaterial mat    = new LightingMaterial();

            for (int z = -1; z <= 1; z++)
            {
                for (int x = -1; x <= 1; x++)
                {
                    CModel model = new CModel(Content.Load <Model>("Content/glow_teapot__cv1"),
                                              new Vector3(x * 500, 0, z * 500), Vector3.Zero,
                                              Vector3.One * 5, GraphicsDevice);

                    model.SetModelEffect(effect, true);
                    model.SetModelMaterial(mat);

                    models.Add(model);
                }
            }

            CModel ground = new CModel(Content.Load <Model>("Content/glow_plane__cv1"),
                                       Vector3.Zero, Vector3.Zero, Vector3.One * 6, GraphicsDevice);

            ground.SetModelEffect(effect, true);
            ground.SetModelMaterial(mat);

            models.Add(ground);

            renderCapture = new RenderCapture(GraphicsDevice);
            glowCapture   = new RenderCapture(GraphicsDevice);

            glowEffect = Content.Load <Effect>("Content/GlowEffect");
            glowEffect.Parameters["GlowTexture"].SetValue(
                Content.Load <Texture2D>("Content/glow_map"));

            blur = new GaussianBlur(GraphicsDevice, Content, 4);

            lastMouseState = Mouse.GetState();
        }
Beispiel #4
0
        // Called when the game should load its content
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            camera = new FreeCamera(new Vector3(1000, 650, 1000),
                                    MathHelper.ToRadians(45),
                                    MathHelper.ToRadians(-30),
                                    GraphicsDevice);

            Effect           effect = Content.Load <Effect>("LightingEffect");
            LightingMaterial mat    = new LightingMaterial();

            for (int z = -1; z <= 1; z++)
            {
                for (int x = -1; x <= 1; x++)
                {
                    CModel model = new CModel(Content.Load <Model>("teapot"),
                                              new Vector3(x * 500, 0, z * 500), Vector3.Zero,
                                              Vector3.One * 50, GraphicsDevice);

                    model.SetModelEffect(effect, true);
                    model.SetModelMaterial(mat);

                    model.Model.Meshes[0].MeshParts[0].Effect.Parameters["BasicTexture"].SetValue(
                        Content.Load <Texture2D>("brick_texture_map"));
                    model.Model.Meshes[0].MeshParts[0].Effect.Parameters["TextureEnabled"].SetValue(true);

                    models.Add(model);
                }
            }

            CModel ground = new CModel(Content.Load <Model>("ground"),
                                       Vector3.Zero, Vector3.Zero, Vector3.One, GraphicsDevice);

            ground.SetModelEffect(effect, true);
            ground.SetModelMaterial(mat);

            models.Add(ground);

            renderCapture = new RenderCapture(GraphicsDevice);
            postprocessor = new PostProcessor(Content.Load <Effect>("BWPostProcessor"),
                                              GraphicsDevice);

            lastMouseState = Mouse.GetState();
        }