public DeferredTransparency()
 {
     _copyTexture = new Material(Content.Load<Effect>("CopyTexture").Clone(), "Copy");
     _copyTextureWithStencil = new Material(Content.Load<Effect>("CopyTexture").Clone(), "CopyWithStencil");
     _clearGBuffer = new Material(Content.Load<Effect>("ClearGBuffer").Clone(), "Clear_NormalsDiffuse");
     _restoreDepth = new Material(Content.Load<Effect>("RestoreDepth"));
 }
Beispiel #2
0
        protected override void BeginTransitionOn()
        {
            _material = _content.Load<Material>("Red");
            _quad = new Quad(_device);
            _metadata = new NamedBoxCollection();

            base.OnShown();
        }
Beispiel #3
0
        public LightingComponent(GraphicsDevice device)
        {
            _quad = new Quad(device);
            _quad.SetPosition(depth: 0.99999f);

            _restoreDepth = new Material(Content.Load<Effect>("RestoreDepth"));
            _copyTexture = new Material(Content.Load<Effect>("CopyTexture"));
        }
Beispiel #4
0
        public AntiAliasComponent(GraphicsDevice device, string inputResource = null)
        {
            _device = device;

            _fxaa = new Material(Content.Load<Effect>("FXAA"), "FXAA");
            _quad = new Quad(device);
            _inputResource = inputResource;
        }
Beispiel #5
0
 public Ssao(GraphicsDevice device)
 {
     _ssaoMaterial = new Material(Content.Load<Effect>("SSAO"));
     _ssaoBlurMaterial = new Material(Content.Load<Effect>("BlurSSAO"));
     Random rand = new Random();
     _ssaoMaterial.Parameters["Random"].SetValue(GenerateRandomNormals(device, 4, 4, rand));//content.Load<Texture2D>("randomnormals"));
     _ssaoMaterial.Parameters["RandomResolution"].SetValue(4);
     _quad = new Quad(device);
 }
Beispiel #6
0
 public Ssao(GraphicsDevice device)
 {
     this.ssaoMaterial = new Material(Content.Load<Effect>("SSAO"));
     this.ssaoBlurMaterial = new Material(Content.Load<Effect>("BlurSSAO"));
     this.ssaoMaterial.Parameters["Random"].SetValue(GenerateRandomNormals(device, 4, 4));//content.Load<Texture2D>("randomnormals"));
     this.ssaoMaterial.Parameters["RandomResolution"].SetValue(4);
     this.ssaoMaterial.Parameters["Samples"].SetValue(GenerateRandomSamplePositions(16));
     this.gaussian = new Gaussian(device);
     this.quad = new Quad(device);
 }
        protected override void BeginTransitionOn()
        {
            _material = new Material(_content.Load<Effect>("Basic"), null);
            _quad = new Quad(_device);
            _metadata = new NamedBoxCollection();

            _metadata.Set(new TypedName<Vector4>("colour"), Color.White.ToVector4().FromXNA());

            base.OnShown();
        }
Beispiel #8
0
        internal static void PerformLightingPass(Renderer renderer, bool ssao, Quad quad, Material restoreDepth, Material copyTexture, IReadOnlyList<IDirectLight> directLights, IReadOnlyList<IIndirectLight> indirectLights, out RenderTarget2D directLightBuffer, out RenderTarget2D indirectLightBuffer)
        {
            //Get some handy objects
            var device = renderer.Device;
            var resolution = renderer.Data.GetValue(new TypedName<Vector2>("resolution"));
            var width = (int)resolution.X;
            var height = (int)resolution.Y;

            //Enable or disable SSAO
            renderer.Data.Set("ssao", ssao);

            // prepare direct lights
            for (int i = 0; i < directLights.Count; i++)
                directLights[i].Prepare(renderer);

            // set and clear direct light buffer
            directLightBuffer = RenderTargetManager.GetTarget(device, width, height, SurfaceFormat.HdrBlendable, DepthFormat.Depth24Stencil8);
            device.SetRenderTarget(directLightBuffer);
            device.Clear(Color.Transparent);

            // work around for a bug in xna 4.0
            renderer.Device.SamplerStates[0] = SamplerState.LinearClamp;
            renderer.Device.SamplerStates[0] = SamplerState.PointClamp;

            // set render states to draw opaque geometry
            device.BlendState = BlendState.Opaque;
            device.DepthStencilState = DepthStencilState.Default;

            // restore depth
            quad.Draw(restoreDepth, renderer.Data);

            // set render states to additive blend
            device.BlendState = BlendState.Additive;

            // draw direct lights
            foreach (IDirectLight light in directLights)
                light.Draw(renderer);

            // prepare indirect lights
            for (int i = 0; i < indirectLights.Count; i++)
                indirectLights[i].Prepare(renderer);

            // set and clear indirect light buffer
            indirectLightBuffer = RenderTargetManager.GetTarget(device, width, height, SurfaceFormat.HdrBlendable, DepthFormat.Depth24Stencil8);
            device.SetRenderTarget(indirectLightBuffer);
            device.Clear(Color.Transparent);

            //draw indirect lights
            foreach (IIndirectLight light in indirectLights)
                light.Draw(renderer);

            // blend direct lighting into the indirect light buffer
            copyTexture.Parameters["Texture"].SetValue(directLightBuffer);
            quad.Draw(copyTexture, renderer.Data);
        }
Beispiel #9
0
        public static void RestoreDepth(Renderer renderer, Quad quad, Material restoreDepth, bool clearDepth = true)
        {
            // work arround for a bug in xna 4.0
            renderer.Device.SamplerStates[0] = SamplerState.LinearClamp;
            renderer.Device.SamplerStates[0] = SamplerState.PointClamp;

            if (clearDepth)
                renderer.Device.Clear(ClearOptions.DepthBuffer, Color.Transparent, 1, 0);

            renderer.Device.DepthStencilState = DepthStencilState.Default;
            renderer.Device.BlendState = BlendState.Additive;
            quad.Draw(restoreDepth, renderer.Data);
        }
Beispiel #10
0
        public ToneMapComponent(GraphicsDevice device)
        {
            _quad = new Quad(device);
            var effect = Content.Load<Effect>("CalculateLuminance");
            _calculateLuminance = new Material(effect.Clone(), "ExtractLuminance");
            _adaptLuminance = new Material(effect.Clone(), "AdaptLuminance");
            _readLuminance = new Material(effect.Clone(), "ReadLuminance");
            _toneMap = new Material(Content.Load<Effect>("ToneMap"), null);
            _bloom = Content.Load<Effect>("Bloom");
            _gaussian = new Gaussian(device);

            _adaptedLuminance = new RenderTarget2D[2];
            _adaptedLuminance[0] = new RenderTarget2D(device, 1, 1, false, SurfaceFormat.Single, DepthFormat.None);
            _adaptedLuminance[1] = new RenderTarget2D(device, 1, 1, false, SurfaceFormat.Single, DepthFormat.None);
        }
Beispiel #11
0
        public override void Initialise(Renderer renderer, ResourceContext context)
        {
            _mixDecalMaterial = new Material(Content.Load<Effect>("DecalBufferMix").Clone(), "MixDecalBuffers");
            _quad = new Quad(renderer.Device);

            // define inputs
            context.DefineInput("gbuffer_normals");
            context.DefineInput("gbuffer_diffuse");
            context.DefineInput("decal_normals");
            context.DefineInput("decal_diffuse");

            // define outputs
            context.DefineOutput("gbuffer_normals");
            context.DefineOutput("gbuffer_diffuse");

            base.Initialise(renderer, context);
        }
Beispiel #12
0
        public ToneMapComponent(GraphicsDevice device)
        {
            quad = new Quad(device);
            var effect = Content.Load<Effect>("CalculateLuminance");
            calculateLuminance = new Material(effect.Clone(), "ExtractLuminance");
            adaptLuminance = new Material(effect.Clone(), "AdaptLuminance");
            readLuminance = new Material(effect.Clone(), "ReadLuminance");
            copyLuminance = new Material(effect.Clone(), "Copy");
            toneMap = new Material(Content.Load<Effect>("ToneMap"), null);
            bloom = Content.Load<Effect>("Bloom");
            gaussian = new Gaussian(device);
            scale = new Resample(device);

            adaptedLuminance = new RenderTarget2D[2];
            adaptedLuminance[0] = new RenderTarget2D(device, 1, 1, false, SurfaceFormat.Single, DepthFormat.None);
            adaptedLuminance[1] = new RenderTarget2D(device, 1, 1, false, SurfaceFormat.Single, DepthFormat.None);

            device.SetRenderTarget(adaptedLuminance[previous]);
            device.Clear(Color.Transparent);
            device.SetRenderTarget(null);
        }
Beispiel #13
0
 public void Draw(Material material, BoxedValueStore<string> parameters)
 {
     foreach (var pass in material.Begin(parameters))
     {
         pass.Apply();
         Draw();
     }
 }
Beispiel #14
0
 public RestoreDepthPhase(GraphicsDevice device)
 {
     _quad = new Quad(device);
     _restoreDepth = new Material(Content.Load<Effect>("RestoreDepth"));
     ClearDepth = true;
 }
 protected abstract void SetEffectParameters(Material e, RendererMetadata metadata);
 protected BasePostProcessComponent(GraphicsDevice device, Effect effect, string technique, SurfaceFormat format = SurfaceFormat.Color)
 {
     _effect = new Material(effect, technique);
     _format = format;
     _quad = new Quad(device);
 }
Beispiel #17
0
 public EdgeDetectComponent(GraphicsDevice device)
 {
     _edgeDetect = new Material(Content.Load<Effect>("EdgeDetect"));
     _quad = new Quad(device);
 }
 public AntiAliasComponent(GraphicsDevice device, string inputResource)
 {
     this.edgeBlur = new Material(Content.Load<Effect>("EdgeBlur"));
     this.quad = new Quad(device);
     this.inputResource = inputResource;
 }
Beispiel #19
0
        public AntiAliasComponent(string inputResource = null)
        {
            _fxaa = new Material(Content.Load<Effect>("FXAA"), "FXAA");

            _inputResource = inputResource;
        }
 public GeometryBufferComponent(GraphicsDevice device)
 {
     clear = new Material(Content.Load<Effect>("ClearGBuffer"));
     scale = new Resample(device);
     quad = new Quad(device);
 }
Beispiel #21
0
 public void Draw(Material material, NamedBoxCollection parameters)
 {
     foreach (var pass in material.Begin(parameters))
     {
         pass.Apply();
         Draw();
     }
 }
Beispiel #22
0
 void IGeometry.Draw(Material material, Renderer renderer)
 {
     Draw(renderer.Data);
 }
Beispiel #23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ParticleSystem"/> class.
 /// </summary>
 /// <param name="device">The device.</param>
 public ParticleSystem(GraphicsDevice device)
 {
     _device = device;
     _material = new Material(Content.Load<Effect>("ParticleSystem").Clone());
     Transform = Matrix4x4.Identity;
 }
Beispiel #24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ParticleSystem"/> class.
 /// </summary>
 /// <param name="device">The device.</param>
 public ParticleSystem(GraphicsDevice device)
 {
     this.device = device;
     this.material = new Material(Content.Load<Effect>("ParticleSystem").Clone());
     this.Capacity = 5;
 }
Beispiel #25
0
 public RestoreDepthPhase(GraphicsDevice device)
 {
     this.quad = new Quad(device);
     this.restoreDepth = new Material(Content.Load<Effect>("RestoreDepth").Clone());
     this.ClearDepth = true;
 }