5 using SiliconStudio.Core;
6 using SiliconStudio.Core.Mathematics;
7 using SiliconStudio.Core.Serialization.Assets;
8 using SiliconStudio.Paradox.Graphics;
10 namespace SiliconStudio.
Paradox.Effects.Images
17 private readonly
Texture[] inputTextures;
18 private int maxInputTextureIndex;
34 if (context == null)
throw new ArgumentNullException(
"context");
38 Assets = context.Services.GetSafeServiceAs<
AssetManager>();
39 Name = name ?? GetType().Name;
41 inputTextures =
new Texture[128];
42 maxInputTextureIndex = -1;
49 public bool Enabled {
get; set; }
76 if (slot < 0 || slot >= inputTextures.Length)
77 throw new ArgumentOutOfRangeException(
"slot",
"slot must be in the range [0, 128[");
79 inputTextures[slot] = texture;
80 if (slot > maxInputTextureIndex)
82 maxInputTextureIndex = slot;
91 maxInputTextureIndex = -1;
92 Array.Clear(inputTextures, 0, inputTextures.Length);
103 if (view == null)
throw new ArgumentNullException(
"view");
105 SetOutputInternal(view, depthStencilBuffer);
114 if (views == null)
throw new ArgumentNullException(
"views");
116 SetOutputInternal(null, views);
128 if (views == null)
throw new ArgumentNullException(
"views");
130 SetOutputInternal(depthStencilBuffer, views);
136 public void Draw(
string name = null)
154 return string.Format(
"Effect {0}", Name);
163 GraphicsDevice.BeginProfile(Color.Green, name ?? Name);
165 if (outputRenderTargetView != null)
167 GraphicsDevice.SetRenderTarget(outputDepthStencilBuffer, outputRenderTargetView);
169 else if (outputRenderTargetViews != null)
171 GraphicsDevice.SetRenderTargets(outputDepthStencilBuffer, outputRenderTargetViews);
180 GraphicsDevice.EndProfile();
194 protected int InputCount
198 return maxInputTextureIndex + 1;
210 if (index < 0 || index > maxInputTextureIndex)
212 throw new ArgumentOutOfRangeException(
"index",
string.Format(
"Invald texture input index [{0}]. Max value is [{1}]", index, maxInputTextureIndex));
214 return inputTextures[index];
225 var input = GetInput(index);
228 throw new InvalidOperationException(
string.Format(
"Expecting texture input on slot [{0}]", index));
238 protected int OutputCount
242 return outputRenderTargetView != null ? 1 : outputRenderTargetViews != null ? outputRenderTargetViews.Length : 0;
256 throw new ArgumentOutOfRangeException(
"index",
string.Format(
"Invald texture outputindex [{0}] cannot be negative for effect [{1}]", index, Name));
259 return outputRenderTargetView ?? (outputRenderTargetViews != null ? outputRenderTargetViews[index] : null);
270 var output = GetOutput(index);
273 throw new InvalidOperationException(
string.Format(
"Expecting texture output on slot [{0}]", index));
282 outputDepthStencilBuffer = depthStencilBuffer;
283 outputRenderTargetView = view;
284 outputRenderTargetViews = null;
290 outputDepthStencilBuffer = depthStencilBuffer;
291 outputRenderTargetView = null;
292 outputRenderTargetViews = views;
void SetOutput(DepthStencilBuffer depthStencilBuffer, params RenderTarget[] views)
Sets the render target outputs.
override string ToString()
Returns a System.String that represents this instance.
A renderable texture view.
void Draw(string name=null)
Draws a full screen quad using iterating on each pass of this effect.
void SetOutput(RenderTarget view, DepthStencilBuffer depthStencilBuffer=null)
Sets the render target output.
RenderTarget GetOutput(int index)
Gets an output render target for the specified index.
void ResetInputs()
Resets the input textures.
Base class for a framework component.
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.
ImageEffectBase(ImageEffectContext context, string name=null)
Initializes a new instance of the ImageEffectBase class.
void SetOutput(params RenderTarget[] views)
Sets the render target outputs.
virtual void PreDrawCore(string name)
Prepare call before DrawCore.
Texture GetInput(int index)
Gets an input texture by the specified index.
Context for post effects.
Texture GetSafeInput(int index)
Gets a non-null input texture by the specified index.
RenderTarget GetSafeOutput(int index)
Gets an non-null output render target for the specified index.
virtual void PostDrawCore()
Posts call after DrawCore
void SetInput(int slot, Texture texture)
Sets an input texture
virtual void DrawCore()
Draws this post effect for a specific pass, implementation dependent.
Base class for texture resources.