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")); }
protected override void BeginTransitionOn() { _material = _content.Load<Material>("Red"); _quad = new Quad(_device); _metadata = new NamedBoxCollection(); base.OnShown(); }
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")); }
public AntiAliasComponent(GraphicsDevice device, string inputResource = null) { _device = device; _fxaa = new Material(Content.Load<Effect>("FXAA"), "FXAA"); _quad = new Quad(device); _inputResource = inputResource; }
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); }
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(); }
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); }
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); }
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); }
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); }
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); }
public void Draw(Material material, BoxedValueStore<string> parameters) { foreach (var pass in material.Begin(parameters)) { pass.Apply(); Draw(); } }
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); }
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; }
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); }
public void Draw(Material material, NamedBoxCollection parameters) { foreach (var pass in material.Begin(parameters)) { pass.Apply(); Draw(); } }
void IGeometry.Draw(Material material, Renderer renderer) { Draw(renderer.Data); }
/// <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; }
/// <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; }
public RestoreDepthPhase(GraphicsDevice device) { this.quad = new Quad(device); this.restoreDepth = new Material(Content.Load<Effect>("RestoreDepth").Clone()); this.ClearDepth = true; }