Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
PostEffectMeshPlugin.cs
Go to the documentation of this file.
1 using SiliconStudio.Paradox.Effects.Modules;
2 using SiliconStudio.Paradox.Games;
3 using SiliconStudio.Paradox.Graphics;
4 using SiliconStudio.Core;
5 using SiliconStudio.Core.Xaml.Markup;
6 
7 namespace SiliconStudio.Paradox.Effects
8 {
9  [ContentProperty("Effect")]
11  {
12  private EffectOld instantiatedEffect;
13  private EffectMesh effectMesh;
14  private Texture2D renderSource;
15 
16  public PostEffectMeshPlugin() : base(null)
17  {
18  ResizeFactor = 1.0f;
19  PixelFormat = PixelFormat.R8G8B8A8_UNorm;
20  }
21 
22  public float ResizeFactor { get; set; }
23 
24  public PixelFormat PixelFormat { get; set; }
25 
26  public EffectBuilder Effect { get; set; }
27 
28  public Texture2D RenderSource
29  {
30  get
31  {
32  if (renderSource == null)
33  renderSource = Texture2D.New(GraphicsDevice, (int)(RenderTarget.Width / ResizeFactor), (int)(RenderTarget.Height / ResizeFactor), PixelFormat, TextureFlags.ShaderResource | TextureFlags.RenderTarget);
34  return renderSource;
35  }
36  set { renderSource = value; }
37  }
38 
39  public RenderTarget RenderTarget { get; set; }
40 
41  public override void Load()
42  {
43  base.Load();
44 
45  Effect.Services = Services;
46  instantiatedEffect = Effect.InstantiatePermutation();
47 
48  // Create mesh
49  effectMesh = new EffectMesh(instantiatedEffect, null, "PostEffectMesh").KeepAliveBy(this);
50  effectMesh.Parameters.Set(TexturingKeys.Texture0, RenderSource);
51  effectMesh.Parameters.Set(RenderTargetKeys.RenderTarget, RenderTarget);
52 
53  effectMesh.EffectPass.RenderPass = RenderPass;
54 
55  // Register mesh for rendering
56  RenderSystem.GlobalMeshes.AddMesh(effectMesh);
57  }
58  }
59 }
override void Load()
Performs primitive-based rendering, creates resources, handles system-level variables, adjusts gamma ramp levels, and creates shaders. See The+GraphicsDevice+class to learn more about the class.
int Width
Gets the width in texel.
Definition: RenderTarget.cs:23
A Texture 2D frontend to SharpDX.Direct3D11.Texture2D.
Definition: Texture2D.cs:37
int Height
Gets the height in texel.
Definition: RenderTarget.cs:29
PostEffectMeshPlugin()
RenderPass is a hierarchy that defines how to collect and render meshes.
Definition: RenderPass.cs:19
PixelFormat
Defines various types of pixel formats.
Definition: PixelFormat.cs:32