Example #1
0
        /// <summary>
        /// Load content.
        /// </summary>
        public void LoadContent()
        {
            // Store graphics device
            this.graphicsDevice = core.GraphicsDevice;

            // Load rendering effects
            clearBufferEffect      = core.ContentManager.Load <Effect>("Effects/ClearGBuffer");
            finalCombineEffect     = core.ContentManager.Load <Effect>("Effects/CombineFinal");
            directionalLightEffect = core.ContentManager.Load <Effect>("Effects/DirectionalLight");
            pointLightEffect       = core.ContentManager.Load <Effect>("Effects/PointLight");
            emissiveLightEffect    = core.ContentManager.Load <Effect>("Effects/EmissiveLight");
            renderBillboards       = core.ContentManager.Load <Effect>("Effects/RenderBillboards");
            fxaaAntialiasing       = core.ContentManager.Load <Effect>("FXAA/fxaa");

            // Get render billboards parameters
            renderBillboards_Texture  = renderBillboards.Parameters["Texture"];
            renderBillboards_Position = renderBillboards.Parameters["Position"];
            renderBillboards_Size     = renderBillboards.Parameters["Size"];

            // Get point light parameters
            pointLight_colorMap             = pointLightEffect.Parameters["ColorMap"];
            pointLight_normalMap            = pointLightEffect.Parameters["NormalMap"];
            pointLight_depthMap             = pointLightEffect.Parameters["DepthMap"];
            pointLight_worldMatrix          = pointLightEffect.Parameters["World"];
            pointLight_viewMatrix           = pointLightEffect.Parameters["View"];
            pointLight_projectionMatrix     = pointLightEffect.Parameters["Projection"];
            pointLight_lightPosition        = pointLightEffect.Parameters["LightPosition"];
            pointLight_lightColor           = pointLightEffect.Parameters["Color"];
            pointLight_lightRadius          = pointLightEffect.Parameters["LightRadius"];
            pointLight_lightIntensity       = pointLightEffect.Parameters["LightIntensity"];
            pointLight_cameraPosition       = pointLightEffect.Parameters["CameraPosition"];
            pointLight_invertViewProjection = pointLightEffect.Parameters["InvertViewProjection"];
            pointLight_halfPixel            = pointLightEffect.Parameters["HalfPixel"];

            // Get directional light paramters
            directionalLight_colorMap             = directionalLightEffect.Parameters["ColorMap"];
            directionalLight_normalMap            = directionalLightEffect.Parameters["NormalMap"];
            directionalLight_depthMap             = directionalLightEffect.Parameters["DepthMap"];
            directionalLight_lightDirection       = directionalLightEffect.Parameters["LightDirection"];
            directionalLight_lightColor           = directionalLightEffect.Parameters["Color"];
            directionalLight_lightIntensity       = directionalLightEffect.Parameters["LightIntensity"];
            directionalLight_cameraPosition       = directionalLightEffect.Parameters["CameraPosition"];
            directionalLight_invertViewProjection = directionalLightEffect.Parameters["InvertViewProjection"];
            directionalLight_gBufferTextureSize   = directionalLightEffect.Parameters["GBufferTextureSize"];

            // Get emissive light parameters
            emissiveLight_ColorMap           = emissiveLightEffect.Parameters["colorMap"];
            emissiveLight_gBufferTextureSize = emissiveLightEffect.Parameters["GBufferTextureSize"];

            // Load light geometry
            pointLightGeometry = core.ContentManager.Load <Model>("Models/PointLightGeometry");
            spotLightGeometry  = core.ContentManager.Load <Model>("Models/SpotLightGeometry");

            // Load light textures
            spotLightCookie = core.ContentManager.Load <Texture2D>("Textures/SpotLightCookie");

            // Create billboard template
            CreateDaggerfallBillboardTemplate();

            // Create rendering classes
            fullScreenQuad = new FullScreenQuad(graphicsDevice);
            gBuffer        = new GBuffer(core);
            bloomProcessor = new BloomProcessor(core);

            // Load content
            skyDomeEffect = core.ContentManager.Load <Effect>("Effects/SkyDomeEffect");
            skyDomeModel  = core.ContentManager.Load <Model>("Models/SkyDomeModel");
            skyDomeModel.Meshes[0].MeshParts[0].Effect = skyDomeEffect.Clone();

            // Create factories
            cloudFactory = new CloudFactory(core);
            starFactory  = new StarFactory(core);

            // Wire up GraphicsDevice events
            graphicsDevice.DeviceReset += new EventHandler <EventArgs>(GraphicsDevice_DeviceReset);
            graphicsDevice.DeviceLost  += new EventHandler <EventArgs>(GraphicsDevice_DeviceLost);
        }