/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Load a font object. m_font = Content.Load <SpriteFont>("Fonts/Verdana"); // Create a screen-UI. m_screenUI = new SpriteBatch(GraphicsDevice); // Load scene objects from scene description. m_sceneRoot = SceneObject.CreateFromSceneDescription(Content, m_scene); // Set up camera. m_sceneCamera = new Camera(); // Create renderer. m_renderer = new LightPrePassRenderer(m_graphics.GraphicsDevice, Content, m_sceneCamera); m_renderer.OutputRenderTargetWidth = Window.ClientBounds.Width; m_renderer.OutputRenderTargetHeight = Window.ClientBounds.Height; Window.ClientSizeChanged += new EventHandler <EventArgs>(OnWindowClientSizeChanged); // Set up camera controller. m_cameraController = new FlyCameraController(m_sceneCamera, Window); m_cameraController.MovementSpeed = 20.0f; m_cameraController.RotationSpeed = 0.1f; m_cameraController.SetCameraProjectionParameters(MathHelper.PiOver4, m_renderer.OutputRenderTargetAspectRatio, 0.1f, 1000); // Add scene objects. m_renderer.AddScene(m_sceneRoot); }
public override void OnGUI(GUI ui) { base.OnGUI(ui); if (m_renderer == null) { m_renderer = Application.Engine.Renderer as LightPrePassRenderer; if (m_renderer == null) { return; } } var width = 320; var height = 200; GUI.Skin.TextColor = Color.White; ui.DrawTexture(new Rectangle(0, 0, width, height), m_BorderTexture); ui.DrawTexture(new Rectangle(2, 2, width - 4, height - 4), m_renderer.DepthBuffer); ui.DrawTexture(new Rectangle(0, height, width, height), m_BorderTexture); ui.DrawTexture(new Rectangle(2, 2 + height, width - 4, height - 4), m_renderer.NormalBuffer); ui.DrawTexture(new Rectangle(0, height * 2, width, height), m_BorderTexture); ui.DrawTexture(new Rectangle(2, 2 + height * 2, width - 4, height - 4), m_renderer.LightBuffer); ui.Label(new Vector2(5, height - 25), "Depth Buffer"); ui.Label(new Vector2(5, 2 * height - 25), "Normal Buffer"); ui.Label(new Vector2(5, 3 * height - 25), "Lights Buffer"); }