/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); projectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, screenWidth / screenHeight, 1.0f, 100.0f); renderTargetBindings = new RenderTargetBinding[3]; renderTargetBindings[0] = new RenderTargetBinding(new RenderTarget2D(GraphicsDevice, screenWidth, screenHeight, false, SurfaceFormat.Color, DepthFormat.Depth16)); //Color renderTargetBindings[1] = new RenderTargetBinding(new RenderTarget2D(GraphicsDevice, screenWidth, screenHeight, false, SurfaceFormat.Color, DepthFormat.Depth16)); //Normal renderTargetBindings[2] = new RenderTargetBinding(new RenderTarget2D(GraphicsDevice, screenWidth, screenHeight, false, SurfaceFormat.Single, DepthFormat.Depth16)); //Depth cubeMesh = Mesh.CreateCubeMesh(0.4f); bricks = Content.Load <Texture2D>("brickwork-texture"); bricksNormal = Content.Load <Texture2D>("brickwork_normal-map"); clearBufferEffect = Content.Load <Effect>("ClearGBuffer"); deferredRenderEffect = Content.Load <Effect>("DeferredRenderEffect"); deferredRenderEffect.Parameters["DiffuseTexture"].SetValue(bricks); deferredRenderEffect.Parameters["World"].SetValue(Matrix.Identity); deferredRenderEffect.Parameters["Projection"].SetValue(projectionMatrix); directionalLightEffect = Content.Load <Effect>("DirectionalLightEffect"); directionalLightEffect.Parameters["DiffuseMap"].SetValue(renderTargetBindings[0].RenderTarget); directionalLightEffect.Parameters["NormalMap"].SetValue(renderTargetBindings[1].RenderTarget); directionalLightEffect.Parameters["DepthMap"].SetValue(renderTargetBindings[2].RenderTarget); directionalLightEffect.Parameters["lightDirection"].SetValue(-Vector3.UnitY); directionalLightEffect.Parameters["Color"].SetValue(Color.BlueViolet.ToVector3()); directionalLightEffect.Parameters["halfPixel"].SetValue(new Vector2(0.5f / screenWidth, 0.5f / screenHeight)); quadRenderer = new QuadRenderComponent(this); //ship = Content.Load<Model>("Models/ship1"); //volleyBall = Content.Load<Model>("volleyBall"); //e = new BasicEffect(GraphicsDevice); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); projectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, screenWidth / screenHeight, 1.0f, 100.0f); renderTargetBindings = new RenderTargetBinding[3]; renderTargetBindings[0] = new RenderTargetBinding(new RenderTarget2D(GraphicsDevice, screenWidth, screenHeight, false, SurfaceFormat.Color, DepthFormat.Depth16));//Color renderTargetBindings[1] = new RenderTargetBinding(new RenderTarget2D(GraphicsDevice, screenWidth, screenHeight, false, SurfaceFormat.Color, DepthFormat.Depth16));//Normal renderTargetBindings[2] = new RenderTargetBinding(new RenderTarget2D(GraphicsDevice, screenWidth, screenHeight, false, SurfaceFormat.Single, DepthFormat.Depth16));//Depth cubeMesh = Mesh.CreateCubeMesh(0.4f); bricks = Content.Load<Texture2D>("brickwork-texture"); bricksNormal = Content.Load<Texture2D>("brickwork_normal-map"); clearBufferEffect = Content.Load<Effect>("ClearGBuffer"); deferredRenderEffect = Content.Load<Effect>("DeferredRenderEffect"); deferredRenderEffect.Parameters["DiffuseTexture"].SetValue(bricks); deferredRenderEffect.Parameters["World"].SetValue(Matrix.Identity); deferredRenderEffect.Parameters["Projection"].SetValue(projectionMatrix); directionalLightEffect = Content.Load<Effect>("DirectionalLightEffect"); directionalLightEffect.Parameters["DiffuseMap"].SetValue(renderTargetBindings[0].RenderTarget); directionalLightEffect.Parameters["NormalMap"].SetValue(renderTargetBindings[1].RenderTarget); directionalLightEffect.Parameters["DepthMap"].SetValue(renderTargetBindings[2].RenderTarget); directionalLightEffect.Parameters["lightDirection"].SetValue(-Vector3.UnitY); directionalLightEffect.Parameters["Color"].SetValue(Color.BlueViolet.ToVector3()); directionalLightEffect.Parameters["halfPixel"].SetValue(new Vector2(0.5f / screenWidth, 0.5f / screenHeight)); quadRenderer = new QuadRenderComponent(this); //ship = Content.Load<Model>("Models/ship1"); //volleyBall = Content.Load<Model>("volleyBall"); //e = new BasicEffect(GraphicsDevice); }