3 using SiliconStudio.Paradox.Effects.Modules;
4 using SiliconStudio.Paradox.Games;
5 using SiliconStudio.Paradox.Graphics;
6 using SiliconStudio.Core.Mathematics;
8 namespace SiliconStudio.
Paradox.Effects
15 private DelegateHolder<ThreadContext>.DelegateType startPassAction;
16 private DelegateHolder<ThreadContext>.DelegateType endPassAction;
31 ClearColor = Color.Black;
34 EnableClearTarget =
true;
35 EnableClearDepth =
true;
36 EnableSetTargets =
true;
90 public Color ClearColor {
get; set; }
98 public float ClearDepth {
get; set; }
106 public byte ClearStencil {
get; set; }
122 public bool EnableClearTarget {
get; set; }
130 public bool EnableClearDepth {
get; set; }
138 public bool EnableSetTargets {
get; set; }
145 get {
return Parameters.TryGet(EffectPlugin.DepthStencilStateKey); }
146 set { Parameters.Set(EffectPlugin.DepthStencilStateKey, value); }
155 public bool UseDepthStencilReadOnly {
get; set; }
161 if (OfflineCompilation)
164 if (!Parameters.ContainsKey(
EffectPlugin.DepthStencilStateKey))
167 if (EnableSetTargets || EnableClearTarget || EnableClearDepth)
171 startPassAction = (threadContext) =>
173 if (threadContext.FirstContext)
175 if (EnableClearDepth &&
DepthStencil != null && !UseDepthStencilReadOnly)
176 threadContext.GraphicsDevice.Clear(
DepthStencil, DepthStencilClearOptions.DepthBuffer, ClearDepth, ClearStencil);
178 threadContext.GraphicsDevice.Clear(
RenderTarget, ClearColor);
181 if (EnableSetTargets)
187 var desc =
RenderTarget != null ? RenderTarget.Description : threadContext.GraphicsDevice.BackBuffer.Description;
188 viewPort =
new Viewport(0, 0, desc.Width, desc.Height);
192 var depthStencil = UseDepthStencilReadOnly ? DepthStencilReadOnly :
DepthStencil;
194 threadContext.GraphicsDevice.SetViewport(viewPort);
195 threadContext.GraphicsDevice.SetRenderTargets(depthStencil,
RenderTarget);
198 RenderPass.StartPass += startPassAction;
202 if (EnableSetTargets)
204 endPassAction = (threadContext) => threadContext.GraphicsDevice.UnsetRenderTargets();
205 RenderPass.EndPass += endPassAction;
213 if (OfflineCompilation)
216 RenderPass.StartPass -= startPassAction;
217 startPassAction = null;
219 RenderPass.EndPass -= endPassAction;
220 endPassAction = null;
A renderable texture view.
DepthStencilStateFactory DepthStencilStates
Gets the DepthStencilStateFactory factory.
Contains depth-stencil state for the device.
readonly DepthStencilState Default
A built-in state object with default settings for using a depth stencil buffer.
RenderTargetsPlugin(string name)
Initializes a new instance of the RenderTargetsPlugin class.
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.
RenderTargetsPlugin()
Initializes a new instance of the RenderTargetsPlugin class.
Defines the window dimensions of a render-target surface onto which a 3D volume projects.
Represents a 32-bit color (4 bytes) in the form of RGBA (in byte order: R, G, B, A).
A Texture 2D frontend to SharpDX.Direct3D11.Texture2D.
Level10 render pass using a depth buffer and a render target.
static readonly Viewport Empty
Empty value for an undefined viewport.