示例#1
0
        //Constructor
        public SSAO(GraphicsDevice GraphicsDevice, ContentManager Content,
                    int Width, int Height)
        {
            //Load SSAO effect
            ssao = Content.Load <Effect>("Effects/SSAO");
            ssao.CurrentTechnique = ssao.Techniques[0];
            //Load SSAO Blur effect
            ssaoBlur = Content.Load <Effect>("Effects/SSAOBlur");
            ssaoBlur.CurrentTechnique = ssaoBlur.Techniques[0];
            //Load SSAO composition effect
            composer = Content.Load <Effect>("Effects/SSAOFinal");
            composer.CurrentTechnique = composer.Techniques[0];
            //Create SSAO Target
            SSAOTarget = new RenderTarget2D(GraphicsDevice, Width, Height, false,
                                            SurfaceFormat.Color, DepthFormat.None);
            //Create SSAO Blur Target
            BlurTarget = new RenderTarget2D(GraphicsDevice, Width, Height, false,
                                            SurfaceFormat.Color, DepthFormat.None);
            //Create FSQ
            fsq = new FullscreenQuad(GraphicsDevice);
            //Load Random Normal Texture
            randomNormals = Content.Load <Texture2D>("null_normal");

            //Set Sample Radius to Default
            sampleRadius = 0;
            //Set Distance Scale to Default
            distanceScale = 0;
        }
示例#2
0
        public DeferredRenderer(GraphicsDevice GraphicsDevice, ContentManager Content,
                                int Width, int Height)
        {
            //Load Clear Shader
            Clear = Content.Load <Effect>("Effects/Clear");
            Clear.CurrentTechnique = Clear.Techniques[0];

            //Load GBuffer Shader
            GBuffer = Content.Load <Effect>("Effects/GBuffer");
            GBuffer.CurrentTechnique = GBuffer.Techniques[0];

            //Load Directional Light Shader
            directionalLight = Content.Load <Effect>("Effects/DirectionalLight");
            directionalLight.CurrentTechnique = directionalLight.Techniques[0];

            //Load Point Light Shader
            pointLight = Content.Load <Effect>("Effects/PointLight");
            pointLight.CurrentTechnique = pointLight.Techniques[0];

            //Load Spot Light Shader
            spotLight = Content.Load <Effect>("Effects/SpotLight");
            spotLight.CurrentTechnique = spotLight.Techniques[0];

            //Load Composition Shader
            compose = Content.Load <Effect>("Effects/Composition");
            compose.CurrentTechnique = compose.Techniques[0];

            //Create LightMap BlendState
            LightMapBS = new BlendState();
            LightMapBS.ColorSourceBlend      = Blend.One;
            LightMapBS.ColorDestinationBlend = Blend.One;
            LightMapBS.ColorBlendFunction    = BlendFunction.Add;
            LightMapBS.AlphaSourceBlend      = Blend.One;
            LightMapBS.AlphaDestinationBlend = Blend.One;
            LightMapBS.AlphaBlendFunction    = BlendFunction.Add;

            //Set GBuffer Texture Size
            GBufferTextureSize = new Vector2(Width, Height);

            //Initialize GBuffer Targets Array
            GBufferTargets = new RenderTargetBinding[3];

            //Intialize Each Target of the GBuffer
            GBufferTargets[0] = new RenderTargetBinding(new RenderTarget2D(GraphicsDevice,
                                                                           Width, Height, false,
                                                                           SurfaceFormat.Rgba64,
                                                                           DepthFormat.Depth24Stencil8));
            GBufferTargets[1] = new RenderTargetBinding(new RenderTarget2D(GraphicsDevice,
                                                                           Width, Height, false,
                                                                           SurfaceFormat.Rgba64,
                                                                           DepthFormat.Depth24Stencil8));
            GBufferTargets[2] = new RenderTargetBinding(new RenderTarget2D(GraphicsDevice,
                                                                           Width, Height, false,
                                                                           SurfaceFormat.Vector2,
                                                                           DepthFormat.Depth24Stencil8));

            //Initialize LightMap
            LightMap = new RenderTarget2D(GraphicsDevice, Width, Height, false,
                                          SurfaceFormat.Color, DepthFormat.Depth24Stencil8);

            //Create Fullscreen Quad
            fsq = new FullscreenQuad(GraphicsDevice);

            //Load Point Light Geometry
            pointLightGeometry = Content.Load <Model>("sphere");

            //Load Spot Light Geometry
            //spotLightGeometry = Content.Load<Model>("SpotLightGeometry");
        }